diff --git a/build.rs b/build.rs index fba69842..89f3ead1 100644 --- a/build.rs +++ b/build.rs @@ -202,7 +202,6 @@ fn main() { .allowlist_function("rdp_process_commands") .allowlist_function("rdp_onscreen_message") .allowlist_function("rdp_check_callback") - .allowlist_function("rdp_new_processor") .allowlist_function("rdp_check_framebuffers") .allowlist_function("rdp_state_size") .allowlist_function("rdp_save_state") diff --git a/parallel-rdp/interface.cpp b/parallel-rdp/interface.cpp index cefb0cc2..f54d2d5d 100644 --- a/parallel-rdp/interface.cpp +++ b/parallel-rdp/interface.cpp @@ -285,15 +285,7 @@ JoystickEvent get_joystick_event() { return joystick_event; } -void rdp_new_processor(GFX_INFO _gfx_info) { - gfx_info = _gfx_info; - - sync_signal = 0; - rdram_dirty.assign(gfx_info.RDRAM_SIZE >> 3, false); - - if (processor) { - delete processor; - } +static void rdp_new_processor() { RDP::CommandProcessorFlags flags = 0; if (gfx_info.upscale == 2) { @@ -380,7 +372,7 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, return; } - rdp_new_processor(gfx_info); + rdp_new_processor(); if (!processor->device_is_supported()) { rdp_close(); @@ -413,6 +405,9 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, achievement_progress_indicator_image = Vulkan::ImageHandle(); fps_image = Vulkan::ImageHandle(); display_fps = false; + + sync_signal = 0; + rdram_dirty.assign(gfx_info.RDRAM_SIZE >> 3, false); } void rdp_close() { @@ -700,7 +695,11 @@ void rdp_save_state(uint8_t *state) { memcpy(state, &rdp_device, sizeof(RDP_DEVICE)); } -void rdp_load_state(const uint8_t *state) { +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)); } diff --git a/parallel-rdp/interface.hpp b/parallel-rdp/interface.hpp index d19e010c..40863096 100644 --- a/parallel-rdp/interface.hpp +++ b/parallel-rdp/interface.hpp @@ -58,11 +58,10 @@ void rdp_render_frame(); CALL_BACK rdp_check_callback(); uint64_t rdp_process_commands(); void rdp_onscreen_message(const char *message, MESSAGE_LENGTH milliseconds); -void rdp_new_processor(GFX_INFO _gfx_info); void rdp_check_framebuffers(uint32_t address, uint32_t length); size_t rdp_state_size(); void rdp_save_state(uint8_t *state); -void rdp_load_state(const 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); JoystickEvent get_joystick_event(); diff --git a/src/ui/video.rs b/src/ui/video.rs index 7e844325..70a1c34a 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -168,8 +168,7 @@ pub fn save_state(rdp_state: *mut u8) { pub fn load_state(device: &mut device::Device, rdp_state: *const u8) { let gfx_info = build_gfx_info(device); unsafe { - rdp_new_processor(gfx_info); - rdp_load_state(rdp_state); + rdp_load_state(gfx_info, rdp_state); for reg in 0..device::vi::VI_REGS_COUNT { rdp_set_vi_register(reg as u32, device.vi.regs[reg]) }