chore: rename consturctors to fit convention
This commit is contained in:
parent
80d49e03d6
commit
614ac4a262
|
@ -8,11 +8,11 @@ pub const Bus = struct {
|
||||||
pak: GamePak,
|
pak: GamePak,
|
||||||
bios: Bios,
|
bios: Bios,
|
||||||
|
|
||||||
pub fn withPak(alloc: Allocator, path: []const u8) !@This() {
|
pub fn init(alloc: Allocator, path: []const u8) !@This() {
|
||||||
return @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
|
// 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"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Allocator = std.mem.Allocator;
|
||||||
pub const Bios = struct {
|
pub const Bios = struct {
|
||||||
buf: []u8,
|
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 });
|
const file = try std.fs.cwd().openFile(path, .{ .read = true });
|
||||||
defer file.close();
|
defer file.close();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const Allocator = std.mem.Allocator;
|
||||||
pub const GamePak = struct {
|
pub const GamePak = struct {
|
||||||
buf: []u8,
|
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 });
|
const file = try std.fs.cwd().openFile(path, .{ .read = true });
|
||||||
defer file.close();
|
defer file.close();
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub const Arm7tdmi = struct {
|
||||||
bus: *Bus,
|
bus: *Bus,
|
||||||
cpsr: CPSR,
|
cpsr: CPSR,
|
||||||
|
|
||||||
pub fn new(scheduler: *Scheduler, bus: *Bus) @This() {
|
pub fn init(scheduler: *Scheduler, bus: *Bus) @This() {
|
||||||
return .{
|
return .{
|
||||||
.r = [_]u32{0x00} ** 16,
|
.r = [_]u32{0x00} ** 16,
|
||||||
.sch = scheduler,
|
.sch = scheduler,
|
||||||
|
|
|
@ -23,9 +23,9 @@ pub fn main() anyerror!void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bus = try Bus.withPak(alloc, zba_args[0]);
|
var bus = try Bus.init(alloc, zba_args[0]);
|
||||||
var scheduler = Scheduler.new(alloc);
|
var scheduler = Scheduler.init(alloc);
|
||||||
var cpu = Arm7tdmi.new(&scheduler, &bus);
|
var cpu = Arm7tdmi.init(&scheduler, &bus);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
emu.runFrame(&scheduler, &cpu, &bus);
|
emu.runFrame(&scheduler, &cpu, &bus);
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub const Scheduler = struct {
|
||||||
tick: u64,
|
tick: u64,
|
||||||
queue: PriorityQueue(Event, void, lessThan),
|
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, {}) };
|
var scheduler = Scheduler{ .tick = 0, .queue = PriorityQueue(Event, void, lessThan).init(alloc, {}) };
|
||||||
|
|
||||||
scheduler.queue.add(.{
|
scheduler.queue.add(.{
|
||||||
|
|
Loading…
Reference in New Issue