zba/src/emu.zig

20 lines
531 B
Zig
Raw Normal View History

2021-12-29 21:09:00 +00:00
const _ = @import("std");
const Scheduler = @import("scheduler.zig").Scheduler;
2022-01-02 03:08:36 +00:00
const Arm7tdmi = @import("cpu.zig").Arm7tdmi;
2021-12-29 21:09:00 +00:00
const Bus = @import("bus.zig").Bus;
2022-01-02 03:08:36 +00:00
const cycles_per_frame: u64 = 10_000; // TODO: How many cycles actually?
2021-12-29 21:09:00 +00:00
2022-01-02 03:08:36 +00:00
pub fn runFrame(sch: *Scheduler, cpu: *Arm7tdmi, bus: *Bus) void {
const frame_end = sch.tick + cycles_per_frame;
2021-12-29 21:09:00 +00:00
while (sch.tick < frame_end) {
while (sch.tick < sch.nextTimestamp()) {
sch.tick += cpu.step();
}
sch.handleEvent(cpu, bus);
}
}