Progressive pixel layout

This commit is contained in:
Brooke Vibber 2024-02-04 14:25:15 -08:00
parent 510457f97a
commit c152c4346b
2 changed files with 62 additions and 5 deletions

View file

@ -31,7 +31,7 @@ pixel_color = $b8 ; u8
pixel_mask = $b9 ; u8
pixel_shift = $ba ; u8
pixel_offset = $bb ; u8
fill_level = $bc ; u8
; FP registers in zero page
FR0 = $d4 ; float48
@ -218,6 +218,15 @@ z_buffer:
.export start
max_fill_level = 6
fill_masks:
.byte %00011111
.byte %00001111
.byte %00000111
.byte %00000011
.byte %00000001
.byte %00000000
; 2 + 9 * byte cycles
.macro add bytes, dest, arg1, arg2
clc ; 2 cyc
@ -959,6 +968,11 @@ copy_byte_loop:
jsr SETVBV
main_loop:
lda #0
sta fill_level
fill_loop:
; sy = -92 .. 91
lda #(256-half_height)
sta sy
@ -973,6 +987,40 @@ loop_sy:
sta sx + 1
loop_sx:
; check the fill mask
ldy #0
loop_skip_level:
cpy fill_level
beq current_level
lda fill_masks,y
and sx
bne not_skipped_mask1
lda fill_masks,y
and sy
beq skipped_mask
not_skipped_mask1:
iny
jmp loop_skip_level
current_level:
lda fill_masks,y
and sx
bne skipped_mask
lda fill_masks,y
and sy
beq not_skipped_mask
skipped_mask:
jmp skipped
not_skipped_mask:
; run the fractal!
zoom_factor cx, sx, zoom, aspect_x
add16 cx, cx, ox
zoom_factor cy, sy, zoom, aspect_y
@ -983,7 +1031,7 @@ loop_sx:
jsr keycheck
beq no_key
; @fixme clear the pixel stats
jmp main_loop
jmp fill_loop
no_key:
; check if we should update the counters
@ -997,7 +1045,7 @@ no_key:
; count_frames >= 120? update!
lda count_frames
cmp #120 ; >= 2 seconds
bmi skip_status
bmi skipped
update_status:
; FR0 = (float)count_pixels & clear count_pixels
@ -1061,7 +1109,7 @@ update_status:
draw_text_indirect speed_start, speed_precision, INBUFF
draw_text speed_start + speed_precision, str_speed_len, str_speed
skip_status:
skipped:
clc
lda sx
@ -1095,6 +1143,13 @@ loop_sy_done:
draw_text 40 - str_done_len, str_done_len, str_done
fill_loop_done:
inc fill_level
lda fill_level
cmp #max_fill_level
beq loop
jmp fill_loop
loop:
; finished
jsr keycheck

View file

@ -14,7 +14,7 @@ Non-goals:
Enjoy! I'll probably work on this off and on for the next few weeks until I've got it producing fractals.
-- brion, january 2023
-- brooke, january 2023 - february 2024
## Current state
@ -28,6 +28,8 @@ The mandelbrot calculations are done using 4.12-precision fixed point numbers. I
Iterations are capped at 255.
The pixels are run in a progressive layout to get the basic shape on screen faster.
## Next steps
Add a running counter of ms/px using the vertical blank interrupts as a timer. This'll show how further work improves it!