mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
some code cleanup
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user