~sircmpwn/hdmg

1e06eb75675f08c8988fad32335bdced726cdca5 — Drew DeVault 1 year, 6 months ago 4b1b594
dmg: initial commit
2 files changed, 46 insertions(+), 0 deletions(-)

A dmg/cart.ha
A dmg/mmu.ha
A dmg/cart.ha => dmg/cart.ha +3 -0
@@ 0,0 1,3 @@
export type cart = struct {
	rom0: [16384]u8,
};

A dmg/mmu.ha => dmg/mmu.ha +43 -0
@@ 0,0 1,43 @@
use sm83;

export type mmu = struct {
	sm83::mmu,
	cart: *cart,
	vram: [0x2000]u8,
	ram0: [0x1000]u8,
	ram1: [0x1000]u8,
	sprites: [0xA0]u8,
};

// Creates a new DMG MMU.
export fn new_mmu(cart: *cart) *mmu = {
	return alloc(mmu {
		readb = &mmu_readb,
		readw = &mmu_readw,
		writeb = &mmu_writeb,
		writew = &mmu_writew,
		cart = cart,
		...
	});
};

// Frees a DMG MMU.
export fn mmu_free(mmu: *mmu) void = {
	free(mmu);
};

fn mmu_readb(mmu: *sm83::mmu, addr: u16) u8 = {
	abort(); // TODO
};

fn mmu_readw(mmu: *sm83::mmu, addr: u16) u16 = {
	abort(); // TODO
};

fn mmu_writeb(mmu: *sm83::mmu, addr: u16, b: u8) void = {
	abort(); // TODO
};

fn mmu_writew(mmu: *sm83::mmu, addr: u16, w: u16) void = {
	abort(); // TODO
};