@@ -269,13 +269,12 @@ impl Lc {
269269 Self { n : 0 }
270270 }
271271
272- fn step ( & mut self , en : bool ) -> bool {
273- if en && self . n != 0 {
272+ fn step ( & mut self , reg : & Reg ) -> bool {
273+ if reg . len_en ( ) && self . n != 0 {
274274 self . n -= 1 ;
275- self . n == 0
276- } else {
277- false
275+ return self . n == 0 ;
278276 }
277+ return false ;
279278 }
280279}
281280
@@ -482,7 +481,7 @@ impl Sq1 {
482481 let old_en = self . r . r . len_en ( ) ;
483482 self . r . r . n [ 4 ] = v;
484483 self . tmr . p = self . r . period ( ) ;
485- if xtra && !old_en && self . r . r . len_en ( ) && self . lc . step ( true ) {
484+ if xtra && !old_en && self . lc . step ( & self . r . r ) {
486485 self . on = false ;
487486 }
488487 if v & 0x80 != 0 {
@@ -578,7 +577,7 @@ impl Sq2 {
578577 let old_en = self . r . r . len_en ( ) ;
579578 self . r . r . n [ 4 ] = v;
580579 self . tmr . p = self . r . period ( ) ;
581- if xtra && !old_en && self . r . r . len_en ( ) && self . lc . step ( true ) {
580+ if xtra && !old_en && self . lc . step ( & self . r . r ) {
582581 self . on = false ;
583582 }
584583 if v & 0x80 != 0 {
@@ -692,7 +691,7 @@ impl Wv {
692691 let old_en = self . r . r . len_en ( ) ;
693692 self . r . r . n [ 4 ] = v;
694693 self . tmr . p = self . r . period ( ) ;
695- if xtra && !old_en && self . r . r . len_en ( ) && self . lc . step ( true ) {
694+ if xtra && !old_en && self . lc . step ( & self . r . r ) {
696695 self . on = false ;
697696 }
698697 if v & 0x80 != 0 {
@@ -805,7 +804,7 @@ impl Ns {
805804 fn write_nrx4 ( & mut self , v : u8 , xtra : bool ) {
806805 let old_en = self . r . r . len_en ( ) ;
807806 self . r . r . n [ 4 ] = v;
808- if xtra && !old_en && self . r . r . len_en ( ) && self . lc . step ( true ) {
807+ if xtra && !old_en && self . lc . step ( & self . r . r ) {
809808 self . on = false ;
810809 }
811810 if v & 0x80 != 0 {
@@ -1245,16 +1244,16 @@ impl Ticker for Apu {
12451244
12461245 let s = self . fs . step ( ) ;
12471246 if Fseq :: len ( s) {
1248- if self . ch1 . lc . step ( self . ch1 . r . r . len_en ( ) ) {
1247+ if self . ch1 . lc . step ( & self . ch1 . r . r ) {
12491248 self . ch1 . on = false ;
12501249 }
1251- if self . ch2 . lc . step ( self . ch2 . r . r . len_en ( ) ) {
1250+ if self . ch2 . lc . step ( & self . ch2 . r . r ) {
12521251 self . ch2 . on = false ;
12531252 }
1254- if self . ch3 . lc . step ( self . ch3 . r . r . len_en ( ) ) {
1253+ if self . ch3 . lc . step ( & self . ch3 . r . r ) {
12551254 self . ch3 . on = false ;
12561255 }
1257- if self . ch4 . lc . step ( self . ch4 . r . r . len_en ( ) ) {
1256+ if self . ch4 . lc . step ( & self . ch4 . r . r ) {
12581257 self . ch4 . on = false ;
12591258 }
12601259 }
0 commit comments