Increase max GeckOS code lines

Started by Dude, March 10, 2010, 02:34:15 PM

Previous topic - Next topic

Dude

I've searched the forums and not found an real answers to this, so forgive me if I've not used enough search terms...

I know that there is a limit to the amount of code lines that can be used, but I forgot what the actually limit is.  I'm in the process of making a few codes for a game and it's getting pretty big lol

So I did the math of what my expected code line count would be and googled what the max limit is in GeckOS.  I saw it mentioned that you can actually INCREASE the max limit by using the "gameconfig.txt" option and also move where the codelist is stored in memory.  I've heard it's possible to more than double the max limit but nobody has actually said HOW.

I checked the documentation and was tempted to just increase the "codelistend" value, but since I don't have an intimate understanding of the Wii's memory I was worried that I might over-write some important memory address :p

Could somebody perhaps provide a quick tutorial and/or what the safest max size could be?

dcx2

Yeah, that's actually a fantastic question.  If you want to find your codes in RAM, you can search Memory Viewer starting at 80000000 for some unique line in one of your codes, like an if or a C2-code.  Sometimes when I only need to make a small change to a C2 code, I just edit it directly in memory; updating C2 codes while the game is running can sometimes be flakey if you aren't careful.  (unless you're using Gecko dotNET, no problems there!  ;D )

That doesn't help you figure out the code size limit, though...maybe Romaap would know?

WiiPower

Quote from: Dude on March 10, 2010, 02:34:15 PM
I've searched the forums and not found an real answers to this, so forgive me if I've not used enough search terms...

I know that there is a limit to the amount of code lines that can be used, but I forgot what the actually limit is.  I'm in the process of making a few codes for a game and it's getting pretty big lol

So I did the math of what my expected code line count would be and googled what the max limit is in GeckOS.  I saw it mentioned that you can actually INCREASE the max limit by using the "gameconfig.txt" option and also move where the codelist is stored in memory.  I've heard it's possible to more than double the max limit but nobody has actually said HOW.

I checked the documentation and was tempted to just increase the "codelistend" value, but since I don't have an intimate understanding of the Wii's memory I was worried that I might over-write some important memory address :p

Could somebody perhaps provide a quick tutorial and/or what the safest max size could be?

The code handler(the code that does ALL the MAGIC) is written to 0x80001800 and after it, there are the codes copied to till 0x80003000. The memory area from 0x80001800-0x80003000 is safe to use, because no game seems to write there, maybe the official SDK even forbids using that.

Then the game has a main.dol, with has fixed offsets where it has to be written to in memory. Look at the 1st 0x100 bytes of a .dol to see what memory areas are directly used by a .dol. Every .dol has an entrypoint, where you have to jump to after writing the .dol into memory to start it. In most cases that's the lowest offset the .dol uses, so if the entrypoint is for example 0x80004000, the memory from 0x80003000-0x80004000 might not _directly_ be used by the .dol, maybe you can set the codelistend to 0x80004000 for it without problems, maybe not. And i'm not sure of you can just set the codelistend without setting its start, you have to try that too. If you find memory that's really not used by a game, you can set the codelist start and end to that area and you codes should work fine.

But the easiest way to get more code lines is to disable the debugger, which results in a different code handler being loaded, that takes less space and leaves more for codes.

Dude

@dcx2:
I didn't know that you could make alterations to the code in memory.  I've always just made the alterations, turned off the codes and then re-enabled the code I modified in Wiird :p
I can see that coming in real handy if I have two identical codes that only have minute differences :)  Just quickly "patch" the code with another address...I wonder if it's possible to make a code to edit your codes...  Kinda like having a main code and using button combinations to change it's addresses and/or values  :D

@WiiPower:
I think most people, like myself, would opt for the safest option :p  I won't bother messing around and trying to find more space for specfic games until I find myself running out of code space for it.

I can't quite figure out the math for finding how many code lines that address range will give me.  Dividing the range by 8 and converting to decimal gives me 768.  Would this be the new code line limit, 768?

Also, I read some more of the documentation and it gave examples...
QuoteExample:
codeliststart = 80345678
Loads the code list to address 80345678.

[value] codelistend - Specify code list end

Example:
codelistend = 80358900
Prevents the code list from writing over address 80358900 or any address after it.

These are purely example addresses?  I only ask since it would give more space lol  Just throwing it out there :)

WiiPower

If you use memory for codes, the game doesn't know that ==> it keeps using _its_ memory as usual. You can only use memory you know that the game doesn't use it.

Oh and forget about just increasing the codelistend, i forgot a "few" important memory offsets:
http://wiibrew.org/wiki/Memory_Map

dcx2

Quote from: Dude on March 10, 2010, 06:05:21 PM
@dcx2:
I didn't know that you could make alterations to the code in memory.  I've always just made the alterations, turned off the codes and then re-enabled the code I modified in Wiird :p
I can see that coming in real handy if I have two identical codes that only have minute differences :)  Just quickly "patch" the code with another address...I wonder if it's possible to make a code to edit your codes...  Kinda like having a main code and using button combinations to change it's addresses and/or values  :D
You can, using a 4E code type.  In fact, I posted about this a while ago.

http://wiird.l0nk.org/forum/index.php/topic,5135.0.html

Unfortunately, I haven't found a good use for it yet.  There are usually simpler ways...but it's still a fun experiment!

WiiPower: Thank you!  I always wondered about these things and your posts have helped me quite a bit.

Dude

#6
I don't have adequate knowledge regarding the various memory regions :p  My knowledge extends as far as knowing the memory areas of mem1, mem2, etc as it relates to locating codes lol

Ok, I'll be using gameconfig.txt at the root of the SD Card and I'm setting everything I need...

To clarify, I intend to use all of the "safe" memory range that you stated, WiiPower.  I know that the my max limit at present is 255 code lines.  So a few quick questions:

What would this new memory area give me in terms of max code lines?

It looks as though you need to set these options PER GAME.  Will I need to set this memory area for code lines in every game I have, or can I set this at the start of the textfile before stating the independant options for each game.  This would make the setting the new "default" and cover every game?

Edit
@dc2x:
Ohhh, nice!  I checked your thread.  there has got to be some weird and wonderful use for this yet :D  My first thought would be to enable seriously dynamic codes to solve those few rare things that ASM can't achieve lol  Complex, but could be worth it.

WiiPower

If there was another bigger memory area that is safe to use, then Gecko OS would use it already. You have to find out what memory can be used for each game alone. And i guess most games use all their memory, and you can't get more memory.

Dude

Aww, well.  Worth asking though :p

I'll have to probe around and see what additional space I can find out of the games I'm working on.

Thanks though guys  :)