Initial Commit

This commit is contained in:
Kilian committed 2026-08-26 23:09:04 +02:00
commit 1f4390a42b
25 files changed
+13462

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#include "memoryMap.h"
uint8_t readMemory(uint16_t address, uint8_t *ram, uint8_t *rom) {
if (address < RAM_SIZE || address >= IO_BASE + IO_SIZE) { // FIXME: Expanded for debug
return ram[address];
} else if (address < RAM_SIZE + IO_SIZE) {
uint16_t _address = address - RAM_SIZE;
switch (_address) {
case KEYBOARD_ADDRESS: {
return getChar();
}
default:
break;
}
return 0;
} else {
return rom[address - RAM_SIZE - IO_SIZE];
}
}
void writeMemory(uint16_t address, uint8_t value, uint8_t *ram, uint8_t *rom) {
if (address < RAM_SIZE) {
ram[address] = value;
} else if (address < RAM_SIZE + IO_SIZE || address >= IO_BASE + IO_SIZE) { // FIXME: Expanded for debug
uint16_t _address = address - RAM_SIZE;
switch (_address) {
case SCREEN_ADDRESS: {
putChar(value);
break;
}
default:
break;
}
} else {
rom[address - RAM_SIZE - IO_SIZE] = value;
}
}
uint8_t readStack(uint8_t address, uint8_t *ram) { return ram[0x100 + address]; }
void writeStack(uint8_t address, uint8_t value, uint8_t *ram) { ram[0x100 + address] = value; }