Commit graph

191 commits

Author SHA1 Message Date
2ed28e5590 drop some old commented out code 2026-08-23 16:08:18 -07:00
e58df379e7 step 2: break out the multiplication hotspot
mandelbrot_hotspot_impl macro calls through to the
sqr16_impl and imul16_impl macros with the xe mode

this is backed by two realized functions, as
mandelbrot_hotspot and mandelbrot_hotspot_xe

these are also called via direct jmp instead of jsr/rts
because there's only one call site so we can save 6 cycles
per iteration by jmp/jmp

could save 6 more cycles per iter by specializing all of
the mandelbrot proc but there isn't room in ram right now

sqr16_func is removed as it is unused and we ran out of
code space adding the hotspot's extra implementations

imul16_func is kept, as it's called via zoom_factor
in a couple of places. this forwards to the xe version
at a cost of 3 cycles, as the call sites aren't patched
2026-08-23 15:48:48 -07:00
d93dd2e6a6 step 1: sqr16_impl and imul16_impl take argument addresses
first step to removing function call overhead
2026-08-23 15:18:25 -07:00
f3a92708d2 unclobber arg in sqr16
this'll make it easier to use direct targets bypassing function args

costs 2 cycles on negatives in this version for now
but it should save us later
2026-08-22 18:48:05 -07:00
e029213c51 comment fix 2026-08-22 17:53:32 -07:00
65563b0e79 Decent speedup in XE mode
Noticed that the separate addition for the low 1 bit case was
doing some dupe memory loads. Ended up making separate code
paths for even and odd values so the even saves two cycles
(from 52 down to 50 cycles) and the odd saves 14 cycles (from
69 down to 55 cycles). nice!

This gets the XE runtime on default view down from 3m38s to 3m33s,
a 5 second runtime improvement
2026-08-22 16:45:09 -07:00
23fa002f33 comments 2026-08-22 16:30:41 -07:00
f6489670b1 comments 2026-08-22 15:58:17 -07:00
55d34cb388 Merge branch 'experiment' 2026-08-22 15:35:53 -07:00
4b352e8f63 Merge branch 'regression' 2026-08-22 15:35:29 -07:00
e284587edc Fix regression from merging ptr and pixel_ptr
the XE fast-path assumed low byte of ptr never changes
to save a couple cycles
2026-08-22 15:35:03 -07:00
27995007c5 experiment 2026-08-22 15:25:58 -07:00
829f46755a Save another few cycles per multiple
add_carry took a fixed 8 cycles with a lda/adc/sta pattern

we can instead use bcc to handle the carry-not-set case in just
2 cycles, skipping over the inc which takes 5 cycles on the
carry-is-set case.

Result is 2-7 cycles instead of 8, saving 1-6 cycles twice
per 16-bit multiplication or square.

Neat!
2026-08-22 14:43:17 -07:00
b4cb773cf1 tweak comment 2026-08-22 14:34:53 -07:00
d9f7ce3e35 whoops missed a bit 2026-08-22 14:27:52 -07:00
173901e49a Add a copy of the old bit-shift multiplier code 2026-08-22 13:01:56 -07:00
3ce4c1e580 Add some timing notes 2026-08-22 13:01:23 -07:00
25c37a1188 zeropage tweaks
* switched zero-page from hardcoded assignments to symbols
* moved most non-hotpath stuff out to .data
* merged ptr and pixel_ptr

Slight slowdown in Atari800MacX from 5m13s to 5m15s
2026-04-08 20:16:31 -07:00
a93dd00e36 Rearrange the segments a bit
* put TABLES in the low memory, before the bank switch window
* reserve bank switch window
* put rest of the code after that and before the framebuffer

so TABLES lives just before $4000
and MAIN lives in $8000-$bfff

could split some more code and/or data into low mem

and/or move the tables not used in extended memory mode into
the bank switch window so they take no address space on XE
or expanded memory machines
2025-12-28 12:55:08 -08:00
97fdc12565 Put the tables before the main code, and shrink the segment
Leaves more room for code and dynamic data/stack
2025-12-28 12:32:57 -08:00
b27be3c159 Add a C shell, which currently just passes through
This is a first step toward moving the UI to C and
adding file and network I/O in C. The fractal core
will remain in assembler as well as the multiplier.
2025-12-28 09:23:38 -08:00
6479cf530c update some timings 2025-09-16 21:56:50 -07:00
29cd3d968f Shaves 3 seconds off initial view runtime on XE :D
Instead of relying solely on the JMP thunks added to
imul16_func and sqr16_func, three call sites within the
mandelbrot iteration function are patched directly to
jsr to the XE versions, saving like 15 cycles per iter

