I am trying to fade color 5 from white to black, but unfortunately my code apparently only fades the blue and green parts. The red part does note fade and is directly set to 0, atleast so it appears to me.
Where is my thinking flaw?
DB #FE
DW START,END,START
ORG #C000
START:
;ld a,5
;call #5F
call setpalet
Main:
ld bc,(palet.col5)
dec c ; green value decreased with 1
ld a,b
and 112 ;and 0111 0000, remove lower 4 bits
rra
rra
rra
rra
dec a
rla
rla
rla
rla
ld d,a ; red data decreased with 1 and stored in D
ld a,b
and 7 ; and 0000 0111 Keep first 3 bits
dec a
add a,d ; blue value decreased with 1 and stored in A
ld b,a
ld (palet.col5),bc ; send data back
ld a,c
or a
jp nz,.go
ld bc,#7707
ld (palet.col5),bc
.go:
call setpalet
SPC_Check:
halt
halt
halt
halt
halt
xor a
CALL #D8 ; Spacebar pressed?
jp z,Main
call #C0 ;beep
End_Rout:
ret ; Back to basic
setpalet:
di
xor a
out (#99),a
ld a,16+128 ; register 16 + set bit 7
out (#99),a
ei
ld bc,#209a ; 32 bytes naar #9a (b=#20, c=#9a)
ld hl,palet
otir
ret
; red_blue,green
palet:
.col0: db 0,0
.col1: db 0,0
.col2: db 0,0
.col3: db 0,0
.col4: db 0,0
.col5: dw #7707
.col6: db 0,0
.col7: dw #7707
.col8: db 0000_0111b,0
.col9: db 0,0
.col10: db 0000_0101b,0
.col11: db 0,0
.col12: db 0,0
.col13: db 0,0
.col14: db 0,0
.col15: db 0,5
END