This commit is contained in:
dannye 2021-03-23 00:53:43 -05:00
commit e8dd755e18
3702 changed files with 163333 additions and 159040 deletions

View file

@ -1,211 +0,0 @@
lb: MACRO ; r, hi, lo
ld \1, ((\2) & $ff) << 8 + ((\3) & $ff)
ENDM
homecall: MACRO
ld a, [H_LOADEDROMBANK]
push af
ld a, BANK(\1)
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
call \1
pop af
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
ENDM
farcall EQUS "callba"
callba: MACRO
ld b, BANK(\1)
ld hl, \1
call Bankswitch
ENDM
callab: MACRO
ld hl, \1
ld b, BANK(\1)
call Bankswitch
ENDM
jpba: MACRO
ld b, BANK(\1)
ld hl, \1
jp Bankswitch
ENDM
jpab: MACRO
ld hl, \1
ld b, BANK(\1)
jp Bankswitch
ENDM
validateCoords: MACRO
IF \1 >= SCREEN_WIDTH
fail "x coord out of range"
ENDC
IF \2 >= SCREEN_HEIGHT
fail "y coord out of range"
ENDC
ENDM
;\1 = r
;\2 = X
;\3 = Y
;\4 = which tilemap (optional)
coord: MACRO
validateCoords \2, \3
IF _NARG >= 4
ld \1, \4 + SCREEN_WIDTH * \3 + \2
ELSE
ld \1, wTileMap + SCREEN_WIDTH * \3 + \2
ENDC
ENDM
;\1 = X
;\2 = Y
;\3 = which tilemap (optional)
aCoord: MACRO
validateCoords \1, \2
IF _NARG >= 3
ld a, [\3 + SCREEN_WIDTH * \2 + \1]
ELSE
ld a, [wTileMap + SCREEN_WIDTH * \2 + \1]
ENDC
ENDM
;\1 = X
;\2 = Y
;\3 = which tilemap (optional)
Coorda: MACRO
validateCoords \1, \2
IF _NARG >= 3
ld [\3 + SCREEN_WIDTH * \2 + \1], a
ELSE
ld [wTileMap + SCREEN_WIDTH * \2 + \1], a
ENDC
ENDM
;\1 = X
;\2 = Y
;\3 = which tilemap (optional)
dwCoord: MACRO
validateCoords \1, \2
IF _NARG >= 3
dw \3 + SCREEN_WIDTH * \2 + \1
ELSE
dw wTileMap + SCREEN_WIDTH * \2 + \1
ENDC
ENDM
;\1 = r
;\2 = X
;\3 = Y
;\4 = map width
overworldMapCoord: MACRO
ld \1, wOverworldMap + ((\2) + 3) + (((\3) + 3) * ((\4) + (3 * 2)))
ENDM
; macro for two nibbles
dn: MACRO
rept _NARG / 2
db ((\1) << 4) | (\2)
shift
shift
endr
ENDM
; macro for putting a byte then a word
dbw: MACRO
db \1
dw \2
ENDM
dba: MACRO
dbw BANK(\1), \1
ENDM
dwb: MACRO
dw \1
db \2
ENDM
dab: MACRO
dwb \1, BANK(\1)
ENDM
dbbw: MACRO
db \1, \2
dw \3
ENDM
bigdw: MACRO ; big-endian word
dw ((\1)/$100) + (((\1)&$ff)*$100)
ENDM
dt: MACRO ; three-byte (big-endian)
db (\1 >> 16) & $ff
db (\1 >> 8) & $ff
db \1 & $ff
ENDM
; Predef macro.
predef_const: MACRO
const \1PredefID
ENDM
add_predef: MACRO
\1Predef::
db BANK(\1)
dw \1
ENDM
predef_id: MACRO
ld a, (\1Predef - PredefPointers) / 3
ENDM
predef: MACRO
predef_id \1
call Predef
ENDM
predef_jump: MACRO
predef_id \1
jp Predef
ENDM
tx_pre_const: MACRO
const \1_id
ENDM
add_tx_pre: MACRO
\1_id:: dw \1
ENDM
db_tx_pre: MACRO
db (\1_id - TextPredefs) / 2 + 1
ENDM
tx_pre_id: MACRO
ld a, (\1_id - TextPredefs) / 2 + 1
ENDM
tx_pre: MACRO
tx_pre_id \1
call PrintPredefTextID
ENDM
tx_pre_jump: MACRO
tx_pre_id \1
jp PrintPredefTextID
ENDM
ldPal: MACRO
ld \1, \2 << 6 | \3 << 4 | \4 << 2 | \5
ENDM
inc_section: MACRO
SECTION \1, ROMX
include \1
ENDM

View file