Ok so it's not a lot, but every seconds counts. ;)

with XE code disabled:
1539 us/iter
5m13s

with old XE code:
1417 us/iter
4m48s

with new XE code:
1406 us/iter
4m45s
2025-09-06 19:53:25 -07:00
b46e6fb343 fix typo on stub x/y inputs
was accidentally falling through to the load
a viewport from a keypress thingy which was
not needed here
2025-09-01 12:28:33 -07:00
f2a6af0995 Replace the not-enough-precision 32 bit to float impl
keep the proc though to encapsulate it but uses the older
logic of rounding down to 3.13 first
2025-07-03 18:43:10 -07:00
96e0356e57 WIP input handling for coords
experimental output via 32-bits mult, looses precision in conversion
2025-07-03 18:41:24 -07:00
fab2760394 refactor countdown as a procedure call 2025-06-28 13:43:43 -07:00
fd954da47e Create map file for convenience
export a symbol and it'll appear in mandel.map
2025-06-23 08:17:39 -07:00
4bac47a4fd fix at 256 seconds 2025-06-23 00:31:53 -07:00
5cf64970c8 Ah that's better
used the appropriate instruction for comparison
2025-06-22 23:10:43 -07:00
Brooke
f7082ab371 wip subtraction method, still not working 2025-06-22 22:21:26 -07:00
Brooke
689363d083 WIP code for elapsed time
not finished, doesn't work right
2025-06-22 20:00:35 -07:00
89b4e45901 flip the y coordinate sign 2025-02-22 20:24:04 -08:00
6e66145ec6 whoops fixes 2025-02-22 15:37:11 -08:00
07db3d00d7 second status bar display with coords/zoom
currently using 3.13 precision to output to floats for formatting
2025-02-22 11:23:13 -08:00
26d612b6f3 move 8 scan lines on the bottom to status bar 2025-02-21 19:42:10 -08:00
25da81c64b clean up text draw, fix offset by one 2025-02-02 16:40:58 -08:00
d182d33b35 draw_string 2025-02-01 10:02:01 -08:00
e0cc704d99 Fix drawing terminator, round usec 2025-01-08 18:34:46 -08:00
7c04862d70 workaround for rounding us/iter
for some reason rounding is giving me wrong results
not sure what i'm doing wrong :D

just show 6 digits :P

ok this gets the us/iter working, and it is more stable
but the elapsed time still needs to be added
2025-01-05 14:29:27 -08:00
918d15e813 wip us/iter counter
seems wrong, gives 32 all the time and that seems too small
2025-01-05 14:05:24 -08:00
eaa00a055a wip changing time units
it does this weird thing where sometimes it's reading out wrong digits
and then switches to expected unit of sec/px

work in progress no clue what's going on
2025-01-04 18:46:51 -08:00
7e5ca79d9a move total_ms, total_pixels out of zero page
this frees up 12 bytes of zero page space and costs no measurable
time as these variables are not in the hot path and there was only
a tiny bit different.
2025-01-04 14:25:25 -08:00
d2bf77dc26 todo notes 2025-01-04 12:13:27 -08:00
582ddf497f apply jamey's suggestion of skipping add for high byte muls
rather than saving 0 into the high bytes, then adding the high-byte
multiplication later, write it directly in place. this saves a few
cycles on every iteration, and it adds up nicely.

View 1 overview render times:
130XE: 10.050 ms/px - 4m56s
800XL: 10.906 ms/px - 5m21s
2025-01-04 10:53:51 -08:00
d157fe1306 Faster pixel skipping on 4x4, 2x2 tiers
Iterate at fill_masks[fill_level]+1 instead of every pixel and then
skipping, saves a smidge of time

view 1 with expanded memory:
10.514 ms/px before
10.430 ms/px after
2025-01-04 10:06:12 -08:00
dcf5a3f59e sixth viewport 2025-01-01 21:15:38 -08:00
837082cf56 tweak viewports
skip experimental 6th viewport that got forgotten
and limit max zoom to 7 (range 0-7) which is what looks good
2025-01-01 15:45:26 -08:00
65fcb44934 3.13 / 6.26 gives nicer results! 2025-01-01 15:37:12 -08:00
c424f1b8bc fill in scanlines during tiering 2024-12-31 22:10:27 -08:00