For my next project I'm using the 8bpp palette from this link: https://wikiti.brandonw.net/index.php?title=84PCE:Ports:4000
Thus, Register A and Register D create a colour in the palette.
I'm trying to get a "fade to black" effect by changing the palette over time. But my palette jumps all over the place instead of simply "fading."
Here's my code, as unoptimized as it may be. What am I doing wrong?
Code:
Thus, Register A and Register D create a colour in the palette.
I'm trying to get a "fade to black" effect by changing the palette over time. But my palette jumps all over the place instead of simply "fading."
Here's my code, as unoptimized as it may be. What am I doing wrong?
Code:
;B is how much to subtract from the BGR colors. B gradually gets larger and larger.
and %01111100 ;The LSB part of "green" does not matter to me
rrca \ rrca
;Now A = the blue amount
sub b
jr c, BlueABelowZero
cp 32
jr c, DoneBlueA
ld a, 31
jr DoneBlueA
BlueABelowZero:
xor a
DoneBlueA:
ld (TB),a ;TB = Where to store the blue value while we work with red and green
ld a, d ; D = the GGGRRRRR part
and %00011111
sub b
jr c, RedABelowZero
cp 32
jr c, DoneRedA
ld a, 31
jr DoneRedA
RedABelowZero:
xor a
DoneRedA:
ld (TR),a ;Temporary red
srl c \ rr d
srl c \ rr d
ld a, d
and %11111000
rrca \ rrca \ rrca
call DoPaletteGreen
ld c, a
ld a, (TB)
sla c \ sla c \ sla c
sla c \ rla
sla c \ rla
push af
ld a, (TR)
add a, c
ld d, a
pop af
; At this point, registers A and D should be the newly-updated palette values
DoPaletteGreen:
sub b
jr c, GreenABelowZero
cp 32
jr c, DoneGreenA
ld a, 31
jr DoneGreenA
GreenABelowZero:
xor a
DoneGreenA:
ret