Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Changing a 16 bit register correctly

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
god22
How do I cheat?
Reputation: 0

Joined: 19 Sep 2017
Posts: 6

PostPosted: Thu Aug 16, 2018 4:25 am    Post subject: Changing a 16 bit register correctly Reply with quote

I got back in to playing ar tonelico recently and was messing around in cheat engine with it. I made a script that will multiply the amount of exp gained after battle but it was way to high. Upon closer inspection, I found out that it was writing to 2 16 bit registers. It would write correctly to the first part but only until it maxed out the first register. It would then overflow into the other part. in decimal form it would say something like 3300| 0->9452 | 31. I have no idea how to fix it.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Aug 16, 2018 1:12 pm    Post subject: Reply with quote

Show the code you are trying to use.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
god22
How do I cheat?
Reputation: 0

Joined: 19 Sep 2017
Posts: 6

PostPosted: Thu Aug 16, 2018 8:33 pm    Post subject: Reply with quote

newmem:
push ebx
mov ebx,[20D20B54] //MC Exp

code:
mov [ecx],edx -> copy calculated exp to memory
sub ebx,[20D20B54]
neg ebx
add [20D20B54],ebx
pop ebx
mov [pcsx2.exe+10922F8],00186A24 //?


Expected:
1. Store exp before exp gain
2. Run orginal code
3. Subtract new exp from old exp
5. add the result to the original exp (creating double xp)

Actual:
0 or 1

Tried:
shl returns a negitive I think

modding edx returns a weird value due to how the emulator calculates values

Can you jump from cheat engine to a lua script and back? That would be the best solution I think.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Thu Aug 16, 2018 10:25 pm    Post subject: Reply with quote

To deal with WORDs (16 bits) you just remove the "E", it's for "Extended" and it was actually added to the 16 bit registries to denote 32 bit. So; AX (16 bits), EAX (32 bits); BX, EBX; CX, ECX; and so on.

Code:
newmem:
push ebx
mov ebx,[20D20B54] //MC Exp //// EBX = Current XP

code:
mov [ecx],edx -> copy calculated exp to memory //// No Idea what you're doing here
sub ebx,[20D20B54] //// EBX (Current XP) - Current XP = 0
neg ebx //// basically : 0 - EBX (0) = 0
add [20D20B54],ebx //// Current XP + EBX (0) = Current XP
pop ebx
mov [pcsx2.exe+10922F8],00186A24


But you need to find where the XP is written when increased, so you can subtract the current value from
the increased value.

Here some wiki pages that might help after you find where is written to.
https://wiki.cheatengine.org/index.php?title=Tutorial:CodeInjection_Integers
https://wiki.cheatengine.org/index.php?title=Tutorial:CodeInjection_Floats

_________________
Back to top
View user's profile Send private message Visit poster's website
god22
How do I cheat?
Reputation: 0

Joined: 19 Sep 2017
Posts: 6

PostPosted: Fri Aug 17, 2018 6:26 am    Post subject: Reply with quote

Thank you for your help. I will try that.

To clarify:

mov [ecx],edx // This is the code that adds exp.


I don't think I can find a code better than that because it isn't a game but an emulated game. Therefore,I was trying to store the old exp before it was changed and subtract it from the new exp. I could take that value and manipulate it however I wanted, or so I thought.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Aug 17, 2018 6:58 am    Post subject: Reply with quote

Something like this should work.
Code:
push eax
mov ax,dx
sub ax,[ecx]
sub dx,ax
imul dx,3
add dx,[ecx]
code:
mov [ecx],edx // could also be, mov [ecx],dx
pop eax

_________________
Back to top
View user's profile Send private message Visit poster's website
god22
How do I cheat?
Reputation: 0

Joined: 19 Sep 2017
Posts: 6

PostPosted: Sat Aug 18, 2018 6:03 am    Post subject: Reply with quote

It went to 1 again. While it didn't work, it did confirm I need to find a different code to use. Oh well. Sorry for wasting your time.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites