mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-20 23:30:43 +00:00
Added keyboard space check test program.
This commit is contained in:
parent
b796a248c0
commit
cfd0e836ce
@ -45,6 +45,11 @@ public class TestPrograms {
|
||||
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeyboardSpace() throws IOException, URISyntaxException {
|
||||
compileAndCompare("test-keyboard-space");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeyboard() throws IOException, URISyntaxException {
|
||||
compileAndCompare("test-keyboard");
|
||||
|
@ -0,0 +1,14 @@
|
||||
// Test keyboard input - test the space bar
|
||||
import "keyboard.kc"
|
||||
|
||||
void main() {
|
||||
keyboard_init();
|
||||
while(true) {
|
||||
do {} while (*RASTER!=$ff);
|
||||
if(keyboard_key_pressed(KEY_SPACE)!=0) {
|
||||
*BGCOL = GREEN;
|
||||
} else {
|
||||
*BGCOL = BLUE;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label RASTER = $d012
|
||||
.label BGCOL = $d021
|
||||
.label CIA1_PORT_A = $dc00
|
||||
.label CIA1_PORT_B = $dc01
|
||||
.label CIA1_PORT_A_DDR = $dc02
|
||||
.label CIA1_PORT_B_DDR = $dc03
|
||||
.const GREEN = 5
|
||||
.const BLUE = 6
|
||||
.const KEY_SPACE = $3c
|
||||
jsr main
|
||||
main: {
|
||||
jsr keyboard_init
|
||||
b4:
|
||||
lda RASTER
|
||||
cmp #$ff
|
||||
bne b4
|
||||
jsr keyboard_key_pressed
|
||||
cmp #0
|
||||
beq b5
|
||||
lda #GREEN
|
||||
sta BGCOL
|
||||
jmp b4
|
||||
b5:
|
||||
lda #BLUE
|
||||
sta BGCOL
|
||||
jmp b4
|
||||
}
|
||||
keyboard_key_pressed: {
|
||||
jsr keyboard_matrix_read
|
||||
and keyboard_matrix_col_bitmask+(KEY_SPACE&7)
|
||||
rts
|
||||
}
|
||||
keyboard_matrix_read: {
|
||||
.const rowid = KEY_SPACE>>3
|
||||
lda keyboard_matrix_row_bitmask+rowid
|
||||
sta CIA1_PORT_A
|
||||
lda CIA1_PORT_B
|
||||
eor #$ff
|
||||
rts
|
||||
}
|
||||
keyboard_init: {
|
||||
lda #$ff
|
||||
sta CIA1_PORT_A_DDR
|
||||
lda #0
|
||||
sta CIA1_PORT_B_DDR
|
||||
rts
|
||||
}
|
||||
keyboard_matrix_row_bitmask: .byte $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f
|
||||
keyboard_matrix_col_bitmask: .byte 1, 2, 4, 8, $10, $20, $40, $80
|
@ -0,0 +1,63 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi() [ ] ( )
|
||||
to:@5
|
||||
@5: scope:[] from @begin
|
||||
[1] phi() [ ] ( )
|
||||
[2] call main param-assignment [ ] ( )
|
||||
to:@end
|
||||
@end: scope:[] from @5
|
||||
[3] phi() [ ] ( )
|
||||
main: scope:[main] from @5
|
||||
[4] phi() [ ] ( main:2 [ ] )
|
||||
[5] call keyboard_init param-assignment [ ] ( main:2 [ ] )
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@10 main::@5
|
||||
[6] if(true) goto main::@4 [ ] ( main:2 [ ] )
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[7] return [ ] ( main:2 [ ] )
|
||||
to:@return
|
||||
main::@4: scope:[main] from main::@1 main::@4
|
||||
[8] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@4 [ ] ( main:2 [ ] )
|
||||
to:main::@9
|
||||
main::@9: scope:[main] from main::@4
|
||||
[9] phi() [ ] ( main:2 [ ] )
|
||||
[10] call keyboard_key_pressed param-assignment [ keyboard_key_pressed::return#0 ] ( main:2 [ keyboard_key_pressed::return#0 ] )
|
||||
[11] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0 [ keyboard_key_pressed::return#2 ] ( main:2 [ keyboard_key_pressed::return#2 ] )
|
||||
to:main::@14
|
||||
main::@14: scope:[main] from main::@9
|
||||
[12] (byte~) main::$2 ← (byte) keyboard_key_pressed::return#2 [ main::$2 ] ( main:2 [ main::$2 ] )
|
||||
[13] if((byte~) main::$2==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@5 [ ] ( main:2 [ ] )
|
||||
to:main::@10
|
||||
main::@10: scope:[main] from main::@14
|
||||
[14] *((const byte*) BGCOL#0) ← (const byte) GREEN#0 [ ] ( main:2 [ ] )
|
||||
to:main::@1
|
||||
main::@5: scope:[main] from main::@14
|
||||
[15] *((const byte*) BGCOL#0) ← (const byte) BLUE#0 [ ] ( main:2 [ ] )
|
||||
to:main::@1
|
||||
keyboard_key_pressed: scope:[keyboard_key_pressed] from main::@9
|
||||
[16] phi() [ ] ( main:2::keyboard_key_pressed:10 [ ] )
|
||||
[17] call keyboard_matrix_read param-assignment [ keyboard_matrix_read::return#0 ] ( main:2::keyboard_key_pressed:10 [ keyboard_matrix_read::return#0 ] )
|
||||
[18] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0 [ keyboard_matrix_read::return#2 ] ( main:2::keyboard_key_pressed:10 [ keyboard_matrix_read::return#2 ] )
|
||||
to:keyboard_key_pressed::@2
|
||||
keyboard_key_pressed::@2: scope:[keyboard_key_pressed] from keyboard_key_pressed
|
||||
[19] (byte~) keyboard_key_pressed::$1 ← (byte) keyboard_matrix_read::return#2 [ keyboard_key_pressed::$1 ] ( main:2::keyboard_key_pressed:10 [ keyboard_key_pressed::$1 ] )
|
||||
[20] (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$1 & *((const byte[]) keyboard_matrix_col_bitmask#0+(const byte) KEY_SPACE#0&(byte/signed byte/word/signed word/dword/signed dword) 7) [ keyboard_key_pressed::return#0 ] ( main:2::keyboard_key_pressed:10 [ keyboard_key_pressed::return#0 ] )
|
||||
to:keyboard_key_pressed::@return
|
||||
keyboard_key_pressed::@return: scope:[keyboard_key_pressed] from keyboard_key_pressed::@2
|
||||
[21] return [ keyboard_key_pressed::return#0 ] ( main:2::keyboard_key_pressed:10 [ keyboard_key_pressed::return#0 ] )
|
||||
to:@return
|
||||
keyboard_matrix_read: scope:[keyboard_matrix_read] from keyboard_key_pressed
|
||||
[22] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0+(const byte) keyboard_matrix_read::rowid#0) [ ] ( main:2::keyboard_key_pressed:10::keyboard_matrix_read:17 [ ] )
|
||||
[23] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) [ keyboard_matrix_read::return#0 ] ( main:2::keyboard_key_pressed:10::keyboard_matrix_read:17 [ keyboard_matrix_read::return#0 ] )
|
||||
to:keyboard_matrix_read::@return
|
||||
keyboard_matrix_read::@return: scope:[keyboard_matrix_read] from keyboard_matrix_read
|
||||
[24] return [ keyboard_matrix_read::return#0 ] ( main:2::keyboard_key_pressed:10::keyboard_matrix_read:17 [ keyboard_matrix_read::return#0 ] )
|
||||
to:@return
|
||||
keyboard_init: scope:[keyboard_init] from main
|
||||
[25] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255 [ ] ( main:2::keyboard_init:5 [ ] )
|
||||
[26] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( main:2::keyboard_init:5 [ ] )
|
||||
to:keyboard_init::@return
|
||||
keyboard_init::@return: scope:[keyboard_init] from keyboard_init
|
||||
[27] return [ ] ( main:2::keyboard_init:5 [ ] )
|
||||
to:@return
|
1783
src/test/java/dk/camelot64/kickc/test/ref/test-keyboard-space.log
Normal file
1783
src/test/java/dk/camelot64/kickc/test/ref/test-keyboard-space.log
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,59 @@
|
||||
(label) @5
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) BGCOL
|
||||
(const byte*) BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) 53281
|
||||
(byte) BLUE
|
||||
(const byte) BLUE#0 BLUE = (byte/signed byte/word/signed word/dword/signed dword) 6
|
||||
(byte*) CIA1_PORT_A
|
||||
(const byte*) CIA1_PORT_A#0 CIA1_PORT_A = ((byte*))(word/dword/signed dword) 56320
|
||||
(byte*) CIA1_PORT_A_DDR
|
||||
(const byte*) CIA1_PORT_A_DDR#0 CIA1_PORT_A_DDR = ((byte*))(word/dword/signed dword) 56322
|
||||
(byte*) CIA1_PORT_B
|
||||
(const byte*) CIA1_PORT_B#0 CIA1_PORT_B = ((byte*))(word/dword/signed dword) 56321
|
||||
(byte*) CIA1_PORT_B_DDR
|
||||
(const byte*) CIA1_PORT_B_DDR#0 CIA1_PORT_B_DDR = ((byte*))(word/dword/signed dword) 56323
|
||||
(byte) GREEN
|
||||
(const byte) GREEN#0 GREEN = (byte/signed byte/word/signed word/dword/signed dword) 5
|
||||
(byte) KEY_SPACE
|
||||
(const byte) KEY_SPACE#0 KEY_SPACE = (byte/signed byte/word/signed word/dword/signed dword) 60
|
||||
(byte*) RASTER
|
||||
(const byte*) RASTER#0 RASTER = ((byte*))(word/dword/signed dword) 53266
|
||||
(void()) keyboard_init()
|
||||
(label) keyboard_init::@return
|
||||
(byte()) keyboard_key_pressed((byte) keyboard_key_pressed::key)
|
||||
(byte~) keyboard_key_pressed::$1 reg byte a 4.0
|
||||
(label) keyboard_key_pressed::@2
|
||||
(label) keyboard_key_pressed::@return
|
||||
(byte) keyboard_key_pressed::key
|
||||
(byte) keyboard_key_pressed::return
|
||||
(byte) keyboard_key_pressed::return#0 reg byte a 4.333333333333333
|
||||
(byte) keyboard_key_pressed::return#2 reg byte a 22.0
|
||||
(byte[]) keyboard_matrix_col_bitmask
|
||||
(const byte[]) keyboard_matrix_col_bitmask#0 keyboard_matrix_col_bitmask = { (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) 4, (byte/signed byte/word/signed word/dword/signed dword) 8, (byte/signed byte/word/signed word/dword/signed dword) 16, (byte/signed byte/word/signed word/dword/signed dword) 32, (byte/signed byte/word/signed word/dword/signed dword) 64, (byte/word/signed word/dword/signed dword) 128 }
|
||||
(byte()) keyboard_matrix_read((byte) keyboard_matrix_read::rowid)
|
||||
(label) keyboard_matrix_read::@return
|
||||
(byte) keyboard_matrix_read::return
|
||||
(byte) keyboard_matrix_read::return#0 reg byte a 1.3333333333333333
|
||||
(byte) keyboard_matrix_read::return#2 reg byte a 4.0
|
||||
(byte) keyboard_matrix_read::row_pressed_bits
|
||||
(byte) keyboard_matrix_read::rowid
|
||||
(const byte) keyboard_matrix_read::rowid#0 rowid = (const byte) KEY_SPACE#0>>(byte/signed byte/word/signed word/dword/signed dword) 3
|
||||
(byte[8]) keyboard_matrix_row_bitmask
|
||||
(const byte[8]) keyboard_matrix_row_bitmask#0 keyboard_matrix_row_bitmask = { (byte/word/signed word/dword/signed dword) 254, (byte/word/signed word/dword/signed dword) 253, (byte/word/signed word/dword/signed dword) 251, (byte/word/signed word/dword/signed dword) 247, (byte/word/signed word/dword/signed dword) 239, (byte/word/signed word/dword/signed dword) 223, (byte/word/signed word/dword/signed dword) 191, (byte/signed byte/word/signed word/dword/signed dword) 127 }
|
||||
(void()) main()
|
||||
(byte~) main::$2 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@10
|
||||
(label) main::@14
|
||||
(label) main::@4
|
||||
(label) main::@5
|
||||
(label) main::@9
|
||||
(label) main::@return
|
||||
|
||||
reg byte a [ keyboard_key_pressed::return#2 ]
|
||||
reg byte a [ main::$2 ]
|
||||
reg byte a [ keyboard_matrix_read::return#2 ]
|
||||
reg byte a [ keyboard_key_pressed::$1 ]
|
||||
reg byte a [ keyboard_key_pressed::return#0 ]
|
||||
reg byte a [ keyboard_matrix_read::return#0 ]
|
Loading…
Reference in New Issue
Block a user