RGBDS syntax updates (#358)

New MACRO and DEF syntax
This commit is contained in:
vulcandth 2022-06-06 16:25:31 -05:00 committed by GitHub
parent d7808d110f
commit 6b5be9129c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
101 changed files with 958 additions and 958 deletions

View file

@ -1,122 +1,122 @@
; Macros to verify assumptions about the data or code
table_width: MACRO
CURRENT_TABLE_WIDTH = \1
IF _NARG == 2
REDEF CURRENT_TABLE_START EQUS "\2"
ELSE
REDEF CURRENT_TABLE_START EQUS "._table_width\@"
{CURRENT_TABLE_START}:
ENDC
MACRO table_width
DEF CURRENT_TABLE_WIDTH = \1
IF _NARG == 2
REDEF CURRENT_TABLE_START EQUS "\2"
ELSE
REDEF CURRENT_TABLE_START EQUS "._table_width\@"
{CURRENT_TABLE_START}:
ENDC
ENDM
assert_table_length: MACRO
x = \1
MACRO assert_table_length
DEF x = \1
ASSERT x * CURRENT_TABLE_WIDTH == @ - {CURRENT_TABLE_START}, \
"{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
ENDM
list_start: MACRO
list_index = 0
IF _NARG == 1
REDEF CURRENT_LIST_START EQUS "\1"
ELSE
REDEF CURRENT_LIST_START EQUS "._list_start\@"
{CURRENT_LIST_START}:
ENDC
MACRO list_start
DEF list_index = 0
IF _NARG == 1
REDEF CURRENT_LIST_START EQUS "\1"
ELSE
REDEF CURRENT_LIST_START EQUS "._list_start\@"
{CURRENT_LIST_START}:
ENDC
ENDM
li: MACRO
MACRO li
ASSERT !STRIN(\1, "@"), STRCAT("String terminator \"@\" in list entry: ", \1)
db \1, "@"
list_index += 1
DEF list_index += 1
ENDM
assert_list_length: MACRO
x = \1
MACRO assert_list_length
DEF x = \1
ASSERT x == list_index, \
"{CURRENT_LIST_START}: expected {d:x} entries, got {d:list_index}"
ENDM
nybble_array: MACRO
CURRENT_NYBBLE_ARRAY_VALUE = 0
CURRENT_NYBBLE_ARRAY_LENGTH = 0
IF _NARG == 1
REDEF CURRENT_NYBBLE_ARRAY_START EQUS "\1"
ELSE
REDEF CURRENT_NYBBLE_ARRAY_START EQUS "._nybble_array\@"
{CURRENT_NYBBLE_ARRAY_START}:
ENDC
MACRO nybble_array
DEF CURRENT_NYBBLE_ARRAY_VALUE = 0
DEF CURRENT_NYBBLE_ARRAY_LENGTH = 0
IF _NARG == 1
REDEF CURRENT_NYBBLE_ARRAY_START EQUS "\1"
ELSE
REDEF CURRENT_NYBBLE_ARRAY_START EQUS "._nybble_array\@"
{CURRENT_NYBBLE_ARRAY_START}:
ENDC
ENDM
nybble: MACRO
MACRO nybble
ASSERT 0 <= (\1) && (\1) < $10, "nybbles must be 0-15"
CURRENT_NYBBLE_ARRAY_VALUE = (\1) | (CURRENT_NYBBLE_ARRAY_VALUE << 4)
CURRENT_NYBBLE_ARRAY_LENGTH += 1
IF CURRENT_NYBBLE_ARRAY_LENGTH % 2 == 0
db CURRENT_NYBBLE_ARRAY_VALUE
CURRENT_NYBBLE_ARRAY_VALUE = 0
ENDC
DEF CURRENT_NYBBLE_ARRAY_VALUE = (\1) | (CURRENT_NYBBLE_ARRAY_VALUE << 4)
DEF CURRENT_NYBBLE_ARRAY_LENGTH += 1
IF CURRENT_NYBBLE_ARRAY_LENGTH % 2 == 0
db CURRENT_NYBBLE_ARRAY_VALUE
DEF CURRENT_NYBBLE_ARRAY_VALUE = 0
ENDC
ENDM
end_nybble_array: MACRO
IF CURRENT_NYBBLE_ARRAY_LENGTH % 2
db CURRENT_NYBBLE_ARRAY_VALUE << 4
ENDC
IF _NARG == 1
x = \1
ASSERT x == CURRENT_NYBBLE_ARRAY_LENGTH, \
"{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} nybbles, got {d:CURRENT_NYBBLE_ARRAY_LENGTH}"
x = (x + 1) / 2
ASSERT x == @ - {CURRENT_NYBBLE_ARRAY_START}, \
"{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} bytes"
ENDC
MACRO end_nybble_array
IF CURRENT_NYBBLE_ARRAY_LENGTH % 2
db CURRENT_NYBBLE_ARRAY_VALUE << 4
ENDC
IF _NARG == 1
DEF x = \1
ASSERT x == CURRENT_NYBBLE_ARRAY_LENGTH, \
"{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} nybbles, got {d:CURRENT_NYBBLE_ARRAY_LENGTH}"
DEF x = (x + 1) / 2
ASSERT x == @ - {CURRENT_NYBBLE_ARRAY_START}, \
"{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} bytes"
ENDC
ENDM
bit_array: MACRO
CURRENT_BIT_ARRAY_VALUE = 0
CURRENT_BIT_ARRAY_LENGTH = 0
IF _NARG == 1
REDEF CURRENT_BIT_ARRAY_START EQUS "\1"
ELSE
REDEF CURRENT_BIT_ARRAY_START EQUS "._bit_array\@"
{CURRENT_BIT_ARRAY_START}:
ENDC
MACRO bit_array
DEF CURRENT_BIT_ARRAY_VALUE = 0
DEF CURRENT_BIT_ARRAY_LENGTH = 0
IF _NARG == 1
REDEF CURRENT_BIT_ARRAY_START EQUS "\1"
ELSE
REDEF CURRENT_BIT_ARRAY_START EQUS "._bit_array\@"
{CURRENT_BIT_ARRAY_START}:
ENDC
ENDM
dbit: MACRO
MACRO dbit
ASSERT (\1) == 0 || (\1) == 1, "bits must be 0 or 1"
CURRENT_BIT_ARRAY_VALUE |= (\1) << (CURRENT_BIT_ARRAY_LENGTH % 8)
CURRENT_BIT_ARRAY_LENGTH += 1
IF CURRENT_BIT_ARRAY_LENGTH % 8 == 0
db CURRENT_BIT_ARRAY_VALUE
CURRENT_BIT_ARRAY_VALUE = 0
ENDC
DEF CURRENT_BIT_ARRAY_VALUE |= (\1) << (CURRENT_BIT_ARRAY_LENGTH % 8)
DEF CURRENT_BIT_ARRAY_LENGTH += 1
IF CURRENT_BIT_ARRAY_LENGTH % 8 == 0
db CURRENT_BIT_ARRAY_VALUE
DEF CURRENT_BIT_ARRAY_VALUE = 0
ENDC
ENDM
end_bit_array: MACRO
IF CURRENT_BIT_ARRAY_LENGTH % 8
db CURRENT_BIT_ARRAY_VALUE
ENDC
IF _NARG == 1
x = \1
ASSERT x == CURRENT_BIT_ARRAY_LENGTH, \
"{CURRENT_BIT_ARRAY_START}: expected {d:x} bits, got {d:CURRENT_BIT_ARRAY_LENGTH}"
x = (x + 7) / 8
ASSERT x == @ - {CURRENT_BIT_ARRAY_START}, \
"{CURRENT_BIT_ARRAY_START}: expected {d:x} bytes"
ENDC
MACRO end_bit_array
IF CURRENT_BIT_ARRAY_LENGTH % 8
db CURRENT_BIT_ARRAY_VALUE
ENDC
IF _NARG == 1
DEF x = \1
ASSERT x == CURRENT_BIT_ARRAY_LENGTH, \
"{CURRENT_BIT_ARRAY_START}: expected {d:x} bits, got {d:CURRENT_BIT_ARRAY_LENGTH}"
DEF x = (x + 7) / 8
ASSERT x == @ - {CURRENT_BIT_ARRAY_START}, \
"{CURRENT_BIT_ARRAY_START}: expected {d:x} bytes"
ENDC
ENDM
def_grass_wildmons: MACRO
MACRO def_grass_wildmons
;\1: encounter rate
CURRENT_GRASS_WILDMONS_RATE = \1
REDEF CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1"
DEF CURRENT_GRASS_WILDMONS_RATE = \1
REDEF CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1"
{CURRENT_GRASS_WILDMONS_LABEL}:
db \1
ENDM
end_grass_wildmons: MACRO
MACRO end_grass_wildmons
IF CURRENT_GRASS_WILDMONS_RATE == 0
ASSERT 1 == @ - {CURRENT_GRASS_WILDMONS_LABEL}, \
"def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected 1 byte"
@ -126,15 +126,15 @@ end_grass_wildmons: MACRO
ENDC
ENDM
def_water_wildmons: MACRO
MACRO def_water_wildmons
;\1: encounter rate
CURRENT_WATER_WILDMONS_RATE = \1
REDEF CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1"
DEF CURRENT_WATER_WILDMONS_RATE = \1
REDEF CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1"
{CURRENT_WATER_WILDMONS_LABEL}:
db \1
ENDM
end_water_wildmons: MACRO
MACRO end_water_wildmons
IF CURRENT_WATER_WILDMONS_RATE == 0
ASSERT 1 == @ - {CURRENT_WATER_WILDMONS_LABEL}, \
"def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected 1 byte"

View file

@ -1,20 +1,20 @@
; Syntactic sugar macros
lb: MACRO ; r, hi, lo
MACRO lb ; r, hi, lo
ld \1, ((\2) & $ff) << 8 + ((\3) & $ff)
ENDM
ldpal: MACRO
MACRO ldpal
ld \1, \2 << 6 | \3 << 4 | \4 << 2 | \5
ENDM
; Design patterns
dict: MACRO
IF \1 == 0
and a
ELSE
cp \1
ENDC
MACRO dict
IF \1 == 0
and a
ELSE
cp \1
ENDC
jp z, \2
ENDM

View file

@ -1,48 +1,48 @@
; Enumerate constants
const_def: MACRO
IF _NARG >= 1
const_value = \1
ELSE
const_value = 0
ENDC
IF _NARG >= 2
const_inc = \2
ELSE
const_inc = 1
ENDC
MACRO const_def
IF _NARG >= 1
DEF const_value = \1
ELSE
DEF const_value = 0
ENDC
IF _NARG >= 2
DEF const_inc = \2
ELSE
DEF const_inc = 1
ENDC
ENDM
const: MACRO
\1 EQU const_value
const_value += const_inc
MACRO const
DEF \1 EQU const_value
DEF const_value += const_inc
ENDM
shift_const: MACRO
\1 EQU 1 << const_value
const_value += const_inc
MACRO shift_const
DEF \1 EQU 1 << const_value
DEF const_value += const_inc
ENDM
const_skip: MACRO
if _NARG >= 1
const_value += const_inc * (\1)
else
const_value += const_inc
endc
MACRO const_skip
if _NARG >= 1
DEF const_value += const_inc * (\1)
else
DEF const_value += const_inc
endc
ENDM
const_next: MACRO
if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value)
fail "const_next cannot go backwards from {const_value} to \1"
else
const_value = \1
endc
MACRO const_next
if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value)
fail "const_next cannot go backwards from {const_value} to \1"
else
DEF const_value = \1
endc
ENDM
rb_skip: MACRO
IF _NARG == 1
rsset _RS + \1
ELSE
rsset _RS + 1
ENDC
MACRO rb_skip
IF _NARG == 1
rsset _RS + \1
ELSE
rsset _RS + 1
ENDC
ENDM

View file

@ -1,4 +1,4 @@
validate_coords: MACRO
MACRO validate_coords
IF _NARG >= 4
IF \1 >= \3
fail "x coord out of range"
@ -11,11 +11,11 @@ validate_coords: MACRO
ENDC
ENDM
hlcoord EQUS "coord hl,"
bccoord EQUS "coord bc,"
decoord EQUS "coord de,"
DEF hlcoord EQUS "coord hl,"
DEF bccoord EQUS "coord bc,"
DEF decoord EQUS "coord de,"
coord: MACRO
MACRO coord
; register, x, y[, origin]
validate_coords \2, \3
IF _NARG >= 4
@ -25,11 +25,11 @@ coord: MACRO
ENDC
ENDM
hlbgcoord EQUS "bgcoord hl,"
bcbgcoord EQUS "bgcoord bc,"
debgcoord EQUS "bgcoord de,"
DEF hlbgcoord EQUS "bgcoord hl,"
DEF bcbgcoord EQUS "bgcoord bc,"
DEF debgcoord EQUS "bgcoord de,"
bgcoord: MACRO
MACRO bgcoord
; register, x, y[, origin]
validate_coords \2, \3, BG_MAP_WIDTH, BG_MAP_HEIGHT
IF _NARG >= 4
@ -39,22 +39,22 @@ bgcoord: MACRO
ENDC
ENDM
hlowcoord EQUS "owcoord hl,"
bcowcoord EQUS "owcoord bc,"
deowcoord EQUS "owcoord de,"
DEF hlowcoord EQUS "owcoord hl,"
DEF bcowcoord EQUS "owcoord bc,"
DEF deowcoord EQUS "owcoord de,"
owcoord: MACRO
MACRO owcoord
; register, x, y, map width
ld \1, wOverworldMap + ((\2) + 3) + (((\3) + 3) * ((\4) + (3 * 2)))
ENDM
event_displacement: MACRO
MACRO event_displacement
; map width, x blocks, y blocks
dw (wOverworldMap + 7 + (\1) + ((\1) + 6) * ((\3) >> 1) + ((\2) >> 1))
db \3, \2
ENDM
dwcoord: MACRO
MACRO dwcoord
; x, y
validate_coords \1, \2
IF _NARG >= 3
@ -64,7 +64,7 @@ dwcoord: MACRO
ENDC
ENDM
ldcoord_a: MACRO
MACRO ldcoord_a
; x, y[, origin]
validate_coords \1, \2
IF _NARG >= 3
@ -74,7 +74,7 @@ ldcoord_a: MACRO
ENDC
ENDM
lda_coord: MACRO
MACRO lda_coord
; x, y[, origin]
validate_coords \1, \2
IF _NARG >= 3
@ -84,7 +84,7 @@ lda_coord: MACRO
ENDC
ENDM
dbmapcoord: MACRO
MACRO dbmapcoord
; x, y
db \2, \1
ENDM

