zba/src/emu.zig

18 lines
494 B
Zig
Raw Normal View History

2022-01-07 23:49:58 +00:00
const Bus = @import("Bus.zig");
2021-12-29 21:09:00 +00:00
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 cycles_per_frame: u64 = 160 * (308 * 4);
2021-12-29 21:09:00 +00:00
pub fn runFrame(sched: *Scheduler, cpu: *Arm7tdmi, bus: *Bus) void {
var cycles: u64 = 0;
while (cycles < cycles_per_frame) : (cycles += 1) {
sched.tick += 1;
_ = cpu.step();
2021-12-29 21:09:00 +00:00
while (sched.tick >= sched.nextTimestamp()) {
sched.handleEvent(cpu, bus);
2021-12-29 21:09:00 +00:00
}
}
}