Add a GUI to ZBA #7
|
@ -128,6 +128,21 @@ pub fn reset(self: *Self) void {
|
||||||
self.io.reset();
|
self.io.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn replaceGamepak(self: *Self, file_path: []const u8) !void {
|
||||||
|
// Note: `save_path` isn't owned by `Backup`
|
||||||
|
const save_path = self.pak.backup.save_path;
|
||||||
|
self.pak.deinit();
|
||||||
|
|
||||||
|
self.pak = try GamePak.init(self.allocator, self.cpu, file_path, save_path);
|
||||||
|
|
||||||
|
const read_ptr: *[table_len]?*const anyopaque = @constCast(self.read_table);
|
||||||
|
const write_ptrs: [2]*[table_len]?*anyopaque = .{ @constCast(self.write_tables[0]), @constCast(self.write_tables[1]) };
|
||||||
|
|
||||||
|
self.fillReadTable(read_ptr);
|
||||||
|
self.fillWriteTable(u32, write_ptrs[0]);
|
||||||
|
self.fillWriteTable(u8, write_ptrs[1]);
|
||||||
|
}
|
||||||
|
|
||||||
fn fillReadTable(self: *Self, table: *[table_len]?*const anyopaque) void {
|
fn fillReadTable(self: *Self, table: *[table_len]?*const anyopaque) void {
|
||||||
const vramMirror = @import("ppu/Vram.zig").mirror;
|
const vramMirror = @import("ppu/Vram.zig").mirror;
|
||||||
|
|
||||||
|
|
|
@ -249,3 +249,8 @@ pub fn reset(cpu: *Arm7tdmi) void {
|
||||||
cpu.bus.reset();
|
cpu.bus.reset();
|
||||||
cpu.reset();
|
cpu.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn replaceGamepak(cpu: *Arm7tdmi, file_path: []const u8) !void {
|
||||||
|
try cpu.bus.replaceGamepak(file_path);
|
||||||
|
reset(cpu);
|
||||||
|
}
|
||||||
|
|
|
@ -70,7 +70,10 @@ pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void {
|
||||||
defer nfd.freePath(file_path);
|
defer nfd.freePath(file_path);
|
||||||
log.info("user chose: \"{s}\"", .{file_path});
|
log.info("user chose: \"{s}\"", .{file_path});
|
||||||
|
|
||||||
// emu.loadRom(cpu, file_path);
|
emu.replaceGamepak(cpu, file_path) catch |e| {
|
||||||
|
log.err("failed to replace GamePak: {}", .{e});
|
||||||
|
break :blk;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue