shithub: pokered

Download patch

ref: bcc4380d40767983a0b253d486bb3c82f0f1fd07
parent: 84694218926e2668ef137783f3c2607f62fa936f
author: Rangi <[email protected]>
date: Mon Apr 19 12:30:07 EDT 2021

Port 'add_tmnum' from pokecrystal

--- a/constants/item_constants.asm
+++ b/constants/item_constants.asm
@@ -118,23 +118,25 @@
 ; match the actual number below.
 NUM_TMS EQU 50
 
+__tmhm_value__ = NUM_TMS + 1
+
+add_tmnum: MACRO
+\1_TMNUM EQU __tmhm_value__
+__tmhm_value__ = __tmhm_value__ + 1
+ENDM
+
 add_hm: MACRO
 ; 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.
-IF !DEF(HM01)
-HM01 EQU const_value
-__tmhm_value__ = NUM_TMS + 1
-ENDC
 	const HM_\1
-\1_TMNUM EQU __tmhm_value__
-__HM_VALUE = __tmhm_value__ - NUM_TMS
-HM{02d:__HM_VALUE}_MOVE EQU \1
-__tmhm_value__ = __tmhm_value__ + 1
+HM_VALUE = __tmhm_value__ - NUM_TMS
+HM{02d:HM_VALUE}_MOVE EQU \1
+	add_tmnum \1
 ENDM
 
+HM01 EQU const_value
 	add_hm CUT          ; $C4
 	add_hm FLY          ; $C5
 	add_hm SURF         ; $C6
@@ -142,22 +144,19 @@
 	add_hm FLASH        ; $C8
 NUM_HMS EQU const_value - HM01
 
+__tmhm_value__ = 1
+
 add_tm: MACRO
 ; 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
-__tmhm_value__ = 1
-ENDC
 	const TM_\1
-\1_TMNUM EQU __tmhm_value__
 TM{02d:__tmhm_value__}_MOVE EQU \1
-__tmhm_value__ = __tmhm_value__ + 1
+	add_tmnum \1
 ENDM
 
+TM01 EQU const_value
 	add_tm MEGA_PUNCH   ; $C9
 	add_tm RAZOR_WIND   ; $CA
 	add_tm SWORDS_DANCE ; $CB