Compare commits
No commits in common. "6a798d2c9d8dba15e58652155ae16459660c32ed" and "aa52bb5917cf88264e4153f91fa706a471236923" have entirely different histories.
6a798d2c9d
...
aa52bb5917
10
src/Gui.zig
10
src/Gui.zig
|
@ -136,13 +136,12 @@ pub fn initAudio(self: *Self, apu: *Apu) void {
|
||||||
self.audio.?.play();
|
self.audio.?.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
if (self.audio) |*aud| aud.deinit();
|
if (self.audio) |aud| aud.deinit();
|
||||||
SDL.SDL_DestroyTexture(self.texture);
|
SDL.SDL_DestroyTexture(self.texture);
|
||||||
SDL.SDL_DestroyRenderer(self.renderer);
|
SDL.SDL_DestroyRenderer(self.renderer);
|
||||||
SDL.SDL_DestroyWindow(self.window);
|
SDL.SDL_DestroyWindow(self.window);
|
||||||
SDL.SDL_Quit();
|
SDL.SDL_Quit();
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Audio = struct {
|
const Audio = struct {
|
||||||
|
@ -169,9 +168,8 @@ const Audio = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *This) void {
|
fn deinit(this: This) void {
|
||||||
SDL.SDL_CloseAudioDevice(self.device);
|
SDL.SDL_CloseAudioDevice(this.device);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn play(this: *This) void {
|
pub fn play(this: *This) void {
|
||||||
|
|
|
@ -49,8 +49,8 @@ io: Io,
|
||||||
cpu: ?*Arm7tdmi,
|
cpu: ?*Arm7tdmi,
|
||||||
sched: *Scheduler,
|
sched: *Scheduler,
|
||||||
|
|
||||||
pub fn init(self: *Self, alloc: Allocator, sched: *Scheduler, cpu: *Arm7tdmi, paths: FilePaths) !void {
|
pub fn init(alloc: Allocator, sched: *Scheduler, paths: FilePaths) !Self {
|
||||||
self.* = .{
|
return Self{
|
||||||
.pak = try GamePak.init(alloc, paths.rom, paths.save),
|
.pak = try GamePak.init(alloc, paths.rom, paths.save),
|
||||||
.bios = try Bios.init(alloc, paths.bios),
|
.bios = try Bios.init(alloc, paths.bios),
|
||||||
.ppu = try Ppu.init(alloc, sched),
|
.ppu = try Ppu.init(alloc, sched),
|
||||||
|
@ -60,34 +60,21 @@ pub fn init(self: *Self, alloc: Allocator, sched: *Scheduler, cpu: *Arm7tdmi, pa
|
||||||
.dma = createDmaTuple(),
|
.dma = createDmaTuple(),
|
||||||
.tim = createTimerTuple(sched),
|
.tim = createTimerTuple(sched),
|
||||||
.io = Io.init(),
|
.io = Io.init(),
|
||||||
.cpu = cpu,
|
.cpu = null,
|
||||||
.sched = sched,
|
.sched = sched,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn init(alloc: Allocator, sched: *Scheduler, paths: FilePaths) !Self {
|
pub fn deinit(self: Self) void {
|
||||||
// return Self{
|
|
||||||
// .pak = try GamePak.init(alloc, paths.rom, paths.save),
|
|
||||||
// .bios = try Bios.init(alloc, paths.bios),
|
|
||||||
// .ppu = try Ppu.init(alloc, sched),
|
|
||||||
// .apu = Apu.init(sched),
|
|
||||||
// .iwram = try Iwram.init(alloc),
|
|
||||||
// .ewram = try Ewram.init(alloc),
|
|
||||||
// .dma = createDmaTuple(),
|
|
||||||
// .tim = createTimerTuple(sched),
|
|
||||||
// .io = Io.init(),
|
|
||||||
// .cpu = null,
|
|
||||||
// .sched = sched,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
|
||||||
self.iwram.deinit();
|
self.iwram.deinit();
|
||||||
self.ewram.deinit();
|
self.ewram.deinit();
|
||||||
self.pak.deinit();
|
self.pak.deinit();
|
||||||
self.bios.deinit();
|
self.bios.deinit();
|
||||||
self.ppu.deinit();
|
self.ppu.deinit();
|
||||||
self.* = undefined;
|
}
|
||||||
|
|
||||||
|
pub fn attach(self: *Self, cpu: *Arm7tdmi) void {
|
||||||
|
self.cpu = cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dbgRead(self: *const Self, comptime T: type, address: u32) T {
|
pub fn dbgRead(self: *const Self, comptime T: type, address: u32) T {
|
||||||
|
|
|
@ -27,9 +27,8 @@ pub fn init(alloc: Allocator, maybe_path: ?[]const u8) !Self {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
if (self.buf) |buf| self.alloc.free(buf);
|
if (self.buf) |buf| self.alloc.free(buf);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(self: *Self, comptime T: type, r15: u32, addr: u32) T {
|
pub fn read(self: *Self, comptime T: type, r15: u32, addr: u32) T {
|
||||||
|
|
|
@ -17,9 +17,8 @@ pub fn init(alloc: Allocator) !Self {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
||||||
|
|
|
@ -58,10 +58,9 @@ inline fn isLarge(self: *const Self) bool {
|
||||||
return self.buf.len > 0x100_0000;
|
return self.buf.len > 0x100_0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
self.backup.deinit();
|
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
self.* = undefined;
|
self.backup.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(self: *Self, comptime T: type, address: u32) T {
|
pub fn read(self: *Self, comptime T: type, address: u32) T {
|
||||||
|
|
|
@ -17,9 +17,8 @@ pub fn init(alloc: Allocator) !Self {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
||||||
|
|
|
@ -74,10 +74,9 @@ pub const Backup = struct {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
if (self.save_path) |path| self.writeSaveToDisk(self.alloc, path) catch |e| log.err("Failed to write save: {}", .{e});
|
if (self.save_path) |path| self.writeSaveToDisk(self.alloc, path) catch |e| log.err("Failed to write save: {}", .{e});
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn loadSaveFromDisk(self: *Self, allocator: Allocator, path: []const u8) !void {
|
fn loadSaveFromDisk(self: *Self, allocator: Allocator, path: []const u8) !void {
|
||||||
|
|
|
@ -250,7 +250,7 @@ pub const Arm7tdmi = struct {
|
||||||
|
|
||||||
logger: ?Logger,
|
logger: ?Logger,
|
||||||
|
|
||||||
pub fn init(sched: *Scheduler, bus: *Bus, log_file: ?std.fs.File) Self {
|
pub fn init(sched: *Scheduler, bus: *Bus) Self {
|
||||||
return Self{
|
return Self{
|
||||||
.r = [_]u32{0x00} ** 16,
|
.r = [_]u32{0x00} ** 16,
|
||||||
.sched = sched,
|
.sched = sched,
|
||||||
|
@ -260,10 +260,14 @@ pub const Arm7tdmi = struct {
|
||||||
.banked_fiq = [_]u32{0x00} ** 10,
|
.banked_fiq = [_]u32{0x00} ** 10,
|
||||||
.banked_r = [_]u32{0x00} ** 12,
|
.banked_r = [_]u32{0x00} ** 12,
|
||||||
.banked_spsr = [_]PSR{.{ .raw = 0x0000_0000 }} ** 5,
|
.banked_spsr = [_]PSR{.{ .raw = 0x0000_0000 }} ** 5,
|
||||||
.logger = if (log_file) |file| Logger.init(file) else null,
|
.logger = null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn attach(self: *Self, log_file: std.fs.File) void {
|
||||||
|
self.logger = Logger.init(log_file);
|
||||||
|
}
|
||||||
|
|
||||||
inline fn bankedIdx(mode: Mode, kind: BankedKind) usize {
|
inline fn bankedIdx(mode: Mode, kind: BankedKind) usize {
|
||||||
const idx: usize = switch (mode) {
|
const idx: usize = switch (mode) {
|
||||||
.User, .System => 0,
|
.User, .System => 0,
|
||||||
|
|
106
src/core/ppu.zig
106
src/core/ppu.zig
|
@ -43,23 +43,26 @@ pub const Ppu = struct {
|
||||||
framebuf: FrameBuffer,
|
framebuf: FrameBuffer,
|
||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
|
|
||||||
scanline_sprites: *[128]?Sprite,
|
scanline_sprites: [128]?Sprite,
|
||||||
scanline: Scanline,
|
scanline: Scanline,
|
||||||
|
|
||||||
pub fn init(allocator: Allocator, sched: *Scheduler) !Self {
|
pub fn init(alloc: Allocator, sched: *Scheduler) !Self {
|
||||||
// Queue first Hblank
|
// Queue first Hblank
|
||||||
sched.push(.Draw, 240 * 4);
|
sched.push(.Draw, 240 * 4);
|
||||||
|
|
||||||
const sprites = try allocator.create([128]?Sprite);
|
const framebufs = try alloc.alloc(u8, (framebuf_pitch * height) * 2);
|
||||||
sprites.* = [_]?Sprite{null} ** 128;
|
std.mem.set(u8, framebufs, 0);
|
||||||
|
|
||||||
|
const scanline_buf = try alloc.alloc(?u16, width * 2);
|
||||||
|
std.mem.set(?u16, scanline_buf, null);
|
||||||
|
|
||||||
return Self{
|
return Self{
|
||||||
.vram = try Vram.init(allocator),
|
.vram = try Vram.init(alloc),
|
||||||
.palette = try Palette.init(allocator),
|
.palette = try Palette.init(alloc),
|
||||||
.oam = try Oam.init(allocator),
|
.oam = try Oam.init(alloc),
|
||||||
.sched = sched,
|
.sched = sched,
|
||||||
.framebuf = try FrameBuffer.init(allocator),
|
.framebuf = FrameBuffer.init(framebufs),
|
||||||
.alloc = allocator,
|
.alloc = alloc,
|
||||||
|
|
||||||
// Registers
|
// Registers
|
||||||
.win = Window.init(),
|
.win = Window.init(),
|
||||||
|
@ -72,19 +75,17 @@ pub const Ppu = struct {
|
||||||
.bldalpha = .{ .raw = 0x0000 },
|
.bldalpha = .{ .raw = 0x0000 },
|
||||||
.bldy = .{ .raw = 0x0000 },
|
.bldy = .{ .raw = 0x0000 },
|
||||||
|
|
||||||
.scanline = try Scanline.init(allocator),
|
.scanline = Scanline.init(scanline_buf),
|
||||||
.scanline_sprites = sprites,
|
.scanline_sprites = [_]?Sprite{null} ** 128,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
self.alloc.destroy(self.scanline_sprites);
|
self.framebuf.deinit(self.alloc);
|
||||||
self.framebuf.deinit();
|
self.scanline.deinit(self.alloc);
|
||||||
self.scanline.deinit();
|
|
||||||
self.vram.deinit();
|
self.vram.deinit();
|
||||||
self.palette.deinit();
|
self.palette.deinit();
|
||||||
self.oam.deinit();
|
self.oam.deinit();
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setBgOffsets(self: *Self, comptime n: u2, word: u32) void {
|
pub fn setBgOffsets(self: *Self, comptime n: u2, word: u32) void {
|
||||||
|
@ -398,7 +399,7 @@ pub const Ppu = struct {
|
||||||
// Reset Current Scanline Pixel Buffer and list of fetched sprites
|
// Reset Current Scanline Pixel Buffer and list of fetched sprites
|
||||||
// in prep for next scanline
|
// in prep for next scanline
|
||||||
self.scanline.reset();
|
self.scanline.reset();
|
||||||
std.mem.set(?Sprite, self.scanline_sprites, null);
|
std.mem.set(?Sprite, &self.scanline_sprites, null);
|
||||||
},
|
},
|
||||||
0x1 => {
|
0x1 => {
|
||||||
const fb_base = framebuf_pitch * @as(usize, scanline);
|
const fb_base = framebuf_pitch * @as(usize, scanline);
|
||||||
|
@ -425,7 +426,7 @@ pub const Ppu = struct {
|
||||||
// Reset Current Scanline Pixel Buffer and list of fetched sprites
|
// Reset Current Scanline Pixel Buffer and list of fetched sprites
|
||||||
// in prep for next scanline
|
// in prep for next scanline
|
||||||
self.scanline.reset();
|
self.scanline.reset();
|
||||||
std.mem.set(?Sprite, self.scanline_sprites, null);
|
std.mem.set(?Sprite, &self.scanline_sprites, null);
|
||||||
},
|
},
|
||||||
0x2 => {
|
0x2 => {
|
||||||
const fb_base = framebuf_pitch * @as(usize, scanline);
|
const fb_base = framebuf_pitch * @as(usize, scanline);
|
||||||
|
@ -451,7 +452,7 @@ pub const Ppu = struct {
|
||||||
// Reset Current Scanline Pixel Buffer and list of fetched sprites
|
// Reset Current Scanline Pixel Buffer and list of fetched sprites
|
||||||
// in prep for next scanline
|
// in prep for next scanline
|
||||||
self.scanline.reset();
|
self.scanline.reset();
|
||||||
std.mem.set(?Sprite, self.scanline_sprites, null);
|
std.mem.set(?Sprite, &self.scanline_sprites, null);
|
||||||
},
|
},
|
||||||
0x3 => {
|
0x3 => {
|
||||||
const vram_base = width * @sizeOf(u16) * @as(usize, scanline);
|
const vram_base = width * @sizeOf(u16) * @as(usize, scanline);
|
||||||
|
@ -640,9 +641,8 @@ const Palette = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *Self) void {
|
fn deinit(self: Self) void {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
||||||
|
@ -689,9 +689,8 @@ const Vram = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *Self) void {
|
fn deinit(self: Self) void {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
||||||
|
@ -750,9 +749,8 @@ const Oam = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *Self) void {
|
fn deinit(self: Self) void {
|
||||||
self.alloc.free(self.buf);
|
self.alloc.free(self.buf);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
pub fn read(self: *const Self, comptime T: type, address: usize) T {
|
||||||
|
@ -1215,38 +1213,35 @@ fn copyToSpriteBuffer(bldcnt: io.BldCnt, scanline: *Scanline, x: u9, bgr555: u16
|
||||||
const Scanline = struct {
|
const Scanline = struct {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
layers: [2][]?u16,
|
buf: [2][]?u16,
|
||||||
buf: []?u16,
|
original: []?u16,
|
||||||
|
|
||||||
allocator: Allocator,
|
fn init(buf: []?u16) Self {
|
||||||
|
std.debug.assert(buf.len == width * 2);
|
||||||
|
|
||||||
fn init(allocator: Allocator) !Self {
|
const top_slice = buf[0..][0..width];
|
||||||
const buf = try allocator.alloc(?u16, width * 2); // Top & Bottom Scanline
|
const btm_slice = buf[width..][0..width];
|
||||||
std.mem.set(?u16, buf, null);
|
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
// Top & Bototm Layers
|
.buf = [_][]?u16{ top_slice, btm_slice },
|
||||||
.layers = [_][]?u16{ buf[0..][0..width], buf[width..][0..width] },
|
.original = buf,
|
||||||
.buf = buf,
|
|
||||||
.allocator = allocator,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset(self: *Self) void {
|
fn reset(self: *Self) void {
|
||||||
std.mem.set(?u16, self.buf, null);
|
std.mem.set(?u16, self.original, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *Self) void {
|
fn deinit(self: Self, alloc: Allocator) void {
|
||||||
self.allocator.free(self.buf);
|
alloc.free(self.original);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn top(self: *Self) []?u16 {
|
fn top(self: *Self) []?u16 {
|
||||||
return self.layers[0];
|
return self.buf[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn btm(self: *Self) []?u16 {
|
fn btm(self: *Self) []?u16 {
|
||||||
return self.layers[1];
|
return self.buf[1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1254,36 +1249,31 @@ const Scanline = struct {
|
||||||
const FrameBuffer = struct {
|
const FrameBuffer = struct {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
layers: [2][]u8,
|
buf: [2][]u8,
|
||||||
buf: []u8,
|
original: []u8,
|
||||||
current: u1,
|
current: u1,
|
||||||
|
|
||||||
allocator: Allocator,
|
|
||||||
|
|
||||||
// TODO: Rename
|
// TODO: Rename
|
||||||
const Device = enum {
|
const Device = enum {
|
||||||
Emulator,
|
Emulator,
|
||||||
Renderer,
|
Renderer,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(allocator: Allocator) !Self {
|
pub fn init(bufs: []u8) Self {
|
||||||
const framebuf_len = framebuf_pitch * height;
|
std.debug.assert(bufs.len == framebuf_pitch * height * 2);
|
||||||
const buf = try allocator.alloc(u8, framebuf_len * 2);
|
|
||||||
std.mem.set(u8, buf, 0);
|
const front = bufs[0 .. framebuf_pitch * height];
|
||||||
|
const back = bufs[framebuf_pitch * height ..];
|
||||||
|
|
||||||
return .{
|
return .{
|
||||||
// Front and Back Framebuffers
|
.buf = [2][]u8{ front, back },
|
||||||
.layers = [_][]u8{ buf[0..][0..framebuf_len], buf[framebuf_len..][0..framebuf_len] },
|
.original = bufs,
|
||||||
.buf = buf,
|
|
||||||
.current = 0,
|
.current = 0,
|
||||||
|
|
||||||
.allocator = allocator,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deinit(self: *Self) void {
|
fn deinit(self: Self, alloc: Allocator) void {
|
||||||
self.allocator.free(self.buf);
|
alloc.free(self.original);
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn swap(self: *Self) void {
|
pub fn swap(self: *Self) void {
|
||||||
|
@ -1291,6 +1281,6 @@ const FrameBuffer = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(self: *Self, comptime dev: Device) []u8 {
|
pub fn get(self: *Self, comptime dev: Device) []u8 {
|
||||||
return self.layers[if (dev == .Emulator) self.current else ~self.current];
|
return self.buf[if (dev == .Emulator) self.current else ~self.current];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,9 +21,8 @@ pub const Scheduler = struct {
|
||||||
return sched;
|
return sched;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: Self) void {
|
||||||
self.queue.deinit();
|
self.queue.deinit();
|
||||||
self.* = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn now(self: *const Self) u64 {
|
pub inline fn now(self: *const Self) u64 {
|
||||||
|
|
18
src/main.zig
18
src/main.zig
|
@ -40,20 +40,22 @@ pub fn main() anyerror!void {
|
||||||
const paths = try handleArguments(allocator, &result);
|
const paths = try handleArguments(allocator, &result);
|
||||||
defer if (paths.save) |path| allocator.free(path);
|
defer if (paths.save) |path| allocator.free(path);
|
||||||
|
|
||||||
const log_file: ?std.fs.File = if (arm7tdmi_logging) try std.fs.cwd().createFile("zba.log", .{}) else null;
|
|
||||||
defer if (log_file) |file| file.close();
|
|
||||||
|
|
||||||
// TODO: Take Emulator Init Code out of main.zig
|
// TODO: Take Emulator Init Code out of main.zig
|
||||||
var scheduler = Scheduler.init(allocator);
|
var scheduler = Scheduler.init(allocator);
|
||||||
defer scheduler.deinit();
|
defer scheduler.deinit();
|
||||||
|
|
||||||
var bus: Bus = undefined;
|
var bus = try Bus.init(allocator, &scheduler, paths);
|
||||||
var arm7tdmi = Arm7tdmi.init(&scheduler, &bus, log_file);
|
|
||||||
if (paths.bios == null) arm7tdmi.fastBoot();
|
|
||||||
|
|
||||||
try bus.init(allocator, &scheduler, &arm7tdmi, paths);
|
|
||||||
defer bus.deinit();
|
defer bus.deinit();
|
||||||
|
|
||||||
|
var arm7tdmi = Arm7tdmi.init(&scheduler, &bus);
|
||||||
|
|
||||||
|
const log_file: ?std.fs.File = if (arm7tdmi_logging) try std.fs.cwd().createFile("zba.log", .{}) else null;
|
||||||
|
defer if (log_file) |file| file.close();
|
||||||
|
|
||||||
|
if (log_file) |file| arm7tdmi.attach(file);
|
||||||
|
bus.attach(&arm7tdmi); // TODO: Shrink Surface (only CPSR and r15?)
|
||||||
|
if (paths.bios == null) arm7tdmi.fastBoot();
|
||||||
|
|
||||||
var gui = Gui.init(bus.pak.title, width, height);
|
var gui = Gui.init(bus.pak.title, width, height);
|
||||||
gui.initAudio(&bus.apu);
|
gui.initAudio(&bus.apu);
|
||||||
defer gui.deinit();
|
defer gui.deinit();
|
||||||
|
|
Loading…
Reference in New Issue