37 lines
1.1 KiB
Zig
37 lines
1.1 KiB
Zig
const std = @import("std");
|
|
|
|
const Uxn = @import("uxn.zig");
|
|
const Varvara = @import("varvara.zig");
|
|
|
|
const DEBUG = true;
|
|
|
|
pub fn main() !void {
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
defer _ = gpa.deinit();
|
|
const allocator = gpa.allocator();
|
|
|
|
var args = try std.process.argsWithAllocator(allocator);
|
|
defer args.deinit();
|
|
_ = args.next();
|
|
const rom_path = args.next();
|
|
|
|
if (rom_path) |path| {
|
|
var file = try std.fs.cwd().openFile(path, .{});
|
|
defer file.close();
|
|
const rom = try file.readToEndAlloc(allocator, 0xFF00);
|
|
defer allocator.free(rom);
|
|
|
|
Uxn.setDebug(DEBUG);
|
|
|
|
var varvara = try Varvara.init(allocator, rom);
|
|
defer varvara.deinit();
|
|
|
|
while (varvara.uxn.eval()) {
|
|
if (DEBUG) std.debug.print("{s}\t\tpc {X}, code {X}\n", .{
|
|
Uxn.fmtInstrs(varvara.uxn.mem.m[varvara.uxn.pc .. varvara.uxn.pc +% 1]),
|
|
varvara.uxn.pc,
|
|
varvara.uxn.mem.m[varvara.uxn.pc],
|
|
});
|
|
}
|
|
} else return error.NoRom;
|
|
}
|