 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
mechalink How do I cheat?
Reputation: 0
Joined: 05 Nov 2023 Posts: 1
|
Posted: Sun Nov 05, 2023 12:17 pm Post subject: Adventures with Saturn and Mednafen |
|
|
So I am trying to pick apart a Saturn game using Ghidra and Cheat Engine, using Mednafen as a Saturn Emulator. This is working except for one weird thing that's happening (this is not a request for a bugfix!): 16 bit chunks are being saved little-endian in Mednafen's running memory, while the structure above them is big-endian. For example, the 4 byte number 10 is being stored as 0x00000A00, as opposed to 0x0A000000 (little endian) or 0x0000000A (big endian). This is also the case for saved byte arrays, eg, the string 'HYD ' (48 59 44 20) is stored as '59 48 20 44'.
Looking at the various byte structure examples on this website for big-endian custom types, I can't quite put together exact code that would work for these cases, because I don't quite understand what the 64 bit vs 32 bit sections are truly doing in the 4 byte custom types. I also can't find anything good on making a custom array type. If anyone has some advice or examples that would help here, that'd be great. Thanks.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Sun Nov 05, 2023 1:06 pm Post subject: |
|
|
So values are comprised of byte pairs, and each byte in the pair is swapped?
Here's an example using a 4-byte type, 64-bit only:
Code: | alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ShuffleMask,16)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(UsesString,1)
alloc(MaxStringSize,2)
alloc(CallMethod,1)
TypeName:
db '4 Bytes Mednafen',0
ByteSize:
dd 4
UsesFloat:
db 0
UsesString:
db 0
MaxStringSize:
dw #100
CallMethod:
db 1
// cdecl int ConvertRoutine(unsigned char *input, PTR_UINT address);
ConvertRoutine:
[64-bit]
movd xmm0,[rcx]
pshufb xmm0,[ShuffleMask]
movd eax,xmm0
ret
[/64-bit]
// cdecl void ConvertBackRoutine(int i, PTR_UINT address, unsigned char *output);
ConvertBackRoutine:
[64-bit]
movd xmm0,ecx
pshufb xmm0,[ShuffleMask]
movd [r8],xmm0
ret
[/64-bit]
ShuffleMask:
db 01 00 03 02
db FF FF FF FF
db FF FF FF FF
db FF FF FF FF |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|