Compare commits
No commits in common. "d794a94b68fb8d5a2f8f17889b062cb86d56ae6a" and "3c2456611e96a0fa8a9c0397377bbec2181ea9b4" have entirely different histories.
d794a94b68
...
3c2456611e
|
@ -75,7 +75,7 @@ impl Cartridge {
|
|||
}
|
||||
|
||||
fn detect_rom_info(memory: &[u8]) -> RomSize {
|
||||
let id = memory[ROM_SIZE_ADDRESS];
|
||||
let id = dbg!(memory[ROM_SIZE_ADDRESS]);
|
||||
id.into()
|
||||
}
|
||||
|
||||
|
|
42
src/timer.rs
42
src/timer.rs
|
@ -21,29 +21,18 @@ impl Timer {
|
|||
use State::*;
|
||||
use TimerSpeed::*;
|
||||
|
||||
match self.state {
|
||||
TIMAOverflow(_) | AbortedTIMAOverflow(_) => self.state = self.state.next(),
|
||||
LoadTMA => {
|
||||
self.counter = self.modulo;
|
||||
self.interrupt = true;
|
||||
|
||||
self.state.next();
|
||||
}
|
||||
Normal => {}
|
||||
}
|
||||
|
||||
if let TIMAOverflow(step) | AbortedTIMAOverflow(step) = self.state {
|
||||
if step < 3 {
|
||||
self.state = self.state.next();
|
||||
} else {
|
||||
if step < 4 {
|
||||
self.state = TIMAOverflow(step + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if self.state == TIMAOverflow(step) {
|
||||
self.counter = self.modulo;
|
||||
self.interrupt = true;
|
||||
}
|
||||
|
||||
self.state = Normal;
|
||||
}
|
||||
}
|
||||
|
||||
self.divider = self.divider.wrapping_add(1);
|
||||
|
||||
|
@ -78,12 +67,14 @@ impl Timer {
|
|||
use State::*;
|
||||
|
||||
match self.state {
|
||||
Normal | AbortedTIMAOverflow(_) => self.counter = byte,
|
||||
Normal => self.counter = byte,
|
||||
TIMAOverflow(step) => {
|
||||
if step < 4 {
|
||||
self.counter = byte;
|
||||
self.state = AbortedTIMAOverflow(step);
|
||||
}
|
||||
LoadTMA => {}
|
||||
}
|
||||
AbortedTIMAOverflow(_) => self.counter = byte,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,19 +173,4 @@ enum State {
|
|||
TIMAOverflow(u8),
|
||||
AbortedTIMAOverflow(u8),
|
||||
Normal,
|
||||
LoadTMA,
|
||||
}
|
||||
|
||||
impl State {
|
||||
fn next(&self) -> Self {
|
||||
use State::*;
|
||||
|
||||
match self {
|
||||
Normal | LoadTMA => Normal,
|
||||
TIMAOverflow(3) => LoadTMA,
|
||||
AbortedTIMAOverflow(3) => Normal,
|
||||
TIMAOverflow(step) => TIMAOverflow(step + 1),
|
||||
AbortedTIMAOverflow(step) => AbortedTIMAOverflow(step + 1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue