some code cleanup

This commit is contained in:
Logan McNaughton
2025-11-22 14:14:22 +01:00
parent 162a6df56d
commit 1141095b65
6 changed files with 8 additions and 11 deletions
-1
View File
@@ -322,7 +322,6 @@ impl Device {
pif: pif::Pif {
rom: [0; 1984],
ram: [0; 64],
input_gathered: false,
channels: [pif::PifChannel {
tx: None,
tx_buf: None,
+1
View File
@@ -192,6 +192,7 @@ pub fn process(device: &mut device::Device, channel: usize) {
&device.vru.words,
device.vru_window.window_notifier.as_ref().unwrap(),
device.vru_window.word_receiver.as_mut().unwrap(),
device.vi.frame_time,
)
} else {
0x7FFF
-2
View File
@@ -8,7 +8,6 @@ pub struct Pif {
#[serde(with = "serde_big_array::BigArray")]
pub ram: [u8; 64],
pub channels: [PifChannel; 5],
pub input_gathered: bool,
}
#[derive(Copy, Clone, serde::Serialize, serde::Deserialize)]
@@ -97,7 +96,6 @@ fn process_channel(device: &mut device::Device, channel: usize) -> usize {
pub fn update_pif_ram(device: &mut device::Device) -> u64 {
unsafe { sdl3_sys::events::SDL_PumpEvents() };
device.pif.input_gathered = true;
let mut active_channels = 0;
for k in 0..PIF_CHANNELS_COUNT {
+3 -5
View File
@@ -158,13 +158,11 @@ pub fn vertical_interrupt_event(device: &mut device::Device) {
device.vi.vi_counter += 1;
if device.netplay.is_none() && paused {
ui::video::pause_loop();
} else if !device.pif.input_gathered {
unsafe { sdl3_sys::events::SDL_PumpEvents() }; // in case the game isn't prompting for input
} else {
device.pif.input_gathered = false;
ui::video::pause_loop(device.vi.frame_time);
}
unsafe { sdl3_sys::events::SDL_PumpEvents() }; // in case the game isn't prompting for input
/*
let vis = if device.cart.pal { 50 } else { 60 };
if device.vi.vi_counter % vis == 0 {
+2 -2
View File
@@ -133,11 +133,11 @@ pub fn load_state(device: &mut device::Device, rdp_state: *const u8) {
}
}
pub fn pause_loop() {
pub fn pause_loop(frame_time: f64) {
let mut paused = true;
let mut frame_advance = false;
while paused && !frame_advance {
std::thread::sleep(std::time::Duration::from_secs_f64(1.0 / 60.0));
std::thread::sleep(std::time::Duration::from_secs_f64(frame_time));
unsafe { sdl3_sys::events::SDL_PumpEvents() };
let callback = unsafe { rdp_check_callback() };
paused = callback.paused;
+2 -1
View File
@@ -2,6 +2,7 @@ pub fn prompt_for_match(
words: &[String],
window_notifier: &tokio::sync::mpsc::Sender<Option<Vec<String>>>,
word_index_receiver: &mut tokio::sync::mpsc::Receiver<String>,
frame_time: f64,
) -> u16 {
let mut dedup_words = words.to_owned();
dedup_words.sort();
@@ -10,7 +11,7 @@ pub fn prompt_for_match(
let mut result = word_index_receiver.try_recv();
while result.is_err() {
result = word_index_receiver.try_recv();
std::thread::sleep(std::time::Duration::from_secs_f64(1.0 / 60.0));
std::thread::sleep(std::time::Duration::from_secs_f64(frame_time));
unsafe { sdl3_sys::events::SDL_PumpEvents() }; // so the OS doesn't complain about the game window being frozen
}
for (i, v) in words.iter().enumerate() {