style(apu): split apu.zig into multiple files + refactor

This commit is contained in:
2022-10-10 13:20:15 -03:00
parent b5d8a65e69
commit dc7cad9691
11 changed files with 959 additions and 925 deletions

View File

@@ -0,0 +1,18 @@
const Self = @This();
timer: u9,
pub fn create() Self {
return .{ .timer = 0 };
}
pub fn tick(self: *Self, enabled: bool, ch_enable: *bool) void {
if (enabled) {
if (self.timer == 0) return;
self.timer -= 1;
// By returning early if timer == 0, this is only
// true if timer == 0 because of the decrement we just did
if (self.timer == 0) ch_enable.* = false;
}
}