1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-24 04:31:02 +00:00

Moved bresenham into main()

This commit is contained in:
jespergravgaard 2017-08-20 21:12:40 +02:00
parent 2707bd5861
commit ffce3298ef
5 changed files with 2032 additions and 1705 deletions

View File

@ -1,16 +1,22 @@
byte STAR = 81;
byte[40*25] SCREEN = $0400;
byte x0 = 0;
byte y0 = 0;
byte x1 = 39;
byte y1 = 24;
byte xd = x1-x0;
byte yd = y1-y0;
byte x = x0;
byte y = y0;
byte e = yd/2;
byte *cursor = SCREEN+y*40+x;
do {
main();
void main() {
byte x0 = 0;
byte y0 = 0;
byte x1 = 39;
byte y1 = 24;
byte xd = x1-x0;
byte yd = y1-y0;
byte x = x0;
byte y = y0;
byte e = yd/2;
byte *cursor = SCREEN+y*40+x;
do {
*cursor = STAR;
x = x + 1;
cursor = cursor + 1;
@ -20,4 +26,5 @@ do {
cursor = cursor + 40;
e = e - xd;
}
} while (x<(x1+1))
} while (x<(x1+1))
}

View File

@ -1,3 +1,5 @@
jsr main
main: {
lda #$0
sta $5
ldx #$c
@ -7,7 +9,7 @@
sta $2
lda #>$400
sta $2+$1
b1:
b1:
ldy #$0
lda #$51
sta ($2),y
@ -15,7 +17,7 @@ b1:
inc $2
bne !+
inc $2+$1
!:
!:
txa
clc
adc #$18
@ -29,12 +31,14 @@ b1:
sta $2
bcc !+
inc $2+$1
!:
!:
txa
sec
sbc #$27
tax
b2:
b2:
lda $4
cmp #$28
bcc b1
rts
}

View File

@ -1,25 +1,31 @@
@begin: scope:[] from
to:@1
@1: scope:[] from @2 @begin
[0] (byte) y#2 ← phi( @2/(byte) y#4 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ]
[0] (byte) e#3 ← phi( @2/(byte) e#5 @begin/(byte) 12 ) [ cursor#3 x#2 e#3 y#2 ]
[0] (byte) x#2 ← phi( @2/(byte) x#1 @begin/(byte) 0 ) [ cursor#3 x#2 e#3 y#2 ]
[0] (byte*) cursor#3 ← phi( @2/(byte*) cursor#5 @begin/(word) 1024 ) [ cursor#3 x#2 e#3 y#2 ]
[1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ]
[2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ]
[3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 y#2 cursor#1 ]
[4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 y#2 cursor#1 ]
[5] if((byte) 39>=(byte) e#1) goto @2 [ x#1 e#1 y#2 cursor#1 ]
to:@3
@3: scope:[] from @1
[6] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ]
[7] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ]
[8] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ]
to:@2
@2: scope:[] from @1 @3
[9] (byte) y#4 ← phi( @1/(byte) y#2 @3/(byte) y#1 ) [ cursor#5 x#1 e#5 y#4 ]
[9] (byte) e#5 ← phi( @1/(byte) e#1 @3/(byte) e#2 ) [ cursor#5 x#1 e#5 y#4 ]
[9] (byte*) cursor#5 ← phi( @1/(byte*) cursor#1 @3/(byte*) cursor#2 ) [ cursor#5 x#1 e#5 y#4 ]
[10] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ]
[0] call main param-assignment [ ]
to:@end
@end: scope:[] from @2
@end: scope:[] from @begin
main: scope:[main] from @begin
to:main::@1
main::@1: scope:[main] from main main::@2
[1] (byte) main::y#2 ← phi( main/(byte) 0 main::@2/(byte) main::y#4 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[1] (byte) main::e#3 ← phi( main/(byte) 12 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[1] (byte) main::x#2 ← phi( main/(byte) 0 main::@2/(byte) main::x#1 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[1] (byte*) main::cursor#3 ← phi( main/(word) 1024 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[2] *((byte*) main::cursor#3) ← (byte) 81 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ]
[3] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 [ main::x#1 main::cursor#3 main::e#3 main::y#2 ]
[4] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 [ main::x#1 main::e#3 main::y#2 main::cursor#1 ]
[5] (byte) main::e#1 ← (byte) main::e#3 + (byte) 24 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ]
[6] if((byte) 39>=(byte) main::e#1) goto main::@2 [ main::x#1 main::e#1 main::y#2 main::cursor#1 ]
to:main::@3
main::@3: scope:[main] from main::@1
[7] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 [ main::x#1 main::e#1 main::cursor#1 main::y#1 ]
[8] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) 40 [ main::x#1 main::e#1 main::cursor#2 main::y#1 ]
[9] (byte) main::e#2 ← (byte) main::e#1 - (byte) 39 [ main::x#1 main::cursor#2 main::e#2 main::y#1 ]
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[10] (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
[10] (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
[10] (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
[11] if((byte) main::x#1<(byte) 40) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ]
to:main::@return
main::@return: scope:[main] from main::@2
[12] return [ ]
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,37 @@
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte[1000]) SCREEN
(byte) STAR
(byte*) cursor
(byte*) cursor#1 zp ptr byte:2 8.25
(byte*) cursor#2 zp ptr byte:2 11.0
(byte*) cursor#3 zp ptr byte:2 11.0
(byte*) cursor#5 zp ptr byte:2 16.5
(byte) e
(byte) e#1 reg byte x 11.0
(byte) e#2 reg byte x 22.0
(byte) e#3 reg byte x 5.5
(byte) e#5 reg byte x 16.5
(byte) x
(byte) x#1 zp byte:4 3.666666666666667
(byte) x#2 zp byte:4 11.0
(byte) x0
(byte) x1
(byte) xd
(byte) y
(byte) y#1 zp byte:5 7.333333333333333
(byte) y#2 zp byte:5 5.5
(byte) y#4 zp byte:5 16.5
(byte) y0
(byte) y1
(byte) yd
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::cursor
(byte*) main::cursor#1 zp ptr byte:2 8.25
(byte*) main::cursor#2 zp ptr byte:2 11.0
(byte*) main::cursor#3 zp ptr byte:2 11.0
(byte*) main::cursor#5 zp ptr byte:2 16.5
(byte) main::e
(byte) main::e#1 reg byte x 11.0
(byte) main::e#2 reg byte x 22.0
(byte) main::e#3 reg byte x 5.5
(byte) main::e#5 reg byte x 16.5
(byte) main::x
(byte) main::x#1 zp byte:4 3.666666666666667
(byte) main::x#2 zp byte:4 11.0
(byte) main::x0
(byte) main::x1
(byte) main::xd
(byte) main::y
(byte) main::y#1 zp byte:5 7.333333333333333
(byte) main::y#2 zp byte:5 5.5
(byte) main::y#4 zp byte:5 16.5
(byte) main::y0
(byte) main::y1
(byte) main::yd
zp ptr byte:2 [ cursor#3 cursor#5 cursor#1 cursor#2 ]
zp byte:4 [ x#2 x#1 ]
reg byte x [ e#3 e#5 e#1 e#2 ]
zp byte:5 [ y#2 y#4 y#1 ]
zp ptr byte:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
zp byte:4 [ main::x#2 main::x#1 ]
reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ]
zp byte:5 [ main::y#2 main::y#4 main::y#1 ]