-
Notifications
You must be signed in to change notification settings - Fork 0
Keyboard Integration
Rudolf Stepan edited this page Jun 3, 2026
·
2 revisions
Keyboard input is routed through VIA6522 Port A and exposed to 6502 software via memory-mapped reads. SDL keyboard events feed an internal FIFO queue in the VIA implementation.
- VIA base: typically
$8800 - ORA (
$8801): read next key byte - DDRA (
$8803): set to input mode ($00) - IFR (
$880D): CA1 bit indicates key available - IER (
$880E): enable CA1 interrupt if desired
VIA_ORA = $8801
VIA_DDRA = $8803
VIA_IFR = $880D
LDA #$00
STA VIA_DDRA
.wait:
LDA VIA_IFR
AND #$02
BEQ .wait
LDA VIA_ORA#include <stdint.h>
#define VIA_ORA (*(volatile uint8_t *)0x8801)
#define VIA_DDRA (*(volatile uint8_t *)0x8803)
#define VIA_IFR (*(volatile uint8_t *)0x880D)
static inline void kb_init(void) {
VIA_DDRA = 0x00;
}
static inline uint8_t kb_getc_blocking(void) {
while ((VIA_IFR & 0x02u) == 0) {
}
return VIA_ORA;
}- ASCII letters and numbers
- common punctuation
- Enter (
0x0D) - Backspace (
0x08) - ESC closes emulator window
Generated from 6502-sbc-emulator Markdown documentation. FPGA hardware track: 6502-sbc-fpga (FPGA Wiki).