mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
+1
-1
@@ -226,7 +226,7 @@ pub fn get_rom_contents(file_path: &std::path::PathBuf) -> Option<Vec<u8>> {
|
||||
pub struct Device {
|
||||
#[serde(skip)]
|
||||
pub netplay: Option<netplay::Netplay>,
|
||||
#[serde(skip, default = "ui::Ui::new")]
|
||||
#[serde(skip)]
|
||||
pub ui: ui::Ui,
|
||||
pub byte_swap: usize,
|
||||
pub save_state: bool,
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ pub fn write_regs(device: &mut device::Device, address: u64, value: u32, mask: u
|
||||
let current_origin = device.vi.regs[reg as usize];
|
||||
device::memory::masked_write_32(&mut device.vi.regs[reg as usize], value, mask);
|
||||
if current_origin != device.vi.regs[reg as usize] {
|
||||
let _ = device.ui.video.fps_tx.try_send(true);
|
||||
let _ = device.ui.video.fps_tx.as_ref().unwrap().try_send(true);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
@@ -127,7 +127,7 @@ pub fn vertical_interrupt_event(device: &mut device::Device) {
|
||||
}
|
||||
|
||||
ui::video::render_frame();
|
||||
let _ = device.ui.video.vis_tx.try_send(true);
|
||||
let _ = device.ui.video.vis_tx.as_ref().unwrap().try_send(true);
|
||||
|
||||
retroachievements::do_frame();
|
||||
|
||||
|
||||
@@ -28,24 +28,27 @@ pub static WEB_CLIENT: std::sync::LazyLock<reqwest::Client> = std::sync::LazyLoc
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Default, Clone)]
|
||||
pub struct Dirs {
|
||||
pub config_dir: std::path::PathBuf,
|
||||
pub data_dir: std::path::PathBuf,
|
||||
pub cache_dir: std::path::PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Audio {
|
||||
pub audio_stream: *mut sdl3_sys::audio::SDL_AudioStream,
|
||||
pub gain: f32,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Input {
|
||||
pub keyboard_state: *const bool,
|
||||
pub last_polled: u64,
|
||||
pub controllers: [input::Controllers; 4],
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Storage {
|
||||
pub save_type: Vec<storage::SaveTypes>,
|
||||
pub paths: storage::Paths,
|
||||
@@ -53,15 +56,17 @@ pub struct Storage {
|
||||
pub save_state_slot: u32,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Video {
|
||||
pub window: *mut sdl3_sys::video::SDL_Window,
|
||||
pub fullscreen: bool,
|
||||
pub fps_tx: tokio::sync::mpsc::Sender<bool>,
|
||||
pub fps_tx: Option<tokio::sync::mpsc::Sender<bool>>,
|
||||
pub fps_rx: Option<tokio::sync::mpsc::Receiver<bool>>,
|
||||
pub vis_tx: tokio::sync::mpsc::Sender<bool>,
|
||||
pub vis_tx: Option<tokio::sync::mpsc::Sender<bool>>,
|
||||
pub vis_rx: Option<tokio::sync::mpsc::Receiver<bool>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Usb {
|
||||
pub usb_tx: Option<tokio::sync::broadcast::Sender<usb::UsbData>>,
|
||||
pub cart_rx: Option<tokio::sync::broadcast::Receiver<usb::UsbData>>,
|
||||
@@ -75,6 +80,7 @@ pub struct GameSettings {
|
||||
pub load_savestate_slot: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Ui {
|
||||
pub dirs: Dirs,
|
||||
pub config: config::Config,
|
||||
@@ -254,9 +260,9 @@ impl Ui {
|
||||
video: Video {
|
||||
window: std::ptr::null_mut(),
|
||||
fullscreen: false,
|
||||
fps_tx,
|
||||
fps_tx: Some(fps_tx),
|
||||
fps_rx: Some(fps_rx),
|
||||
vis_tx,
|
||||
vis_tx: Some(vis_tx),
|
||||
vis_rx: Some(vis_rx),
|
||||
},
|
||||
usb: Usb {
|
||||
|
||||
+10
-5
@@ -33,7 +33,7 @@ pub struct InputProfile {
|
||||
pub deadzone: i32,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Input {
|
||||
pub input_profiles: std::collections::BTreeMap<String, InputProfile>,
|
||||
pub input_profile_binding: [String; 4],
|
||||
@@ -45,7 +45,7 @@ pub struct Input {
|
||||
pub emulate_vru: bool,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Video {
|
||||
pub upscale: u32,
|
||||
pub ssaa: bool,
|
||||
@@ -56,7 +56,7 @@ pub struct Video {
|
||||
pub crt: bool,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Emulation {
|
||||
pub overclock: bool,
|
||||
pub disable_expansion_pak: bool,
|
||||
@@ -69,13 +69,15 @@ pub struct Cheats {
|
||||
std::collections::HashMap<String, std::collections::HashMap<String, Option<String>>>,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Config {
|
||||
pub input: Input,
|
||||
pub video: Video,
|
||||
pub emulation: Emulation,
|
||||
pub rom_dir: std::path::PathBuf,
|
||||
pub recent_roms: Vec<String>,
|
||||
#[serde(skip)]
|
||||
write_to_disk: bool,
|
||||
}
|
||||
|
||||
impl Drop for Cheats {
|
||||
@@ -113,7 +115,9 @@ impl Cheats {
|
||||
|
||||
impl Drop for Config {
|
||||
fn drop(&mut self) {
|
||||
write_config(self);
|
||||
if self.write_to_disk {
|
||||
write_config(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +176,7 @@ impl Config {
|
||||
},
|
||||
rom_dir: std::path::PathBuf::new(),
|
||||
recent_roms: Vec::new(),
|
||||
write_to_disk: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ pub const DEADZONE_DEFAULT: i32 = 5;
|
||||
|
||||
pub const UNKNOWN_CONTROLLER_NAME: &str = "Unknown controller";
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Controllers {
|
||||
pub rumble: bool,
|
||||
pub game_controller: *mut sdl3_sys::gamepad::SDL_Gamepad,
|
||||
|
||||
+4
-3
@@ -13,6 +13,7 @@ pub enum SaveTypes {
|
||||
Romsave,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Paths {
|
||||
pub eep_file_path: std::path::PathBuf,
|
||||
pub sra_file_path: std::path::PathBuf,
|
||||
@@ -25,19 +26,19 @@ pub struct Paths {
|
||||
|
||||
// the bool indicates whether the save has been written to
|
||||
// if that is the case, it will be flushed to the disk when the program closes
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Save {
|
||||
pub data: Vec<u8>,
|
||||
pub write_pending: bool,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct RomSave {
|
||||
pub data: std::collections::HashMap<u32, u8>,
|
||||
pub write_pending: bool,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Saves {
|
||||
pub eeprom: Save,
|
||||
pub sram: Save,
|
||||
|
||||
Reference in New Issue
Block a user