feat(bus): implement Gameboy Advance MMIO

This commit is contained in:
2022-01-02 02:36:06 -06:00
parent b63eb2dabc
commit 65c3dd722c
5 changed files with 132 additions and 53 deletions

View File

@@ -34,17 +34,17 @@ pub fn comptimeHalfSignedDataTransfer(comptime P: bool, comptime U: bool, compti
},
0b01 => {
// LDRH
const halfword = bus.readHalfWord(address);
const halfword = bus.read16(address);
cpu.r[rd] = @as(u32, halfword);
},
0b10 => {
// LDRSB
const byte = bus.readByte(address);
const byte = bus.read8(address);
cpu.r[rd] = util.u32SignExtend(8, @as(u32, byte));
},
0b11 => {
// LDRSH
const halfword = bus.readHalfWord(address);
const halfword = bus.read16(address);
cpu.r[rd] = util.u32SignExtend(16, @as(u32, halfword));
},
}
@@ -53,8 +53,8 @@ pub fn comptimeHalfSignedDataTransfer(comptime P: bool, comptime U: bool, compti
// STRH
const src = @truncate(u16, cpu.r[rd]);
bus.writeHalfWord(address + 2, src);
bus.writeHalfWord(address, src);
bus.write16(address + 2, src);
bus.write16(address, src);
} else {
std.debug.panic("TODO Figure out if this is also SWP", .{});
}