Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → [Pokecrystal] Creating a state that changes a sprite palette

#26 2016-09-11 22:10:07

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,386/3,492

Re: [Pokecrystal] Creating a state that changes a sprite palette

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).

Offline

#27 2016-09-12 12:29:40

Kuroko Aizawa
Member
Registered: 2011-12-01
Post 373/494

Re: [Pokecrystal] Creating a state that changes a sprite palette

Thanks to Mateo, it's like working 95%.

TBS5vZo.png

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

Offline

#28 2016-09-13 02:37:13

Rangi
Member
Registered: 2016-05-09
Post 206/771

Re: [Pokecrystal] Creating a state that changes a sprite palette

So the problem is that Pokémon in battle, specifically your own Pokémon's back sprite, don't use the pink color?

Comparing battle_struct:

battle_struct: MACRO
...
\1DVs::       ds 2
\1PP::        ds NUM_MOVES
\1Happiness:: db
\1Level::     db
\1Status::    ds 2
...

With party_struct:

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)


ROM hack: Pokémon Polished Crystal (GitHub) — version 2.2.0 released!

Offline

  • Index
  • → Help/Question
  • → [Pokecrystal] Creating a state that changes a sprite palette

Board footer

Powered by FluxBB