Eliminate enum: use const instead, with case-by-case parallel const implementations

This commit is contained in:
Rangi 2020-07-09 12:43:26 -04:00
parent 54d76dec38
commit 676a35f76f
5 changed files with 75 additions and 92 deletions

View file

@ -115,9 +115,9 @@ add_hm: MACRO
; The first usage also defines HM01 as the first HM item id.
IF !DEF(HM01)
HM01 EQU const_value
enum_start NUM_TMS + 1
__tmhm_value__ = NUM_TMS + 1
ENDC
HM_VALUE EQU __enum__ - NUM_TMS
HM_VALUE EQU __tmhm_value__ - NUM_TMS
IF HM_VALUE < 10
MOVE_FOR_HM EQUS "HM0{d:HM_VALUE}_MOVE"
ELSE
@ -127,7 +127,8 @@ MOVE_FOR_HM = \1
PURGE MOVE_FOR_HM
PURGE HM_VALUE
const HM_\1
enum \1_TMNUM
\1_TMNUM EQU __tmhm_value__
__tmhm_value__ = __tmhm_value__ + 1
ENDM
add_hm CUT ; $C4
@ -145,17 +146,18 @@ add_tm: MACRO
; The first usage also defines TM01 as the first TM item id.
IF !DEF(TM01)
TM01 EQU const_value
enum_start 1
__tmhm_value__ = 1
ENDC
IF __enum__ < 10
MOVE_FOR_TM EQUS "TM0{d:__enum__}_MOVE"
IF __tmhm_value__ < 10
MOVE_FOR_TM EQUS "TM0{d:__tmhm_value__}_MOVE"
ELSE
MOVE_FOR_TM EQUS "TM{d:__enum__}_MOVE"
MOVE_FOR_TM EQUS "TM{d:__tmhm_value__}_MOVE"
ENDC
MOVE_FOR_TM = \1
PURGE MOVE_FOR_TM
const TM_\1
enum \1_TMNUM
\1_TMNUM EQU __tmhm_value__
__tmhm_value__ = __tmhm_value__ + 1
ENDM
add_tm MEGA_PUNCH ; $C9
@ -212,5 +214,5 @@ assert NUM_TMS == const_value - TM01, "NUM_TMS ({d:NUM_TMS}) does not match the
; 50 TMs + 5 HMs = 55 learnable TM/HM flags per Pokémon.
; These fit in 7 bytes, with one unused bit left over.
enum_start NUM_TMS + NUM_HMS + 1
enum UNUSED_TMNUM
__tmhm_value__ = NUM_TMS + NUM_HMS + 1
UNUSED_TMNUM EQU __tmhm_value__