Detailed Guide on Basic Codetypes (Again, for new hackers)

Started by REDSOXROX, January 13, 2009, 11:50:49 PM

Previous topic - Next topic

REDSOXROX

'Cause I was bored

Using Basic Codetypes

Hi again, today we will be learning, refreshing our memory, or coming to understand the basic codetypes.

First off I'd like to link to the codetype document by Kenobi: http://www.usbgecko.com/codetypes.htm

If you can understand that, this will be of no use to you.

In this guide a variety of code examples will be used. To find them and more cool codes, just visit http://www.usbgecko.com/codes/.

BA, PO, etc The following contains information by Kenobi in the codetype doc Additions by me are in italics

ba : Base Address. Set at 0x80000000 each time the code handler is executed. Each time the ba is added to a code address, the code handler do : address = address + (ba & 0xFE000000). You can modify it, however if you do, don't forget to reset it to its original value after. To reset the BA in most games, make the last line of the code E0000000 80008000

po : Pointer. Set at 0x80000000 each time the code handler is executed. Each time the po is added to a code address, the code handler do : address = address + po. You can modify it at will. This is used in games where levels have different amounts of memory, so the address for something moves from level to level. Example: Super Mario Galaxy (See the guides by dexter0 for more information!

grN : "Gecko Register N". It's not a real register, like r0 or r1. It's a 32-bits value, for which the Gecko has reserved a place in memory. N can range from 0x0 to 0xF. You can store/load anything in it, however be careful that other codes could overwrite your value. Don't expect it to be the same each time the code handler is executed. If you want to store a value that must not change, try to use a "real" address ouside of the code handler, or use the 46/4E code types along with a goto code type. Note that grN are stored before the gecko/code handler. That mean they should always be accessible at a static address : 0x80001804. [0x80001804]=gr0, [0x80001808]=gr1,...,[0x80001840]=grF. That way you can access them directly, when inserting an asm routine for example.

bN : "Block N". A block is made of two 32bits value. They are used to store information for the repeat/return/goto/gosub codes. b0 data is stored at 0x80001844, b1 data at 0x8000184C...

CT : Code Type. Range from 0 to 7. It's the 3 first bits of the first number of a code. Because of this, you'll notice that in the codes all the CT are actually multiplied by 2 : CT1 : 2..., CT2 : 4... CT3 : 6...,..., CT7 : E... . The fourth bit is used to tell the code handler to use the pointer instead of the base address. That means that you'll know if the base address is used by looking at the first number of a code. If it's even it's the base address, if it's odd it's the pointer.

CST : Code Sub Type. It's the 3 first bits of the second number of a code. Because of this, you'll notice that in the codes all the CST are actually multiplied by 2 : CST1 : 2..., CST2 : 4... CST3 : 6...,..., CST7 : E... . The fourth bit is actually a part of the address (____).

-End BA, PO, ETC-

Codetypes

CT0- You'll be using these alot for codes like unlimited health, ammo, lives, and whatnot. Also a good basic codetype to start on!


CT0: Direct ram write/fill

CST0: 8bits Write & Fill

00______ YYYY00XX : 8bits ram write and fill (ba) writes XX YYYY+1 times at ba+address

10______ YYYY00XX : 8bits ram write and fill (po) writes XX YYYY+1 times at po+address

CST1: 16bits Write & Fill

02______ YYYYXXXX : 16bits ram write and fill (ba) writes XXXX YYYY+1 times at ba+address

12______ YYYYXXXX : 16bits ram write and fill (po) writes XXXX YYYY+1 times at po+address

CST2: 32bits Write

04______ XXXXXXXX : 32bits ram write (ba) writes XXXXXXXX at ba+address

14______ XXXXXXXX : 32bits ram write (po) writes XXXXXXXX at po+address


HOW TO DECIDE WHICH TO USE:

You probably did a search for the code and selected 8, 16, or 32 bits. Just go under whatever category you picked!

00, 02, and 04 have the same function- just used with different bits, and 10, 12, and 14 have their own function, except with different bits.

00/02/04: You should use this to write to an address that does not change in different levels.
10/12/14: This can be used to write an address that works on multiple levels, after doing a pointer search.

NEW

01/03/05: Same function as 00 etc but you can use this with 81000000! So you can skip the 4A and E0000000 80008000!
11/13/15: Same function as 10 etc but you can use this with 81000000! So you can skip the 4A and E0000000 80008000!

Implementing:


take your found address. You should be able to poke it to a different value. Now, the first thing to do is look at the first 8 bits. If it is 80 or 81, skip this step. But, if it is  90/91, you need to add another line. Make it like this:
4A000000 (8 bits here)000000

So if the 8 bits were 91, it would look like this:

4A000000 91000000

Now we're going to use the address. IT WILL BE 32 BITS. The first 8 bits in it don't matter anymore. Replace them with 00/02/04 or 10/12/14. Since it's 32 bits, use 04 or 14. We'll use 14. Now we should set the number to what we want!

1428AE64 <00000063> Between <>is the number we set. Don't change anything else in the first 32 bits!

Do some poking to get a good value. Remember, this is in hex. 99= 63 in hex. Just use Windows Calculator, Scientific Mode, and put in the number you want in "dec" mode. Now select "hex". Use that number.

Now our code looks like this.
4A000000 91000000
1428AE64 00000063

It will now work! But, we aren't finished yet! We changed the BA with this line: 4A000000 81000000
If another code after ours expects the BA to be at 80, it won't be...its at 81...so the code won't work.
It's easy to fix. Just add E0000000 80008000 as the last line.

Now we have a complete code!

4A000000 91000000
1428AE64 00000063
E0000000 80008000

(Again using my 99 lives in Brawl as an example code (EDIT: TWEAKED...this code will not work) ...it is easy for me to explain when it is a code I made)

All we needed was CT0, plus the 4A line. You can make complete codes using this. However, usually only simple ones.

Using the real code...
1528AE64 00000063

is a complete code. No E0/4A lines needed.

Some harder code types:

CT1 Regular If codes (16/32 bits)- using this we can do "If" statements. An example would be...

If Mario's health is zero, then set it to three. etc

For info see the code type doc.

I'll do a quick example.

Let's say Mario's health address is at 80111111.
No need to modify the BA for this as it's in the 80 range.

Now we want to make it go to three if it's at zero.

It's kind of like the CT0 codes with another line.

We'll put it like this:

30111111 00000000

this checks if his health is zero. If yes, the following lines go into effect:

14111111 00000003

Which sets it to three.

For more information please see the code type doc.

Please point out mistakes/ tell me things to add! Wrote this when I was tired, so there's bound to be some mistakes!
Red Sox vs. Yankees 4/4/2k10 Season Opener
Red Sox: 9 Yankees: 7 Final!

Duker

Quote from: REDSOXROX on January 13, 2009, 11:50:49 PM4A000000 81000000
1428AE64 00000063
E0000000 80008000
That is very unefficient, just use 15 instead:
1528AE64 00000063
(80xxxxxx=14 ; 81xxxxxx=15)

Exact same thing, with two less lines :) .

