basic palette cycling

This commit is contained in:
Brooke Vibber 2024-08-18 21:06:30 -07:00
parent 8be03993ab
commit 6f05a9bbd0

View file

@ -32,6 +32,7 @@ pixel_mask = $b9 ; u8
pixel_shift = $ba ; u8 pixel_shift = $ba ; u8
pixel_offset = $bb ; u8 pixel_offset = $bb ; u8
fill_level = $bc ; u8 fill_level = $bc ; u8
palette_offset = $bd ; u8
; FP registers in zero page ; FP registers in zero page
FR0 = $d4 ; float48 FR0 = $d4 ; float48
@ -87,6 +88,12 @@ SYSVBV = $E45F
XITVBV = $E462 XITVBV = $E462
SETVBV = $E45C SETVBV = $E45C
COLOR0 = $2C4
COLOR1 = $2C5
COLOR2 = $2C6
COLOR3 = $2C7
COLOR4 = $2C8
; Keycodes! ; Keycodes!
KEY_PLUS = $06 KEY_PLUS = $06
KEY_MINUS = $0e KEY_MINUS = $0e
@ -205,6 +212,11 @@ color_map:
.byte 3 .byte 3
.endrepeat .endrepeat
palette:
.byte $00
.byte $36
.byte $88
.byte $d4
.code .code
z_buffer_len = 16 z_buffer_len = 16
@ -809,9 +821,33 @@ done:
.proc vblank_handler .proc vblank_handler
inc count_frames inc count_frames
inc palette_offset
jmp XITVBV jmp XITVBV
.endproc .endproc
.proc update_palette
lda palette
sta COLOR4
clc
lda palette_offset
and #$f0
adc palette + 1
sta COLOR0
clc
lda palette_offset
and #$f0
adc palette + 2
sta COLOR1
clc
lda palette_offset
and #$f0
adc palette + 3
sta COLOR2
.endproc
.proc update_speed .proc update_speed
; convert frames (u16) to fp ; convert frames (u16) to fp
; add to frames_total ; add to frames_total
@ -971,6 +1007,11 @@ copy_byte_loop:
lda #$22 lda #$22
sta DMACTL sta DMACTL
; Initialize the palette
lda #0
sta palette_offset
jsr update_palette
; install the vblank handler ; install the vblank handler
lda #7 ; deferred lda #7 ; deferred
ldx #.hibyte(vblank_handler) ldx #.hibyte(vblank_handler)
@ -1122,6 +1163,8 @@ update_status:
draw_text_indirect speed_start, speed_precision, INBUFF draw_text_indirect speed_start, speed_precision, INBUFF
draw_text speed_start + speed_precision, str_speed_len, str_speed draw_text speed_start + speed_precision, str_speed_len, str_speed
jsr update_palette
skipped: skipped:
clc clc