Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement memory callbacks for the new bsnes core #2797

Merged

Conversation

Morilli
Copy link
Collaborator

@Morilli Morilli commented Jun 13, 2021

Basically, everything "works" but the moment a callback gets executed bizhawk crashes. I can not pinpoint what is going on or what is crashing because apparently memory gets corrupted so badly the execution jumps into places it shouldn't be able to.

No idea what's going on or how to fix it, so I'm just putting this here for feedback because it would probably be nice to have this at some point.
Also it's likely libco.

If anyone wants to test, I'm using the SMW-BizHawk.lua script from https://github.com/brunovalads/smw-stuff (needs super mario world rom) with the Lagmeter option enabled (which executes get_registers on callback).

@nattthebear
Copy link
Contributor

Haven't looked yet, but is the crash just #2585?

@Morilli
Copy link
Collaborator Author

Morilli commented Jul 2, 2021

Haven't looked yet, but is the crash just #2585?

Hmm, you might be right about that. I guess whenever host code was calling core functions before it was never a reentrant call.

@Morilli
Copy link
Collaborator Author

Morilli commented Nov 23, 2021

Have rebased onto #3007; should be in a working state now.

@vadosnaprimer
Copy link
Contributor

So this one is ready too?

@Morilli Morilli marked this pull request as ready for review November 23, 2021 19:42
@Morilli Morilli changed the title Trying to implement memory callbacks for the new bsnes core Implement memory callbacks for the new bsnes core Nov 23, 2021
I thought I cherry-picked the right version, welp
@vadosnaprimer
Copy link
Contributor

vadosnaprimer commented Nov 29, 2021

[19:49:56] <natt> The idea seems fine
[19:51:02] <natt> In particular, with modern waterbox it is 100% legal and allowed to have the following call sequence: 1) Emuhawk calls waterbox frameadvance. 2) Transition to guest code and start frame advance. 3) Guest code switches to a different libsnes cothread 4) Guest code calls back into host space.
[19:51:32] <natt> 3 and 4 don't need a thread transition between them. The host does not require the guest to have any particular stack pointer value for 4) (just that it has to be a legal memory address in the guest)
[19:51:53] <natt> I spent a lot of effort making that work and this is the payout
[19:53:17] <natt> (With classic native code, using cothreads like that would cause 4) to have C# managed code running on something which is not understood by win32 as a thread, and creates a giant mess sometimes)

@vadosnaprimer vadosnaprimer merged commit cc38f4b into TASEmulators:master Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants