add_tm, add_hm, and add_mt define TM##_MOVE, HM##_MOVE, and MT##_MOVE constants, to avoid repeating the move names in tmhm_moves.asm

This commit is contained in:
Rangi 2020-07-06 16:53:05 -04:00
parent ddf1163a21
commit 43a9295789
4 changed files with 87 additions and 67 deletions

View File

@ -19,8 +19,6 @@ INCLUDE "constants/cry_constants.asm"
INCLUDE "constants/engine_flags.asm" INCLUDE "constants/engine_flags.asm"
INCLUDE "constants/event_flags.asm" INCLUDE "constants/event_flags.asm"
INCLUDE "constants/icon_constants.asm" INCLUDE "constants/icon_constants.asm"
INCLUDE "constants/item_constants.asm"
INCLUDE "constants/item_data_constants.asm"
INCLUDE "constants/landmark_constants.asm" INCLUDE "constants/landmark_constants.asm"
INCLUDE "constants/map_constants.asm" INCLUDE "constants/map_constants.asm"
INCLUDE "constants/map_data_constants.asm" INCLUDE "constants/map_data_constants.asm"
@ -31,6 +29,8 @@ INCLUDE "constants/menu_constants.asm"
INCLUDE "constants/mobile_constants.asm" INCLUDE "constants/mobile_constants.asm"
INCLUDE "constants/move_constants.asm" INCLUDE "constants/move_constants.asm"
INCLUDE "constants/move_effect_constants.asm" INCLUDE "constants/move_effect_constants.asm"
INCLUDE "constants/item_constants.asm"
INCLUDE "constants/item_data_constants.asm"
INCLUDE "constants/music_constants.asm" INCLUDE "constants/music_constants.asm"
INCLUDE "constants/npc_trade_constants.asm" INCLUDE "constants/npc_trade_constants.asm"
INCLUDE "constants/phone_constants.asm" INCLUDE "constants/phone_constants.asm"

View File

@ -198,10 +198,22 @@
const ITEM_BE ; be const ITEM_BE ; be
add_tm: MACRO add_tm: MACRO
; Defines three constants:
; - TM_\1: the item id, starting at $bf
; - \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) 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
@ -259,12 +271,26 @@ ENDM
add_tm FIRE_PUNCH ; f0 add_tm FIRE_PUNCH ; f0
add_tm FURY_CUTTER ; f1 add_tm FURY_CUTTER ; f1
add_tm NIGHTMARE ; f2 add_tm NIGHTMARE ; f2
NUM_TMS EQU const_value - TM01 - 2 ; discount ITEM_C3 and ITEM_DC NUM_TMS EQU __enum__ - 1
add_hm: MACRO add_hm: MACRO
; Defines three constants:
; - HM_\1: the item id, starting at $f3
; - \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 TM item id.
if !DEF(HM01) if !DEF(HM01)
HM01 EQU const_value HM01 EQU const_value
endc endc
HM_VALUE EQU __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
@ -276,15 +302,29 @@ ENDM
add_hm FLASH ; f7 add_hm FLASH ; f7
add_hm WHIRLPOOL ; f8 add_hm WHIRLPOOL ; f8
add_hm WATERFALL ; f9 add_hm WATERFALL ; f9
NUM_HMS EQU const_value - HM01 NUM_HMS EQU __enum__ - NUM_TMS - 1
add_mt: MACRO add_mt: MACRO
; Defines two constants:
; - \1_TMNUM: the learnable TM/HM flag, starting at 58
; - MT##_MOVE: alias for the move id, equal to the value of \1
MT_VALUE EQU __enum__ - NUM_TMS - NUM_HMS
if MT_VALUE < 10
MOVE_FOR_MT EQUS "MT0{d:MT_VALUE}_MOVE"
else
MOVE_FOR_MT EQUS "MT{d:MT_VALUE}_MOVE"
endc
MOVE_FOR_MT = \1
PURGE MOVE_FOR_MT
PURGE MT_VALUE
enum \1_TMNUM enum \1_TMNUM
ENDM ENDM
add_mt FLAMETHROWER add_mt FLAMETHROWER
add_mt THUNDERBOLT add_mt THUNDERBOLT
add_mt ICE_BEAM add_mt ICE_BEAM
NUM_TUTORS = __enum__ - NUM_TMS - NUM_HMS - 1
NUM_TM_HM_TUTOR EQU __enum__ - 1 NUM_TM_HM_TUTOR EQU __enum__ - 1
const ITEM_FA ; fa const ITEM_FA ; fa

View File

@ -1,66 +1,46 @@
; The add_tm, add_hm, and add_mt macros in constants/item_constants.asm simultaneously
; define constants for the item IDs and for the corresponding move values.
TMHMMoves: TMHMMoves:
; entries correspond to *_TMNUM enums (see constants/item_constants.asm) ; entries correspond to *_TMNUM enums (see constants/item_constants.asm)
; TMs ; TMs
db DYNAMICPUNCH n = 1
db HEADBUTT rept NUM_TMS
db CURSE if n < 10
db ROLLOUT MOVE_FOR_TM EQUS "TM0{d:n}_MOVE"
db ROAR else
db TOXIC MOVE_FOR_TM EQUS "TM{d:n}_MOVE"
db ZAP_CANNON endc
db ROCK_SMASH db MOVE_FOR_TM
db PSYCH_UP PURGE MOVE_FOR_TM
db HIDDEN_POWER n = n + 1
db SUNNY_DAY endr
db SWEET_SCENT
db SNORE
db BLIZZARD
db HYPER_BEAM
db ICY_WIND
db PROTECT
db RAIN_DANCE
db GIGA_DRAIN
db ENDURE
db FRUSTRATION
db SOLARBEAM
db IRON_TAIL
db DRAGONBREATH
db THUNDER
db EARTHQUAKE
db RETURN
db DIG
db PSYCHIC_M
db SHADOW_BALL
db MUD_SLAP
db DOUBLE_TEAM
db ICE_PUNCH
db SWAGGER
db SLEEP_TALK
db SLUDGE_BOMB
db SANDSTORM
db FIRE_BLAST
db SWIFT
db DEFENSE_CURL
db THUNDERPUNCH
db DREAM_EATER
db DETECT
db REST
db ATTRACT
db THIEF
db STEEL_WING
db FIRE_PUNCH
db FURY_CUTTER
db NIGHTMARE
; HMs ; HMs
db CUT n = 1
db FLY rept NUM_HMS
db SURF if n < 10
db STRENGTH MOVE_FOR_HM EQUS "HM0{d:n}_MOVE"
db FLASH else
db WHIRLPOOL MOVE_FOR_HM EQUS "HM{d:n}_MOVE"
db WATERFALL endc
db MOVE_FOR_HM
PURGE MOVE_FOR_HM
n = n + 1
endr
; Move tutor ; Move tutor
db FLAMETHROWER n = 1
db THUNDERBOLT rept NUM_TUTORS
db ICE_BEAM if n < 10
MOVE_FOR_MT EQUS "MT0{d:n}_MOVE"
else
MOVE_FOR_MT EQUS "MT{d:n}_MOVE"
endc
db MOVE_FOR_MT
PURGE MOVE_FOR_MT
n = n + 1
endr
db 0 ; end db 0 ; end

View File

@ -40,15 +40,15 @@ MoveTutor:
cp MOVETUTOR_THUNDERBOLT cp MOVETUTOR_THUNDERBOLT
jr z, .thunderbolt jr z, .thunderbolt
; MOVETUTOR_ICE_BEAM ; MOVETUTOR_ICE_BEAM
ld a, ICE_BEAM ld a, MT03_MOVE ; ICE_BEAM
ret ret
.flamethrower .flamethrower
ld a, FLAMETHROWER ld a, MT01_MOVE ; FLAMETHROWER
ret ret
.thunderbolt .thunderbolt
ld a, THUNDERBOLT ld a, MT02_MOVE ; THUNDERBOLT
ret ret
CheckCanLearnMoveTutorMove: CheckCanLearnMoveTutorMove: