diff options
author | dannye <33dannye@gmail.com> | 2020-11-04 00:06:44 -0600 |
---|---|---|
committer | dannye <33dannye@gmail.com> | 2020-11-04 00:06:44 -0600 |
commit | 5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch) | |
tree | dde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /macros | |
parent | 53fcd05aa24693093d8af1dc8ec4fedd3957decc (diff) |
Sync with pokered
Diffstat (limited to 'macros')
-rwxr-xr-x | macros/asm_macros.asm | 190 | ||||
-rwxr-xr-x | macros/code.asm | 20 | ||||
-rw-r--r-- | macros/const.asm | 40 | ||||
-rw-r--r-- | macros/coords.asm | 90 | ||||
-rwxr-xr-x | macros/data.asm | 80 | ||||
-rwxr-xr-x | macros/data_macros.asm | 242 | ||||
-rw-r--r-- | macros/farcall.asm | 33 | ||||
-rw-r--r-- | macros/gfx.asm | 22 | ||||
-rw-r--r-- | macros/predef.asm | 36 | ||||
-rwxr-xr-x | macros/scripts/audio.asm (renamed from macros/audio_macros.asm) | 119 | ||||
-rw-r--r-- | macros/scripts/events.asm (renamed from macros/event_macros.asm) | 110 | ||||
-rw-r--r-- | macros/scripts/maps.asm | 225 | ||||
-rwxr-xr-x | macros/scripts/text.asm | 213 | ||||
-rwxr-xr-x | macros/text_macros.asm | 80 | ||||
-rw-r--r-- | macros/wram.asm | 97 |
15 files changed, 995 insertions, 602 deletions
diff --git a/macros/asm_macros.asm b/macros/asm_macros.asm deleted file mode 100755 index 7012d7e1..00000000 --- a/macros/asm_macros.asm +++ /dev/null @@ -1,190 +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) - call BankswitchCommon - call \1 - pop af - call BankswitchCommon -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 - db (\1 << 4 | \2) -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 - -; 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 diff --git a/macros/code.asm b/macros/code.asm new file mode 100755 index 00000000..8507b1ad --- /dev/null +++ b/macros/code.asm @@ -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 diff --git a/macros/const.asm b/macros/const.asm new file mode 100644 index 00000000..57380e97 --- /dev/null +++ b/macros/const.asm @@ -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 diff --git a/macros/coords.asm b/macros/coords.asm new file mode 100644 index 00000000..6b16e7f7 --- /dev/null +++ b/macros/coords.asm @@ -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 diff --git a/macros/data.asm b/macros/data.asm new file mode 100755 index 00000000..16742d53 --- /dev/null +++ b/macros/data.asm @@ -0,0 +1,80 @@ +; 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" + +tmhm: MACRO +; used in data/pokemon/base_stats/*.asm +_tms1 = 0 ; TM01-TM24 (24) +_tms2 = 0 ; TM25-TM48 (24) +_tms3 = 0 ; TM49-TM50 + HM01-HM05 (7/24) +REPT _NARG + if DEF(\1_TMNUM) + if \1_TMNUM < 24 + 1 +_tms1 = _tms1 | (1 << ((\1_TMNUM) - 1)) + ELIF \1_TMNUM < 48 + 1 +_tms2 = _tms2 | (1 << ((\1_TMNUM) - 1 - 24)) + else +_tms3 = _tms3 | (1 << ((\1_TMNUM) - 1 - 48)) + ENDC + else + fail "\1 is not a TM or HM move" + ENDC + SHIFT +ENDR +REPT 3 ; TM01-TM24 (24/24) + db _tms1 & $ff +_tms1 = _tms1 >> 8 +ENDR +REPT 3 ; TM25-TM48 (24/24) + db _tms2 & $ff +_tms2 = _tms2 >> 8 +ENDR +REPT 1 ; TM49-TM50 + HM01-HM05 (7/8) + db _tms3 & $ff +_tms3 = _tms3 >> 8 +ENDR +ENDM + + +; Constant data (db, dw, dl) macros + +dn: MACRO ; nybbles + db (\1 << 4 | \2) +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 diff --git a/macros/data_macros.asm b/macros/data_macros.asm deleted file mode 100755 index ee5cb8f0..00000000 --- a/macros/data_macros.asm +++ /dev/null @@ -1,242 +0,0 @@ - -; Constant enumeration is useful for monsters, items, moves, etc. -const_def: MACRO -const_value = 0 -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 diff --git a/macros/farcall.asm b/macros/farcall.asm new file mode 100644 index 00000000..b4af8b2d --- /dev/null +++ b/macros/farcall.asm @@ -0,0 +1,33 @@ +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) + call BankswitchCommon + call \1 + pop af + call BankswitchCommon +ENDM diff --git a/macros/gfx.asm b/macros/gfx.asm new file mode 100644 index 00000000..98eabec4 --- /dev/null +++ b/macros/gfx.asm @@ -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 diff --git a/macros/predef.asm b/macros/predef.asm new file mode 100644 index 00000000..f4e7f609 --- /dev/null +++ b/macros/predef.asm @@ -0,0 +1,36 @@ +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 + +predef_const: MACRO + const \1PredefID +ENDM diff --git a/macros/audio_macros.asm b/macros/scripts/audio.asm index 6daadbc6..b12a2adc 100755 --- a/macros/audio_macros.asm +++ b/macros/scripts/audio.asm @@ -1,18 +1,3 @@ - -;StopAllMusic: MACRO -; ld a, $ff -; call PlaySound -;ENDM - -Ch1 EQU 0 -Ch2 EQU 1 -Ch3 EQU 2 -Ch4 EQU 3 -Ch5 EQU 4 -Ch6 EQU 5 -Ch7 EQU 6 -Ch8 EQU 7 - audio_header: MACRO db (_NARG - 2) << 6 | \2 dw \1_\2 @@ -30,14 +15,17 @@ audio_header: MACRO 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 $10 + db pitch_sweep_cmd IF \2 < 0 db (\1 << 4) | (%1000 | (\2 * -1)) ELSE @@ -45,12 +33,17 @@ pitch_sweep: MACRO 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 $20 | \1 + db square_note_cmd | \1 IF \3 < 0 db (\2 << 4) | (%1000 | (\3 * -1)) ELSE @@ -63,8 +56,9 @@ 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 - db $20 | \1 + db noise_note_cmd | \1 IF \3 < 0 db (\2 << 4) | (%1000 | (\3 * -1)) ELSE @@ -73,27 +67,17 @@ noise_note: MACRO db \4 ENDM -C_ EQU $0 -C# EQU $1 -D_ EQU $2 -D# EQU $3 -E_ EQU $4 -F_ EQU $5 -F# EQU $6 -G_ EQU $7 -G# EQU $8 -A_ EQU $9 -A# EQU $A -B_ EQU $B - ; 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 $B0 | (\2 - 1) + db drum_note_cmd | (\2 - 1) db \1 ENDM @@ -105,17 +89,23 @@ drum_note_short: MACRO db (\1 << 4) | (\2 - 1) ENDM + const_next $c0 + ; arguments: length [1, 16] + const rest_cmd ; $c0 rest: MACRO - db $C0 | (\1 - 1) + 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 $D0 | \1 + db note_type_cmd | \1 IF \3 < 0 db (\2 << 4) | (%1000 | (\3 * -1)) ELSE @@ -124,40 +114,52 @@ note_type: MACRO ENDM ; arguments: speed [0, 15] +drum_speed_cmd EQU note_type_cmd ; $d0 drum_speed: MACRO - db $D0 | \1 + db drum_speed_cmd | \1 ENDM + const_next $e0 + ; arguments: octave [1, 8] + const octave_cmd ; $e0 octave: MACRO - db $E8 - \1 + 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 $E8 + 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 $EA + 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 $EB + 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 $EC + db duty_cycle_cmd db \1 ENDM @@ -167,48 +169,65 @@ ENDM ; 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 $ED - db \1 / $100 - db \1 % $100 + 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 $EE + 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 $F0 + 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 $F8 + 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 $FC + 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 $FD + db sound_call_cmd dw \1 ENDM ; arguments: count, address + const sound_loop_cmd ; $fe sound_loop: MACRO - db $FE + db sound_loop_cmd db \1 dw \2 ENDM + const sound_ret_cmd ; $ff sound_ret: MACRO - db $FF + db sound_ret_cmd ENDM diff --git a/macros/event_macros.asm b/macros/scripts/events.asm index a3ce9746..266ffdd1 100644 --- a/macros/event_macros.asm +++ b/macros/scripts/events.asm @@ -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,14 +51,16 @@ 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 + EventFlagAddressa: MACRO event_byte = ((\1) / 8) @@ -72,7 +77,8 @@ CheckEventHL: MACRO event_byte = ((\1) / 8) ld hl, wEventFlags + event_byte bit (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index CheckEventReuseHL: MACRO @@ -82,14 +88,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 @@ -101,7 +109,8 @@ event_byte = ((\1) / 8) ENDC bit (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index CheckAndSetEvent: MACRO @@ -109,7 +118,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 @@ -117,7 +127,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 @@ -125,7 +136,8 @@ CheckAndSetEventA: MACRO bit (\1) % 8, a set (\1) % 8, a ld [wEventFlags + ((\1) / 8)], a - ENDM +ENDM + ;\1 = event index CheckAndResetEventA: MACRO @@ -133,7 +145,8 @@ CheckAndResetEventA: MACRO bit (\1) % 8, a res (\1) % 8, a ld [wEventFlags + ((\1) / 8)], a - ENDM +ENDM + CheckAndSetEventReuseHL: MACRO IF event_byte != ((\1) / 8) @@ -161,7 +174,8 @@ SetEvent: MACRO event_byte = ((\1) / 8) ld hl, wEventFlags + event_byte set (\1) % 8, [hl] - ENDM +ENDM + ;\1 = event index SetEventReuseHL: MACRO @@ -171,7 +185,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 @@ -183,32 +198,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 @@ -218,7 +237,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 @@ -230,25 +250,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) @@ -258,7 +281,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) @@ -268,7 +292,8 @@ dwEventFlagAddress: MACRO ELSE dw wEventFlags + ((\1) / 8) ENDC - ENDM +ENDM + ;\1 = start ;\2 = end @@ -289,7 +314,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] @@ -310,7 +335,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 @@ -328,7 +353,8 @@ event_fill_count = event_fill_count + 1 ENDC ENDC ENDC - ENDM +ENDM + ;\1 = start ;\2 = end @@ -350,7 +376,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] @@ -375,7 +401,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 @@ -393,7 +419,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 @@ -431,7 +458,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 @@ -460,7 +488,8 @@ CheckEitherEventSet: MACRO pop bc ENDC ENDC - ENDM +ENDM + CheckEitherEventSetReuseA: MACRO IF event_byte != ((\1) / 8) @@ -499,4 +528,5 @@ AdjustEventBit: MACRO IF ((\1) % 8) != (\2) add ((\1) % 8) - (\2) ENDC - ENDM +ENDM + diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm new file mode 100644 index 00000000..2032629b --- /dev/null +++ b/macros/scripts/maps.asm @@ -0,0 +1,225 @@ +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 +_NUM_WARPS = _NUM_WARPS + 1 +; the Nth warp defines a corresponding Nth warp_to, stored in _WARP_TO_NUM_<N> +_WARP_TO_NAME EQUS "_WARP_TO_NUM_{d:{_NUM_WARPS}}" +_WARP_TO_NAME EQUS "warp_to \1, \2, _WARP_TO_WIDTH" + PURGE _WARP_TO_NAME +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 +; output and purge each _WARP_TO_NUM_<N> warp_to, from N=1 to _NUM_WARPS +_WARP_TO_WIDTH = \1_WIDTH +_WARP_TO_N = 1 + REPT _NUM_WARPS +_WARP_TO_NAME EQUS "_WARP_TO_NUM_{d:_WARP_TO_N}" + _WARP_TO_NAME +_WARP_TO_N = _WARP_TO_N + 1 +_PURGE_WARP_TO_NUM EQUS "PURGE {_WARP_TO_NAME}" + _PURGE_WARP_TO_NUM + PURGE _PURGE_WARP_TO_NUM + PURGE _WARP_TO_NAME + 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 diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm new file mode 100755 index 00000000..2ec1de43 --- /dev/null +++ b/macros/scripts/text.asm @@ -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_PIKACHU ; $14 +sound_cry_pikachu: MACRO + db TX_SOUND_CRY_PIKACHU +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 diff --git a/macros/text_macros.asm b/macros/text_macros.asm deleted file mode 100755 index 21e02634..00000000 --- a/macros/text_macros.asm +++ /dev/null @@ -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" diff --git a/macros/wram.asm b/macros/wram.asm new file mode 100644 index 00000000..41fd1dad --- /dev/null +++ b/macros/wram.asm @@ -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 |