@ -1,177 +0,0 @@
StopAllMusic: MACRO
ld a, $ff
call PlaySound
ENDM
Ch0 EQU 0
Ch1 EQU 1
Ch2 EQU 2
Ch3 EQU 3
Ch4 EQU 4
Ch5 EQU 5
Ch6 EQU 6
Ch7 EQU 7
audio: MACRO
db (_NARG - 2) << 6 | \2
dw \1_\2
IF _NARG > 2
db \3
dw \1_\3
ENDC
IF _NARG > 3
db \4
dw \1_\4
ENDC
IF _NARG > 4
db \5
dw \1_\5
ENDC
ENDM
;format: length [0, 7], pitch change [-7, 7]
pitchenvelope: MACRO
db $dd ; soundinput
IF \2 > 0
db (\1 << 4) | \2
ELSE
db (\1 << 4) | (%1000 | (\2 * -1))
ENDC
ENDM
;format: length [0, 15], volume [0, 15], volume change [-7, 7], pitch
squarenote: MACRO
; noise/sound
db \1
;db $20 | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
ELSE
db (\2 << 4) | \3
ENDC
dw \4
ENDM
;format: length [0, 15], volume [0, 15], volume change [-7, 7], pitch
noisenote: MACRO
db \1 ; | $20
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
ELSE
db (\2 << 4) | \3
ENDC
db \4
ENDM
;format: instrument length (in 16ths)
snare1: MACRO
db $B0 | (\1 - 1)
db $01
ENDM
snare2: MACRO
db $B0 | (\1 - 1)
db $02
ENDM
snare3: MACRO
db $B0 | (\1 - 1)
db $03
ENDM
snare4: MACRO
db $B0 | (\1 - 1)
db $04
ENDM
snare5: MACRO
db $B0 | (\1 - 1)
db $05
ENDM
triangle1: MACRO
db $B0 | (\1 - 1)
db $06
ENDM
triangle2: MACRO
db $B0 | (\1 - 1)
db $07
ENDM
snare6: MACRO
db $B0 | (\1 - 1)
db $08
ENDM
snare7: MACRO
db $B0 | (\1 - 1)
db $09
ENDM
snare8: MACRO
db $B0 | (\1 - 1)
db $0A
ENDM
snare9: MACRO
db $B0 | (\1 - 1)
db $0B
ENDM
cymbal1: MACRO
db $B0 | (\1 - 1)
db $0C
ENDM
cymbal2: MACRO
db $B0 | (\1 - 1)
db $0D
ENDM
cymbal3: MACRO
db $B0 | (\1 - 1)
db $0E
ENDM
mutedsnare1: MACRO
db $B0 | (\1 - 1)
db $0F
ENDM
triangle3: MACRO
db $B0 | (\1 - 1)
db $10
ENDM
mutedsnare2: MACRO
db $B0 | (\1 - 1)
db $11
ENDM
mutedsnare3: MACRO
db $B0 | (\1 - 1)
db $12
ENDM
mutedsnare4: MACRO
db $B0 | (\1 - 1)
db $13
ENDM
duty: MACRO
;db $EC
db $db
db \1
ENDM
;format: rest length (in 16ths)
rest: MACRO
db $C0 | (\1 - 1)
ENDM
executemusic: MACRO
togglesfx
ENDM

20
macros/code.asm Normal file
View file

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

40
macros/const.asm Normal file
View file

@ -0,0 +1,40 @@
; 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
ENDM
const: MACRO
\1 EQU const_value
const_value = const_value + const_inc
ENDM
shift_const: MACRO
\1 EQU (1 << const_value)
const_value = const_value + const_inc
ENDM
const_skip: MACRO
if _NARG >= 1
const_value = const_value + const_inc * (\1)
else
const_value = 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
ENDM

90
macros/coords.asm Normal file
View file

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

84
macros/data.asm Normal file
View file

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

View file

