98 lines
2.6 KiB
Zig
98 lines
2.6 KiB
Zig
const std = @import("std");
|
|
const common = @import("../common.zig");
|
|
const Mirroring = common.Mirroring;
|
|
|
|
pub const Nrom = @import("nrom.zig");
|
|
pub const Mmc1 = @import("mmc1.zig");
|
|
pub const Uxrom = @import("uxrom.zig");
|
|
pub const Cnrom = @import("cnrom.zig");
|
|
pub const Mmc3 = @import("mmc3.zig");
|
|
pub const Axrom = @import("axrom.zig");
|
|
pub const ColorDreams = @import("color_dreams.zig");
|
|
pub const Unrom512 = @import("unrom512.zig");
|
|
pub const Bnrom = @import("bnrom.zig");
|
|
pub const Gxrom = @import("gxrom.zig");
|
|
pub const Camerica = @import("camerica.zig");
|
|
pub const Mmc2 = @import("mmc2.zig");
|
|
pub const Mmc4 = @import("mmc4.zig");
|
|
pub const Action53 = @import("action53.zig");
|
|
pub const Mapper180 = @import("mapper180.zig");
|
|
|
|
pub const Mapper = union(enum) {
|
|
nrom: Nrom,
|
|
mmc1: Mmc1,
|
|
uxrom: Uxrom,
|
|
cnrom: Cnrom,
|
|
mmc3: Mmc3,
|
|
axrom: Axrom,
|
|
color_dreams: ColorDreams,
|
|
unrom512: Unrom512,
|
|
bnrom: Bnrom,
|
|
gxrom: Gxrom,
|
|
camerica: Camerica,
|
|
mmc2: Mmc2,
|
|
mmc4: Mmc4,
|
|
action53: Action53,
|
|
mapper180: Mapper180,
|
|
|
|
pub fn cpuRead(self: *const Mapper, address: u16, prg_rom: []const u8, prg_ram: []const u8) ?u8 {
|
|
return switch (self.*) {
|
|
inline else => |*m| m.cpuRead(address, prg_rom, prg_ram),
|
|
};
|
|
}
|
|
|
|
pub fn cpuWrite(self: *Mapper, address: u16, value: u8, prg_ram: []u8) bool {
|
|
return switch (self.*) {
|
|
inline else => |*m| m.cpuWrite(address, value, prg_ram),
|
|
};
|
|
}
|
|
|
|
pub fn ppuRead(self: *const Mapper, address: u16, chr_rom: []const u8, chr_ram: []const u8, chr_is_ram: bool) ?u8 {
|
|
return switch (self.*) {
|
|
inline else => |*m| m.ppuRead(address, chr_rom, chr_ram, chr_is_ram),
|
|
};
|
|
}
|
|
|
|
pub fn ppuWrite(self: *Mapper, address: u16, value: u8, chr_ram: []u8, chr_is_ram: bool) bool {
|
|
return switch (self.*) {
|
|
inline else => |*m| m.ppuWrite(address, value, chr_ram, chr_is_ram),
|
|
};
|
|
}
|
|
|
|
pub fn mirroring(self: *const Mapper) Mirroring {
|
|
return switch (self.*) {
|
|
inline else => |*m| m.mirroring(),
|
|
};
|
|
}
|
|
|
|
pub fn irqLine(self: *const Mapper) bool {
|
|
return switch (self.*) {
|
|
inline else => |*m| m.irqLine(),
|
|
};
|
|
}
|
|
|
|
pub fn notifyPpuAddress(self: *Mapper, address: u16) void {
|
|
switch (self.*) {
|
|
inline else => |*m| m.notifyPpuAddress(address),
|
|
}
|
|
}
|
|
};
|
|
|
|
test {
|
|
_ = Nrom;
|
|
_ = Mmc1;
|
|
_ = Uxrom;
|
|
_ = Cnrom;
|
|
_ = Mmc3;
|
|
_ = Axrom;
|
|
_ = ColorDreams;
|
|
_ = Unrom512;
|
|
_ = Bnrom;
|
|
_ = Gxrom;
|
|
_ = Camerica;
|
|
_ = Mmc2;
|
|
_ = Mmc4;
|
|
_ = Action53;
|
|
_ = Mapper180;
|
|
}
|