add_tm and add_hm define TM##_MOVE and HM##_MOVE constants, to avoid repeating the move names twice

This commit is contained in:
Rangi 2020-07-06 09:32:55 -04:00
parent 405889193e
commit 25a3e67b94
3 changed files with 94 additions and 60 deletions

View file

@ -16,12 +16,12 @@ INCLUDE "constants/pokemon_constants.asm"
INCLUDE "constants/pokedex_constants.asm" INCLUDE "constants/pokedex_constants.asm"
INCLUDE "constants/pokemon_data_constants.asm" INCLUDE "constants/pokemon_data_constants.asm"
INCLUDE "constants/trainer_constants.asm" INCLUDE "constants/trainer_constants.asm"
INCLUDE "constants/item_constants.asm"
INCLUDE "constants/type_constants.asm" INCLUDE "constants/type_constants.asm"
INCLUDE "constants/move_constants.asm" INCLUDE "constants/move_constants.asm"
INCLUDE "constants/move_animation_constants.asm" INCLUDE "constants/move_animation_constants.asm"
INCLUDE "constants/move_effect_constants.asm" INCLUDE "constants/move_effect_constants.asm"
INCLUDE "constants/battle_constants.asm" INCLUDE "constants/battle_constants.asm"
INCLUDE "constants/item_constants.asm"
INCLUDE "constants/icon_constants.asm" INCLUDE "constants/icon_constants.asm"
INCLUDE "constants/sprite_constants.asm" INCLUDE "constants/sprite_constants.asm"
INCLUDE "constants/sprite_data_constants.asm" INCLUDE "constants/sprite_data_constants.asm"

View file

@ -103,10 +103,27 @@ SAFARI_ROCK EQU $16 ; overload
const_value = $C4 const_value = $C4
add_hm: MACRO add_hm: MACRO
if !DEF(HM01) ; Defines three constants:
; - HM_\1: the item id, starting at $C4
; - \1_TMNUM: the learnable TM/HM flag, starting at 51
; - HM##_MOVE: alias for the move id, equal to the value of \1
; The first usage also defines HM01 as the first HM item id.
;
; HMs are defined before TMs, so the value of NUM_TMS is not
; available here, and its value of 50 is hard-coded.
IF !DEF(HM01)
HM01 EQU const_value HM01 EQU const_value
enum_start 51 ; NUM_TMS + 1 enum_start 51 ; NUM_TMS + 1
endc ENDC
HM_VALUE EQU __enum__ - 50 ; __enum__ - NUM_TMS
IF HM_VALUE < 10
MOVE_FOR_HM EQUS "HM0{d:HM_VALUE}_MOVE"
ELSE
MOVE_FOR_HM EQUS "HM{d:HM_VALUE}_MOVE"
ENDC
MOVE_FOR_HM = \1
PURGE MOVE_FOR_HM
PURGE HM_VALUE
const HM_\1 const HM_\1
enum \1_TMNUM enum \1_TMNUM
ENDM ENDM
@ -119,10 +136,22 @@ ENDM
NUM_HMS EQU const_value - HM01 NUM_HMS EQU const_value - HM01
add_tm: MACRO add_tm: MACRO
if !DEF(TM01) ; Defines three constants:
; - TM_\1: the item id, starting at $C9
; - \1_TMNUM: the learnable TM/HM flag, starting at 1
; - TM##_MOVE: alias for the move id, equal to the value of \1
; The first usage also defines TM01 as the first TM item id.
IF !DEF(TM01)
TM01 EQU const_value TM01 EQU const_value
enum_start 1 enum_start 1
endc ENDC
IF __enum__ < 10
MOVE_FOR_TM EQUS "TM0{d:__enum__}_MOVE"
ELSE
MOVE_FOR_TM EQUS "TM{d:__enum__}_MOVE"
ENDC
MOVE_FOR_TM = \1
PURGE MOVE_FOR_TM
const TM_\1 const TM_\1
enum \1_TMNUM enum \1_TMNUM
ENDM ENDM
@ -179,5 +208,7 @@ ENDM
add_tm SUBSTITUTE ; $FA add_tm SUBSTITUTE ; $FA
NUM_TMS EQU const_value - TM01 NUM_TMS EQU const_value - TM01
; 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_start NUM_TMS + NUM_HMS + 1
enum UNUSED_TMNUM enum UNUSED_TMNUM

View file

@ -1,56 +1,59 @@
; The add_hm and add_tm macros in constants/item_constants.asm simultaneously
; define constants for the item IDs and for the corresponding move values.
TechnicalMachines: TechnicalMachines:
db MEGA_PUNCH db TM01_MOVE
db RAZOR_WIND db TM02_MOVE
db SWORDS_DANCE db TM03_MOVE
db WHIRLWIND db TM04_MOVE
db MEGA_KICK db TM05_MOVE
db TOXIC db TM06_MOVE
db HORN_DRILL db TM07_MOVE
db BODY_SLAM db TM08_MOVE
db TAKE_DOWN db TM09_MOVE
db DOUBLE_EDGE db TM10_MOVE
db BUBBLEBEAM db TM11_MOVE
db WATER_GUN db TM12_MOVE
db ICE_BEAM db TM13_MOVE
db BLIZZARD db TM14_MOVE
db HYPER_BEAM db TM15_MOVE
db PAY_DAY db TM16_MOVE
db SUBMISSION db TM17_MOVE
db COUNTER db TM18_MOVE
db SEISMIC_TOSS db TM19_MOVE
db RAGE db TM20_MOVE
db MEGA_DRAIN db TM21_MOVE
db SOLARBEAM db TM22_MOVE
db DRAGON_RAGE db TM23_MOVE
db THUNDERBOLT db TM24_MOVE
db THUNDER db TM25_MOVE
db EARTHQUAKE db TM26_MOVE
db FISSURE db TM27_MOVE
db DIG db TM28_MOVE
db PSYCHIC_M db TM29_MOVE
db TELEPORT db TM30_MOVE
db MIMIC db TM31_MOVE
db DOUBLE_TEAM db TM32_MOVE
db REFLECT db TM33_MOVE
db BIDE db TM34_MOVE
db METRONOME db TM35_MOVE
db SELFDESTRUCT db TM36_MOVE
db EGG_BOMB db TM37_MOVE
db FIRE_BLAST db TM38_MOVE
db SWIFT db TM39_MOVE
db SKULL_BASH db TM40_MOVE
db SOFTBOILED db TM41_MOVE
db DREAM_EATER db TM42_MOVE
db SKY_ATTACK db TM43_MOVE
db REST db TM44_MOVE
db THUNDER_WAVE db TM45_MOVE
db PSYWAVE db TM46_MOVE
db EXPLOSION db TM47_MOVE
db ROCK_SLIDE db TM48_MOVE
db TRI_ATTACK db TM49_MOVE
db SUBSTITUTE db TM50_MOVE
db CUT db HM01_MOVE
db FLY db HM02_MOVE
db SURF db HM03_MOVE
db STRENGTH db HM04_MOVE
db FLASH db HM05_MOVE