@ -1,246 +0,0 @@
; Constant enumeration is useful for monsters, items, moves, etc.
const_def: MACRO
if _NARG >= 1
const_value = \1
else
const_value = 0
endc
ENDM
const: MACRO
\1 EQU const_value
const_value = const_value + 1
ENDM
; data format macros
percent EQUS "* $ff / 100"
bcd2: MACRO
dn ((\1) / 1000) % 10, ((\1) / 100) % 10
dn ((\1) / 10) % 10, (\1) % 10
ENDM
bcd3: MACRO
dn ((\1) / 100000) % 10, ((\1) / 10000) % 10
dn ((\1) / 1000) % 10, ((\1) / 100) % 10
dn ((\1) / 10) % 10, (\1) % 10
ENDM
coins equs "bcd2"
money equs "bcd3"
;\1 = Map Width
;\2 = Rows above (Y-blocks)
;\3 = X movement (X-blocks)
EVENT_DISP: MACRO
dw (wOverworldMap + 7 + (\1) + ((\1) + 6) * ((\2) >> 1) + ((\3) >> 1)) ; Ev.Disp
db \2,\3 ;Y,X
ENDM
FLYWARP_DATA: MACRO
EVENT_DISP \1,\2,\3
db ((\2) & $01) ;sub-block Y
db ((\3) & $01) ;sub-block X
ENDM
; external map entry macro
EMAP: MACRO ; emap x-coordinate,y-coordinate,textpointer
; the appearance of towns and routes in the town map, indexed by map id
; nybble: y-coordinate
; nybble: x-coordinate
; word : pointer to map name
dn \2, \1
dw \3
ENDM
; internal map entry macro
IMAP: MACRO ; imap mapid_less_than,x-coordinate,y-coordinate,textpointer
; the appearance of buildings and dungeons in the town map
; byte : maximum map id subject to this rule
; nybble: y-coordinate
; nybble: x-coordinate
; word : pointer to map name
db \1 + 1
dn \3, \2
dw \4
ENDM
; tilesets' headers macro
tileset: MACRO
db BANK(\2) ; BANK(GFX)
dw \1, \2, \3 ; Block, GFX, Coll
db \4, \5, \6 ; counter tiles
db \7 ; grass tile
db \8 ; permission (indoor, cave, outdoor)
ENDM
INDOOR EQU 0
CAVE EQU 1
OUTDOOR EQU 2
RGB: MACRO
dw (\3 << 10 | \2 << 5 | \1)
ENDM
WALK EQU $FE
STAY EQU $FF
DOWN EQU $D0
UP EQU $D1
LEFT EQU $D2
RIGHT EQU $D3
NONE EQU $FF
;\1 sprite id
;\2 x position
;\3 y position
;\4 movement (WALK/STAY)
;\5 range or direction
;\6 text id
;\7 items only: item id
;\7 trainers only: trainer class/pokemon id
;\8 trainers only: trainer number/pokemon level
object: MACRO
db \1
db \3 + 4
db \2 + 4
db \4
db \5
IF (_NARG > 7)
db TRAINER | \6
db \7
db \8
ELSE
IF (_NARG > 6)
db ITEM | \6
db \7
ELSE
db \6
ENDC
ENDC
ENDM
;\1 x position
;\2 y position
;\3 destination warp id
;\4 destination map (-1 = wLastMap)
warp: MACRO
db \2, \1, \3, \4
ENDM
;\1 x position
;\2 y position
;\3 sign id
sign: MACRO
db \2, \1, \3
ENDM
;\1 x position
;\2 y position
;\3 map width
warp_to: MACRO
EVENT_DISP \3, \2, \1
ENDM
;\1 (byte) = current map id
;\2 (byte) = connected map id
;\3 (byte) = x movement of connection strip
;\4 (byte) = connection strip offset
;\5 (word) = connected map blocks pointer
NORTH_MAP_CONNECTION: MACRO
db \2 ; map id
dw \5 + (\2_WIDTH * (\2_HEIGHT - 3)) + \4; "Connection Strip" location
dw wOverworldMap + 3 + \3 ; current map position
IF (\1_WIDTH < \2_WIDTH)
db \1_WIDTH - \3 + 3 ; width of connection strip
ELSE
db \2_WIDTH - \4 ; width of connection strip
ENDC
db \2_WIDTH ; map width
db (\2_HEIGHT * 2) - 1 ; y alignment (y coordinate of player when entering map)
db (\3 - \4) * -2 ; x alignment (x coordinate of player when entering map)
dw wOverworldMap + 1 + (\2_HEIGHT * (\2_WIDTH + 6)) ; window (position of the upper left block after entering the map)
ENDM
;\1 (byte) = current map id
;\2 (byte) = connected map id
;\3 (byte) = x movement of connection strip
;\4 (byte) = connection strip offset
;\5 (word) = connected map blocks pointer
;\6 (flag) = add 3 to width of connection strip (why?)
SOUTH_MAP_CONNECTION: MACRO
db \2 ; map id
dw \5 + \4 ; "Connection Strip" location
dw wOverworldMap + 3 + (\1_HEIGHT + 3) * (\1_WIDTH + 6) + \3 ; current map position
IF (\1_WIDTH < \2_WIDTH)
IF (_NARG > 5)
db \1_WIDTH - \3 + 3 ; width of connection strip
ELSE
db \1_WIDTH - \3 ; width of connection strip
ENDC
ELSE
db \2_WIDTH - \4 ; width of connection strip
ENDC
db \2_WIDTH ; map width
db 0 ; y alignment (y coordinate of player when entering map)
db (\3 - \4) * -2 ; x alignment (x coordinate of player when entering map)
dw wOverworldMap + 7 + \2_WIDTH ; window (position of the upper left block after entering the map)
ENDM
;\1 (byte) = current map id
;\2 (byte) = connected map id
;\3 (byte) = y movement of connection strip
;\4 (byte) = connection strip offset
;\5 (word) = connected map blocks pointer
WEST_MAP_CONNECTION: MACRO
db \2 ; map id
dw \5 + (\2_WIDTH * \4) + \2_WIDTH - 3 ; "Connection Strip" location
dw wOverworldMap + (\1_WIDTH + 6) * (\3 + 3) ; current map position
IF (\1_HEIGHT < \2_HEIGHT)
db \1_HEIGHT - \3 + 3 ; height of connection strip
ELSE
db \2_HEIGHT - \4 ; height of connection strip
ENDC
db \2_WIDTH ; map width
db (\3 - \4) * -2 ; y alignment
db (\2_WIDTH * 2) - 1 ; x alignment
dw wOverworldMap + 6 + (2 * \2_WIDTH) ; window (position of the upper left block after entering the map)
ENDM
;\1 (byte) = current map id
;\2 (byte) = connected map id
;\3 (byte) = y movement of connection strip
;\4 (byte) = connection strip offset
;\5 (word) = connected map blocks pointer
;\6 (flag) = add 3 to height of connection strip (why?)
EAST_MAP_CONNECTION: MACRO
db \2 ; map id
dw \5 + (\2_WIDTH * \4) ; "Connection Strip" location
dw wOverworldMap - 3 + (\1_WIDTH + 6) * (\3 + 4) ; current map position
IF (\1_HEIGHT < \2_HEIGHT)
IF (_NARG > 5)
db \1_HEIGHT - \3 + 3 ; height of connection strip
ELSE
db \1_HEIGHT - \3 ; height of connection strip
ENDC
ELSE
db \2_HEIGHT - \4 ; height of connection strip
ENDC
db \2_WIDTH ; map width
db (\3 - \4) * -2 ; y alignment
db 0 ; x alignment
dw wOverworldMap + 7 + \2_WIDTH ; window (position of the upper left block after entering the map)
ENDM
tmlearn: MACRO
x = 0
REPT _NARG
IF \1 != 0
x = x | (1 << ((\1 - 1) % 8))
ENDC
SHIFT
ENDR
db x
ENDM

48
macros/farcall.asm Normal file
View file

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

22
macros/gfx.asm Normal file
View file

@ -0,0 +1,22 @@
RGB: MACRO
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) *"
palettes EQUS "* PALETTE_SIZE"
palette EQUS "+ PALETTE_SIZE *"
color EQUS "+ PAL_COLOR_SIZE *"
tiles EQUS "* LEN_2BPP_TILE"
tile EQUS "+ LEN_2BPP_TILE *"
dbsprite: MACRO
; 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

32
macros/predef.asm Normal file
View file

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

233
macros/scripts/audio.asm Normal file
View file

@ -0,0 +1,233 @@
audio_header: MACRO
db (_NARG - 2) << 6 | \2
dw \1_\2
IF _NARG > 2
db \3
dw \1_\3
ENDC
IF _NARG > 3
db \4
dw \1_\4
ENDC
IF _NARG > 4
db \5
dw \1_\5
ENDC
ENDM
const_def $10
; arguments: length [0, 7], pitch change [-7, 7]
; length: length of time between pitch shifts
; sometimes used with a value >7 in which case the MSB is ignored
; pitch change: positive value means increase in pitch, negative value means decrease in pitch
; 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
db pitch_sweep_cmd
IF \2 < 0
db (\1 << 4) | (%1000 | (\2 * -1))
ELSE
db (\1 << 4) | \2
ENDC
ENDM
const_next $20
const sfx_note_cmd ; $20
; arguments: length [0, 15], volume [0, 15], fade [-7, 7], frequency
; 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
db square_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
ELSE
db (\2 << 4) | \3
ENDC
dw \4
ENDM
; arguments: length [0, 15], volume [0, 15], fade [-7, 7], frequency
; 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
db noise_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
ELSE
db (\2 << 4) | \3
ENDC
db \4
ENDM
; arguments: pitch, length [1, 16]
note: MACRO
db (\1 << 4) | (\2 - 1)
ENDM
const_next $b0
; arguments: instrument [1, 19], length [1, 16]
const drum_note_cmd ; $b0
drum_note: MACRO
db drum_note_cmd | (\2 - 1)
db \1
ENDM
; arguments: instrument, length [1, 16]
; 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
db (\1 << 4) | (\2 - 1)
ENDM
const_next $c0
; arguments: length [1, 16]
const rest_cmd ; $c0
rest: MACRO
db rest_cmd | (\1 - 1)
ENDM
const_next $d0
; arguments: speed [0, 15], volume [0, 15], fade [-7, 7]
; 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
const note_type_cmd ; $d0
note_type: MACRO
db note_type_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
ELSE
db (\2 << 4) | \3
ENDC
ENDM
; arguments: speed [0, 15]
drum_speed_cmd EQU note_type_cmd ; $d0
drum_speed: MACRO
db drum_speed_cmd | \1
ENDM
const_next $e0
; arguments: octave [1, 8]
const octave_cmd ; $e0
octave: MACRO
db octave_cmd | (8 - \1)
ENDM
const_next $e8
; when enabled, effective frequency used is incremented by 1
const toggle_perfect_pitch_cmd ; $e8
toggle_perfect_pitch: MACRO
db toggle_perfect_pitch_cmd
ENDM
const_skip ; $e9
; arguments: delay [0, 255], depth [0, 15], rate [0, 15]
; delay: time delay until vibrato effect begins
; depth: amplitude of vibrato wave
; rate: frequency of vibrato wave
const vibrato_cmd ; $ea
vibrato: MACRO
db vibrato_cmd
db \1
db (\2 << 4) | \3
ENDM
; arguments: length [1, 256], octave [1, 8], pitch
const pitch_slide_cmd ; $eb
pitch_slide: MACRO
db pitch_slide_cmd
db \1 - 1
db ((8 - \2) << 4) | \3
ENDM
; arguments: duty cycle [0, 3] (12.5%, 25%, 50%, 75%)
const duty_cycle_cmd ; $ec
duty_cycle: MACRO
db duty_cycle_cmd
db \1
ENDM
; arguments: tempo [0, $ffff]
; used to calculate note delay counters
; so a smaller value means music plays faster
; ideally should be set to $100 or less to guarantee no overflow
; if larger than $100, large note speed or note length values might cause overflow
; stored in big endian
const tempo_cmd ; $ed
tempo: MACRO
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
db stereo_panning_cmd
db (\1 << 4) | \2
ENDM
const unknownmusic0xef_cmd ; $ef
unknownmusic0xef: MACRO
db unknownmusic0xef_cmd
db \1
ENDM
; arguments: left master volume [0, 7], right master volume [0, 7]
const volume_cmd ; $f0
volume: MACRO
db volume_cmd
db (\1 << 4) | \2
ENDM
const_next $f8
; when enabled, the sfx data is interpreted as music data
const execute_music_cmd ; $f8
execute_music: MACRO
db execute_music_cmd
ENDM
const_next $fc
; arguments: duty cycle 1, duty cycle 2, duty cycle 3, duty cycle 4
const duty_cycle_pattern_cmd ; $fc
duty_cycle_pattern: MACRO
db duty_cycle_pattern_cmd
db \1 << 6 | \2 << 4 | \3 << 2 | \4
ENDM
; arguments: address
const sound_call_cmd ; $fd
sound_call: MACRO
db sound_call_cmd
dw \1
ENDM
; arguments: count, address
const sound_loop_cmd ; $fe
sound_loop: MACRO
db sound_loop_cmd
db \1
dw \2
ENDM
const sound_ret_cmd ; $ff
sound_ret: MACRO
db sound_ret_cmd
ENDM

