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

Replacing Instruction w/ DME #10

Open
Serah64 opened this issue Apr 16, 2021 · 8 comments
Open

Replacing Instruction w/ DME #10

Serah64 opened this issue Apr 16, 2021 · 8 comments

Comments

@Serah64
Copy link

Serah64 commented Apr 16, 2021

Hey there,

Certain memory addresses and consecutive byte-sized addresses that all serve only one purpose in various games don't seem to create the desired effect.

For example, writing 0x3BE00001 to 0x80269F50 in Super Mario Sunshine is supposed to change which Alt. Nozzle Mario has on from the normal Hover Nozzle to the Rocket Nozzle. By writing to the respective memory addresses with DME, it doesn't change anything. However, if I use Dolphin's built-in memory editor and right-click the address to "Replace Instruction", it works every time.

Additionally, I have confirmed that my instance of DME is hooked and I have even read the values of the addresses after writing to them, and it appears as though they are in fact writing the correct values to the correct addresses, but still it does not appear to work unless I use the "Replace Instruction" feature mentioned above.

If I'm missing a key function that I'm supposed to use, do let me know what it is!

(PS: Am running ipython in Windows Powershell, DME imported and using the write_byte and read_byte functions there to test memory addresses. Also have a custom write_bytes function for the case of writing across multiple addresses. Thanks!)

@henriquegemignani
Copy link
Member

If you're replacing actual instructions, you need to be careful with Dolphin's JIT and instruction cache!
Sadly, the only way I know of doing this is having the game itself call icbi, so I imagine you'll need to do some dol patching. This is what I do for the multiworld things in Randovania.

@Serah64
Copy link
Author

Serah64 commented Apr 16, 2021

Gotcha! Are there functions that allow me to do this in DME, and if so, where can I read about them / could you provide an example?

Thanks so much for the hasty response! :)

@henriquegemignani
Copy link
Member

No, DME handles just changing the game's memory in runtime.

Randovania itself has a big framework for patching a gamecube dol file, including patching a function so it can run code written via remotely via DME or a Nintendont fork.
While I plan to split of part of that into it's own repository, that's not where it is right now :)

Ah, if you do use Randovania's code, be mindful of the different license.

@Serah64
Copy link
Author

Serah64 commented Apr 16, 2021

Understood!

Thanks so much for the help. Yes, I'll be sure to read the license and follow whatever guidelines are necessary.

I'm working on a program that has not been made open-source (as of yet anyways) which will be very similar to Crowd Control, but with a much bigger scope for customization, catalog, and options for Twitch Chat to play with in-game.

We've made an enormous amount of progress so far in Dolphin. DME has been extraordinarily helpful in all of this!

@Serah64 Serah64 closed this as completed Apr 16, 2021
@Serah64 Serah64 reopened this Jul 1, 2021
@Serah64
Copy link
Author

Serah64 commented Jul 1, 2021

So, there's another solution to the issue I initially commented on, it's related to the JIT Cache refreshing. It doesn't happen automatically when memory is written through DME. Is there a command to do it?

Thanks!

@henriquegemignani
Copy link
Member

That is precisely what I said in my first reply.

@Serah64
Copy link
Author

Serah64 commented Jul 1, 2021

I see that, but that's through patching the game. Since Dolphin natively has an option to manually clear the cache while the game is running, I was wondering if there was an object to do it through a terminal. (Currently using py-DME as a library rather than in its application form, using ipython in powershell)

@henriquegemignani
Copy link
Member

That's the only way I know.

Triggering a JIT cache clear involves some form of RPC with Dolphin, which there isn't afaik.

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

No branches or pull requests

2 participants