Skip to content

Commit

Permalink
Add an optional iteration count feature and update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsk2 committed Dec 31, 2022
1 parent e9b2b41 commit 3ca7d7f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ is intended for [Commander X16](https://www.commanderx16.com) (see also here on
- New instructions for the 65C02 (well only `stz` and `bra`)

**This is work in progress**. Currently the default section of the Mandelbrot set (see screenshot below)
using the X16s full resolution of 320x240 at a depth of 24 iterations is calculated in roughly 14 minutes.
The C64 version takes two and a half hours to calculate the same visualisation in a resolution of 320x200.
Of course the biggest part of the speedup stems from the fact that the 65C02 in the X16 runs at 8MHz where
the 6510 in a C64 is clocked at 1MHz. But even if that is taken into account the X16 version is currently
about 25% faster.
using the X16s full resolution of 320x240 at a depth of 24 iterations (in total 717022 iterations) is
calculated in under 13 minutes at about 950 iterations/sec. The C64 version takes two and a half hours to
calculate the same visualisation in a resolution of 320x200. Of course the biggest part of the speedup stems
from the fact that the 65C02 in the X16 runs at 8MHz where the 6510 in a C64 is clocked at 1MHz. But even
if that is taken into account the X16 version is currently faster.

![](/result.png?raw=true "Example picture in hires mode")

Expand Down
26 changes: 26 additions & 0 deletions main.a
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!cpu 65c02

;TESTS = 1
;ITER_COUNT = 1

*=$0801
!byte $0c,$08,$e6,$07,$9e,$20,$32,$30,$36,$32,$00,$00,$00
Expand Down Expand Up @@ -69,6 +70,18 @@ MAX_ITER
!byte ITER_DEFAULT
; **************************************************

!ifdef ITER_COUNT {
ITER_CTR
!byte 0, 0, 0, 0, 0

CONST_UINT_ONE
!byte 0, 1, 0, 0, 0

TXT_ITERATIONS
!byte 18
!tx "ITERATIONS : $"
}

; Number of points (resolution) in x direction
MAX_X
!byte <RES_X, >RES_X
Expand Down Expand Up @@ -217,6 +230,10 @@ calcOneMandelbrotSequence
+callFunc move32Bit, IMAG, YN

.loopMandelbrot

!ifdef ITER_COUNT {
+callFunc add32BitUnsigned, CONST_UINT_ONE, ITER_CTR
}
jsr testMandelbrotDone
beq .continueMandelbrot
jmp .endMandelbrot
Expand Down Expand Up @@ -264,6 +281,9 @@ initMandel
+load16BitImmediate 0, COUNT_X
lda #0
sta COUNT_Y
!ifdef ITER_COUNT {
+callFuncMono clear32Bit, ITER_CTR
}
; reset complex numbers
+callFunc move32Bit, INIT_REAL, REAL
+callFunc move32Bit, INIT_IMAG, IMAG
Expand Down Expand Up @@ -424,6 +444,12 @@ VEC_SPECIAL_PRINT
+printFixedPoint STEP_X
+printStr .TXT_STEPPING_Y
+printFixedPoint STEP_Y

!ifdef ITER_COUNT {
+printStr TXT_ITERATIONS
+printFixedPoint ITER_CTR
}

jsr .specialWrapper

rts
Expand Down
Binary file modified result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3ca7d7f

Please sign in to comment.