1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-08-03 01:29:04 +00:00

Added 8x8 char scroller

This commit is contained in:
jespergravgaard 2017-11-17 09:37:11 +01:00
parent f28db3067b
commit e64b12e7be
13 changed files with 12181 additions and 0 deletions

View File

@ -0,0 +1 @@
lsr {zpby1}

View File

@ -0,0 +1,3 @@
sta {zpwo1}
lda #0
sta {zpwo1}+1

View File

@ -0,0 +1,3 @@
stx {zpwo1}
ldx #0
stx {zpwo1}+1

View File

@ -0,0 +1,3 @@
sty {zpwo1}
ldy #0
sty {zpwo1}+1

View File

@ -0,0 +1,4 @@
lda {zpby1}
sta {zpwo1}
lda #0
sta {zpwo1}+1

View File

@ -0,0 +1,2 @@
asl {zpwo1}
rol {zpwo1}+1

View File

@ -0,0 +1,6 @@
lda {zpwo1}
asl
sta {zpwo2}
lda {zpwo1}+1
rol
sta {zpwo2}+1

View File

@ -24,6 +24,10 @@ public class TestPrograms extends TestCase {
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
}
public void testScrollBig() throws IOException, URISyntaxException {
compileAndCompare("scrollbig");
}
public void testPtrComplex() throws IOException, URISyntaxException {
compileAndCompare("ptr-complex");
}

View File

@ -0,0 +1,191 @@
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.const PROCPORT = 1
.const CHARGEN = $d000
.const SCREEN = $400
.const RASTER = $d012
.const BGCOL = $d020
.const SCROLL = $d016
.label current_bit = 2
.label nxt = 7
.label current_chargen = 3
TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @"
jsr main
main: {
jsr fillscreen
lda #<CHARGEN
sta current_chargen
lda #>CHARGEN
sta current_chargen+1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
lda #1
sta current_bit
ldx #7
b2:
lda RASTER
cmp #$fe
bne b2
b3:
lda RASTER
cmp #$ff
bne b3
inc BGCOL
jsr scroll_soft
dec BGCOL
jmp b2
rts
}
scroll_soft: {
dex
cpx #$ff
bne b1
jsr scroll_bit
ldx #7
b1:
stx SCROLL
rts
}
scroll_bit: {
.label _8 = 3
.label c = 9
.label sc = 5
jsr scroll_hard
lda current_bit
lsr
sta current_bit
bne b1
jsr next_char
sta c
lda #0
sta c+1
asl c
rol c+1
asl c
rol c+1
asl c
rol c+1
lda #<CHARGEN
clc
adc c
sta _8
lda #>CHARGEN
adc c+1
sta _8+1
lda #$80
sta current_bit
b1:
sei
lda #$32
sta PROCPORT
lda #<SCREEN+$28+$27
sta sc
lda #>SCREEN+$28+$27
sta sc+1
ldx #0
b2:
stx $ff
ldy $ff
lda (current_chargen),y
and current_bit
cmp #0
beq b3_from_b2
lda #'*'
jmp b3
b3_from_b2:
lda #' '
b3:
ldy #0
sta (sc),y
lda sc
clc
adc #$28
sta sc
bcc !+
inc sc+1
!:
inx
cpx #8
bne b2
lda #$37
sta PROCPORT
cli
rts
}
next_char: {
ldy #0
lda (nxt),y
cmp #'@'
bne b1
lda TEXT
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
b1:
inc nxt
bne !+
inc nxt+1
!:
rts
}
scroll_hard: {
.const line0 = SCREEN+$28*0
.const line1 = SCREEN+$28*1
.const line2 = SCREEN+$28*2
.const line3 = SCREEN+$28*3
.const line4 = SCREEN+$28*4
.const line5 = SCREEN+$28*5
.const line6 = SCREEN+$28*6
.const line7 = SCREEN+$28*7
ldx #0
b1:
lda line0+1,x
sta line0,x
lda line1+1,x
sta line1,x
lda line2+1,x
sta line2,x
lda line3+1,x
sta line3,x
lda line4+1,x
sta line4,x
lda line5+1,x
sta line5,x
lda line6+1,x
sta line6,x
lda line7+1,x
sta line7,x
inx
cpx #$27
bne b1
rts
}
fillscreen: {
.const fill = $20
.label cursor = 3
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
b1:
ldy #0
lda #fill
sta (cursor),y
inc cursor
bne !+
inc cursor+1
!:
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
rts
}

