Skip to content

Commit d075f87

Browse files
committed
2026-05-15 15:02:17
1 parent 2f69e91 commit d075f87

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/apu.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ struct Env {
211211
}
212212

213213
impl Env {
214-
fn new() -> Self {
214+
fn power_up() -> Self {
215215
Self { t: Tmr::power_up(8), v: 0 }
216216
}
217217

@@ -222,11 +222,11 @@ impl Env {
222222
self.v = reg.vol_init();
223223
}
224224

225-
fn clock(&mut self, p: u8, add: bool) {
226-
if p == 0 || self.t.step(1) == 0 {
225+
fn step(&mut self, reg: &Reg) {
226+
if reg.env_p() == 0 || self.t.step(1) == 0 {
227227
return;
228228
}
229-
let n = if add { self.v.wrapping_add(1) } else { self.v.wrapping_sub(1) };
229+
let n = if reg.env_add() { self.v.wrapping_add(1) } else { self.v.wrapping_sub(1) };
230230
if n <= 15 {
231231
self.v = n;
232232
}
@@ -361,7 +361,7 @@ impl Sq1 {
361361
on: false,
362362
tmr: Tmr::power_up(8192),
363363
lc: Lc::power_up(),
364-
env: Env::new(),
364+
env: Env::power_up(),
365365
swp: Swp::new(),
366366
blip: Blip::power_up(sr),
367367
idx: 1,
@@ -465,7 +465,7 @@ impl Sq2 {
465465
on: false,
466466
tmr: Tmr::power_up(8192),
467467
lc: Lc::power_up(),
468-
env: Env::new(),
468+
env: Env::power_up(),
469469
blip: Blip::power_up(sr),
470470
idx: 1,
471471
}
@@ -693,7 +693,7 @@ impl Ns {
693693
on: false,
694694
tmr: Tmr::power_up(8),
695695
lc: Lc::power_up(),
696-
env: Env::new(),
696+
env: Env::power_up(),
697697
lfsr: Lfsr::new(),
698698
blip: Blip::power_up(sr),
699699
}
@@ -1189,13 +1189,13 @@ impl Ticker for Apu {
11891189
}
11901190
if Fseq::env(s) {
11911191
if self.ch1.on {
1192-
self.ch1.env.clock(self.ch1.r.env_p(), self.ch1.r.env_add());
1192+
self.ch1.env.step(&self.ch1.r);
11931193
}
11941194
if self.ch2.on {
1195-
self.ch2.env.clock(self.ch2.r.env_p(), self.ch2.r.env_add());
1195+
self.ch2.env.step(&self.ch2.r);
11961196
}
11971197
if self.ch4.on {
1198-
self.ch4.env.clock(self.ch4.r.env_p(), self.ch4.r.env_add());
1198+
self.ch4.env.step(&self.ch4.r);
11991199
}
12001200
}
12011201
if Fseq::swp(s) && self.ch1.on {

0 commit comments

Comments
 (0)