zba/src/emu.zig

20 lines
519 B
Zig
Raw Normal View History

2021-12-29 21:09:00 +00:00
const _ = @import("std");
const Scheduler = @import("scheduler.zig").Scheduler;
const ARM7TDMI = @import("cpu.zig").ARM7TDMI;
const Bus = @import("bus.zig").Bus;
const CYCLES_PER_FRAME: u64 = 10_000; // TODO: What is this?
pub fn runFrame(sch: *Scheduler, cpu: *ARM7TDMI, bus: *Bus) void {
const frame_end = sch.tick + CYCLES_PER_FRAME;
while (sch.tick < frame_end) {
while (sch.tick < sch.nextTimestamp()) {
sch.tick += cpu.step();
}
sch.handleEvent(cpu, bus);
}
}