View file

@ -1,71 +1,71 @@
; Value macros
percent EQUS "* $ff / 100"
DEF percent EQUS "* $ff / 100"
bcd2: MACRO
MACRO bcd2
dn ((\1) / 1000) % 10, ((\1) / 100) % 10
dn ((\1) / 10) % 10, (\1) % 10
ENDM
bcd3: MACRO
MACRO bcd3
dn ((\1) / 100000) % 10, ((\1) / 10000) % 10
dn ((\1) / 1000) % 10, ((\1) / 100) % 10
dn ((\1) / 10) % 10, (\1) % 10
ENDM
; used in data/pokemon/base_stats/*.asm
tmhm: MACRO
MACRO tmhm
; initialize bytes to 0
FOR n, (NUM_TM_HM + 7) / 8
_tm{d:n} = 0
ENDR
; set bits of bytes
REPT _NARG
IF DEF(\1_TMNUM)
n = (\1_TMNUM - 1) / 8
i = (\1_TMNUM - 1) % 8
_tm{d:n} |= 1 << i
ELSE
FAIL "\1 is not a TM or HM move"
ENDC
SHIFT
ENDR
; output bytes
FOR n, (NUM_TM_HM + 7) / 8
db _tm{d:n}
ENDR
FOR n, (NUM_TM_HM + 7) / 8
DEF _tm{d:n} = 0
ENDR
; set bits of bytes
REPT _NARG
IF DEF(\1_TMNUM)
DEF n = (\1_TMNUM - 1) / 8
DEF i = (\1_TMNUM - 1) % 8
DEF _tm{d:n} |= 1 << i
ELSE
FAIL "\1 is not a TM or HM move"
ENDC
SHIFT
ENDR
; output bytes
FOR n, (NUM_TM_HM + 7) / 8
db _tm{d:n}
ENDR
ENDM
; Constant data (db, dw, dl) macros
dbw: MACRO
MACRO dbw
db \1
dw \2
ENDM
dwb: MACRO
MACRO dwb
dw \1
db \2
ENDM
dn: MACRO ; nybbles
REPT _NARG / 2
db ((\1) << 4) | (\2)
SHIFT 2
ENDR
MACRO dn ; nybbles
REPT _NARG / 2
db ((\1) << 4) | (\2)
SHIFT 2
ENDR
ENDM
dba: MACRO ; dbw bank, address
REPT _NARG
dbw BANK(\1), \1
SHIFT
ENDR
MACRO dba ; dbw bank, address
REPT _NARG
dbw BANK(\1), \1
SHIFT
ENDR
ENDM
dab: MACRO ; dwb address, bank
REPT _NARG
dwb \1, BANK(\1)
SHIFT
ENDR
MACRO dab ; dwb address, bank
REPT _NARG
dwb \1, BANK(\1)
SHIFT
ENDR
ENDM

View file

@ -1,28 +1,28 @@
farcall: MACRO
MACRO farcall
ld b, BANK(\1)
ld hl, \1
call Bankswitch
ENDM
callfar: MACRO
MACRO callfar
ld hl, \1
ld b, BANK(\1)
call Bankswitch
ENDM
farjp: MACRO
MACRO farjp
ld b, BANK(\1)
ld hl, \1
jp Bankswitch
ENDM
jpfar: MACRO
MACRO jpfar
ld hl, \1
ld b, BANK(\1)
jp Bankswitch
ENDM
homecall: MACRO
MACRO homecall
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)
@ -34,7 +34,7 @@ homecall: MACRO
ld [MBC1RomBank], a
ENDM
homecall_sf: MACRO ; homecall but save flags by popping into bc instead of af
MACRO homecall_sf ; homecall but save flags by popping into bc instead of af
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)

View file

@ -1,22 +1,22 @@
RGB: MACRO
REPT _NARG / 3
dw palred (\1) + palgreen (\2) + palblue (\3)
SHIFT 3
ENDR
MACRO RGB
REPT _NARG / 3
dw palred (\1) + palgreen (\2) + palblue (\3)
SHIFT 3
ENDR
ENDM
palred EQUS "(1 << 0) *"
palgreen EQUS "(1 << 5) *"
palblue EQUS "(1 << 10) *"
DEF palred EQUS "(1 << 0) *"
DEF palgreen EQUS "(1 << 5) *"
DEF palblue EQUS "(1 << 10) *"
palettes EQUS "* PALETTE_SIZE"
palette EQUS "+ PALETTE_SIZE *"
color EQUS "+ PAL_COLOR_SIZE *"
DEF palettes EQUS "* PALETTE_SIZE"
DEF palette EQUS "+ PALETTE_SIZE *"
DEF color EQUS "+ PAL_COLOR_SIZE *"
tiles EQUS "* LEN_2BPP_TILE"
tile EQUS "+ LEN_2BPP_TILE *"
DEF tiles EQUS "* LEN_2BPP_TILE"
DEF tile EQUS "+ LEN_2BPP_TILE *"
dbsprite: MACRO
MACRO dbsprite
; x tile, y tile, x pixel, y pixel, vtile offset, attributes
db (\2 * TILE_WIDTH) % $100 + \4, (\1 * TILE_WIDTH) % $100 + \3, \5, \6
ENDM

View file

@ -1,32 +1,32 @@
predef_id: MACRO
MACRO predef_id
ld a, (\1Predef - PredefPointers) / 3
ENDM
predef: MACRO
MACRO predef
predef_id \1
call Predef
ENDM
predef_jump: MACRO
MACRO predef_jump
predef_id \1
jp Predef
ENDM
tx_pre_id: MACRO
MACRO tx_pre_id
ld a, (\1_id - TextPredefs) / 2 + 1
ENDM
tx_pre: MACRO
MACRO tx_pre
tx_pre_id \1
call PrintPredefTextID
ENDM
tx_pre_jump: MACRO
MACRO tx_pre_jump
tx_pre_id \1
jp PrintPredefTextID
ENDM
db_tx_pre: MACRO
MACRO db_tx_pre
db (\1_id - TextPredefs) / 2 + 1
ENDM

View file

@ -1,4 +1,4 @@
audio_header: MACRO
MACRO audio_header
db (_NARG - 2) << 6 | \2
dw \1_\2
IF _NARG > 2
@ -24,7 +24,7 @@ ENDM
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
const pitch_sweep_cmd ; $10
pitch_sweep: MACRO
MACRO pitch_sweep
db pitch_sweep_cmd
IF \2 < 0
db (\1 << 4) | (%1000 | (\2 * -1))
@ -41,8 +41,8 @@ ENDM
; fade: positive value means decrease in volume, negative value means increase in volume
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
square_note_cmd EQU sfx_note_cmd ; $20
square_note: MACRO
DEF square_note_cmd EQU sfx_note_cmd ; $20
MACRO square_note
db square_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@ -56,8 +56,8 @@ ENDM
; fade: positive value means decrease in volume, negative value means increase in volume
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
noise_note_cmd EQU sfx_note_cmd ; $20
noise_note: MACRO
DEF noise_note_cmd EQU sfx_note_cmd ; $20
MACRO noise_note
db noise_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@ -68,7 +68,7 @@ noise_note: MACRO
ENDM
; arguments: pitch, length [1, 16]
note: MACRO
MACRO note
db (\1 << 4) | (\2 - 1)
ENDM
@ -76,7 +76,7 @@ ENDM
; arguments: instrument [1, 19], length [1, 16]
const drum_note_cmd ; $b0
drum_note: MACRO
MACRO drum_note
db drum_note_cmd | (\2 - 1)
db \1
ENDM
@ -85,7 +85,7 @@ ENDM
; like drum_note but one 1 byte instead of 2
; can only be used with instruments 1-10, excluding 2
; unused
drum_note_short: MACRO
MACRO drum_note_short
db (\1 << 4) | (\2 - 1)
ENDM
@ -93,7 +93,7 @@ ENDM
; arguments: length [1, 16]
const rest_cmd ; $c0
rest: MACRO
MACRO rest
db rest_cmd | (\1 - 1)
ENDM
@ -104,7 +104,7 @@ ENDM
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
const note_type_cmd ; $d0
note_type: MACRO
MACRO note_type
db note_type_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@ -114,8 +114,8 @@ note_type: MACRO
ENDM
; arguments: speed [0, 15]
drum_speed_cmd EQU note_type_cmd ; $d0
drum_speed: MACRO
DEF drum_speed_cmd EQU note_type_cmd ; $d0
MACRO drum_speed
db drum_speed_cmd | \1
ENDM
@ -123,7 +123,7 @@ ENDM
; arguments: octave [1, 8]
const octave_cmd ; $e0
octave: MACRO
MACRO octave
db octave_cmd | (8 - \1)
ENDM
@ -131,7 +131,7 @@ ENDM
; when enabled, effective frequency used is incremented by 1
const toggle_perfect_pitch_cmd ; $e8
toggle_perfect_pitch: MACRO
MACRO toggle_perfect_pitch
db toggle_perfect_pitch_cmd
ENDM
@ -142,7 +142,7 @@ ENDM
; depth: amplitude of vibrato wave
; rate: frequency of vibrato wave
const vibrato_cmd ; $ea
vibrato: MACRO
MACRO vibrato
db vibrato_cmd
db \1
db (\2 << 4) | \3
@ -150,7 +150,7 @@ ENDM
; arguments: length [1, 256], octave [1, 8], pitch
const pitch_slide_cmd ; $eb
pitch_slide: MACRO
MACRO pitch_slide
db pitch_slide_cmd
db \1 - 1
db ((8 - \2) << 4) | \3
@ -158,7 +158,7 @@ ENDM
; arguments: duty cycle [0, 3] (12.5%, 25%, 50%, 75%)
const duty_cycle_cmd ; $ec
duty_cycle: MACRO
MACRO duty_cycle
db duty_cycle_cmd
db \1
ENDM
@ -170,27 +170,27 @@ ENDM
; if larger than $100, large note speed or note length values might cause overflow
; stored in big endian
const tempo_cmd ; $ed
tempo: MACRO
MACRO tempo
db tempo_cmd
db HIGH(\1), LOW(\1)
ENDM
; arguments: left output enable mask, right output enable mask
const stereo_panning_cmd ; $ee
stereo_panning: MACRO
MACRO stereo_panning
db stereo_panning_cmd
db (\1 << 4) | \2
ENDM
const unknownmusic0xef_cmd ; $ef
unknownmusic0xef: MACRO
MACRO unknownmusic0xef
db unknownmusic0xef_cmd
db \1
ENDM
; arguments: left master volume [0, 7], right master volume [0, 7]
const volume_cmd ; $f0
volume: MACRO
MACRO volume
db volume_cmd
db (\1 << 4) | \2
ENDM
@ -199,7 +199,7 @@ ENDM
; when enabled, the sfx data is interpreted as music data
const execute_music_cmd ; $f8
execute_music: MACRO
MACRO execute_music
db execute_music_cmd
ENDM
@ -207,27 +207,27 @@ ENDM
; arguments: duty cycle 1, duty cycle 2, duty cycle 3, duty cycle 4
const duty_cycle_pattern_cmd ; $fc
duty_cycle_pattern: MACRO
MACRO duty_cycle_pattern
db duty_cycle_pattern_cmd
db \1 << 6 | \2 << 4 | \3 << 2 | \4
ENDM
; arguments: address
const sound_call_cmd ; $fd
sound_call: MACRO
MACRO sound_call
db sound_call_cmd
dw \1
ENDM
; arguments: count, address
const sound_loop_cmd ; $fe
sound_loop: MACRO
MACRO sound_loop
db sound_loop_cmd
db \1
dw \2
ENDM
const sound_ret_cmd ; $ff
sound_ret: MACRO
MACRO sound_ret
db sound_ret_cmd
ENDM

View file

@ -1,7 +1,7 @@
;\1 = event index
;\2 = return result in carry instead of zero flag
CheckEvent: MACRO
event_byte = ((\1) / 8)
MACRO CheckEvent
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
IF _NARG > 1
@ -19,9 +19,9 @@ ENDM
;\1 = event index
CheckEventReuseA: MACRO
MACRO CheckEventReuseA
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDC
@ -31,10 +31,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
CheckEventAfterBranchReuseA: MACRO
event_byte = ((\2) / 8)
MACRO CheckEventAfterBranchReuseA
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDC
@ -45,7 +45,7 @@ ENDM
;\1 = reg
;\2 = event index
;\3 = event index this event is relative to (optional, this is needed when there is a fixed flag address)
EventFlagBit: MACRO
MACRO EventFlagBit
IF _NARG > 2
ld \1, ((\3) % 8) + ((\2) - (\3))
ELSE
@ -56,24 +56,24 @@ ENDM
;\1 = reg
;\2 = event index
EventFlagAddress: MACRO
event_byte = ((\2) / 8)
MACRO EventFlagAddress
DEF event_byte = ((\2) / 8)
ld \1, wEventFlags + event_byte
ENDM
;\1 = event index
CheckEventHL: MACRO
event_byte = ((\1) / 8)
MACRO CheckEventHL
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
ENDM
;\1 = event index
CheckEventReuseHL: MACRO
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO CheckEventReuseHL
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -83,18 +83,18 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
CheckEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
MACRO CheckEventForceReuseHL
DEF event_byte = ((\1) / 8)
bit (\1) % 8, [hl]
ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
CheckEventAfterBranchReuseHL: MACRO
event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO CheckEventAfterBranchReuseHL
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -103,8 +103,8 @@ ENDM
;\1 = event index
CheckAndSetEvent: MACRO
event_byte = ((\1) / 8)
MACRO CheckAndSetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
set (\1) % 8, [hl]
@ -112,8 +112,8 @@ ENDM
;\1 = event index
CheckAndResetEvent: MACRO
event_byte = ((\1) / 8)
MACRO CheckAndResetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
res (\1) % 8, [hl]
@ -121,7 +121,7 @@ ENDM
;\1 = event index
CheckAndSetEventA: MACRO
MACRO CheckAndSetEventA
ld a, [wEventFlags + ((\1) / 8)]
bit (\1) % 8, a
set (\1) % 8, a
@ -130,7 +130,7 @@ ENDM
;\1 = event index
CheckAndResetEventA: MACRO
MACRO CheckAndResetEventA
ld a, [wEventFlags + ((\1) / 8)]
bit (\1) % 8, a
res (\1) % 8, a
@ -139,17 +139,17 @@ ENDM
;\1 = event index
SetEvent: MACRO
event_byte = ((\1) / 8)
MACRO SetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
set (\1) % 8, [hl]
ENDM
;\1 = event index
SetEventReuseHL: MACRO
MACRO SetEventReuseHL
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -159,10 +159,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
SetEventAfterBranchReuseHL: MACRO
event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO SetEventAfterBranchReuseHL
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -172,8 +172,8 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
SetEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
MACRO SetEventForceReuseHL
DEF event_byte = ((\1) / 8)
set (\1) % 8, [hl]
ENDM
@ -181,7 +181,7 @@ ENDM
;\1 = event index
;\2 = event index
;\3, \4, ... = additional (optional) event indices
SetEvents: MACRO
MACRO SetEvents
SetEvent \1
REPT _NARG - 1
SetEventReuseHL \2
@ -191,17 +191,17 @@ ENDM
;\1 = event index
ResetEvent: MACRO
event_byte = ((\1) / 8)
MACRO ResetEvent
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
res (\1) % 8, [hl]
ENDM
;\1 = event index
ResetEventReuseHL: MACRO
MACRO ResetEventReuseHL
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -211,10 +211,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
ResetEventAfterBranchReuseHL: MACRO
event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
event_byte = ((\1) / 8)
MACRO ResetEventAfterBranchReuseHL
DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@ -224,8 +224,8 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
ResetEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
MACRO ResetEventForceReuseHL
DEF event_byte = ((\1) / 8)
res (\1) % 8, [hl]
ENDM
@ -233,7 +233,7 @@ ENDM
;\1 = event index
;\2 = event index
;\3 = event index (optional)
ResetEvents: MACRO
MACRO ResetEvents
ResetEvent \1
REPT _NARG - 1
ResetEventReuseHL \2
@ -244,9 +244,9 @@ ENDM
;\1 = start
;\2 = end
SetEventRange: MACRO
event_start_byte = ((\1) / 8)
event_end_byte = ((\2) / 8)
MACRO SetEventRange
DEF event_start_byte = ((\1) / 8)
DEF event_end_byte = ((\2) / 8)
IF event_end_byte < event_start_byte
FAIL "Incorrect argument order in SetEventRange."
@ -257,12 +257,12 @@ event_end_byte = ((\2) / 8)
or (1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))
ld [wEventFlags + event_start_byte], a
ELSE
event_fill_start = event_start_byte + 1
event_fill_count = event_end_byte - event_start_byte - 1
DEF event_fill_start = event_start_byte + 1
DEF event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
event_fill_start -= 1
event_fill_count += 1
DEF event_fill_start -= 1
DEF event_fill_count += 1
ELSE
ld a, [wEventFlags + event_start_byte]
or $ff - ((1 << ((\1) % 8)) - 1)
@ -270,7 +270,7 @@ event_fill_count += 1
ENDC
IF ((\2) % 8) == 7
event_fill_count += 1
DEF event_fill_count += 1
ENDC
IF event_fill_count == 1
@ -306,9 +306,9 @@ ENDM
;\1 = start
;\2 = end
;\3 = assume a is 0 if present
ResetEventRange: MACRO
event_start_byte = ((\1) / 8)
event_end_byte = ((\2) / 8)
MACRO ResetEventRange
DEF event_start_byte = ((\1) / 8)
DEF event_end_byte = ((\2) / 8)
IF event_end_byte < event_start_byte
FAIL "Incorrect argument order in ResetEventRange."
@ -319,12 +319,12 @@ event_end_byte = ((\2) / 8)
and ~((1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))) & $ff
ld [wEventFlags + event_start_byte], a
ELSE
event_fill_start = event_start_byte + 1
event_fill_count = event_end_byte - event_start_byte - 1
DEF event_fill_start = event_start_byte + 1
DEF event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
event_fill_start -= 1
event_fill_count += 1
DEF event_fill_start -= 1
DEF event_fill_count += 1
ELSE
ld a, [wEventFlags + event_start_byte]
and ~($ff - ((1 << ((\1) % 8)) - 1)) & $ff
@ -332,7 +332,7 @@ event_fill_count += 1
ENDC
IF ((\2) % 8) == 7
event_fill_count += 1
DEF event_fill_count += 1
ENDC
IF event_fill_count == 1
@ -375,10 +375,10 @@ ENDM
;\1 = event index 1
;\2 = event index 2
;\3 = try to reuse a (optional)
CheckBothEventsSet: MACRO
MACRO CheckBothEventsSet
IF ((\1) / 8) == ((\2) / 8)
IF (_NARG < 3) || (((\1) / 8) != event_byte)
event_byte = ((\1) / 8)
DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + ((\1) / 8)]
ENDC
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
@ -411,7 +411,7 @@ ENDM
; returns the complement of whether either event is set in Z flag
;\1 = event index 1
;\2 = event index 2
CheckEitherEventSet: MACRO
MACRO CheckEitherEventSet
IF ((\1) / 8) == ((\2) / 8)
ld a, [wEventFlags + ((\1) / 8)]
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
@ -441,7 +441,7 @@ ENDM
; for handling fixed event bits when events are inserted/removed
;\1 = event index
;\2 = fixed flag bit
AdjustEventBit: MACRO
MACRO AdjustEventBit
IF ((\1) % 8) != (\2)
add ((\1) % 8) - (\2)
ENDC

View file

@ -1,7 +1,7 @@
def_object_events: MACRO
REDEF _NUM_OBJECT_EVENTS EQUS "_NUM_OBJECT_EVENTS_\@"
MACRO def_object_events
REDEF _NUM_OBJECT_EVENTS EQUS "_NUM_OBJECT_EVENTS_\@"
db {_NUM_OBJECT_EVENTS}
{_NUM_OBJECT_EVENTS} = 0
DEF {_NUM_OBJECT_EVENTS} = 0
ENDM
;\1 x position
@ -13,7 +13,7 @@ ENDM
;\7 items only: item id
;\7 trainers only: trainer class/pokemon id
;\8 trainers only: trainer number/pokemon level
object_event: MACRO
MACRO object_event
db \3
db \2 + 4
db \1 + 4
@ -29,42 +29,42 @@ object_event: MACRO
ELSE
db \6
ENDC
{_NUM_OBJECT_EVENTS} += 1
DEF {_NUM_OBJECT_EVENTS} += 1
ENDM
def_warp_events: MACRO
REDEF _NUM_WARP_EVENTS EQUS "_NUM_WARP_EVENTS_\@"
MACRO def_warp_events
REDEF _NUM_WARP_EVENTS EQUS "_NUM_WARP_EVENTS_\@"
db {_NUM_WARP_EVENTS}
{_NUM_WARP_EVENTS} = 0
DEF {_NUM_WARP_EVENTS} = 0
ENDM
;\1 x position
;\2 y position
;\3 destination map (-1 = wLastMap)
;\4 destination warp id; starts at 1 (internally at 0)
warp_event: MACRO
MACRO warp_event
db \2, \1, \4 - 1, \3
_WARP_{d:{_NUM_WARP_EVENTS}}_X = \1
_WARP_{d:{_NUM_WARP_EVENTS}}_Y = \2
{_NUM_WARP_EVENTS} += 1
DEF _WARP_{d:{_NUM_WARP_EVENTS}}_X = \1
DEF _WARP_{d:{_NUM_WARP_EVENTS}}_Y = \2
DEF {_NUM_WARP_EVENTS} += 1
ENDM
def_bg_events: MACRO
REDEF _NUM_BG_EVENTS EQUS "_NUM_BG_EVENTS_\@"
MACRO def_bg_events
REDEF _NUM_BG_EVENTS EQUS "_NUM_BG_EVENTS_\@"
db {_NUM_BG_EVENTS}
{_NUM_BG_EVENTS} = 0
DEF {_NUM_BG_EVENTS} = 0
ENDM
;\1 x position
;\2 y position
;\3 sign id
bg_event: MACRO
MACRO bg_event
db \2, \1, \3
{_NUM_BG_EVENTS} += 1
DEF {_NUM_BG_EVENTS} += 1
ENDM
;\1 source map
def_warps_to: MACRO
MACRO def_warps_to
FOR n, _NUM_WARP_EVENTS
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
@ -73,18 +73,18 @@ ENDM
;\1 x position
;\2 y position
;\3 map width
warp_to: MACRO
MACRO warp_to
event_displacement \3, \1, \2
ENDM
;\1 first bit offset / first object id
def_trainers: MACRO
IF _NARG == 1
CURRENT_TRAINER_BIT = \1
ELSE
CURRENT_TRAINER_BIT = 1
ENDC
MACRO def_trainers
IF _NARG == 1
DEF CURRENT_TRAINER_BIT = \1
ELSE
DEF CURRENT_TRAINER_BIT = 1
ENDC
ENDM
;\1 event flag
@ -92,22 +92,22 @@ ENDM
;\3 TextBeforeBattle
;\4 TextAfterBattle
;\5 TextEndBattle
trainer: MACRO
_ev_bit = \1 % 8
_cur_bit = CURRENT_TRAINER_BIT % 8
MACRO trainer
DEF _ev_bit = \1 % 8
DEF _cur_bit = CURRENT_TRAINER_BIT % 8
ASSERT _ev_bit == _cur_bit, \
"Expected \1 to be bit {d:_cur_bit}, got {d:_ev_bit}"
db CURRENT_TRAINER_BIT
db \2 << 4
dw wEventFlags + (\1 - CURRENT_TRAINER_BIT) / 8
dw \3, \5, \4, \4
CURRENT_TRAINER_BIT += 1
DEF CURRENT_TRAINER_BIT += 1
ENDM
;\1 x position
;\2 y position
;\3 movement data
map_coord_movement: MACRO
MACRO map_coord_movement
dbmapcoord \1, \2
dw \3
ENDM
@ -117,10 +117,10 @@ ENDM
;\2 map id
;\3 tileset
;\4 connections: combo of NORTH, SOUTH, WEST, and/or EAST, or 0 for none
map_header: MACRO
CURRENT_MAP_WIDTH = \2_WIDTH
CURRENT_MAP_HEIGHT = \2_HEIGHT
CURRENT_MAP_OBJECT EQUS "\1_Object"
MACRO map_header
DEF CURRENT_MAP_WIDTH = \2_WIDTH
DEF CURRENT_MAP_HEIGHT = \2_HEIGHT
DEF CURRENT_MAP_OBJECT EQUS "\1_Object"
\1_h::
db \3
db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH
@ -131,7 +131,7 @@ CURRENT_MAP_OBJECT EQUS "\1_Object"
ENDM
; Comes after map_header and connection macros
end_map_header: MACRO
MACRO end_map_header
dw {CURRENT_MAP_OBJECT}
PURGE CURRENT_MAP_WIDTH, CURRENT_MAP_HEIGHT, CURRENT_MAP_OBJECT
ENDM
@ -142,63 +142,63 @@ ENDM
;\3 map id
;\4 offset of the target map relative to the current map
; (x offset for east/west, y offset for north/south)
connection: MACRO
MACRO connection
; Calculate tile offsets for source (current) and target maps
_src = 0
_tgt = (\4) + 3
IF _tgt < 2
_src = -_tgt
_tgt = 0
ENDC
; Calculate tile offsets for source (current) and target maps
DEF _src = 0
DEF _tgt = (\4) + 3
IF _tgt < 2
DEF _src = -_tgt
DEF _tgt = 0
ENDC
IF !STRCMP("\1", "north")
_blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
_map = _tgt
_win = (\3_WIDTH + 6) * \3_HEIGHT + 1
_y = \3_HEIGHT * 2 - 1
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
_len = \3_WIDTH
ENDC
IF !STRCMP("\1", "north")
DEF _blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
DEF _map = _tgt
DEF _win = (\3_WIDTH + 6) * \3_HEIGHT + 1
DEF _y = \3_HEIGHT * 2 - 1
DEF _x = (\4) * -2
DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
DEF _len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "south")
_blk = _src
_map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
_win = \3_WIDTH + 7
_y = 0
_x = (\4) * -2
_len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
_len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "south")
DEF _blk = _src
DEF _map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
DEF _win = \3_WIDTH + 7
DEF _y = 0
DEF _x = (\4) * -2
DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
IF _len > \3_WIDTH
DEF _len = \3_WIDTH
ENDC
ELIF !STRCMP("\1", "west")
_blk = (\3_WIDTH * _src) + \3_WIDTH - 3
_map = (CURRENT_MAP_WIDTH + 6) * _tgt
_win = (\3_WIDTH + 6) * 2 - 6
_y = (\4) * -2
_x = \3_WIDTH * 2 - 1
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
_len = \3_HEIGHT
ENDC
ELIF !STRCMP("\1", "west")
DEF _blk = (\3_WIDTH * _src) + \3_WIDTH - 3
DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt
DEF _win = (\3_WIDTH + 6) * 2 - 6
DEF _y = (\4) * -2
DEF _x = \3_WIDTH * 2 - 1
DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
DEF _len = \3_HEIGHT
ENDC
ELIF !STRCMP("\1", "east")
_blk = (\3_WIDTH * _src)
_map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
_win = \3_WIDTH + 7
_y = (\4) * -2
_x = 0
_len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
_len = \3_HEIGHT
ENDC
ELIF !STRCMP("\1", "east")
DEF _blk = (\3_WIDTH * _src)
DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
DEF _win = \3_WIDTH + 7
DEF _y = (\4) * -2
DEF _x = 0
DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
IF _len > \3_HEIGHT
DEF _len = \3_HEIGHT
ENDC
ELSE
fail "Invalid direction for 'connection'."
ENDC
ELSE
fail "Invalid direction for 'connection'."
ENDC
db \3
dw \2_Blocks + _blk

View file

@ -1,44 +1,44 @@
text EQUS "db TX_START," ; Start writing text.
next EQUS "db \"<NEXT>\"," ; Move a line down.
line EQUS "db \"<LINE>\"," ; Start writing at the bottom line.
para EQUS "db \"<PARA>\"," ; Start a new paragraph.
cont EQUS "db \"<CONT>\"," ; Scroll to the next line.
done EQUS "db \"<DONE>\"" ; End a text box.
prompt EQUS "db \"<PROMPT>\"" ; Prompt the player to end a text box (initiating some other event).
DEF text EQUS "db TX_START," ; Start writing text.
DEF next EQUS "db \"<NEXT>\"," ; Move a line down.
DEF line EQUS "db \"<LINE>\"," ; Start writing at the bottom line.
DEF para EQUS "db \"<PARA>\"," ; Start a new paragraph.
DEF cont EQUS "db \"<CONT>\"," ; Scroll to the next line.
DEF done EQUS "db \"<DONE>\"" ; End a text box.
DEF prompt EQUS "db \"<PROMPT>\"" ; Prompt the player to end a text box (initiating some other event).
page EQUS "db \"<PAGE>\"," ; Start a new Pokédex page.
dex EQUS "db \"<DEXEND>\", \"@\"" ; End a Pokédex entry.
DEF page EQUS "db \"<PAGE>\"," ; Start a new Pokédex page.
DEF dex EQUS "db \"<DEXEND>\", \"@\"" ; End a Pokédex entry.
; TextCommandJumpTable indexes (see home/text.asm)
const_def
const TX_START ; $00
text_start: MACRO
MACRO text_start
db TX_START
ENDM
const TX_RAM ; $01
text_ram: MACRO
MACRO text_ram
db TX_RAM
dw \1 ; address to read from
ENDM
const TX_BCD ; $02
text_bcd: MACRO
MACRO text_bcd
db TX_BCD
dw \1 ; address to read from
db \2 ; number of bytes + print flags
ENDM
const TX_MOVE ; $03
text_move: MACRO
MACRO text_move
db TX_MOVE
dw \1 ; address of the new location
ENDM
const TX_BOX ; $04
text_box: MACRO
MACRO text_box
; draw box
db TX_BOX
dw \1 ; address of upper left corner
@ -46,27 +46,27 @@ text_box: MACRO
ENDM
const TX_LOW ; $05
text_low: MACRO
MACRO text_low
db TX_LOW
ENDM
const TX_PROMPT_BUTTON ; $06
text_promptbutton: MACRO
MACRO text_promptbutton
db TX_PROMPT_BUTTON
ENDM
const TX_SCROLL ; $07
text_scroll: MACRO
MACRO text_scroll
db TX_SCROLL
ENDM
const TX_START_ASM ; $08
text_asm: MACRO
MACRO text_asm
db TX_START_ASM
ENDM
const TX_NUM ; $09
text_decimal: MACRO
MACRO text_decimal
; print a big-endian decimal number.
db TX_NUM
dw \1 ; address to read from
@ -74,76 +74,76 @@ text_decimal: MACRO
ENDM
const TX_PAUSE ; $0a
text_pause: MACRO
MACRO text_pause
db TX_PAUSE
ENDM
const TX_SOUND_GET_ITEM_1 ; $0b
sound_get_item_1: MACRO
MACRO sound_get_item_1
db TX_SOUND_GET_ITEM_1
ENDM
TX_SOUND_LEVEL_UP EQU TX_SOUND_GET_ITEM_1
sound_level_up EQUS "sound_get_item_1"
DEF TX_SOUND_LEVEL_UP EQU TX_SOUND_GET_ITEM_1
DEF sound_level_up EQUS "sound_get_item_1"
const TX_DOTS ; $0c
text_dots: MACRO
MACRO text_dots
db TX_DOTS
db \1 ; number of ellipses to draw
ENDM
const TX_WAIT_BUTTON ; $0d
text_waitbutton: MACRO
MACRO text_waitbutton
db TX_WAIT_BUTTON
ENDM
const TX_SOUND_POKEDEX_RATING ; $0e
sound_pokedex_rating: MACRO
MACRO sound_pokedex_rating
db TX_SOUND_POKEDEX_RATING
ENDM
const TX_SOUND_GET_ITEM_1_DUPLICATE ; $0f
sound_get_item_1_duplicate: MACRO
MACRO sound_get_item_1_duplicate
db TX_SOUND_GET_ITEM_1_DUPLICATE
ENDM
const TX_SOUND_GET_ITEM_2 ; $10
sound_get_item_2: MACRO
MACRO sound_get_item_2
db TX_SOUND_GET_ITEM_2
ENDM
const TX_SOUND_GET_KEY_ITEM ; $11
sound_get_key_item: MACRO
MACRO sound_get_key_item
db TX_SOUND_GET_KEY_ITEM
ENDM
const TX_SOUND_CAUGHT_MON ; $12
sound_caught_mon: MACRO
MACRO sound_caught_mon
db TX_SOUND_CAUGHT_MON
ENDM
const TX_SOUND_DEX_PAGE_ADDED ; $13
sound_dex_page_added: MACRO
MACRO sound_dex_page_added
db TX_SOUND_DEX_PAGE_ADDED
ENDM
const TX_SOUND_CRY_NIDORINA ; $14
sound_cry_nidorina: MACRO
MACRO sound_cry_nidorina
db TX_SOUND_CRY_NIDORINA
ENDM
const TX_SOUND_CRY_PIDGEOT ; $15
sound_cry_pidgeot: MACRO
MACRO sound_cry_pidgeot
db TX_SOUND_CRY_PIDGEOT
ENDM
const TX_SOUND_CRY_DEWGONG ; $16
sound_cry_dewgong: MACRO
MACRO sound_cry_dewgong
db TX_SOUND_CRY_DEWGONG
ENDM
const TX_FAR ; $17
text_far: MACRO
MACRO text_far
db TX_FAR
dab \1 ; address of text commands
ENDM
@ -152,7 +152,7 @@ ENDM
const_next $50
const TX_END ; $50
text_end: MACRO
MACRO text_end
db TX_END
ENDM
@ -161,12 +161,12 @@ ENDM
const_def -1, -1
const TX_SCRIPT_POKECENTER_NURSE ; $ff
script_pokecenter_nurse: MACRO
MACRO script_pokecenter_nurse
db TX_SCRIPT_POKECENTER_NURSE
ENDM
const TX_SCRIPT_MART ; $fe
script_mart: MACRO
MACRO script_mart
db TX_SCRIPT_MART
db _NARG ; number of items
IF _NARG
@ -176,12 +176,12 @@ script_mart: MACRO
ENDM
const TX_SCRIPT_BILLS_PC ; $fd
script_bills_pc: MACRO
MACRO script_bills_pc
db TX_SCRIPT_BILLS_PC
ENDM
const TX_SCRIPT_PLAYERS_PC ; $fc
script_players_pc: MACRO
MACRO script_players_pc
db TX_SCRIPT_PLAYERS_PC
ENDM
@ -190,23 +190,23 @@ ENDM
const_skip ; $fa
const TX_SCRIPT_POKECENTER_PC ; $f9
script_pokecenter_pc: MACRO
MACRO script_pokecenter_pc
db TX_SCRIPT_POKECENTER_PC
ENDM
const_skip ; $f8
const TX_SCRIPT_PRIZE_VENDOR ; $f7
script_prize_vendor: MACRO
MACRO script_prize_vendor
db TX_SCRIPT_PRIZE_VENDOR
ENDM
const TX_SCRIPT_CABLE_CLUB_RECEPTIONIST ; $f6
script_cable_club_receptionist: MACRO
MACRO script_cable_club_receptionist
db TX_SCRIPT_CABLE_CLUB_RECEPTIONIST
ENDM
const TX_SCRIPT_VENDING_MACHINE ; $f5
script_vending_machine: MACRO
MACRO script_vending_machine
db TX_SCRIPT_VENDING_MACHINE
ENDM

View file

@ -1,39 +1,39 @@
vc_hook: MACRO
IF DEF(_RED_VC) || DEF(_BLUE_VC)
.VC_\1::
ENDC
MACRO vc_hook
IF DEF(_RED_VC) || DEF(_BLUE_VC)
.VC_\1::
ENDC
ENDM
vc_hook_red: MACRO
IF DEF(_RED_VC)
.VC_\1::
ENDC
MACRO vc_hook_red
IF DEF(_RED_VC)
.VC_\1::
ENDC
ENDM
vc_hook_blue: MACRO
IF DEF(_BLUE_VC)
.VC_\1::
ENDC
MACRO vc_hook_blue
IF DEF(_BLUE_VC)
.VC_\1::
ENDC
ENDM
vc_patch: MACRO
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ASSERT !DEF(CURRENT_VC_PATCH), "Already started a vc_patch"
CURRENT_VC_PATCH EQUS "\1"
.VC_{CURRENT_VC_PATCH}::
ENDC
MACRO vc_patch
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ASSERT !DEF(CURRENT_VC_PATCH), "Already started a vc_patch"
DEF CURRENT_VC_PATCH EQUS "\1"
.VC_{CURRENT_VC_PATCH}::
ENDC
ENDM
vc_patch_end: MACRO
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ASSERT DEF(CURRENT_VC_PATCH), "No vc_patch started"
.VC_{CURRENT_VC_PATCH}_End::
PURGE CURRENT_VC_PATCH
ENDC
MACRO vc_patch_end
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ASSERT DEF(CURRENT_VC_PATCH), "No vc_patch started"
.VC_{CURRENT_VC_PATCH}_End::
PURGE CURRENT_VC_PATCH
ENDC
ENDM
vc_assert: MACRO
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ASSERT \#
ENDC
MACRO vc_assert
IF DEF(_RED_VC) || DEF(_BLUE_VC)
ASSERT \#
ENDC
ENDM

View file

@ -1,12 +1,12 @@
; Used in wram.asm
flag_array: MACRO
MACRO flag_array
ds ((\1) + 7) / 8
ENDM
BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2
DEF BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2
box_struct: MACRO
MACRO box_struct
\1Species:: db
\1HP:: dw
\1BoxLevel:: db
@ -27,7 +27,7 @@ box_struct: MACRO
\1PP:: ds NUM_MOVES
ENDM
party_struct: MACRO
MACRO party_struct
box_struct \1
\1Level:: db
\1Stats::
@ -38,7 +38,7 @@ party_struct: MACRO
\1Special:: dw
ENDM
battle_struct: MACRO
MACRO battle_struct
\1Species:: db
\1HP:: dw
\1PartyPos::
@ -60,7 +60,7 @@ battle_struct: MACRO
\1PP:: ds NUM_MOVES
ENDM
spritestatedata1: MACRO
MACRO spritestatedata1
\1PictureID:: db
\1MovementStatus:: db
\1ImageIndex:: db
@ -78,7 +78,7 @@ spritestatedata1: MACRO
\1End::
ENDM
spritestatedata2: MACRO
MACRO spritestatedata2
\1WalkAnimationCounter:: db
ds 1
\1YDisplacement:: db
@ -96,14 +96,14 @@ spritestatedata2: MACRO
\1End::
ENDM
sprite_oam_struct: MACRO
MACRO sprite_oam_struct
\1YCoord:: db
\1XCoord:: db
\1TileID:: db
\1Attributes:: db
ENDM
map_connection_struct: MACRO
MACRO map_connection_struct
\1ConnectedMap:: db
\1ConnectionStripSrc:: dw
\1ConnectionStripDest:: dw