From 56dc6ecb70e6fc76d32d6a7194acb273b76bfe0e Mon Sep 17 00:00:00 2001 From: David Guillen Fandos Date: Mon, 8 Mar 2021 18:44:03 +0100 Subject: Remove libco This removes libco and all the usages of it (+pthreads). Rewired all dynarecs and interpreter to return after every frame so that libretro can process events. This required to make dynarec re-entrant. Dynarecs were updated to check for new frame on every update (IRQ, cycle exhaustion, I/O write, etc). The performance impact of doing so should be minimal (and definitely outweight the libco gains). While at it, fixed small issues to get a bit more perf: arm dynarec was not idling correctly, mips was using stack when not needed, etc. Tested on PSP (mips), OGA (armv7), Linux (x86 and interpreter). Not tested on Android though. --- main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 0f9bb88..a2f6d8e 100644 --- a/main.c +++ b/main.c @@ -132,6 +132,7 @@ u32 update_gba(void) cpu_ticks += execute_cycles; reg[CHANGED_PC_STATUS] = 0; + reg[COMPLETED_FRAME] = 0; if(gbc_sound_update) { @@ -227,14 +228,14 @@ u32 update_gba(void) oam_update_count = 0; flush_ram_count = 0; - switch_to_main_thread(); - update_gbc_sound(cpu_ticks); gbc_sound_update = 0; process_cheats(); vcount = 0; + // We completed a frame, tell the dynarec to exit to the main thread + reg[COMPLETED_FRAME] = 1; } if(vcount == (dispstat >> 8)) @@ -267,7 +268,7 @@ u32 update_gba(void) if(timer[i].count < execute_cycles) execute_cycles = timer[i].count; } - } while(reg[CPU_HALT_STATE] != CPU_ACTIVE); + } while(reg[CPU_HALT_STATE] != CPU_ACTIVE && !reg[COMPLETED_FRAME]); return execute_cycles; } -- cgit v1.2.3