mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-12-05 11:04:30 +13:00
The 'tmhm' macro adjusts to the number of TMs/HMs
This commit is contained in:
parent
21908ba30a
commit
94daf57156
|
|
@ -219,7 +219,9 @@ ENDM
|
||||||
add_tm SUBSTITUTE ; $FA
|
add_tm SUBSTITUTE ; $FA
|
||||||
assert NUM_TMS == const_value - TM01, "NUM_TMS ({d:NUM_TMS}) does not match the number of add_tm definitions"
|
assert NUM_TMS == const_value - TM01, "NUM_TMS ({d:NUM_TMS}) does not match the number of add_tm definitions"
|
||||||
|
|
||||||
|
NUM_TM_HM EQU NUM_TMS + NUM_HMS
|
||||||
|
|
||||||
; 50 TMs + 5 HMs = 55 learnable TM/HM flags per Pokémon.
|
; 50 TMs + 5 HMs = 55 learnable TM/HM flags per Pokémon.
|
||||||
; These fit in 7 bytes, with one unused bit left over.
|
; These fit in 7 bytes, with one unused bit left over.
|
||||||
__tmhm_value__ = NUM_TMS + NUM_HMS + 1
|
__tmhm_value__ = NUM_TM_HM + 1
|
||||||
UNUSED_TMNUM EQU __tmhm_value__
|
UNUSED_TMNUM EQU __tmhm_value__
|
||||||
|
|
|
||||||
|
|
@ -16,36 +16,36 @@ ENDM
|
||||||
coins EQUS "bcd2"
|
coins EQUS "bcd2"
|
||||||
money EQUS "bcd3"
|
money EQUS "bcd3"
|
||||||
|
|
||||||
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-HM05 (7/24)
|
n = 0
|
||||||
|
REPT (NUM_TM_HM + 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)
|
||||||
else
|
PURGE _TM_BYTE
|
||||||
_tms3 = _tms3 | (1 << ((\1_TMNUM) - 1 - 48))
|
ELSE
|
||||||
ENDC
|
FAIL "\1 is not a TM or HM move"
|
||||||
else
|
|
||||||
fail "\1 is not a TM or HM 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 + 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 1 ; TM49-TM50 + HM01-HM05 (7/8)
|
|
||||||
db _tms3 & $ff
|
|
||||||
_tms3 = _tms3 >> 8
|
|
||||||
ENDR
|
ENDR
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue