Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: 32-bit check types for pnach #12297

Open
SlyCooperReloadCoded opened this issue Feb 12, 2025 · 0 comments
Open

[Feature Request]: 32-bit check types for pnach #12297

SlyCooperReloadCoded opened this issue Feb 12, 2025 · 0 comments
Labels
Enhancement / Feature Request FR: Low Priority Niche request that does not benefit many users. FR: Medium Complexity Requires some codebase knowledge. A proficient developer should be able to manage.

Comments

@SlyCooperReloadCoded
Copy link
Contributor

SlyCooperReloadCoded commented Feb 12, 2025

Description

Currently, pnach is mostly based on PS2 Patch Engine, which consists of 8-bit (1 byte) and 16-bit (2-byte) checks in the form of the E and D types. This feature request is proposing two new modes for the D and E types that allow for 32-bit checks. PR #10606 (F type) would also have to receive these modes if it gets implemented.

32-bit 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. Test condition values are:

0 = Equal To
1 = Not Equal To
2 = Less Than
3 = Greater Than

patch=1,EE,Daaaaaaa,extended,nnt20000
patch=1,EE,vvvvvvvv,extended,00000000
patch=1,EE,E2nn0000,extended,taaaaaaa
patch=1,EE,vvvvvvvv,extended,00000000

32-bit Multi-Line "if float" Conditional

Same operation, but the value @v and the value read at address @a are interpreted as floats rather than a decimal/hexadecimal number (i.e. value of 0xC1B80000 would be treated as a float of -23 rather than decimal 3250061312)

patch=1,EE,Daaaaaaa,extended,nnt30000
patch=1,EE,vvvvvvvv,extended,00000000
patch=1,EE,E3nn0000,extended,taaaaaaa
patch=1,EE,vvvvvvvv,extended,00000000

Reason

The justification for the plain 32-bit mode existing is simple - there's only 8-bit and 16-bit checks for this type, so why not 32-bit? Additionally, 32-bit checks already partially exist with the C type, just not in "if" conditional form.

The justification for the 32-bit float mode is a bit more complicated. Currently, the only way to check if a value is between two floats is by either:

  1. Writing ASM (bleugh)
  2. Checking the first two bytes of the float

Examples

An example is trying to compare the floats 45 (first two bytes are 0x4234) and -23 (first two bytes are 0xC1B8):

patch=1,EE,E002C1B8,extended,3XXXXXXX
patch=1,EE,E0014234,extended,2XXXXXXX
patch=1,EE,2XXXXXXX,extended,XXXXXXXX

Not only does being limited to 16-bit reduce the accuracy of the check since you can't check for the last two bytes as well, but it also uses decimal logic rather than float logic, so it interprets the 0xC1B8 as larger than the 0x4234 which isn't correct in float logic, so the check breaks. The whole thing is a mess and it would be beneficial if a 32-bit float check type existed.

@SlyCooperReloadCoded SlyCooperReloadCoded added Enhancement / Feature Request FR: Awaiting Consideration The feature request is awaiting a team members consideration. labels Feb 12, 2025
@F0bes F0bes added FR: Low Priority Niche request that does not benefit many users. FR: Medium Complexity Requires some codebase knowledge. A proficient developer should be able to manage. and removed FR: Awaiting Consideration The feature request is awaiting a team members consideration. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement / Feature Request FR: Low Priority Niche request that does not benefit many users. FR: Medium Complexity Requires some codebase knowledge. A proficient developer should be able to manage.
Projects
None yet
Development

No branches or pull requests

2 participants