After tinkering about with the memory allocation functionality UniPCemu uses (to keep track of used memory allocations), I've managed to shrink it's current memory usage for those to only 5% of what it used previously. So from 2240KB to only 450KB, freeing up another 1.8MB for user memory or video memory on the PSP :D Although it's only in source control right now, I'm probably making a release version of it soon (together with the other improvements for speed, packet server(Seperated Pcap library support improved on Windows(using Dosbox based dynamic loading of the DLL, allowing for it to become optional unless required for the packet server (when enabled)), now supporting all possible line break formats (Mac, Windows, Linux) in it's inputs, ARP support added for the static IP addresses (allowing for custom addresses outside the DHCP space to be used for each logged in client, disconnect crash fixed)), Sound Blaster IRQ switched to IRQ7 (fixing Windows 9x detection of the IRQ) and various optimizations (up to 75% faster than the previous release so far, reaching it's old speed in certain Windows 9x cases again(Windows 95 at 20%+ realtime speed)))).
Edit: Improved the MIDI active sense a bit(locks).
It still crashes in the JPCSP emulator (null pointer dereference somehow)?
OK. I've changed a few little things on the common emulator side of things:
- Changed the timer thread to wait 1 second before trying to check for it's termination through SDL 1.2 after terminating it (this is only called once when restarting the emulator environment, which shouldn't be much of an issue).
- The timer enabled flag would be cleared in that case now before terminating the thread instead of after (ommitting the unlock and relock for this).
- On SDL 1.2 it won't wait for threads to end using SDL_WaitThread if the thread itself already reported itself having terminated.
- The order of cleaning up the emulation state has been changed in the main thread: First, stop the timers using a soft-reset (keeping the thread alive if it's present). Then, terminate the emulator if needed (which also saves any changed to the machine state on disk (Settings file)). Finally, stop the timer thread itself. (Previously it would stop the timer thread in one call, performing emulator termination afterwards). After all that, the normal cleanup sequence starts (terminating threads followed by SDL cleanup and remainder cleanup (terminating SDL input itself, terminating audio, terminating video, terminating PCap(on available builds), terminating the app itself))). The steps from the termination of the SDL input and onwards are skipped over when soft-resetting the emulation using the settings menu (which seems to run fine on the PSP all the time somehow, even on current releases of UniPCemu).
Only the first few steps (stop timers, finish emulator) are switched now. It will first stop the timers themselves, then emulation (causing the settings to be saved properly) and only after that try to terminate the timer thread itself.
Somehow, I notice that during the termination of the timer thread itself, something seems to trigger the exit callback or actually calling the exit game method directly on the PSP (the JPCSP logs say it's from the "update_thread" thread)?