2021-12-29 21:09:00 +00:00
|
|
|
const std = @import("std");
|
2022-10-21 08:11:44 +00:00
|
|
|
const emu = @import("emu.zig");
|
2021-12-29 21:09:00 +00:00
|
|
|
|
|
|
|
const Scheduler = @import("scheduler.zig").Scheduler;
|
2022-10-21 08:11:50 +00:00
|
|
|
const Bus = @import("Bus.zig");
|
2022-10-21 08:11:44 +00:00
|
|
|
const Arm7tdmi = @import("cpu.zig").Arm7tdmi;
|
2021-12-29 21:09:00 +00:00
|
|
|
|
|
|
|
pub fn main() anyerror!void {
|
|
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
|
|
const alloc = gpa.allocator();
|
2022-10-21 08:11:47 +00:00
|
|
|
defer std.debug.assert(!gpa.deinit());
|
2021-12-29 21:09:00 +00:00
|
|
|
|
2022-10-21 08:11:45 +00:00
|
|
|
const args = try std.process.argsAlloc(alloc);
|
|
|
|
defer std.process.argsFree(alloc, args);
|
|
|
|
|
|
|
|
const zba_args: []const []const u8 = args[1..];
|
|
|
|
|
|
|
|
if (zba_args.len == 0) {
|
|
|
|
std.log.err("Expected PATH to Gameboy Advance ROM as a CLI argument", .{});
|
|
|
|
return;
|
|
|
|
} else if (zba_args.len > 1) {
|
|
|
|
std.log.err("Too many CLI arguments were provided", .{});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-21 08:11:45 +00:00
|
|
|
var scheduler = Scheduler.init(alloc);
|
2022-10-21 08:11:47 +00:00
|
|
|
defer scheduler.deinit();
|
|
|
|
|
2022-10-21 08:11:49 +00:00
|
|
|
var bus = try Bus.init(alloc, &scheduler, zba_args[0]);
|
|
|
|
defer bus.deinit();
|
|
|
|
|
2022-10-21 08:11:45 +00:00
|
|
|
var cpu = Arm7tdmi.init(&scheduler, &bus);
|
2021-12-29 21:09:00 +00:00
|
|
|
|
2022-10-21 08:11:46 +00:00
|
|
|
cpu.skipBios();
|
|
|
|
|
2021-12-29 21:09:00 +00:00
|
|
|
while (true) {
|
|
|
|
emu.runFrame(&scheduler, &cpu, &bus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test "basic test" {
|
|
|
|
try std.testing.expectEqual(10, 3 + 7);
|
|
|
|
}
|