Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cheat code works fine on console but crashes the emulator
#1
I'm testing a cheat code I wrote for a game (Kya: Dark Lineage)
This is the RAW code:
Code:
50495B9C 00000002
00495B9A 00000000
70495B9A 0010FFFD
D0495B9A 0400FFFD
606f2d90 0000007F
00020000 00000104
506E1064 00000004
006E1068 00000000
Which works as expected on console: when pressing L3, the code activates.
However, when I adjust it for PCSX2:
Code:
patch=1,EE,50495B9C,extended,00000002
patch=1,EE,00495B9A,extended,00000000
patch=1,EE,70495B9A,extended,0010FFFD
patch=1,EE,D0495B9A,extended,0000FFFD
patch=1,EE,606f2d90,extended,0000007F
patch=1,EE,00020000,extended,00000104
patch=1,EE,D0495B9A,extended,0000FFFD
patch=1,EE,506E1064,extended,00000004
patch=1,EE,006E1068,extended,00000000
As soon as I enable cheats on the emulator, it crashes. It happens on both the stable 1.6 build and the latest 1.7 dev build as of writing.
If I comment out the last three lines, the rest of the code works as excepted, so maybe it's a problem with the memory copying?
I can't figure out what I'm doing wrong, or if it's a problem with the emulator.
Reply

Sponsored links

#2
First thing to try is using E code instead of D code. I'm not sure how good pcsx2 handle that second line of 6 code if condition is not true.
Code:
patch=1,EE,D0495B9A,extended,0000FFFD
patch=1,EE,606f2d90,extended,0000007F
patch=1,EE,00020000,extended,00000104

In this case it will probably skip only first part of code, and launch patch to change byte in 0x20000 memory instead. This can be reason for emulator closing, as it trigger tlb misses if i'm right. SkipCount for D codes is hardcoded to 1, so i'm probably right. 
Same goes for last 5 code.
Personally i don't fully trust 6 codes in pcsx2, and suggest try to avoid that if possible.
Reply
#3
(04-24-2021, 08:49 PM)kozarovv Wrote: First thing to try is using E code instead of D code. I'm not sure how good pcsx2 handle that second line of 6 code if condition is not true.
Code:
patch=1,EE,D0495B9A,extended,0000FFFD
patch=1,EE,606f2d90,extended,0000007F
patch=1,EE,00020000,extended,00000104

In this case it will probably skip only first part of code, and launch patch to change byte in 0x20000 memory instead. This can be reason for emulator closing, as it trigger tlb misses if i'm right. SkipCount for D codes is hardcoded to 1, so i'm probably right. 
Same goes for last 5 code.
Personally i don't fully trust 6 codes in pcsx2, and suggest try to avoid that if possible.


I have written several cheat codes for the game, most of which include 6-codes preceded by D-codes, all work without an issue (the emulator correctly skips the second line too). But perhaps the issue could be 5-codes preceded by D-codes (since that's the one causing the crash)?

Looking at the ps2rd documentation, that does have D codes that specify how many lines to execute or skip, I wonder why that's not implemented in PCSX2
Reply
#4
(04-24-2021, 08:49 PM)kozarovv Wrote: First thing to try is using E code instead of D code. I'm not sure how good pcsx2 handle that second line of 6 code if condition is not true.
Code:
patch=1,EE,D0495B9A,extended,0000FFFD
patch=1,EE,606f2d90,extended,0000007F
patch=1,EE,00020000,extended,00000104

In this case it will probably skip only first part of code, and launch patch to change byte in 0x20000 memory instead. This can be reason for emulator closing, as it trigger tlb misses if i'm right. SkipCount for D codes is hardcoded to 1, so i'm probably right. 
Same goes for last 5 code.
Personally i don't fully trust 6 codes in pcsx2, and suggest try to avoid that if possible.

I changed the cheat code to this:
Code:
patch=1,EE,50495B9C,extended,00000002
patch=1,EE,00495B9A,extended,00000000
patch=1,EE,70495B9A,extended,0010FFFD
patch=1,EE,D0495B9A,extended,0000FFFD
patch=1,EE,606f2d90,extended,0000007F
patch=1,EE,00020000,extended,00000104
patch=1,EE,E002FFFD,extended,00495B9A
patch=1,EE,506E1064,extended,00000004
patch=1,EE,006E1068,extended,00000000
And yeah, it works fine now, it doesn't cause a crash and with the memory view I can see it only copies the value when I press L3.
And for some reason, it seems that E-codes support the length argument unlike D-codes? Because if I change E002FFFD to E004FFFD, and put it in place of the D-code before, then it correctly ignores the next 4 lines until I press L3? Weird, but it is a solution to my problem. I'll edit my the other cheats to use E-codes instead, so I can confirm it works better
Reply
#5
(04-24-2021, 08:53 PM)zacchi4k Wrote: I have written several cheat codes for the game, most of which include 6-codes preceded by D-codes, all work without an issue (the emulator correctly skips the second line too). But perhaps the issue could be 5-codes preceded by D-codes (since that's the one causing the crash)?

Looking at the ps2rd documentation, that does have D codes that specify how many lines to execute or skip, I wonder why that's not implemented in PCSX2

PCSX2 use CB7+ a like cheat system. So E codes are more powerful here, while ps2rd favorize D codes, since they extended them instead of going full CB7+ format. Implementing count for D codes now will be hacky because 99% codes for pcsx2 will have 0 skip count, so you need add case for that in parser to handle as 1, type should be easier as 0 is equal anyway. Not a big deal, but why if E codes work here great.

Edit: Here is small cheat sheet for current pcsx2 implementation.
https://gist.github.com/kozarovv/c97c052...2dd2d290f1
Reply




Users browsing this thread: 1 Guest(s)