Implement RTC #1

Merged
paoda merged 14 commits from rtc into main 2022-09-17 23:36:34 +00:00
2 changed files with 3 additions and 3 deletions
Showing only changes of commit a2e702c366 - Show all commits

View File

@ -505,8 +505,8 @@ pub const Clock = struct {
cpu.sched.push(.RealTimeClock, 1 << 24); // Every Second cpu.sched.push(.RealTimeClock, 1 << 24); // Every Second
} }
pub fn updateTime(self: *This) void { pub fn updateTime(self: *This, late: u64) void {
self.cpu.sched.push(.RealTimeClock, 1 << 24); // Reschedule self.cpu.sched.push(.RealTimeClock, (1 << 24) -| late); // Reschedule
const now = DateTime.now(); const now = DateTime.now();
self.year = toBcd(u8, @intCast(u8, now.date.year - 2000)); self.year = toBcd(u8, @intCast(u8, now.date.year - 2000));

View File

@ -66,7 +66,7 @@ pub const Scheduler = struct {
if (device.kind != .Rtc or device.ptr == null) return; if (device.kind != .Rtc or device.ptr == null) return;
const clock = @ptrCast(*Clock, @alignCast(@alignOf(*Clock), device.ptr.?)); const clock = @ptrCast(*Clock, @alignCast(@alignOf(*Clock), device.ptr.?));
clock.updateTime(); clock.updateTime(late);
}, },
.FrameSequencer => cpu.bus.apu.tickFrameSequencer(late), .FrameSequencer => cpu.bus.apu.tickFrameSequencer(late),
.SampleAudio => cpu.bus.apu.sampleAudio(late), .SampleAudio => cpu.bus.apu.sampleAudio(late),