fix(bus): restrict Game ROM and VRAM to a 16-bit bus
This commit is contained in:
parent
46c694d95a
commit
abe2fc431e
|
@ -98,7 +98,6 @@ pub const Bus = struct {
|
|||
|
||||
pub fn write16(self: *@This(), addr: u32, halfword: u16) void {
|
||||
// TODO: write16 can write to GamePak Flash
|
||||
|
||||
switch (addr) {
|
||||
// General Internal Memory
|
||||
0x0200_0000...0x0203_FFFF => std.debug.panic("[Bus:16] write 0x{X:} to 0x{X:} in IWRAM", .{ halfword, addr }),
|
||||
|
|
|
@ -23,7 +23,7 @@ pub const GamePak = struct {
|
|||
}
|
||||
|
||||
pub inline fn get32(self: *const @This(), idx: usize) u32 {
|
||||
return (@as(u32, self.buf[idx + 3]) << 24) | (@as(u32, self.buf[idx + 2]) << 16) | (@as(u32, self.buf[idx + 1]) << 8) | (@as(u32, self.buf[idx]));
|
||||
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
||||
}
|
||||
|
||||
pub inline fn get16(self: *const @This(), idx: usize) u16 {
|
||||
|
|
|
@ -32,14 +32,12 @@ const Vram = struct {
|
|||
}
|
||||
|
||||
pub inline fn get32(self: *const @This(), idx: usize) u32 {
|
||||
return (@as(u32, self.buf[idx + 3]) << 24) | (@as(u32, self.buf[idx + 2]) << 16) | (@as(u32, self.buf[idx + 1]) << 8) | (@as(u32, self.buf[idx]));
|
||||
return (@as(u32, self.get16(idx + 2)) << 16) | @as(u32, self.get16(idx));
|
||||
}
|
||||
|
||||
pub inline fn set32(self: *@This(), idx: usize, word: u32) void {
|
||||
self.buf[idx + 3] = @truncate(u8, word >> 24);
|
||||
self.buf[idx + 2] = @truncate(u8, word >> 16);
|
||||
self.buf[idx + 1] = @truncate(u8, word >> 8);
|
||||
self.buf[idx] = @truncate(u8, word);
|
||||
self.set16(idx + 2, @truncate(u16, word >> 16));
|
||||
self.set16(idx, @truncate(u16, word));
|
||||
}
|
||||
|
||||
pub inline fn get16(self: *const @This(), idx: usize) u16 {
|
||||
|
|
Loading…
Reference in New Issue