dolphin icon indicating copy to clipboard operation
dolphin copied to clipboard

Add support to handle standard gecko gameconfig.txt operations

Open Zarklord opened this issue 3 years ago • 19 comments

This adds support for several common gameconfig.txt commands several modding scenes use, including Smash Bros.

This add support for the codeliststart and codelistend commands which allow for larger gecko codes. It also adds support for poke and pokeifequal commands. MinimaLauncher has support for the command searchandpoke, but I was unable to find a usage of it, and was unable to reverse how that code works from MinimaLaunchers source code.

This PR combined with #10464 allows game mods like Project M, Legacy XP and Brawl Minus(after converting the GCT to a gecko cheat, and putting the files on the sd.raw) to be able to boot natively in Dolphin without trying to use MinimaLauncher, or any other loader.

I hacked up a way to set the gameconfig in the QT ui, but I'm not convinced its the best way to do it, and considering I'm not very knowledgeable about the dolphin codebase, if someone has a better place for me to put it, I'll gladly do it.

Zarklord avatar Feb 19 '22 05:02 Zarklord

Is this PR complete and ready for merge? I can’t build and test myself for the next while, but expanded Gecko support seems like a great step for Dolphin, particularly in the wake of Dolphin’s push for mod support (Riivolution etc).

TheMrIron2 avatar Mar 02 '22 11:03 TheMrIron2

@TheMrIron2 somebody should probably review the code as this is my first time writing code for dolphin, but yes, this is ready to merge, and working completely.

Zarklord avatar Mar 02 '22 14:03 Zarklord

Please squash all of these fixups.

AdmiralCurtiss avatar Mar 19 '22 23:03 AdmiralCurtiss

@AdmiralCurtiss done

Zarklord avatar Mar 20 '22 01:03 Zarklord

Can you post some instructions on how to use this, exactly?

To clarify, I am completely unfamiliar with this format, how it is used on console, and what it is supposed to accomplish. So some details and/or examples would be nice.

AdmiralCurtiss avatar Mar 22 '22 04:03 AdmiralCurtiss

I feel should note that this seems to allow for code injection over netplay.

I don't think this allows for any more code injection over netplay than Gecko or AR Codes currently do, but I also am not an expert and could be missing something

Zarklord avatar Mar 22 '22 23:03 Zarklord

Can you post some instructions on how to use this, exactly?

