diff options
Diffstat (limited to 'home/pokedex_flags.asm')
-rw-r--r-- | home/pokedex_flags.asm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/home/pokedex_flags.asm b/home/pokedex_flags.asm index 424fee13..fe866ba9 100644 --- a/home/pokedex_flags.asm +++ b/home/pokedex_flags.asm @@ -1,3 +1,35 @@ +CountSetBits:: +; Count the number of set bits in b bytes starting from hl. +; Return in a, c and [wNumSetBits]. + ld c, 0 +.next + ld a, [hli] + ld e, a + ld d, 8 + +.count + srl e + ld a, 0 + adc c + ld c, a + dec d + jr nz, .count + + dec b + jr nz, .next + + ld a, c + ld [wNumSetBits], a + ret + +GetWeekday:: + ld a, [wCurDay] +.mod + sub 7 + jr nc, .mod + add 7 + ret + SetSeenAndCaughtMon:: push af ld c, a |