diff --git a/build.rs b/build.rs index 807dcd3..a717c62 100644 --- a/build.rs +++ b/build.rs @@ -98,6 +98,7 @@ fn main() { .allowlist_function("rdp_close") .allowlist_function("rdp_set_vi_register") .allowlist_function("rdp_update_screen") + .allowlist_function("rdp_full_sync") .allowlist_function("rdp_process_commands") .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .generate() diff --git a/parallel-rdp/interface.cpp b/parallel-rdp/interface.cpp index c6635c0..5f8707d 100644 --- a/parallel-rdp/interface.cpp +++ b/parallel-rdp/interface.cpp @@ -62,6 +62,7 @@ static int cmd_cur; static int cmd_ptr; static bool emu_running; static GFX_INFO gfx_info; +static uint64_t sync_signal; static const unsigned cmd_len_lut[64] = { 1, @@ -383,8 +384,6 @@ uint64_t rdp_process_commands() if ((cmd_ptr + length) & ~(0x0003FFFF >> 3)) return interrupt_timer; - *gfx_info.DPC_STATUS_REG |= DP_STATUS_PIPE_BUSY | DP_STATUS_START_GCLK; - uint32_t offset = DP_CURRENT; if (*gfx_info.DPC_STATUS_REG & DP_STATUS_XBUS_DMA) { @@ -433,7 +432,7 @@ uint64_t rdp_process_commands() if (RDP::Op(command) == RDP::Op::SyncFull) { - processor->wait_for_timeline(processor->signal_timeline()); + sync_signal = processor->signal_timeline(); uint32_t width = viCalculateHorizonalWidth(*gfx_info.VI_H_START_REG, *gfx_info.VI_X_SCALE_REG, *gfx_info.VI_WIDTH_REG); if (width == 0) @@ -446,8 +445,6 @@ uint64_t rdp_process_commands() height = 240; } interrupt_timer = width * height * 4; - - *gfx_info.DPC_STATUS_REG &= ~(DP_STATUS_PIPE_BUSY | DP_STATUS_START_GCLK); } cmd_cur += cmd_length; @@ -456,7 +453,11 @@ uint64_t rdp_process_commands() cmd_ptr = 0; cmd_cur = 0; *gfx_info.DPC_CURRENT_REG = *gfx_info.DPC_END_REG; - *gfx_info.DPC_STATUS_REG |= DP_STATUS_CBUF_READY; return interrupt_timer; } + +void rdp_full_sync() +{ + processor->wait_for_timeline(sync_signal); +} diff --git a/parallel-rdp/interface.hpp b/parallel-rdp/interface.hpp index b53268e..67075e8 100644 --- a/parallel-rdp/interface.hpp +++ b/parallel-rdp/interface.hpp @@ -28,6 +28,7 @@ extern "C" void rdp_set_vi_register(uint32_t reg, uint32_t value); bool rdp_update_screen(); uint64_t rdp_process_commands(); + void rdp_full_sync(); #ifdef __cplusplus } diff --git a/src/device/rdp.rs b/src/device/rdp.rs index c61f4db..5d46e61 100644 --- a/src/device/rdp.rs +++ b/src/device/rdp.rs @@ -102,6 +102,7 @@ pub fn write_regs_dpc(device: &mut device::Device, address: u64, value: u32, mas fn run_rdp(device: &mut device::Device) { let timer = ui::video::process_rdp_list(); + device.rdp.regs_dpc[DPC_STATUS_REG as usize] |= DPC_STATUS_START_GCLK | DPC_STATUS_PIPE_BUSY; if timer != 0 { device::events::create_event( @@ -183,5 +184,9 @@ pub fn init(device: &mut device::Device) { } fn rdp_interrupt_event(device: &mut device::Device) { + device.rdp.regs_dpc[DPC_STATUS_REG as usize] &= !(DPC_STATUS_START_GCLK | DPC_STATUS_PIPE_BUSY); + + ui::video::full_sync(); + device::mi::set_rcp_interrupt(device, device::mi::MI_INTR_DP) } diff --git a/src/ui/video.rs b/src/ui/video.rs index dfa52e5..ff38bf8 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -73,6 +73,10 @@ pub fn process_rdp_list() -> u64 { unsafe { rdp_process_commands() } } +pub fn full_sync() { + unsafe { rdp_full_sync() } +} + pub fn draw_text(text: &str, renderer: *mut sdl3_sys::render::SDL_Renderer, font: &rusttype::Font) { let text_size = 32; let scale = rusttype::Scale::uniform(text_size as f32);