Hey folks, I'm trying to write a patch for Imzogelmo's color coded MP digits, to temporarily set the Reflect palette back to it's normal green-yellow for the duration the Reflect barrier is shown. I'm calling a routine that's basically a copy of Lenophis' Bad Decoration function to reset the palette at $7FF8-$7FFF, except I've inserted reflect's original four-color palette into free space and it's loading that instead.
It works, and much like Crusader, it overwrites previously-Reflect's-now-actually-MP-numerals palette for the rest of the battle. So naturally, I figured I'd combine this with Bad Decoration. However, from what I can tell, the Bad Decoration code is called multiple times every frame (during animations) and undoes any changes to Reflect's palette. I'm at a loss as to where to call my code from so that the palette changes last throughout Reflect's animation. I don't know exactly how Crusader does it.
I'm currently hooking C1/C9A5, as that is called by Reflect to play the "ping" sound. It's reached via C1/C884 (X = 8B) much in the same way Crusader is (X = 67).
Another approach may be to modify Bad Decoration so that it only calls the code to restore the palette once Crusader/Reflect has finished their animations, but I don't know where to hook Leno's code either.
Here's my code. Also, please find attached the code for Bad Decoration and Color-coded MP Digits (which I've taken the liberty to disassemble and comment for my own understanding).
hirom
;header
!freespacelong = $C0D613 ;new code and palette data (relocatable)
;Called by Reflect
org $C1C9A5
;INC $6281 ;from C1/C884, X = 8B (play "ping" sound?)
JSR c1changepalette
org $C1FFE5
c1changepalette:
JSL changepalette
INC $6281 ;from C1/C884, X = 8B (play ching sound?)
RTS
macro changepalette()
changepalette:
PHA : PHX : PHY : PHP
SEP #$20
TDC
TAX
.loop
LDA newpalette,X ;load the palette
STA $7FF8,X ;store the palette
INX
CPX #$0008
BNE .loop
PLP : PLY : PLX : PLA
RTL
endmacro
;New code (relocatable anywhere)
org !freespacelong
%changepalette()
newpalette:
dw $43FD ;B16:G31:R29 (Pastel Yellow)
dw $3FF1 ;B15:G31:R17 (Pastel Green)
dw $03E0 ;B00:G31:R00 (Light Green)
dw $02E0 ;B00:G23:R00 (Dark Green)