mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-04-08 14:37:40 +00:00
Implemented simple DTV raster test
This commit is contained in:
parent
f212c55c02
commit
171b015d5f
@ -0,0 +1 @@
|
||||
inc {c1},x
|
@ -0,0 +1,4 @@
|
||||
lda {c1},y
|
||||
clc
|
||||
adc #1
|
||||
sta {c1},y
|
@ -8,10 +8,10 @@ import dk.camelot64.kickc.model.types.SymbolTypeSimple;
|
||||
import dk.camelot64.kickc.model.values.ConstantInteger;
|
||||
import dk.camelot64.kickc.model.values.ConstantLiteral;
|
||||
|
||||
/** Binary boolean and Operator ( x & y ) */
|
||||
public class OperatorBoolAnd extends OperatorBinary {
|
||||
/** Binary bitwise and Operator ( x & y ) */
|
||||
public class OperatorBitwiseAnd extends OperatorBinary {
|
||||
|
||||
public OperatorBoolAnd(int precedence) {
|
||||
public OperatorBitwiseAnd(int precedence) {
|
||||
super("&", "_band_", precedence);
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ import dk.camelot64.kickc.model.types.SymbolTypeSimple;
|
||||
import dk.camelot64.kickc.model.values.ConstantInteger;
|
||||
import dk.camelot64.kickc.model.values.ConstantLiteral;
|
||||
|
||||
/** Unary Boolean Not operator (~b) */
|
||||
public class OperatorBoolNot extends OperatorUnary {
|
||||
/** Unary bitwise Not operator (~b) */
|
||||
public class OperatorBitwiseNot extends OperatorUnary {
|
||||
|
||||
public OperatorBoolNot(int precedence) {
|
||||
super("~", "_not_", precedence);
|
||||
public OperatorBitwiseNot(int precedence) {
|
||||
super("~", "_bnot_", precedence);
|
||||
}
|
||||
|
||||
@Override
|
@ -8,10 +8,10 @@ import dk.camelot64.kickc.model.types.SymbolTypeSimple;
|
||||
import dk.camelot64.kickc.model.values.ConstantInteger;
|
||||
import dk.camelot64.kickc.model.values.ConstantLiteral;
|
||||
|
||||
/** Binary boolean or Operator ( x | y ) */
|
||||
public class OperatorBoolOr extends OperatorBinary {
|
||||
/** Binary bitwise or Operator ( x | y ) */
|
||||
public class OperatorBitwiseOr extends OperatorBinary {
|
||||
|
||||
public OperatorBoolOr(int precedence) {
|
||||
public OperatorBitwiseOr(int precedence) {
|
||||
super("|", "_bor_", precedence);
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ import dk.camelot64.kickc.model.types.SymbolTypeSimple;
|
||||
import dk.camelot64.kickc.model.values.ConstantInteger;
|
||||
import dk.camelot64.kickc.model.values.ConstantLiteral;
|
||||
|
||||
/** Binary boolean exclusive or Operator ( x ^ y ) */
|
||||
public class OperatorBoolXor extends OperatorBinary {
|
||||
/** Binary bitwise exclusive or Operator ( x ^ y ) */
|
||||
public class OperatorBitwiseXor extends OperatorBinary {
|
||||
|
||||
public OperatorBoolXor(int precedence) {
|
||||
public OperatorBitwiseXor(int precedence) {
|
||||
super("^", "_bxor_", precedence);
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public class OperatorPlus extends OperatorBinary {
|
||||
|
||||
@Override
|
||||
public SymbolType inferType(SymbolTypeSimple type1, SymbolTypeSimple type2) {
|
||||
|
||||
// Handle all non-numeric types
|
||||
if(type1.equals(SymbolType.STRING) && isStringLike(type2)) {
|
||||
return SymbolType.STRING;
|
||||
|
@ -10,7 +10,7 @@ public class Operators {
|
||||
public static final OperatorUnary DECREMENT = new OperatorDecrement(1);
|
||||
public static final OperatorUnary POS = new OperatorPos(2);
|
||||
public static final OperatorUnary NEG = new OperatorNeg(2);
|
||||
public static final OperatorUnary BOOL_NOT = new OperatorBoolNot(2);
|
||||
public static final OperatorUnary BOOL_NOT = new OperatorBitwiseNot(2);
|
||||
public static final OperatorUnary LOGIC_NOT = new OperatorLogicNot(2);
|
||||
public static final OperatorUnary DEREF = new OperatorDeref(2);
|
||||
public static final OperatorUnary ADDRESS_OF = new OperatorAddressOf(2);
|
||||
@ -40,9 +40,9 @@ public class Operators {
|
||||
public static final OperatorBinary GE = new OperatorGreaterThanEqual(7);
|
||||
public static final OperatorBinary EQ = new OperatorEqual(8);
|
||||
public static final OperatorBinary NEQ = new OperatorNotEqual(8);
|
||||
public static final OperatorBinary BOOL_AND = new OperatorBoolAnd(9);
|
||||
public static final OperatorBinary BOOL_XOR = new OperatorBoolXor(10);
|
||||
public static final OperatorBinary BOOL_OR = new OperatorBoolOr(11);
|
||||
public static final OperatorBinary BOOL_AND = new OperatorBitwiseAnd(9);
|
||||
public static final OperatorBinary BOOL_XOR = new OperatorBitwiseXor(10);
|
||||
public static final OperatorBinary BOOL_OR = new OperatorBitwiseOr(11);
|
||||
public static final OperatorBinary LOGIC_AND = new OperatorLogicAnd(12);
|
||||
public static final OperatorBinary LOGIC_OR = new OperatorLogicOr(13);
|
||||
|
||||
|
@ -45,6 +45,11 @@ public class TestPrograms {
|
||||
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testC64DtvColor() throws IOException, URISyntaxException {
|
||||
compileAndCompare("c64dtv-color");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCastPrecedenceProblem() throws IOException, URISyntaxException {
|
||||
compileAndCompare("cast-precedence-problem");
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Commodore 64 Registers and Constants
|
||||
|
||||
const byte* PROCPORT = $01;
|
||||
|
||||
const byte* CHARGEN = $d000;
|
||||
|
29
src/test/java/dk/camelot64/kickc/test/kc/c64dtv-color.kc
Normal file
29
src/test/java/dk/camelot64/kickc/test/kc/c64dtv-color.kc
Normal file
@ -0,0 +1,29 @@
|
||||
// Test C64DTV v2 256-colors and the 16-color redefinable palette
|
||||
|
||||
import "c64dtv.kc"
|
||||
|
||||
void main() {
|
||||
asm { sei }
|
||||
*DTV_FEATURE = DTV_FEATURE_ENABLE;
|
||||
*DTV_CONTROL = DTV_CONTROL_HIGHCOLOR_ON | DTV_CONTROL_BORDER_OFF | DTV_CONTROL_BADLINE_OFF;
|
||||
|
||||
byte[16] palette = { $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $a, $b, $c, $d, $e, $f };
|
||||
|
||||
while(true) {
|
||||
while(*RASTER!=$40) { }
|
||||
|
||||
// Create rasterbars
|
||||
*BGCOL = 0;
|
||||
for (byte r : $31..$ff) {
|
||||
asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop }
|
||||
(*BGCOL)++;
|
||||
}
|
||||
|
||||
// Rotate palette
|
||||
for(byte c : 0..$f) {
|
||||
DTV_PALETTE[c] = palette[c];
|
||||
palette[c]++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
18
src/test/java/dk/camelot64/kickc/test/kc/c64dtv.kc
Normal file
18
src/test/java/dk/camelot64/kickc/test/kc/c64dtv.kc
Normal file
@ -0,0 +1,18 @@
|
||||
// C64 DTV version 2 Registers and Constants
|
||||
|
||||
import "c64.kc"
|
||||
|
||||
const byte* DTV_CONTROL = $d03c;
|
||||
const byte DTV_CONTROL_LINEAR_ADDRESSING_ON = $01;
|
||||
const byte DTV_CONTROL_BORDER_OFF = $02;
|
||||
const byte DTV_CONTROL_HIGHCOLOR_ON = $04;
|
||||
const byte DTV_CONTROL_OVERSCAN_ON = $08;
|
||||
const byte DTV_CONTROL_COLORRAM_OFF = $10;
|
||||
const byte DTV_CONTROL_BADLINE_OFF = $20;
|
||||
const byte DTV_CONTROL_CHUNKY_ON = $40;
|
||||
|
||||
const byte* DTV_FEATURE = $d03f;
|
||||
const byte DTV_FEATURE_ENABLE = 1;
|
||||
const byte DTV_FEATURE_DISABLE_TIL_RESET = 2;
|
||||
|
||||
const byte* DTV_PALETTE = $d200;
|
67
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.asm
Normal file
67
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.asm
Normal file
@ -0,0 +1,67 @@
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label RASTER = $d012
|
||||
.label BGCOL = $d021
|
||||
.label DTV_CONTROL = $d03c
|
||||
.const DTV_CONTROL_BORDER_OFF = 2
|
||||
.const DTV_CONTROL_HIGHCOLOR_ON = 4
|
||||
.const DTV_CONTROL_BADLINE_OFF = $20
|
||||
.label DTV_FEATURE = $d03f
|
||||
.const DTV_FEATURE_ENABLE = 1
|
||||
.label DTV_PALETTE = $d200
|
||||
jsr main
|
||||
main: {
|
||||
sei
|
||||
lda #DTV_FEATURE_ENABLE
|
||||
sta DTV_FEATURE
|
||||
lda #DTV_CONTROL_HIGHCOLOR_ON|DTV_CONTROL_BORDER_OFF|DTV_CONTROL_BADLINE_OFF
|
||||
sta DTV_CONTROL
|
||||
b4:
|
||||
lda RASTER
|
||||
cmp #$40
|
||||
bne b4
|
||||
lda #0
|
||||
sta BGCOL
|
||||
ldx #$31
|
||||
b7:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
inc BGCOL
|
||||
inx
|
||||
cpx #0
|
||||
bne b7
|
||||
ldx #0
|
||||
b8:
|
||||
lda palette,x
|
||||
sta DTV_PALETTE,x
|
||||
inc palette,x
|
||||
inx
|
||||
cpx #$10
|
||||
bne b8
|
||||
jmp b4
|
||||
palette: .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, $a, $b, $c, $d, $e, $f
|
||||
}
|
40
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.cfg
Normal file
40
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.cfg
Normal file
@ -0,0 +1,40 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi() [ ] ( )
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi() [ ] ( )
|
||||
[2] call main param-assignment [ ] ( )
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi() [ ] ( )
|
||||
main: scope:[main] from @1
|
||||
asm { sei }
|
||||
[5] *((const byte*) DTV_FEATURE#0) ← (const byte) DTV_FEATURE_ENABLE#0 [ ] ( main:2 [ ] )
|
||||
[6] *((const byte*) DTV_CONTROL#0) ← (const byte) DTV_CONTROL_HIGHCOLOR_ON#0|(const byte) DTV_CONTROL_BORDER_OFF#0|(const byte) DTV_CONTROL_BADLINE_OFF#0 [ ] ( main:2 [ ] )
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@8
|
||||
[7] if(true) goto main::@4 [ ] ( main:2 [ ] )
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[8] return [ ] ( main:2 [ ] )
|
||||
to:@return
|
||||
main::@4: scope:[main] from main::@1 main::@4
|
||||
[9] if(*((const byte*) RASTER#0)!=(byte/signed byte/word/signed word/dword/signed dword) 64) goto main::@4 [ ] ( main:2 [ ] )
|
||||
to:main::@6
|
||||
main::@6: scope:[main] from main::@4
|
||||
[10] *((const byte*) BGCOL#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( main:2 [ ] )
|
||||
to:main::@7
|
||||
main::@7: scope:[main] from main::@6 main::@7
|
||||
[11] (byte) main::r#2 ← phi( main::@6/(byte/signed byte/word/signed word/dword/signed dword) 49 main::@7/(byte) main::r#1 ) [ main::r#2 ] ( main:2 [ main::r#2 ] )
|
||||
asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop }
|
||||
[13] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) [ main::r#2 ] ( main:2 [ main::r#2 ] )
|
||||
[14] (byte) main::r#1 ← ++ (byte) main::r#2 [ main::r#1 ] ( main:2 [ main::r#1 ] )
|
||||
[15] if((byte) main::r#1!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@7 [ main::r#1 ] ( main:2 [ main::r#1 ] )
|
||||
to:main::@8
|
||||
main::@8: scope:[main] from main::@7 main::@8
|
||||
[16] (byte) main::c#2 ← phi( main::@7/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@8/(byte) main::c#1 ) [ main::c#2 ] ( main:2 [ main::c#2 ] )
|
||||
[17] *((const byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((const byte[16]) main::palette#0 + (byte) main::c#2) [ main::c#2 ] ( main:2 [ main::c#2 ] )
|
||||
[18] *((const byte[16]) main::palette#0 + (byte) main::c#2) ← ++ *((const byte[16]) main::palette#0 + (byte) main::c#2) [ main::c#2 ] ( main:2 [ main::c#2 ] )
|
||||
[19] (byte) main::c#1 ← ++ (byte) main::c#2 [ main::c#1 ] ( main:2 [ main::c#1 ] )
|
||||
[20] if((byte) main::c#1!=(byte/signed byte/word/signed word/dword/signed dword) 16) goto main::@8 [ main::c#1 ] ( main:2 [ main::c#1 ] )
|
||||
to:main::@1
|
1191
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.log
Normal file
1191
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.log
Normal file
File diff suppressed because it is too large
Load Diff
39
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.sym
Normal file
39
src/test/java/dk/camelot64/kickc/test/ref/c64dtv-color.sym
Normal file
@ -0,0 +1,39 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) BGCOL
|
||||
(const byte*) BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) 53281
|
||||
(byte*) DTV_CONTROL
|
||||
(const byte*) DTV_CONTROL#0 DTV_CONTROL = ((byte*))(word/dword/signed dword) 53308
|
||||
(byte) DTV_CONTROL_BADLINE_OFF
|
||||
(const byte) DTV_CONTROL_BADLINE_OFF#0 DTV_CONTROL_BADLINE_OFF = (byte/signed byte/word/signed word/dword/signed dword) 32
|
||||
(byte) DTV_CONTROL_BORDER_OFF
|
||||
(const byte) DTV_CONTROL_BORDER_OFF#0 DTV_CONTROL_BORDER_OFF = (byte/signed byte/word/signed word/dword/signed dword) 2
|
||||
(byte) DTV_CONTROL_HIGHCOLOR_ON
|
||||
(const byte) DTV_CONTROL_HIGHCOLOR_ON#0 DTV_CONTROL_HIGHCOLOR_ON = (byte/signed byte/word/signed word/dword/signed dword) 4
|
||||
(byte*) DTV_FEATURE
|
||||
(const byte*) DTV_FEATURE#0 DTV_FEATURE = ((byte*))(word/dword/signed dword) 53311
|
||||
(byte) DTV_FEATURE_ENABLE
|
||||
(const byte) DTV_FEATURE_ENABLE#0 DTV_FEATURE_ENABLE = (byte/signed byte/word/signed word/dword/signed dword) 1
|
||||
(byte*) DTV_PALETTE
|
||||
(const byte*) DTV_PALETTE#0 DTV_PALETTE = ((byte*))(word/dword/signed dword) 53760
|
||||
(byte*) RASTER
|
||||
(const byte*) RASTER#0 RASTER = ((byte*))(word/dword/signed dword) 53266
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@4
|
||||
(label) main::@6
|
||||
(label) main::@7
|
||||
(label) main::@8
|
||||
(label) main::@return
|
||||
(byte) main::c
|
||||
(byte) main::c#1 reg byte x 151.5
|
||||
(byte) main::c#2 reg byte x 201.99999999999997
|
||||
(byte[16]) main::palette
|
||||
(const byte[16]) main::palette#0 palette = { (byte/signed byte/word/signed word/dword/signed dword) 0, (byte/signed byte/word/signed word/dword/signed dword) 1, (byte/signed byte/word/signed word/dword/signed dword) 2, (byte/signed byte/word/signed word/dword/signed dword) 3, (byte/signed byte/word/signed word/dword/signed dword) 4, (byte/signed byte/word/signed word/dword/signed dword) 5, (byte/signed byte/word/signed word/dword/signed dword) 6, (byte/signed byte/word/signed word/dword/signed dword) 7, (byte/signed byte/word/signed word/dword/signed dword) 8, (byte/signed byte/word/signed word/dword/signed dword) 9, (byte/signed byte/word/signed word/dword/signed dword) 10, (byte/signed byte/word/signed word/dword/signed dword) 11, (byte/signed byte/word/signed word/dword/signed dword) 12, (byte/signed byte/word/signed word/dword/signed dword) 13, (byte/signed byte/word/signed word/dword/signed dword) 14, (byte/signed byte/word/signed word/dword/signed dword) 15 }
|
||||
(byte) main::r
|
||||
(byte) main::r#1 reg byte x 151.5
|
||||
(byte) main::r#2 reg byte x 67.33333333333333
|
||||
|
||||
reg byte x [ main::r#2 main::r#1 ]
|
||||
reg byte x [ main::c#2 main::c#1 ]
|
@ -72,6 +72,8 @@ void raster() {
|
||||
}
|
||||
Importing c64.kc
|
||||
PARSING src/test/java/dk/camelot64/kickc/test/kc/c64.kc
|
||||
// Commodore 64 Registers and Constants
|
||||
|
||||
const byte* PROCPORT = $01;
|
||||
|
||||
const byte* CHARGEN = $d000;
|
||||
|
@ -74,6 +74,8 @@ void anim() {
|
||||
|
||||
Importing c64
|
||||
PARSING src/test/java/dk/camelot64/kickc/test/kc/c64.kc
|
||||
// Commodore 64 Registers and Constants
|
||||
|
||||
const byte* PROCPORT = $01;
|
||||
|
||||
const byte* CHARGEN = $d000;
|
||||
|
@ -215,6 +215,8 @@ void gen_sintab(byte* sintab, byte length, byte min, byte max) {
|
||||
|
||||
Importing c64
|
||||
PARSING src/test/java/dk/camelot64/kickc/test/kc/c64.kc
|
||||
// Commodore 64 Registers and Constants
|
||||
|
||||
const byte* PROCPORT = $01;
|
||||
|
||||
const byte* CHARGEN = $d000;
|
||||
|
Loading…
x
Reference in New Issue
Block a user