fix: improper lifetime for *Arm7tdmi ptr in Bus
*Arm7tdmi ptr is now assigned one scope up so that it lives as least as long as Bus does
This commit is contained in:
parent
85e8ca9146
commit
75ba9a4bf9
|
@ -60,6 +60,10 @@ pub fn deinit(self: Self) void {
|
||||||
self.ppu.deinit();
|
self.ppu.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn attach(self: *Self, cpu: *Arm7tdmi) void {
|
||||||
|
self.cpu = cpu;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handleDMATransfers(self: *Self) void {
|
pub fn handleDMATransfers(self: *Self) void {
|
||||||
while (self.isDmaRunning()) {
|
while (self.isDmaRunning()) {
|
||||||
if (self.dma._1.step(self)) continue;
|
if (self.dma._1.step(self)) continue;
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub const Arm7tdmi = struct {
|
||||||
binary_log: bool,
|
binary_log: bool,
|
||||||
|
|
||||||
pub fn init(alloc: Allocator, sched: *Scheduler, paths: FilePaths) !Self {
|
pub fn init(alloc: Allocator, sched: *Scheduler, paths: FilePaths) !Self {
|
||||||
var cpu: Arm7tdmi = .{
|
return Self{
|
||||||
.r = [_]u32{0x00} ** 16,
|
.r = [_]u32{0x00} ** 16,
|
||||||
.sched = sched,
|
.sched = sched,
|
||||||
.bus = try Bus.init(alloc, sched, paths),
|
.bus = try Bus.init(alloc, sched, paths),
|
||||||
|
@ -93,8 +93,6 @@ pub const Arm7tdmi = struct {
|
||||||
.log_buf = undefined,
|
.log_buf = undefined,
|
||||||
.binary_log = false,
|
.binary_log = false,
|
||||||
};
|
};
|
||||||
cpu.bus.cpu = &cpu;
|
|
||||||
return cpu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
|
|
|
@ -80,6 +80,8 @@ pub fn main() anyerror!void {
|
||||||
const paths = .{ .bios = bios_path, .rom = rom_path, .save = save_path };
|
const paths = .{ .bios = bios_path, .rom = rom_path, .save = save_path };
|
||||||
var cpu = try Arm7tdmi.init(alloc, &scheduler, paths);
|
var cpu = try Arm7tdmi.init(alloc, &scheduler, paths);
|
||||||
defer cpu.deinit();
|
defer cpu.deinit();
|
||||||
|
|
||||||
|
cpu.bus.attach(&cpu);
|
||||||
cpu.fastBoot();
|
cpu.fastBoot();
|
||||||
|
|
||||||
// Initialize SDL Audio
|
// Initialize SDL Audio
|
||||||
|
|
Loading…
Reference in New Issue