Shallan50K Spiral Competition.
Shallan50K recently created a competition to reproduce the image below in the least number of bytes.
A few people have asked about the zero page auto run aspect of the program so I thought I'd drop in a paragraph to explain it.
In zero page there is a small routine called CHRGET which is used by the basic interpreter, this routine is located at $73. When basic starts up it uses this routine to read either from the command line or from the basic program. Any program put here will run instead when the machine boots.
The easiest thing to do would be to place the program here and just have it run, unfortunately basic also uses $8b to initialise its random routines which means that if the program is longer that 23 bytes corruption will occur!
To solve this problem the program is loaded into lower memory with the last line of code lined up with $73 so that when basic runs the last line of the program runs instead! The last line of code needs to be a branch command to jump to the beginning of the program. The start location of the code has to move as the code changes to ensure that the branch is always located at $73.
Hope that make sense.
My solution to the problem is below:
/*
Turtles all the way down
(c) AMK Enterprises 2021
All rights reserved
*/
// for PC
.const directionTableHigh = $0114 // would you believe it this memory block is $00,$00,$ff,$ff
// just what i need for the table! Winner Winner turtle dinner
// for mac
//.const directionTableHigh = $017e // would you believe it this memory block is $00,$00,$ff,$ff
// just what i need for the table! Winner Winner turtle dinner
.const theCount = $16 // HA HA HAR
* = $42
Entry:
jsr $e544 // kernal cls
!outerLoop:
inx
xaa #$03
tax
clc
.byte $b5, <stepz__ // lda stepz__,x
adc theCount // HA HA HAR
tay
!loop:
/*
move the cursor to the next point
*/
clc
.byte $a5, <cursor // lda cursor
.byte $75, <directionTableLow // adc directionTableLow,x
.byte $85, <cursor // sta cursor
.byte $a5, (<cursor)+1 // lda cursor+1
adc directionTableHigh,x
.byte $85, (<cursor)+1 // sta cursor+1
/*
draw an inverse @
*/
lda #$80 // inverse @ code
sta cursor:$3fe // dirty dirty dirty self mod code
/*
decrease counter
and
loop
*/
dey
bne !loop-
/*
reduce the length of the line
*/
.byte $c6,<theCount // dec theCount - HA HA HAR
/*
if line length isnt zero do it all again
*/
bne !outerLoop-
/*
stay a while
.....
stay for ever
*/
beq *
stepz__:
.byte 16,0,16,0
directionTableLow:
.byte -1,-40,1,40
* = * "jump"
bne Entry