Commit Graph

845 Commits

Author SHA1 Message Date
nattthebear 1c27943707 Make SNES rom memory domain writeable
Use at your own risk
2020-12-13 20:11:58 -05:00
nattthebear 72ea5ce866
Waterbox: Allow SEH unwinding through guest calls. (#2519)
The goal of the separate stacks was to allow this, but I never quite finished the job.  Now, when a SEH exception (generally a Rust panic in a guest syscall handler, or a C# Exception in a callback) tries to unwind through guest code, it works.  Note that we don't actually unwind the guest stack, as there's nothing useful to be gained from that;  When an emulator core throws an exception like this, it should be considered completely hosed.  Throw it out and get a new one.

There were two bugs stopping this from working.

First of all, we had custom thunks that lacked sufficient unwind information for RtlUnwind to get through.  For the sysv <-> msabi adapter, this was fixed by making it regular Rust code instead of hand assembled junkus.  So the compiler generates valid unwind information for all of that.  Then we just JIT a small stub on top in the MsHostSysVGuest code, which needs no unwind information because it won't throw an exception itself and transparently passes execution to something with valid unwind information without invalidating that information.  (NB:  Clr JIT stubs use the same strategy.)  For the host <-> guest stack transition code, a small hand generated unwind stub was added to interop.s that is registered with `RtlAddFunctionTable`.  I've seen the unwind work successfully without this second set of unwind information, but better safe than sorry.

Secondly, our misuse of SubSystemTib caught up with us.  It's an old field, allegedly from OS/2, that we repurposed to hold TLS information needed for the waterbox stack transitions.  Most people think nothing uses it any more, but in fact if it's set to a non-NULL value, but doesn't contain valid information, `KERNELBASE!GetModuleFileNameW` will crash when it tries to get a module name from there.  The fix here was to simply tighten up our usage of SubSystemTib:  We were already nulling it out when returning from guest code, but not when calling back to host code in guest code.

Fixes #2487.  Unwinding of this sort has never worked well in waterbox; the reason why that issue is more recent is that the particular reproducing case of firmware didn't cause an exception in a callback in older code; the exception happened in pure managed code.
2020-12-13 19:12:16 -05:00
nattthebear 6130a7241f Fix Saturn cart detection
Closes #2513.
Similar to ddd229e03d, Mednafen internals expect enumeration setting types to work with MDFN_GetSettingI, but we weren't doing that.
2020-12-12 13:40:33 -05:00
nattthebear 2f2f104e3d Update nyma cores to Mednafen 1.26.1
See Mednafen release notes for full changes.  Mostly just Sega Saturn stuff.

Closes #2464
Closes #2162
2020-12-12 10:50:18 -05:00
Andrew Cook 58cbec6dd6
[PSX] Make Octoshock more debuggable (#2508)
* [PSX] Bodge in a system bus memory domain

Fixes: debugger window crashes when adding a breakpoint

* [PSX] Use Octoshock's built-in disassembler

* [PSX] Add support for execute memcbs to the core

* [PSX] Have memcbs include actual values

* [PSX] Use SafeHandles instead of raw pointers

* [PSX] Use core's internal peek and poke functions for System Bus

* [PSX] Move memory maps into IDebuggable impl to be next to memory map hooks

* [PSX] Revert using SafeHandles

* [PSX] Fire execution callback after trace callback instead of at end of fetch
2020-12-08 11:34:24 -06:00
zeromus e9f365a4a5 libsnes - core dll update for prior commits 2020-12-05 23:37:16 -05:00
TiKevin83 fe25b41c1e
Update libgambatte to r729+ (#2486)
* updating libgambatte from various updates to gambatte-speedrun
2020-11-23 22:59:40 -05:00
nattthebear 98ad14ff47 Fix two semi-related savestate bugs in waterbox.
We had two instances where the act of sealing could lose snapshots that were never recovered.  It's oof.
2020-10-13 09:10:46 -04:00
zeromus 593c01a9e0 octoshock - fix some irregularities in savestate quality. this is intended to address #2214, and at least it passes the "first 60-100 frames in tastudio integrity test" test case given, but I still can't promise it's perfect. 2020-10-04 00:44:35 -04:00
YoshiRulz c0b755a33b
Recompile Cygne, Handy, mGBA, and QuickNes for Linux 2020-09-26 22:19:02 +10:00
nattthebear 507e818374 Fix the faust core so it actually runs again 2020-09-14 07:23:00 -04:00
nattthebear ddd229e03d Fix two mostly unrelated nyma settings issues
Mednafen has extra aliases of enum values that we don't need here and were confusing the system.  Now, NGP no longer has three different "English" options for language.
Internal Mednafen code expects MDFN_GetSettingB ("bool") to work with enum values, so long as those enums are 0 and 1, but we weren't handling that.

Fixes #2385
2020-09-10 08:05:11 -04:00
nattthebear 6047a12ad8 Rework and fix up invisible allocations and sound/video format init in nyma cores.
See the submodule commits for the tech details.  Fixes #2365.  As a side effect, Faust state sizes should be moderately smaller now.
2020-09-07 11:08:09 -04:00
YoshiRulz d5c24b3671
Rebuild mGBA .so 2020-08-31 01:51:32 +10:00
feos eed111bd8b update mgba to 6d754eef3288362c1d4cc40f9a459533baff3f64 2020-08-30 11:58:19 +03:00
YoshiRulz c137252211
Recompile libmgba.dll.so 2020-08-30 06:12:53 +10:00
RetroEdit e5a4bdb0eb
Update the mGBA dll to finish fixing #1620 2020-08-29 19:45:03 +00:00
nattthebear 18780a8752
Fix GBC-AGB bios issues (#2317)
All six combinations (bios, no bios) X (dmg, cgb, cgb in agb) should work now

Closes #2100
2020-08-21 13:14:50 -04:00
zeromus 6dfb09167c update gambatte submodule and post new dll 2020-08-21 00:04:24 -04:00
nattthebear 25bdeb7f69 Use alloc_plain to allocate the md_cart space so it will be writable if needed
This lets us support mapper32k_w without needing extra hacks.  Because of lazystates, this doesn't hurt us on state size either (lazystates did not exists when we did 722358c1b1
2020-08-07 07:17:14 -04:00
Sappharad c3c9a4c81f New GPGX build 2020-08-06 21:44:15 -05:00
nattthebear 9600bc2ce0 ps2 - add fenv support and recompile dobie with it
This isn't so great, and could lead to nondeterminism or abi violations depending on how things use fenv.  For now it's just a dobie experiment
2020-08-06 07:28:24 -04:00
SuuperW ab0ca538f6 update libmelonDS.dll (see SuuperW/melonDS/DSHawk, updates since May 2nd.) 2020-08-02 16:23:40 -05:00
nattthebear 96bee60cda nyma -- only ask the frontend for firmwares the core actually requests
Fixes #2240
2020-08-01 09:16:01 -04:00
nattthebear 78bf2285fc
Waterbox: Add pseudo-thread implementation and experimental DobieStation (PS2) core (#2263)
Waterbox supports threads now, but they're not real threads on the host side because that's complicated and can be nondeterministic. Instead, everything is scheduled to share one host thread. This means that scheduling is actually cooperative and certain patterns of spinlocks and other nonsense can fail to work at all, but "regular" code probably will.

With this, add DobieStation PS2 core. This core was selected because it has threads and is otherwise simple to port; easy to build and a good core/frontend separation. It's not a wonderful core however, with low speed (made abysmally lower by our lack of real threads) and low compatibility, so it remains a curiosity for now.
2020-08-01 07:03:29 -04:00
YoshiRulz ef34944a27
Rebuild libmgba just in case 2020-07-28 17:57:59 +10:00
nattthebear 2cdc978e2f rework mgba callbacks to not be global junks 2020-07-26 15:36:29 -04:00
YoshiRulz 2f5c947a5c
Check-in mGBA binary for Linux 2020-07-27 05:23:37 +10:00
feos 74f9a3db87 mgba: update with https://github.com/TASVideos/mgba/pull/3 2020-07-26 13:26:13 +03:00
zeromus fd30826655 experimental ffmpeg downloading: in place of the ffmpeg encode settings is a download form. This downloads it to the prescribed local location. It then checks to make sure it is the EXACT required version -- the only version we support 2020-07-24 22:25:00 -04:00
nattthebear 1c606c1eb6 waterbox - expose read-only information about the guest memory page table 2020-07-23 16:08:24 -04:00
nattthebear 356abf6c43 Really, actually, truly fix the waterbox savestate snafu, probably
The description in the previous commit is accurate, but the problem runs deeper and was on the whole a complete failure for me to appreciate the difference between active and swapped in on memoryblocks.  Bleeecch.
2020-07-23 15:20:04 -04:00
nattthebear e343f6bd26 Fix a complete savestate snafu in waterbox
This was broken by 175556529e, with two related issues:  When we allowed for some operations to happen even when the block is inactive, we didn't account for the fact that in swapin, the block technically is not active yet (the lock is not on the self), and similarly in swapout, the lock has already been moved out of self.  The former caused all memory areas to revert to RWX at the host OS level after a swap, so no dirty detection was done.  After the former was fixed, the latter caused saved costacks to still get missed.

At the same time we ran into a perfect storm with costacks on Windows; if a stack page is not yet dirty, but we hit a fault for something else, Windows will not call our VEH handler unless the TIB stack extents are satisfactory, since it needs userspace to fix up the TIB extents via VEH or SEH handler, but there's already an exception pending.
2020-07-23 13:30:58 -04:00
nattthebear 07c7c329d3
Experiment to speed up libco and hence libsnes (#2248)
The compiler now can fully inline the co_switch, and with most registers being specified as clobbers and not saved explicitly, the compiler can choose to save only what it needs to (we don't have to defensively save everything).

Practically speaking, the co_switch calls are usually inlined, but the functions they're in don't seem to be that big and don't make direct use of r12..r15 too much anyway, so (push r12..r15, switch, pop r12..r15) is a common emit.  But I see a miniscule FPS increase.
2020-07-22 16:13:19 -04:00
nattthebear c7e8744664 Add an extra exclamation point to indicate that code is VERY IMPORTANT
This broke any waterbox core that called in to native code in the same EnterExit() right after sealing.  All nyma cores were broken, 32x was not, didn't check the rest.  Regressed in 175556529e.

It worked fine in release mode, theoretically
2020-07-18 11:54:05 -04:00
nattthebear 175556529e waterboxhost refactor
Set up a second mirror of guest memory; easily accomplished because we were already using memfd_create / CreateFileMappingW.
This lets us simplify a lot of host code that has to access guest memory that may not be active right now, or might have been mprotect()ed to something weird.  Activate is only needed now to run guest code, or when the C# side wants to peer into guest memory for memory domains and such (waterboxhost does not share the mirror address with the C# side).
2020-07-13 19:38:29 -04:00
nattthebear c8985e3007
Waterbox: Stack Marshalling (#2209)
Waterbox guest code now runs on a stack inside the guest memory space. This removes some potential opportunities for nondeterminism and makes future porting of libco-enabled cores easier.
2020-07-07 17:48:12 -04:00
nattthebear 3a18f6356d Rebuild all of waterbox as sysvabi, not msabi
This helps linux at the expense of windows, except it seems like windows gets a nice little speed up as well
2020-07-03 18:21:48 -04:00
nattthebear 2ee3125724 Refactor gpgx init method to use fewer arguments
Upcoming waterbox changes will likely limit the number of arguments a function can take to 6, which should be enough for anybody
2020-07-03 13:24:54 -04:00
nattthebear fa5885d7a1
Rewrite WaterboxHost in rust. (#2190)
This replaces the old managed one.  The only direct effect of this is to fix some hard to reproduce crashes in bsnes.

In the long run, we'll use this new code to help build more waterbox features.
2020-07-03 11:45:59 -04:00
zeromus dfe027cf8f finish renaming hyper/turbo wbx files 2020-06-20 20:20:42 -04:00
zeromus d917d6f377 update mgba from upstream, including commits 2f2908240178cd418acc6e4942ad9b78939b85a5 and 8f1148498e12197745f62e477d9b8e07382cc72e to address #1593 (at least, it fixes the shrek 2 non-tas scenario) 2020-06-18 04:46:21 -04:00
nattthebear ecdfc66617 nyma big setting update
Moves a lot of settings around, hopefully addressing some concerns
2020-06-14 16:02:33 -04:00
nattthebear 7ba3f6db03 saturn - fix crash in dead or alive
It does look pretty awful with interlacing, but that's not something bizhawk is equipped to solve at present
2020-06-14 10:15:05 -04:00
nattthebear f2b461bed1 nyma - overhaul some input stuff to support some more things
saturn guns and keyboards now work
2020-06-13 18:19:41 -04:00
nattthebear f2b79bb0c1 Fix saturn compilation issue
fixes #2124
2020-06-12 13:20:04 -04:00
nattthebear 8c06de56c2 saturn - support lag flag again 2020-06-11 14:47:26 -04:00
nattthebear f14dace4a0 Move saturn over to nyma, get latest version. 2020-06-11 12:17:10 -04:00
nattthebear 69e30ee33f Decrease state size in pcfx, pce, pce-fast 2020-06-09 10:09:17 -04:00
nattthebear 9bb56f0b5c move pcfx to nymacore 2020-06-09 08:15:06 -04:00