LD, LDH, WRAM, and HRAM

This commit is contained in:
2025-01-30 21:59:05 -07:00
parent 1bf98447a3
commit 022c24dd35
11 changed files with 458 additions and 58 deletions

30
lib/ram.c Normal file
View File

@ -0,0 +1,30 @@
#include <ram.h>
typedef struct {
u8 wram[0x2000];
u8 hram[0x80];
} ram_context;
static ram_context ctx;
u8 wram_read(u16 address) {
address -= 0xC000;
return ctx.wram[address];
}
void wram_write(u16 address, u8 value){
address -= 0xC000;
ctx.wram[address] = value;
}
u8 hram_read(u16 address){
address -= 0xFF80;
return ctx.hram[address];
}
void hram_write(u16 address, u8 value){
address -= 0xFF80;
ctx.hram[address] = value;
}