mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-23 23:32:55 +00:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/test/java/dk/camelot64/kickc/test/TestPrograms.java
This commit is contained in:
commit
bb9a4ac461
@ -0,0 +1,16 @@
|
||||
lda #<{c1}
|
||||
clc
|
||||
adc {z1}
|
||||
sta !a1+ +1
|
||||
lda #>{c1}
|
||||
adc {z1}+1
|
||||
sta !a1+ +2
|
||||
lda #<{c2}
|
||||
clc
|
||||
adc {z1}
|
||||
sta !a2+ +1
|
||||
lda #>{c2}
|
||||
adc {z1}+1
|
||||
sta !a2+ +2
|
||||
!a2: lda {c2}
|
||||
!a1: sta {c1}
|
@ -44,6 +44,11 @@ public class TestPrograms {
|
||||
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScrollUp() throws IOException, URISyntaxException {
|
||||
compileAndCompare("test-scroll-up");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRollSpriteMsb() throws IOException, URISyntaxException {
|
||||
compileAndCompare("roll-sprite-msb");
|
||||
|
31
src/test/kc/test-scroll-up.kc
Normal file
31
src/test/kc/test-scroll-up.kc
Normal file
@ -0,0 +1,31 @@
|
||||
// Tests different ways of scrolling up the screen
|
||||
|
||||
const byte* screen = $400;
|
||||
|
||||
void main() {
|
||||
scrollup1();
|
||||
scrollup2();
|
||||
scrollup3();
|
||||
}
|
||||
|
||||
void scrollup1() {
|
||||
for (word line = 0; line < 40*24; line += 40)
|
||||
for (byte c=0; c<40; ++c)
|
||||
screen[line+c] = screen[line+c+40];
|
||||
}
|
||||
|
||||
void scrollup2() {
|
||||
byte* line1 = screen;
|
||||
byte* line2 = screen+40;
|
||||
for( byte l: 0..23 )
|
||||
for (byte c: 0..39)
|
||||
*line1++ = *line2++;
|
||||
}
|
||||
|
||||
void scrollup3() {
|
||||
for (word line = 0; line < 40*24; line += 40) {
|
||||
word l2 = line;
|
||||
for (byte c=0; c<40; ++c)
|
||||
screen[l2++] = screen[l2+40];
|
||||
}
|
||||
}
|
165
src/test/ref/test-scroll-up.asm
Normal file
165
src/test/ref/test-scroll-up.asm
Normal file
@ -0,0 +1,165 @@
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label screen = $400
|
||||
main: {
|
||||
jsr scrollup1
|
||||
jsr scrollup2
|
||||
jsr scrollup3
|
||||
rts
|
||||
}
|
||||
scrollup3: {
|
||||
.label l2 = 2
|
||||
.label l2_1 = 4
|
||||
.label line = 2
|
||||
.label l2_2 = 4
|
||||
.label l2_4 = 4
|
||||
lda #<0
|
||||
sta l2
|
||||
sta l2+1
|
||||
b1:
|
||||
lda l2
|
||||
sta l2_4
|
||||
lda l2+1
|
||||
sta l2_4+1
|
||||
ldx #0
|
||||
b2:
|
||||
lda #<screen
|
||||
clc
|
||||
adc l2_2
|
||||
sta !a1++1
|
||||
lda #>screen
|
||||
adc l2_2+1
|
||||
sta !a1++2
|
||||
lda #<screen+$28
|
||||
clc
|
||||
adc l2_2
|
||||
sta !a2++1
|
||||
lda #>screen+$28
|
||||
adc l2_2+1
|
||||
sta !a2++2
|
||||
!a2:
|
||||
lda screen+$28
|
||||
!a1:
|
||||
sta screen
|
||||
inc l2_1
|
||||
bne !+
|
||||
inc l2_1+1
|
||||
!:
|
||||
inx
|
||||
cpx #$28
|
||||
bcc b2
|
||||
clc
|
||||
lda line
|
||||
adc #<$28
|
||||
sta line
|
||||
lda line+1
|
||||
adc #>$28
|
||||
sta line+1
|
||||
cmp #>$28*$18
|
||||
bcc b1
|
||||
bne !+
|
||||
lda line
|
||||
cmp #<$28*$18
|
||||
bcc b1
|
||||
!:
|
||||
rts
|
||||
}
|
||||
scrollup2: {
|
||||
.label line1 = 4
|
||||
.label line2 = 2
|
||||
.label l = 6
|
||||
lda #0
|
||||
sta l
|
||||
lda #<screen
|
||||
sta line1
|
||||
lda #>screen
|
||||
sta line1+1
|
||||
lda #<screen+$28
|
||||
sta line2
|
||||
lda #>screen+$28
|
||||
sta line2+1
|
||||
b1:
|
||||
ldx #0
|
||||
b2:
|
||||
ldy #0
|
||||
lda (line2),y
|
||||
sta (line1),y
|
||||
inc line1
|
||||
bne !+
|
||||
inc line1+1
|
||||
!:
|
||||
inc line2
|
||||
bne !+
|
||||
inc line2+1
|
||||
!:
|
||||
inx
|
||||
cpx #$28
|
||||
bne b2
|
||||
inc l
|
||||
lda l
|
||||
cmp #$18
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
scrollup1: {
|
||||
.label _0 = 4
|
||||
.label _2 = 7
|
||||
.label line = 2
|
||||
lda #<0
|
||||
sta line
|
||||
sta line+1
|
||||
b1:
|
||||
ldx #0
|
||||
b2:
|
||||
txa
|
||||
clc
|
||||
adc line
|
||||
sta _0
|
||||
lda #0
|
||||
adc line+1
|
||||
sta _0+1
|
||||
txa
|
||||
clc
|
||||
adc line
|
||||
sta _2
|
||||
lda #0
|
||||
adc line+1
|
||||
sta _2+1
|
||||
lda #<screen
|
||||
clc
|
||||
adc _0
|
||||
sta !a1++1
|
||||
lda #>screen
|
||||
adc _0+1
|
||||
sta !a1++2
|
||||
lda #<screen+$28
|
||||
clc
|
||||
adc _2
|
||||
sta !a2++1
|
||||
lda #>screen+$28
|
||||
adc _2+1
|
||||
sta !a2++2
|
||||
!a2:
|
||||
lda screen+$28
|
||||
!a1:
|
||||
sta screen
|
||||
inx
|
||||
cpx #$28
|
||||
bcc b2
|
||||
clc
|
||||
lda line
|
||||
adc #<$28
|
||||
sta line
|
||||
lda line+1
|
||||
adc #>$28
|
||||
sta line+1
|
||||
cmp #>$28*$18
|
||||
bcc b1
|
||||
bne !+
|
||||
lda line
|
||||
cmp #<$28*$18
|
||||
bcc b1
|
||||
!:
|
||||
rts
|
||||
}
|
92
src/test/ref/test-scroll-up.cfg
Normal file
92
src/test/ref/test-scroll-up.cfg
Normal file
@ -0,0 +1,92 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@4
|
||||
@4: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @4
|
||||
[3] phi()
|
||||
main: scope:[main] from @4
|
||||
[4] phi()
|
||||
[5] call scrollup1
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[6] phi()
|
||||
[7] call scrollup2
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1
|
||||
[8] phi()
|
||||
[9] call scrollup3
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@2
|
||||
[10] return
|
||||
to:@return
|
||||
scrollup3: scope:[scrollup3] from main::@2
|
||||
[11] phi()
|
||||
to:scrollup3::@1
|
||||
scrollup3::@1: scope:[scrollup3] from scrollup3 scrollup3::@3
|
||||
[12] (word) scrollup3::l2#0 ← phi( scrollup3/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup3::@3/(word) scrollup3::line#1 )
|
||||
[13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0
|
||||
to:scrollup3::@2
|
||||
scrollup3::@2: scope:[scrollup3] from scrollup3::@1 scrollup3::@2
|
||||
[14] (byte) scrollup3::c#2 ← phi( scrollup3::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup3::@2/(byte) scrollup3::c#1 )
|
||||
[14] (word) scrollup3::l2#2 ← phi( scrollup3::@1/(word~) scrollup3::l2#4 scrollup3::@2/(word) scrollup3::l2#1 )
|
||||
[15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2)
|
||||
[16] (word) scrollup3::l2#1 ← ++ (word) scrollup3::l2#2
|
||||
[17] (byte) scrollup3::c#1 ← ++ (byte) scrollup3::c#2
|
||||
[18] if((byte) scrollup3::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup3::@2
|
||||
to:scrollup3::@3
|
||||
scrollup3::@3: scope:[scrollup3] from scrollup3::@2
|
||||
[19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40
|
||||
[20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1
|
||||
to:scrollup3::@return
|
||||
scrollup3::@return: scope:[scrollup3] from scrollup3::@3
|
||||
[21] return
|
||||
to:@return
|
||||
scrollup2: scope:[scrollup2] from main::@1
|
||||
[22] phi()
|
||||
to:scrollup2::@1
|
||||
scrollup2::@1: scope:[scrollup2] from scrollup2 scrollup2::@3
|
||||
[23] (byte) scrollup2::l#4 ← phi( scrollup2/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup2::@3/(byte) scrollup2::l#1 )
|
||||
[23] (byte*) scrollup2::line1#3 ← phi( scrollup2/(const byte*) screen#0 scrollup2::@3/(byte*) scrollup2::line1#1 )
|
||||
[23] (byte*) scrollup2::line2#3 ← phi( scrollup2/(const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 scrollup2::@3/(byte*) scrollup2::line2#1 )
|
||||
to:scrollup2::@2
|
||||
scrollup2::@2: scope:[scrollup2] from scrollup2::@1 scrollup2::@2
|
||||
[24] (byte) scrollup2::c#2 ← phi( scrollup2::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup2::@2/(byte) scrollup2::c#1 )
|
||||
[24] (byte*) scrollup2::line1#2 ← phi( scrollup2::@1/(byte*) scrollup2::line1#3 scrollup2::@2/(byte*) scrollup2::line1#1 )
|
||||
[24] (byte*) scrollup2::line2#2 ← phi( scrollup2::@1/(byte*) scrollup2::line2#3 scrollup2::@2/(byte*) scrollup2::line2#1 )
|
||||
[25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2)
|
||||
[26] (byte*) scrollup2::line1#1 ← ++ (byte*) scrollup2::line1#2
|
||||
[27] (byte*) scrollup2::line2#1 ← ++ (byte*) scrollup2::line2#2
|
||||
[28] (byte) scrollup2::c#1 ← ++ (byte) scrollup2::c#2
|
||||
[29] if((byte) scrollup2::c#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup2::@2
|
||||
to:scrollup2::@3
|
||||
scrollup2::@3: scope:[scrollup2] from scrollup2::@2
|
||||
[30] (byte) scrollup2::l#1 ← ++ (byte) scrollup2::l#4
|
||||
[31] if((byte) scrollup2::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup2::@1
|
||||
to:scrollup2::@return
|
||||
scrollup2::@return: scope:[scrollup2] from scrollup2::@3
|
||||
[32] return
|
||||
to:@return
|
||||
scrollup1: scope:[scrollup1] from main
|
||||
[33] phi()
|
||||
to:scrollup1::@1
|
||||
scrollup1::@1: scope:[scrollup1] from scrollup1 scrollup1::@3
|
||||
[34] (word) scrollup1::line#4 ← phi( scrollup1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup1::@3/(word) scrollup1::line#1 )
|
||||
to:scrollup1::@2
|
||||
scrollup1::@2: scope:[scrollup1] from scrollup1::@1 scrollup1::@2
|
||||
[35] (byte) scrollup1::c#2 ← phi( scrollup1::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup1::@2/(byte) scrollup1::c#1 )
|
||||
[36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2
|
||||
[37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2
|
||||
[38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2)
|
||||
[39] (byte) scrollup1::c#1 ← ++ (byte) scrollup1::c#2
|
||||
[40] if((byte) scrollup1::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup1::@2
|
||||
to:scrollup1::@3
|
||||
scrollup1::@3: scope:[scrollup1] from scrollup1::@2
|
||||
[41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40
|
||||
[42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1
|
||||
to:scrollup1::@return
|
||||
scrollup1::@return: scope:[scrollup1] from scrollup1::@3
|
||||
[43] return
|
||||
to:@return
|
1621
src/test/ref/test-scroll-up.log
Normal file
1621
src/test/ref/test-scroll-up.log
Normal file
File diff suppressed because it is too large
Load Diff
64
src/test/ref/test-scroll-up.sym
Normal file
64
src/test/ref/test-scroll-up.sym
Normal file
@ -0,0 +1,64 @@
|
||||
(label) @4
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@return
|
||||
(byte*) screen
|
||||
(const byte*) screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024
|
||||
(void()) scrollup1()
|
||||
(word~) scrollup1::$0 $0 zp ZP_WORD:4 101.0
|
||||
(word~) scrollup1::$2 $2 zp ZP_WORD:7 202.0
|
||||
(label) scrollup1::@1
|
||||
(label) scrollup1::@2
|
||||
(label) scrollup1::@3
|
||||
(label) scrollup1::@return
|
||||
(byte) scrollup1::c
|
||||
(byte) scrollup1::c#1 reg byte x 151.5
|
||||
(byte) scrollup1::c#2 reg byte x 101.0
|
||||
(word) scrollup1::line
|
||||
(word) scrollup1::line#1 line zp ZP_WORD:2 16.5
|
||||
(word) scrollup1::line#4 line zp ZP_WORD:2 32.0
|
||||
(void()) scrollup2()
|
||||
(label) scrollup2::@1
|
||||
(label) scrollup2::@2
|
||||
(label) scrollup2::@3
|
||||
(label) scrollup2::@return
|
||||
(byte) scrollup2::c
|
||||
(byte) scrollup2::c#1 reg byte x 151.5
|
||||
(byte) scrollup2::c#2 reg byte x 50.5
|
||||
(byte) scrollup2::l
|
||||
(byte) scrollup2::l#1 l zp ZP_BYTE:6 16.5
|
||||
(byte) scrollup2::l#4 l zp ZP_BYTE:6 3.142857142857143
|
||||
(byte*) scrollup2::line1
|
||||
(byte*) scrollup2::line1#1 line1 zp ZP_WORD:4 35.5
|
||||
(byte*) scrollup2::line1#2 line1 zp ZP_WORD:4 157.0
|
||||
(byte*) scrollup2::line1#3 line1 zp ZP_WORD:4 22.0
|
||||
(byte*) scrollup2::line2
|
||||
(byte*) scrollup2::line2#1 line2 zp ZP_WORD:2 42.599999999999994
|
||||
(byte*) scrollup2::line2#2 line2 zp ZP_WORD:2 104.66666666666666
|
||||
(byte*) scrollup2::line2#3 line2 zp ZP_WORD:2 22.0
|
||||
(void()) scrollup3()
|
||||
(label) scrollup3::@1
|
||||
(label) scrollup3::@2
|
||||
(label) scrollup3::@3
|
||||
(label) scrollup3::@return
|
||||
(byte) scrollup3::c
|
||||
(byte) scrollup3::c#1 reg byte x 151.5
|
||||
(byte) scrollup3::c#2 reg byte x 67.33333333333333
|
||||
(word) scrollup3::l2
|
||||
(word) scrollup3::l2#0 l2 zp ZP_WORD:2 4.714285714285714
|
||||
(word) scrollup3::l2#1 l2#1 zp ZP_WORD:4 67.33333333333333
|
||||
(word) scrollup3::l2#2 l2#2 zp ZP_WORD:4 207.5
|
||||
(word~) scrollup3::l2#4 l2#4 zp ZP_WORD:4 22.0
|
||||
(word) scrollup3::line
|
||||
(word) scrollup3::line#1 line zp ZP_WORD:2 16.5
|
||||
|
||||
zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 scrollup1::line#4 scrollup1::line#1 ]
|
||||
zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 scrollup1::$0 ]
|
||||
reg byte x [ scrollup3::c#2 scrollup3::c#1 ]
|
||||
zp ZP_BYTE:6 [ scrollup2::l#4 scrollup2::l#1 ]
|
||||
reg byte x [ scrollup2::c#2 scrollup2::c#1 ]
|
||||
reg byte x [ scrollup1::c#2 scrollup1::c#1 ]
|
||||
zp ZP_WORD:7 [ scrollup1::$2 ]
|
Loading…
Reference in New Issue
Block a user