* Partial port of graphics debugger to new BSNES
* minimal "working" copy-paste
* small fix for the previous commit
* Implement more stuff
* no idea whose responsibility "EnterExit" is but this should work
* add support for backdropcolor
i have 0% trust in this code
* implement mode7, apply backcolor on load
* 🙈
un-"implement" the nonfunctional scanlinehookmanager as well as the non-functional palette setting logic
- this may actually break config lol
* don't break libsnes config
* Provide IBSNESForGfxDebugger in the subbsnes core
* Remove redundant semicolon
* Clean up diff of `comboPalette_SelectedIndexChanged`
* Fix crash
Co-authored-by: YoshiRulz <OSSYoshiRulz@gmail.com>
* BSNESv115+: Replace the 'snes_audio_sample' callback with a dynamic audio sample vector to reduce callbacks
* fix integration for subbsnes core
* reduce buffer allocations
- also make frame setter private now that it's possible
* BSNESv115: allow subframe inputs
* BSNESv115: Implement ICycleTiming
may be correct, not sure
* BSNESv115: add dedicated subframe core
I have probably overlooked something...
* Don't implement ICycleTiming in the non-subframe core
requires re-implementing the "FrameAdvance" function in the subframe core
* Register previously missing services in the subframe core as well
* Wire up SubBsnes everywhere in the frontend
* Change reset cycle to reset instruction
* Deduplicate some code
* Slightly rework frame advance logic. The main intent here is to prevent a case where two frames are ran within a single "frame." The current code probably wouldn't crash due to that, but best not to do that.
Also make SGB work here. A bit of a joke since you really can only abuse it for subframe resets, but might as well especially with the settings implying it's possible (and someone is bound to complain).
Co-authored-by: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Deflate compression in rewinder is now zstd compression
Binary blobs in zip files are zstd compressed (text is uncompresed for user ease).
All wbx cores and resources are re-compressed with zstd, wbx build scripts are changed to account for this. Shaves off a bit with download size and it's faster to decompress to.
This never really worked. Besides being unusuably slow and not very accurate, there was a miscompliation problem that caused release builds to not function.
Squashed commit of the following:
commit 1f6cdb99a8486b3f89395b2bd3f13f730e21f743
Merge: bcef146d7 ecd428898
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 03:05:12 2022 -0700
Merge branch 'transfer_pak_ares' of https://github.com/CasualPokePlayer/BizHawk into transfer_pak_ares
commit bcef146d7d62e5ce435ae3fc4d585d71d98bec52
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 03:05:05 2022 -0700
a
commit ecd4288980f7311eba3bdd0a9d1a3fca02e42e43
Merge: 86a7e3e85 ccb24cc79
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 02:57:00 2022 -0700
Merge branch 'transfer_pak_ares' of https://github.com/CasualPokePlayer/BizHawk into transfer_pak_ares
commit 86a7e3e85bc1b3cb979671edcbfca66e69d5212b
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 02:56:50 2022 -0700
a
commit ccb24cc79fd922b1e3e3b80d660c7b7696f0cf84
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 02:51:36 2022 -0700
a
commit 285fd66f9240dfa502a269adb19cc1f3d11236c5
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 02:02:31 2022 -0700
misc
commit 9fb76345e4507cbd53ab5e4c2c61a5cb992b7241
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 01:50:46 2022 -0700
frontend hookup
commit dabee3a4d63c5801e3147dd758e3c187be0ab8bd
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Mon Mar 21 01:26:48 2022 -0700
actually hook other shit up also delete some shit
commit df632d6ddf6eaeb61ad3ad640851709c2614bfbd
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 21:37:18 2022 -0700
a
commit 143c4039453290ef1e8a4cf53ddea534efa0cea3
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 21:28:07 2022 -0700
a
commit fd75dcc5150860171e3d96fd0bcb4749eeb99378
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 21:03:51 2022 -0700
a
commit ea039643e9a093f63f8dc8c7446e9e70f7f965f0
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 19:56:46 2022 -0700
a
commit 8b373d2ba547cd1ab61360e8129f31452014c728
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 19:33:47 2022 -0700
a
commit dc18a90bebcae013aca4494c1e0a83603dbdbea6
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 19:18:34 2022 -0700
a
commit 3d0eba5f57d95f7cfd74b662f70a40cac5638539
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 19:16:56 2022 -0700
a
commit d97ea34753c007663ea0e629df8830e6aae98e91
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 18:28:01 2022 -0700
a
commit 7a1fe0442c7dd6425048207a19b1b18f9dc3e344
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 17:22:10 2022 -0700
a
commit 421de8ebb8c02736e65f28a88a17cabf297c6e10
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 16:57:47 2022 -0700
is this right?
commit 9fcaa1905b6e3b6bc73c8e8c15c55cab06ddb7f4
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 15:57:32 2022 -0700
rework audio
commit 602577ded89f2fd7d4514792e4f9f485235ce2f1
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 14:54:29 2022 -0700
doh
commit 5521dab709551d9f02bd0cf0d979d8a3860541c6
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 14:42:50 2022 -0700
a
commit bc10461eb9d47bea5acc7cc22963b8e7025b9a31
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 14:41:17 2022 -0700
a
commit d088719299bc0946962bba9404469fe9628633c6
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 14:25:07 2022 -0700
a
commit d425c49bc2ea7925f485379dad33326fa8566754
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 14:18:33 2022 -0700
a
commit ea7c69a512ce84977ad92be0c3f97f396dcf13a7
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 14:13:41 2022 -0700
a
commit b350580b5c8ce455d6ffa41237c2564e8fa76a58
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 14:05:46 2022 -0700
a
commit 5983b23e760e5ca8a3c8141075f383275da570b4
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 13:57:25 2022 -0700
a
commit 12de82e8841284cb70ec02765d86e3729661dcb4
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 13:46:58 2022 -0700
a
commit 992bdf114c24a8a3d37c110629f9a66bfaf21cf8
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 13:05:28 2022 -0700
a
commit 3637649dde95ff4fb24474ee0d1dde795cbc5fe3
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 12:49:52 2022 -0700
o
commit 7d7264b92822ce34ba5412f4cf869c6a4e6fb9b9
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 12:41:55 2022 -0700
testing time
commit bb3a2f89861cdf429091d8253a656e782b68e33b
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 12:14:30 2022 -0700
bleh
commit df46cc34d6edc312b519c98b6c7be3ac6ab89bd2
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 06:18:28 2022 -0700
bleh
commit 21c28a81726ab9a9f206a58424e5434cd0bac1a8
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 05:43:39 2022 -0700
hack test time
commit 3d9e462addc20d6b6d8ffc41595c4751d6fc2975
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 05:36:51 2022 -0700
oh right need to build it
commit a970194f64ac0652f97236debd39e142b01d4dcf
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 05:32:07 2022 -0700
guessing not endianess, maybe need more reset state work?
commit 5d4c11dbf2f767e63d505da22d6bbdef76a4e28b
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 05:23:52 2022 -0700
is this a endianess issue?
commit c5fcd687f5e2c62b1f0f065a3b9c9ffa30867eeb
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 05:11:43 2022 -0700
debug time
commit 437071710ea040a466dd25d7fe691fcdbdb95030
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 05:03:58 2022 -0700
better emulate reset thingie
commit e02503c3f74aa89784b5cc43d1fe5daa6fedf5d3
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Sun Mar 20 04:31:42 2022 -0700
initial mouse and transfer pak support
* Fix#3173 by only calling bus.map() on initial power, not subsequent calls
* yeah screw that, we'll just lock the bus to prevent map calls from going through
* initialize peekable in reset with false, just for safety i guess
* prep for handling multi-threaded renderer in melon, along with some other cleanups
* initial core side support for mt rendering, probably crashes?
* oops
* ok use ref not in
* testing
* poor man's semaphore
* clean this up, hopefully fix a deadlock?
* update submodule
* reduce submodule diff
* cleanup
* hook up thread wait cb
* maybe make shutdown not hardlock?
* oops
* oops
* testing
* testing
* a
* lol
* fuck
* a
* oops
* a
* a
* a
* a
* a
* a
* a
* a
* a
* if false this
* a
* a
* a
* bleh
* a
* update to upstream
* oh right lua
* region override for bsnes
* hook up SnesInitData right. still needs region override sync setting
* settings stuff, also need to make sure sameboy is using the right region for sgb
* and build
* clearer struct definition; move struct to header file
Co-authored-by: Morilli <35152647+Morilli@users.noreply.github.com>
* prep for performance ares64 core, needs work unmanaged side
* get this going
* rebuild this
* apparently build didnt get cp'd? need to investigate
* fix build, other shit
* suppress these warnings
* tweaks and builds
* apparently bizinvoker doesnt like having LibAres64 class shared between non-waterbox and waterboxed, so split it.
also states for performance core
* builds
* fix this option, describe supersampling properly
* penguin64
* Large SRAM
Cherry pick changes in order to run games with SRAM support for games larger than 8MB based on the existing commit by ekeeke in Genesis-Plus-GX.
e6ab7563e7
* Revert "Large SRAM"
Removes changes to the cd cart files and contains the newly built gpgx.wbx.gz.
* ares64
* build, currently cherry picking c9af34027b to build this
* some work
* commit the frontend work. crashes on some NR_SCHED_GETAFFINITY syscall
* delete this
* fix oopsie, add debugging shit
* getting closer...
* what the fuck is this mame shit doing???
* fuck
* it's one of these isn't it
* fucking hell
* at least it's not crashing on init now
* bleh
* let's see if this works?
* audio i think?
* oh right, need to disable threading here since that's not wbx supported
* testing
* testing
* testing...
* testing
* wtf?
* lol
* it's doing something now i guess?
* let's try this
* maybe this will catch this bullshit?
* lol
* the fuck?
* what
* meh
* bleh
* let's have some fun
* bleh
* bleh
* bleh
* maybe this works better
* let's try this?
* meh
* this probably will break
* lol
* meh
* a
* a
* a
* a
* a
* meh
* a
* a
* b
* alloc invisible these video buffers
* a
* actually build
* bleh
* well uhhhhhhhh let's see if this blows up for fun i guess?
* bleh
* yeah that when as well as expected
* push this
* bleh
* bleh
* bleh
* a
* dirty hackery
* fuck space/tabs
* hook up input
* hook up input frontend side
* reset/power
* going to have to commit to dumb workaround here i guess?
* fuck this bullshit crash
* cic stuff
* oops
* testing
* hook up save detection
* memory domains and saveram shit
* oops
* someday i'll get macros right
* let's get this kinda reproducable
* build
* bleh
* frontend shit
* bleh
* testing
* a
* fucking
* a
* a
* a
* workaround C# bullshit marshalling maybe?
* revert that, let's hack it on c# side instead
* disgusting hack
* fuck c#
* fix oopsies for eeprom/flash and fuck c#
* apparently explicit layout just dont work, thanks c#!
* correct orientation
* actually fix orientation
* testing
* bleh
* b
* a
* fix crash here
* rumble getter
* hook up rumble with frontend, cache readonly controller settings on core init
* remove old experiment
* make clean make install
* update melon
* frontend work
* make this work (i think?)
* fucking merge conflicts
* bleh
* hack up DSi support, very hardcoded atm, but at least states are reasonable
* add IS_DSI load flag
* frontend work bleh
* oops forgot to push
* ok fine apparently that doesnt display right
* oops
* prevent zealous release screen calls, DSi firmware seems to not like it?
* support for loading DSiWare title
* dsiware
* oh right this bullshit
* oops
* will this work
* why the fuck was this signed
* 0 out these hashes, these are also unique per console, no hope verifying these
* testing...
* more testing...
* this is probably a bad idea
* well this probably fixes state size issues
* time to debug this
* oh derp it's just not enough memory in invis heap
* let's see if this works?
* apparently this breaks slow ppu?
* testing...
* testing...
* testing...
* sanity checking
* let's try again
* i do not know what the fuck is up with this emulator nor do i care enough, state size is still under a mb anyways with slow ppu
* oops forgot to commit this
* resolve some issues
* tweak memory allocation sizes
* dont save more cache stuff
* wtf was i even thinking here
* move comment back to original pos, comment on double loading
* nymashock wbx
* shit
* lagflag stuff
* saveram stuff
* debugging how this works
* lets see if this works better
* fuck strings
* ok let's do this right i think
* probably have this all working
* get repo in
* add nymashock to build scripts
* also update this readme
* get rid of this default, seems to break internally anyways?
* ""fix"" dualshock (wtf to do with rumble???), make override defaults actually default, add hack to allow for overriding default controllers
* hide useless rtc settings
* hack fix override defaults for controllers, get something going for nyma psx schema
* oops dont forget this
* make fucking default controllers hack work (what the fuck is this code???) also complete schema and mnemonics
* FUCKING FIX THIS BULLSHIT DEFAULT
* let's make this a little nicer
* add mnemonics for □/△/○, fixes weirdness with input display
* fix weird overscan issues when multiwidth + no-interlacing happens at the same time
* do this "properly"
* analog mnemonics
* default controls for dualshock/gamepad filled
* set nymashock as preferred core
* apparently this didnt get committed?
* update README too
* control name fix
* Revert "control name fix"
This reverts commit a3cae89b18.
Co-authored-by: YoshiRulz <OSSYoshiRulz@gmail.com>
* BSNESv115+: get rid of input_state + input_poll; just poll
* call `snes_controller_latch` on latches done in the core,
- this now also actually calls the InputCallbackSystem
- needed some edits in the core to support executing the callback even when no controller is connected in port 1
* Fix and somewhat normalize the SnesCallbacks order
- saveram was not working at all on certain roms, as the "CARTRIDGE_RAM" memory domain was returning a null pointer (similar thing for "CARTRIDGE_ROM"; changed it to correctly return the current rom)
- add sa1_bwram domain for clarity and an SGB_ROM domain
* Actually working callbacks
now actually work after natt's changes
* Set whether memory hooks exist every frame to prevent unnecessary function calls if not
commit af7cadfce4b750f8b1b23476c281bd2dfe027225
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Tue Nov 2 22:43:21 2021 -0700
right, rename these too
commit e27197d18ad33af53729b1a57ee4a048189c41c4
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Tue Nov 2 22:40:42 2021 -0700
build
commit 1af068f11f553ade70999fb2c640ee98e054aa36
Author: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com>
Date: Tue Nov 2 22:37:28 2021 -0700
new way to do mic input for melonds
* add support for more SGB firmware
* replace illegally provided bootroms with legal homebrew bootroms
* let's swap these with homebrew bootroms too
* add builds
* this should probably be preferred
* Fix incorrect assignment
* Fix whitespace changes to Designer files
Co-authored-by: Morilli <35152647+Morilli@users.noreply.github.com>
Co-authored-by: YoshiRulz <OSSYoshiRulz@gmail.com>
- also patched out the left/right and up/down handling in the core, where it didn't belong
- also fixed the existing payloadcontroller because it wasn't working at all lol
* Slam all this shit in here i don't care
* no lzma pls
* un-hack things that i hacked earlier (closer to bsnes source now)
* remove more unused files
* remove more files
* get some stuff working on this weird ass branch
* do this to get actual video (holy shit it works) while palette is incorrect
* make video look correct and hopefully fix stack waterbox allocation size uh ?
* Move the new bsnes core to its own dir as a new core and get input working
* remove leftover files from old bsnes
* fix some shit for now
* make lag frame detection work
* Improve cartridge loading to hopefully make sgb work (haven't tested)
- also changes some audio buffer stuff, might be better or worse than before idk
- need to figure out the saveram stuff
- path requests might actually completely fail atm, no idea how to verify that
* refactor to use a switch instead of some weird array with function pointers
- and implement snes_get_mapper, might be helpful or smth idk
* implement entropy c++-side and delete all this useless code holy
* delete dumb unnecessary code
* implement snes_peek_logical_register c++-side
* normalize all indentation
* attempt to properly support sharprtc and epsonrtc data loading and writing
* Duplicate winforms code to add entropy support c#-side and implement layer_enable functionality
The duplicated code is just so i can have a proper window for the new bsnes core. I do not like duplicating code like this, so this should be improved if possible
* Checkpoint for the start of getting rid of the ugly api wrapper stuff
* Next checkpoint for a full api refactor
* bullshit denied
just no.
every file is either copied or manually edited or written from scratch etc.
do not. force. one indent_style on every single file.
It just does not work.
* remove the entire eMessage_CMD handling and convert to native function calls
* general improvements regarding functionality
- adds hotfixes and fast_ppu core options
- add back the alwaysDoubleSize setting
- use bsnes's own serialize function for savestating now
- generate and use the color palette only in c# cause it doesn't need to be on the c++-side
- and more cleanup like always
* somewhat implement IMemoryDomains
* Implement trace logger and cleanup more unused stuff
* Implement ISaveRam, fix controller mapping for TAStudio and remove the pwrap stuff
* Fix ISaveRam, add a controller configuration box for the new core, (hopefully) fix controller inputs
- also differentiates BG prio0 and prio1 now (with options for it)
- some minor irrelevant edits in bsnes source
* Cleanup some more and optimize a bit
* Support firmware loading and make sgb work (hopefully)
* Remove all unused files
* Add back CropSGBFrame option and cleanup snes_video_refresh logic
* Some hopefully sensible changes
* One more cleanup pass
* Change to new PortedCore attribute
necessary after the changes in 98b07c42d5
Co-authored-by: nattthebear <goyuken@gmail.com>
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.
* Move .so libraries to dll dir, update some build scripts
* Move OpenTK.dll.config with OpenTK.dll
* Keep EmuHawkMono.sh in Windows-built artifacts
* Add Package.sh to match QuickTestBuildAndPackage.bat
used as `Dist/BuildRelease.sh && Dist/Package.sh`
* Update GitLab CI to use Package.sh
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
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
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.
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.
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.
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.
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
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).
Bizhawk never would hit this because it only ever runs waterboxes in one host thread, but an application that spun up many threads and ran waterboxes in each would leak 32 bytes of heap for each native thread destroyed, which is super duper not really meaningful at all
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.
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.
Cores that used the .invisible section to store data were saving it; this was a regression from before, so PCFX states should be back down to the previous release size, or perhaps a bit smaller.
Add the ability to dirty track libco cothreads, as used in the bsnes core. This saves a lot of space in those states and they're now quite competitive in size.
some bsnes cothreads call callbacks that hit managed threads. We shouldn't do that, but we do, and sometimes those threads run MSVC's __stkchk which can, depending on circumstances, blow up if the thread extents aren't set.
This also means that we cannot save space on a lot of cothread stacks because __stkchck will blow up any detection guards we try
The waterbox system now uses host os facilities to track whether memory has been written to, to automatically choose what thing to savestate. This results in a large size decrease for some cores, like snes9x or gpgx (when running cartridge games). Doesn't do much for cores that were already memory efficient, or for bsnes because of libco compatibility issues; but those cores don't regress either.
and who said waterbox can't thread. well, it sort of can't. but it sort of can.
the speedup isn't that great, but speed is now pretty close (5%?) to snes9x in the only game that matters (final fantasy 5)
For the external cores, I simply listed whatever the release build we have right now built them with. There are other makefiles and such hanging around...
Nyma cores have to move some big complex structs on init and it's annoying and error prone. This solution is not fast, but these are one time transfers anyway, and it does keep code size and saved size down. Architecture yay.
This was benign, because libunwind will ignore a frame header it doesn't understand (__eh_frame was still fine). But now there's no spew in the console. And over the next 50 years it will save a combined 0.3 seconds of cpu time
The goal here is to provide an unwind implementation that works. We (probably) don't have a working ldso, so reconfigure libunwind to work without that. To do that, it needs __eh_frame_* variables which it can addressof to find the locations of .eh_frame and .eh_frame_hdr. There is no way I could get gold to add these at all, so switch back to ld and add a custom linkscript. The custom linkscript gives us the opportunity to simplify the savestate memory mapping stuff inside ElfLoader, which should knock a bit of time off of state loads -- those VirtualProtect calls are not cheap. This also removes a potential source of nondeterminism with certain clever out of range pointers.
Any waterbox core that I didn't recompile for this commit will assert now until it is recompiled, because .wbxsyscall is in the wrong palace.
Trigger condition: Any 32x rom smaller than 4MB in total size that tries to read out of bounds between its actual end and the 4MB limit
I've fixed the emulator crash, but I do not know if such roms are actually mirroring correctly - they probably aren't
Create an all new waterbox build environment:
WSL2 + Ubuntu 20.04 LTS (Other linuxes may work)
Musl libc with waterbox customizations
LLVM's libclang-rt, libunwind, libcxxabi, libcxx
Static linking to elf files
Compared with the old system, this is easier to set up a dev env for and easier to update in the future. The executables are larger but produce smaller savestates due to static linking. The modern toolchain means advanced library features and language features that sometimes appear in some upstream cores will be reusable.
If you tried setting your gains to 100 in the previous patch, it worked sort of, but I decided to incorporate ekeeke/Genesis-Plus-GX@f6f4556 as well to actually fix it completely, and rescale the setting properly so that 1.0 really is neutral gain.
Fixes#1319
gpgx upstream automatically gives 64KiB sram to every game of size 2MB or lower, unless specifically overrided. That sucks and we don't do it. But some games do need it; there's not enough information to autodetect otherwise. So add a flag that we can set in gameDB for it, and set it true for two known games that have problems otherwise.
mapper_32k_w expects to be able to write to rom area, so those roms now need larger savestate space
We could be extra clever and alloc_invisible the space and then restore after loadstate, but this pokeymans garbage doesn't deserve that work