Affiliates:
BannerBomb
| Gecko Codetype Documentation
This Gecko Codetype Documentation based on work from: BannerBomb. |
Direct Ram Writes
00______ YYYY00XX
Writes the value XX to YYYY+1 consecutive byte -sized addresses, starting with the address ba +______
To use po instead of ba , change the codetype from 00 to 10.
For values of ______ >= 0x01000000, add one to the codetype.
02______ YYYYXXXX
Writes the value XXXX to YYYY+1 consecutive halfword -sized addresses, starting with the address ba +______
To use po instead of ba , change the codetype from 02 to 12.
For values of ______ >= 0x01000000, add one to the codetype.
04______ XXXXXXXX
Writes the value XXXXXXXX to ba +______
To use po instead of ba , change the codetype from 04 to 14.
For values of ______ >= 0x01000000, add one to the codetype. String Write (Patch Code)
06______ YYYYYYYY
d1d2d3d4 d5d6....
Writes each byte (d1, d2, d3, ...) consecutively, starting at address ba +______
YYYYYYYY is the number of bytes to write
To use po instead of ba , change the codetype from 06 to 16.
For values of ______ >= 0x01000000, add one to the codetype. Slider/Multi Skip (Serial)
08______ XXXXXXXX
TNNNZZZZ VVVVVVVV
______ + ba = Initial Address
X = Initial value for the RAM write
T = Value Size (0 = byte , 1 = halfword , 2 = word )
N = Amount of additional addresses to write to (the first is assumed)
Z = Address Increment; in bytes (How many To skip By)
V = Value Increment (How much to add to the value after each additional RAM write)
To use po instead of ba , change the codetype from 08 to 18.
For values of ______ >= 0x01000000, add one to the codetype. | Direct Ram Writes 8 bits16 bits32 bitsStringSerialIf Codes 32 bits if Equal32 bits if Not Equal32 bits if Greater32 bits if Lower16 bits if Equal16 bits if Not Equal16 bits if Greater16 bits if LowerBase Address Load intoSet toStore atNext Code's LocationPointer Address Load intoSet toStore atNext Code's LocationFlow Control Set RepeatExecute RepeatReturnGotoGosubGecko Register Set grN toLoad into grNStore grN atgrN/Direct Value OpsgrN OpsMemory Copy 1Memory Copy 2grN If Codes 16 bits if Equal16 bits if Not Equal16 bits if Greater16 bits if LowerCounter If Codes 16 bits if Equal16 bits if Not Equal16 bits if Greater16 bits if LowerASM Codes ExecuteInsertCreate BranchOther On/Off SwitchAddress Range CheckFull TerminatorEndif (+else)End of CodesGecko 1.8+ Only Insert ASM + Checksum(If) Search, Set Pointer Appendix Codetypes in depth | If Codes 32 bits (endif, then) If equal
20______ XXXXXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 32 bits at [ ]==XXXXXXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 20 to 30.
For values of ______ >= 0x01000000, add one to the codetype. 32 bits (endif, then) If not equal
22______ XXXXXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 32 bits at [ ]!=XXXXXXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 22 to 32.
For values of ______ >= 0x01000000, add one to the codetype. 32 bits (endif, then) If greater than (unsigned)
24______ XXXXXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 32 bits at [ ]>XXXXXXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 24 to 34.
For values of ______ >= 0x01000000, add one to the codetype. 32 bits (endif, then) If lower than (unsigned)
26______ XXXXXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 32 bits at [ ]<XXXXXXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 26 to 36.
For values of ______ >= 0x01000000, add one to the codetype. 16 bits (endif, then) If equal
28______ MMMMXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 16 bits at ([ ] & not(MMMM))==XXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 28 to 38.
For values of ______ >= 0x01000000, add one to the codetype. 16 bits (endif, then) If not equal
2A______ MMMMXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 16 bits at ([ ] & not(MMMM))!=XXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 2A to 3A.
For values of ______ >= 0x01000000, add one to the codetype. 16 bits (endif, then) If greater than
2C______ MMMMXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 16 bits at ([ ] & not(MMMM))>XXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 2C to 3C.
For values of ______ >= 0x01000000, add one to the codetype. 16 bits (endif, then) If lower than
2E______ MMMMXXXX
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If 16 bits at ([ ] & not(MMMM))<XXXX,
then codes are executed (else code execution set to false)
To use po instead of ba , change the codetype from 2E to 3E.
For values of ______ >= 0x01000000, add one to the codetype. Base Address
40TYZ00N XXXXXXXX
40000 : ba = [ XXXXXXXX ]
40001 : ba = [ ]
40010 : ba = [ ba+XXXXXXXX ]
40011 : ba = [ ]
40100 : ba += [ XXXXXXXX ]
40101 : ba += [ ]
40110 : ba += [ ba+XXXXXXXX ]
40111 : ba += [ ]
50010 : ba = [ ]
50011 : ba = [ ]
50110 : ba += [ ]
50111 : ba += [ ]
42TYZ00N XXXXXXXX
42000 : ba = XXXXXXXX
42001 : ba = grN +XXXXXXXX
42010 : ba = ba +XXXXXXXX
42011 : ba = ba + grN +XXXXXXXX
42100 : ba += XXXXXXXX
42101 : ba += grN +XXXXXXXX
42110 : ba += ba +XXXXXXXX
42111 : ba += ba + grN +XXXXXXXX
52010 : ba = po +XXXXXXXX
52011 : ba = po + grN +XXXXXXXX
52110 : ba += po +XXXXXXXX
52111 : ba += po + grN +XXXXXXXX
440YZ00N XXXXXXXX
44000 : [ XXXXXXXX ] = ba
44001 : [ ] = ba
44010 : [ XXXXXXXX+ba ] = ba
44011 : [ ] = ba
54010 : [ ] = ba
54011 : [ ] = ba Put next code's location into the Base Address
4600XXXX 00000000
XXXX is a signed 16bits value : 0xFFFF=-1
ba will hold the address at which the next line of code is stored + XXXX Pointer Address Load into Pointer Address
48TYZ00N XXXXXXXX
48000 : po = [ XXXXXXXX ]
48001 : po = [ ]
48010 : po = [ ]
48011 : po = [ ]
48100 : po += [ XXXXXXXX ]
48101 : po += [ ]
48110 : po += [ ]
48111 : po += [ ]
58010 : po = [ po+XXXXXXXX ]
58011 : po = [ ]
58110 : po += [ po+XXXXXXXX ]
58111 : po += [ ]
4ATYZ00N XXXXXXXX
4A000 : po = XXXXXXXX
4A001 : po = grN +XXXXXXXX
4A010 : po = ba +XXXXXXXX
4A011 : po = ba + grN +XXXXXXXX
4A100 : po += XXXXXXXX
4A101 : po += grN +XXXXXXXX
4A110 : po += ba +XXXXXXXX
4A111 : po += ba + grN +XXXXXXXX
5A010 : po = po +XXXXXXXX
5A011 : po = po + grN +XXXXXXXX
5A110 : po += po +XXXXXXXX
5A111 : po += po + grN +XXXXXXXX
4C0YZ00N XXXXXXXX
4C000 : [ XXXXXXXX ] = po
4C001 : [ ] = po
4C010 : [ XXXXXXXX+ba ] = po
4C011 : [ ] = po
5C010 : [ ] = po
5C011 : [ ] = po Put next code's location into the Pointer Address
4E00XXXX 00000000
XXXX is a signed 16bits value : 0xFFFF=-1
po will hold the address at which the next line of code is stored + XXXX Flow Control
6000NNNN 0000000P
Store next code address and NNNN (number of times to repeat) in bP .
62000000 0000000P
If NNNN stored in bP is >0, it is decreased by 1 and the code handler jumps to the "next code address" stored in bP
64000000 0000000P
If the code execution status is true, the code handler jumps to the "next code address" stored in bP (NNNN in bP is not touched).
64100000 0000000P
If the code execution status is false, the code handler jumps to the "next code address" stored in bP (NNNN in bP is not touched).
64200000 0000000P
No matter what the code execution status is, the code handler jumps to the "next code address" stored in bP (NNNN in bP is not touched).
6600XXXX 00000000
If the code execution status is true, the code handler jumps to (next line of code + XXXX lines). XXXX is signed.
6610XXXX 00000000
If the code execution status is false, the code handler jumps to (next line of code + XXXX lines). XXXX is signed.
6620XXXX 00000000
The code handler jumps to (next line of code + XXXX lines). XXXX is signed.
6800XXXX 0000000P
If the code execution status is true, the code handler stores the next code address in bP , then it jumps to (next line of code + XXXX lines). XXXX is signed.
6810XXXX 0000000P
If the code execution status is false, the code handler stores the next code address in bP , then it jumps to (next line of code + XXXX lines). XXXX is signed.
6820XXXX 0000000P
No matter what the code execution status is, the code handler stores the next code address in bP , then it jumps to (next line of code + XXXX lines). XXXX is signed.
Gecko Register
80SY000N XXXXXXXX
8000 : grN = XXXXXXXX
8001 : grN = XXXXXXXX+ ba
8010 : grN += XXXXXXXX
8011 : grN += XXXXXXXX+ ba
9001 : grN = XXXXXXXX+ po
9011 : grN += XXXXXXXX+ po
82UY000N XXXXXXXX
8200 : grN = 8bits at [ XXXXXXXX ]
8210 : grN = 16bits at [ XXXXXXXX ]
8220 : grN = 32bits at [ XXXXXXXX ]
8201 : grN = 8bits at [ ]
8211 : grN = 16bits at [ ]
8221 : grN = 32bits at [ ]
9201 : grN = 8bits at [ ]
9211 : grN = 16bits at [ ]
9221 : grN = 32bits at [ ]
84T0YYYN XXXXXXXX : Starting Address is XXXXXXXX
84T1YYYN XXXXXXXX : Starting Address is XXXXXXXX+ ba
94T1YYYN XXXXXXXX : Starting Address is XXXXXXXX+ po
T = 0 : byte
T = 1 : halfword
T = 2 : word
Write grN 's T to YYY+1 consecutive T-sized addresses.
Gecko Register / Direct Value Operations
86TY000N XXXXXXXX
86T0 : grN = ( grN ? XXXXXXXX)
86T1 : [ ] = ([ ] ? XXXXXXXX)
86T2 : grN = ( grN ? [ XXXXXXXX ])
86T3 : [ ] = ([ ] ? [ XXXXXXXX ])
T : ?
0 : add (+)
1 : mul (*)
2 : or (|)
3 : and (&)
4 : xor (^)
5 : slw (<<)
6 : srw (>>)
7 : rol (rotate left)
8 : asr (arithmetic shift right)
9 : fadds (single float add)
A : fmuls (single float mul)
Gecko Register Operations
88TY000N 0000000K
88T0 : grN = ( grN ? grK)
88T1 : [ ] = ([ ] ? grK)
88T2 : grN = ( grN ? [ grK ])
88T3 : [ ] = ([ ] ? [ grK ])
T : ?
0 : add (+)
1 : mul (*)
2 : or (|)
3 : and (&)
4 : xor (^)
5 : slw (<<)
6 : srw (>>)
7 : rol (rotate left)
8 : asr (arithmetic shift right)
9 : fadds (single float add)
A : fmuls (single float mul)
8AYYYYNK XXXXXXXX
copy YYYY bytes from [ ] to [ grK ]+XXXXXXXX, grK can't be F.
8AYYYYNF XXXXXXXX
copy YYYY bytes from [ ] to ba +XXXXXXXX
9AYYYYNF XXXXXXXX
copy YYYY bytes from [ ] to po +XXXXXXXX
8CYYYYNK XXXXXXXX
copy YYYY bytes from [ ]+XXXXXXXX to [ grK ], grN can't be F.
8CYYYYFK XXXXXXXX
copy YYYY bytes from ba +XXXXXXXX to [ grK ]
9CYYYYFK XXXXXXXX
copy YYYY bytes from po +XXXXXXXX to [ grK ]
Gecko Register If Codes 16 bits (endif, then) If equal
A0______ KN00MMMM
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If ([ ] and not(MMMM))==([ grK ] and not(MMMM)) then codes are executed (else code execution set to false).
If N or K is F, it will use ba +______ instead of grF!
To use po instead of ba (when grN or grK is F), change the codetype from A0 to B0.
For values of ______ >= 0x01000000, add one to the codetype.
16 bits (endif, then) If not equal
A2______ KN00MMMM
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If ([ ] and not(MMMM))!=([ grK ] and not(MMMM)) then codes are executed (else code execution set to false).
If N or K is F, it will use ba +______ instead of grF!
To use po instead of ba (when grN or grK is F), change the codetype from A2 to B2.
For values of ______ >= 0x01000000, add one to the codetype.
16 bits (endif, then) If greater
A4______ KN00MMMM
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If ([ ] and not(MMMM))>([ grK ] and not(MMMM)) then codes are executed (else code execution set to false).
If N or K is F, it will use ba +______ instead of grF!
To use po instead of ba (when grN or grK is F), change the codetype from A4 to B4.
For values of ______ >= 0x01000000, add one to the codetype.
16 bits (endif, then) If lower
A6______ KN00MMMM
Adding 1 to ______ will make this code first apply an Endif.
(It will still use ______ for address calculation; without the added 1)
If ([ ] and not(MMMM))<([ grK ] and not(MMMM)) then codes are executed (else code execution set to false).
If N or K is F, it will use ba +______ instead of grF!
To use po instead of ba (when grN or grK is F), change the codetype from A6 to B6.
For values of ______ >= 0x01000000, add one to the codetype.
Counter If Codes 16 bits (endif, then) If counter value equal
A80ZZZZT MMMMXXXX
ZZZZ : The code's counter.
Code's Operation : If current execution status is true, increase counter by 1. If it's false, reset counter to 0.
Condition : If (XXXX and not(MMMM))==ZZZZ, codes following this are executed (else code execution set to false).
T = 0 : Do Code's Operation, then run Condition.
T = 1 : Apply an Endif, then do Code's Operation, finally run Condition.
T = 8 : Do Code's Operation, then run Condition (and if it is true, reset counter to 0).
T = 9 : Apply an Endif, then do Code's Operation, finally run Condition (and if it is true, reset counter to 0).
16 bits (endif, then) If counter value not equal
AA0ZZZZT MMMMXXXX
ZZZZ : The code's counter.
Code's Operation : If current execution status is true, increase counter by 1. If it's false, reset counter to 0.
Condition : If (XXXX and not(MMMM))!=ZZZZ, codes following this are executed (else code execution set to false).
T = 0 : Do Code's Operation, then run Condition.
T = 1 : Apply an Endif, then do Code's Operation, finally run Condition.
T = 8 : Do Code's Operation, then run Condition (and if it is true, reset counter to 0).
T = 9 : Apply an Endif, then do Code's Operation, finally run Condition (and if it is true, reset counter to 0).
16 bits (endif, then) If counter value greater
AC0ZZZZT MMMMXXXX
ZZZZ : The code's counter.
Code's Operation : If current execution status is true, increase counter by 1. If it's false, reset counter to 0.
Condition : If (XXXX and not(MMMM))>ZZZZ, codes following this are executed (else code execution set to false).
T = 0 : Do Code's Operation, then run Condition.
T = 1 : Apply an Endif, then do Code's Operation, finally run Condition.
T = 8 : Do Code's Operation, then run Condition (and if it is true, reset counter to 0).
T = 9 : Apply an Endif, then do Code's Operation, finally run Condition (and if it is true, reset counter to 0).
16 bits (endif, then) If counter value lower
AE0ZZZZT MMMMXXXX
ZZZZ : The code's counter.
Code's Operation : If current execution status is true, increase counter by 1. If it's false, reset counter to 0.
Condition : If (XXXX and not(MMMM))<ZZZZ, codes following this are executed (else code execution set to false).
T = 0 : Do Code's Operation, then run Condition.
T = 1 : Apply an Endif, then do Code's Operation, finally run Condition.
T = 8 : Do Code's Operation, then run Condition (and if it is true, reset counter to 0).
T = 9 : Apply an Endif, then do Code's Operation, finally run Condition (and if it is true, reset counter to 0).
ASM Codes
C0000000 NNNNNNNN
ZZZZZZZZ ZZZZZZZZ
ZZZZZZZZ ZZZZZZZZ
4E800020 00000000
Executes the NNNNNNNN lines of instruction placed under the code.
The instructions MUST end with a blr (0x4E800020).
C2______ NNNNNNNN
ZZZZZZZZ ZZZZZZZZ
ZZZZZZZZ ZZZZZZZZ
ZZZZZZZZ 00000000
This code will replace the instruction at ba +______ with a branch that will point to ZZZZZZZZ.
The replaced is not saved, the code creator must then put it in his code manualy (if needed).
The instruction MUST end with ONE 00000000, because the code handler will add a "b ( ba +______)" instruction there.
If your asm code fills all the line, add a 60000000 00000000 under it (and count this line in NNNNNNNN).
To use po instead of ba , change the codetype from C2 to D2.
For values of ______ >= 0x01000000, add one to the codetype.
C6______ YYYYYYYY
Writes, at ______+ ba , a "b YYYYYYYY" instruction.
To use po instead of ba , change the codetype from C6 to D6.
For values of ______ >= 0x01000000, add one to the codetype.
Other
CC000000 00000000
This code will only work correctly if an If... code is placed before it.
Each time the code execution status goes from true to false to true, and the switch code is reached, the "switch" is moved. The switch moves from on<->off, and set the code execution accordingly to its state. The value of the switch is stored inside the code.
It is NOT an If... code. It only changes the current code executions status.
CE00000T XXXXYYYY
T = 0, Don't apply Endif.
T = 1, Apply Endif.
Then check if ba >= 0xXXXX0000 and ba < 0xYYYY0000.
If XXXX>=YYYY, then the code will always set the code execution to false.
To use po instead of ba , change the codetype from CE to DE.
E0000000 XXXXYYYY
Clears the code execution status.
If XXXX<>0, ba = 0xXXXX0000
If YYYY<>0, po = 0xYYYY0000
E2T000VV XXXXYYYY
T = 0, Applies VV Endifs.
T = 1, Applies VV Endifs and inverse the code execution status (="else").
If XXXX<>0, ba = 0xXXXX0000
If YYYY<>0, po = 0xYYYY0000
F0000000 00000000
Tells the code handler that there are no more codes in the code list. The code handler exits.
Gecko 1.8+ Only Insert ASM With 16 bit XOR Checksum
F2______ YYZZZZNN
ZZZZZZZZ ZZZZZZZZ
ZZZZZZZZ ZZZZZZZZ
ZZZZZZZZ 00000000
YY (signed) 16-bit values after (if positive) or before (if negative) [ ] will be XOR'ed together. If the result is equal to ZZZZ, the code will be executed.
The rest of the code functions the exact same way as the C2 codetype (Insert ASM), with NN as the number of lines.
To use po instead of ba , change the codetype from F2 to F4.
For values of ______ >= 0x01000000, add one to the codetype.
F60000NN XXXXYYYY
ZZZZZZZZ ZZZZZZZZ
ZZZZZZZZ ZZZZZZZZ
Creates an if (so this code requires an endif), then searches for the NN lines of Z values between XXXX0000 and YYYY0000 (or, if XXXX is 8000, between 80003000 and YYYY0000).
To prevent this code from causing game lag, it will only search the first time it is read by the code handler (the result is saved to the code and reused).
If the Z values are found, set po to the starting address of the values (SSSSSSSS) and replace the F6 line with F60003NN SSSSSSSS.
If the Z values are not found, then set code execution status to false and replace the F6 line with F60001NN XXXXYYYY.
| Appendix A hex digit actually represents 4 bits, and you need to look at the underlying bits to understand why the code types are defined the way they are. Normally, we refer to a 32-bit RAM write as an "04 code type", but this is actually a misnomer. It misleadingly implies that the 8 bits belonging to the two hex digits "04" are the code type, when the actual code type only has 7 bits! The 8th bit belongs to the address, which creates the "05" code type. People also think that the address is only comprised of 24 bits (the other 6 hex digits), when the address is actually 25 bits (the other 6 hex digits + the last bit of the second digit).
A picture may help; Here's the binary breakdown of the first word of a code.
Hex Digit | First | Second | Third | Fourth ...
Bit# | 0 1 2 | 3 | 4 5 6 | 7 | 8 9 10 11 | 12 ...
is | Code Type | ba/po | Code Sub Type | address ..............................
|
|