Skip to content

PNACH Code Types

zami edited this page Sep 7, 2022 · 2 revisions

Introduction & credits

These comments and examples are copied from root670's Cheat Device repository, so not all codetypes behave exactly the same way on PCSX2.

In order to use these in a PCSX2 pnach file, all you gotta do is add a couple words.

Before:

203C5104 4000C3FF

After:

patch=1,EE,203C5104,extended,4000C3FF

Constant Write

Constantly writes the value @v to address @a.

8-Bit

0aaaaaaa 000000vv

16-Bit

1aaaaaaa 0000vvvv

32-Bit

2aaaaaaa vvvvvvvv

Increment / Decrement

Increments/decrements the current value at address @a by value @v.

8-Bit Increment

300000vv 0aaaaaaa

8-Bit Decrement

301000vv 0aaaaaaa

16-Bit Increment

3020vvvv 0aaaaaaa

16-Bit Decrement

3030vvvv 0aaaaaaa

32-Bit Increment

30400000 0aaaaaaa
vvvvvvvv 00000000

32-Bit Decrement

30500000 0aaaaaaa
vvvvvvvv 00000000

Constant Serial Write

8-Bit & 16-Bit:

Starting with address @a, this code type will write the value @v to @n addresses. In each cycle, the address is incremented by @s or @s * 2 and the value is incremented by @i.

8-Bit

8-aaaaaaa nnnnssss
000000vv 000000ii

16-Bit

8-aaaaaaa nnnnssss
1000vvvv 0000iiii

32-Bit:

Starting with address @a, this code type will write the 32-bit value @v to @n addresses. In each cycle, the address is incremented by @s * 4 and the value is incremented by @i.

4-aaaaaaa nnnnssss
vvvvvvvv iiiiiiii

Copy Bytes

Copies a block of @n bytes from source address @s to destination address @d.

5-sssssss nnnnnnnn
0ddddddd 00000000

Pointer Write

Loads 32-bit base address from address @a and adds offset @i to it to get either the final address (normal pointer write, where @n == 1, @n being the number of times to point) or a new pointer location (multi-level pointer write, where @n > 1), in the multi-level pointer write case, continue by loading 32-bit base address from the pointer location computed at the previous iteration and adding offset @p to it, keep doing this until all (@n - 1) offsets @p have been processed, and constantly writes the value @v to the final address.

8-Bit

6-aaaaaaa 000000vv
0000nnnn iiiiiiii
pppppppp pppppppp	# First extra ptr line, only required if @n > 1`
pppppppp pppppppp	# Second extra pointer line, required if @n > ((N << 1) - 1)`
pppppppp pppppppp	# Third etc. etc.

16-Bit

6-aaaaaaa 0000vvvv
0001nnnn iiiiiiii
pppppppp pppppppp
pppppppp pppppppp

32-Bit

6-aaaaaaa vvvvvvvv
0002nnnn iiiiiiii
pppppppp pppppppp
pppppppp pppppppp

Boolean Operation

Performs a bitwise logical operation between value @v and the value stored at address @a.

8-Bit OR

7-aaaaaaa 000000vv

16-Bit OR

7-aaaaaaa 0010vvvv

8-Bit AND

7-aaaaaaa 002000vv

16-Bit AND

7-aaaaaaa 0030vvvv

8-Bit XOR

7-aaaaaaa 004000vv

16-Bit XOR

7-aaaaaaa 0050vvvv

"Execute all following codes if equal to="

All following codes will be executed only if 32-bit value at address @a is equal to value @v.

32-Bit

C-aaaaaaa vvvvvvvv

Multi-line "if" Conditional

Compares value at address @a to value @v, and executes next @n lines only if the test condition @t is true. Values for @t are: 0 equal 1 not equal 2 less than 3 greater than

8-Bit

D-aaaaaaa nnt100vv

16-Bit

D-aaaaaaa nnt0vvvv

Multi-line "if" Conditional 2 ("deprecated")

Same as above, but this type is internally converted to the D type.

8-Bit

E-1nn00vv taaaaaaa

16-Bit

E-0nnvvvv taaaaaaa