I/O

DMA Registers (0xFFFF_FFA2-0xFFFF_FFAF)

These registers are used for direct memory access (DMA), which allows virtual drives to access the main system memory independently from the CPU, allowing the CPU to perform other tasks in the meantime.

A DMA transfer of one drive block (512 bytes) takes 128 cycles, which is much faster than individually reading/writing the values!

Note that the MMU locks all memory reads and writes during the 128 cycles of a DMA transfer.

The boot values of these registers are not defined! the values of these registers must be set explicitly.

DMA Read Registers

  • 0xFFFF_FFA2: Initiate DMA Read
    Write to this write-only address to initiate a DMA read.
    Ensure that the parameters in the registers below have been set before initiation!

  • 0xFFFF_FFA3: Drive Number
    The number of the drive to be read from.

  • 0xFFFF_FFA4: Block Number
    The number of the drive block to read.

  • 0xFFFF_FFA5-0xFFFF_FFA8: RAM Read Start Address
    The drive block data is read into RAM starting at this address (little-endian).

DMA Write Registers

  • 0xFFFF_FFA9: Initiate DMA Write
    Write to this write-only address to initiate a DMA write.
    Ensure that the parameters in the registers below have been set before initiation!

  • 0xFFFF_FFAA: Drive Number
    The number of the drive to be written to.

  • 0xFFFF_FFAB: Block Number
    The number of the drive block to be overwritten.

  • 0xFFFF_FFAC-0xFFFF_FFAF: RAM Write Start Address
    The data in RAM starting at this address (little-endian) overwrites the chosen drive block.

VRAM DMA Registers (0xFFFF_FFB0-0xFFFF_FFB9)

Not yet implemented... VRAM DMA coming soon!

Error Register (0xFFFF_FFBA)

Bits in the error register get set if a non-fatal error occurs during program execution. This register is read-only, and reading the register resets all the bits back to 0.

This register is typically used for error handling and user-friendly error reports.

Error Types:

-IllegalRead: This bit is set when a program attempts to read from write-only memory or an unused memory address.

-IllegalWrite: This bit is set when a program attempts to write to read-only memory or an unused memory address.

Each bit corresponds to a different error:

7 6 5 4 3 210
IllegalWriteIllegalRead

Manual Frame Updates (0xFFFF_FFBB-0xFFFF_FFBD)

Some programs may want to slow down the frame rate until the frame is ready to be displayed. Do to this, programs can write to write-only address 0xFFFF_FFBD to enable manual frame updates.

When manual frame updates are enabled, the screen will not display the new VRAM state until the program writes to write-only address 0xFFFF_FFBB. This triggers a manual frame update, updating the screen to reflect the new VRAM state.

While manual frame updates prevent issues with flickering or invisible graphics, they can lead to choppy or inconsistent frames, so manual frame updates should only be enabled when needed. Ideally, programs should be aware of their timings and/or update the screen before the next frame.

Manual frame updates can be disabled again by writing to the write-only address 0xFFFF_FFBC.

Keyboard Input (0xFFFF_FFBE - 0xFFFF_FFFD)

The keyboard register consists of 64 bytes of memory located at the range [0xFFFF_FFBE-0xFFFF_FFFD]. Each byte corresponds to a physical key on the computer keyboard. When a key's bit is set, that key is currently being pressed. When a key's bit is reset, that key is not currently being pressed.

The order of bits within the keyboard register matches the order of SDL2 Scancodes. As stated above, the key name represents the physical key on the keyboard- the resulting value is handled entirely by the given program.

