mirror of
https://github.com/FranLMSP/snes.git
synced 2026-10-03 16:05:18 -04:00
refactor frame loop
This commit is contained in:
@@ -25,12 +25,17 @@ impl Emulator {
|
|||||||
self.cpu.cycles = 0;
|
self.cpu.cycles = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_frame_ending(&self) -> bool {
|
pub fn loop_frame(&mut self) {
|
||||||
self.bus.ppu.registers.v_count == 0
|
let mut frame_started = true;
|
||||||
}
|
loop {
|
||||||
|
self.tick();
|
||||||
pub fn is_frame_starting(&self) -> bool {
|
if !frame_started && self.bus.ppu.registers.v_count == 260 {
|
||||||
self.bus.ppu.registers.v_count == 1
|
break;
|
||||||
|
}
|
||||||
|
if self.bus.ppu.registers.v_count >= 261 {
|
||||||
|
frame_started = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
|
|||||||
@@ -450,15 +450,7 @@ fn main() {
|
|||||||
|
|
||||||
// Actually run the emulation
|
// Actually run the emulation
|
||||||
if !state.emulation.is_paused {
|
if !state.emulation.is_paused {
|
||||||
// We want to keep the emulator running
|
emulator.loop_frame();
|
||||||
// as long as we are not at the end of the frame
|
|
||||||
while !emulator.is_frame_ending() {
|
|
||||||
emulator.tick()
|
|
||||||
}
|
|
||||||
// It takes some amount of cycles to get out of 0 v-count
|
|
||||||
while !emulator.is_frame_starting() {
|
|
||||||
emulator.tick()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render emulator framebuffer
|
// Render emulator framebuffer
|
||||||
|
|||||||
Reference in New Issue
Block a user