Code Types (Playstation 2)

From Wiki - GameHacking.org
Revision as of 03:26, 7 October 2013 by Pyriel (talk | contribs)
Jump to: navigation, search

The Playstation 2 has several competing devices, all with differing sets of code types. The differences between sets can be slight, as is the case with early Action Replays and CodeBreakers below version 6, or major, as with the Action Replay Max and any other device. All of the types are encoded in one of two formats. Either the typical model is used, where each code is two 32-bit values and the command is the first position (uppermost 4 bits), or each code is two 32-bit values, and the uppermost 7 bits is the primary command (first positions and 3 bits from the second position). In both cases additional data is packed into the code in whatever location the designers thought convenient. This can introduce variation, even when two devices have substantially similar code types.

Datel Devices

Datel Advanced Gaming Devices[1] is responsible for the Action Replay line of devices for the Playstation 2. Three major versions have been released, 1.x, 2.x, and 3.x, otherwise known as the Action Replay MAX. The 2 earlier versions utilized the typical model for their code formats. The 3.x version is the only Playstation 2 device that uses the 7-bit command model.

Action Replay Version 1

Type Format Description Limitations
8-bit Constant Write 0XXXXXXX 000000YY Write the 8-bit value Y to address X.
16-bit Constant Write 1XXXXXXX 0000YYYY Write the 16-bit value Y to address X.
32-bit Constant Write 2XXXXXXX YYYYYYYY Write the 32-bit value Y to address X.
Increment/Decrement 30T0YYYY 0XXXXXXX

30T00000 0XXXXXXX
YYYYYYYY 00000000
Load the value at the address given by X, add the value Y, and write the result back to X. The size of the value loaded and the Y increment are given by T. Increment values (Y) that exceed the size limitations will be truncated. The 8-bit and 16-bit codes all use the single-line format. The 32-bit codes require two lines.

1 — 8-bit increment
2 — 8-bit decrement
3 — 16-bit increment
4 — 16-bit decrement
5 — 32-bit increment
6 — 32-bit decrement

Requires a limiter to be useful.
32-bit Constant, Multi-address Write 4XXXXXXX NNNNIIII
YYYYYYYY 00000000
Write the 32-bit value Y to a series of addresses starting at X. The number of addresses written is given by N, and the space between is determined by I. Firstly, write the 32-bit value Y to address X and decrement N by 1. If N is more than 0, increment X by (I * 4) and store Y there as well. Repeat the cycle until N reaches zero.
Copy Bytes 5XXXXXXX NNNNNNNN
YYYYYYYY 00000000
Copies the values of N bytes starting from X to target memory starting at Y.
Timer Code B0000000 YYYYYYYY Delay code execution. No codes below this one will be executed until Y reaches zero.
16-bit Logical If (Skip 1) DXXXXXXX 00T0YYYY Load the 16-bit value at address X, and perform the comparison indicated by T. If the condition is met, execute the next code line, otherwise skip it. Values for T are:

0 — Equal 1 — Not Equal 2 — Less Than 3 — Greater Than

Logical If (Skip N) ENNNYYYY TXXXXXXX Load the 16-bit value at address X, and perform the comparison indicated by T. If the condition is met, execute the next N code lines, otherwise skip them. Values for T are identical the Skip 1 list.
Enable/Master FXXXXXXX YYYYYYYY Writes a hook to the cheat engine at the address indicated by X. Special values of Y will instead cause an interrupt (also indicated by Y) to be hooked, instead of the game's code.

Action Replay Version 2

This version implements all the code types of Version 1, and has the following additional types.

Type Format Description Limitations
Pointer Write 6WXXXXXX BBBBBBBB
ZZZZZZZZ YYYYYYYY
Add the address offset B to the address X (B required because otherwise the upper half of the PS2's memory is lost). The result is the actual address of the pointer. After retrieving it, add the index Z to it, giving the final address. Y is then stored at this address. The size of the variable being handled is indicated by W. When W is zero, the write is 16 bits. When W is one, 32 bits are written.
Escape Code List/All Off CXXXXXXX YYYYYYYY Compare the 32-bit value at X to Y. If they are not equal, quit processing codes. No codes below this one will execute until the value at X is equal to Y.
Conditional Enable/Master 8DDDDDDD XXXXXXXX
YYYYYYYY 00000000
During hook processing, waits for the value Y to appear at address X. When found, a hook to the cheat engine is written to X. D is set to X + 1.


Code Types
Consoles
Playstation - Sega Saturn - Dreamcast - Playstation 2 - Game Cube
Portables
Game Boy Advance - Nintendo DS