Factor out GetHPPals and SetHPPals from home.asm

The remaining code in home.asm is almost all "generic", unrelated to Pokémon-specific game logic, so leaving it as-is might be neater than little home/*.asm files for each routine.
This commit is contained in:
Rangi 2018-05-23 11:08:23 -04:00
parent ad5337863d
commit d2880d1981
2 changed files with 20 additions and 20 deletions

View File

@ -227,26 +227,7 @@ CompareLong:: ; 31e4
; 31f3
INCLUDE "home/tilemap.asm"
SetHPPal:: ; 334e
; Set palette for hp bar pixel length e at hl.
call GetHPPal
ld [hl], d
ret
; 3353
GetHPPal:: ; 3353
; Get palette for hp bar pixel length e in d.
ld d, HP_GREEN
ld a, e
cp (50 * 48 / 100)
ret nc
inc d ; HP_YELLOW
cp (21 * 48 / 100)
ret nc
inc d ; HP_RED
ret
; 335f
INCLUDE "home/hp_pals.asm"
CountSetBits:: ; 0x335f
; Count the number of set bits in b bytes starting from hl.

19
home/hp_pals.asm Normal file
View File

@ -0,0 +1,19 @@
SetHPPal:: ; 334e
; Set palette for hp bar pixel length e at hl.
call GetHPPal
ld [hl], d
ret
; 3353
GetHPPal:: ; 3353
; Get palette for hp bar pixel length e in d.
ld d, HP_GREEN
ld a, e
cp (50 * 48 / 100)
ret nc
inc d ; HP_YELLOW
cp (21 * 48 / 100)
ret nc
inc d ; HP_RED
ret
; 335f