diff --git a/src/bus.zig b/src/bus.zig index eac5836..71d6660 100644 --- a/src/bus.zig +++ b/src/bus.zig @@ -8,11 +8,11 @@ pub const Bus = struct { pak: GamePak, bios: Bios, - pub fn withPak(alloc: Allocator, path: []const u8) !@This() { + pub fn init(alloc: Allocator, path: []const u8) !@This() { return @This(){ - .pak = try GamePak.fromPath(alloc, path), + .pak = try GamePak.init(alloc, path), // TODO: don't hardcode this + bundle open-sorce Boot ROM - .bios = try Bios.fromPath(alloc, "./bin/gba_bios.bin"), + .bios = try Bios.init(alloc, "./bin/gba_bios.bin"), }; } diff --git a/src/bus/bios.zig b/src/bus/bios.zig index c9456c6..a8d6d14 100644 --- a/src/bus/bios.zig +++ b/src/bus/bios.zig @@ -5,7 +5,7 @@ const Allocator = std.mem.Allocator; pub const Bios = struct { buf: []u8, - pub fn fromPath(alloc: Allocator, path: []const u8) !@This() { + pub fn init(alloc: Allocator, path: []const u8) !@This() { const file = try std.fs.cwd().openFile(path, .{ .read = true }); defer file.close(); diff --git a/src/bus/pak.zig b/src/bus/pak.zig index b9ab9aa..d642917 100644 --- a/src/bus/pak.zig +++ b/src/bus/pak.zig @@ -5,7 +5,7 @@ const Allocator = std.mem.Allocator; pub const GamePak = struct { buf: []u8, - pub fn fromPath(alloc: Allocator, path: []const u8) !@This() { + pub fn init(alloc: Allocator, path: []const u8) !@This() { const file = try std.fs.cwd().openFile(path, .{ .read = true }); defer file.close(); diff --git a/src/cpu.zig b/src/cpu.zig index 9b7cee1..49661a8 100644 --- a/src/cpu.zig +++ b/src/cpu.zig @@ -20,7 +20,7 @@ pub const Arm7tdmi = struct { bus: *Bus, cpsr: CPSR, - pub fn new(scheduler: *Scheduler, bus: *Bus) @This() { + pub fn init(scheduler: *Scheduler, bus: *Bus) @This() { return .{ .r = [_]u32{0x00} ** 16, .sch = scheduler, diff --git a/src/main.zig b/src/main.zig index ba7923b..a75db88 100644 --- a/src/main.zig +++ b/src/main.zig @@ -23,9 +23,9 @@ pub fn main() anyerror!void { return; } - var bus = try Bus.withPak(alloc, zba_args[0]); - var scheduler = Scheduler.new(alloc); - var cpu = Arm7tdmi.new(&scheduler, &bus); + var bus = try Bus.init(alloc, zba_args[0]); + var scheduler = Scheduler.init(alloc); + var cpu = Arm7tdmi.init(&scheduler, &bus); while (true) { emu.runFrame(&scheduler, &cpu, &bus); diff --git a/src/scheduler.zig b/src/scheduler.zig index 760d856..9e80c10 100644 --- a/src/scheduler.zig +++ b/src/scheduler.zig @@ -10,7 +10,7 @@ pub const Scheduler = struct { tick: u64, queue: PriorityQueue(Event, void, lessThan), - pub fn new(alloc: Allocator) @This() { + pub fn init(alloc: Allocator) @This() { var scheduler = Scheduler{ .tick = 0, .queue = PriorityQueue(Event, void, lessThan).init(alloc, {}) }; scheduler.queue.add(.{