1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-20 04:37:53 +00:00

Added all Plus/4 IC's and I/O addresses.

This commit is contained in:
jespergravgaard 2020-05-16 09:33:01 +02:00
parent 1d534dcc3d
commit 8d0d36e50b
32 changed files with 224 additions and 57 deletions

@ -32,7 +32,7 @@ char * const COLORRAM = 0xd800;
char * const COLS = 0xd800;
// Default address of screen character matrix
char * const DEFAULT_SCREEN = 0x0c00;
char * const DEFAULT_SCREEN = 0x0400;
// The CIA#1: keyboard matrix, joystick #1/#2
struct MOS6526_CIA * const CIA1 = 0xdc00;

@ -0,0 +1,19 @@
// MOS 6523 TRI-PORT INTERFACE (TPI)
// It has three dedicated 8-bit I/O ports which provide 24 individually programmable I/O lines
// Used in the Commodore 1551 disk drive
// http://archive.6502.org/datasheets/mos_6523_tpi_preliminary_nov_1980.pdf
struct MOS6523_TIA {
// Port A
char PORT_A;
// Port B
char PORT_B;
// Port C
char PORT_C;
// Port A data direction register.
char PORT_A_DDR;
// Port B data direction register.
char PORT_B_DDR;
// Port C data direction register.
char PORT_C_DDR;
}

@ -0,0 +1,7 @@
// MOS 6529 Single Port Interface (SPI aka PIO)
// I/O controller providing a single 8-bit digital bidirectional parallel I/O port.
// http://archive.6502.org/datasheets/mos_6529_spi.pdf
struct MOS6529_PIO {
char PORT;
};

@ -0,0 +1,15 @@
// MOS 6551 6551 ASYNCHRONOUS COMMUNICATION INTERFACE ADAPTER
// used for RS232
// http://archive.6502.org/datasheets/mos_6551_acia.pdf
// https://en.wikipedia.org/wiki/MOS_Technology_6551
struct MOS6551_ACIA {
// DATA port
char DATA;
// STATUS port
char STATUS;
// COMMAND port
char COMMAND;
// CONTROL port
char CONTROL;
};

@ -0,0 +1,18 @@
// MOS 7501/8501 MICROPROCESSOR
// https://en.wikipedia.org/wiki/MOS_Technology_6510
// The processor port of the MOS 7501 CPU
// http://hackjunk.com/2017/06/23/commodore-16-plus-4-8501-to-6510-cpu-conversion/
struct MOS7501_PORT {
// The on-chip processor port
// P0: SER DAT OUT
// P1: SER CLK OUT / CASS WRT
// P2: SER ATN OUT
// P3: CASS MOTOR
// P4: CASS READ
// P6: SER CLK IN
// P7: SER DAT IN
char PORT;
// The data direction of the port
char DDR;
};

