Improve RDP emulation performance (#228)

* Improve RDP emulation performance

* more

* more

* more

* more
This commit is contained in:
Logan McNaughton
2025-02-07 22:29:20 +01:00
committed by GitHub
parent cd2b3dd143
commit a9afd6bb5c
7 changed files with 36 additions and 68 deletions
+8 -51
View File
@@ -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,
@@ -330,45 +331,6 @@ bool rdp_update_screen()
return emu_running;
}
static uint32_t viCalculateHorizonalWidth(uint32_t hstart, uint32_t xscale, uint32_t width)
{
if (xscale == 0)
return 320;
uint32_t start = ((hstart & 0x03FF0000) >> 16) & 0x3FF;
uint32_t end = (hstart & 0x3FF);
uint32_t delta;
if (end > start)
delta = end - start;
else
delta = start - end;
uint32_t scale = (xscale & 0xFFF);
if (delta == 0)
{
delta = width;
}
return (delta * scale) / 0x400;
}
static uint32_t viCalculateVerticalHeight(uint32_t vstart, uint32_t yscale)
{
if (yscale == 0)
return 240;
uint32_t start = ((vstart & 0x03FF0000) >> 16) & 0x3FF;
uint32_t end = (vstart & 0x3FF);
uint32_t delta;
if (end > start)
delta = end - start;
else
delta = start - end;
uint32_t scale = (yscale & 0xFFF);
return (delta * scale) / 0x800;
}
uint64_t rdp_process_commands()
{
uint64_t interrupt_timer = 0;
@@ -431,19 +393,9 @@ 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)
{
width = 320;
}
uint32_t height = viCalculateVerticalHeight(*gfx_info.VI_V_START_REG, *gfx_info.VI_Y_SCALE_REG);
if (height == 0)
{
height = 240;
}
interrupt_timer = width * height * 4;
interrupt_timer = 60000;
}
cmd_cur += cmd_length;
@@ -455,3 +407,8 @@ uint64_t rdp_process_commands()
return interrupt_timer;
}
void rdp_full_sync()
{
processor->wait_for_timeline(sync_signal);
}