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
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
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!
* 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
* 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
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.
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
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
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
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.
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
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