You are not logged in.
When you pop af, you not only return a to its original value like you meant to, you also undo the changes to the flags that you made, therefore making the cp instruction pointless (you can't test for its results after the call, because you overwrite them before you return to the main function).
Thanks to Mateo, it's like working 95%.
Except for that. Yeah.
CheckPink: push bc rept 11 inc bc endr ld a, [bc] cp (1 << PNK) pop bc ret GetMonPalettePointer: push af call CheckPink ; return 0 in a if not pink, 1 if pink jr z, .pink pop af ld l, a ld h, $0 add hl, hl add hl, hl add hl, hl ld bc, PokemonPalettes add hl, bc ret .pink: pop af ; so we don't just leave that register pair that we pushed hanging around ld hl, PokemonPalettes ret
So the problem is that Pokémon in battle, specifically your own Pokémon's back sprite, don't use the pink color?
battle_struct: MACRO ... \1DVs:: ds 2 \1PP:: ds NUM_MOVES \1Happiness:: db \1Level:: db \1Status:: ds 2 ...
party_struct: MACRO ; include stuff from box_struct ... \1DVs:: ds 2 \1PP:: ds NUM_MOVES \1Happiness:: db \1PokerusStatus:: db \1CaughtLevel:: db \1CaughtLocation:: db \1Level:: db ; now this is unique to party_struct \1Status:: db ...
There are three fewer bytes between DVs and Status in battle_struct than in party_struct.
A hacky way to account for this would be to check if bc == BattleMonDVs in CheckPink, and if so, add 8 instead of 11. And do the same thing if bc == EnemyMonDVs, since wild Pokémon can be pink too.
Something like this would work:
; check if bc == BattleMonDVs push hl ld hl, BattleMonDVs ld a, h cp b jr nz, .bc_is_not_battlemondvs ld a, l cp c jr nz, .bc_is_not_battlemondvs ; over here you know that bc == BattleMonDVs jr .bc_uses_battle_struct .bc_is_not_battlemondvs: ; check if bc == EnemyMonDVs ld hl, BattleMonDVs ld a, h cp b jr nz, .bc_is_not_enemymondvs_either ld a, l cp c jr nz, .bc_is_not_enemymondvs_either ; over here you know that bc == EnemyMonDVs .bc_uses_battle_struct: pop hl ; add 8 to bc to get Status ... .bc_is_not_enemymondvs_either: ; add 11 to bc to get Status ...
Last edited by Rangi (2016-09-13 02:50:36)