add nes cartridge subsystem and 41 ines mapper variants

This commit is contained in:
2026-08-14 06:48:16 +02:00
parent 42f20478bd
commit 04fb7bcc1f
41 changed files with 5042 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
const types = @import("types.zig");
const Mirroring = types.Mirroring;
const Nrom = @This();
prg_16k: bool,
mirroring_mode: Mirroring,
pub fn init(
prg_size: usize,
_mirroring: Mirroring,
) Nrom {
return .{
.prg_16k = prg_size == 0x4000,
.mirroring_mode = _mirroring,
};
}
pub fn cpuMapRead(
self: *const Nrom,
address: u16,
) ?usize {
if (address < 0x8000)
return null;
const offset =
@as(usize, address) - 0x8000;
return if (self.prg_16k)
offset & 0x3fff
else
offset;
}
pub fn cpuWrite(
_: *Nrom,
_: u16,
_: u8,
) void {
// NROM has no mapper registers.
}
pub fn ppuMapRead(
_: *const Nrom,
address: u16,
) ?usize {
if (address >= 0x2000)
return null;
return address;
}
pub fn ppuMapWrite(
_: *const Nrom,
address: u16,
) ?usize {
if (address >= 0x2000)
return null;
return address;
}
pub fn mirroring(
self: *const Nrom,
) Mirroring {
return self.mirroring_mode;
}
pub fn irqAsserted(_: *const Nrom) bool {
return false;
}