2021-12-29 21:09:00 +00:00
|
|
|
const _ = @import("std");
|
|
|
|
|
|
|
|
const Scheduler = @import("scheduler.zig").Scheduler;
|
2022-10-21 08:11:44 +00:00
|
|
|
const Arm7tdmi = @import("cpu.zig").Arm7tdmi;
|
2021-12-29 21:09:00 +00:00
|
|
|
const Bus = @import("bus.zig").Bus;
|
|
|
|
|
2022-10-21 08:11:44 +00:00
|
|
|
const cycles_per_frame: u64 = 10_000; // TODO: How many cycles actually?
|
2021-12-29 21:09:00 +00:00
|
|
|
|
2022-10-21 08:11:44 +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);
|
|
|
|
}
|
|
|
|
}
|