diff --git a/parallel-rdp/interface.cpp b/parallel-rdp/interface.cpp index cef00628..8bd74538 100644 --- a/parallel-rdp/interface.cpp +++ b/parallel-rdp/interface.cpp @@ -200,6 +200,24 @@ bool sdl_event_filter(void *userdata, SDL_Event *event) case SDL_SCANCODE_RIGHTBRACKET: callback.raise_volume = true; break; + case SDL_SCANCODE_0: + case SDL_SCANCODE_1: + case SDL_SCANCODE_2: + case SDL_SCANCODE_3: + case SDL_SCANCODE_4: + case SDL_SCANCODE_5: + case SDL_SCANCODE_6: + case SDL_SCANCODE_7: + case SDL_SCANCODE_8: + case SDL_SCANCODE_9: + if (event->key.mod & SDL_KMOD_ALT) + { + if (event->key.scancode == SDL_SCANCODE_0) + callback.save_state_slot = 0; + else + callback.save_state_slot = event->key.scancode - SDL_SCANCODE_1 + 1; + } + break; default: break; } @@ -289,6 +307,7 @@ void rdp_init(void *_window, GFX_INFO _gfx_info) callback.emu_running = true; callback.enable_speedlimiter = true; callback.paused = false; + callback.save_state_slot = 0; crop_letterbox = false; } diff --git a/parallel-rdp/interface.hpp b/parallel-rdp/interface.hpp index b26933aa..7c69061d 100644 --- a/parallel-rdp/interface.hpp +++ b/parallel-rdp/interface.hpp @@ -34,6 +34,7 @@ extern "C" bool lower_volume; bool raise_volume; bool paused; + uint32_t save_state_slot; } CALL_BACK; void rdp_init(void *_window, GFX_INFO _gfx_info); diff --git a/src/ui.rs b/src/ui.rs index d529ae8a..ddd4ca29 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -32,6 +32,7 @@ pub struct Storage { pub save_type: Vec, pub paths: storage::Paths, pub saves: storage::Saves, + pub save_state_slot: u32, } pub struct Video { @@ -125,6 +126,7 @@ impl Ui { joysticks, }, storage: Storage { + save_state_slot: 0, save_type: vec![], paths: storage::Paths { eep_file_path: std::path::PathBuf::new(), diff --git a/src/ui/storage.rs b/src/ui/storage.rs index ce7f00a0..f91a1cb0 100644 --- a/src/ui/storage.rs +++ b/src/ui/storage.rs @@ -199,10 +199,13 @@ pub fn init(ui: &mut ui::Ui, rom: &[u8]) { .paths .savestate_file_path .clone_from(&states_path); - ui.storage - .paths - .savestate_file_path - .push(prefix.to_owned() + "-" + &ui.game_hash + ".state"); + ui.storage.paths.savestate_file_path.push( + prefix.to_owned() + + "-" + + &ui.game_hash + + ".state" + + ui.storage.save_state_slot.to_string().as_str(), + ); } pub fn load_saves(ui: &mut ui::Ui, netplay: &mut Option) { diff --git a/src/ui/video.rs b/src/ui/video.rs index ef2a8fc9..0594d8ec 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -143,6 +143,16 @@ pub fn check_callback(device: &mut device::Device) -> bool { } } + if device.ui.storage.save_state_slot != callback.save_state_slot { + println!("Switching save state slot to {}", callback.save_state_slot); + device.ui.storage.save_state_slot = callback.save_state_slot; + device + .ui + .storage + .paths + .savestate_file_path + .set_extension("state".to_owned() + callback.save_state_slot.to_string().as_str()); + } if callback.lower_volume { ui::audio::lower_audio_volume(&mut device.ui); } else if callback.raise_volume {