• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › Development Discussion v
« Previous 1 2 3 4 5 … 117 Next »

Experimenting with modding games using Python
View New Posts | View Today's Posts

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Experimenting with modding games using Python
09-16-2022, 06:07 AM (This post was last modified: 09-16-2022, 06:56 AM by One More Try.)
#1
One More Try Offline
Posting Freak
*****
Posts: 888
Threads: 23
Joined: Dec 2014
I've been experimenting with Felk's WIP Python scripting build.  Normally you would use CodeWrite to make gecko codes to create a complex mod for a game, such as rewriting the camera behavior.  The downsides to gecko are that you have to create the mod using ASM, which can become extremely complex, and it doesn't lend itself to easy editing. You also have to load variables for ASM into dolphin's memory somewhere.

To recreate the capabilities of Gecko ASM mods using Felk's build, I had to add code breakpoint events and register read/writes, which was rather simple to do. Sidenote: I had to remove PowerPC::CheckBreakPoints from JitAsm.cpp, because it's also in Jit.cpp and they both get called, which causes double triggering. It didn't seem to break anything. Not sure on what the proper fix is.

So a mod would look like:

Code:
Declare Variables/Constants

Create code breakpoint event listener with 'while True:' loop to inject the mod every time the breakpoint is hit (once per frame)

If breakpoint == code address
  Read needed registers
  Read needed memory
  Edit values using standard python code rather than ASM.
  Write registers you want to edit
  Write memory you want to edit

Repeat if-statements for other code breakpoints.

I had some worries that the game would keep running as the python code was executing or that it would lag.  Fortunately,
  1. The breakpoints can be log-on-hit, but don't break.  So the game never actually stops.
  2. The async event listener will execute the code before letting the game continue running. So you can be sure your values are injected on the breakpoint
  3. It doesn't appear to increase lag by a noticeable amount.
Code breakpoints are also generally better than memory breakpoints, which seem to have the potential to create a lot of lag.

I'm not sure how many people are interested in this? Gecko codes are usable outside of dolphin, but python codes aren't.
Find
Reply
09-18-2022, 08:11 PM
#2
djneo Offline
Above and Beyond
*******
Posts: 1,316
Threads: 30
Joined: Jan 2016
Sounds interesting as always, Im a fan Smile
specs:

Windows 10
Intel i7-9900K @ 4.9Ghz
32 GB RAM
Nvidia 1080ti
Website Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma