diff options
Diffstat (limited to 'macros')
-rw-r--r-- | macros/code.asm | 64 | ||||
-rw-r--r-- | macros/coords.asm | 4 | ||||
-rw-r--r-- | macros/data.asm | 51 | ||||
-rw-r--r-- | macros/enum.asm | 6 | ||||
-rw-r--r-- | macros/gfx.asm (renamed from macros/color.asm) | 8 | ||||
-rw-r--r-- | macros/legacy.asm | 165 | ||||
-rw-r--r-- | macros/rst.asm | 4 | ||||
-rw-r--r-- | macros/scripts/battle_anims.asm | 4 | ||||
-rw-r--r-- | macros/scripts/battle_commands.asm | 13 | ||||
-rw-r--r-- | macros/scripts/events.asm | 136 | ||||
-rw-r--r-- | macros/scripts/gfx_anims.asm | 2 | ||||
-rw-r--r-- | macros/scripts/maps.asm | 43 | ||||
-rw-r--r-- | macros/scripts/movement.asm | 2 | ||||
-rw-r--r-- | macros/scripts/text.asm | 8 | ||||
-rw-r--r-- | macros/scripts/trade_anims.asm | 15 | ||||
-rw-r--r--[-rwxr-xr-x] | macros/wram.asm | 61 |
16 files changed, 394 insertions, 192 deletions
diff --git a/macros/code.asm b/macros/code.asm index 799c27d45..9429884ca 100644 --- a/macros/code.asm +++ b/macros/code.asm @@ -1,11 +1,11 @@ ; Syntactic sugar macros lb: MACRO ; r, hi, lo - ld \1, (\2 & $ff) << 8 + (\3 & $ff) + ld \1, ((\2) & $ff) << 8 | ((\3) & $ff) ENDM ln: MACRO ; r, hi, lo - ld \1, (\2 & $f) << 4 + (\3 & $f) + ld \1, ((\2) & $f) << 4 | ((\3) & $f) ENDM ldpixel: MACRO @@ -19,7 +19,6 @@ ENDM depixel EQUS "ldpixel de," bcpixel EQUS "ldpixel bc," - ; Design patterns jumptable: MACRO @@ -36,13 +35,15 @@ jumptable: MACRO ENDM maskbits: MACRO -; masks just enough bits to cover the argument +; masks just enough bits to cover the first argument +; the second argument is an optional shift amount ; e.g. "maskbits 26" becomes "and %00011111" (since 26 - 1 = %00011001) +; and "maskbits 3, 2" becomes "and %00001100" (since "maskbits 3" becomes %00000011) ; example usage in rejection sampling: ; .loop ; call Random -; maskbits 30 -; cp 30 +; maskbits 26 +; cp 26 ; jr nc, .loop x = 1 rept 8 @@ -50,5 +51,56 @@ if x + 1 < (\1) x = x << 1 | 1 endc endr +if _NARG == 2 + and x << (\2) +else and x +endc +ENDM + +calc_sine_wave: MACRO +; input: a = a signed 6-bit value +; output: a = d * sin(a * pi/32) + and %111111 + cp %100000 + jr nc, .negative\@ + call .apply\@ + ld a, h + ret +.negative\@ + and %011111 + call .apply\@ + ld a, h + xor $ff + inc a + ret +.apply\@ + ld e, a + ld a, d + ld d, 0 +if _NARG == 1 + ld hl, \1 +else + ld hl, .sinetable\@ +endc + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld hl, 0 +.multiply\@ ; factor amplitude + srl a + jr nc, .even\@ + add hl, de +.even\@ + sla e + rl d + and a + jr nz, .multiply\@ + ret +if _NARG == 0 +.sinetable\@ + sine_table 32 +endc ENDM diff --git a/macros/coords.asm b/macros/coords.asm index 95c4cb041..0833c242c 100644 --- a/macros/coords.asm +++ b/macros/coords.asm @@ -26,11 +26,11 @@ ENDM dwcoord: MACRO ; x, y - rept _NARG / 2 +rept _NARG / 2 dw (\2) * SCREEN_WIDTH + (\1) + wTileMap shift shift - endr +endr ENDM ldcoord_a: MACRO diff --git a/macros/data.asm b/macros/data.asm index 8345a2523..08a23ad29 100644 --- a/macros/data.asm +++ b/macros/data.asm @@ -1,3 +1,7 @@ +; Value macros + +percent EQUS "* $ff / 100" + ; Constant data (db, dw, dl) macros dwb: MACRO @@ -26,29 +30,29 @@ dbwww: MACRO ENDM dn: MACRO ; nybbles - rept _NARG / 2 +rept _NARG / 2 db ((\1) << 4) | (\2) shift shift - endr +endr ENDM dc: MACRO ; "crumbs" - rept _NARG / 4 +rept _NARG / 4 db ((\1) << 6) | ((\2) << 4) | ((\3) << 2) | (\4) shift shift shift shift - endr +endr ENDM dx: MACRO x = 8 * ((\1) - 1) - rept \1 +rept \1 db ((\2) >> x) & $ff x = x + -8 - endr +endr ENDM dt: MACRO ; three-byte (big-endian) @@ -64,17 +68,17 @@ bigdw: MACRO ; big-endian word ENDM dba: MACRO ; dbw bank, address - rept _NARG +rept _NARG dbw BANK(\1), \1 shift - endr +endr ENDM dab: MACRO ; dwb address, bank - rept _NARG +rept _NARG dwb \1, BANK(\1) shift - endr +endr ENDM dba_pic: MACRO ; dbw bank, address @@ -82,7 +86,6 @@ dba_pic: MACRO ; dbw bank, address dw \1 ENDM - dbpixel: MACRO if _NARG >= 4 ; x tile, x pxl, y tile, y pxl @@ -98,28 +101,24 @@ dsprite: MACRO db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5, \6 ENDM - menu_coords: MACRO ; x1, y1, x2, y2 db \2, \1 ; start coords db \4, \3 ; end coords ENDM - -sine_wave: MACRO -; \1: amplitude -x = 0 - rept $20 - ; Round up. - dw (sin(x) + (sin(x) & $ff)) >> 8 -x = x + (\1) * $40000 - endr -ENDM - - bcd: MACRO - rept _NARG +rept _NARG dn ((\1) % 100) / 10, (\1) % 10 shift - endr +endr +ENDM + +sine_table: MACRO +; \1 samples of sin(x) from x=0 to x<32768 (pi radians) +x = 0 +rept \1 + dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up +x = x + DIV(32768, \1) ; a circle has 65536 "degrees" +endr ENDM diff --git a/macros/enum.asm b/macros/enum.asm index c1321a636..009400743 100644 --- a/macros/enum.asm +++ b/macros/enum.asm @@ -22,11 +22,14 @@ enum_set: MACRO __enum__ = \1 ENDM - ; Enumerate constants const_def: MACRO +if _NARG >= 1 +const_value = \1 +else const_value = 0 +endc ENDM const: MACRO @@ -39,7 +42,6 @@ shift_const: MACRO const_value = const_value + 1 ENDM - ; Enumerate strings define: MACRO diff --git a/macros/color.asm b/macros/gfx.asm index 5ebaae218..ff07ba468 100644 --- a/macros/color.asm +++ b/macros/gfx.asm @@ -11,5 +11,9 @@ palred EQUS "(1 << 0) *" palgreen EQUS "(1 << 5) *" palblue EQUS "(1 << 10) *" -palettes EQUS "* 8" -palette EQUS "+ 8 *" +palettes EQUS "* PALETTE_SIZE" +palette EQUS "+ PALETTE_SIZE *" +color EQUS "+ PAL_COLOR_SIZE *" + +tiles EQUS "* LEN_2BPP_TILE" +tile EQUS "+ LEN_2BPP_TILE *" diff --git a/macros/legacy.asm b/macros/legacy.asm new file mode 100644 index 000000000..35e6e9ccb --- /dev/null +++ b/macros/legacy.asm @@ -0,0 +1,165 @@ +; Legacy support for pre-2018 pokecrystal. +; Allows porting scripts with as few edits as possible. + +; macros/rst.asm +callba EQUS "farcall" +callab EQUS "callfar" + +; macros/scripts/audio.asm +unknownmusic0xde EQUS "sound_duty" + +; macros/scripts/events.asm + +checkmorn EQUS "checktime MORN" +checkday EQUS "checktime DAY" +checknite EQUS "checktime NITE" + +if_equal EQUS "ifequal" +if_not_equal EQUS "ifnotequal" +if_greater_than EQUS "ifgreater" +if_less_than EQUS "ifless" +end_all EQUS "endall" + +checkmaptriggers EQUS "checkmapscene" +domaptrigger EQUS "setmapscene" +checktriggers EQUS "checkscene" +dotrigger EQUS "setscene" + +faceperson EQUS "faceobject" +moveperson EQUS "moveobject" +writepersonxy EQUS "writeobjectxy" +spriteface EQUS "turnobject" +objectface EQUS "turnobject" + +RAM2MEM EQUS "vartomem" +loadfont EQUS "opentext" +loadmenudata EQUS "loadmenu" +loadmenuheader EQUS "loadmenu" +writebackup EQUS "closewindow" +interpretmenu EQUS "_2dmenu" +interpretmenu2 EQUS "verticalmenu" +battlecheck EQUS "randomwildmon" +loadtrainerdata EQUS "loadmemtrainer" +loadpokedata EQUS "loadwildmon" +returnafterbattle EQUS "reloadmapafterbattle" +trainerstatus EQUS "trainerflagaction" +talkaftercancel EQUS "endifjustbattled" +talkaftercheck EQUS "checkjustbattled" +playrammusic EQUS "encountermusic" +reloadmapmusic EQUS "dontrestartmapmusic" +resetfuncs EQUS "endall" +storetext EQUS "battletowertext" +displaylocation EQUS "landmarktotext" +givepokeitem EQUS "givepokemail" +checkpokeitem EQUS "checkpokemail" + +; macros/scripts/maps.asm + +mapconst: MACRO + map_const \1, \3, \2 +ENDM + +maptrigger EQUS "scene_script" + +warp_def: MACRO + warp_event \2, \1, \4, \3 +ENDM + +xy_trigger: MACRO + coord_event \3, \2, \1, \5 +ENDM + +signpost: MACRO + bg_event \2, \1, \3, \4 +ENDM + +person_event: MACRO +; object_event \3, \2, \1, \4, \5, \6, \7, \8, \9, \10, \11, \12, \13 + db \1, \2 + 4, \3 + 4, \4 + dn \6, \5 + db \7, \8 + shift + dn \8, \9 + shift + db \9 + shift + dw \9 + shift + dw \9 +ENDM + +PERSONTYPE_SCRIPT EQUS "OBJECTTYPE_SCRIPT" +PERSONTYPE_ITEMBALL EQUS "OBJECTTYPE_ITEMBALL" +PERSONTYPE_TRAINER EQUS "OBJECTTYPE_TRAINER" + +; macros/scripts/movement.asm + +show_person EQUS "show_object" +hide_person EQUS "hide_object" +remove_person EQUS "remove_object" + +turn_head_down EQUS "turn_head DOWN" +turn_head_up EQUS "turn_head UP" +turn_head_left EQUS "turn_head LEFT" +turn_head_right EQUS "turn_head RIGHT" +turn_step_down EQUS "turn_step DOWN" +turn_step_up EQUS "turn_step UP" +turn_step_left EQUS "turn_step LEFT" +turn_step_right EQUS "turn_step RIGHT" +slow_step_down EQUS "slow_step DOWN" +slow_step_up EQUS "slow_step UP" +slow_step_left EQUS "slow_step LEFT" +slow_step_right EQUS "slow_step RIGHT" +step_down EQUS "step DOWN" +step_up EQUS "step UP" +step_left EQUS "step LEFT" +step_right EQUS "step RIGHT" +big_step_down EQUS "big_step DOWN" +big_step_up EQUS "big_step UP" +big_step_left EQUS "big_step LEFT" +big_step_right EQUS "big_step RIGHT" +slow_slide_step_down EQUS "slow_slide_step DOWN" +slow_slide_step_up EQUS "slow_slide_step UP" +slow_slide_step_left EQUS "slow_slide_step LEFT" +slow_slide_step_right EQUS "slow_slide_step RIGHT" +slide_step_down EQUS "slide_step DOWN" +slide_step_up EQUS "slide_step UP" +slide_step_left EQUS "slide_step LEFT" +slide_step_right EQUS "slide_step RIGHT" +fast_slide_step_down EQUS "fast_slide_step DOWN" +fast_slide_step_up EQUS "fast_slide_step UP" +fast_slide_step_left EQUS "fast_slide_step LEFT" +fast_slide_step_right EQUS "fast_slide_step RIGHT" +turn_away_down EQUS "turn_away DOWN" +turn_away_up EQUS "turn_away UP" +turn_away_left EQUS "turn_away LEFT" +turn_away_right EQUS "turn_away RIGHT" +turn_in_down EQUS "turn_in DOWN" +turn_in_up EQUS "turn_in UP" +turn_in_left EQUS "turn_in LEFT" +turn_in_right EQUS "turn_in RIGHT" +turn_waterfall_down EQUS "turn_waterfall DOWN" +turn_waterfall_up EQUS "turn_waterfall UP" +turn_waterfall_left EQUS "turn_waterfall LEFT" +turn_waterfall_right EQUS "turn_waterfall RIGHT" +slow_jump_step_down EQUS "slow_jump_step DOWN" +slow_jump_step_up EQUS "slow_jump_step UP" +slow_jump_step_left EQUS "slow_jump_step LEFT" +slow_jump_step_right EQUS "slow_jump_step RIGHT" +jump_step_down EQUS "jump_step DOWN" +jump_step_up EQUS "jump_step UP" +jump_step_left EQUS "jump_step LEFT" +jump_step_right EQUS "jump_step RIGHT" +fast_jump_step_down EQUS "fast_jump_step DOWN" +fast_jump_step_up EQUS "fast_jump_step UP" +fast_jump_step_left EQUS "fast_jump_step LEFT" +fast_jump_step_right EQUS "fast_jump_step RIGHT" + +step_sleep_1 EQUS "step_sleep 1" +step_sleep_2 EQUS "step_sleep 2" +step_sleep_3 EQUS "step_sleep 3" +step_sleep_4 EQUS "step_sleep 4" +step_sleep_5 EQUS "step_sleep 5" +step_sleep_6 EQUS "step_sleep 6" +step_sleep_7 EQUS "step_sleep 7" +step_sleep_8 EQUS "step_sleep 8" diff --git a/macros/rst.asm b/macros/rst.asm index 58f54d5e8..00505e123 100644 --- a/macros/rst.asm +++ b/macros/rst.asm @@ -14,10 +14,6 @@ callfar: MACRO ; address, bank rst FarCall ENDM -; legacy support for pre-2018 pokecrystal -callba EQUS "farcall" -callab EQUS "callfar" - homecall: MACRO ld a, [hROMBank] push af diff --git a/macros/scripts/battle_anims.asm b/macros/scripts/battle_anims.asm index 5c7aabed3..f25b6da22 100644 --- a/macros/scripts/battle_anims.asm +++ b/macros/scripts/battle_anims.asm @@ -1,6 +1,6 @@ anim_wait: MACRO if \1 >= $d0 - flip out + fail "anim_wait argument must be less than $d0." endc db \1 ENDM @@ -295,7 +295,7 @@ anim_call: MACRO dw \1 ; address ENDM - enum anim_ret_command ; $ff +anim_ret_command EQU -1 ; $ff anim_ret: MACRO db anim_ret_command ENDM diff --git a/macros/scripts/battle_commands.asm b/macros/scripts/battle_commands.asm index 4ae8dbaf4..48e034bdf 100644 --- a/macros/scripts/battle_commands.asm +++ b/macros/scripts/battle_commands.asm @@ -15,10 +15,10 @@ ENDM command damagevariation ; 08 command checkhit ; 09 command lowersub ; 0a - command hittargetnosub ; 0b + command moveanimnosub ; 0b command raisesub ; 0c command failuretext ; 0d - command checkfaint ; 0e + command applydamage ; 0e command criticaltext ; 0f command supereffectivetext ; 10 command checkdestinybond ; 11 @@ -169,19 +169,18 @@ ENDM command ragedamage ; a2 command resettypematchup ; a3 command allstatsup ; a4 - command effect0xa5 ; a5 + command bidefailtext ; a5 command raisesubnoanim ; a6 command lowersubnoanim ; a7 - command effect0xa8 ; a8 + command beatupfailtext ; a8 command clearmissdamage ; a9 command movedelay ; aa - command hittarget ; ab + command moveanim ; ab command tristatuschance ; ac command supereffectivelooptext ; ad command startloop ; ae command curl ; af -__enum__ set $fe - + enum_start $fe command endturn ; fe command endmove ; ff diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm index 9bca1c004..a8f6c2015 100644 --- a/macros/scripts/events.asm +++ b/macros/scripts/events.asm @@ -1,4 +1,4 @@ -; ScriptCommandTable indexes (see engine/scripting.asm) +; ScriptCommandTable indexes (see engine/overworld/scripting.asm) enum_start enum scall_command ; $00 @@ -37,16 +37,16 @@ ptjump: MACRO dw \1 ; pointer ENDM - enum if_equal_command ; $06 -if_equal: MACRO - db if_equal_command + enum ifequal_command ; $06 +ifequal: MACRO + db ifequal_command db \1 ; byte dw \2 ; pointer ENDM - enum if_not_equal_command ; $07 -if_not_equal: MACRO - db if_not_equal_command + enum ifnotequal_command ; $07 +ifnotequal: MACRO + db ifnotequal_command db \1 ; byte dw \2 ; pointer ENDM @@ -63,16 +63,16 @@ iftrue: MACRO dw \1 ; pointer ENDM - enum if_greater_than_command ; $0a -if_greater_than: MACRO - db if_greater_than_command + enum ifgreater_command ; $0a +ifgreater: MACRO + db ifgreater_command db \1 ; byte dw \2 ; pointer ENDM - enum if_less_than_command ; $0b -if_less_than: MACRO - db if_less_than_command + enum ifless_command ; $0b +ifless: MACRO + db ifless_command db \1 ; byte dw \2 ; pointer ENDM @@ -110,13 +110,13 @@ ENDM enum checkmapscene_command ; $11 checkmapscene: MACRO db checkmapscene_command - map \1 ; map + map_id \1 ; map ENDM enum setmapscene_command ; $12 setmapscene: MACRO db setmapscene_command - map \1 ; map + map_id \1 ; map db \2 ; scene_id ENDM @@ -194,23 +194,23 @@ ENDM enum giveitem_command ; $1f giveitem: MACRO +if _NARG == 1 + giveitem \1, 1 +else db giveitem_command db \1 ; item -if _NARG == 2 db \2 ; quantity -else - db 1 endc ENDM enum takeitem_command ; $20 takeitem: MACRO +if _NARG == 1 + takeitem \1, 1 +else db takeitem_command db \1 ; item -if _NARG == 2 db \2 ; quantity -else - db 1 endc ENDM @@ -283,10 +283,6 @@ checktime: MACRO db \1 ; time ENDM -checkmorn EQUS "checktime MORN" -checkday EQUS "checktime DAY" -checknite EQUS "checktime NITE" - enum checkpoke_command ; $2c checkpoke: MACRO db checkpoke_command @@ -295,23 +291,21 @@ ENDM enum givepoke_command ; $2d givepoke: MACRO +if _NARG == 2 + givepoke \1, \2, NO_ITEM, FALSE +elif _NARG == 3 + givepoke \1, \2, \3, FALSE +else db givepoke_command db \1 ; pokemon db \2 ; level - if _NARG >= 3 db \3 ; item - if _NARG >= 4 db \4 ; trainer - if \4 +if \4 dw \5 ; trainer_name_pointer dw \6 ; pkmn_nickname - endc - else - db 0 - endc - else - db 0, 0 - endc +endc +endc ENDM enum giveegg_command ; $2e @@ -321,15 +315,15 @@ giveegg: MACRO db \2 ; level ENDM - enum givepokeitem_command ; $2f -givepokeitem: MACRO - db givepokeitem_command + enum givepokemail_command ; $2f +givepokemail: MACRO + db givepokemail_command dw \1 ; pointer ENDM - enum checkpokeitem_command ; $30 -checkpokeitem: MACRO - db checkpokeitem_command + enum checkpokemail_command ; $30 +checkpokemail: MACRO + db checkpokemail_command dw \1 ; pointer ENDM @@ -389,19 +383,19 @@ ENDM warpmod: MACRO db warpmod_command db \1 ; warp_id - map \2 ; map + map_id \2 ; map ENDM enum blackoutmod_command ; $3b blackoutmod: MACRO db blackoutmod_command - map \1 ; map + map_id \1 ; map ENDM enum warp_command ; $3c warp: MACRO db warp_command - map \1 ; map + map_id \1 ; map db \2 ; x db \3 ; y ENDM @@ -477,11 +471,11 @@ ENDM enum refreshscreen_command ; $48 refreshscreen: MACRO +if _NARG == 0 + refreshscreen 0 +else db refreshscreen_command -if _NARG == 1 db \1 ; dummy -else - db 0 endc ENDM @@ -520,10 +514,10 @@ yesorno: MACRO db yesorno_command ENDM - enum loadmenudata_command ; $4f -loadmenudata: MACRO - db loadmenudata_command - dw \1 ; data + enum loadmenu_command ; $4f +loadmenu: MACRO + db loadmenu_command + dw \1 ; menu_header ENDM enum closewindow_command ; $50 @@ -651,14 +645,14 @@ scripttalkafter: MACRO db scripttalkafter_command ENDM - enum end_if_just_battled_command ; $66 -end_if_just_battled: MACRO - db end_if_just_battled_command + enum endifjustbattled_command ; $66 +endifjustbattled: MACRO + db endifjustbattled_command ENDM - enum check_just_battled_command ; $67 -check_just_battled: MACRO - db check_just_battled_command + enum checkjustbattled_command ; $67 +checkjustbattled: MACRO + db checkjustbattled_command ENDM enum setlasttalked_command ; $68 @@ -751,9 +745,9 @@ showemote: MACRO db \3 ; time ENDM - enum spriteface_command ; $76 -spriteface: MACRO - db spriteface_command + enum turnobject_command ; $76 +turnobject: MACRO + db turnobject_command db \1 ; object id db \2 ; facing ENDM @@ -920,9 +914,9 @@ reloadandreturn: MACRO db \1 ; which_method ENDM - enum end_all_command ; $93 -end_all: MACRO - db end_all_command + enum endall_command ; $93 +endall: MACRO + db endall_command ENDM enum pokemart_command ; $94 @@ -986,12 +980,12 @@ ENDM enum verbosegiveitem_command ; $9e verbosegiveitem: MACRO +if _NARG == 1 + verbosegiveitem \1, 1 +else db verbosegiveitem_command db \1 ; item -if _NARG == 2 db \2 ; quantity -else - db 1 endc ENDM @@ -1006,7 +1000,7 @@ ENDM swarm: MACRO db swarm_command db \1 ; flag - map \2 ; map + map_id \2 ; map ENDM enum halloffame_command ; $a1 @@ -1023,7 +1017,7 @@ ENDM warpfacing: MACRO db warpfacing_command db \1 ; facing - map \2 ; map + map_id \2 ; map db \3 ; x db \4 ; y ENDM @@ -1062,7 +1056,7 @@ wait: MACRO db \1 ; duration ENDM - enum check_save_command ; $a9 -check_save: MACRO - db check_save_command + enum checksave_command ; $a9 +checksave: MACRO + db checksave_command ENDM diff --git a/macros/scripts/gfx_anims.asm b/macros/scripts/gfx_anims.asm index 943a000a9..8f33512ec 100644 --- a/macros/scripts/gfx_anims.asm +++ b/macros/scripts/gfx_anims.asm @@ -4,7 +4,7 @@ frame: MACRO db \1 x = \2 if _NARG > 2 -rept _NARG +- 2 +rept _NARG + -2 x = x | (1 << (\3 + 1)) shift endr diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index 31a1f16d9..7f5947a55 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -1,12 +1,12 @@ -map: MACRO +map_id: MACRO ;\1: map id db GROUP_\1, MAP_\1 ENDM - scene_script: MACRO ;\1: script pointer - dw \1, 0 + dw \1 + dw 0 ; filler ENDM callback: MACRO @@ -15,19 +15,19 @@ callback: MACRO dbw \1, \2 ENDM -warp_def: MACRO +warp_event: MACRO ;\1: x: left to right, starts at 0 ;\2: y: top to bottom, starts at 0 -;\3: warp destination: starts at 1 -;\4: map id: from constants/map_constants.asm - db \2, \1, \3 - map \4 +;\3: map id: from constants/map_constants.asm +;\4: warp destination: starts at 1 + db \2, \1, \4 + map_id \3 ENDM coord_event: MACRO ;\1: x: left to right, starts at 0 ;\2: y: top to bottom, starts at 0 -;\3: scene id: controlled by setscene/setmapscene +;\3: scene id: a SCENE_* constant; controlled by setscene/setmapscene ;\4: script pointer db \3, \2, \1 db 0 ; filler @@ -74,34 +74,33 @@ object_event: MACRO dw \9 ENDM - trainer: MACRO -;\1: flag: an EVENT_BEAT_* constant -;\2: trainer group -;\3: trainer id +;\1: trainer group +;\2: trainer id +;\3: flag: an EVENT_BEAT_* constant ;\4: seen text ;\5: win text ;\6: loss text ;\7: after-battle text - dw \1 - db \2, \3 + dw \3 + db \1, \2 dw \4, \5, \6, \7 ENDM itemball: MACRO ;\1: item: from constants/item_constants.asm ;\2: quantity: default 1 -if _NARG == 2 - db \1, \2 +if _NARG == 1 + itemball \1, 1 else - db \1, 1 + db \1, \2 endc ENDM hiddenitem: MACRO -;\1: flag: an EVENT_* constant -;\2: item: from constants/item_constants.asm - dwb \1, \2 +;\1: item: from constants/item_constants.asm +;\2: flag: an EVENT_* constant + dwb \2, \1 ENDM elevfloor: MACRO @@ -109,7 +108,7 @@ elevfloor: MACRO ;\2: warp destination: starts at 1 ;\3: map id db \1, \2 - map \3 + map_id \3 ENDM conditional_event: MACRO diff --git a/macros/scripts/movement.asm b/macros/scripts/movement.asm index 451608723..83d1ad0e6 100644 --- a/macros/scripts/movement.asm +++ b/macros/scripts/movement.asm @@ -1,4 +1,4 @@ -; MovementPointers indexes (see engine/movement.asm) +; MovementPointers indexes (see engine/overworld/movement.asm) enum_start ; Directional movements diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm index bff18c7ea..d1fec35db 100644 --- a/macros/scripts/text.asm +++ b/macros/scripts/text.asm @@ -46,9 +46,9 @@ text_low: MACRO db TX_LOW ENDM - enum WAIT_BUTTON ; $06 + enum TX_WAIT_BUTTON ; $06 text_waitbutton: MACRO - db WAIT_BUTTON + db TX_WAIT_BUTTON ENDM enum TX_SCROLL ; $07 @@ -56,9 +56,9 @@ text_scroll: MACRO db TX_SCROLL ENDM - enum START_ASM ; $08 + enum TX_START_ASM ; $08 start_asm: MACRO - db START_ASM + db TX_START_ASM ENDM enum TX_NUM ; $09 diff --git a/macros/scripts/trade_anims.asm b/macros/scripts/trade_anims.asm index 94c9070aa..6227f2022 100644 --- a/macros/scripts/trade_anims.asm +++ b/macros/scripts/trade_anims.asm @@ -21,7 +21,7 @@ tradeanim_enter_link_tube: MACRO db tradeanim_enter_link_tube_command ENDM -__enum__ set $5 + enum_start $05 enum tradeanim_exit_link_tube_command ; $05 tradeanim_exit_link_tube: MACRO @@ -33,14 +33,14 @@ tradeanim_tube_to_ot: MACRO db tradeanim_tube_to_ot_command ENDM -__enum__ set $0e + enum_start $0e enum tradeanim_tube_to_player_command ; $0e tradeanim_tube_to_player: MACRO db tradeanim_tube_to_player_command ENDM -__enum__ set $16 + enum_start $16 enum tradeanim_sent_to_ot_text_command ; $16 tradeanim_sent_to_ot_text: MACRO @@ -92,7 +92,7 @@ tradeanim_scroll_out_right: MACRO db tradeanim_scroll_out_right_command ENDM -__enum__ set $21 + enum_start $21 enum tradeanim_wait_80_command ; $21 tradeanim_wait_80: MACRO @@ -119,7 +119,7 @@ tradeanim_wait_anim: MACRO db tradeanim_wait_anim_command ENDM -__enum__ set $27 + enum_start $27 enum tradeanim_poof_command ; $27 tradeanim_poof: MACRO @@ -166,7 +166,6 @@ tradeanim_wait_180_if_ot_egg: MACRO db tradeanim_wait_180_if_ot_egg_command ENDM - ; Mobile enum_start $01 @@ -185,7 +184,7 @@ mobiletradeanim_sendmon: MACRO db mobiletradeanim_sendmon_command ENDM -__enum__ set $05 + enum_start $05 enum mobiletradeanim_05_command ; $05 mobiletradeanim_05: MACRO @@ -207,7 +206,7 @@ mobiletradeanim_receivemon: MACRO db mobiletradeanim_receivemon_command ENDM -__enum__ set $0b + enum_start $0b enum mobiletradeanim_showgetmon_command ; $0b mobiletradeanim_showgetmon: MACRO diff --git a/macros/wram.asm b/macros/wram.asm index 7c8ca44a1..eec839b7d 100755..100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -76,7 +76,6 @@ red_party_struct: MACRO \1Special:: dw ENDM - battle_struct: MACRO \1Species:: db \1Item:: db @@ -103,19 +102,17 @@ battle_struct: MACRO ENDM box: MACRO -\1:: \1Count:: db \1Species:: ds MONS_PER_BOX + 1 \1Mons:: \1Mon1:: box_struct \1Mon1 -\1Mon2:: ds BOXMON_STRUCT_LENGTH * (MONS_PER_BOX +- 1) +\1Mon2:: ds BOXMON_STRUCT_LENGTH * (MONS_PER_BOX + -1) \1MonOT:: ds NAME_LENGTH * MONS_PER_BOX \1MonNicknames:: ds MON_NAME_LENGTH * MONS_PER_BOX \1MonNicknamesEnd:: \1End:: ds 2 ; padding ENDM - map_connection_struct: MACRO \1ConnectedMapGroup:: db \1ConnectedMapNumber:: db @@ -132,7 +129,7 @@ channel_struct: MACRO ; Addreses are wChannel1 (c101). \1MusicID:: dw \1MusicBank:: db -\1Flags:: db ; 0:on/off 1:subroutine 3:sfx 4:noise 5:rest +\1Flags1:: db ; 0:on/off 1:subroutine 3:sfx 4:noise 5:rest \1Flags2:: db ; 0:vibrato on/off 2:duty 4:cry pitch \1Flags3:: db ; 0:vibrato up/down \1MusicAddress:: dw @@ -142,51 +139,49 @@ channel_struct: MACRO \1Condition:: db ; conditional jumps \1DutyCycle:: db ; bits 6-7 (0:12.5% 1:25% 2:50% 3:75%) \1Intensity:: db ; hi:pressure lo:velocity -\1Frequency:: ; 11 bits -\1FrequencyLo:: db -\1FrequencyHi:: db +\1Frequency:: dw ; 11 bits \1Pitch:: db ; 0:rest 1-c:note \1Octave:: db ; 7-0 (0 is highest) \1PitchOffset:: db ; raises existing octaves (to repeat phrases) \1NoteDuration:: db ; frames remaining for the current note -\1Field16:: ds 1 ; c117 - ds 1 ; c118 +\1Field16:: ds 1 + ds 1 \1LoopCount:: db \1Tempo:: dw \1Tracks:: db ; hi:left lo:right -\1SFXDutyLoop:: db ; c11d +\1SFXDutyLoop:: db \1VibratoDelayCount:: db ; initialized by \1VibratoDelay \1VibratoDelay:: db ; number of frames a note plays until vibrato starts \1VibratoExtent:: db \1VibratoRate:: db ; hi:frames for each alt lo:frames to the next alt \1PitchWheelTarget:: dw ; frequency endpoint for pitch wheel -\1PitchWheelAmount:: db ; c124 -\1PitchWheelAmountFraction:: db ; c125 -\1Field25:: db ; c126 - ds 1 ; c127 +\1PitchWheelAmount:: db +\1PitchWheelAmountFraction:: db +\1Field25:: db + ds 1 \1CryPitch:: dw \1Field29:: ds 1 \1Field2a:: ds 2 \1Field2c:: ds 1 \1NoteLength:: db ; frames per 16th note -\1Field2e:: ds 1 ; c12f -\1Field2f:: ds 1 ; c130 -\1Field30:: ds 1 ; c131 - ds 1 ; c132 +\1Field2e:: ds 1 +\1Field2f:: ds 1 +\1Field30:: ds 1 + ds 1 ENDM battle_tower_struct: MACRO -\1Name:: ds NAME_LENGTH +- 1 +\1Name:: ds NAME_LENGTH + -1 \1TrainerClass:: ds 1 -\1Pkmn1:: party_struct \1Pkmn1 -\1Pkmn1Name:: ds MON_NAME_LENGTH -\1Pkmn1NameEnd:: -\1Pkmn2:: party_struct \1Pkmn2 -\1Pkmn2Name:: ds MON_NAME_LENGTH -\1Pkmn2NameEnd:: -\1Pkmn3:: party_struct \1Pkmn3 -\1Pkmn3Name:: ds MON_NAME_LENGTH -\1Pkmn3NameEnd:: +\1Mon1:: party_struct \1Mon1 +\1Mon1Name:: ds MON_NAME_LENGTH +\1Mon1NameEnd:: +\1Mon2:: party_struct \1Mon2 +\1Mon2Name:: ds MON_NAME_LENGTH +\1Mon2NameEnd:: +\1Mon3:: party_struct \1Mon3 +\1Mon3Name:: ds MON_NAME_LENGTH +\1Mon3NameEnd:: \1TrainerData:: ds BATTLETOWER_TRAINERDATALENGTH \1TrainerEnd:: ENDM @@ -222,7 +217,7 @@ hof_mon: MACRO \1ID:: dw \1DVs:: dw \1Level:: db -\1Nickname:: ds MON_NAME_LENGTH +- 1 +\1Nickname:: ds MON_NAME_LENGTH + -1 \1End:: ENDM @@ -234,11 +229,11 @@ hall_of_fame: MACRO \1Mon4:: hof_mon \1Mon4 \1Mon5:: hof_mon \1Mon5 \1Mon6:: hof_mon \1Mon6 -\1End:: ds 1 +\1End:: db ENDM link_battle_record: MACRO -\1Name:: ds NAME_LENGTH +- 1 +\1Name:: ds NAME_LENGTH + -1 \1ID:: dw \1Wins:: dw \1Losses:: dw @@ -285,7 +280,6 @@ slot_reel: MACRO ENDM object_struct: MACRO -\1Struct:: \1Sprite:: db \1MapObjectIndex:: db \1SpriteTile:: db @@ -323,7 +317,6 @@ object_struct: MACRO ENDM map_object: MACRO -\1Object:: \1ObjectStructID:: db \1ObjectSprite:: db \1ObjectYCoord:: db |