fix timing and support END_TICKs now that lsdpack is emitting them at all
This commit is contained in:
parent
c22c9bcbd8
commit
83f6ffab56
32
src/main.rs
32
src/main.rs
|
@ -252,21 +252,28 @@ impl Lsdpack {
|
|||
self.repeat_cmd = None;
|
||||
}
|
||||
}
|
||||
let cmd = self.load_new_cmd_from_stream();
|
||||
ongoing = self.apply_cmd(cmd);
|
||||
let (cmd, flagged_ongoing) = self.load_new_cmd_from_stream();
|
||||
ongoing = flagged_ongoing;
|
||||
ongoing &= self.apply_cmd(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
#[link_section = ".iwram"]
|
||||
fn load_new_cmd_from_stream(&mut self) -> LsdpackCmd {
|
||||
let cmd = self.next_byte();
|
||||
if cmd & 0x40 != 0 {
|
||||
self.repeat_cmd = Some((cmd & 0x3f).into());
|
||||
self.repeat_cmd_counter = self.next_byte() as usize;
|
||||
self.repeat_cmd.unwrap()
|
||||
} else {
|
||||
cmd.into()
|
||||
fn load_new_cmd_from_stream(&mut self) -> (LsdpackCmd, bool) {
|
||||
const FLAG_REPEAT: u8 = 0x40;
|
||||
const FLAG_END_TICK: u8 = 0x80;
|
||||
let mut cmd = self.next_byte();
|
||||
let mut ongoing = true;
|
||||
if cmd & FLAG_END_TICK != 0 {
|
||||
cmd &= !FLAG_END_TICK;
|
||||
ongoing = false;
|
||||
}
|
||||
if cmd & FLAG_REPEAT != 0 {
|
||||
cmd &= !FLAG_REPEAT;
|
||||
self.repeat_cmd = Some(cmd.into());
|
||||
self.repeat_cmd_counter = self.next_byte() as usize;
|
||||
}
|
||||
(cmd.into(), ongoing)
|
||||
}
|
||||
|
||||
#[link_section = ".iwram"]
|
||||
|
@ -418,12 +425,13 @@ extern "C" fn main() -> ! {
|
|||
IE.write(IrqBits::VBLANK.with_timer0(true));
|
||||
IME.write(true);
|
||||
|
||||
TIMER0_RELOAD.write((((16777216 / 256) / 6) as u16).wrapping_neg());
|
||||
//TIMER0_RELOAD.write((((16777216 / 1) / 360) as u16).wrapping_neg());
|
||||
TIMER0_RELOAD.write((((280896 / 1) / 6) as u16).wrapping_neg());
|
||||
TIMER0_CONTROL.write(
|
||||
TimerControl::new()
|
||||
.with_overflow_irq(true)
|
||||
.with_cascade(false)
|
||||
.with_scale(TimerScale::_256)
|
||||
.with_scale(TimerScale::_1)
|
||||
.with_enabled(true),
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue