style(scheduler): rename scheduler event handlers
This commit is contained in:
parent
ae6b8e2f03
commit
739d38533a
|
@ -373,7 +373,7 @@ pub const Apu = struct {
|
|||
return @as(u64, 1) << (15 + @as(u6, cycle));
|
||||
}
|
||||
|
||||
pub fn tickFrameSequencer(self: *Self, late: u64) void {
|
||||
pub fn onSequencerTick(self: *Self, late: u64) void {
|
||||
self.fs.tick();
|
||||
|
||||
switch (self.fs.step) {
|
||||
|
@ -403,7 +403,7 @@ pub const Apu = struct {
|
|||
self.ch4.tickEnvelope();
|
||||
}
|
||||
|
||||
pub fn handleTimerOverflow(self: *Self, cpu: *Arm7tdmi, tim_id: u3) void {
|
||||
pub fn onDmaAudioSampleRequest(self: *Self, cpu: *Arm7tdmi, tim_id: u3) void {
|
||||
if (!self.cnt.apu_enable.read()) return;
|
||||
|
||||
if (@boolToInt(self.dma_cnt.chA_timer.read()) == tim_id) {
|
||||
|
|
|
@ -128,7 +128,7 @@ pub fn setNr44(self: *Self, fs: *const FrameSequencer, byte: u8) void {
|
|||
self.cnt = new;
|
||||
}
|
||||
|
||||
pub fn channelTimerOverflow(self: *Self, late: u64) void {
|
||||
pub fn onNoiseEvent(self: *Self, late: u64) void {
|
||||
self.lfsr.onLfsrTimerExpire(self.poly, late);
|
||||
|
||||
self.sample = 0;
|
||||
|
|
|
@ -58,7 +58,7 @@ pub fn tickEnvelope(self: *Self) void {
|
|||
self.env_dev.tick(self.envelope);
|
||||
}
|
||||
|
||||
pub fn channelTimerOverflow(self: *Self, late: u64) void {
|
||||
pub fn onToneEvent(self: *Self, late: u64) void {
|
||||
self.square.onSquareTimerExpire(Self, self.freq, late);
|
||||
|
||||
self.sample = 0;
|
||||
|
|
|
@ -71,7 +71,7 @@ pub fn tickEnvelope(self: *Self) void {
|
|||
self.env_dev.tick(self.envelope);
|
||||
}
|
||||
|
||||
pub fn channelTimerOverflow(self: *Self, late: u64) void {
|
||||
pub fn onToneSweepEvent(self: *Self, late: u64) void {
|
||||
self.square.onSquareTimerExpire(Self, self.freq, late);
|
||||
|
||||
self.sample = 0;
|
||||
|
|
|
@ -116,7 +116,7 @@ pub fn setNr34(self: *Self, fs: *const FrameSequencer, byte: u8) void {
|
|||
self.freq = new;
|
||||
}
|
||||
|
||||
pub fn channelTimerOverflow(self: *Self, late: u64) void {
|
||||
pub fn onWaveEvent(self: *Self, late: u64) void {
|
||||
self.wave_dev.onWaveTimerExpire(self.freq, self.select, late);
|
||||
|
||||
self.sample = 0;
|
||||
|
|
|
@ -288,7 +288,7 @@ pub const Clock = struct {
|
|||
cpu.sched.push(.RealTimeClock, 1 << 24); // Every Second
|
||||
}
|
||||
|
||||
pub fn updateTime(self: *Self, late: u64) void {
|
||||
pub fn onClockUpdate(self: *Self, late: u64) void {
|
||||
self.cpu.sched.push(.RealTimeClock, (1 << 24) -| late); // Reschedule
|
||||
|
||||
const now = DateTime.now();
|
||||
|
|
|
@ -154,7 +154,7 @@ fn Timer(comptime id: u2) type {
|
|||
|
||||
// DMA Sound Things
|
||||
if (id == 0 or id == 1) {
|
||||
cpu.bus.apu.handleTimerOverflow(cpu, id);
|
||||
cpu.bus.apu.onDmaAudioSampleRequest(cpu, id);
|
||||
}
|
||||
|
||||
// Perform Cascade Behaviour
|
||||
|
|
|
@ -562,7 +562,7 @@ pub const Ppu = struct {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn handleHDrawEnd(self: *Self, cpu: *Arm7tdmi, late: u64) void {
|
||||
pub fn onHdrawEnd(self: *Self, cpu: *Arm7tdmi, late: u64) void {
|
||||
// Transitioning to a Hblank
|
||||
if (self.dispstat.hblank_irq.read()) {
|
||||
cpu.bus.io.irq.hblank.set();
|
||||
|
@ -578,7 +578,7 @@ pub const Ppu = struct {
|
|||
self.sched.push(.HBlank, 68 * 4 -| late);
|
||||
}
|
||||
|
||||
pub fn handleHBlankEnd(self: *Self, cpu: *Arm7tdmi, late: u64) void {
|
||||
pub fn onHblankEnd(self: *Self, cpu: *Arm7tdmi, late: u64) void {
|
||||
// The End of a Hblank (During Draw or Vblank)
|
||||
const old_scanline = self.vcount.scanline.read();
|
||||
const scanline = (old_scanline + 1) % 228;
|
||||
|
|
|
@ -43,7 +43,7 @@ pub const Scheduler = struct {
|
|||
.Draw => {
|
||||
// The end of a VDraw
|
||||
cpu.bus.ppu.drawScanline();
|
||||
cpu.bus.ppu.handleHDrawEnd(cpu, late);
|
||||
cpu.bus.ppu.onHdrawEnd(cpu, late);
|
||||
},
|
||||
.TimerOverflow => |id| {
|
||||
switch (id) {
|
||||
|
@ -55,10 +55,10 @@ pub const Scheduler = struct {
|
|||
},
|
||||
.ApuChannel => |id| {
|
||||
switch (id) {
|
||||
0 => cpu.bus.apu.ch1.channelTimerOverflow(late),
|
||||
1 => cpu.bus.apu.ch2.channelTimerOverflow(late),
|
||||
2 => cpu.bus.apu.ch3.channelTimerOverflow(late),
|
||||
3 => cpu.bus.apu.ch4.channelTimerOverflow(late),
|
||||
0 => cpu.bus.apu.ch1.onToneSweepEvent(late),
|
||||
1 => cpu.bus.apu.ch2.onToneEvent(late),
|
||||
2 => cpu.bus.apu.ch3.onWaveEvent(late),
|
||||
3 => cpu.bus.apu.ch4.onNoiseEvent(late),
|
||||
}
|
||||
},
|
||||
.RealTimeClock => {
|
||||
|
@ -66,12 +66,12 @@ pub const Scheduler = struct {
|
|||
if (device.kind != .Rtc or device.ptr == null) return;
|
||||
|
||||
const clock = @ptrCast(*Clock, @alignCast(@alignOf(*Clock), device.ptr.?));
|
||||
clock.updateTime(late);
|
||||
clock.onClockUpdate(late);
|
||||
},
|
||||
.FrameSequencer => cpu.bus.apu.tickFrameSequencer(late),
|
||||
.FrameSequencer => cpu.bus.apu.onSequencerTick(late),
|
||||
.SampleAudio => cpu.bus.apu.sampleAudio(late),
|
||||
.HBlank => cpu.bus.ppu.handleHBlankEnd(cpu, late), // The end of a HBlank
|
||||
.VBlank => cpu.bus.ppu.handleHDrawEnd(cpu, late), // The end of a VBlank
|
||||
.HBlank => cpu.bus.ppu.onHblankEnd(cpu, late), // The end of a HBlank
|
||||
.VBlank => cpu.bus.ppu.onHdrawEnd(cpu, late), // The end of a VBlank
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue