1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-27 04:49:27 +00:00

Added program that shows a spiral on the screen.

This commit is contained in:
jespergravgaard 2019-07-06 10:32:25 +02:00
parent 966773ed2b
commit c5f1ec7d8a
11 changed files with 10056 additions and 21 deletions

View File

@ -0,0 +1,5 @@
ldy #0
lda ({z3}),y
sta {z1}
lda ({z2}),y
sta {z1}+1

View File

@ -35,6 +35,11 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testSCreenShowSpiral() throws IOException, URISyntaxException {
compileAndCompare("screen-show-spiral");
}
@Test
public void testNesArray() throws IOException, URISyntaxException {
compileAndCompare("nes-array");

View File

@ -1,7 +1,7 @@
// Test initializing array using KickAssembler
// Sinus table
byte[] SINTAB = kickasm {{
byte[256] SINTAB = kickasm {{
.fill 256, 128 + 128*sin(i*2*PI/256)
}};

View File

@ -0,0 +1,96 @@
// Fill screen using a spiral based on distance-to-center / angle-to-center
import "stdlib"
import "sqr"
import "atan2"
// Screen containing distance to center
const byte* SCREEN_DIST = malloc(1000);
// Screen containing angle to center
const byte* SCREEN_ANGLE = malloc(1000);
// Screen containing angle to center
const byte* SCREEN_FILL = 0x0400;
// Char to fill with
const byte FILL_CHAR = '@';
void main() {
init_dist_screen(SCREEN_DIST);
init_angle_screen(SCREEN_ANGLE);
while(true) {
// Find the minimum dist/angle that is not already filled
byte* dist = SCREEN_DIST;
byte* angle = SCREEN_ANGLE;
byte* fill = SCREEN_FILL;
word min_dist_angle = 0xffff;
byte* min_fill = SCREEN_FILL;
do {
if(*fill!=FILL_CHAR) {
word dist_angle = { *dist, *angle };
if(dist_angle<min_dist_angle) {
min_fill = fill;
min_dist_angle = dist_angle;
}
}
dist++;
angle++;
fill++;
} while (fill<SCREEN_FILL+1000);
// Break if not found (means we are done)
if(min_dist_angle==0xffff)
break;
// Fill the found location
*min_fill = FILL_CHAR;
}
}
// Populates 1000 bytes (a screen) with values representing the angle to the center.
// Utilizes symmetry around the center
void init_angle_screen(byte* screen) {
byte* screen_topline = screen+40*12;
byte *screen_bottomline = screen+40*12;
for(byte y: 0..12) {
for( byte x=0,xb=39; x<=19; x++, xb--) {
signed word xw = (signed word)(word){ 39-x*2, 0 };
signed word yw = (signed word)(word){ y*2, 0 };
word angle_w = atan2_16(xw, yw);
byte ang_w = >(angle_w+0x0080);
screen_bottomline[xb] = ang_w;
screen_topline[xb] = -ang_w;
screen_topline[x] = 0x80+ang_w;
screen_bottomline[x] = 0x80-ang_w;
}
screen_topline -= 40;
screen_bottomline += 40;
}
}
// Populates 1000 bytes (a screen) with values representing the distance to the center.
// The actual value stored is distance*2 to increase precision
void init_dist_screen(byte* screen) {
NUM_SQUARES = 0x30;
init_squares();
byte* screen_topline = screen;
byte *screen_bottomline = screen+40*24;
for(byte y: 0..12) {
byte y2 = y*2;
byte yd = (y2>=24)?(y2-24):(24-y2);
word yds = sqr(yd);
for( byte x=0,xb=39; x<=19; x++, xb--) {
byte x2 = x*2;
byte xd = (x2>=39)?(x2-39):(39-x2);
word xds = sqr(xd);
word ds = xds+yds;
byte d = sqrt(ds);
screen_topline[x] = d;
screen_bottomline[x] = d;
screen_topline[xb] = d;
screen_bottomline[xb] = d;
}
screen_topline += 40;
screen_bottomline -= 40;
}
}

View File

@ -8,7 +8,7 @@
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← *((const byte[]) SINTAB#0)
[4] *((const byte*) SCREEN#0) ← *((const byte[$100]) SINTAB#0)
to:main::@return
main::@return: scope:[main] from main
[5] return

View File

@ -2,12 +2,12 @@ Identified constant variable (byte*) SCREEN
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte[]) SINTAB#0 ← kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
(byte[$100]) SINTAB#0 ← kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
(byte*) SCREEN#0 ← ((byte*)) (number) $400
to:@1
main: scope:[main] from @1
*((byte*) SCREEN#0 + (number) 0) ← *((byte[]) SINTAB#0 + (number) 0)
*((byte*) SCREEN#0 + (number) 0) ← *((byte[$100]) SINTAB#0 + (number) 0)
to:main::@return
main::@return: scope:[main] from main
return
@ -26,13 +26,13 @@ SYMBOL TABLE SSA
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte[]) SINTAB
(byte[]) SINTAB#0
(byte[$100]) SINTAB
(byte[$100]) SINTAB#0
(void()) main()
(label) main::@return
Adding number conversion cast (unumber) 0 in *((byte*) SCREEN#0 + (number) 0) ← *((byte[]) SINTAB#0 + (number) 0)
Adding number conversion cast (unumber) 0 in *((byte*) SCREEN#0 + (number) 0) ← *((byte[]) SINTAB#0 + (unumber)(number) 0)
Adding number conversion cast (unumber) 0 in *((byte*) SCREEN#0 + (number) 0) ← *((byte[$100]) SINTAB#0 + (number) 0)
Adding number conversion cast (unumber) 0 in *((byte*) SCREEN#0 + (number) 0) ← *((byte[$100]) SINTAB#0 + (unumber)(number) 0)
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
@ -43,12 +43,12 @@ Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant (const byte[]) SINTAB#0 = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
Constant (const byte[$100]) SINTAB#0 = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
Constant (const byte*) SCREEN#0 = (byte*) 1024
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SINTAB#0 in [2] *((const byte*) SCREEN#0 + (byte) 0) ← *((const byte[]) SINTAB#0 + (byte) 0)
Simplifying expression containing zero SCREEN#0 in [2] *((const byte*) SCREEN#0 + (byte) 0) ← *((const byte[]) SINTAB#0)
Simplifying expression containing zero SINTAB#0 in [2] *((const byte*) SCREEN#0 + (byte) 0) ← *((const byte[$100]) SINTAB#0 + (byte) 0)
Simplifying expression containing zero SCREEN#0 in [2] *((const byte*) SCREEN#0 + (byte) 0) ← *((const byte[$100]) SINTAB#0)
Successful SSA optimization PassNSimplifyExpressionWithZero
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
@ -75,7 +75,7 @@ FINAL CONTROL FLOW GRAPH
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← *((const byte[]) SINTAB#0)
[4] *((const byte*) SCREEN#0) ← *((const byte[$100]) SINTAB#0)
to:main::@return
main::@return: scope:[main] from main
[5] return
@ -84,7 +84,7 @@ main::@return: scope:[main] from main
VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte[]) SINTAB
(byte[$100]) SINTAB
(void()) main()
Initial phi equivalence classes
@ -115,7 +115,7 @@ bend_from_b1:
bend:
//SEG9 main
main: {
//SEG10 [4] *((const byte*) SCREEN#0) ← *((const byte[]) SINTAB#0) -- _deref_pbuc1=_deref_pbuc2
//SEG10 [4] *((const byte*) SCREEN#0) ← *((const byte[$100]) SINTAB#0) -- _deref_pbuc1=_deref_pbuc2
lda SINTAB
sta SCREEN
jmp breturn
@ -131,7 +131,7 @@ SINTAB:
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) SCREEN#0) ← *((const byte[]) SINTAB#0) [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [4] *((const byte*) SCREEN#0) ← *((const byte[$100]) SINTAB#0) [ ] ( main:2 [ ] ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [main]
@ -165,7 +165,7 @@ bend_from_b1:
bend:
//SEG9 main
main: {
//SEG10 [4] *((const byte*) SCREEN#0) ← *((const byte[]) SINTAB#0) -- _deref_pbuc1=_deref_pbuc2
//SEG10 [4] *((const byte*) SCREEN#0) ← *((const byte[$100]) SINTAB#0) -- _deref_pbuc1=_deref_pbuc2
lda SINTAB
sta SCREEN
jmp breturn
@ -204,8 +204,8 @@ FINAL SYMBOL TABLE
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte[]) SINTAB
(const byte[]) SINTAB#0 SINTAB = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
(byte[$100]) SINTAB
(const byte[$100]) SINTAB#0 SINTAB = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
(void()) main()
(label) main::@return
@ -231,7 +231,7 @@ Score: 14
//SEG8 @end
//SEG9 main
main: {
//SEG10 [4] *((const byte*) SCREEN#0) ← *((const byte[]) SINTAB#0) -- _deref_pbuc1=_deref_pbuc2
//SEG10 [4] *((const byte*) SCREEN#0) ← *((const byte[$100]) SINTAB#0) -- _deref_pbuc1=_deref_pbuc2
lda SINTAB
sta SCREEN
//SEG11 main::@return

View File

@ -3,8 +3,8 @@
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte[]) SINTAB
(const byte[]) SINTAB#0 SINTAB = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
(byte[$100]) SINTAB
(const byte[$100]) SINTAB#0 SINTAB = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
(void()) main()
(label) main::@return

View File

@ -0,0 +1,743 @@
// Fill screen using a spiral based on distance-to-center / angle-to-center
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Screen containing angle to center
.label SCREEN_FILL = $400
// Char to fill with
.const FILL_CHAR = '@'
.const NUM_SQUARES = $30
.label heap_head = $2c
.label SQUARES = $41
// Screen containing distance to center
.label SCREEN_DIST = $30
// Screen containing angle to center
.label SCREEN_ANGLE = $32
bbegin:
lda #<$3e8
sta malloc.size
lda #>$3e8
sta malloc.size+1
lda #<HEAP_START
sta heap_head
lda #>HEAP_START
sta heap_head+1
jsr malloc
lda malloc.mem
sta SCREEN_DIST
lda malloc.mem+1
sta SCREEN_DIST+1
lda #<$3e8
sta malloc.size
lda #>$3e8
sta malloc.size+1
jsr malloc
lda malloc.mem
sta SCREEN_ANGLE
lda malloc.mem+1
sta SCREEN_ANGLE+1
jsr main
rts
main: {
.label dist = 4
.label angle = 6
.label fill = 2
.label dist_angle = $c
.label min_dist_angle = 8
.label min_dist_angle_3 = $c
.label min_fill = $a
.label min_dist_angle_7 = $c
.label min_dist_angle_8 = $c
lda SCREEN_DIST
sta init_dist_screen.screen
lda SCREEN_DIST+1
sta init_dist_screen.screen+1
jsr init_dist_screen
lda SCREEN_ANGLE
sta init_angle_screen.screen
lda SCREEN_ANGLE+1
sta init_angle_screen.screen+1
jsr init_angle_screen
b1:
// Find the minimum dist/angle that is not already filled
lda SCREEN_DIST
sta dist
lda SCREEN_DIST+1
sta dist+1
lda SCREEN_ANGLE
sta angle
lda SCREEN_ANGLE+1
sta angle+1
lda #<SCREEN_FILL
sta min_fill
lda #>SCREEN_FILL
sta min_fill+1
lda #<$ffff
sta min_dist_angle
lda #>$ffff
sta min_dist_angle+1
lda #<SCREEN_FILL
sta fill
lda #>SCREEN_FILL
sta fill+1
b2:
lda #FILL_CHAR
ldy #0
cmp (fill),y
beq b10
lda (angle),y
sta dist_angle
lda (dist),y
sta dist_angle+1
lda min_dist_angle+1
cmp dist_angle+1
bne !+
lda min_dist_angle
cmp dist_angle
beq b11
!:
bcc b11
lda fill
sta min_fill
lda fill+1
sta min_fill+1
b3:
inc dist
bne !+
inc dist+1
!:
inc angle
bne !+
inc angle+1
!:
inc fill
bne !+
inc fill+1
!:
lda fill+1
cmp #>SCREEN_FILL+$3e8
bcc b9
bne !+
lda fill
cmp #<SCREEN_FILL+$3e8
bcc b9
!:
lda min_dist_angle_3+1
cmp #>$ffff
bne b7
lda min_dist_angle_3
cmp #<$ffff
bne b7
rts
b7:
// Fill the found location
lda #FILL_CHAR
ldy #0
sta (min_fill),y
jmp b1
b9:
lda min_dist_angle_3
sta min_dist_angle
lda min_dist_angle_3+1
sta min_dist_angle+1
jmp b2
b11:
lda min_dist_angle
sta min_dist_angle_8
lda min_dist_angle+1
sta min_dist_angle_8+1
jmp b3
b10:
lda min_dist_angle
sta min_dist_angle_7
lda min_dist_angle+1
sta min_dist_angle_7+1
jmp b3
}
// Populates 1000 bytes (a screen) with values representing the angle to the center.
// Utilizes symmetry around the center
// init_angle_screen(byte* zeropage($f) screen)
init_angle_screen: {
.label _10 = $19
.label screen = $f
.label screen_topline = $11
.label screen_bottomline = $f
.label xw = $34
.label yw = $36
.label angle_w = $19
.label ang_w = $38
.label x = $13
.label xb = $14
.label y = $e
lda screen
clc
adc #<$28*$c
sta screen_topline
lda screen+1
adc #>$28*$c
sta screen_topline+1
clc
lda screen_bottomline
adc #<$28*$c
sta screen_bottomline
lda screen_bottomline+1
adc #>$28*$c
sta screen_bottomline+1
lda #0
sta y
b1:
lda #$27
sta xb
lda #0
sta x
b2:
lda x
asl
eor #$ff
clc
adc #$27+1
ldy #0
sta xw+1
sty xw
lda y
asl
sta yw+1
sty yw
jsr atan2_16
lda #$80
clc
adc _10
sta _10
bcc !+
inc _10+1
!:
lda _10+1
sta ang_w
ldy xb
sta (screen_bottomline),y
eor #$ff
clc
adc #1
sta (screen_topline),y
lda #$80
clc
adc ang_w
ldy x
sta (screen_topline),y
lda #$80
sec
sbc ang_w
sta (screen_bottomline),y
inc x
dec xb
lda x
cmp #$13+1
bcc b2
lda screen_topline
sec
sbc #<$28
sta screen_topline
lda screen_topline+1
sbc #>$28
sta screen_topline+1
lda #$28
clc
adc screen_bottomline
sta screen_bottomline
bcc !+
inc screen_bottomline+1
!:
inc y
lda #$d
cmp y
bne b1
rts
}
// Find the atan2(x, y) - which is the angle of the line from (0,0) to (x,y)
// Finding the angle requires a binary search using CORDIC_ITERATIONS_16
// Returns the angle in hex-degrees (0=0, 0x8000=PI, 0x10000=2*PI)
// atan2_16(signed word zeropage($34) x, signed word zeropage($36) y)
atan2_16: {
.label _2 = $15
.label _7 = $17
.label yi = $15
.label xi = $17
.label angle = $19
.label xd = $1d
.label yd = $1b
.label return = $19
.label x = $34
.label y = $36
lda y+1
bmi !b1+
jmp b1
!b1:
sec
lda #0
sbc y
sta _2
lda #0
sbc y+1
sta _2+1
b3:
lda x+1
bmi !b4+
jmp b4
!b4:
sec
lda #0
sbc x
sta _7
lda #0
sbc x+1
sta _7+1
b6:
lda #0
sta angle
sta angle+1
tax
b10:
lda yi+1
bne b11
lda yi
bne b11
b12:
lsr angle+1
ror angle
lda x+1
bpl b7
sec
lda #<$8000
sbc angle
sta angle
lda #>$8000
sbc angle+1
sta angle+1
b7:
lda y+1
bpl b8
sec
lda #0
sbc angle
sta angle
lda #0
sbc angle+1
sta angle+1
b8:
rts
b11:
txa
tay
lda xi
sta xd
lda xi+1
sta xd+1
lda yi
sta yd
lda yi+1
sta yd+1
b13:
cpy #2
bcs b14
cpy #0
beq b17
lda xd+1
cmp #$80
ror xd+1
ror xd
lda yd+1
cmp #$80
ror yd+1
ror yd
b17:
lda yi+1
bpl b18
lda xi
sec
sbc yd
sta xi
lda xi+1
sbc yd+1
sta xi+1
lda yi
clc
adc xd
sta yi
lda yi+1
adc xd+1
sta yi+1
txa
asl
tay
sec
lda angle
sbc CORDIC_ATAN2_ANGLES_16,y
sta angle
lda angle+1
sbc CORDIC_ATAN2_ANGLES_16+1,y
sta angle+1
b19:
inx
cpx #CORDIC_ITERATIONS_16-1+1
bne !b12+
jmp b12
!b12:
jmp b10
b18:
lda xi
clc
adc yd
sta xi
lda xi+1
adc yd+1
sta xi+1
lda yi
sec
sbc xd
sta yi
lda yi+1
sbc xd+1
sta yi+1
txa
asl
tay
clc
lda angle
adc CORDIC_ATAN2_ANGLES_16,y
sta angle
lda angle+1
adc CORDIC_ATAN2_ANGLES_16+1,y
sta angle+1
jmp b19
b14:
lda xd+1
cmp #$80
ror xd+1
ror xd
lda xd+1
cmp #$80
ror xd+1
ror xd
lda yd+1
cmp #$80
ror yd+1
ror yd
lda yd+1
cmp #$80
ror yd+1
ror yd
dey
dey
jmp b13
b4:
lda x
sta xi
lda x+1
sta xi+1
jmp b6
b1:
lda y
sta yi
lda y+1
sta yi+1
jmp b3
}
// Populates 1000 bytes (a screen) with values representing the distance to the center.
// The actual value stored is distance*2 to increase precision
// init_dist_screen(byte* zeropage($20) screen)
init_dist_screen: {
.label screen = $20
.label screen_bottomline = $22
.label yds = $39
.label xds = $3b
.label ds = $3b
.label x = $24
.label xb = $25
.label screen_topline = $20
.label y = $1f
jsr init_squares
lda screen
clc
adc #<$28*$18
sta screen_bottomline
lda screen+1
adc #>$28*$18
sta screen_bottomline+1
lda #0
sta y
b1:
lda y
asl
cmp #$18
bcs b2
eor #$ff
clc
adc #$18+1
b4:
jsr sqr
lda sqr.return
sta sqr.return_2
lda sqr.return+1
sta sqr.return_2+1
lda #$27
sta xb
lda #0
sta x
b5:
lda x
asl
cmp #$27
bcs b6
eor #$ff
clc
adc #$27+1
b8:
jsr sqr
lda ds
clc
adc yds
sta ds
lda ds+1
adc yds+1
sta ds+1
jsr sqrt
ldy x
sta (screen_topline),y
sta (screen_bottomline),y
ldy xb
sta (screen_topline),y
sta (screen_bottomline),y
inc x
dec xb
lda x
cmp #$13+1
bcc b5
lda #$28
clc
adc screen_topline
sta screen_topline
bcc !+
inc screen_topline+1
!:
lda screen_bottomline
sec
sbc #<$28
sta screen_bottomline
lda screen_bottomline+1
sbc #>$28
sta screen_bottomline+1
inc y
lda #$d
cmp y
bne b1
rts
b6:
sec
sbc #$27
jmp b8
b2:
sec
sbc #$18
jmp b4
}
// Find the (integer) square root of a word value
// If the square is not an integer then it returns the largest integer N where N*N <= val
// Uses a table of squares that must be initialized by calling init_squares()
// sqrt(word zeropage($3b) val)
sqrt: {
.label _1 = $26
.label _3 = $26
.label found = $26
.label val = $3b
lda SQUARES
sta bsearch16u.items
lda SQUARES+1
sta bsearch16u.items+1
jsr bsearch16u
lda _3
sec
sbc SQUARES
sta _3
lda _3+1
sbc SQUARES+1
sta _3+1
lsr _1+1
ror _1
lda _1
rts
}
// Searches an array of nitems unsigned words, the initial member of which is pointed to by base, for a member that matches the value key.
// - key - The value to look for
// - items - Pointer to the start of the array to search in
// - num - The number of items in the array
// Returns pointer to an entry in the array that matches the search key
// bsearch16u(word zeropage($3b) key, word* zeropage($26) items, byte register(X) num)
bsearch16u: {
.label _2 = $26
.label pivot = $3d
.label result = $3f
.label return = $26
.label items = $26
.label key = $3b
ldx #NUM_SQUARES
b3:
cpx #0
bne b4
ldy #1
lda (items),y
cmp key+1
bne !+
dey
lda (items),y
cmp key
beq b2
!:
bcc b2
lda _2
sec
sbc #<1*SIZEOF_WORD
sta _2
lda _2+1
sbc #>1*SIZEOF_WORD
sta _2+1
b2:
rts
b4:
txa
lsr
asl
clc
adc items
sta pivot
lda #0
adc items+1
sta pivot+1
sec
lda key
ldy #0
sbc (pivot),y
sta result
lda key+1
iny
sbc (pivot),y
sta result+1
bne b6
lda result
bne b6
lda pivot
sta return
lda pivot+1
sta return+1
rts
b6:
lda result+1
bmi b7
bne !+
lda result
beq b7
!:
lda #1*SIZEOF_WORD
clc
adc pivot
sta items
lda #0
adc pivot+1
sta items+1
dex
b7:
txa
lsr
tax
jmp b3
}
// Find the square of a byte value
// Uses a table of squares that must be initialized by calling init_squares()
// sqr(byte register(A) val)
sqr: {
.label return = $3b
.label return_2 = $39
asl
tay
lda (SQUARES),y
sta return
iny
lda (SQUARES),y
sta return+1
rts
}
// Initialize squares table
// Uses iterative formula (x+1)^2 = x^2 + 2*x + 1
init_squares: {
.label squares = $2a
.label sqr = $28
lda #NUM_SQUARES*SIZEOF_WORD
sta malloc.size
lda #0
sta malloc.size+1
jsr malloc
lda SQUARES
sta squares
lda SQUARES+1
sta squares+1
ldx #0
txa
sta sqr
sta sqr+1
b1:
ldy #0
lda sqr
sta (squares),y
iny
lda sqr+1
sta (squares),y
lda #SIZEOF_WORD
clc
adc squares
sta squares
bcc !+
inc squares+1
!:
txa
asl
clc
adc #1
clc
adc sqr
sta sqr
bcc !+
inc sqr+1
!:
inx
cpx #NUM_SQUARES-1+1
bne b1
rts
}
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($2e) size)
malloc: {
.label mem = $41
.label size = $2e
lda heap_head
sta mem
lda heap_head+1
sta mem+1
lda heap_head
clc
adc size
sta heap_head
lda heap_head+1
adc size+1
sta heap_head+1
rts
}
// Angles representing ATAN(0.5), ATAN(0.25), ATAN(0.125), ...
CORDIC_ATAN2_ANGLES_16:
.for (var i=0; i<CORDIC_ITERATIONS_16; i++)
.word 256*2*256*atan(1/pow(2,i))/PI/2

View File

@ -0,0 +1,387 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call malloc
to:@3
@3: scope:[] from @1
[3] (void*) SCREEN_DIST#0 ← (void*)(byte*) malloc::mem#0
[4] call malloc
to:@4
@4: scope:[] from @3
[5] (void*) SCREEN_ANGLE#0 ← (void*)(byte*) malloc::mem#0
to:@2
@2: scope:[] from @4
[6] phi()
[7] call main
to:@end
@end: scope:[] from @2
[8] phi()
main: scope:[main] from @2
[9] (byte*) init_dist_screen::screen#0 ← (byte*)(void*) SCREEN_DIST#0
[10] call init_dist_screen
to:main::@8
main::@8: scope:[main] from main
[11] (byte*) init_angle_screen::screen#0 ← (byte*)(void*) SCREEN_ANGLE#0
[12] call init_angle_screen
to:main::@1
main::@1: scope:[main] from main::@7 main::@8
[13] (byte*) main::dist#0 ← (byte*)(void*) SCREEN_DIST#0
[14] (byte*) main::angle#0 ← (byte*)(void*) SCREEN_ANGLE#0
to:main::@2
main::@2: scope:[main] from main::@1 main::@9
[15] (byte*) main::min_fill#5 ← phi( main::@1/(const byte*) SCREEN_FILL#0 main::@9/(byte*) main::min_fill#2 )
[15] (word) main::min_dist_angle#2 ← phi( main::@1/(word) $ffff main::@9/(word~) main::min_dist_angle#6 )
[15] (byte*) main::angle#2 ← phi( main::@1/(byte*) main::angle#0 main::@9/(byte*) main::angle#1 )
[15] (byte*) main::dist#2 ← phi( main::@1/(byte*) main::dist#0 main::@9/(byte*) main::dist#1 )
[15] (byte*) main::fill#2 ← phi( main::@1/(const byte*) SCREEN_FILL#0 main::@9/(byte*) main::fill#1 )
[16] if(*((byte*) main::fill#2)==(const byte) FILL_CHAR#0) goto main::@10
to:main::@4
main::@4: scope:[main] from main::@2
[17] (word) main::dist_angle#0 ← *((byte*) main::dist#2) w= *((byte*) main::angle#2)
[18] if((word) main::dist_angle#0>=(word) main::min_dist_angle#2) goto main::@11
to:main::@5
main::@5: scope:[main] from main::@4
[19] (byte*~) main::min_fill#10 ← (byte*) main::fill#2
to:main::@3
main::@3: scope:[main] from main::@10 main::@11 main::@5
[20] (byte*) main::min_fill#2 ← phi( main::@10/(byte*) main::min_fill#5 main::@11/(byte*) main::min_fill#5 main::@5/(byte*~) main::min_fill#10 )
[20] (word) main::min_dist_angle#3 ← phi( main::@10/(word~) main::min_dist_angle#7 main::@11/(word~) main::min_dist_angle#8 main::@5/(word) main::dist_angle#0 )
[21] (byte*) main::dist#1 ← ++ (byte*) main::dist#2
[22] (byte*) main::angle#1 ← ++ (byte*) main::angle#2
[23] (byte*) main::fill#1 ← ++ (byte*) main::fill#2
[24] if((byte*) main::fill#1<(const byte*) SCREEN_FILL#0+(word) $3e8) goto main::@9
to:main::@6
main::@6: scope:[main] from main::@3
[25] if((word) main::min_dist_angle#3!=(word) $ffff) goto main::@7
to:main::@return
main::@return: scope:[main] from main::@6
[26] return
to:@return
main::@7: scope:[main] from main::@6
[27] *((byte*) main::min_fill#2) ← (const byte) FILL_CHAR#0
to:main::@1
main::@9: scope:[main] from main::@3
[28] (word~) main::min_dist_angle#6 ← (word) main::min_dist_angle#3
to:main::@2
main::@11: scope:[main] from main::@4
[29] (word~) main::min_dist_angle#8 ← (word) main::min_dist_angle#2
to:main::@3
main::@10: scope:[main] from main::@2
[30] (word~) main::min_dist_angle#7 ← (word) main::min_dist_angle#2
to:main::@3
init_angle_screen: scope:[init_angle_screen] from main::@8
[31] (byte*) init_angle_screen::screen_topline#0 ← (byte*) init_angle_screen::screen#0 + (word)(number) $28*(number) $c
[32] (byte*) init_angle_screen::screen_bottomline#0 ← (byte*) init_angle_screen::screen#0 + (word)(number) $28*(number) $c
to:init_angle_screen::@1
init_angle_screen::@1: scope:[init_angle_screen] from init_angle_screen init_angle_screen::@3
[33] (byte*) init_angle_screen::screen_topline#5 ← phi( init_angle_screen/(byte*) init_angle_screen::screen_topline#0 init_angle_screen::@3/(byte*) init_angle_screen::screen_topline#1 )
[33] (byte*) init_angle_screen::screen_bottomline#5 ← phi( init_angle_screen/(byte*) init_angle_screen::screen_bottomline#0 init_angle_screen::@3/(byte*) init_angle_screen::screen_bottomline#1 )
[33] (byte) init_angle_screen::y#4 ← phi( init_angle_screen/(byte) 0 init_angle_screen::@3/(byte) init_angle_screen::y#1 )
to:init_angle_screen::@2
init_angle_screen::@2: scope:[init_angle_screen] from init_angle_screen::@1 init_angle_screen::@4
[34] (byte) init_angle_screen::xb#2 ← phi( init_angle_screen::@1/(byte) $27 init_angle_screen::@4/(byte) init_angle_screen::xb#1 )
[34] (byte) init_angle_screen::x#2 ← phi( init_angle_screen::@1/(byte) 0 init_angle_screen::@4/(byte) init_angle_screen::x#1 )
[35] (byte~) init_angle_screen::$2 ← (byte) init_angle_screen::x#2 << (byte) 1
[36] (byte~) init_angle_screen::$3 ← (byte) $27 - (byte~) init_angle_screen::$2
[37] (word) init_angle_screen::xw#0 ← (byte~) init_angle_screen::$3 w= (byte) 0
[38] (byte~) init_angle_screen::$6 ← (byte) init_angle_screen::y#4 << (byte) 1
[39] (word) init_angle_screen::yw#0 ← (byte~) init_angle_screen::$6 w= (byte) 0
[40] (signed word) atan2_16::x#0 ← (signed word)(word) init_angle_screen::xw#0
[41] (signed word) atan2_16::y#0 ← (signed word)(word) init_angle_screen::yw#0
[42] call atan2_16
[43] (word) atan2_16::return#2 ← (word) atan2_16::return#0
to:init_angle_screen::@4
init_angle_screen::@4: scope:[init_angle_screen] from init_angle_screen::@2
[44] (word) init_angle_screen::angle_w#0 ← (word) atan2_16::return#2
[45] (word~) init_angle_screen::$10 ← (word) init_angle_screen::angle_w#0 + (byte) $80
[46] (byte) init_angle_screen::ang_w#0 ← > (word~) init_angle_screen::$10
[47] *((byte*) init_angle_screen::screen_bottomline#5 + (byte) init_angle_screen::xb#2) ← (byte) init_angle_screen::ang_w#0
[48] (byte~) init_angle_screen::$12 ← - (byte) init_angle_screen::ang_w#0
[49] *((byte*) init_angle_screen::screen_topline#5 + (byte) init_angle_screen::xb#2) ← (byte~) init_angle_screen::$12
[50] (byte~) init_angle_screen::$13 ← (byte) $80 + (byte) init_angle_screen::ang_w#0
[51] *((byte*) init_angle_screen::screen_topline#5 + (byte) init_angle_screen::x#2) ← (byte~) init_angle_screen::$13
[52] (byte~) init_angle_screen::$14 ← (byte) $80 - (byte) init_angle_screen::ang_w#0
[53] *((byte*) init_angle_screen::screen_bottomline#5 + (byte) init_angle_screen::x#2) ← (byte~) init_angle_screen::$14
[54] (byte) init_angle_screen::x#1 ← ++ (byte) init_angle_screen::x#2
[55] (byte) init_angle_screen::xb#1 ← -- (byte) init_angle_screen::xb#2
[56] if((byte) init_angle_screen::x#1<(byte) $13+(byte) 1) goto init_angle_screen::@2
to:init_angle_screen::@3
init_angle_screen::@3: scope:[init_angle_screen] from init_angle_screen::@4
[57] (byte*) init_angle_screen::screen_topline#1 ← (byte*) init_angle_screen::screen_topline#5 - (byte) $28
[58] (byte*) init_angle_screen::screen_bottomline#1 ← (byte*) init_angle_screen::screen_bottomline#5 + (byte) $28
[59] (byte) init_angle_screen::y#1 ← ++ (byte) init_angle_screen::y#4
[60] if((byte) init_angle_screen::y#1!=(byte) $d) goto init_angle_screen::@1
to:init_angle_screen::@return
init_angle_screen::@return: scope:[init_angle_screen] from init_angle_screen::@3
[61] return
to:@return
atan2_16: scope:[atan2_16] from init_angle_screen::@2
[62] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
to:atan2_16::@2
atan2_16::@2: scope:[atan2_16] from atan2_16
[63] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0
to:atan2_16::@3
atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2
[64] (signed word) atan2_16::yi#0 ← phi( atan2_16::@1/(signed word~) atan2_16::yi#16 atan2_16::@2/(signed word~) atan2_16::$2 )
[65] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
to:atan2_16::@5
atan2_16::@5: scope:[atan2_16] from atan2_16::@3
[66] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0
to:atan2_16::@6
atan2_16::@6: scope:[atan2_16] from atan2_16::@4 atan2_16::@5
[67] (signed word) atan2_16::xi#0 ← phi( atan2_16::@4/(signed word~) atan2_16::xi#13 atan2_16::@5/(signed word~) atan2_16::$7 )
to:atan2_16::@10
atan2_16::@10: scope:[atan2_16] from atan2_16::@19 atan2_16::@6
[68] (word) atan2_16::angle#12 ← phi( atan2_16::@19/(word) atan2_16::angle#13 atan2_16::@6/(byte) 0 )
[68] (byte) atan2_16::i#2 ← phi( atan2_16::@19/(byte) atan2_16::i#1 atan2_16::@6/(byte) 0 )
[68] (signed word) atan2_16::xi#3 ← phi( atan2_16::@19/(signed word) atan2_16::xi#8 atan2_16::@6/(signed word) atan2_16::xi#0 )
[68] (signed word) atan2_16::yi#3 ← phi( atan2_16::@19/(signed word) atan2_16::yi#8 atan2_16::@6/(signed word) atan2_16::yi#0 )
[69] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@11
to:atan2_16::@12
atan2_16::@12: scope:[atan2_16] from atan2_16::@10 atan2_16::@19
[70] (word) atan2_16::angle#6 ← phi( atan2_16::@10/(word) atan2_16::angle#12 atan2_16::@19/(word) atan2_16::angle#13 )
[71] (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 >> (byte) 1
[72] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@7
to:atan2_16::@21
atan2_16::@21: scope:[atan2_16] from atan2_16::@12
[73] (word) atan2_16::angle#4 ← (word) $8000 - (word) atan2_16::angle#1
to:atan2_16::@7
atan2_16::@7: scope:[atan2_16] from atan2_16::@12 atan2_16::@21
[74] (word) atan2_16::angle#11 ← phi( atan2_16::@12/(word) atan2_16::angle#1 atan2_16::@21/(word) atan2_16::angle#4 )
[75] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@8
to:atan2_16::@9
atan2_16::@9: scope:[atan2_16] from atan2_16::@7
[76] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11
to:atan2_16::@8
atan2_16::@8: scope:[atan2_16] from atan2_16::@7 atan2_16::@9
[77] (word) atan2_16::return#0 ← phi( atan2_16::@9/(word) atan2_16::angle#5 atan2_16::@7/(word) atan2_16::angle#11 )
to:atan2_16::@return
atan2_16::@return: scope:[atan2_16] from atan2_16::@8
[78] return
to:@return
atan2_16::@11: scope:[atan2_16] from atan2_16::@10
[79] (byte~) atan2_16::shift#5 ← (byte) atan2_16::i#2
[80] (signed word~) atan2_16::xd#10 ← (signed word) atan2_16::xi#3
[81] (signed word~) atan2_16::yd#10 ← (signed word) atan2_16::yi#3
to:atan2_16::@13
atan2_16::@13: scope:[atan2_16] from atan2_16::@11 atan2_16::@14
[82] (signed word) atan2_16::yd#3 ← phi( atan2_16::@11/(signed word~) atan2_16::yd#10 atan2_16::@14/(signed word) atan2_16::yd#1 )
[82] (signed word) atan2_16::xd#3 ← phi( atan2_16::@11/(signed word~) atan2_16::xd#10 atan2_16::@14/(signed word) atan2_16::xd#1 )
[82] (byte) atan2_16::shift#2 ← phi( atan2_16::@11/(byte~) atan2_16::shift#5 atan2_16::@14/(byte) atan2_16::shift#1 )
[83] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@14
to:atan2_16::@15
atan2_16::@15: scope:[atan2_16] from atan2_16::@13
[84] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@17
to:atan2_16::@16
atan2_16::@16: scope:[atan2_16] from atan2_16::@15
[85] (signed word) atan2_16::xd#2 ← (signed word) atan2_16::xd#3 >> (signed byte) 1
[86] (signed word) atan2_16::yd#2 ← (signed word) atan2_16::yd#3 >> (signed byte) 1
to:atan2_16::@17
atan2_16::@17: scope:[atan2_16] from atan2_16::@15 atan2_16::@16
[87] (signed word) atan2_16::xd#5 ← phi( atan2_16::@15/(signed word) atan2_16::xd#3 atan2_16::@16/(signed word) atan2_16::xd#2 )
[87] (signed word) atan2_16::yd#5 ← phi( atan2_16::@15/(signed word) atan2_16::yd#3 atan2_16::@16/(signed word) atan2_16::yd#2 )
[88] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@18
to:atan2_16::@20
atan2_16::@20: scope:[atan2_16] from atan2_16::@17
[89] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#5
[90] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#5
[91] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1
[92] (word) atan2_16::angle#3 ← (word) atan2_16::angle#12 - *((const word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16#0 + (byte~) atan2_16::$24)
to:atan2_16::@19
atan2_16::@19: scope:[atan2_16] from atan2_16::@18 atan2_16::@20
[93] (signed word) atan2_16::xi#8 ← phi( atan2_16::@18/(signed word) atan2_16::xi#1 atan2_16::@20/(signed word) atan2_16::xi#2 )
[93] (word) atan2_16::angle#13 ← phi( atan2_16::@18/(word) atan2_16::angle#2 atan2_16::@20/(word) atan2_16::angle#3 )
[93] (signed word) atan2_16::yi#8 ← phi( atan2_16::@18/(signed word) atan2_16::yi#1 atan2_16::@20/(signed word) atan2_16::yi#2 )
[94] (byte) atan2_16::i#1 ← ++ (byte) atan2_16::i#2
[95] if((byte) atan2_16::i#1==(const byte) CORDIC_ITERATIONS_16#0-(byte) 1+(byte) 1) goto atan2_16::@12
to:atan2_16::@10
atan2_16::@18: scope:[atan2_16] from atan2_16::@17
[96] (signed word) atan2_16::xi#1 ← (signed word) atan2_16::xi#3 + (signed word) atan2_16::yd#5
[97] (signed word) atan2_16::yi#1 ← (signed word) atan2_16::yi#3 - (signed word) atan2_16::xd#5
[98] (byte~) atan2_16::$23 ← (byte) atan2_16::i#2 << (byte) 1
[99] (word) atan2_16::angle#2 ← (word) atan2_16::angle#12 + *((const word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16#0 + (byte~) atan2_16::$23)
to:atan2_16::@19
atan2_16::@14: scope:[atan2_16] from atan2_16::@13
[100] (signed word) atan2_16::xd#1 ← (signed word) atan2_16::xd#3 >> (signed byte) 2
[101] (signed word) atan2_16::yd#1 ← (signed word) atan2_16::yd#3 >> (signed byte) 2
[102] (byte) atan2_16::shift#1 ← (byte) atan2_16::shift#2 - (byte) 2
to:atan2_16::@13
atan2_16::@4: scope:[atan2_16] from atan2_16::@3
[103] (signed word~) atan2_16::xi#13 ← (signed word) atan2_16::x#0
to:atan2_16::@6
atan2_16::@1: scope:[atan2_16] from atan2_16
[104] (signed word~) atan2_16::yi#16 ← (signed word) atan2_16::y#0
to:atan2_16::@3
init_dist_screen: scope:[init_dist_screen] from main
[105] phi()
[106] call init_squares
to:init_dist_screen::@10
init_dist_screen::@10: scope:[init_dist_screen] from init_dist_screen
[107] (byte*) init_dist_screen::screen_bottomline#0 ← (byte*) init_dist_screen::screen#0 + (word)(number) $28*(number) $18
to:init_dist_screen::@1
init_dist_screen::@1: scope:[init_dist_screen] from init_dist_screen::@10 init_dist_screen::@9
[108] (byte*) init_dist_screen::screen_bottomline#10 ← phi( init_dist_screen::@9/(byte*) init_dist_screen::screen_bottomline#1 init_dist_screen::@10/(byte*) init_dist_screen::screen_bottomline#0 )
[108] (byte*) init_dist_screen::screen_topline#10 ← phi( init_dist_screen::@9/(byte*) init_dist_screen::screen_topline#1 init_dist_screen::@10/(byte*) init_dist_screen::screen#0 )
[108] (byte) init_dist_screen::y#10 ← phi( init_dist_screen::@9/(byte) init_dist_screen::y#1 init_dist_screen::@10/(byte) 0 )
[109] (byte) init_dist_screen::y2#0 ← (byte) init_dist_screen::y#10 << (byte) 1
[110] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
to:init_dist_screen::@3
init_dist_screen::@3: scope:[init_dist_screen] from init_dist_screen::@1
[111] (byte~) init_dist_screen::$5 ← (byte) $18 - (byte) init_dist_screen::y2#0
to:init_dist_screen::@4
init_dist_screen::@4: scope:[init_dist_screen] from init_dist_screen::@2 init_dist_screen::@3
[112] (byte) init_dist_screen::yd#0 ← phi( init_dist_screen::@2/(byte~) init_dist_screen::$7 init_dist_screen::@3/(byte~) init_dist_screen::$5 )
[113] (byte) sqr::val#0 ← (byte) init_dist_screen::yd#0
[114] call sqr
[115] (word) sqr::return#2 ← (word) sqr::return#0
to:init_dist_screen::@11
init_dist_screen::@11: scope:[init_dist_screen] from init_dist_screen::@4
[116] (word) init_dist_screen::yds#0 ← (word) sqr::return#2
to:init_dist_screen::@5
init_dist_screen::@5: scope:[init_dist_screen] from init_dist_screen::@11 init_dist_screen::@13
[117] (byte) init_dist_screen::xb#2 ← phi( init_dist_screen::@11/(byte) $27 init_dist_screen::@13/(byte) init_dist_screen::xb#1 )
[117] (byte) init_dist_screen::x#2 ← phi( init_dist_screen::@11/(byte) 0 init_dist_screen::@13/(byte) init_dist_screen::x#1 )
[118] (byte) init_dist_screen::x2#0 ← (byte) init_dist_screen::x#2 << (byte) 1
[119] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
to:init_dist_screen::@7
init_dist_screen::@7: scope:[init_dist_screen] from init_dist_screen::@5
[120] (byte~) init_dist_screen::$13 ← (byte) $27 - (byte) init_dist_screen::x2#0
to:init_dist_screen::@8
init_dist_screen::@8: scope:[init_dist_screen] from init_dist_screen::@6 init_dist_screen::@7
[121] (byte) init_dist_screen::xd#0 ← phi( init_dist_screen::@6/(byte~) init_dist_screen::$15 init_dist_screen::@7/(byte~) init_dist_screen::$13 )
[122] (byte) sqr::val#1 ← (byte) init_dist_screen::xd#0
[123] call sqr
[124] (word) sqr::return#3 ← (word) sqr::return#0
to:init_dist_screen::@12
init_dist_screen::@12: scope:[init_dist_screen] from init_dist_screen::@8
[125] (word) init_dist_screen::xds#0 ← (word) sqr::return#3
[126] (word) init_dist_screen::ds#0 ← (word) init_dist_screen::xds#0 + (word) init_dist_screen::yds#0
[127] (word) sqrt::val#0 ← (word) init_dist_screen::ds#0
[128] call sqrt
[129] (byte) sqrt::return#2 ← (byte) sqrt::return#0
to:init_dist_screen::@13
init_dist_screen::@13: scope:[init_dist_screen] from init_dist_screen::@12
[130] (byte) init_dist_screen::d#0 ← (byte) sqrt::return#2
[131] *((byte*) init_dist_screen::screen_topline#10 + (byte) init_dist_screen::x#2) ← (byte) init_dist_screen::d#0
[132] *((byte*) init_dist_screen::screen_bottomline#10 + (byte) init_dist_screen::x#2) ← (byte) init_dist_screen::d#0
[133] *((byte*) init_dist_screen::screen_topline#10 + (byte) init_dist_screen::xb#2) ← (byte) init_dist_screen::d#0
[134] *((byte*) init_dist_screen::screen_bottomline#10 + (byte) init_dist_screen::xb#2) ← (byte) init_dist_screen::d#0
[135] (byte) init_dist_screen::x#1 ← ++ (byte) init_dist_screen::x#2
[136] (byte) init_dist_screen::xb#1 ← -- (byte) init_dist_screen::xb#2
[137] if((byte) init_dist_screen::x#1<(byte) $13+(byte) 1) goto init_dist_screen::@5
to:init_dist_screen::@9
init_dist_screen::@9: scope:[init_dist_screen] from init_dist_screen::@13
[138] (byte*) init_dist_screen::screen_topline#1 ← (byte*) init_dist_screen::screen_topline#10 + (byte) $28
[139] (byte*) init_dist_screen::screen_bottomline#1 ← (byte*) init_dist_screen::screen_bottomline#10 - (byte) $28
[140] (byte) init_dist_screen::y#1 ← ++ (byte) init_dist_screen::y#10
[141] if((byte) init_dist_screen::y#1!=(byte) $d) goto init_dist_screen::@1
to:init_dist_screen::@return
init_dist_screen::@return: scope:[init_dist_screen] from init_dist_screen::@9
[142] return
to:@return
init_dist_screen::@6: scope:[init_dist_screen] from init_dist_screen::@5
[143] (byte~) init_dist_screen::$15 ← (byte) init_dist_screen::x2#0 - (byte) $27
to:init_dist_screen::@8
init_dist_screen::@2: scope:[init_dist_screen] from init_dist_screen::@1
[144] (byte~) init_dist_screen::$7 ← (byte) init_dist_screen::y2#0 - (byte) $18
to:init_dist_screen::@4
sqrt: scope:[sqrt] from init_dist_screen::@12
[145] (word) bsearch16u::key#0 ← (word) sqrt::val#0
[146] (word*) bsearch16u::items#1 ← (word*)(void*) SQUARES#1
[147] call bsearch16u
[148] (word*) bsearch16u::return#3 ← (word*) bsearch16u::return#1
to:sqrt::@1
sqrt::@1: scope:[sqrt] from sqrt
[149] (word*) sqrt::found#0 ← (word*) bsearch16u::return#3
[150] (word~) sqrt::$3 ← (word*) sqrt::found#0 - (word*)(void*) SQUARES#1
[151] (word~) sqrt::$1 ← (word~) sqrt::$3 >> (byte) 1
[152] (byte) sqrt::return#0 ← (byte)(word~) sqrt::$1
to:sqrt::@return
sqrt::@return: scope:[sqrt] from sqrt::@1
[153] return
to:@return
bsearch16u: scope:[bsearch16u] from sqrt
[154] phi()
to:bsearch16u::@3
bsearch16u::@3: scope:[bsearch16u] from bsearch16u bsearch16u::@7
[155] (word*) bsearch16u::items#2 ← phi( bsearch16u/(word*) bsearch16u::items#1 bsearch16u::@7/(word*) bsearch16u::items#8 )
[155] (byte) bsearch16u::num#3 ← phi( bsearch16u/(const byte) NUM_SQUARES#3 bsearch16u::@7/(byte) bsearch16u::num#0 )
[156] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@4
to:bsearch16u::@5
bsearch16u::@5: scope:[bsearch16u] from bsearch16u::@3
[157] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2
to:bsearch16u::@1
bsearch16u::@1: scope:[bsearch16u] from bsearch16u::@5
[158] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD
to:bsearch16u::@2
bsearch16u::@2: scope:[bsearch16u] from bsearch16u::@1 bsearch16u::@5
[159] (word*) bsearch16u::return#2 ← phi( bsearch16u::@5/(word*) bsearch16u::items#2 bsearch16u::@1/(word*~) bsearch16u::$2 )
to:bsearch16u::@return
bsearch16u::@return: scope:[bsearch16u] from bsearch16u::@2 bsearch16u::@8
[160] (word*) bsearch16u::return#1 ← phi( bsearch16u::@8/(word*~) bsearch16u::return#6 bsearch16u::@2/(word*) bsearch16u::return#2 )
[161] return
to:@return
bsearch16u::@4: scope:[bsearch16u] from bsearch16u::@3
[162] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1
[163] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1
[164] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16
[165] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0)
[166] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6
to:bsearch16u::@8
bsearch16u::@8: scope:[bsearch16u] from bsearch16u::@4
[167] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0
to:bsearch16u::@return
bsearch16u::@6: scope:[bsearch16u] from bsearch16u::@4
[168] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7
to:bsearch16u::@9
bsearch16u::@9: scope:[bsearch16u] from bsearch16u::@6
[169] (word*) bsearch16u::items#0 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD
[170] (byte) bsearch16u::num#1 ← -- (byte) bsearch16u::num#3
to:bsearch16u::@7
bsearch16u::@7: scope:[bsearch16u] from bsearch16u::@6 bsearch16u::@9
[171] (word*) bsearch16u::items#8 ← phi( bsearch16u::@9/(word*) bsearch16u::items#0 bsearch16u::@6/(word*) bsearch16u::items#2 )
[171] (byte) bsearch16u::num#5 ← phi( bsearch16u::@9/(byte) bsearch16u::num#1 bsearch16u::@6/(byte) bsearch16u::num#3 )
[172] (byte) bsearch16u::num#0 ← (byte) bsearch16u::num#5 >> (byte) 1
to:bsearch16u::@3
sqr: scope:[sqr] from init_dist_screen::@4 init_dist_screen::@8
[173] (byte) sqr::val#2 ← phi( init_dist_screen::@4/(byte) sqr::val#0 init_dist_screen::@8/(byte) sqr::val#1 )
[174] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1
[175] (word) sqr::return#0 ← *((word*)(void*) SQUARES#1 + (byte~) sqr::$0)
to:sqr::@return
sqr::@return: scope:[sqr] from sqr
[176] return
to:@return
init_squares: scope:[init_squares] from init_dist_screen
[177] phi()
[178] call malloc
to:init_squares::@2
init_squares::@2: scope:[init_squares] from init_squares
[179] (void*) SQUARES#1 ← (void*)(byte*) malloc::mem#0
[180] (word*) init_squares::squares#0 ← (word*)(void*) SQUARES#1
to:init_squares::@1
init_squares::@1: scope:[init_squares] from init_squares::@1 init_squares::@2
[181] (byte) init_squares::i#2 ← phi( init_squares::@1/(byte) init_squares::i#1 init_squares::@2/(byte) 0 )
[181] (word*) init_squares::squares#2 ← phi( init_squares::@1/(word*) init_squares::squares#1 init_squares::@2/(word*) init_squares::squares#0 )
[181] (word) init_squares::sqr#2 ← phi( init_squares::@1/(word) init_squares::sqr#1 init_squares::@2/(byte) 0 )
[182] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2
[183] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD
[184] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1
[185] (byte~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1
[186] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4
[187] (byte) init_squares::i#1 ← ++ (byte) init_squares::i#2
[188] if((byte) init_squares::i#1!=(const byte) NUM_SQUARES#3-(byte) 1+(byte) 1) goto init_squares::@1
to:init_squares::@return
init_squares::@return: scope:[init_squares] from init_squares::@1
[189] return
to:@return
malloc: scope:[malloc] from @1 @3 init_squares
[190] (word) malloc::size#3 ← phi( @3/(word) $3e8 @1/(word) $3e8 init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[190] (byte*) heap_head#12 ← phi( @3/(byte*) heap_head#1 @1/(const byte*) HEAP_START#0 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#12
[192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[193] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,380 @@
(label) @1
(label) @2
(label) @3
(label) @4
(label) @begin
(label) @end
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16
(const word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16#0 CORDIC_ATAN2_ANGLES_16 = kickasm {{ .for (var i=0; i<CORDIC_ITERATIONS_16; i++)
.word 256*2*256*atan(1/pow(2,i))/PI/2
}}
(byte) CORDIC_ITERATIONS_16
(const byte) CORDIC_ITERATIONS_16#0 CORDIC_ITERATIONS_16 = (byte) $f
(byte) FILL_CHAR
(const byte) FILL_CHAR#0 FILL_CHAR = (byte) '@'
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN_ANGLE
(void*) SCREEN_ANGLE#0 SCREEN_ANGLE zp ZP_WORD:50 0.08695652173913043
(byte*) SCREEN_DIST
(void*) SCREEN_DIST#0 SCREEN_DIST zp ZP_WORD:48 0.08
(byte*) SCREEN_FILL
(const byte*) SCREEN_FILL#0 SCREEN_FILL = (byte*) 1024
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) SQUARES
(void*) SQUARES#1 SQUARES zp ZP_WORD:65 0.03225806451612903
(word()) atan2_16((signed word) atan2_16::x , (signed word) atan2_16::y)
(signed word~) atan2_16::$2 $2 zp ZP_WORD:21 4.0
(byte~) atan2_16::$23 reg byte a 2002.0
(byte~) atan2_16::$24 reg byte a 2002.0
(signed word~) atan2_16::$7 $7 zp ZP_WORD:23 4.0
(label) atan2_16::@1
(label) atan2_16::@10
(label) atan2_16::@11
(label) atan2_16::@12
(label) atan2_16::@13
(label) atan2_16::@14
(label) atan2_16::@15
(label) atan2_16::@16
(label) atan2_16::@17
(label) atan2_16::@18
(label) atan2_16::@19
(label) atan2_16::@2
(label) atan2_16::@20
(label) atan2_16::@21
(label) atan2_16::@3
(label) atan2_16::@4
(label) atan2_16::@5
(label) atan2_16::@6
(label) atan2_16::@7
(label) atan2_16::@8
(label) atan2_16::@9
(label) atan2_16::@return
(word) atan2_16::angle
(word) atan2_16::angle#1 angle zp ZP_WORD:25 3.0
(word) atan2_16::angle#11 angle zp ZP_WORD:25 4.0
(word) atan2_16::angle#12 angle zp ZP_WORD:25 190.66666666666666
(word) atan2_16::angle#13 angle zp ZP_WORD:25 1334.6666666666667
(word) atan2_16::angle#2 angle zp ZP_WORD:25 2002.0
(word) atan2_16::angle#3 angle zp ZP_WORD:25 2002.0
(word) atan2_16::angle#4 angle zp ZP_WORD:25 4.0
(word) atan2_16::angle#5 angle zp ZP_WORD:25 4.0
(word) atan2_16::angle#6 angle zp ZP_WORD:25 2004.0
(byte) atan2_16::i
(byte) atan2_16::i#1 reg byte x 1501.5
(byte) atan2_16::i#2 reg byte x 208.54166666666669
(word) atan2_16::return
(word) atan2_16::return#0 return zp ZP_WORD:25 34.99999999999999
(word) atan2_16::return#2 return zp ZP_WORD:25 202.0
(byte) atan2_16::shift
(byte) atan2_16::shift#1 reg byte y 20002.0
(byte) atan2_16::shift#2 reg byte y 8001.25
(byte~) atan2_16::shift#5 reg byte y 667.3333333333334
(signed word) atan2_16::x
(signed word) atan2_16::x#0 x zp ZP_WORD:52 2.8684210526315796
(signed word) atan2_16::xd
(signed word) atan2_16::xd#1 xd zp ZP_WORD:29 6667.333333333333
(signed word~) atan2_16::xd#10 xd zp ZP_WORD:29 1001.0
(signed word) atan2_16::xd#2 xd zp ZP_WORD:29 1001.0
(signed word) atan2_16::xd#3 xd zp ZP_WORD:29 7668.333333333332
(signed word) atan2_16::xd#5 xd zp ZP_WORD:29 1001.0
(signed word) atan2_16::xi
(signed word) atan2_16::xi#0 xi zp ZP_WORD:23 6.0
(signed word) atan2_16::xi#1 xi zp ZP_WORD:23 500.5
(signed word~) atan2_16::xi#13 xi zp ZP_WORD:23 4.0
(signed word) atan2_16::xi#2 xi zp ZP_WORD:23 500.5
(signed word) atan2_16::xi#3 xi zp ZP_WORD:23 267.0666666666667
(signed word) atan2_16::xi#8 xi zp ZP_WORD:23 1001.0
(signed word) atan2_16::y
(signed word) atan2_16::y#0 y zp ZP_WORD:54 2.724999999999999
(signed word) atan2_16::yd
(signed word) atan2_16::yd#1 yd zp ZP_WORD:27 10001.0
(signed word~) atan2_16::yd#10 yd zp ZP_WORD:27 2002.0
(signed word) atan2_16::yd#2 yd zp ZP_WORD:27 2002.0
(signed word) atan2_16::yd#3 yd zp ZP_WORD:27 4601.0
(signed word) atan2_16::yd#5 yd zp ZP_WORD:27 2002.0
(signed word) atan2_16::yi
(signed word) atan2_16::yi#0 yi zp ZP_WORD:21 1.2000000000000002
(signed word) atan2_16::yi#1 yi zp ZP_WORD:21 667.3333333333334
(signed word~) atan2_16::yi#16 yi zp ZP_WORD:21 4.0
(signed word) atan2_16::yi#2 yi zp ZP_WORD:21 667.3333333333334
(signed word) atan2_16::yi#3 yi zp ZP_WORD:21 353.4117647058823
(signed word) atan2_16::yi#8 yi zp ZP_WORD:21 1001.0
(word*()) bsearch16u((word) bsearch16u::key , (word*) bsearch16u::items , (byte) bsearch16u::num)
(byte~) bsearch16u::$16 reg byte a 2002.0
(word*~) bsearch16u::$2 $2 zp ZP_WORD:38 4.0
(byte~) bsearch16u::$6 reg byte a 2002.0
(label) bsearch16u::@1
(label) bsearch16u::@2
(label) bsearch16u::@3
(label) bsearch16u::@4
(label) bsearch16u::@5
(label) bsearch16u::@6
(label) bsearch16u::@7
(label) bsearch16u::@8
(label) bsearch16u::@9
(label) bsearch16u::@return
(word*) bsearch16u::items
(word*) bsearch16u::items#0 items zp ZP_WORD:38 1001.0
(word*) bsearch16u::items#1 items zp ZP_WORD:38 2.0
(word*) bsearch16u::items#2 items zp ZP_WORD:38 334.5555555555556
(word*) bsearch16u::items#8 items zp ZP_WORD:38 1501.5
(word) bsearch16u::key
(word) bsearch16u::key#0 key zp ZP_WORD:59 0.26666666666666666
(byte) bsearch16u::num
(byte) bsearch16u::num#0 reg byte x 2002.0
(byte) bsearch16u::num#1 reg byte x 2002.0
(byte) bsearch16u::num#3 reg byte x 556.1111111111111
(byte) bsearch16u::num#5 reg byte x 3003.0
(word*) bsearch16u::pivot
(word*) bsearch16u::pivot#0 pivot zp ZP_WORD:61 501.0
(signed word) bsearch16u::result
(signed word) bsearch16u::result#0 result zp ZP_WORD:63 1501.5
(word*) bsearch16u::return
(word*) bsearch16u::return#1 return zp ZP_WORD:38 2.0
(word*) bsearch16u::return#2 return zp ZP_WORD:38 6.0
(word*) bsearch16u::return#3 return zp ZP_WORD:38 4.0
(word*~) bsearch16u::return#6 return zp ZP_WORD:38 4.0
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:44 0.6000000000000001
(byte*) heap_head#12 heap_head zp ZP_WORD:44 4.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 $10 zp ZP_WORD:25 202.0
(byte~) init_angle_screen::$12 reg byte a 202.0
(byte~) init_angle_screen::$13 reg byte a 202.0
(byte~) init_angle_screen::$14 reg byte a 202.0
(byte~) init_angle_screen::$2 reg byte a 202.0
(byte~) init_angle_screen::$3 reg byte a 202.0
(byte~) init_angle_screen::$6 reg byte a 202.0
(label) init_angle_screen::@1
(label) init_angle_screen::@2
(label) init_angle_screen::@3
(label) init_angle_screen::@4
(label) init_angle_screen::@return
(byte) init_angle_screen::ang_w
(byte) init_angle_screen::ang_w#0 ang_w zp ZP_BYTE:56 84.16666666666666
(word) init_angle_screen::angle_w
(word) init_angle_screen::angle_w#0 angle_w zp ZP_WORD:25 202.0
(byte*) init_angle_screen::screen
(byte*) init_angle_screen::screen#0 screen zp ZP_WORD:15 3.0
(byte*) init_angle_screen::screen_bottomline
(byte*) init_angle_screen::screen_bottomline#0 screen_bottomline zp ZP_WORD:15 4.0
(byte*) init_angle_screen::screen_bottomline#1 screen_bottomline zp ZP_WORD:15 7.333333333333333
(byte*) init_angle_screen::screen_bottomline#5 screen_bottomline zp ZP_WORD:15 9.040000000000001
(byte*) init_angle_screen::screen_topline
(byte*) init_angle_screen::screen_topline#0 screen_topline zp ZP_WORD:17 2.0
(byte*) init_angle_screen::screen_topline#1 screen_topline zp ZP_WORD:17 5.5
(byte*) init_angle_screen::screen_topline#5 screen_topline zp ZP_WORD:17 9.416666666666666
(byte) init_angle_screen::x
(byte) init_angle_screen::x#1 x zp ZP_BYTE:19 101.0
(byte) init_angle_screen::x#2 x zp ZP_BYTE:19 25.25
(byte) init_angle_screen::xb
(byte) init_angle_screen::xb#1 xb zp ZP_BYTE:20 101.0
(byte) init_angle_screen::xb#2 xb zp ZP_BYTE:20 19.238095238095237
(signed word) init_angle_screen::xw
(word) init_angle_screen::xw#0 xw zp ZP_WORD:52 33.666666666666664
(byte) init_angle_screen::y
(byte) init_angle_screen::y#1 y zp ZP_BYTE:14 16.5
(byte) init_angle_screen::y#4 y zp ZP_BYTE:14 4.730769230769231
(signed word) init_angle_screen::yw
(word) init_angle_screen::yw#0 yw zp ZP_WORD:54 50.5
(void()) init_dist_screen((byte*) init_dist_screen::screen)
(byte~) init_dist_screen::$13 reg byte a 202.0
(byte~) init_dist_screen::$15 reg byte a 202.0
(byte~) init_dist_screen::$5 reg byte a 22.0
(byte~) init_dist_screen::$7 reg byte a 22.0
(label) init_dist_screen::@1
(label) init_dist_screen::@10
(label) init_dist_screen::@11
(label) init_dist_screen::@12
(label) init_dist_screen::@13
(label) init_dist_screen::@2
(label) init_dist_screen::@3
(label) init_dist_screen::@4
(label) init_dist_screen::@5
(label) init_dist_screen::@6
(label) init_dist_screen::@7
(label) init_dist_screen::@8
(label) init_dist_screen::@9
(label) init_dist_screen::@return
(byte) init_dist_screen::d
(byte) init_dist_screen::d#0 reg byte a 126.25
(word) init_dist_screen::ds
(word) init_dist_screen::ds#0 ds zp ZP_WORD:59 202.0
(byte*) init_dist_screen::screen
(byte*) init_dist_screen::screen#0 screen zp ZP_WORD:32 1.5
(byte*) init_dist_screen::screen_bottomline
(byte*) init_dist_screen::screen_bottomline#0 screen_bottomline zp ZP_WORD:34 4.0
(byte*) init_dist_screen::screen_bottomline#1 screen_bottomline zp ZP_WORD:34 7.333333333333333
(byte*) init_dist_screen::screen_bottomline#10 screen_bottomline zp ZP_WORD:34 6.848484848484849
(byte*) init_dist_screen::screen_topline
(byte*) init_dist_screen::screen_topline#1 screen_topline zp ZP_WORD:32 5.5
(byte*) init_dist_screen::screen_topline#10 screen_topline zp ZP_WORD:32 7.0625
(byte) init_dist_screen::x
(byte) init_dist_screen::x#1 x zp ZP_BYTE:36 101.0
(byte) init_dist_screen::x#2 x zp ZP_BYTE:36 26.578947368421055
(byte) init_dist_screen::x2
(byte) init_dist_screen::x2#0 reg byte a 202.0
(byte) init_dist_screen::xb
(byte) init_dist_screen::xb#1 xb zp ZP_BYTE:37 101.0
(byte) init_dist_screen::xb#2 xb zp ZP_BYTE:37 20.2
(byte) init_dist_screen::xd
(byte) init_dist_screen::xd#0 reg byte a 303.0
(word) init_dist_screen::xds
(word) init_dist_screen::xds#0 xds zp ZP_WORD:59 202.0
(byte) init_dist_screen::y
(byte) init_dist_screen::y#1 y zp ZP_BYTE:31 16.5
(byte) init_dist_screen::y#10 y zp ZP_BYTE:31 0.9705882352941178
(byte) init_dist_screen::y2
(byte) init_dist_screen::y2#0 reg byte a 22.0
(byte) init_dist_screen::yd
(byte) init_dist_screen::yd#0 reg byte a 33.0
(word) init_dist_screen::yds
(word) init_dist_screen::yds#0 yds zp ZP_WORD:57 4.869565217391305
(void()) init_squares()
(byte~) init_squares::$3 reg byte a 22.0
(byte~) init_squares::$4 reg byte a 22.0
(label) init_squares::@1
(label) init_squares::@2
(label) init_squares::@return
(byte) init_squares::i
(byte) init_squares::i#1 reg byte x 16.5
(byte) init_squares::i#2 reg byte x 5.5
(word) init_squares::sqr
(word) init_squares::sqr#1 sqr zp ZP_WORD:40 7.333333333333333
(word) init_squares::sqr#2 sqr zp ZP_WORD:40 6.6000000000000005
(word*) init_squares::squares
(word*) init_squares::squares#0 squares zp ZP_WORD:42 4.0
(word*) init_squares::squares#1 squares zp ZP_WORD:42 3.6666666666666665
(word*) init_squares::squares#2 squares zp ZP_WORD:42 17.5
(void()) main()
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@9
(label) main::@return
(byte*) main::angle
(byte*) main::angle#0 angle zp ZP_WORD:6 22.0
(byte*) main::angle#1 angle zp ZP_WORD:6 50.5
(byte*) main::angle#2 angle zp ZP_WORD:6 34.888888888888886
(byte*) main::dist
(byte*) main::dist#0 dist zp ZP_WORD:4 11.0
(byte*) main::dist#1 dist zp ZP_WORD:4 40.4
(byte*) main::dist#2 dist zp ZP_WORD:4 39.25
(word) main::dist_angle
(word) main::dist_angle#0 dist_angle zp ZP_WORD:12 101.0
(byte*) main::fill
(byte*) main::fill#1 fill zp ZP_WORD:2 101.0
(byte*) main::fill#2 fill zp ZP_WORD:2 40.4
(word) main::min_dist_angle
(word) main::min_dist_angle#2 min_dist_angle zp ZP_WORD:8 101.0
(word) main::min_dist_angle#3 min_dist_angle#3 zp ZP_WORD:12 83.0
(word~) main::min_dist_angle#6 min_dist_angle zp ZP_WORD:8 202.0
(word~) main::min_dist_angle#7 min_dist_angle#7 zp ZP_WORD:12 202.0
(word~) main::min_dist_angle#8 min_dist_angle#8 zp ZP_WORD:12 202.0
(byte*) main::min_fill
(byte*~) main::min_fill#10 min_fill zp ZP_WORD:10 202.0
(byte*) main::min_fill#2 min_fill zp ZP_WORD:10 59.285714285714285
(byte*) main::min_fill#5 min_fill zp ZP_WORD:10 50.5
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:65 0.3333333333333333
(void*) malloc::return
(word) malloc::size
(word) malloc::size#3 size zp ZP_WORD:46 1.0
(word()) sqr((byte) sqr::val)
(byte~) sqr::$0 reg byte a 4.0
(label) sqr::@return
(word) sqr::return
(word) sqr::return#0 return zp ZP_WORD:59 28.5
(word) sqr::return#2 return#2 zp ZP_WORD:57 22.0
(word) sqr::return#3 return zp ZP_WORD:59 202.0
(byte) sqr::val
(byte) sqr::val#0 reg byte a 22.0
(byte) sqr::val#1 reg byte a 202.0
(byte) sqr::val#2 reg byte a 114.0
(byte()) sqrt((word) sqrt::val)
(word~) sqrt::$1 $1 zp ZP_WORD:38 2.0
(word~) sqrt::$3 $3 zp ZP_WORD:38 4.0
(label) sqrt::@1
(label) sqrt::@return
(word*) sqrt::found
(word*) sqrt::found#0 found zp ZP_WORD:38 4.0
(byte) sqrt::return
(byte) sqrt::return#0 reg byte a 34.33333333333333
(byte) sqrt::return#2 reg byte a 202.0
(byte) sqrt::sq
(word) sqrt::val
(word) sqrt::val#0 val zp ZP_WORD:59 103.0
zp ZP_WORD:2 [ main::fill#2 main::fill#1 ]
zp ZP_WORD:4 [ main::dist#2 main::dist#0 main::dist#1 ]
zp ZP_WORD:6 [ main::angle#2 main::angle#0 main::angle#1 ]
zp ZP_WORD:8 [ main::min_dist_angle#2 main::min_dist_angle#6 ]
zp ZP_WORD:10 [ main::min_fill#5 main::min_fill#2 main::min_fill#10 ]
zp ZP_WORD:12 [ main::min_dist_angle#3 main::min_dist_angle#7 main::min_dist_angle#8 main::dist_angle#0 ]
zp ZP_BYTE:14 [ init_angle_screen::y#4 init_angle_screen::y#1 ]
zp ZP_WORD:15 [ init_angle_screen::screen_bottomline#5 init_angle_screen::screen_bottomline#0 init_angle_screen::screen_bottomline#1 init_angle_screen::screen#0 ]
zp ZP_WORD:17 [ init_angle_screen::screen_topline#5 init_angle_screen::screen_topline#0 init_angle_screen::screen_topline#1 ]
zp ZP_BYTE:19 [ init_angle_screen::x#2 init_angle_screen::x#1 ]
zp ZP_BYTE:20 [ init_angle_screen::xb#2 init_angle_screen::xb#1 ]
zp ZP_WORD:21 [ atan2_16::yi#3 atan2_16::yi#8 atan2_16::yi#0 atan2_16::yi#16 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ]
zp ZP_WORD:23 [ atan2_16::xi#3 atan2_16::xi#8 atan2_16::xi#0 atan2_16::xi#13 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ]
reg byte x [ atan2_16::i#2 atan2_16::i#1 ]
zp ZP_WORD:25 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 atan2_16::return#2 init_angle_screen::angle_w#0 init_angle_screen::$10 ]
reg byte y [ atan2_16::shift#2 atan2_16::shift#5 atan2_16::shift#1 ]
zp ZP_WORD:27 [ atan2_16::yd#5 atan2_16::yd#3 atan2_16::yd#10 atan2_16::yd#1 atan2_16::yd#2 ]
zp ZP_WORD:29 [ atan2_16::xd#5 atan2_16::xd#3 atan2_16::xd#10 atan2_16::xd#1 atan2_16::xd#2 ]
zp ZP_BYTE:31 [ init_dist_screen::y#10 init_dist_screen::y#1 ]
zp ZP_WORD:32 [ init_dist_screen::screen_topline#10 init_dist_screen::screen_topline#1 init_dist_screen::screen#0 ]
zp ZP_WORD:34 [ init_dist_screen::screen_bottomline#10 init_dist_screen::screen_bottomline#1 init_dist_screen::screen_bottomline#0 ]
reg byte a [ init_dist_screen::yd#0 init_dist_screen::$7 init_dist_screen::$5 ]
zp ZP_BYTE:36 [ init_dist_screen::x#2 init_dist_screen::x#1 ]
zp ZP_BYTE:37 [ init_dist_screen::xb#2 init_dist_screen::xb#1 ]
reg byte a [ init_dist_screen::xd#0 init_dist_screen::$15 init_dist_screen::$13 ]
zp ZP_WORD:38 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 bsearch16u::return#3 sqrt::found#0 sqrt::$3 sqrt::$1 ]
reg byte x [ bsearch16u::num#5 bsearch16u::num#1 bsearch16u::num#3 bsearch16u::num#0 ]
reg byte a [ sqr::val#2 sqr::val#0 sqr::val#1 ]
zp ZP_WORD:40 [ init_squares::sqr#2 init_squares::sqr#1 ]
zp ZP_WORD:42 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
reg byte x [ init_squares::i#2 init_squares::i#1 ]
zp ZP_WORD:44 [ heap_head#12 heap_head#1 ]
zp ZP_WORD:46 [ malloc::size#3 ]
zp ZP_WORD:48 [ SCREEN_DIST#0 ]
zp ZP_WORD:50 [ SCREEN_ANGLE#0 ]
reg byte a [ init_angle_screen::$2 ]
reg byte a [ init_angle_screen::$3 ]
zp ZP_WORD:52 [ init_angle_screen::xw#0 atan2_16::x#0 ]
reg byte a [ init_angle_screen::$6 ]
zp ZP_WORD:54 [ init_angle_screen::yw#0 atan2_16::y#0 ]
zp ZP_BYTE:56 [ init_angle_screen::ang_w#0 ]
reg byte a [ init_angle_screen::$12 ]
reg byte a [ init_angle_screen::$13 ]
reg byte a [ init_angle_screen::$14 ]
reg byte a [ atan2_16::$24 ]
reg byte a [ atan2_16::$23 ]
reg byte a [ init_dist_screen::y2#0 ]
zp ZP_WORD:57 [ sqr::return#2 init_dist_screen::yds#0 ]
reg byte a [ init_dist_screen::x2#0 ]
zp ZP_WORD:59 [ sqr::return#3 init_dist_screen::xds#0 sqr::return#0 init_dist_screen::ds#0 sqrt::val#0 bsearch16u::key#0 ]
reg byte a [ sqrt::return#2 ]
reg byte a [ init_dist_screen::d#0 ]
reg byte a [ sqrt::return#0 ]
reg byte a [ bsearch16u::$6 ]
reg byte a [ bsearch16u::$16 ]
zp ZP_WORD:61 [ bsearch16u::pivot#0 ]
zp ZP_WORD:63 [ bsearch16u::result#0 ]
reg byte a [ sqr::$0 ]
zp ZP_WORD:65 [ SQUARES#1 malloc::mem#0 ]
reg byte a [ init_squares::$3 ]
reg byte a [ init_squares::$4 ]