From 0d086a179cf8e91b839f306bb597ef9e6125f6b2 Mon Sep 17 00:00:00 2001
From: Brooke Vibber <bvibber@pobox.com>
Date: Tue, 31 Dec 2024 07:20:53 -0800
Subject: [PATCH] wip

---
 mandel.s | 108 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 68 insertions(+), 40 deletions(-)

diff --git a/mandel.s b/mandel.s
index fc30532..50213ad 100644
--- a/mandel.s
+++ b/mandel.s
@@ -1,43 +1,42 @@
 ; Our zero-page vars
-sx    = $80     ; i16: screen pixel x
-sy    = $82     ; i16: screen pixel y
-ox    = $84     ; fixed4.12: center point x
-oy    = $86     ; fixed4.12: center point y
-cx    = $88     ; fixed4.12: c_x
-cy    = $8a     ; fixed4.12: c_y
-zx    = $8c     ; fixed4.12: z_x
-zy    = $8e     ; fixed4.12: z_y
+ox              = $80 ; fixed8.24: center point x
+oy              = $84 ; fixed8.24: center point y
+cx              = $88 ; fixed8.24: c_x
+cy              = $8c ; fixed8.24: c_y
 
-zx_2  = $90     ; fixed4.12: z_x^2
-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
+zx              = $90 ; fixed8.24: z_x
+zy              = $94 ; fixed8.24: z_y
+zx_2            = $98 ; fixed8.24: z_x^2
+zy_2            = $9c ; fixed8.24: z_y^2
 
-iter          = $a0 ; u8: iteration count
+zx_zy           = $a0 ; fixed8.24: z_x * z_y
+dist            = $a4 ; fixed8.24: z_x^2 + z_y^2
+sx              = $a8 ; i16: screen pixel x
+sy              = $aa ; i16: screen pixel y
+z_buffer_active = $ac ; boolean: 1 if we triggered the lake, 0 if not
+z_buffer_start  = $ad ; u8: index into z_buffer
+z_buffer_end    = $ae ; u8: index into z_buffer
+iter            = $af ; 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
+ptr             = $b0 ; u16
+pixel_ptr       = $b2 ; u16
+zoom            = $b4 ; u8: zoom shift level
+fill_level      = $b5 ; u8
+pixel_color     = $b6 ; u8
+pixel_mask      = $b7 ; u8
+pixel_shift     = $b8 ; u8
+pixel_offset    = $b9 ; u8
+palette_offset  = $ba ; u8
+chroma_offset   = $bb ; u8
+palette_ticks   = $bc ; u8
+chroma_ticks    = $bd ; u8
+count_frames    = $be ; u8
+count_pixels    = $bf ; u8
 
-z_buffer_active = $b0 ; boolean: 1 if we triggered the lake, 0 if not
-z_buffer_start  = $b1 ; u8: index into z_buffer
-z_buffer_end    = $b2 ; u8: index into z_buffer
-temp            = $b4 ; u16
-temp2           = $b6 ; u16
-pixel_ptr       = $b8 ; u16
-pixel_color     = $ba ; u8
-pixel_mask      = $bb ; u8
-pixel_shift     = $bc ; u8
-pixel_offset    = $bd ; u8
-fill_level      = $be ; u8
-palette_offset  = $bf ; u8
-
-palette_ticks = $c0 ; u8
-chroma_ticks  = $c1 ; u8
-chroma_offset = $c2 ; u8
-ptr           = $c4 ; u16
+total_pixels    = $c0 ; float48
+total_ms        = $c6 ; float48
+temp            = $cc ; u16
+temp2           = $ce ; u16
 
 palette_delay = 23
 chroma_delay = 137
@@ -884,12 +883,41 @@ next:
     ; zx_zy = 0
     ; dist = 0
     ; iter = 0
+;    lda #00
+;    ldx #(iter - zx + 1)
+;initloop:
+;    sta zx - 1,x
+;    dex
+;    bne initloop
+;    sta z_buffer_start
+;    sta z_buffer_end
+
     lda #00
-    ldx #(iter - zx + 1)
-initloop:
-    sta zx - 1,x
-    dex
-    bne initloop
+    sta zx
+    sta zx + 1
+    sta zx + 2
+    sta zx + 3
+    sta zy
+    sta zy + 1
+    sta zy + 2
+    sta zy + 3
+    sta zx_2
+    sta zx_2 + 1
+    sta zx_2 + 2
+    sta zx_2 + 3
+    sta zy_2
+    sta zy_2 + 1
+    sta zy_2 + 2
+    sta zy_2 + 3
+    sta zx_zy
+    sta zx_zy + 1
+    sta zx_zy + 2
+    sta zx_zy + 3
+    sta dist
+    sta dist + 1
+    sta dist + 2
+    sta dist + 3
+    sta iter
     sta z_buffer_start
     sta z_buffer_end