parent
d968983ceb
commit
cbc973a559
1
build.rs
1
build.rs
@ -204,6 +204,7 @@ fn main() {
|
||||
.allowlist_function("rdp_check_callback")
|
||||
.allowlist_function("rdp_check_framebuffers")
|
||||
.allowlist_function("rdp_state_size")
|
||||
.allowlist_function("rdp_idle")
|
||||
.allowlist_function("rdp_save_state")
|
||||
.allowlist_function("rdp_load_state")
|
||||
.allowlist_function("rdp_set_fps")
|
||||
|
||||
@ -702,19 +702,17 @@ void rdp_check_framebuffers(uint32_t address, uint32_t length) {
|
||||
|
||||
size_t rdp_state_size() { return sizeof(RDP_DEVICE); }
|
||||
|
||||
void rdp_save_state(uint8_t *state, bool rewind) {
|
||||
if (!rewind) { // speed hack for rewind
|
||||
processor->idle();
|
||||
rdram_dirty.assign(gfx_info.RDRAM_SIZE >> 3, false);
|
||||
sync_signal = 0;
|
||||
}
|
||||
void rdp_idle() {
|
||||
processor->idle();
|
||||
rdram_dirty.assign(gfx_info.RDRAM_SIZE >> 3, false);
|
||||
sync_signal = 0;
|
||||
}
|
||||
|
||||
void rdp_save_state(uint8_t *state) {
|
||||
memcpy(state, &rdp_device, sizeof(RDP_DEVICE));
|
||||
}
|
||||
|
||||
void rdp_load_state(GFX_INFO _gfx_info, const uint8_t *state) {
|
||||
sync_signal = 0;
|
||||
rdram_dirty.assign(gfx_info.RDRAM_SIZE >> 3, false);
|
||||
|
||||
gfx_info = _gfx_info;
|
||||
memcpy(&rdp_device, state, sizeof(RDP_DEVICE));
|
||||
}
|
||||
|
||||
@ -61,7 +61,8 @@ uint64_t rdp_process_commands();
|
||||
void rdp_onscreen_message(const char *message, MESSAGE_LENGTH milliseconds);
|
||||
void rdp_check_framebuffers(uint32_t address, uint32_t length);
|
||||
size_t rdp_state_size();
|
||||
void rdp_save_state(uint8_t *state, bool rewind);
|
||||
void rdp_idle();
|
||||
void rdp_save_state(uint8_t *state);
|
||||
void rdp_load_state(GFX_INFO _gfx_info, const uint8_t *state);
|
||||
void rdp_set_fps(uint32_t fps, uint32_t vis);
|
||||
|
||||
|
||||
@ -111,8 +111,12 @@ pub fn process_savestates(device: &mut device::Device) {
|
||||
}
|
||||
|
||||
fn create_savestate(device: &mut device::Device, rewind: bool) {
|
||||
if !rewind {
|
||||
// skipped on rewind as a speed hack
|
||||
ui::video::idle(); // to flush the RDP so the RDRAM is updated
|
||||
}
|
||||
let mut rdp_state: Vec<u8> = vec![0; ui::video::state_size()];
|
||||
ui::video::save_state(rdp_state.as_mut_ptr(), rewind);
|
||||
ui::video::save_state(rdp_state.as_mut_ptr());
|
||||
|
||||
let mut ra_state: Vec<u8> = vec![0; retroachievements::state_size()];
|
||||
retroachievements::save_state(ra_state.as_mut_ptr(), ra_state.len());
|
||||
@ -228,6 +232,8 @@ fn load_savestate(device: &mut device::Device, rewind: bool) {
|
||||
if let Some(mut state) = state_data
|
||||
&& device.rdram.size == state.device.rdram.size
|
||||
{
|
||||
ui::video::idle(); // to flush the RDP so it doesn't overwrite the RDRAM
|
||||
|
||||
device.savestate.last_rewind_saved = state.device.vi.elapsed_time;
|
||||
|
||||
std::mem::swap(&mut device.ui.storage.saves, &mut state.saves);
|
||||
|
||||
@ -161,8 +161,12 @@ pub fn state_size() -> usize {
|
||||
unsafe { rdp_state_size() }
|
||||
}
|
||||
|
||||
pub fn save_state(rdp_state: *mut u8, rewind: bool) {
|
||||
unsafe { rdp_save_state(rdp_state, rewind) }
|
||||
pub fn save_state(rdp_state: *mut u8) {
|
||||
unsafe { rdp_save_state(rdp_state) }
|
||||
}
|
||||
|
||||
pub fn idle() {
|
||||
unsafe { rdp_idle() }
|
||||
}
|
||||
|
||||
pub fn load_state(device: &mut device::Device, rdp_state: *const u8) {
|
||||
|
||||
Reference in New Issue
Block a user