Difference between revisions of "Code Types (Playstation 2)"

From Wiki - GameHacking.org
Jump to: navigation, search
 
Line 8: Line 8:
 
{| class="wikitable"  
 
{| class="wikitable"  
 
|- class="codestop" valign="top"
 
|- class="codestop" valign="top"
| '''Type''' || '''Format''' || '''Description''' || '''Limitations'''
+
| '''Type''' || '''Format''' || '''Description'''
 
|- valign="top"
 
|- valign="top"
 
| 8-bit Constant Write
 
| 8-bit Constant Write
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 0XXXXXXX 000000YY
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 0XXXXXXX 000000YY
 
| Write the 8-bit value Y to address X.
 
| Write the 8-bit value Y to address X.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| 16-bit Constant Write
 
| 16-bit Constant Write
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 1XXXXXXX 0000YYYY
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 1XXXXXXX 0000YYYY
 
| Write the 16-bit value Y to address X.
 
| Write the 16-bit value Y to address X.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| 32-bit Constant Write
 
| 32-bit Constant Write
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 2XXXXXXX YYYYYYYY
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 2XXXXXXX YYYYYYYY
 
| Write the 32-bit value Y to address X.
 
| Write the 32-bit value Y to address X.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| Increment/Decrement
 
| Increment/Decrement
Line 33: Line 33:
 
4 — 16-bit decrement<br>
 
4 — 16-bit decrement<br>
 
5 — 32-bit increment<br>
 
5 — 32-bit increment<br>
6 — 32-bit decrement
+
6 — 32-bit decrement<br>
| Requires a limiter to be useful.
+
<br>
 +
Requires a limiter to be useful, such as an activation flag tied to a button press. Otherwise, the increment runs hundreds of times every second.
 +
 
 
|- valign="top"
 
|- valign="top"
 
| 32-bit Constant, Multi-address Write
 
| 32-bit Constant, Multi-address Write
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 4XXXXXXX&nbsp;NNNNIIII<br>YYYYYYYY&nbsp;00000000
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 4XXXXXXX&nbsp;NNNNIIII<br>YYYYYYYY&nbsp;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.
 
| 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.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| Copy Bytes
 
| Copy Bytes
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 5XXXXXXX&nbsp;NNNNNNNN<br>YYYYYYYY&nbsp;00000000
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 5XXXXXXX&nbsp;NNNNNNNN<br>YYYYYYYY&nbsp;00000000
 
| Copies the values of N bytes starting from X to target memory starting at Y.
 
| Copies the values of N bytes starting from X to target memory starting at Y.
|
+
 
 +
|- valign="top"
 +
| 32-bit Pre-hook Write (One-time Write)
 +
| style="font-size: %60; font-family: Courier New, Monospace;" | AXXXXXXX&nbsp;YYYYYYYY
 +
| Write the 32-bit value Y to address X, but only during hook processing.  In general, this means that the value is written once when the game starts up.
 +
 
 
|- valign="top"
 
|- valign="top"
 
| Timer Code
 
| Timer Code
 
| style="font-size: %60; font-family: Courier New, Monospace;" | B0000000&nbsp;YYYYYYYY
 
| style="font-size: %60; font-family: Courier New, Monospace;" | B0000000&nbsp;YYYYYYYY
 
| Delay code execution.  No codes below this one will be executed until Y reaches zero.
 
| Delay code execution.  No codes below this one will be executed until Y reaches zero.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| 16-bit Logical If (Skip 1)
 
| 16-bit Logical If (Skip 1)
Line 58: Line 65:
 
2 — Less Than
 
2 — Less Than
 
3 — Greater Than   
 
3 — Greater Than   
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| Logical If (Skip N)
 
| Logical If (Skip N)
 
| style="font-size: %60; font-family: Courier New, Monospace;" | ENNNYYYY&nbsp;TXXXXXXX
 
| style="font-size: %60; font-family: Courier New, Monospace;" | ENNNYYYY&nbsp;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.
 
| 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.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| Enable/Master
 
| Enable/Master
 
| style="font-size: %60; font-family: Courier New, Monospace;" | FXXXXXXX&nbsp;YYYYYYYY
 
| style="font-size: %60; font-family: Courier New, Monospace;" | FXXXXXXX&nbsp;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.
 
| 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.
|
+
 
 
|}
 
|}
  
Line 76: Line 83:
 
