Compare commits
4 Commits
3fe577abb9
...
9a2b7a48c0
Author | SHA1 | Date |
---|---|---|
Rekai Nyangadzayi Musuka | 9a2b7a48c0 | |
Rekai Nyangadzayi Musuka | fe908a6ea9 | |
Rekai Nyangadzayi Musuka | bf95eee3f1 | |
Rekai Nyangadzayi Musuka | 240fbcb1df |
|
@ -1 +1 @@
|
||||||
Subproject commit dbc6b8e54ad753b0605feaeecc8e79dba3572ed3
|
Subproject commit a1b01ffeab452790790034b8a0e97aa30bbeb800
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3cc4bb6dfba885de2c2d6f7c5ee6bc68a5be02bf
|
Subproject commit 016b8bcf98e50ae9408f6a9606bbec5a9bc6f677
|
|
@ -58,7 +58,10 @@ pub fn load(allocator: Allocator, file_path: []const u8) !void {
|
||||||
const contents = try config_file.readToEndAlloc(allocator, try config_file.getEndPos());
|
const contents = try config_file.readToEndAlloc(allocator, try config_file.getEndPos());
|
||||||
defer allocator.free(contents);
|
defer allocator.free(contents);
|
||||||
|
|
||||||
const table = try toml.parseContents(allocator, contents, null);
|
var parser = try toml.parseFile(allocator, file_path);
|
||||||
|
defer parser.deinit();
|
||||||
|
|
||||||
|
const table = try parser.parse();
|
||||||
defer table.deinit();
|
defer table.deinit();
|
||||||
|
|
||||||
// TODO: Report unknown config options
|
// TODO: Report unknown config options
|
||||||
|
|
|
@ -94,10 +94,9 @@ pub fn sound1CntL(self: *const Self) u8 {
|
||||||
pub fn setSound1CntL(self: *Self, value: u8) void {
|
pub fn setSound1CntL(self: *Self, value: u8) void {
|
||||||
const new = io.Sweep{ .raw = value };
|
const new = io.Sweep{ .raw = value };
|
||||||
|
|
||||||
if (self.sweep.direction.read() and !new.direction.read()) {
|
if (!new.direction.read()) {
|
||||||
// Sweep Negate bit has been cleared
|
// If at least one (1) sweep calculation has been made with
|
||||||
// If At least 1 Sweep Calculation has been made since
|
// the negate bit set (since last trigger), disable the channel
|
||||||
// the last trigger, the channel is immediately disabled
|
|
||||||
|
|
||||||
if (self.sweep_dev.calc_performed) self.enabled = false;
|
if (self.sweep_dev.calc_performed) self.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ pub fn tick(self: *Self, ch1: *ToneSweep) void {
|
||||||
if (self.timer == 0) {
|
if (self.timer == 0) {
|
||||||
const period = ch1.sweep.period.read();
|
const period = ch1.sweep.period.read();
|
||||||
self.timer = if (period == 0) 8 else period;
|
self.timer = if (period == 0) 8 else period;
|
||||||
if (!self.calc_performed) self.calc_performed = true;
|
|
||||||
|
|
||||||
if (self.enabled and period != 0) {
|
if (self.enabled and period != 0) {
|
||||||
const new_freq = self.calculate(ch1.sweep, &ch1.enabled);
|
const new_freq = self.calculate(ch1.sweep, &ch1.enabled);
|
||||||
|
@ -52,7 +51,10 @@ pub fn calculate(self: *Self, sweep: io.Sweep, ch_enable: *bool) u12 {
|
||||||
const shadow_shifted = shadow >> sweep.shift.read();
|
const shadow_shifted = shadow >> sweep.shift.read();
|
||||||
const decrease = sweep.direction.read();
|
const decrease = sweep.direction.read();
|
||||||
|
|
||||||
const freq = if (decrease) shadow - shadow_shifted else shadow + shadow_shifted;
|
const freq = if (decrease) blk: {
|
||||||
|
self.calc_performed = true;
|
||||||
|
break :blk shadow - shadow_shifted;
|
||||||
|
} else shadow + shadow_shifted;
|
||||||
if (freq > 0x7FF) ch_enable.* = false;
|
if (freq > 0x7FF) ch_enable.* = false;
|
||||||
|
|
||||||
return freq;
|
return freq;
|
||||||
|
|
Loading…
Reference in New Issue