1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-08-02 09:29:35 +00:00

Implemented keyboard routines for reading the keyboard matrix status.

This commit is contained in:
jespergravgaard 2018-03-19 01:15:18 +01:00
parent 171b015d5f
commit 8f6db3a39b
10 changed files with 4271 additions and 559 deletions

View File

@ -0,0 +1,2 @@
lda {c1}
eor #$ff

View File

@ -15,6 +15,7 @@ import dk.camelot64.kickc.model.values.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Type inference of expressions (rValues & unary/binary operators)
@ -365,4 +366,53 @@ public class SymbolTypeInference {
throw new RuntimeException("LValue statement not implemented " + statementLValue);
}
}
/**
* Find the symbol type that is the intersection between the two passed types.
* Handles SymbolTypeMulti by intersecting the sub type lists.
* @param type1 The first type
* @param type2 The second type
* @return The intersection between the two types (handling multi-types)
*/
public static SymbolType intersectTypes(SymbolType type1, SymbolType type2) {
List<SymbolType> newSubTypes = new ArrayList<>();
if(type1 instanceof SymbolTypeMulti) {
Collection<SymbolType> subTypes1 = ((SymbolTypeMulti) type1).getTypes();
if(type2 instanceof SymbolTypeMulti) {
Collection<SymbolType> subTypes2 = ((SymbolTypeMulti) type2).getTypes();
for(SymbolType subType1 : subTypes1) {
if(subTypes2.contains(subType1)) {
newSubTypes.add(subType1);
}
}
} else {
// Element type is not multi - check if the list type contains it
if(subTypes1.contains(type2)) {
newSubTypes.add(type2);
}
}
} else {
// List-type not multi - check if the element type contains it
if(type2 instanceof SymbolTypeMulti) {
Collection<SymbolType> subTypes2 = ((SymbolTypeMulti) type2).getTypes();
if(subTypes2.contains(type1)) {
newSubTypes.add(type1);
}
} else {
// Element type is not multi - check if the list type is the same
if(type1.equals(type2)) {
newSubTypes.add(type1);
}
}
}
if(newSubTypes.size()==0) {
return null;
} else if(newSubTypes.size()==1) {
// A single type matching - use it
return newSubTypes.get(0);
} else {
// Multiple matches was found - use them
return new SymbolTypeMulti(newSubTypes);
}
}
}

View File

@ -130,28 +130,35 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization {
ValueList valueList = (ValueList) assignment.getrValue2();
List<RValue> values = valueList.getList();
boolean allConstant = true;
SymbolType elementType = null;
// Type of the elements of the list (deducted from the type of all elements)
SymbolType listType = null;
List<ConstantValue> elements = new ArrayList<>();
for(RValue value : values) {
if(value instanceof ConstantValue) {
ConstantValue constantValue = (ConstantValue) value;
SymbolType type = constantValue.getType(getScope());
if(elementType == null) {
elementType = type;
for(RValue elmValue : values) {
if(elmValue instanceof ConstantValue) {
ConstantValue constantValue = (ConstantValue) elmValue;
SymbolType elmType = constantValue.getType(getScope());
if(listType == null) {
listType = elmType;
} else {
if(!SymbolTypeInference.typeMatch(type, elementType)) {
throw new RuntimeException("Array type mismatch " + elementType + " does not match " + type + " " + valueList.toString(getProgram()));
if(!SymbolTypeInference.typeMatch(listType, elmType)) {
SymbolType intersectType = SymbolTypeInference.intersectTypes(listType, elmType);
if(intersectType==null) {
// No overlap between list type and element type
throw new RuntimeException("Array type " + listType + " does not match element type" + elmType + ". Array: " + valueList.toString(getProgram()));
} else {
listType = intersectType;
}
}
}
elements.add(constantValue);
} else {
allConstant = false;
elementType = null;
listType = null;
break;
}
}
if(allConstant && elementType != null) {
ConstantValue constant = new ConstantArrayList(elements, elementType);
if(allConstant && listType != null) {
ConstantValue constant = new ConstantArrayList(elements, listType);
constants.put(variable, constant);
}
}

View File

@ -45,6 +45,11 @@ public class TestPrograms {
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false);
}
@Test
public void testKeyboard() throws IOException, URISyntaxException {
compileAndCompare("test-keyboard");
}
@Test
public void testC64DtvColor() throws IOException, URISyntaxException {
compileAndCompare("c64dtv-color");

View File

@ -0,0 +1,119 @@
import "c64.kc"
// CIA#1 Port A: keyboard matrix columns and joystick #2
const byte* CIA1_PORT_A = $dc00;
// CIA#1 Port B: keyboard matrix rows and joystick #1.
const byte* CIA1_PORT_B = $dc01;
// CIA #1 Port A data direction register.
const byte* CIA1_PORT_A_DDR = $dc02;
// CIA #1 Port B data direction register.
const byte* CIA1_PORT_B_DDR = $dc03;
void main() {
// Clear screen
for(byte* sc = $400; sc<$400+1000;sc++) {
*sc = ' ';
}
// Init keyboard
keyboard_init();
while(true) {
do {} while (*RASTER!=$ff);
byte* screen = $400;
// Read & print keyboard matrix
for(byte row : 0..7) {
byte row_pressed_bits = keyboard_matrix_read(row);
for(byte col : 0..7) {
if( (row_pressed_bits & $80) != 0) {
screen[col] = '1';
} else {
screen[col] = '0';
}
row_pressed_bits = row_pressed_bits << 1;
}
screen = screen + 40;
}
screen = screen + 40;
// Checks specific chars
byte[] chars = { '@', 'a', 'b', 'c', 'd', 'e' };
for( byte i : 0..5 ) {
byte ch = chars[i];
if(keyboard_char_pressed(ch)!=0) {
screen[i] = ch;
} else {
screen[i] = ' ';
}
}
}
}
// Initialize keyboard reading by setting CIA#$ Data Direction Registers
void keyboard_init() {
// Keyboard Matrix Columns Write Mode
*CIA1_PORT_A_DDR = $ff;
// Keyboard Matrix Columns Read Mode
*CIA1_PORT_B_DDR = $00;
}
// Determines whether a specific key representing a PETSCII char is currently pressed
// Returns zero if the key is not pressed and a non-zero value if the key is currently pressed
byte keyboard_char_pressed(byte ch) {
return keyboard_matrix_read(keyboard_matrix_row(ch)) & keyboard_matrix_col(ch);
}
// Keyboard row bits as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7)
byte[8] keyboard_row_bits = { %11111110, %11111101, %11111011, %11110111, %11101111, %11011111, %10111111, %01111111 };
// Read a single row of the keyboard matrix
// The row ID (0-7) of the keyboard matrix row to read. See the C64 key matrix for row IDs.
// Returns the keys pressed on the row as bits according to the C64 key matrix.
byte keyboard_matrix_read(byte rowid) {
*CIA1_PORT_A = keyboard_row_bits[rowid];
byte row_pressed_bits = ~*CIA1_PORT_B;
return row_pressed_bits;
}
// Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7)
byte[] keyboard_matrix_col_bitmask = { %00000001, %00000010, %00000100, %00001000, %00010000, %00100000, %01000000, %10000000 };
// The keyboard matrix position of each PETSCII char between $00 and $3f (lower case)
// Matrix positions are encoded as column ID (0-7) in the high nibble and row ID (0-7) in the low nibble %ccccrrrr
byte[] keyboard_matrix_chars = {
// CR Char
$65, // ($00) @
$21, // ($01) a
$43, // ($02) b
$42, // ($03) c
$22, // ($04) d
$61 // ($05) e
};
// Get the row ID of the keyboard matrix row containing a specific PETSCII char
// Returns the row ID (0-7) of the keyboard matrix row containing the passed char
// The row ID is suitable for passing to keyboard_matrix_read(rowid)
byte keyboard_matrix_row(byte ch) {
return keyboard_matrix_chars[ch] & $f;
}
// Get the column bit mask of the keyboard matrix column containing a specific PETSCII char.
// Returns the keyboard matrix column bit mask of the passed char.
// The returned bit is suitable for ANDing with the result of keyboard_matrix_read(rowid) to determine if the corresponding key is pressed.
byte keyboard_matrix_col(byte ch) {
byte col_id = keyboard_matrix_chars[ch] >>4;
return keyboard_matrix_col_bitmask[col_id];
}
// C64 Keyboard Matrix Reference - from http://codebase64.org/doku.php?id=base:reading_the_keyboard
// +----+----------------------+-------------------------------------------------------------------------------------------------------+
// | | Write | Read $dc01 (PETSCII code in parenthesis): |
// |row:| $dc00: row bits +------------+------------+------------+------------+------------+------------+------------+------------+
// | | | BIT 7 | BIT 6 | BIT 5 | BIT 4 | BIT 3 | BIT 2 | BIT 1 | BIT 0 |
// +----+----------------------+------------+------------+------------+------------+------------+------------+------------+------------+
// |0. | #%11111110 (254/$fe) | DOWN ($ )| F5 ($ )| F3 ($ )| F1 ($ )| F7 ($ )| RIGHT ($ )| RETURN($ )|DELETE ($ )|
// |1. | #%11111101 (253/$fd) |LEFT-SH($ )| e ($05)| s ($13)| z ($1a)| 4 ($34)| a ($01)| w ($17)| 3 ($33)|
// |2. | #%11111011 (251/$fb) | x ($18)| t ($14)| f ($06)| c ($03)| 6 ($36)| d ($04)| r ($12)| 5 ($35)|
// |3. | #%11110111 (247/$f7) | v ($16)| u ($15)| h ($08)| b ($02)| 8 ($38)| g ($07)| y ($19)| 7 ($37)|
// |4. | #%11101111 (239/$ef) | n ($0e)| o ($0f)| k ($0b)| m ($0d)| 0 ($30)| j ($0a)| i ($09)| 9 ($39)|
// |5. | #%11011111 (223/$df) | , ($2c)| @ ($00)| : ($3a)| . ($2e)| - ($2d)| l ($0c)| p ($10)| + ($2b)|
// |6. | #%10111111 (191/$bf) | / ($2f)| ^ ($1e)| = ($3d)|RGHT-SH($ )| HOME ($ )| ; ($3b)| * ($2a)| £ ($1c)|
// |7. | #%01111111 (127/$7f) | STOP ($ )| q ($11)|COMMODR($ )| SPACE ($20)| 2 ($32)|CONTROL($ )| <- ($1f)| 1 ($31)|
// +----+----------------------+------------+------------+------------+------------+------------+------------+------------+------------+

View File

@ -0,0 +1,151 @@
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label RASTER = $d012
.label CIA1_PORT_A = $dc00
.label CIA1_PORT_B = $dc01
.label CIA1_PORT_A_DDR = $dc02
.label CIA1_PORT_B_DDR = $dc03
jsr main
main: {
.label sc = 2
.label row_pressed_bits = 4
.label screen = 2
.label ch = 4
lda #<$400
sta sc
lda #>$400
sta sc+1
b1:
lda #' '
ldy #0
sta (sc),y
inc sc
bne !+
inc sc+1
!:
lda sc+1
cmp #>$400+$3e8
bcc b1
bne !+
lda sc
cmp #<$400+$3e8
bcc b1
!:
jsr keyboard_init
b5:
lda RASTER
cmp #$ff
bne b5
lda #<$400
sta screen
lda #>$400
sta screen+1
ldx #0
b6:
txa
jsr keyboard_matrix_read
sta row_pressed_bits
ldy #0
b7:
lda #$80
and row_pressed_bits
cmp #0
beq b8
lda #'1'
sta (screen),y
b9:
asl row_pressed_bits
iny
cpy #8
bne b7
lda screen
clc
adc #$28
sta screen
bcc !+
inc screen+1
!:
inx
cpx #8
bne b6
lda screen
clc
adc #$28
sta screen
bcc !+
inc screen+1
!:
ldx #0
b10:
lda chars,x
sta ch
jsr keyboard_char_pressed
cmp #0
beq b11
txa
tay
lda ch
sta (screen),y
b12:
inx
cpx #6
bne b10
jmp b5
b11:
txa
tay
lda #' '
sta (screen),y
jmp b12
b8:
lda #'0'
sta (screen),y
jmp b9
chars: .byte '@', 'a', 'b', 'c', 'd', 'e'
}
keyboard_char_pressed: {
.label _1 = 5
.label ch = 4
ldy ch
jsr keyboard_matrix_row
jsr keyboard_matrix_read
sta _1
ldy ch
jsr keyboard_matrix_col
and _1
rts
}
keyboard_matrix_col: {
lda keyboard_matrix_chars,y
lsr
lsr
lsr
lsr
tay
lda keyboard_matrix_col_bitmask,y
rts
}
keyboard_matrix_read: {
tay
lda keyboard_row_bits,y
sta CIA1_PORT_A
lda CIA1_PORT_B
eor #$ff
rts
}
keyboard_matrix_row: {
lda keyboard_matrix_chars,y
and #$f
rts
}
keyboard_init: {
lda #$ff
sta CIA1_PORT_A_DDR
lda #0
sta CIA1_PORT_B_DDR
rts
}
keyboard_row_bits: .byte $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f
keyboard_matrix_col_bitmask: .byte 1, 2, 4, 8, $10, $20, $40, $80
keyboard_matrix_chars: .byte $65, $21, $43, $42, $22, $61

View File

@ -0,0 +1,138 @@
@begin: scope:[] from
[0] phi() [ ] ( )
to:@6
@6: scope:[] from @begin
[1] phi() [ ] ( )
[2] call main param-assignment [ ] ( )
to:@end
@end: scope:[] from @6
[3] phi() [ ] ( )
main: scope:[main] from @6
[4] phi() [ ] ( main:2 [ ] )
to:main::@1
main::@1: scope:[main] from main main::@1
[5] (byte*) main::sc#2 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1024 main::@1/(byte*) main::sc#1 ) [ main::sc#2 ] ( main:2 [ main::sc#2 ] )
[6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] )
[7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 [ main::sc#1 ] ( main:2 [ main::sc#1 ] )
[8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] )
to:main::@13
main::@13: scope:[main] from main::@1
[9] phi() [ ] ( main:2 [ ] )
[10] call keyboard_init param-assignment [ ] ( main:2 [ ] )
to:main::@2
main::@2: scope:[main] from main::@12 main::@13
[11] if(true) goto main::@5 [ ] ( main:2 [ ] )
to:main::@return
main::@return: scope:[main] from main::@2
[12] return [ ] ( main:2 [ ] )
to:@return
main::@5: scope:[main] from main::@2 main::@5
[13] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5 [ ] ( main:2 [ ] )
to:main::@6
main::@6: scope:[main] from main::@19 main::@5
[14] (byte*) main::screen#12 ← phi( main::@5/((byte*))(word/signed word/dword/signed dword) 1024 main::@19/(byte*) main::screen#1 ) [ main::row#2 main::screen#12 ] ( main:2 [ main::row#2 main::screen#12 ] )
[14] (byte) main::row#2 ← phi( main::@5/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@19/(byte) main::row#1 ) [ main::row#2 main::screen#12 ] ( main:2 [ main::row#2 main::screen#12 ] )
[15] (byte) keyboard_matrix_read::rowid#0 ← (byte) main::row#2 [ main::row#2 main::screen#12 keyboard_matrix_read::rowid#0 ] ( main:2 [ main::row#2 main::screen#12 keyboard_matrix_read::rowid#0 ] )
[16] call keyboard_matrix_read param-assignment [ main::row#2 main::screen#12 keyboard_matrix_read::return#2 ] ( main:2 [ main::row#2 main::screen#12 keyboard_matrix_read::return#2 ] )
[17] (byte) keyboard_matrix_read::return#0 ← (byte) keyboard_matrix_read::return#2 [ main::row#2 main::screen#12 keyboard_matrix_read::return#0 ] ( main:2 [ main::row#2 main::screen#12 keyboard_matrix_read::return#0 ] )
to:main::@26
main::@26: scope:[main] from main::@6
[18] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#0 [ main::row#2 main::screen#12 main::row_pressed_bits#0 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#0 ] )
to:main::@7
main::@7: scope:[main] from main::@26 main::@9
[19] (byte) main::col#2 ← phi( main::@26/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@9/(byte) main::col#1 ) [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] )
[19] (byte) main::row_pressed_bits#2 ← phi( main::@26/(byte) main::row_pressed_bits#0 main::@9/(byte) main::row_pressed_bits#1 ) [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] )
[20] (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 main::$5 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 main::$5 ] )
[21] if((byte~) main::$5==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@8 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] )
to:main::@17
main::@17: scope:[main] from main::@7
[22] *((byte*) main::screen#12 + (byte) main::col#2) ← (byte) '1' [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] )
to:main::@9
main::@9: scope:[main] from main::@17 main::@8
[23] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::row#2 main::screen#12 main::col#2 main::row_pressed_bits#1 ] ( main:2 [ main::row#2 main::screen#12 main::col#2 main::row_pressed_bits#1 ] )
[24] (byte) main::col#1 ← ++ (byte) main::col#2 [ main::row#2 main::screen#12 main::row_pressed_bits#1 main::col#1 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#1 main::col#1 ] )
[25] if((byte) main::col#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@7 [ main::row#2 main::screen#12 main::row_pressed_bits#1 main::col#1 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#1 main::col#1 ] )
to:main::@19
main::@19: scope:[main] from main::@9
[26] (byte*) main::screen#1 ← (byte*) main::screen#12 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::row#2 main::screen#1 ] ( main:2 [ main::row#2 main::screen#1 ] )
[27] (byte) main::row#1 ← ++ (byte) main::row#2 [ main::row#1 main::screen#1 ] ( main:2 [ main::row#1 main::screen#1 ] )
[28] if((byte) main::row#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@6 [ main::row#1 main::screen#1 ] ( main:2 [ main::row#1 main::screen#1 ] )
to:main::@20
main::@20: scope:[main] from main::@19
[29] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::screen#2 ] ( main:2 [ main::screen#2 ] )
to:main::@10
main::@10: scope:[main] from main::@12 main::@20
[30] (byte) main::i#2 ← phi( main::@12/(byte) main::i#1 main::@20/(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::screen#2 main::i#2 ] ( main:2 [ main::screen#2 main::i#2 ] )
[31] (byte) main::ch#0 ← *((const byte[]) main::chars#0 + (byte) main::i#2) [ main::screen#2 main::i#2 main::ch#0 ] ( main:2 [ main::screen#2 main::i#2 main::ch#0 ] )
[32] (byte) keyboard_char_pressed::ch#0 ← (byte) main::ch#0 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 ] ( main:2 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 ] )
[33] call keyboard_char_pressed param-assignment [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::return#1 ] ( main:2 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::return#1 ] )
[34] (byte) keyboard_char_pressed::return#0 ← (byte) keyboard_char_pressed::return#1 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::return#0 ] ( main:2 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::return#0 ] )
to:main::@27
main::@27: scope:[main] from main::@10
[35] (byte~) main::$13 ← (byte) keyboard_char_pressed::return#0 [ main::screen#2 main::i#2 main::ch#0 main::$13 ] ( main:2 [ main::screen#2 main::i#2 main::ch#0 main::$13 ] )
[36] if((byte~) main::$13==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@11 [ main::screen#2 main::i#2 main::ch#0 ] ( main:2 [ main::screen#2 main::i#2 main::ch#0 ] )
to:main::@21
main::@21: scope:[main] from main::@27
[37] *((byte*) main::screen#2 + (byte) main::i#2) ← (byte) main::ch#0 [ main::screen#2 main::i#2 ] ( main:2 [ main::screen#2 main::i#2 ] )
to:main::@12
main::@12: scope:[main] from main::@11 main::@21
[38] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::screen#2 main::i#1 ] ( main:2 [ main::screen#2 main::i#1 ] )
[39] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 6) goto main::@10 [ main::screen#2 main::i#1 ] ( main:2 [ main::screen#2 main::i#1 ] )
to:main::@2
main::@11: scope:[main] from main::@27
[40] *((byte*) main::screen#2 + (byte) main::i#2) ← (byte) ' ' [ main::screen#2 main::i#2 ] ( main:2 [ main::screen#2 main::i#2 ] )
to:main::@12
main::@8: scope:[main] from main::@7
[41] *((byte*) main::screen#12 + (byte) main::col#2) ← (byte) '0' [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#12 main::row_pressed_bits#2 main::col#2 ] )
to:main::@9
keyboard_char_pressed: scope:[keyboard_char_pressed] from main::@10
[42] (byte) keyboard_matrix_row::ch#0 ← (byte) keyboard_char_pressed::ch#0 [ keyboard_char_pressed::ch#0 keyboard_matrix_row::ch#0 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_row::ch#0 ] )
[43] call keyboard_matrix_row param-assignment [ keyboard_char_pressed::ch#0 keyboard_matrix_row::return#1 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_row::return#1 ] )
[44] (byte) keyboard_matrix_row::return#0 ← (byte) keyboard_matrix_row::return#1 [ keyboard_char_pressed::ch#0 keyboard_matrix_row::return#0 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_row::return#0 ] )
to:keyboard_char_pressed::@2
keyboard_char_pressed::@2: scope:[keyboard_char_pressed] from keyboard_char_pressed
[45] (byte) keyboard_matrix_read::rowid#1 ← (byte) keyboard_matrix_row::return#0 [ keyboard_char_pressed::ch#0 keyboard_matrix_read::rowid#1 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_read::rowid#1 ] )
[46] call keyboard_matrix_read param-assignment [ keyboard_matrix_read::return#2 keyboard_char_pressed::ch#0 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_matrix_read::return#2 keyboard_char_pressed::ch#0 ] )
[47] (byte) keyboard_matrix_read::return#1 ← (byte) keyboard_matrix_read::return#2 [ keyboard_char_pressed::ch#0 keyboard_matrix_read::return#1 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_read::return#1 ] )
to:keyboard_char_pressed::@3
keyboard_char_pressed::@3: scope:[keyboard_char_pressed] from keyboard_char_pressed::@2
[48] (byte~) keyboard_char_pressed::$1 ← (byte) keyboard_matrix_read::return#1 [ keyboard_char_pressed::ch#0 keyboard_char_pressed::$1 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_char_pressed::$1 ] )
[49] (byte) keyboard_matrix_col::ch#0 ← (byte) keyboard_char_pressed::ch#0 [ keyboard_char_pressed::$1 keyboard_matrix_col::ch#0 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::$1 keyboard_matrix_col::ch#0 ] )
[50] call keyboard_matrix_col param-assignment [ keyboard_char_pressed::$1 keyboard_matrix_col::return#1 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::$1 keyboard_matrix_col::return#1 ] )
[51] (byte) keyboard_matrix_col::return#0 ← (byte) keyboard_matrix_col::return#1 [ keyboard_char_pressed::$1 keyboard_matrix_col::return#0 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::$1 keyboard_matrix_col::return#0 ] )
to:keyboard_char_pressed::@4
keyboard_char_pressed::@4: scope:[keyboard_char_pressed] from keyboard_char_pressed::@3
[52] (byte~) keyboard_char_pressed::$2 ← (byte) keyboard_matrix_col::return#0 [ keyboard_char_pressed::$1 keyboard_char_pressed::$2 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::$1 keyboard_char_pressed::$2 ] )
[53] (byte) keyboard_char_pressed::return#1 ← (byte~) keyboard_char_pressed::$1 & (byte~) keyboard_char_pressed::$2 [ keyboard_char_pressed::return#1 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::return#1 ] )
to:keyboard_char_pressed::@return
keyboard_char_pressed::@return: scope:[keyboard_char_pressed] from keyboard_char_pressed::@4
[54] return [ keyboard_char_pressed::return#1 ] ( main:2::keyboard_char_pressed:33 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::return#1 ] )
to:@return
keyboard_matrix_col: scope:[keyboard_matrix_col] from keyboard_char_pressed::@3
[55] (byte) keyboard_matrix_col::col_id#0 ← *((const byte[]) keyboard_matrix_chars#0 + (byte) keyboard_matrix_col::ch#0) >> (byte/signed byte/word/signed word/dword/signed dword) 4 [ keyboard_matrix_col::col_id#0 ] ( main:2::keyboard_char_pressed:33::keyboard_matrix_col:50 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::$1 keyboard_matrix_col::col_id#0 ] )
[56] (byte) keyboard_matrix_col::return#1 ← *((const byte[]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_matrix_col::col_id#0) [ keyboard_matrix_col::return#1 ] ( main:2::keyboard_char_pressed:33::keyboard_matrix_col:50 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::$1 keyboard_matrix_col::return#1 ] )
to:keyboard_matrix_col::@return
keyboard_matrix_col::@return: scope:[keyboard_matrix_col] from keyboard_matrix_col
[57] return [ keyboard_matrix_col::return#1 ] ( main:2::keyboard_char_pressed:33::keyboard_matrix_col:50 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::$1 keyboard_matrix_col::return#1 ] )
to:@return
keyboard_matrix_read: scope:[keyboard_matrix_read] from keyboard_char_pressed::@2 main::@6
[58] (byte) keyboard_matrix_read::rowid#2 ← phi( keyboard_char_pressed::@2/(byte) keyboard_matrix_read::rowid#1 main::@6/(byte) keyboard_matrix_read::rowid#0 ) [ keyboard_matrix_read::rowid#2 ] ( main:2::keyboard_matrix_read:16 [ main::row#2 main::screen#12 keyboard_matrix_read::rowid#2 ] main:2::keyboard_char_pressed:33::keyboard_matrix_read:46 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_read::rowid#2 ] )
[59] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_row_bits#0 + (byte) keyboard_matrix_read::rowid#2) [ ] ( main:2::keyboard_matrix_read:16 [ main::row#2 main::screen#12 ] main:2::keyboard_char_pressed:33::keyboard_matrix_read:46 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 ] )
[60] (byte) keyboard_matrix_read::return#2 ← ~ *((const byte*) CIA1_PORT_B#0) [ keyboard_matrix_read::return#2 ] ( main:2::keyboard_matrix_read:16 [ main::row#2 main::screen#12 keyboard_matrix_read::return#2 ] main:2::keyboard_char_pressed:33::keyboard_matrix_read:46 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_read::return#2 ] )
to:keyboard_matrix_read::@return
keyboard_matrix_read::@return: scope:[keyboard_matrix_read] from keyboard_matrix_read
[61] return [ keyboard_matrix_read::return#2 ] ( main:2::keyboard_matrix_read:16 [ main::row#2 main::screen#12 keyboard_matrix_read::return#2 ] main:2::keyboard_char_pressed:33::keyboard_matrix_read:46 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_read::return#2 ] )
to:@return
keyboard_matrix_row: scope:[keyboard_matrix_row] from keyboard_char_pressed
[62] (byte) keyboard_matrix_row::return#1 ← *((const byte[]) keyboard_matrix_chars#0 + (byte) keyboard_matrix_row::ch#0) & (byte/signed byte/word/signed word/dword/signed dword) 15 [ keyboard_matrix_row::return#1 ] ( main:2::keyboard_char_pressed:33::keyboard_matrix_row:43 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_row::return#1 ] )
to:keyboard_matrix_row::@return
keyboard_matrix_row::@return: scope:[keyboard_matrix_row] from keyboard_matrix_row
[63] return [ keyboard_matrix_row::return#1 ] ( main:2::keyboard_char_pressed:33::keyboard_matrix_row:43 [ main::screen#2 main::i#2 main::ch#0 keyboard_char_pressed::ch#0 keyboard_matrix_row::return#1 ] )
to:@return
keyboard_init: scope:[keyboard_init] from main::@13
[64] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255 [ ] ( main:2::keyboard_init:10 [ ] )
[65] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( main:2::keyboard_init:10 [ ] )
to:keyboard_init::@return
keyboard_init::@return: scope:[keyboard_init] from keyboard_init
[66] return [ ] ( main:2::keyboard_init:10 [ ] )
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
(label) @6
(label) @begin
(label) @end
(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*) RASTER
(const byte*) RASTER#0 RASTER = ((byte*))(word/dword/signed dword) 53266
(byte()) keyboard_char_pressed((byte) keyboard_char_pressed::ch)
(byte~) keyboard_char_pressed::$1 $1 zp ZP_BYTE:5 0.8
(byte~) keyboard_char_pressed::$2 reg byte a 4.0
(label) keyboard_char_pressed::@2
(label) keyboard_char_pressed::@3
(label) keyboard_char_pressed::@4
(label) keyboard_char_pressed::@return
(byte) keyboard_char_pressed::ch
(byte) keyboard_char_pressed::ch#0 ch zp ZP_BYTE:4 13.125
(byte) keyboard_char_pressed::return
(byte) keyboard_char_pressed::return#0 reg byte a 202.0
(byte) keyboard_char_pressed::return#1 reg byte a 34.33333333333333
(void()) keyboard_init()
(label) keyboard_init::@return
(byte[]) keyboard_matrix_chars
(const byte[]) keyboard_matrix_chars#0 keyboard_matrix_chars = { (byte/signed byte/word/signed word/dword/signed dword) 101, (byte/signed byte/word/signed word/dword/signed dword) 33, (byte/signed byte/word/signed word/dword/signed dword) 67, (byte/signed byte/word/signed word/dword/signed dword) 66, (byte/signed byte/word/signed word/dword/signed dword) 34, (byte/signed byte/word/signed word/dword/signed dword) 97 }
(byte()) keyboard_matrix_col((byte) keyboard_matrix_col::ch)
(label) keyboard_matrix_col::@return
(byte) keyboard_matrix_col::ch
(byte) keyboard_matrix_col::ch#0 reg byte y 4.0
(byte) keyboard_matrix_col::col_id
(byte) keyboard_matrix_col::col_id#0 reg byte a 4.0
(byte) keyboard_matrix_col::return
(byte) keyboard_matrix_col::return#0 reg byte a 4.0
(byte) keyboard_matrix_col::return#1 reg byte a 1.3333333333333333
(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 202.0
(byte) keyboard_matrix_read::return#1 reg byte a 4.0
(byte) keyboard_matrix_read::return#2 reg byte a 26.25
(byte) keyboard_matrix_read::row_pressed_bits
(byte) keyboard_matrix_read::rowid
(byte) keyboard_matrix_read::rowid#0 reg byte a 202.0
(byte) keyboard_matrix_read::rowid#1 reg byte a 4.0
(byte) keyboard_matrix_read::rowid#2 reg byte a 105.0
(byte()) keyboard_matrix_row((byte) keyboard_matrix_row::ch)
(label) keyboard_matrix_row::@return
(byte) keyboard_matrix_row::ch
(byte) keyboard_matrix_row::ch#0 reg byte y 4.0
(byte) keyboard_matrix_row::return
(byte) keyboard_matrix_row::return#0 reg byte a 4.0
(byte) keyboard_matrix_row::return#1 reg byte a 1.3333333333333333
(byte[8]) keyboard_row_bits
(const byte[8]) keyboard_row_bits#0 keyboard_row_bits = { (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::$13 reg byte a 202.0
(byte~) main::$5 reg byte a 2002.0
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@12
(label) main::@13
(label) main::@17
(label) main::@19
(label) main::@2
(label) main::@20
(label) main::@21
(label) main::@26
(label) main::@27
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@9
(label) main::@return
(byte) main::ch
(byte) main::ch#0 ch zp ZP_BYTE:4 50.5
(byte[]) main::chars
(const byte[]) main::chars#0 chars = { (byte) '@', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e' }
(byte) main::col
(byte) main::col#1 reg byte y 1501.5
(byte) main::col#2 reg byte y 667.3333333333334
(byte) main::i
(byte) main::i#1 reg byte x 151.5
(byte) main::i#2 reg byte x 56.11111111111111
(byte) main::row
(byte) main::row#1 reg byte x 151.5
(byte) main::row#2 reg byte x 21.642857142857142
(byte) main::row_pressed_bits
(byte) main::row_pressed_bits#0 row_pressed_bits zp ZP_BYTE:4 202.0
(byte) main::row_pressed_bits#1 row_pressed_bits zp ZP_BYTE:4 667.3333333333334
(byte) main::row_pressed_bits#2 row_pressed_bits zp ZP_BYTE:4 620.8
(byte*) main::sc
(byte*) main::sc#1 sc zp ZP_WORD:2 16.5
(byte*) main::sc#2 sc zp ZP_WORD:2 16.5
(byte*) main::screen
(byte*) main::screen#1 screen zp ZP_WORD:2 71.0
(byte*) main::screen#12 screen zp ZP_WORD:2 169.53846153846155
(byte*) main::screen#2 screen zp ZP_WORD:2 17.75
zp ZP_WORD:2 [ main::sc#2 main::sc#1 main::screen#12 main::screen#1 main::screen#2 ]
reg byte x [ main::row#2 main::row#1 ]
zp ZP_BYTE:4 [ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 main::ch#0 keyboard_char_pressed::ch#0 ]
reg byte y [ main::col#2 main::col#1 ]
reg byte x [ main::i#2 main::i#1 ]
reg byte a [ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#1 keyboard_matrix_read::rowid#0 ]
reg byte a [ keyboard_matrix_read::return#0 ]
reg byte a [ main::$5 ]
reg byte a [ keyboard_char_pressed::return#0 ]
reg byte a [ main::$13 ]
reg byte y [ keyboard_matrix_row::ch#0 ]
reg byte a [ keyboard_matrix_row::return#0 ]
reg byte a [ keyboard_matrix_read::return#1 ]
zp ZP_BYTE:5 [ keyboard_char_pressed::$1 ]
reg byte y [ keyboard_matrix_col::ch#0 ]
reg byte a [ keyboard_matrix_col::return#0 ]
reg byte a [ keyboard_char_pressed::$2 ]
reg byte a [ keyboard_char_pressed::return#1 ]
reg byte a [ keyboard_matrix_col::col_id#0 ]
reg byte a [ keyboard_matrix_col::return#1 ]
reg byte a [ keyboard_matrix_read::return#2 ]
reg byte a [ keyboard_matrix_row::return#1 ]