110
macros/event_macros.asm → macros/scripts/events.asm Executable file → Normal file
View file

@ -15,7 +15,8 @@ event_byte = ((\1) / 8)
ELSE
bit (\1) % 8, a
ENDC
ENDM
ENDM
;\1 = event index
CheckEventReuseA: MACRO
@ -25,7 +26,8 @@ event_byte = ((\1) / 8)
ENDC
bit (\1) % 8, a
ENDM
ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
@ -37,7 +39,8 @@ event_byte = ((\1) / 8)
ENDC
bit (\1) % 8, a
ENDM
ENDM
;\1 = reg
;\2 = event index
@ -48,21 +51,24 @@ EventFlagBit: MACRO
ELSE
ld \1, (\2) % 8
ENDC
ENDM
ENDM
;\1 = reg
;\2 = event index
EventFlagAddress: MACRO
event_byte = ((\2) / 8)
ld \1, wEventFlags + event_byte
ENDM
ENDM
;\1 = event index
CheckEventHL: MACRO
event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
CheckEventReuseHL: MACRO
@ -72,14 +78,16 @@ event_byte = ((\1) / 8)
ENDC
bit (\1) % 8, [hl]
ENDM
ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
CheckEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
bit (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
@ -91,7 +99,8 @@ event_byte = ((\1) / 8)
ENDC
bit (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
CheckAndSetEvent: MACRO
@ -99,7 +108,8 @@ event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
set (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
CheckAndResetEvent: MACRO
@ -107,7 +117,8 @@ event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
res (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
CheckAndSetEventA: MACRO
@ -115,7 +126,8 @@ CheckAndSetEventA: MACRO
bit (\1) % 8, a
set (\1) % 8, a
ld [wEventFlags + ((\1) / 8)], a
ENDM
ENDM
;\1 = event index
CheckAndResetEventA: MACRO
@ -123,14 +135,16 @@ CheckAndResetEventA: MACRO
bit (\1) % 8, a
res (\1) % 8, a
ld [wEventFlags + ((\1) / 8)], a
ENDM
ENDM
;\1 = event index
SetEvent: MACRO
event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
set (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
SetEventReuseHL: MACRO
@ -140,7 +154,8 @@ event_byte = ((\1) / 8)
ENDC
set (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
@ -152,32 +167,36 @@ event_byte = ((\1) / 8)
ENDC
set (\1) % 8, [hl]
ENDM
ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
SetEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
set (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
;\2 = event index
;\3, \4, ... = additional (optional) event indices
SetEvents: MACRO
SetEvent \1
rept (_NARG + -1)
REPT _NARG - 1
SetEventReuseHL \2
shift
endr
ENDM
SHIFT
ENDR
ENDM
;\1 = event index
ResetEvent: MACRO
event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
res (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
ResetEventReuseHL: MACRO
@ -187,7 +206,8 @@ event_byte = ((\1) / 8)
ENDC
res (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
@ -199,25 +219,28 @@ event_byte = ((\1) / 8)
ENDC
res (\1) % 8, [hl]
ENDM
ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
ResetEventForceReuseHL: MACRO
event_byte = ((\1) / 8)
res (\1) % 8, [hl]
ENDM
ENDM
;\1 = event index
;\2 = event index
;\3 = event index (optional)
ResetEvents: MACRO
ResetEvent \1
rept (_NARG + -1)
REPT _NARG - 1
ResetEventReuseHL \2
shift
endr
ENDM
SHIFT
ENDR
ENDM
;\1 = event index
;\2 = number of bytes away from the base address (optional, for matching the ROM)
@ -227,7 +250,8 @@ dbEventFlagBit: MACRO
ELSE
db ((\1) % 8)
ENDC
ENDM
ENDM
;\1 = event index
;\2 = number of bytes away from the base address (optional, for matching the ROM)
@ -237,7 +261,8 @@ dwEventFlagAddress: MACRO
ELSE
dw wEventFlags + ((\1) / 8)
ENDC
ENDM
ENDM
;\1 = start
;\2 = end
@ -258,7 +283,7 @@ event_fill_start = event_start_byte + 1
event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
event_fill_start = event_fill_start + -1
event_fill_start = event_fill_start - 1
event_fill_count = event_fill_count + 1
ELSE
ld a, [wEventFlags + event_start_byte]
@ -279,7 +304,7 @@ event_fill_count = event_fill_count + 1
ld a, $ff
ld hl, wEventFlags + event_fill_start
REPT event_fill_count + -1
REPT event_fill_count - 1
ld [hli], a
ENDR
@ -297,7 +322,8 @@ event_fill_count = event_fill_count + 1
ENDC
ENDC
ENDC
ENDM
ENDM
;\1 = start
;\2 = end
@ -319,7 +345,7 @@ event_fill_start = event_start_byte + 1
event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
event_fill_start = event_fill_start + -1
event_fill_start = event_fill_start - 1
event_fill_count = event_fill_count + 1
ELSE
ld a, [wEventFlags + event_start_byte]
@ -344,7 +370,7 @@ event_fill_count = event_fill_count + 1
xor a
ENDC
REPT event_fill_count + -1
REPT event_fill_count - 1
ld [hli], a
ENDR
@ -362,7 +388,8 @@ event_fill_count = event_fill_count + 1
ENDC
ENDC
ENDC
ENDM
ENDM
; returns whether both events are set in Z flag
; This is counter-intuitive because the other event checks set the Z flag when
@ -400,7 +427,8 @@ event_byte = ((\1) / 8)
pop bc
ENDC
ENDC
ENDM
ENDM
; returns the complement of whether either event is set in Z flag
;\1 = event index 1
@ -429,7 +457,8 @@ CheckEitherEventSet: MACRO
pop bc
ENDC
ENDC
ENDM
ENDM
; for handling fixed event bits when events are inserted/removed
;\1 = event index
@ -438,4 +467,5 @@ AdjustEventBit: MACRO
IF ((\1) % 8) != (\2)
add ((\1) % 8) - (\2)
ENDC
ENDM
ENDM

219
macros/scripts/maps.asm Normal file
View file

@ -0,0 +1,219 @@
def_objects: MACRO
IF DEF(_NUM_OBJECTS)
PURGE _NUM_OBJECTS
ENDC
_NUM_OBJECTS EQUS "_NUM_OBJECTS_\@"
db _NUM_OBJECTS
_NUM_OBJECTS = 0
ENDM
;\1 sprite id
;\2 x position
;\3 y position
;\4 movement (WALK/STAY)
;\5 range or direction
;\6 text id
;\7 items only: item id
;\7 trainers only: trainer class/pokemon id
;\8 trainers only: trainer number/pokemon level
object: MACRO
db \1
db \3 + 4
db \2 + 4
db \4
db \5
IF _NARG > 7
db TRAINER | \6
db \7
db \8
ELIF _NARG > 6
db ITEM | \6
db \7
ELSE
db \6
ENDC
_NUM_OBJECTS = _NUM_OBJECTS + 1
ENDM
def_warps: MACRO
IF DEF(_NUM_WARPS)
PURGE _NUM_WARPS
ENDC
_NUM_WARPS EQUS "_NUM_WARPS_\@"
db _NUM_WARPS
_NUM_WARPS = 0
ENDM
;\1 x position
;\2 y position
;\3 destination warp id
;\4 destination map (-1 = wLastMap)
warp: MACRO
db \2, \1, \3, \4
_TMP EQUS "\n_WARP_{d:{_NUM_WARPS}}_X = \1\n_WARP_{d:{_NUM_WARPS}}_Y = \2"
_TMP
PURGE _TMP
_NUM_WARPS = _NUM_WARPS + 1
ENDM
def_signs: MACRO
IF DEF(_NUM_SIGNS)
PURGE _NUM_SIGNS
ENDC
_NUM_SIGNS EQUS "_NUM_SIGNS_\@"
db _NUM_SIGNS
_NUM_SIGNS = 0
ENDM
;\1 x position
;\2 y position
;\3 sign id
sign: MACRO
db \2, \1, \3
_NUM_SIGNS = _NUM_SIGNS + 1
ENDM
;\1 source map
def_warps_to: MACRO
N = 0
REPT _NUM_WARPS
_TMP EQUS "warp_to _WARP_{d:N}_X, _WARP_{d:N}_Y, \1_WIDTH"
_TMP
PURGE _TMP
N = N + 1
ENDR
ENDM
;\1 x position
;\2 y position
;\3 map width
warp_to: MACRO
event_displacement \3, \1, \2
ENDM
;\1 event flag
;\2 view range
;\3 TextBeforeBattle
;\4 TextAfterBattle
;\5 TextEndBattle
trainer: MACRO
IF _NARG > 5
dbEventFlagBit \1, \2
db (\3 << 4)
dwEventFlagAddress \1, \2
SHIFT
ELSE
dbEventFlagBit \1
db (\2 << 4)
dwEventFlagAddress \1
ENDC
dw \3, \5, \4, \4
ENDM
;\1 x position
;\2 y position
;\3 movement data
map_coord_movement: MACRO
dbmapcoord \1, \2
dw \3
ENDM
;\1 map name
;\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"
\1_h::
db \3
db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH
dw \1_Blocks
dw \1_TextPointers
dw \1_Script
db \4
ENDM
; Comes after map_header and connection macros
end_map_header: MACRO
dw CURRENT_MAP_OBJECT
PURGE CURRENT_MAP_WIDTH
PURGE CURRENT_MAP_HEIGHT
PURGE CURRENT_MAP_OBJECT
ENDM
; Connections go in order: north, south, west, east
;\1 direction
;\2 map name
;\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
; Calculate tile offsets for source (current) and target maps
_src = 0
_tgt = (\4) + 3
IF _tgt < 2
_src = -_tgt
_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
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", "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", "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
ELSE
fail "Invalid direction for 'connection'."
ENDC
db \3
dw \2_Blocks + _blk
dw wOverworldMap + _map
db _len - _src
db \3_WIDTH
db _y, _x
dw wOverworldMap + _win
ENDM

213
macros/scripts/text.asm Normal file
View file

@ -0,0 +1,213 @@
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).
page EQUS "db \"<PAGE>\"," ; Start a new Pokédex page.
dex EQUS "db \"<DEXEND>\", \"@\"" ; End a Pokédex entry.
; TextCommandJumpTable indexes (see home/text.asm)
const_def
const TX_START ; $00
text_start: MACRO
db TX_START
ENDM
const TX_RAM ; $01
text_ram: MACRO
db TX_RAM
dw \1 ; address to read from
ENDM
const TX_BCD ; $02
text_bcd: MACRO
db TX_BCD
dw \1 ; address to read from
db \2 ; number of bytes + print flags
ENDM
const TX_MOVE ; $03
text_move: MACRO
db TX_MOVE
dw \1 ; address of the new location
ENDM
const TX_BOX ; $04
text_box: MACRO
; draw box
db TX_BOX
dw \1 ; address of upper left corner
db \2, \3 ; height, width
ENDM
const TX_LOW ; $05
text_low: MACRO
db TX_LOW
ENDM
const TX_PROMPT_BUTTON ; $06
text_promptbutton: MACRO
db TX_PROMPT_BUTTON
ENDM
const TX_SCROLL ; $07
text_scroll: MACRO
db TX_SCROLL
ENDM
const TX_START_ASM ; $08
text_asm: MACRO
db TX_START_ASM
ENDM
const TX_NUM ; $09
text_decimal: MACRO
; print a big-endian decimal number.
db TX_NUM
dw \1 ; address to read from
dn \2, \3 ; number of bytes to read, number of digits to display
ENDM
const TX_PAUSE ; $0a
text_pause: MACRO
db TX_PAUSE
ENDM
const TX_SOUND_GET_ITEM_1 ; $0b
sound_get_item_1: MACRO
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"
const TX_DOTS ; $0c
text_dots: MACRO
db TX_DOTS
db \1 ; number of ellipses to draw
ENDM
const TX_WAIT_BUTTON ; $0d
text_waitbutton: MACRO
db TX_WAIT_BUTTON
ENDM
const TX_SOUND_POKEDEX_RATING ; $0e
sound_pokedex_rating: MACRO
db TX_SOUND_POKEDEX_RATING
ENDM
const TX_SOUND_GET_ITEM_1_DUPLICATE ; $0f
sound_get_item_1_duplicate: MACRO
db TX_SOUND_GET_ITEM_1_DUPLICATE
ENDM
const TX_SOUND_GET_ITEM_2 ; $10
sound_get_item_2: MACRO
db TX_SOUND_GET_ITEM_2
ENDM
const TX_SOUND_GET_KEY_ITEM ; $11
sound_get_key_item: MACRO
db TX_SOUND_GET_KEY_ITEM
ENDM
const TX_SOUND_CAUGHT_MON ; $12
sound_caught_mon: MACRO
db TX_SOUND_CAUGHT_MON
ENDM
const TX_SOUND_DEX_PAGE_ADDED ; $13
sound_dex_page_added: MACRO
db TX_SOUND_DEX_PAGE_ADDED
ENDM
const TX_SOUND_CRY_NIDORINA ; $14
sound_cry_nidorina: MACRO
db TX_SOUND_CRY_NIDORINA
ENDM
const TX_SOUND_CRY_PIDGEOT ; $15
sound_cry_pidgeot: MACRO
db TX_SOUND_CRY_PIDGEOT
ENDM
const TX_SOUND_CRY_DEWGONG ; $16
sound_cry_dewgong: MACRO
db TX_SOUND_CRY_DEWGONG
ENDM
const TX_FAR ; $17
text_far: MACRO
db TX_FAR
dab \1 ; address of text commands
ENDM
const_next $50
const TX_END ; $50
text_end: MACRO
db TX_END
ENDM
; Text script IDs (see home/text_script.asm)
const_def -1, -1
const TX_SCRIPT_POKECENTER_NURSE ; $ff
script_pokecenter_nurse: MACRO
db TX_SCRIPT_POKECENTER_NURSE
ENDM
const TX_SCRIPT_MART ; $fe
script_mart: MACRO
db TX_SCRIPT_MART
db _NARG ; number of items
REPT _NARG
db \1 ; item id
SHIFT
ENDR
db -1 ; end
ENDM
const TX_SCRIPT_BILLS_PC ; $fd
script_bills_pc: MACRO
db TX_SCRIPT_BILLS_PC
ENDM
const TX_SCRIPT_PLAYERS_PC ; $fc
script_players_pc: MACRO
db TX_SCRIPT_PLAYERS_PC
ENDM
const_skip ; $fb
const_skip ; $fa
const TX_SCRIPT_POKECENTER_PC ; $f9
script_pokecenter_pc: MACRO
db TX_SCRIPT_POKECENTER_PC
ENDM
const_skip ; $f8
const TX_SCRIPT_PRIZE_VENDOR ; $f7
script_prize_vendor: MACRO
db TX_SCRIPT_PRIZE_VENDOR
ENDM
const TX_SCRIPT_CABLE_CLUB_RECEPTIONIST ; $f6
script_cable_club_receptionist: MACRO
db TX_SCRIPT_CABLE_CLUB_RECEPTIONIST
ENDM
const TX_SCRIPT_VENDING_MACHINE ; $f5
script_vending_machine: MACRO
db TX_SCRIPT_VENDING_MACHINE
ENDM

View file

@ -1,80 +0,0 @@
; text macros
text EQUS "db $00," ; Start writing text.
next EQUS "db $4e," ; Move a line down.
line EQUS "db $4f," ; Start writing at the bottom line.
para EQUS "db $51," ; Start a new paragraph.
cont EQUS "db $55," ; Scroll to the next line.
done EQUS "db $57" ; End a text box.
prompt EQUS "db $58" ; Prompt the player to end a text box (initiating some other event).
page EQUS "db $49," ; Start a new Pokedex page.
dex EQUS "db $5f, $50" ; End a Pokedex entry.
TX_RAM: MACRO
; prints text to screen
; \1: RAM address to read from
db $1
dw \1
ENDM
TX_BCD: MACRO
; \1: RAM address to read from
; \2: number of bytes + print flags
db $2
dw \1
db \2
ENDM
TX_LINE EQUS "db $05"
TX_BLINK EQUS "db $06"
;TX_SCROLL EQUS "db $07"
TX_ASM EQUS "db $08"
TX_NUM: MACRO
; print a big-endian decimal number.
; \1: address to read from
; \2: number of bytes to read
; \3: number of digits to display
db $09
dw \1
db \2 << 4 | \3
ENDM
TX_DELAY EQUS "db $0a"
TX_SFX_ITEM_1 EQUS "db $0b"
TX_SFX_LEVEL_UP EQUS "db $0b"
;TX_ELLIPSES EQUS "db $0c"
TX_WAIT EQUS "db $0d"
;TX_SFX_DEX_RATING EQUS "db $0e"
TX_SFX_ITEM_2 EQUS "db $10"
TX_SFX_KEY_ITEM EQUS "db $11"
TX_SFX_CAUGHT_MON EQUS "db $12"
TX_SFX_DEX_PAGE_ADDED EQUS "db $13"
TX_CRY_NIDORINA EQUS "db $14"
TX_CRY_PIDGEOT EQUS "db $15"
;TX_CRY_DEWGONG EQUS "db $16"
TX_FAR: MACRO
db $17
dw \1
db BANK(\1)
ENDM
TX_VENDING_MACHINE EQUS "db $f5"
TX_CABLE_CLUB_RECEPTIONIST EQUS "db $f6"
TX_PRIZE_VENDOR EQUS "db $f7"
TX_POKECENTER_PC EQUS "db $f9"
TX_PLAYERS_PC EQUS "db $fc"
TX_BILLS_PC EQUS "db $fd"
TX_MART: MACRO
db $FE, _NARG
REPT _NARG
db \1
SHIFT
ENDR
db $FF
ENDM
TX_POKECENTER_NURSE EQUS "db $ff"

97
macros/wram.asm Normal file
View file

@ -0,0 +1,97 @@
; Used in wram.asm
flag_array: MACRO
ds ((\1) + 7) / 8
ENDM
BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2
box_struct: MACRO
\1Species:: db
\1HP:: dw
\1BoxLevel:: db
\1Status:: db
\1Type::
\1Type1:: db
\1Type2:: db
\1CatchRate:: db
\1Moves:: ds NUM_MOVES
\1OTID:: dw
\1Exp:: ds 3
\1HPExp:: dw
\1AttackExp:: dw
\1DefenseExp:: dw
\1SpeedExp:: dw
\1SpecialExp:: dw
\1DVs:: ds 2
\1PP:: ds NUM_MOVES
ENDM
party_struct: MACRO
box_struct \1
\1Level:: db
\1Stats::
\1MaxHP:: dw
\1Attack:: dw
\1Defense:: dw
\1Speed:: dw
\1Special:: dw
ENDM
battle_struct: MACRO
\1Species:: db
\1HP:: dw
\1PartyPos::
\1BoxLevel:: db
\1Status:: db
\1Type::
\1Type1:: db
\1Type2:: db
\1CatchRate:: db
\1Moves:: ds NUM_MOVES
\1DVs:: ds 2
\1Level:: db
\1Stats::
\1MaxHP:: dw
\1Attack:: dw
\1Defense:: dw
\1Speed:: dw
\1Special:: dw
\1PP:: ds NUM_MOVES
ENDM
spritestatedata1: MACRO
\1PictureID:: db
\1MovementStatus:: db
\1ImageIndex:: db
\1YStepVector:: db
\1YPixels:: db
\1XStepVector:: db
\1XPixels:: db
\1IntraAnimFrameCounter:: db
\1AnimFrameCounter:: db
\1FacingDirection:: db
\1YAdjusted:: db
\1XAdjusted:: db
\1CollisionData:: db
ds 3
\1End::
ENDM
spritestatedata2: MACRO
\1WalkAnimationCounter:: db
ds 1
\1YDisplacement:: db
\1XDisplacement:: db
\1MapY:: db
\1MapX:: db
\1MovementByte1:: db
\1GrassPriority:: db
\1MovementDelay:: db
\1OrigFacingDirection:: db
ds 3
\1PictureID:: db
\1ImageBaseOffset:: db
ds 1
\1End::
ENDM