WiiRD Code Types

onitsuka chihiro
Well, WiiRd is bringing new code types in comparison the the USB Gecko and of course you might fear - will my GCT codes work. And of course they do. You just have to update them. And this I am gonna concentrate on the changes of the code handler.

Please note that you need to know about the Gecko code types to read this!


 

Standard memory fill codes:

GCT codes:

 8 bit: 00XXXXXX ZZZZ00YY
16 bit: 01XXXXXX ZZZZYYYY
32 bit: 02XXXXXX YYYYYYYY
Consecutive: 03XXXXXX YYYYYYYYWiiRd code: 

 8 bit: 00XXXXXX ZZZZ00YY or 10XXXXXX ZZZZ00YY
16 bit: 02XXXXXX ZZZZYYYY or 12XXXXXX ZZZZYYYY
32 bit: 04XXXXXX YYYYYYYY or 14XXXXXX YYYYYYYY
Consecutive: 06XXXXXX YYYYYYYY or 16XXXXXX YYYYYYYYYou recognize WiiRd has two possibilities. They are not identical! The codes beginning with 0 mean they write to the address [base+XXXXXX] (XXXXXX may go up to 1FFFFFF) while the codes begining with 1 write to the address [pointer+XXXXXX] - this means that you can access regular memory using the “base address” even while you’re handling pointers in between. ZZZZ is handled the exact same way.

 

Serial codes:

GCT:

04XXXXXX YYYYYYYY
TNNNZZZZ VVVVVVVVT being 0 for 8 bit, 1 for 16 bit, 2 for 32 bit

WiiRd:

08XXXXXX YYYYYYYY or 18XXXXXX YYYYYYYY
TNNNZZZZ VVVVVVVVSame structure.. again 08 means use base address to apply offset, while 18 means pointer address!

 

Conditional codes:

GCT:

32 bit: 1TXXXXXX YYYYYYYY (compare value: YYYYYYYY)
16 bit: 2TXXXXXX ZZZZYYYY (compare value: ZZZZ & YYYY)
 Endif: 60000000 00000000T: see Gecko instructions too long to list

WiiRd:

32 bit: 2TXXXXXX YYYYYYYY or 3TXXXXXX YYYYYYYY
16 bit: 2UXXXXXX ZZZZYYYY or 3UXXXXXX ZZZZYYYY
    (compare value: (not ZZZZ) & YYYY)
 Endif: E2000001 00000000T: 0 -> equal (==) (equals GCT type C)
T: 2 -> not equal (!=) (GCT: D)
T: 4 -> greater than (>) (GCT: E)
T: 6 -> lower than (<) (GCT: F)
U: 8 -> equal (==) (GCT: C)
U: A -> not equal (!=) (GCT: D)
U: C -> greater than (>) (GCT: E)
U: E -> lower than (<) (GCT: F)

As you see.. WiiRd only allows allows comparison until the next endif! However.. there is a trick - if you raise XXXXXX by 1 (so make 145544 to 145545) and your statement includes and endif - this is kinda neat if you have multiple statements in a row (like if player pressed D-Up - if he presses D-Down - the “if he presses D-Down” can include the endif for the selection before!

 

Base address changing

set Base address to XXXXXXXX:

  GCT: 30000000 XXXXXXXX
WiiRd: 42000000 XXXXXXXX for ba - 4A0000000 XXXXXXXX for poload Base address from XXXXXXXX

  GCT: 31000000 XXXXXXXX
WiiRd: 40000000 XXXXXXXX for ba - 48000000 XXXXXXXX for poset Base address to data register N

  GCT: 3200000N 00000000
WiiRd: 4200100N 00000000 for ba - 4A00100N 00000000 for postore Base address to XXXXXXXX

  GCT: 33000000 XXXXXXXX
WiiRd: 44000000 XXXXXXXX for ba - 4C000000 XXXXXXXX for poadd XXXXXXXX to current base address

  GCT: 34000000 XXXXXXXX
WiiRd: 42010000 XXXXXXXX for ba - 5A010000 XXXXXXXX for poYou see… all codes can be used the exact same way!
A very elegent way to make a full terminator in WiiRd to reset both the base address and the pointer ist:

WiiRd: E0000000 80008000 //Sets ba and po to 80000000 

Set Repeat Code Types

GCT:

40000000 000MNNNN //set block
[block]
41000000 000M0000 //execute blockWiiRd:

6000NNNN 0000000M
[block]
62000000 0000000M 

Load & Store Code Types

load XXXXXXXX into register specified by N

  GCT: 5000000N XXXXXXXX
WiiRd: 8000000N XXXXXXXXload data at address XXXXXXXX into register N

  GCT: 510U000N XXXXXXXX
WiiRd: 82U0000N XXXXXXXX
U: 0: 8 bit; 1: 16 bit; 2: 32 bitExecute instructions from code list

  GCT: 54000000 XXXXXXXX //execute XXXXXXXX operations
WiiRd: C0000000 NNNNNNNN //execute NNNNNNNN lines of operationsBoth GCT and WiiRd codes must end with blr!

Perform the operation N=(XXXXXXXX ? N) where operation is specified by T/U

  GCT: 5T00000N XXXXXXXX
WiiRd: 86U0000N XXXXXXXXPlease note that the speicifications of T and U differ (see description documents)!

Perform the operation n=(M ? N) where operation is specified by T/U

  GCT: 5T0001MN 00000000
WiiRd: 88TY000N 0000000MPlease note that the speicifications of T and U differ (see description documents)!

 

Hook Code Types

Hook

//XXXXXX: offset - YYYYYYYY: address to branch to
  GCT: C0XXXXXX YYYYYYYY
WiiRd: C6XXXXXX YYYYYYYY for ba or D6XXXXXX YYYYYYYY for po 

Insert Instruction Code Types

Execute NNNNNNNN bytes/lines of code at instruction base+XXXXXX

  GCT: C1XXXXXX NNNNNNNN (N=bytes)
WiiRd: C2XXXXXX NNNNNNNN (N=lines) for ba
    or D2XXXXXX NNNNNNNN (N=lines) for poPlease make sure that in both cases one last value remains as 00000000 - this one will be overwritten to branch back to regular code. In case of WiiRd if your last code line would be 00000000 00000000 then, please use 60000000 00000000 instead!

 

End If Code Types

GCT: 60000000 XXXXXXXXSet execution status to 0 (=execute)
Set base address to XXXXXXXX if XXXXXXXX =! 0

WiiRd:
Regular endif:

E20000VV XXXXYYYYApplies VV endifs (you can close deep if trees that way).. set ba to XXXX0000 if XXXX!=0 and po to YYYY0000 if YYYY!=0

Full terminator:

E0000000 XXXXYYYYClears all if trees.. If XXXX!=0, ba = XXXX0000 - If YYYY!=0, po = YYYY0000

 

Finished