mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-07 07:29:49 +00:00
Added hex code font.
This commit is contained in:
parent
281a77c06c
commit
5f61df4c16
@ -0,0 +1,3 @@
|
||||
stx $ff
|
||||
ldy $ff
|
||||
ora ({z1}),y
|
@ -542,6 +542,12 @@ class AsmFragmentTemplateSynthesisRule {
|
||||
// Rewrite wv.z1=(word)_ror_4 to wv.z1=(word)
|
||||
synths.add(new AsmFragmentTemplateSynthesisRule("vw(.*)z1=(.*)_ror_4", rvalAa, null, "vw$1z1=$2", "lsr {z1}+1\nror {z1}\nlsr {z1}+1\nror {z1}\nlsr {z1}+1\nror {z1}\nlsr {z1}+1\nror {z1}", null, null));
|
||||
|
||||
// Rewrite vbuaa=(byte)_rol_N to wbuz1=(byte)
|
||||
synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_1", rvalAa, null, "vbuaa=$1", "asl", null, null));
|
||||
synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_2", rvalAa, null, "vbuaa=$1", "asl\nasl", null, null));
|
||||
synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_3", rvalAa, null, "vbuaa=$1", "asl\nasl\nasl", null, null));
|
||||
synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_4", rvalAa, null, "vbuaa=$1", "asl\nasl\nasl\nasl", null, null));
|
||||
|
||||
// Rewrite multiple _derefidx_vbuc1 to use YY
|
||||
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_derefidx_vbuc1(.*)_derefidx_vbuc1(.*)", rvalYy+"|"+ threeC1, "ldy #{c1}", "$1_derefidx_vbuyy$2_derefidx_vbuyy$3", null, mapC1));
|
||||
|
||||
|
@ -35,9 +35,14 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFontHex() throws IOException, URISyntaxException {
|
||||
compileAndCompare("font-hex");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMemcpy0() throws IOException, URISyntaxException {
|
||||
compileAndCompare("memcpy-0", log());
|
||||
compileAndCompare("memcpy-0");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
135
src/test/kc/font-hex.kc
Normal file
135
src/test/kc/font-hex.kc
Normal file
@ -0,0 +1,135 @@
|
||||
// Creates a font where each char contains the number of the char (00-ff)
|
||||
|
||||
import "c64"
|
||||
import "string"
|
||||
|
||||
byte* SCREEN = 0x0400;
|
||||
byte* CHARSET = 0x2000;
|
||||
|
||||
void main() {
|
||||
*D018 = toD018(SCREEN, CHARSET);
|
||||
|
||||
// Make charset from proto chars
|
||||
byte* charset = CHARSET;
|
||||
byte* proto_hi = FONT_HEX_PROTO;
|
||||
for( byte c: 0..15 ) {
|
||||
byte* proto_lo = FONT_HEX_PROTO;
|
||||
for( byte c: 0..15 ) {
|
||||
for( byte i: 0..4) {
|
||||
charset[i] = proto_hi[i]<<3 | proto_lo[i];
|
||||
}
|
||||
charset[5] = 0;
|
||||
charset[6] = 0;
|
||||
charset[7] = 0;
|
||||
proto_lo += 5;
|
||||
charset += 8;
|
||||
}
|
||||
proto_hi += 5;
|
||||
}
|
||||
|
||||
// Show all chars on screen
|
||||
for (byte c: 0..255) {
|
||||
SCREEN[c] = c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Bit patterns for symbols 0-f (3x5 pixels)
|
||||
byte[] FONT_HEX_PROTO = {
|
||||
// 0
|
||||
0b010,
|
||||
0b101,
|
||||
0b101,
|
||||
0b101,
|
||||
0b010,
|
||||
// 1
|
||||
0b110,
|
||||
0b010,
|
||||
0b010,
|
||||
0b010,
|
||||
0b111,
|
||||
// 2
|
||||
0b110,
|
||||
0b001,
|
||||
0b010,
|
||||
0b100,
|
||||
0b111,
|
||||
// 3
|
||||
0b110,
|
||||
0b001,
|
||||
0b010,
|
||||
0b001,
|
||||
0b110,
|
||||
// 4
|
||||
0b101,
|
||||
0b101,
|
||||
0b111,
|
||||
0b001,
|
||||
0b001,
|
||||
// 5
|
||||
0b111,
|
||||
0b100,
|
||||
0b110,
|
||||
0b001,
|
||||
0b110,
|
||||
// 6
|
||||
0b011,
|
||||
0b100,
|
||||
0b110,
|
||||
0b101,
|
||||
0b010,
|
||||
// 7
|
||||
0b111,
|
||||
0b001,
|
||||
0b001,
|
||||
0b001,
|
||||
0b001,
|
||||
// 8
|
||||
0b010,
|
||||
0b101,
|
||||
0b010,
|
||||
0b101,
|
||||
0b010,
|
||||
// 9
|
||||
0b010,
|
||||
0b101,
|
||||
0b011,
|
||||
0b001,
|
||||
0b001,
|
||||
// a
|
||||
0b010,
|
||||
0b101,
|
||||
0b111,
|
||||
0b101,
|
||||
0b101,
|
||||
// b
|
||||
0b110,
|
||||
0b101,
|
||||
0b110,
|
||||
0b101,
|
||||
0b110,
|
||||
// c
|
||||
0b011,
|
||||
0b100,
|
||||
0b100,
|
||||
0b100,
|
||||
0b011,
|
||||
// d
|
||||
0b110,
|
||||
0b101,
|
||||
0b101,
|
||||
0b101,
|
||||
0b110,
|
||||
// e
|
||||
0b111,
|
||||
0b100,
|
||||
0b111,
|
||||
0b100,
|
||||
0b111,
|
||||
// f
|
||||
0b111,
|
||||
0b100,
|
||||
0b111,
|
||||
0b100,
|
||||
0b100
|
||||
};
|
90
src/test/ref/font-hex.asm
Normal file
90
src/test/ref/font-hex.asm
Normal file
@ -0,0 +1,90 @@
|
||||
// Creates a font where each char contains the number of the char (00-ff)
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label D018 = $d018
|
||||
.label SCREEN = $400
|
||||
.label CHARSET = $2000
|
||||
main: {
|
||||
.const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
|
||||
.label proto_lo = 5
|
||||
.label charset = 7
|
||||
.label proto_hi = 2
|
||||
.label c = 4
|
||||
lda #toD0181_return
|
||||
sta D018
|
||||
lda #0
|
||||
sta c
|
||||
lda #<CHARSET
|
||||
sta charset
|
||||
lda #>CHARSET
|
||||
sta charset+1
|
||||
lda #<FONT_HEX_PROTO
|
||||
sta proto_hi
|
||||
lda #>FONT_HEX_PROTO
|
||||
sta proto_hi+1
|
||||
b1:
|
||||
ldx #0
|
||||
lda #<FONT_HEX_PROTO
|
||||
sta proto_lo
|
||||
lda #>FONT_HEX_PROTO
|
||||
sta proto_lo+1
|
||||
b2:
|
||||
ldy #0
|
||||
b3:
|
||||
lda (proto_hi),y
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
ora (proto_lo),y
|
||||
sta (charset),y
|
||||
iny
|
||||
cpy #5
|
||||
bne b3
|
||||
lda #0
|
||||
ldy #5
|
||||
sta (charset),y
|
||||
ldy #6
|
||||
sta (charset),y
|
||||
ldy #7
|
||||
sta (charset),y
|
||||
lda #5
|
||||
clc
|
||||
adc proto_lo
|
||||
sta proto_lo
|
||||
bcc !+
|
||||
inc proto_lo+1
|
||||
!:
|
||||
lda #8
|
||||
clc
|
||||
adc charset
|
||||
sta charset
|
||||
bcc !+
|
||||
inc charset+1
|
||||
!:
|
||||
inx
|
||||
cpx #$10
|
||||
bne b2
|
||||
lda #5
|
||||
clc
|
||||
adc proto_hi
|
||||
sta proto_hi
|
||||
bcc !+
|
||||
inc proto_hi+1
|
||||
!:
|
||||
inc c
|
||||
lda #$10
|
||||
cmp c
|
||||
bne b1
|
||||
ldx #0
|
||||
// Show all chars on screen
|
||||
b6:
|
||||
txa
|
||||
sta SCREEN,x
|
||||
inx
|
||||
cpx #0
|
||||
bne b6
|
||||
rts
|
||||
}
|
||||
// Bit patterns for symbols 0-f (3x5 pixels)
|
||||
FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 3, 4, 4, 4, 3, 6, 5, 5, 5, 6, 7, 4, 7, 4, 7, 7, 4, 7, 4, 4
|
59
src/test/ref/font-hex.cfg
Normal file
59
src/test/ref/font-hex.cfg
Normal file
@ -0,0 +1,59 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
to:main::toD0181
|
||||
main::toD0181: scope:[main] from main
|
||||
[5] phi()
|
||||
to:main::@7
|
||||
main::@7: scope:[main] from main::toD0181
|
||||
[6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main::@5 main::@7
|
||||
[7] (byte) main::c#6 ← phi( main::@5/(byte) main::c#1 main::@7/(byte) 0 )
|
||||
[7] (byte*) main::charset#5 ← phi( main::@5/(byte*) main::charset#1 main::@7/(const byte*) CHARSET#0 )
|
||||
[7] (byte*) main::proto_hi#6 ← phi( main::@5/(byte*) main::proto_hi#1 main::@7/(const byte[]) FONT_HEX_PROTO#0 )
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1 main::@4
|
||||
[8] (byte) main::c1#4 ← phi( main::@1/(byte) 0 main::@4/(byte) main::c1#1 )
|
||||
[8] (byte*) main::charset#4 ← phi( main::@1/(byte*) main::charset#5 main::@4/(byte*) main::charset#1 )
|
||||
[8] (byte*) main::proto_lo#4 ← phi( main::@1/(const byte[]) FONT_HEX_PROTO#0 main::@4/(byte*) main::proto_lo#1 )
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@2 main::@3
|
||||
[9] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@3/(byte) main::i#1 )
|
||||
[10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3
|
||||
[11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2)
|
||||
[12] *((byte*) main::charset#4 + (byte) main::i#2) ← (byte~) main::$2
|
||||
[13] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[14] if((byte) main::i#1!=(byte) 5) goto main::@3
|
||||
to:main::@4
|
||||
main::@4: scope:[main] from main::@3
|
||||
[15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0
|
||||
[16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0
|
||||
[17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0
|
||||
[18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5
|
||||
[19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8
|
||||
[20] (byte) main::c1#1 ← ++ (byte) main::c1#4
|
||||
[21] if((byte) main::c1#1!=(byte) $10) goto main::@2
|
||||
to:main::@5
|
||||
main::@5: scope:[main] from main::@4
|
||||
[22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5
|
||||
[23] (byte) main::c#1 ← ++ (byte) main::c#6
|
||||
[24] if((byte) main::c#1!=(byte) $10) goto main::@1
|
||||
to:main::@6
|
||||
main::@6: scope:[main] from main::@5 main::@6
|
||||
[25] (byte) main::c2#2 ← phi( main::@5/(byte) 0 main::@6/(byte) main::c2#1 )
|
||||
[26] *((const byte*) SCREEN#0 + (byte) main::c2#2) ← (byte) main::c2#2
|
||||
[27] (byte) main::c2#1 ← ++ (byte) main::c2#2
|
||||
[28] if((byte) main::c2#1!=(byte) 0) goto main::@6
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@6
|
||||
[29] return
|
||||
to:@return
|
1481
src/test/ref/font-hex.log
Normal file
1481
src/test/ref/font-hex.log
Normal file
File diff suppressed because it is too large
Load Diff
68
src/test/ref/font-hex.sym
Normal file
68
src/test/ref/font-hex.sym
Normal file
@ -0,0 +1,68 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) CHARSET
|
||||
(const byte*) CHARSET#0 CHARSET = (byte*) 8192
|
||||
(byte*) D018
|
||||
(const byte*) D018#0 D018 = (byte*) 53272
|
||||
(byte[]) FONT_HEX_PROTO
|
||||
(const byte[]) FONT_HEX_PROTO#0 FONT_HEX_PROTO = { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 3, (byte) 4, (byte) 4, (byte) 4, (byte) 3, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 4 }
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(void()) main()
|
||||
(byte~) main::$1 reg byte a 2002.0
|
||||
(byte~) main::$2 reg byte a 2002.0
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@4
|
||||
(label) main::@5
|
||||
(label) main::@6
|
||||
(label) main::@7
|
||||
(label) main::@return
|
||||
(byte) main::c
|
||||
(byte) main::c#1 c zp ZP_BYTE:4 16.5
|
||||
(byte) main::c#6 c zp ZP_BYTE:4 1.375
|
||||
(byte) main::c1
|
||||
(byte) main::c1#1 reg byte x 151.5
|
||||
(byte) main::c1#4 reg byte x 16.833333333333332
|
||||
(byte) main::c2
|
||||
(byte) main::c2#1 reg byte x 16.5
|
||||
(byte) main::c2#2 reg byte x 22.0
|
||||
(byte*) main::charset
|
||||
(byte*) main::charset#1 charset zp ZP_WORD:7 35.5
|
||||
(byte*) main::charset#4 charset zp ZP_WORD:7 137.90909090909093
|
||||
(byte*) main::charset#5 charset zp ZP_WORD:7 22.0
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte y 1501.5
|
||||
(byte) main::i#2 reg byte y 1251.25
|
||||
(byte*) main::proto_hi
|
||||
(byte*) main::proto_hi#1 proto_hi zp ZP_WORD:2 7.333333333333333
|
||||
(byte*) main::proto_hi#6 proto_hi zp ZP_WORD:2 68.2
|
||||
(byte*) main::proto_lo
|
||||
(byte*) main::proto_lo#1 proto_lo zp ZP_WORD:5 50.5
|
||||
(byte*) main::proto_lo#4 proto_lo zp ZP_WORD:5 120.29999999999998
|
||||
(label) main::toD0181
|
||||
(word~) main::toD0181_$0
|
||||
(number~) main::toD0181_$1
|
||||
(number~) main::toD0181_$2
|
||||
(number~) main::toD0181_$3
|
||||
(word~) main::toD0181_$4
|
||||
(byte~) main::toD0181_$5
|
||||
(number~) main::toD0181_$6
|
||||
(number~) main::toD0181_$7
|
||||
(number~) main::toD0181_$8
|
||||
(byte*) main::toD0181_gfx
|
||||
(byte) main::toD0181_return
|
||||
(const byte) main::toD0181_return#0 toD0181_return = >(word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4|>(word)(const byte*) CHARSET#0/(byte) 4&(byte) $f
|
||||
(byte*) main::toD0181_screen
|
||||
|
||||
zp ZP_WORD:2 [ main::proto_hi#6 main::proto_hi#1 ]
|
||||
zp ZP_BYTE:4 [ main::c#6 main::c#1 ]
|
||||
zp ZP_WORD:5 [ main::proto_lo#4 main::proto_lo#1 ]
|
||||
zp ZP_WORD:7 [ main::charset#4 main::charset#5 main::charset#1 ]
|
||||
reg byte x [ main::c1#4 main::c1#1 ]
|
||||
reg byte y [ main::i#2 main::i#1 ]
|
||||
reg byte x [ main::c2#2 main::c2#1 ]
|
||||
reg byte a [ main::$1 ]
|
||||
reg byte a [ main::$2 ]
|
Loading…
Reference in New Issue
Block a user