{| class="wikitable"  
 
{| class="wikitable"  
 
|- class="codestop" valign="top"
 
|- class="codestop" valign="top"
| '''Type''' || '''Format''' || '''Description''' || '''Limitations'''
+
| '''Type''' || '''Format''' || '''Description'''
 
|- valign="top"
 
|- valign="top"
 
| Pointer Write
 
| Pointer Write
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 6WXXXXXX&nbsp;BBBBBBBB<br>ZZZZZZZZ&nbsp;YYYYYYYY
 
| style="font-size: %60; font-family: Courier New, Monospace;" | 6WXXXXXX&nbsp;BBBBBBBB<br>ZZZZZZZZ&nbsp;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.
 
| 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.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| Escape Code List/All Off
 
| Escape Code List/All Off
 
| style="font-size: %60; font-family: Courier New, Monospace;" | CXXXXXXX&nbsp;YYYYYYYY
 
| style="font-size: %60; font-family: Courier New, Monospace;" | CXXXXXXX&nbsp;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.
 
| 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.
|
+
 
 
|- valign="top"
 
|- valign="top"
 
| Conditional Enable/Master
 
| Conditional Enable/Master
Line 94: Line 101:
 
|}
 
|}
  
 +
===Action Replay MAX (Version 3)===
 +
The Action Replay MAX has a completely rewritten cheat engine that uses 7-bits per command.  It is not backwards compatible with codes from earlier versions.  Some older codes can be translated to the new command format, but other code types were completely abandoned, e.g., Copy Bytes.
 +
 +
Since the second position of most codes is shared between the command (upper 3 bits) and the address (lowest bit), it will appear that two formats exist.  For example, the 16-bit Constant Write will appear in codes as either 02XXXXXX or 03XXXXXX, depending on whether the most significant bit of the address is 0 or 1.  For the sake of brevity, only the first case will be listed in the Format column.  When using formats from this table, bear in mind that you may have to add 1 to that second position, if your address is greater than 0xFFFFFF.
 +
{| class="wikitable"
 +
|- class="codestop" valign="top"
 +
| '''Type''' || '''Format''' || '''Description'''
 +
|- valign="top"
 +
| 8-bit Constant Write<br>(Command 00)
 +
| style="font-size: %60; font-family: Courier New, Monospace;" | 00XXXXXX&nbsp;NNNNNNYY
 +
| Write the 8-bit value Y to address X and the next N byte-aligned addresses if N is greater than zero.
 +
 +
|- valign="top"
 +
| 16-bit Constant Write<br>(Command 01)
 +
| style="font-size: %60; font-family: Courier New, Monospace;" | 02XXXXXX&nbsp;NNNNYYYY
 +
| Write the 16-bit value Y to address X and the next N halfword-aligned addresses if N is greater than zero.
 +
 +
|- valign="top"
 +
| 32-bit Constant Write<br>(Command 02)
 +
| style="font-size: %60; font-family: Courier New, Monospace;" | 04XXXXXX&nbsp;YYYYYYYY
 +
| Write the 32-bit value Y to address X.
  
 +
|}
 
{{Code Types}}
 
{{Code Types}}
 
[[Category:Code Types]]
 
[[Category:Code Types]]

Latest revision as of 12:46, 7 October 2013

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
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, such as an activation flag tied to a button press. Otherwise, the increment runs hundreds of times every second.

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.
32-bit Pre-hook Write (One-time Write) AXXXXXXX YYYYYYYY Write the 32-bit value Y to address X, but only during hook processing. In general, this means that the value is written once when the game starts up.
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
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.

Action Replay MAX (Version 3)

The Action Replay MAX has a completely rewritten cheat engine that uses 7-bits per command. It is not backwards compatible with codes from earlier versions. Some older codes can be translated to the new command format, but other code types were completely abandoned, e.g., Copy Bytes.

Since the second position of most codes is shared between the command (upper 3 bits) and the address (lowest bit), it will appear that two formats exist. For example, the 16-bit Constant Write will appear in codes as either 02XXXXXX or 03XXXXXX, depending on whether the most significant bit of the address is 0 or 1. For the sake of brevity, only the first case will be listed in the Format column. When using formats from this table, bear in mind that you may have to add 1 to that second position, if your address is greater than 0xFFFFFF.

Type Format Description
8-bit Constant Write
(Command 00)
00XXXXXX NNNNNNYY Write the 8-bit value Y to address X and the next N byte-aligned addresses if N is greater than zero.
16-bit Constant Write
(Command 01)
02XXXXXX NNNNYYYY Write the 16-bit value Y to address X and the next N halfword-aligned addresses if N is greater than zero.
32-bit Constant Write
(Command 02)
04XXXXXX YYYYYYYY Write the 32-bit value Y to address X.
Code Types
Consoles
Playstation - Sega Saturn - Dreamcast - Playstation 2 - Game Cube
Portables
Game Boy Advance - Nintendo DS