diff options
author | Rangi <remy.oukaour+rangi@gmail.com> | 2020-09-22 12:57:02 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi@gmail.com> | 2020-09-22 12:57:02 -0400 |
commit | 3b4ea37c363b70ea1683059329879466dec4a094 (patch) | |
tree | 430b2260d025fc28880ce3f76882d97dcd50507d /macros | |
parent | 268e2cae0b98779cfb0c590ab9612151c752e868 (diff) |
Replace enum with const, and update many constants to be more like pokegold
Diffstat (limited to 'macros')
-rw-r--r-- | macros/const.asm | 40 | ||||
-rw-r--r-- | macros/data.asm | 2 | ||||
-rw-r--r-- | macros/enum.asm | 53 | ||||
-rw-r--r-- | macros/text.asm | 104 |
4 files changed, 94 insertions, 105 deletions
diff --git a/macros/const.asm b/macros/const.asm new file mode 100644 index 0000000..5dfc3bc --- /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/data.asm b/macros/data.asm index 241e52a..0c3723a 100644 --- a/macros/data.asm +++ b/macros/data.asm @@ -52,7 +52,7 @@ dx: MACRO x = 8 * ((\1) - 1) rept \1 db LOW((\2) >> x) -x = x + -8 +x = x - 8 endr ENDM diff --git a/macros/enum.asm b/macros/enum.asm deleted file mode 100644 index 385aee6..0000000 --- a/macros/enum.asm +++ /dev/null @@ -1,53 +0,0 @@ -; Enumerate variables - -enum_start: MACRO -if _NARG >= 1 -__enum__ = \1 -else -__enum__ = 0 -endc -if _NARG >= 2 -__enumdir__ = \2 -else -__enumdir__ = +1 -endc -ENDM - -enum: MACRO -\1 = __enum__ -__enum__ = __enum__ + __enumdir__ -ENDM - -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 -\1 EQU const_value -const_value = const_value + 1 -ENDM - -shift_const: MACRO -\1 EQU (1 << const_value) -const_value = const_value + 1 -ENDM - - -; Enumerate strings - -define: MACRO -if !DEF(\1) -\1 EQUS \2 -endc -ENDM diff --git a/macros/text.asm b/macros/text.asm index 4ce8d43..a734df7 100644 --- a/macros/text.asm +++ b/macros/text.asm @@ -5,130 +5,132 @@ 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). -text_end EQUS "db $50" ; End control code for text processor (different from "@") -; TODO: determine if these are in -; Pokedex text commands are only used with pokered. -; They are included for compatibility. -page EQUS "db $50," ; Start a new Pokedex page. -dex EQUS "db $e8, $50" ; End a Pokedex entry. +; TextCommands indexes (see home/text.asm) + const_def 1 - enum_start 1 - enum TX_RAM ; $01 + const TX_RAM ; $01 text_from_ram: MACRO db TX_RAM dw \1 ; address - ENDM +endm - enum TX_BCD ; $02 + const TX_BCD ; $02 text_bcd: macro db TX_BCD dw \1 ; address db \2 ; flags + digits, see PrintBCDNumber - ENDM +endm - enum TX_MOVE ; $03 + const TX_MOVE ; $03 text_move: macro db TX_MOVE dw \1 ; address - ENDM +endm - enum TX_BOX ; $04 + const TX_BOX ; $04 text_box: macro db TX_BOX dw \1 ; address db \2, \3 ; width, height - ENDM +endm - enum TX_LOW ; $05 + const TX_LOW ; $05 text_low: macro db TX_LOW - endm +endm - enum WAIT_BUTTON ; $06 + const WAIT_BUTTON ; $06 text_waitbutton: macro db WAIT_BUTTON - endm +endm - enum TX_SCROLL ; $07 + const TX_SCROLL ; $07 text_scroll: macro db TX_SCROLL - endm +endm - enum START_ASM ; $08 + const START_ASM ; $08 start_asm: macro db START_ASM - endm +endm - enum TX_NUM ; $09 + const TX_NUM ; $09 deciram: macro db TX_NUM dw \1 ; address dn \2, \3 ; bytes, flags + digits - endm +endm - enum TX_EXIT ; $0a + const TX_EXIT ; $0a text_exit: macro db TX_EXIT - endm +endm - enum TX_SOUND_0B ; $0b + const TX_SOUND_0B ; $0b sound_dex_fanfare_50_79: macro db TX_SOUND_0B - endm +endm - enum TX_DOTS ; $0c + const TX_DOTS ; $0c text_dots: macro db TX_DOTS db \1 - endm +endm - enum TX_LINK_WAIT_BUTTON ; $0d + const TX_LINK_WAIT_BUTTON ; $0d link_wait_button: macro db TX_LINK_WAIT_BUTTON - endm +endm - enum TX_SOUND_0E ; $0e + const TX_SOUND_0E ; $0e sound_dex_fanfare_20_49: macro db TX_SOUND_0E - endm +endm - enum TX_SOUND_0F ; $0f + const TX_SOUND_0F ; $0f sound_item: macro db TX_SOUND_0F - endm +endm - enum TX_SOUND_10 ; $10 + const TX_SOUND_10 ; $10 sound_caught_mon: macro db TX_SOUND_10 - endm +endm - enum TX_SOUND_11 ; $11 + const TX_SOUND_11 ; $11 sound_dex_fanfare_80_109: macro db TX_SOUND_11 - endm +endm - enum TX_SOUND_12 ; $12 + const TX_SOUND_12 ; $12 sound_fanfare: macro db TX_SOUND_12 - endm +endm - enum TX_SOUND_13 ; $13 + const TX_SOUND_13 ; $13 sound_slot_machine_start: macro db TX_SOUND_13 - endm +endm - enum TX_CRY_14 ; $14 + const TX_CRY_14 ; $14 cry_nidorina: macro db TX_CRY_14 - endm +endm - enum TX_CRY_15 ; $15 + const TX_CRY_15 ; $15 cry_pigeot: macro db TX_CRY_15 - endm +endm - enum TX_CRY_16 ; $16 + const TX_CRY_16 ; $16 cry_jugon: macro db TX_CRY_16 - endm +endm + + const_next $50 + + const TX_END ; $50 +text_end: macro + db TX_END +endm |