awesome new palette cycler

This commit is contained in:
Brooke Vibber 2024-12-30 10:21:52 -08:00
parent 100c0f3314
commit 64a6cf50f3
2 changed files with 84 additions and 26 deletions

108
mandel.s
View file

@ -13,13 +13,13 @@ zy_2 = $92 ; fixed4.12: z_y^2
zx_zy = $94 ; fixed4.12: z_x * z_y
dist = $96 ; fixed4.12: z_x^2 + z_y^2
iter = $a0 ; u8: iteration count
iter = $a0 ; u8: iteration count
zoom = $a1 ; u8: zoom shift level
count_frames = $a2 ; u8
count_pixels = $a3 ; u8
total_ms = $a4 ; float48
total_pixels = $aa ; float48
zoom = $a1 ; u8: zoom shift level
count_frames = $a2 ; u8
count_pixels = $a3 ; u8
total_ms = $a4 ; float48
total_pixels = $aa ; float48
z_buffer_active = $b0 ; boolean: 1 if we triggered the lake, 0 if not
z_buffer_start = $b1 ; u8: index into z_buffer
@ -34,6 +34,14 @@ pixel_offset = $bd ; u8
fill_level = $be ; u8
palette_offset = $bf ; u8
palette_ticks = $c0 ; u8
chroma_ticks = $c1 ; u8
chroma_offset = $c2 ; u8
palette_delay = 120
chroma_delay = 120
; FP registers in zero page
FR0 = $d4 ; float48
FRE = $da
@ -224,11 +232,26 @@ color_map:
.byte 3
.endrepeat
palette:
.byte $00
.byte $46
.byte $78
.byte $b4
palette_start:
.byte $04
.byte $08
.byte $0e
palette_repeat:
.byte $03
.byte $09
palette_entries = 3
palette_chroma:
.repeat 15, i
.byte (i + 1) << 4
.endrepeat
.repeat 2, i
.byte (i + 1) << 4
.endrepeat
palette_chroma_entries = 15
.code
z_buffer_len = 16
@ -1136,31 +1159,65 @@ done:
.proc vblank_handler
inc count_frames
inc chroma_ticks
lda chroma_ticks
cmp #(chroma_delay)
bne skip_chroma
lda #0
sta chroma_ticks
inc chroma_offset
lda chroma_offset
cmp #(palette_chroma_entries)
bne skip_chroma
lda #0
sta chroma_offset
skip_chroma:
inc palette_ticks
lda palette_ticks
cmp #(palette_delay)
bne skip_luma
lda #0
sta palette_ticks
inc palette_offset
lda palette_offset
cmp #(palette_entries)
bne skip_luma
lda #0
sta palette_offset
skip_luma:
jsr update_palette
jmp XITVBV
.endproc
.proc update_palette
lda palette
lda #0
sta COLOR4
clc
lda palette_offset
and #$f0
adc palette + 1
ldx chroma_offset
ldy palette_offset
lda palette_chroma,x
ora palette_start,y
sta COLOR0
clc
lda palette_offset
and #$f0
adc palette + 2
inx
iny
lda palette_chroma,x
ora palette_start,y
sta COLOR1
clc
lda palette_offset
and #$f0
adc palette + 3
inx
iny
lda palette_chroma,x
ora palette_start,y
sta COLOR2
rts
@ -1358,6 +1415,9 @@ copy_byte_loop:
; Initialize the palette
lda #0
sta palette_offset
sta palette_delay
sta chroma_offset
sta chroma_delay
jsr update_palette
; install the vblank handler

View file

@ -11,8 +11,6 @@ things to try:
* 'wide pixels' 2x and 4x for a fuller initial image in the tiered rendering
* rework the palette cycling to look more like an advancing flow
* extact viewport for display & re-input via keyboard
* fujinet screenshot/viewport uploader