Same goes with other codetypes, if it's an 81 address just add 1.

y helo thar!

REDSOXROX

Quote from: Duker on January 13, 2009, 11:55:07 PM
Quote from: REDSOXROX on January 13, 2009, 11:50:49 PM4A000000 81000000
1428AE64 00000063
E0000000 80008000
That is very unefficient, just use 15 instead:
1528AE64 00000063
(80xxxxxx=14 ; 81xxxxxx=15)

Exact same thing, with two less lines :) .

Same goes with other codetypes, if it's an 81 address just add 1.
Awesome! I'll update it with that when possible
Red Sox vs. Yankees 4/4/2k10 Season Opener
Red Sox: 9 Yankees: 7 Final!

Fred

If someone helped you press the thank you button.

Romaap

If I remember correctly, Link said somewhere that the ba can only be a multiple of 2000000 so only 80000000, 90000000 and 920000000.

Jassim

thank so much for this cos i couldnt understand a word of the codetypes page, this is really noob friendly thanks

do NOT pm me to request a code or if you have any problems with my code.
[spoiler]http://cristgaming.com/pirate.swf[/spoiler]



hetoan2

if you set ba to 81000000 then the ba will just be 80000000 or it will freeze.

REDSOXROX

Hm, you can't set BA to anything other than 80/90?
:confused:
Red Sox vs. Yankees 4/4/2k10 Season Opener
Red Sox: 9 Yankees: 7 Final!

Romaap

Quote from: REDSOXROX on January 14, 2009, 10:46:09 PM
Hm, you can't set BA to anything other than 80/90?
:confused:
80/90 and 92
edit: even the C0 and D0 :D

REDSOXROX

Quote from: Romaap on January 14, 2009, 11:01:06 PM
Quote from: REDSOXROX on January 14, 2009, 10:46:09 PM
Hm, you can't set BA to anything other than 80/90?
:confused:
80/90 and 92
Okay...so  use Pointers to set to anything else?

And updated
Red Sox vs. Yankees 4/4/2k10 Season Opener
Red Sox: 9 Yankees: 7 Final!

Link

the base address is intended really just to be a base address and not to follow pointers.. thus the ba is always a multiple of 0x02000000 - as codes can reach from ba/po+0 to ba/po+0x01FFFFFF thus using the ba it is possible to reach any theoretically availible memory spot. Even virtual memory in Gamecube mode!
The po is more universal in that case.. the po can have every thinkable 32-bit integer value! But that's what a pointer is supposed to do. Point everywherre!

Other than that: good tutorial!

REDSOXROX

Quote from: Link on January 14, 2009, 11:58:56 PM
the base address is intended really just to be a base address and not to follow pointers.. thus the ba is always a multiple of 0x02000000 - as codes can reach from ba/po+0 to ba/po+0x01FFFFFF thus using the ba it is possible to reach any theoretically availible memory spot. Even virtual memory in Gamecube mode!
The po is more universal in that case.. the po can have every thinkable 32-bit integer value! But that's what a pointer is supposed to do. Point everywherre!

Other than that: good tutorial!
Thanks that straightened it out for me!

Thanks! :)
Red Sox vs. Yankees 4/4/2k10 Season Opener
Red Sox: 9 Yankees: 7 Final!