Key NameBit Index
A4
B5
C6
D7
E8
F9
G10
H11
I12
J13
K14
L15
M16
N17
O18
P19
Q20
R21
S22
T23
U24
V25
W26
X27
Y28
Z29
130
231
332
433
534
635
736
837
938
039
RETURN40
ESCAPE41
BACKSPACE42
TAB43
SPACE44
MINUS45
EQUALS46
LEFTBRACKET47
RIGHTBRACKET48
BACKSLASH49
NONUSHASH50
SEMICOLON51
APOSTROPHE52
GRAVE53
COMMA54
PERIOD55
SLASH56
CAPSLOCK57
F158
F259
F360
F461
F562
F663
F764
F865
F966
F1067
F1168
F1269
PRINTSCREEN70
SCROLLLOCK71
PAUSE72
INSERT73
HOME74
PAGEUP75
DELETE76
END77
PAGEDOWN78
RIGHT79
LEFT80
DOWN81
UP82
NUMLOCKCLEAR83
KP_DIVIDE84
KP_MULTIPLY85
KP_PLUS86
KP_MINUS87
KP_ENTER88
KP_189
KP_290
KP_391
KP_492
KP_593
KP_694
KP_795
KP_896
KP_997
KP_098
KP_PERIOD99
NONUSBACKSLASH100
APPLICATION101
POWER102
KP_EQUALS103
F13104
F14105
F15106
F16107
F17108
F18109
F19110
F20111
F21112
F22113
F23114
F24115
EXECUTE116
HELP117
MENU118
SELECT119
STOP120
AGAIN121
UNDO122
CUT123
COPY124
PASTE125
FIND126
MUTE127
VOLUMEUP128
VOLUMEDOWN129
KP_COMMA133
KP_EQUALSAS400134
INTERNATIONAL1135
INTERNATIONAL2136
INTERNATIONAL3137
INTERNATIONAL4138
INTERNATIONAL5139
INTERNATIONAL6140
INTERNATIONAL7141
INTERNATIONAL8142
INTERNATIONAL9143
LANG1144
LANG2145
LANG3146
LANG4147
LANG5148
LANG6149
LANG7150
LANG8151
LANG9152
ALTERASE153
SYSREQ154
CANCEL155
CLEAR156
PRIOR157
RETURN2158
SEPARATOR159
OUT160
OPER161
CLEARAGAIN162
CRSEL163
EXSEL164
KP_00176
KP_000177
THOUSANDSSEPARATOR178
DECIMALSSEPARATOR179
CURRENCYUNIT180
CURRENCYSUBUNIT181
KP_LEFTPAREN182
KP_RIGHTPAREN183
KP_LEFTBRACE184
KP_RIGHTBRACE185
KP_TAB186
KP_BACKSPACE187
KP_A188
KP_B189
KP_C190
KP_D191
KP_E192
KP_F193
KP_XOR194
KP_POWER195
KP_PERCENT196
KP_LESS197
KP_GREATER198
KP_AMPERSAND199
KP_DBLAMPERSAND200
KP_VERTICALBAR201
KP_DBLVERTICALBAR202
KP_COLON203
KP_HASH204
KP_SPACE205
KP_AT206
KP_EXCLAM207
KP_MEMSTORE208
KP_MEMRECALL209
KP_MEMCLEAR210
KP_MEMADD211
KP_MEMSUBTRACT212
KP_MEMMULTIPLY213
KP_MEMDIVIDE214
KP_PLUSMINUS215
KP_CLEAR216
KP_CLEARENTRY217
KP_BINARY218
KP_OCTAL219
KP_DECIMAL220
KP_HEXADECIMAL221
LCTRL224
LSHIFT225
LALT226
LGUI227
RCTRL228
RSHIFT229
RALT230
RGUI231
MODE257
AUDIONEXT258
AUDIOPREV259
AUDIOSTOP260
AUDIOPLAY261
AUDIOMUTE262
MEDIASELECT263
WWW264
MAIL265
CALCULATOR266
COMPUTER267
AC_SEARCH268
AC_HOME269
AC_BACK270
AC_FORWARD271
AC_STOP272
AC_REFRESH273
AC_BOOKMARKS274
BRIGHTNESSDOWN275
BRIGHTNESSUP276
DISPLAYSWITCH277
KBDILLUMTOGGLE278
KBDILLUMDOWN279
KBDILLUMUP280
EJECT281
SLEEP282
APP1283
APP2284
AUDIOREWIND285
AUDIOFASTFORWARD286
SOFTLEFT287
SOFTRIGHT288
CALL289
ENDCALL290