View File

@ -0,0 +1,152 @@
@begin: scope:[] from
to:@6
@6: scope:[] from @begin
[0] call main param-assignment [ ] ( )
to:@end
@end: scope:[] from @6
main: scope:[main] from @6
[1] phi() [ ] ( main:0 [ ] )
[2] call fillscreen param-assignment [ ] ( main:0 [ ] )
to:main::@2
main::@2: scope:[main] from main main::@2 main::@8
[3] (byte*) current_chargen#27 ← phi( main::@8/(byte*) current_chargen#0 main/(const byte*) CHARGEN#0 ) [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:0 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] )
[3] (byte*) nxt#31 ← phi( main::@8/(byte*) nxt#0 main/(const byte*) TEXT#0 ) [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:0 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] )
[3] (byte) current_bit#29 ← phi( main::@8/(byte) current_bit#0 main/(byte) 1 ) [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:0 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] )
[3] (byte) scroll#18 ← phi( main::@8/(byte) scroll#0 main/(byte) 7 ) [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:0 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] )
[4] if(*((const byte*) RASTER#0)!=(byte) 254) goto main::@2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:0 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] )
to:main::@3
main::@3: scope:[main] from main::@2 main::@3
[5] if(*((const byte*) RASTER#0)!=(byte) 255) goto main::@3 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:0 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] )
to:main::@5
main::@5: scope:[main] from main::@3
[6] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:0 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] )
[7] call scroll_soft param-assignment [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
to:main::@8
main::@8: scope:[main] from main::@5
[8] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
[9] if(true) goto main::@2 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
to:main::@return
main::@return: scope:[main] from main::@8
[10] return [ ] ( main:0 [ ] )
to:@return
scroll_soft: scope:[scroll_soft] from main::@5
[11] (byte) scroll#3 ← -- (byte) scroll#18 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ( main:0::scroll_soft:7 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] )
[12] if((byte) scroll#3!=(byte) 255) goto scroll_soft::@1 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ( main:0::scroll_soft:7 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] )
to:scroll_soft::@2
scroll_soft::@2: scope:[scroll_soft] from scroll_soft
[13] call scroll_bit param-assignment [ current_bit#21 nxt#37 current_chargen#18 ] ( main:0::scroll_soft:7 [ current_bit#21 nxt#37 current_chargen#18 ] )
to:scroll_soft::@1
scroll_soft::@1: scope:[scroll_soft] from scroll_soft scroll_soft::@2
[14] (byte*) current_chargen#0 ← phi( scroll_soft/(byte*) current_chargen#27 scroll_soft::@2/(byte*) current_chargen#18 ) [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0::scroll_soft:7 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
[14] (byte*) nxt#0 ← phi( scroll_soft/(byte*) nxt#31 scroll_soft::@2/(byte*) nxt#37 ) [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0::scroll_soft:7 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
[14] (byte) current_bit#0 ← phi( scroll_soft/(byte) current_bit#29 scroll_soft::@2/(byte) current_bit#21 ) [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0::scroll_soft:7 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
[14] (byte) scroll#0 ← phi( scroll_soft/(byte) scroll#3 scroll_soft::@2/(byte) 7 ) [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0::scroll_soft:7 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
[15] *((const byte*) SCROLL#0) ← (byte) scroll#0 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0::scroll_soft:7 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
to:scroll_soft::@return
scroll_soft::@return: scope:[scroll_soft] from scroll_soft::@1
[16] return [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] ( main:0::scroll_soft:7 [ scroll#0 current_bit#0 nxt#0 current_chargen#0 ] )
to:@return
scroll_bit: scope:[scroll_bit] from scroll_soft::@2
[17] phi() [ current_bit#29 nxt#31 current_chargen#27 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#29 nxt#31 current_chargen#27 ] )
[18] call scroll_hard param-assignment [ current_bit#29 nxt#31 current_chargen#27 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#29 nxt#31 current_chargen#27 ] )
to:scroll_bit::@7
scroll_bit::@7: scope:[scroll_bit] from scroll_bit
[19] (byte~) scroll_bit::$1 ← (byte) current_bit#29 >> (byte) 1 [ nxt#31 current_chargen#27 scroll_bit::$1 ] ( main:0::scroll_soft:7::scroll_bit:13 [ nxt#31 current_chargen#27 scroll_bit::$1 ] )
[20] (byte) current_bit#5 ← (byte~) scroll_bit::$1 [ nxt#31 current_chargen#27 current_bit#5 ] ( main:0::scroll_soft:7::scroll_bit:13 [ nxt#31 current_chargen#27 current_bit#5 ] )
[21] if((byte) current_bit#5!=(byte) 0) goto scroll_bit::@1 [ nxt#31 current_chargen#27 current_bit#5 ] ( main:0::scroll_soft:7::scroll_bit:13 [ nxt#31 current_chargen#27 current_bit#5 ] )
to:scroll_bit::@4
scroll_bit::@4: scope:[scroll_bit] from scroll_bit::@7
[22] call next_char param-assignment [ next_char::c#2 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13 [ next_char::c#2 nxt#15 ] )
to:scroll_bit::@8
scroll_bit::@8: scope:[scroll_bit] from scroll_bit::@4
[23] (word) scroll_bit::c#0 ← (byte) next_char::c#2 [ scroll_bit::c#0 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13 [ scroll_bit::c#0 nxt#15 ] )
[24] (word) scroll_bit::c#1 ← (word) scroll_bit::c#0 << (byte) 1 [ scroll_bit::c#1 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13 [ scroll_bit::c#1 nxt#15 ] )
[25] (word) scroll_bit::c#2 ← (word) scroll_bit::c#1 << (byte) 1 [ scroll_bit::c#2 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13 [ scroll_bit::c#2 nxt#15 ] )
[26] (word) scroll_bit::c#3 ← (word) scroll_bit::c#2 << (byte) 1 [ scroll_bit::c#3 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13 [ scroll_bit::c#3 nxt#15 ] )
[27] (byte*~) scroll_bit::$8 ← (const byte*) CHARGEN#0 + (word) scroll_bit::c#3 [ scroll_bit::$8 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13 [ scroll_bit::$8 nxt#15 ] )
[28] (byte*) current_chargen#5 ← (byte*~) scroll_bit::$8 [ current_chargen#5 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_chargen#5 nxt#15 ] )
to:scroll_bit::@1
scroll_bit::@1: scope:[scroll_bit] from scroll_bit::@7 scroll_bit::@8
[29] (byte*) nxt#37 ← phi( scroll_bit::@7/(byte*) nxt#31 scroll_bit::@8/(byte*) nxt#15 ) [ current_bit#21 nxt#37 current_chargen#18 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 ] )
[29] (byte) current_bit#21 ← phi( scroll_bit::@7/(byte) current_bit#5 scroll_bit::@8/(byte) 128 ) [ current_bit#21 nxt#37 current_chargen#18 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 ] )
[29] (byte*) current_chargen#18 ← phi( scroll_bit::@7/(byte*) current_chargen#27 scroll_bit::@8/(byte*) current_chargen#5 ) [ current_bit#21 nxt#37 current_chargen#18 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 ] )
asm { sei }
[31] *((const byte*) PROCPORT#0) ← (byte) 50 [ current_bit#21 nxt#37 current_chargen#18 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 ] )
to:scroll_bit::@2
scroll_bit::@2: scope:[scroll_bit] from scroll_bit::@1 scroll_bit::@3
[32] (byte*) scroll_bit::sc#2 ← phi( scroll_bit::@1/(const byte*) SCREEN#0+(byte) 40+(byte) 39 scroll_bit::@3/(byte*) scroll_bit::sc#1 ) [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] )
[32] (byte) scroll_bit::r#2 ← phi( scroll_bit::@1/(byte) 0 scroll_bit::@3/(byte) scroll_bit::r#1 ) [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] )
[33] (byte) scroll_bit::bits#0 ← (byte*) current_chargen#18 *idx (byte) scroll_bit::r#2 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::bits#0 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::bits#0 ] )
[34] (byte~) scroll_bit::$12 ← (byte) scroll_bit::bits#0 & (byte) current_bit#21 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::$12 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::$12 ] )
[35] if((byte~) scroll_bit::$12==(byte) 0) goto scroll_bit::@3 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] )
to:scroll_bit::@5
scroll_bit::@5: scope:[scroll_bit] from scroll_bit::@2
to:scroll_bit::@3
scroll_bit::@3: scope:[scroll_bit] from scroll_bit::@2 scroll_bit::@5
[36] (byte) scroll_bit::b#2 ← phi( scroll_bit::@2/(byte) ' ' scroll_bit::@5/(byte) '*' ) [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::b#2 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::b#2 ] )
[37] *((byte*) scroll_bit::sc#2) ← (byte) scroll_bit::b#2 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#2 ] )
[38] (byte*) scroll_bit::sc#1 ← (byte*) scroll_bit::sc#2 + (byte) 40 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#1 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#2 scroll_bit::sc#1 ] )
[39] (byte) scroll_bit::r#1 ← ++ (byte) scroll_bit::r#2 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#1 scroll_bit::sc#1 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#1 scroll_bit::sc#1 ] )
[40] if((byte) scroll_bit::r#1!=(byte) 8) goto scroll_bit::@2 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#1 scroll_bit::sc#1 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 scroll_bit::r#1 scroll_bit::sc#1 ] )
to:scroll_bit::@6
scroll_bit::@6: scope:[scroll_bit] from scroll_bit::@3
[41] *((const byte*) PROCPORT#0) ← (byte) 55 [ current_bit#21 nxt#37 current_chargen#18 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 ] )
asm { cli }
to:scroll_bit::@return
scroll_bit::@return: scope:[scroll_bit] from scroll_bit::@6
[43] return [ current_bit#21 nxt#37 current_chargen#18 ] ( main:0::scroll_soft:7::scroll_bit:13 [ current_bit#21 nxt#37 current_chargen#18 ] )
to:@return
next_char: scope:[next_char] from scroll_bit::@4
[44] (byte) next_char::c#0 ← *((byte*) nxt#31) [ nxt#31 next_char::c#0 ] ( main:0::scroll_soft:7::scroll_bit:13::next_char:22 [ nxt#31 next_char::c#0 ] )
[45] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1 [ nxt#31 next_char::c#0 ] ( main:0::scroll_soft:7::scroll_bit:13::next_char:22 [ nxt#31 next_char::c#0 ] )
to:next_char::@2
next_char::@2: scope:[next_char] from next_char
[46] (byte) next_char::c#1 ← *((const byte*) TEXT#0) [ next_char::c#1 ] ( main:0::scroll_soft:7::scroll_bit:13::next_char:22 [ next_char::c#1 ] )
to:next_char::@1
next_char::@1: scope:[next_char] from next_char next_char::@2
[47] (byte) next_char::c#2 ← phi( next_char/(byte) next_char::c#0 next_char::@2/(byte) next_char::c#1 ) [ next_char::c#2 nxt#18 ] ( main:0::scroll_soft:7::scroll_bit:13::next_char:22 [ next_char::c#2 nxt#18 ] )
[47] (byte*) nxt#18 ← phi( next_char/(byte*) nxt#31 next_char::@2/(const byte*) TEXT#0 ) [ next_char::c#2 nxt#18 ] ( main:0::scroll_soft:7::scroll_bit:13::next_char:22 [ next_char::c#2 nxt#18 ] )
[48] (byte*) nxt#15 ← ++ (byte*) nxt#18 [ next_char::c#2 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13::next_char:22 [ next_char::c#2 nxt#15 ] )
to:next_char::@return
next_char::@return: scope:[next_char] from next_char::@1
[49] return [ next_char::c#2 nxt#15 ] ( main:0::scroll_soft:7::scroll_bit:13::next_char:22 [ next_char::c#2 nxt#15 ] )
to:@return
scroll_hard: scope:[scroll_hard] from scroll_bit
[50] phi() [ ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 ] )
to:scroll_hard::@1
scroll_hard::@1: scope:[scroll_hard] from scroll_hard scroll_hard::@1
[51] (byte) scroll_hard::i#2 ← phi( scroll_hard/(byte) 0 scroll_hard::@1/(byte) scroll_hard::i#1 ) [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[52] (byte~) scroll_hard::$17 ← (const byte[]) scroll_hard::line0#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$17 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$17 ] )
[53] *((const byte[]) scroll_hard::line0#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$17 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[54] (byte~) scroll_hard::$19 ← (const byte[]) scroll_hard::line1#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$19 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$19 ] )
[55] *((const byte[]) scroll_hard::line1#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$19 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[56] (byte~) scroll_hard::$21 ← (const byte[]) scroll_hard::line2#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$21 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$21 ] )
[57] *((const byte[]) scroll_hard::line2#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$21 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[58] (byte~) scroll_hard::$23 ← (const byte[]) scroll_hard::line3#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$23 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$23 ] )
[59] *((const byte[]) scroll_hard::line3#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$23 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[60] (byte~) scroll_hard::$25 ← (const byte[]) scroll_hard::line4#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$25 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$25 ] )
[61] *((const byte[]) scroll_hard::line4#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$25 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[62] (byte~) scroll_hard::$27 ← (const byte[]) scroll_hard::line5#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$27 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$27 ] )
[63] *((const byte[]) scroll_hard::line5#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$27 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[64] (byte~) scroll_hard::$29 ← (const byte[]) scroll_hard::line6#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$29 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$29 ] )
[65] *((const byte[]) scroll_hard::line6#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$29 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[66] (byte~) scroll_hard::$31 ← (const byte[]) scroll_hard::line7#0+(byte) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$31 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 scroll_hard::$31 ] )
[67] *((const byte[]) scroll_hard::line7#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$31 [ scroll_hard::i#2 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#2 ] )
[68] (byte) scroll_hard::i#1 ← ++ (byte) scroll_hard::i#2 [ scroll_hard::i#1 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#1 ] )
[69] if((byte) scroll_hard::i#1!=(byte) 39) goto scroll_hard::@1 [ scroll_hard::i#1 ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 scroll_hard::i#1 ] )
to:scroll_hard::@return
scroll_hard::@return: scope:[scroll_hard] from scroll_hard::@1
[70] return [ ] ( main:0::scroll_soft:7::scroll_bit:13::scroll_hard:18 [ current_bit#29 nxt#31 current_chargen#27 ] )
to:@return
fillscreen: scope:[fillscreen] from main
[71] phi() [ ] ( main:0::fillscreen:2 [ ] )
to:fillscreen::@1
fillscreen::@1: scope:[fillscreen] from fillscreen fillscreen::@1
[72] (byte*) fillscreen::cursor#2 ← phi( fillscreen/(const byte*) SCREEN#0 fillscreen::@1/(byte*) fillscreen::cursor#1 ) [ fillscreen::cursor#2 ] ( main:0::fillscreen:2 [ fillscreen::cursor#2 ] )
[73] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:0::fillscreen:2 [ fillscreen::cursor#2 ] )
[74] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:0::fillscreen:2 [ fillscreen::cursor#1 ] )
[75] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word) 1000) goto fillscreen::@1 [ fillscreen::cursor#1 ] ( main:0::fillscreen:2 [ fillscreen::cursor#1 ] )
to:fillscreen::@return
fillscreen::@return: scope:[fillscreen] from fillscreen::@1
[76] return [ ] ( main:0::fillscreen:2 [ ] )
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,145 @@
(label) @6
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = (word) 53280
(byte*) CHARGEN
(const byte*) CHARGEN#0 CHARGEN = (word) 53248
(byte*) PROCPORT
(const byte*) PROCPORT#0 PROCPORT = (byte) 1
(byte*) RASTER
(const byte*) RASTER#0 RASTER = (word) 53266
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (word) 1024
(byte*) SCROLL
(const byte*) SCROLL#0 SCROLL = (word) 53270
(byte*) TEXT
(const byte*) TEXT#0 TEXT = (string) "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @"
(byte) current_bit
(byte) current_bit#0 current_bit zp ZP_BYTE:2 2.5
(byte) current_bit#21 current_bit zp ZP_BYTE:2 0.9375
(byte) current_bit#29 current_bit zp ZP_BYTE:2 1.875
(byte) current_bit#5 current_bit zp ZP_BYTE:2 3.0
(byte*) current_chargen
(byte*) current_chargen#0 current_chargen zp ZP_PTR_BYTE:3 2.5
(byte*) current_chargen#18 current_chargen zp ZP_PTR_BYTE:3 1.0625
(byte*) current_chargen#27 current_chargen zp ZP_PTR_BYTE:3 1.3636363636363638
(byte*) current_chargen#5 current_chargen zp ZP_PTR_BYTE:3 4.0
(void()) fillscreen((byte*) fillscreen::screen , (byte) fillscreen::fill)
(label) fillscreen::@1
(label) fillscreen::@return
(byte*) fillscreen::cursor
(byte*) fillscreen::cursor#1 cursor zp ZP_PTR_BYTE:3 16.5
(byte*) fillscreen::cursor#2 cursor zp ZP_PTR_BYTE:3 16.5
(byte) fillscreen::fill
(const byte) fillscreen::fill#0 fill = (byte) 32
(byte*) fillscreen::screen
(void()) main()
(label) main::@2
(label) main::@3
(label) main::@5
(label) main::@8
(label) main::@return
(byte()) next_char()
(label) next_char::@1
(label) next_char::@2
(label) next_char::@return
(byte) next_char::c
(byte) next_char::c#0 reg byte a 3.0
(byte) next_char::c#1 reg byte a 4.0
(byte) next_char::c#2 reg byte a 1.5
(byte) next_char::return
(byte*) nxt
(byte*) nxt#0 nxt zp ZP_PTR_BYTE:7 2.5
(byte*) nxt#15 nxt zp ZP_PTR_BYTE:7 0.4444444444444444
(byte*) nxt#18 nxt zp ZP_PTR_BYTE:7 4.0
(byte*) nxt#31 nxt zp ZP_PTR_BYTE:7 1.3076923076923075
(byte*) nxt#37 nxt zp ZP_PTR_BYTE:7 0.375
(byte) scroll
(byte) scroll#0 reg byte x 2.5
(byte) scroll#18 reg byte x 3.25
(byte) scroll#3 reg byte x 3.0
(void()) scroll_bit()
(byte~) scroll_bit::$1 reg byte a 4.0
(byte~) scroll_bit::$12 reg byte a 22.0
(byte*~) scroll_bit::$8 $8 zp ZP_PTR_BYTE:3 4.0
(label) scroll_bit::@1
(label) scroll_bit::@2
(label) scroll_bit::@3
(label) scroll_bit::@4
(label) scroll_bit::@5
(label) scroll_bit::@6
(label) scroll_bit::@7
(label) scroll_bit::@8
(label) scroll_bit::@return
(byte) scroll_bit::b
(byte) scroll_bit::b#2 reg byte a 11.0
(byte) scroll_bit::bits
(byte) scroll_bit::bits#0 reg byte a 22.0
(word) scroll_bit::c
(word) scroll_bit::c#0 c zp ZP_WORD:9 4.0
(word) scroll_bit::c#1 c zp ZP_WORD:9 4.0
(word) scroll_bit::c#2 c zp ZP_WORD:9 4.0
(word) scroll_bit::c#3 c zp ZP_WORD:9 4.0
(byte) scroll_bit::r
(byte) scroll_bit::r#1 reg byte x 16.5
(byte) scroll_bit::r#2 reg byte x 4.714285714285714
(byte*) scroll_bit::sc
(byte*) scroll_bit::sc#1 sc zp ZP_PTR_BYTE:5 7.333333333333333
(byte*) scroll_bit::sc#2 sc zp ZP_PTR_BYTE:5 5.5
(void()) scroll_hard()
(byte~) scroll_hard::$17 reg byte a 22.0
(byte~) scroll_hard::$19 reg byte a 22.0
(byte~) scroll_hard::$21 reg byte a 22.0
(byte~) scroll_hard::$23 reg byte a 22.0
(byte~) scroll_hard::$25 reg byte a 22.0
(byte~) scroll_hard::$27 reg byte a 22.0
(byte~) scroll_hard::$29 reg byte a 22.0
(byte~) scroll_hard::$31 reg byte a 22.0
(label) scroll_hard::@1
(label) scroll_hard::@return
(byte) scroll_hard::i
(byte) scroll_hard::i#1 reg byte x 16.5
(byte) scroll_hard::i#2 reg byte x 11.647058823529411
(byte[]) scroll_hard::line0
(const byte[]) scroll_hard::line0#0 line0 = (const byte*) SCREEN#0+(byte) 40*(byte) 0
(byte[]) scroll_hard::line1
(const byte[]) scroll_hard::line1#0 line1 = (const byte*) SCREEN#0+(byte) 40*(byte) 1
(byte[]) scroll_hard::line2
(const byte[]) scroll_hard::line2#0 line2 = (const byte*) SCREEN#0+(byte) 40*(byte) 2
(byte[]) scroll_hard::line3
(const byte[]) scroll_hard::line3#0 line3 = (const byte*) SCREEN#0+(byte) 40*(byte) 3
(byte[]) scroll_hard::line4
(const byte[]) scroll_hard::line4#0 line4 = (const byte*) SCREEN#0+(byte) 40*(byte) 4
(byte[]) scroll_hard::line5
(const byte[]) scroll_hard::line5#0 line5 = (const byte*) SCREEN#0+(byte) 40*(byte) 5
(byte[]) scroll_hard::line6
(const byte[]) scroll_hard::line6#0 line6 = (const byte*) SCREEN#0+(byte) 40*(byte) 6
(byte[]) scroll_hard::line7
(const byte[]) scroll_hard::line7#0 line7 = (const byte*) SCREEN#0+(byte) 40*(byte) 7
(void()) scroll_soft()
(label) scroll_soft::@1
(label) scroll_soft::@2
(label) scroll_soft::@return
reg byte x [ scroll#18 scroll#0 scroll#3 ]
zp ZP_BYTE:2 [ current_bit#29 current_bit#0 current_bit#21 current_bit#5 ]
zp ZP_PTR_BYTE:3 [ current_chargen#27 current_chargen#0 current_chargen#18 current_chargen#5 fillscreen::cursor#2 fillscreen::cursor#1 scroll_bit::$8 ]
reg byte x [ scroll_bit::r#2 scroll_bit::r#1 ]
zp ZP_PTR_BYTE:5 [ scroll_bit::sc#2 scroll_bit::sc#1 ]
reg byte a [ scroll_bit::b#2 ]
zp ZP_PTR_BYTE:7 [ nxt#18 nxt#31 nxt#0 nxt#37 nxt#15 ]
reg byte a [ next_char::c#2 next_char::c#0 next_char::c#1 ]
reg byte x [ scroll_hard::i#2 scroll_hard::i#1 ]
reg byte a [ scroll_bit::$1 ]
zp ZP_WORD:9 [ scroll_bit::c#0 scroll_bit::c#1 scroll_bit::c#2 scroll_bit::c#3 ]
reg byte a [ scroll_bit::bits#0 ]
reg byte a [ scroll_bit::$12 ]
reg byte a [ scroll_hard::$17 ]
reg byte a [ scroll_hard::$19 ]
reg byte a [ scroll_hard::$21 ]
reg byte a [ scroll_hard::$23 ]
reg byte a [ scroll_hard::$25 ]
reg byte a [ scroll_hard::$27 ]
reg byte a [ scroll_hard::$29 ]
reg byte a [ scroll_hard::$31 ]

View File

@ -0,0 +1,102 @@
// An 8x8 char letter scroller
byte* PROCPORT = $01;
byte* CHARGEN = $d000;
byte* SCREEN = $0400;
byte* RASTER = $d012;
byte* BGCOL = $d020;
byte* SCROLL = $d016;
byte* TEXT = "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @";
void main() {
fillscreen(SCREEN, $20);
do {
// Wait for raster
do {} while(*RASTER!=$fe);
do {} while(*RASTER!=$ff);
++*BGCOL;
scroll_soft();
--*BGCOL;
} while(true);
}
// Soft-scroll using $d016 - trigger bit-scroll/char-scroll when needed
byte scroll = 7;
void scroll_soft() {
if(--scroll==$ff) {
scroll = 7;
scroll_bit();
}
*SCROLL = scroll;
}
// Scroll the next bit from the current char onto the screen
byte* current_chargen = CHARGEN;
byte current_bit = 1;
void scroll_bit() {
scroll_hard();
current_bit = current_bit>>1;
if(current_bit==0) {
word c = next_char();
c = c<<1;
c = c<<1;
c = c<<1;
current_chargen = CHARGEN+c;
current_bit = $80;
}
asm { sei }
*PROCPORT = $32;
byte* sc = SCREEN+40+39;
for(byte r:0..7) {
byte bits = current_chargen[r];
byte b = ' ';
if((bits & current_bit) != 0) {
b = '*';
}
*sc = b;
sc = sc+40;
}
*PROCPORT = $37;
asm { cli }
}
byte* nxt = TEXT;
// Find the next char of the scroll text
byte next_char() {
byte c = *nxt;
if(c=='@') {
nxt = TEXT;
c = *nxt;
}
nxt++;
return c;
}
void scroll_hard() {
// Hard scroll
byte[] line0 = SCREEN+40*0;
byte[] line1 = SCREEN+40*1;
byte[] line2 = SCREEN+40*2;
byte[] line3 = SCREEN+40*3;
byte[] line4 = SCREEN+40*4;
byte[] line5 = SCREEN+40*5;
byte[] line6 = SCREEN+40*6;
byte[] line7 = SCREEN+40*7;
for(byte i=0;i!=39;i++) {
line0[i]=line0[i+1];
line1[i]=line1[i+1];
line2[i]=line2[i+1];
line3[i]=line3[i+1];
line4[i]=line4[i+1];
line5[i]=line5[i+1];
line6[i]=line6[i+1];
line7[i]=line7[i+1];
}
}
// Fill the screen with one char
void fillscreen(byte* screen, byte fill) {
for( byte* cursor = screen; cursor < screen+1000; cursor++) {
*cursor = fill;
}
}