It largely depends on the game, but at least for SSBB(which was my target for adding this feature), the primary purpose is expanding the code list size(thus allowing more gecko codes to be run, which is needed for most smash bro's mods)

An example gameconfig is the following:

codeliststart = 80570000
codelistend = 80580000
poke(800042B8, 60000000)
pokeifequal(803E9930, 4BFECA1D, 803E9930, 60000000)
pokeifequal(803E99A8, 4BFECA1D, 803E99A8, 60000000)
pokeifequal(803E9D5C, 4BFECA1D, 803E9D5C, 60000000)

codeliststart and codelistend are defining the new region of memory for the codes to be stored in. The poke and pokeifequal are game specific, in the case of SSBB from what I can tell these pokes are enabling this expanded memory region to work(the game crashes if I only have the codelist statements but not the poke commands)

Zarklord avatar Mar 22 '22 23:03 Zarklord

Can you post some instructions on how to use this, exactly?

It largely depends on the game, but at least for SSBB(which was my target for adding this feature), the primary purpose is expanding the code list size(thus allowing more gecko codes to be run, which is needed for most smash bro's mods)

An example gameconfig is the following:

codeliststart = 80570000
codelistend = 80580000
poke(800042B8, 60000000)
pokeifequal(803E9930, 4BFECA1D, 803E9930, 60000000)
pokeifequal(803E99A8, 4BFECA1D, 803E99A8, 60000000)
pokeifequal(803E9D5C, 4BFECA1D, 803E9D5C, 60000000)

codeliststart and codelistend are defining the new region of memory for the codes to be stored in. The poke and pokeifequal are game specific, in the case of SSBB from what I can tell these pokes are enabling this expanded memory region to work(the game crashes if I only have the codelist statements but not the poke commands)

Hi, I am currently trying to test this out using the game Goldeneye with a large number of codes.

Can you tell me where the gameconfig.txt file would be placed ? How do you enable the loading of codes? Does the "Enable Cheats" option have to checked? Can this modification use Gecko Codes entered in "Cheats Manager", or do they have to be on sd.raw only in gct format? Thanks!

marks-garage avatar Apr 02 '22 01:04 marks-garage

Hi, I am currently trying to test this out using the game Goldeneye with a large number of codes.

Can you tell me where the gameconfig.txt file would be placed?

The gameconfig is no longer a txt file, instead its a second tab in the Gecko Cheats section for a game's configuration menu.

How do you enable the loading of codes?

There is no enable or disable, if the gameconfig is empty nothing happens, otherwise its read and used

Does the "Enable Cheats" option have to checked?

Yes

Can this modification use Gecko Codes entered in "Cheats Manager", or do they have to be on sd.raw only in gct format? Thanks!

This as far as I'm aware will only be for the "Cheats Manager" gecko codes (but converting from gct to a Cheats Manager Gecko Code is trivial).

Zarklord avatar Apr 02 '22 04:04 Zarklord

I have used Dolphin w/Gecko v1.9 and an original Wii using the following gameconfig.txt: codeliststart = 80703880 codelistend = 8070B860 poke(804B1BA8, 38037FFF)

I noticed your gameconfig.txt specifies a much lower memory address codeliststart = 80570000 codelistend = 80580000 poke(800042B8, 60000000)

Using my gameconfig.txt, no codes are loaded, using your example gameconfig.txt I was able to load codes. I have 100s of lines of gecko codes that already have fixed offsets calculated for the 80703880 to 8070B860 range and would continue to use this range if possible. The range I specified also works on an original Wii and I would like to continue to support both the Wii and Dolphin when I release codes. Can you think of any reason why my range (codeliststart & codelistend) does not appear to work with your mods ? Do you have any suggestions how I could make my range work? It is hard finding any information on Gecko. Thanks again.

marks-garage avatar Apr 02 '22 17:04 marks-garage

I have used Dolphin w/Gecko v1.9 and an original Wii using the following gameconfig.txt: codeliststart = 80703880 codelistend = 8070B860 poke(804B1BA8, 38037FFF)

I noticed your gameconfig.txt specifies a much lower memory address codeliststart = 80570000 codelistend = 80580000 poke(800042B8, 60000000)

Using my gameconfig.txt, no codes are loaded, using your example gameconfig.txt I was able to load codes. I have 100s of lines of gecko codes that already have fixed offsets calculated for the 80703880 to 8070B860 range and would continue to use this range if possible. The range I specified also works on an original Wii and I would like to continue to support both the Wii and Dolphin when I release codes. Can you think of any reason why my range (codeliststart & codelistend) does not appear to work with your mods ? Do you have any suggestions how I could make my range work? It is hard finding any information on Gecko. Thanks again.

Can you turn on logging for Gecko in dolphin and posting the relevant log lines, I'm curious what the output is...

Zarklord avatar Apr 03 '22 00:04 Zarklord

With both my and your "gameconfig.txt" I see this, so maybe the whole process is getting skipped, but it is just a warning. What other logging should enable ?

37:56:516 Core\ConfigManager.cpp:178 N[CORE]: Active title: GoldenEye 007 (SJBE52) 37:56:517 Core\ConfigLoaders\GameConfigLoader.cpp:142 W[CORE]: Unknown game INI option in section Gecko_GameConfig: codelistend 37:56:517 Core\ConfigLoaders\GameConfigLoader.cpp:142 W[CORE]: Unknown game INI option in section Gecko_GameConfig: codeliststart

Here is my SJBE52.ini file. I have tried with and without the "SJBE52:" header under [Gecko_GameConfig]

[Gecko] $Game Starts Up Quicker 08573504 00000000 2002000C 00000000 045C95C0 7F800000 [Gecko_Enabled] $Game Starts Up Quicker [Gecko_GameConfig] SJBE52: codeliststart = 80703880 codelistend = 8070B860 poke(804B1BA8, 38037FFF)

marks-garage avatar Apr 03 '22 01:04 marks-garage

@marks-garage that warning can be safely ignored, if you turn on the "Action Replay" logging, it should spit out some information that can determine if the gameconfig that you created is working.

Zarklord avatar Apr 04 '22 16:04 Zarklord

@marks-garage that warning can be safely ignored, if you turn on the "Action Replay" logging, it should spit out some information that can determine if the gameconfig that you created is working.

I was seeing codes loaded in either case with Action Reply log enabled For some reason I could not get my code range to work, I did try various code ranges for start and end. I ended up using the example start and end range you specified and backed out my offsets within my codes and was able to get it working as expected.

On my real Wii, my gameconfig.txt is this: codeliststart = 80703880 codelistend = 8070B860 poke(804B1BA8, 38037FFF)

Codes are stored in memory somewhere around 0x80002300, with the gameconfig.txt codes are now stored at 0x80703880. Any code I had that used an address that had an address greater than 0x80703880, I needed to add an offset of 7FE0, since 7FE0 worth of bytes were inserted due to the code handler.

This does not appear to happen with Dolphin and your branch, no offset was needed. I am at a loss as to why since I believe the codehander.bin Dolphin uses is identical to the one used on the wii, maybe this is expected behavior and only real Wii hardware requires the offset because of it's memory layout.

marks-garage avatar Apr 10 '22 01:04 marks-garage

Codes are stored in memory somewhere around 0x80002300, with the gameconfig.txt codes are now stored at 0x80703880. Any code I had that used an address that had an address greater than 0x80703880, I needed to add an offset of 7FE0, since 7FE0 worth of bytes were inserted due to the code handler.

Codes are stored in memory at exactly 0x80002338, so I'm with you here, however you lost me at I needed to add an offset of 7FE0, since 7FE0 worth of bytes were inserted due to the code handler. first off, I don't believe any version of the codehandler is 7FE0 bytes long, second off, regardless of the codeliststart/codelistend, the codehandler is always stored at 0x80001800 (on both wii and dolphin), so I don't think I even understand your statements/questions to even begin answering them, if you could try and clarify your statements that would be appreciated.

Zarklord avatar Apr 11 '22 16:04 Zarklord

Sorry, not due to the length of the code handler, but due to the length of the memory section added by the gameconfig.txt

codeliststart = 80703880 codelistend = 8070B860

The 7FE0 offset was the difference of (codelistend -codeliststart). Any gecko code I used that referenced an address above my codeliststart of 80703880 had to have an offset added of 7FE0.

I observed this on a physical wii and also running dolphin and launching gecko v1.9 dol file with codes installed on the sd.raw file.

With your gameconfig.txt branch I no longer need that offset 7FE0 added to my codes.

marks-garage avatar Apr 12 '22 01:04 marks-garage

@marks-garage sorry for the late reply, I'm unaware of any reason that this would be an issue, my only suggestion would be to try messing with the MMU settings, as that's the only thing I can think of that would be affected by this.

Zarklord avatar Apr 19 '22 00:04 Zarklord

@marks-garage sorry for the late reply, I'm unaware of any reason that this would be an issue, my only suggestion would be to try messing with the MMU settings, as that's the only thing I can think of that would be affected by this.

No worries. Not sure it's a real issue, your branch works and I am testing with it, I just had to account for some address differences that may only apply to my configuration and use your example gameconfig.txt.

marks-garage avatar Apr 20 '22 00:04 marks-garage

@AdmiralCurtiss same deal as with #10470 , anything on my end I need to do to get this merged into dolphin?

Zarklord avatar Jul 16 '22 20:07 Zarklord