root670 / CheatDevicePS2

Game enhancer for PlayStation 2 similar to Action Replay, GameShark, and CodeBreaker. (No longer in development)
GNU General Public License v3.0
79 stars 18 forks source link

engine: Implement multi-level pointer write support. #25

Closed luisdallos closed 4 years ago

luisdallos commented 4 years ago

This is a generalization of the current pointer write code type implementation as the number of times to point (@n) can be greater than 1 and one or more extra pointer lines (containing two 32-bit offsets) can be present (depending on @n value).

So, normal/traditional pointer write codes can be seen as a specific case of multi-level pointer write codes where @n == 1 and with no extra pointer lines present.

Note that multi-level pointer write codes are supported in CodeBreaker v7 and newer.

Example:

602829D8 0000FFFF
00010002 0000071C
0000FB20 00000000

- loads base at address 0x002829D8, say base is 0x00290000
- adds offset 0x0000071C to make address 0x0029071C
- loads base at address 0x0029071C, say base is 0x002A0000
- adds offset 0x0000FB20 to make address 0x002AFB20
- stores 16-bit value 0xFFFF to address 0x002AFB20

Note that execution stops, if (base & 0x3FFFFFFC) == 0.

Reference: http://web.archive.org/web/20180618074627/http://www.codemasters-project.net/portal-english/apportal/cmp_plugins/content/content.php?content.23

Test build: http://www.mediafire.com/file/1cb8url81814rq6/cheatdevice.elf/file

root670 commented 4 years ago

I'd been meaning to add this for a while, so thank you for pulling it together! With this PR, I believe the engine now has feature-parity with the CodeBreaker engine with the exception of the B-type delay code.