feat: rewrite device ticks

This commit is contained in:
2022-10-12 22:55:25 -03:00
parent fd38fd6506
commit 785135a074
5 changed files with 51 additions and 39 deletions

View File

@@ -3,6 +3,7 @@ const util = @import("../../util.zig");
const Scheduler = @import("../scheduler.zig").Scheduler;
const FrameSequencer = @import("../apu.zig").FrameSequencer;
const Tick = @import("../apu.zig").Apu.Tick;
const Length = @import("device/Length.zig");
const Envelope = @import("device/Envelope.zig");
const Square = @import("signal/Square.zig");
@@ -50,12 +51,12 @@ pub fn reset(self: *Self) void {
self.enabled = false;
}
pub fn tickLength(self: *Self) void {
self.len_dev.tick(self.freq.length_enable.read(), &self.enabled);
}
pub fn tickEnvelope(self: *Self) void {
self.env_dev.tick(self.envelope);
pub fn tick(self: *Self, comptime kind: Tick) void {
switch (kind) {
.Length => self.len_dev.tick(self.freq.length_enable.read(), &self.enabled),
.Envelope => self.env_dev.tick(self.envelope),
.Sweep => @compileError("Channel 2 does not implement Sweep"),
}
}
pub fn onToneEvent(self: *Self, late: u64) void {