style: code refactoring

This commit is contained in:
2022-10-21 05:13:04 -03:00
parent 208f4b522d
commit ae6b8e2f03
9 changed files with 65 additions and 89 deletions

View File

@@ -1,4 +1,5 @@
const io = @import("../bus/io.zig");
const util = @import("../../util.zig");
const Scheduler = @import("../scheduler.zig").Scheduler;
const FrameSequencer = @import("../apu.zig").FrameSequencer;
@@ -123,7 +124,7 @@ pub fn setNr44(self: *Self, fs: *const FrameSequencer, byte: u8) void {
self.enabled = self.isDacEnabled();
}
self.lfsr.updateLength(fs, self, new);
util.audio.length.ch4.update(self, fs, new);
self.cnt = new;
}
@@ -135,10 +136,6 @@ pub fn channelTimerOverflow(self: *Self, late: u64) void {
self.sample = if (self.enabled) self.lfsr.sample() * @as(i8, self.env_dev.vol) else 0;
}
pub fn amplitude(self: *const Self) i16 {
return @as(i16, self.sample);
}
fn isDacEnabled(self: *const Self) bool {
return self.envelope.raw & 0xF8 != 0x00;
}