From 64a6cf50f3a5d7aa46632b6ab8f83120e2c49448 Mon Sep 17 00:00:00 2001 From: Brooke Vibber Date: Mon, 30 Dec 2024 10:21:52 -0800 Subject: [PATCH] awesome new palette cycler --- mandel.s | 108 ++++++++++++++++++++++++++++++++++++++++++------------- todo.md | 2 -- 2 files changed, 84 insertions(+), 26 deletions(-) diff --git a/mandel.s b/mandel.s index 90396d4..198e40c 100644 --- a/mandel.s +++ b/mandel.s @@ -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 diff --git a/todo.md b/todo.md index 6c6d84d..a8675af 100644 --- a/todo.md +++ b/todo.md @@ -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