The 'tmhm' macro adjusts to the number of TMs/HMs/tutors

This commit is contained in:
Rangi 2021-01-06 10:20:19 -05:00
parent 5db892782a
commit f773fd1dd8
1 changed files with 23 additions and 23 deletions

View File

@ -1,33 +1,33 @@
tmhm: MACRO
; used in data/pokemon/base_stats/*.asm ; used in data/pokemon/base_stats/*.asm
_tms1 = 0 ; TM01-TM24 (24) tmhm: MACRO
_tms2 = 0 ; TM25-TM48 (24) ; initialize bytes to 0
_tms3 = 0 ; TM49-TM50 + HM01-HM07 + MT01-MT03 (12/24) n = 0
rept (NUM_TM_HM_TUTOR + 7) / 8
_TM_BYTE EQUS "_tm{d:n}"
_TM_BYTE = 0
PURGE _TM_BYTE
n = n + 1
endr
; set bits of bytes
rept _NARG rept _NARG
if DEF(\1_TMNUM) if DEF(\1_TMNUM)
if \1_TMNUM < 24 + 1 n = (\1_TMNUM - 1) / 8
_tms1 = _tms1 | (1 << ((\1_TMNUM) - 1)) i = (\1_TMNUM - 1) % 8
elif \1_TMNUM < 48 + 1 _TM_BYTE EQUS "_tm{d:n}"
_tms2 = _tms2 | (1 << ((\1_TMNUM) - 1 - 24)) _TM_BYTE = _TM_BYTE | (1 << i)
PURGE _TM_BYTE
else else
_tms3 = _tms3 | (1 << ((\1_TMNUM) - 1 - 48)) fail "\1 is not a TM, HM, or tutor move"
endc
else
fail "\1 is not a TM, HM, or move tutor move"
endc endc
shift shift
endr endr
rept 3 ; TM01-TM24 (24/24) ; output bytes
db _tms1 & $ff n = 0
_tms1 = _tms1 >> 8 rept (NUM_TM_HM_TUTOR + 7) / 8
endr _TM_BYTE EQUS "_tm{d:n}"
rept 3 ; TM25-TM48 (24/24) db _TM_BYTE
db _tms2 & $ff PURGE _TM_BYTE
_tms2 = _tms2 >> 8 n = n + 1
endr
rept 2 ; TM49-TM50 + HM01-HM07 + MT01-MT03 (12/16)
db _tms3 & $ff
_tms3 = _tms3 >> 8
endr endr
ENDM ENDM