@ -1,8 +1,16 @@
// Plus/4 / Commodore 16 registers and memory layout
// http://zimmers.net/anonftp/pub/cbm/schematics/computers/plus4/264_Hardware_Spec.pdf
// http://www.zimmers.net/anonftp/pub/cbm/schematics/computers/plus4/Plus_4_Technical_Docs.pdf
// http://personalpages.tds.net/~rcarlsen/cbm/c16/C16_Service_Manual_314001-03_(1984_Oct).pdf
// https://www.floodgap.com/retrobits/ckb/secret/264memory.txt
#include <mos7360.h>
#include <mos6551.h>
#include <mos6529.h>
#include <mos7501.h>
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
struct MOS7360_TED * const TED = 0xff00;
// The processor port
// Used for serial I/O and controlling the cassette
struct MOS7501_PORT * const PROCESSOR_PORT = 0x00;
// Default address of screen luminance/color matrix
char * const DEFAULT_COLORRAM = 0x0800;
@ -10,3 +18,39 @@ char * const DEFAULT_COLORRAM = 0x0800;
// Default address of screen character matrix
char * const DEFAULT_SCREEN = 0x0c00;
// The ACIA used for RS232 (only on the Plus/4)
struct MOS6551_ACIA * const ACIA = 0xfd00;
// User Port PIO (P0-P7)
// Bit 2 (P2) is used to detect if play on cassette is pressed (CST sense)
struct MOS6529_PIO * const USER_PORT = 0xfd10;
// Keyboard Port PIO (P0-P7)
// The input latch is part of the TED.
struct MOS6529_PIO * const KEYBOARD_PORT = 0xfd30;
// ROM configuration for the machine, which normally has the BASIC and kernal ROMs enabled.
// The ROM configuration is adjusted by writing to the registers (the value is irrelevant).
// The upper portion of the kernal ROM at $FC00-$FCFF is always enabled no matter what the memory configuration, as are the I/O registers.
struct {
// $FDD0 enables or disables BASIC,
char BASIC;
// $FDD1 the low function ROM,
char FUNCTION_LOW;
// $FDD2 the low cartridge ROM,
char CARTRIDGE_LOW;
// $FDD3 is unused,
char UNUSED;
// $FDD4 the kernal,
char KERNAL;
// $FDD5 the high function ROM
char FUNCTION_HIGH;
// $FDD6 the high cartridge ROM.
char CARTRIDGE_HIGH;
} * const ROM_BANKING = 0xfdd0;
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
struct MOS7360_TED * const TED = 0xff00;

@ -57,7 +57,7 @@ char keyboard_matrix_any(void) {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
char keyboard_matrix_read(char rowid) {
CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid];
char row_pressed_bits = ~CIA1->PORT_B;

@ -822,7 +822,7 @@ keyboard_event_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -14505,7 +14505,7 @@ keyboard_event_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte zp($ef) rowid)
keyboard_matrix_read: {
.label return = $102
@ -21563,7 +21563,7 @@ keyboard_event_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// [217] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuxx
@ -29401,7 +29401,7 @@ keyboard_event_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -619,7 +619,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(Y) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -13315,7 +13315,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte zp($ce) rowid)
keyboard_matrix_read: {
.label return = $d2
@ -20087,7 +20087,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(Y) rowid)
keyboard_matrix_read: {
// [220] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuyy
@ -27042,7 +27042,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(Y) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -238,7 +238,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx

@ -5011,7 +5011,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
.label return = $47
.label return_1 = $44
@ -7096,7 +7096,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// [62] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx
@ -9369,7 +9369,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
// [62] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2

@ -215,7 +215,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx

@ -5358,7 +5358,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
.label return = $4f
.label return_1 = $4c
@ -7796,7 +7796,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// [67] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx
@ -10270,7 +10270,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
// [67] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2

@ -96,7 +96,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx

@ -3393,7 +3393,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
.label return = $2a
.label return_1 = $27
@ -5344,7 +5344,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// [29] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx
@ -7298,7 +7298,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
// [29] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2

@ -1505,7 +1505,7 @@ keyboard_event_scan: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -14667,7 +14667,7 @@ keyboard_event_scan: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte zp($c4) rowid)
keyboard_matrix_read: {
.label return = $d3
@ -19467,7 +19467,7 @@ keyboard_event_scan: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// [444] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuxx
@ -24612,7 +24612,7 @@ keyboard_event_scan: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -399,7 +399,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -2778,7 +2778,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte zp($31) rowid)
keyboard_matrix_read: {
.label return = $35
@ -3766,7 +3766,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// [111] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuxx
@ -5008,7 +5008,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -12,12 +12,12 @@
.const OFFSET_STRUCT_MOS7360_TED_BG_COLOR = $15
.const OFFSET_STRUCT_MOS7360_TED_BORDER_COLOR = $19
.const OFFSET_STRUCT_MOS7360_TED_RASTER_LO = $1d
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// Default address of screen luminance/color matrix
.label DEFAULT_COLORRAM = $800
// Default address of screen character matrix
.label DEFAULT_SCREEN = $c00
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// The random state variable
.label rand_state = 3
.segment Code

@ -239,6 +239,13 @@ main::@return: scope:[main] from main::@1
@end: scope:[] from @3
SYMBOL TABLE SSA
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(label) @1
(label) @2
(label) @3
@ -247,6 +254,11 @@ SYMBOL TABLE SSA
(const nomodify byte*) DEFAULT_COLORRAM = (byte*)(number) $800
(const nomodify byte*) DEFAULT_SCREEN = (byte*)(number) $c00
(const byte*) FADE[(number) $10] = { (byte) 2, (byte) $12, (byte) $22, (byte) $32, (byte) $42, (byte) $52, (byte) $62, (byte) $72, (byte) $76, (byte) $66, (byte) $56, (byte) $46, (byte) $36, (byte) $26, (byte) $16, (byte) 6 }
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
@ -279,6 +291,8 @@ SYMBOL TABLE SSA
(byte) MOS7360_TED::SOUND_CONTROL
(const byte*) MOS7360_TED::UNUSED[(number) $1d] = { fill( $1d, 0) }
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(const byte) OFFSET_STRUCT_MOS7360_TED_BG_COLOR = (byte) $15
(const byte) OFFSET_STRUCT_MOS7360_TED_BORDER_COLOR = (byte) $19
(const byte) OFFSET_STRUCT_MOS7360_TED_RASTER_LO = (byte) $1d
@ -520,9 +534,9 @@ Inlining cast (byte) main::y#4 ← (unumber)(number) $18
Inlining cast (byte) main::x#3 ← (unumber)(number) 0
Inlining cast (byte) main::x#4 ← (unumber)(number) $27
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (struct MOS7360_TED*) 65280
Simplifying constant pointer cast (byte*) 2048
Simplifying constant pointer cast (byte*) 3072
Simplifying constant pointer cast (struct MOS7360_TED*) 65280
Simplifying constant integer cast 0
Simplifying constant integer cast 7
Simplifying constant integer cast 9
@ -918,6 +932,18 @@ memset::@3: scope:[memset] from memset::@2
VARIABLE REGISTER WEIGHTS
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
@ -949,6 +975,8 @@ VARIABLE REGISTER WEIGHTS
(byte) MOS7360_TED::ROM_SWITCH
(byte) MOS7360_TED::SOUND_CONTROL
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(void()) main()
(word~) main::$10 202.0
(byte~) main::$12 202.0
@ -1113,12 +1141,12 @@ Target platform is plus4 / MOS6502X
.const OFFSET_STRUCT_MOS7360_TED_BG_COLOR = $15
.const OFFSET_STRUCT_MOS7360_TED_BORDER_COLOR = $19
.const OFFSET_STRUCT_MOS7360_TED_RASTER_LO = $1d
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// Default address of screen luminance/color matrix
.label DEFAULT_COLORRAM = $800
// Default address of screen character matrix
.label DEFAULT_SCREEN = $c00
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// The random state variable
.label rand_state = $27
// The random state variable
@ -1700,6 +1728,10 @@ Uplift Scope [rand] 2,002: zp[2]:37 [ rand::$0 ] 2,002: zp[2]:41 [ rand::$1 ] 2,
Uplift Scope [memset] 3,572.33: zp[2]:9 [ memset::dst#2 memset::dst#4 memset::dst#1 ] 183.67: zp[2]:49 [ memset::end#0 ] 143: zp[1]:8 [ memset::c#5 ] 0: zp[2]:6 [ memset::str#4 ]
Uplift Scope [] 1,501.5: zp[2]:39 [ rand_state#1 ] 1,501.5: zp[2]:43 [ rand_state#2 ] 325.72: zp[2]:4 [ rand_state#11 rand_state#3 ]
Uplift Scope [MOS7360_TED]
Uplift Scope [MOS6551_ACIA]
Uplift Scope [MOS6529_PIO]
Uplift Scope [MOS7501_PORT]
Uplift Scope [$0]
Uplift Scope [RADIX]
Uplifting [main] best 8346 combination reg byte x [ main::x#11 main::x#10 main::x#2 main::x#1 ] zp[1]:2 [ main::y#11 main::y#10 main::y#2 main::y#1 ] zp[2]:21 [ main::$5 ] zp[2]:13 [ main::$29 ] zp[2]:15 [ main::$30 ] zp[2]:17 [ main::$3 ] zp[2]:23 [ main::$6 ] reg byte a [ main::$9 ] zp[2]:31 [ main::$10 ] reg byte a [ main::$12 ] reg byte a [ main::$13 ] zp[1]:36 [ main::$18 ] zp[2]:11 [ main::$24 ] zp[1]:33 [ main::rnd#0 ] zp[1]:25 [ main::cnt#0 ] zp[2]:26 [ main::$8 ] zp[2]:19 [ main::offset#0 ]
@ -1708,6 +1740,10 @@ Uplifting [rand] best 8346 combination zp[2]:37 [ rand::$0 ] zp[2]:41 [ rand::$1
Uplifting [memset] best 8327 combination zp[2]:9 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:49 [ memset::end#0 ] reg byte x [ memset::c#5 ] zp[2]:6 [ memset::str#4 ]
Uplifting [] best 8327 combination zp[2]:39 [ rand_state#1 ] zp[2]:43 [ rand_state#2 ] zp[2]:4 [ rand_state#11 rand_state#3 ]
Uplifting [MOS7360_TED] best 8327 combination
Uplifting [MOS6551_ACIA] best 8327 combination
Uplifting [MOS6529_PIO] best 8327 combination
Uplifting [MOS7501_PORT] best 8327 combination
Uplifting [$0] best 8327 combination
Uplifting [RADIX] best 8327 combination
Attempting to uplift remaining variables inzp[1]:2 [ main::y#11 main::y#10 main::y#2 main::y#1 ]
Uplifting [main] best 8327 combination zp[1]:2 [ main::y#11 main::y#10 main::y#2 main::y#1 ]
@ -1756,12 +1792,12 @@ ASSEMBLER BEFORE OPTIMIZATION
.const OFFSET_STRUCT_MOS7360_TED_BG_COLOR = $15
.const OFFSET_STRUCT_MOS7360_TED_BORDER_COLOR = $19
.const OFFSET_STRUCT_MOS7360_TED_RASTER_LO = $1d
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// Default address of screen luminance/color matrix
.label DEFAULT_COLORRAM = $800
// Default address of screen character matrix
.label DEFAULT_SCREEN = $c00
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// The random state variable
.label rand_state = 3
// @begin
@ -2295,12 +2331,24 @@ Removing unreachable instruction jmp __b6
Succesful ASM optimization Pass5UnreachableCodeElimination
FINAL SYMBOL TABLE
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(label) @1
(label) @begin
(label) @end
(const nomodify byte*) DEFAULT_COLORRAM = (byte*) 2048
(const nomodify byte*) DEFAULT_SCREEN = (byte*) 3072
(const byte*) FADE[(number) $10] = { (byte) 2, (byte) $12, (byte) $22, (byte) $32, (byte) $42, (byte) $52, (byte) $62, (byte) $72, (byte) $76, (byte) $66, (byte) $56, (byte) $46, (byte) $36, (byte) $26, (byte) $16, (byte) 6 }
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
@ -2333,6 +2381,8 @@ FINAL SYMBOL TABLE
(byte) MOS7360_TED::SOUND_CONTROL
(const byte*) MOS7360_TED::UNUSED[(number) $1d] = { fill( $1d, 0) }
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(const byte) OFFSET_STRUCT_MOS7360_TED_BG_COLOR = (byte) $15
(const byte) OFFSET_STRUCT_MOS7360_TED_BORDER_COLOR = (byte) $19
(const byte) OFFSET_STRUCT_MOS7360_TED_RASTER_LO = (byte) $1d
@ -2459,12 +2509,12 @@ Score: 6721
.const OFFSET_STRUCT_MOS7360_TED_BG_COLOR = $15
.const OFFSET_STRUCT_MOS7360_TED_BORDER_COLOR = $19
.const OFFSET_STRUCT_MOS7360_TED_RASTER_LO = $1d
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// Default address of screen luminance/color matrix
.label DEFAULT_COLORRAM = $800
// Default address of screen character matrix
.label DEFAULT_SCREEN = $c00
// The TED chip controlling video and sound on the Plus/4 and Commodore 16
.label TED = $ff00
// The random state variable
.label rand_state = 3
// @begin

@ -1,9 +1,21 @@
(byte) $0::BASIC
(byte) $0::CARTRIDGE_HIGH
(byte) $0::CARTRIDGE_LOW
(byte) $0::FUNCTION_HIGH
(byte) $0::FUNCTION_LOW
(byte) $0::KERNAL
(byte) $0::UNUSED
(label) @1
(label) @begin
(label) @end
(const nomodify byte*) DEFAULT_COLORRAM = (byte*) 2048
(const nomodify byte*) DEFAULT_SCREEN = (byte*) 3072
(const byte*) FADE[(number) $10] = { (byte) 2, (byte) $12, (byte) $22, (byte) $32, (byte) $42, (byte) $52, (byte) $62, (byte) $72, (byte) $76, (byte) $66, (byte) $56, (byte) $46, (byte) $36, (byte) $26, (byte) $16, (byte) 6 }
(byte) MOS6529_PIO::PORT
(byte) MOS6551_ACIA::COMMAND
(byte) MOS6551_ACIA::CONTROL
(byte) MOS6551_ACIA::DATA
(byte) MOS6551_ACIA::STATUS
(byte) MOS7360_TED::BG_COLOR
(byte) MOS7360_TED::BG_COLOR1
(byte) MOS7360_TED::BG_COLOR2
@ -36,6 +48,8 @@
(byte) MOS7360_TED::SOUND_CONTROL
(const byte*) MOS7360_TED::UNUSED[(number) $1d] = { fill( $1d, 0) }
(byte) MOS7360_TED::VSCAN_POS
(byte) MOS7501_PORT::DDR
(byte) MOS7501_PORT::PORT
(const byte) OFFSET_STRUCT_MOS7360_TED_BG_COLOR = (byte) $15
(const byte) OFFSET_STRUCT_MOS7360_TED_BORDER_COLOR = (byte) $19
(const byte) OFFSET_STRUCT_MOS7360_TED_RASTER_LO = (byte) $1d

@ -102,7 +102,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -974,7 +974,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte zp($b) rowid)
keyboard_matrix_read: {
.label return = $f
@ -1293,7 +1293,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// [40] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuxx
@ -1749,7 +1749,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -272,7 +272,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx

@ -5597,7 +5597,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
.label return = $2b
.label return_1 = $28
@ -7702,7 +7702,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// [80] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx
@ -10275,7 +10275,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
// [80] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2

@ -54,7 +54,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx

@ -651,7 +651,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
.label return = 7
.label return_1 = 4
@ -829,7 +829,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// [20] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2
lda keyboard_matrix_row_bitmask+keyboard_key_pressed.rowidx
@ -1128,7 +1128,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]
// [20] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask+(const byte) keyboard_key_pressed::rowidx#0) -- _deref_pbuc1=_deref_pbuc2

@ -234,7 +234,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]

@ -1545,7 +1545,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte zp($b) rowid)
keyboard_matrix_read: {
.label return = $1b
@ -2083,7 +2083,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// [58] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1) ← *((const byte*) keyboard_matrix_row_bitmask + (byte) keyboard_matrix_read::rowid#2) -- _deref_pbuc1=pbuc2_derefidx_vbuxx
@ -2825,7 +2825,7 @@ keyboard_key_pressed: {
// 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.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
// CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid]