2021-12-29 21:09:00 +00:00
|
|
|
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:46 +00:00
|
|
|
const cycles_per_frame: u64 = 100; // 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 {
|
2022-10-21 08:11:46 +00:00
|
|
|
var cycles: u64 = 0;
|
|
|
|
while (cycles < cycles_per_frame) : (cycles += 1) {
|
|
|
|
sch.tick += 1;
|
|
|
|
_ = cpu.step();
|
2021-12-29 21:09:00 +00:00
|
|
|
|
2022-10-21 08:11:46 +00:00
|
|
|
while (sch.tick >= sch.nextTimestamp()) {
|
|
|
|
sch.handleEvent(cpu, bus);
|
2021-12-29 21:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|