43 lines
1.0 KiB
Zig
Executable File
43 lines
1.0 KiB
Zig
Executable File
const rl = @import("raylib");
|
|
const std = @import("std");
|
|
|
|
const print = std.debug.print;
|
|
const Allocator = std.mem.Allocator;
|
|
const ChipContext = @import("chip.zig");
|
|
const RaylibChip = @import("raylib-chip.zig");
|
|
const MainScene = @import("./main-scene.zig");
|
|
const listROMs = @import("./roms.zig").listROMs;
|
|
|
|
fn megabytes(amount: usize) usize {
|
|
return amount * 1024 * 1024;
|
|
}
|
|
|
|
pub fn main() anyerror!void {
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
const allocator = gpa.allocator();
|
|
defer {
|
|
if (gpa.deinit() == .leak) @panic("Leaked memory");
|
|
}
|
|
|
|
rl.SetConfigFlags(rl.ConfigFlags{ .FLAG_WINDOW_RESIZABLE = true });
|
|
rl.InitWindow(1024, 720, "CHIP-8");
|
|
defer rl.CloseWindow();
|
|
|
|
rl.InitAudioDevice();
|
|
defer rl.CloseAudioDevice();
|
|
|
|
rl.SetTargetFPS(60);
|
|
|
|
var scene = try MainScene.init(allocator);
|
|
defer scene.deinit();
|
|
|
|
while (!rl.WindowShouldClose()) {
|
|
var dt = rl.GetFrameTime();
|
|
scene.update(dt);
|
|
|
|
rl.BeginDrawing();
|
|
scene.draw();
|
|
rl.EndDrawing();
|
|
}
|
|
}
|