feat: put RTC Sync on Scheduler
TODO: Database to see what games have what GPIO devices
This commit is contained in:
@@ -2,6 +2,7 @@ const std = @import("std");
|
||||
|
||||
const Bus = @import("Bus.zig");
|
||||
const Arm7tdmi = @import("cpu.zig").Arm7tdmi;
|
||||
const Clock = @import("bus/GamePak.zig").Clock;
|
||||
|
||||
const Order = std.math.Order;
|
||||
const PriorityQueue = std.PriorityQueue;
|
||||
@@ -60,6 +61,13 @@ pub const Scheduler = struct {
|
||||
3 => cpu.bus.apu.ch4.channelTimerOverflow(late),
|
||||
}
|
||||
},
|
||||
.RealTimeClock => {
|
||||
const device = &cpu.bus.pak.gpio.device;
|
||||
if (device.kind != .Rtc or device.ptr == null) return;
|
||||
|
||||
const clock = @ptrCast(*Clock, @alignCast(@alignOf(*Clock), device.ptr.?));
|
||||
clock.updateTime();
|
||||
},
|
||||
.FrameSequencer => cpu.bus.apu.tickFrameSequencer(late),
|
||||
.SampleAudio => cpu.bus.apu.sampleAudio(late),
|
||||
.HBlank => cpu.bus.ppu.handleHBlankEnd(cpu, late), // The end of a HBlank
|
||||
@@ -118,4 +126,5 @@ pub const EventKind = union(enum) {
|
||||
SampleAudio,
|
||||
FrameSequencer,
|
||||
ApuChannel: u2,
|
||||
RealTimeClock,
|
||||
};
|
||||
|
Reference in New Issue
Block a user