D
DLPB_
Guest
I am trying to centre the description texts in the menus (at the moment they all have fixed X position). I have created some code to do this job (and a function already exists to count the width of all letters in a string). So the original code is this:
Code: [Select]
Code: [Select]
Code: [Select]
This simply doesn't work (because I lack knowledge on how the stack works), so I am doing something very wrong. It returns to the completely wrong address.
Questions:
1. When making a call, do you always need to use push ebp mov ebp,esp / mov esp,ebp pop ebp ?
2. Is there a better way of doing the above
3. How do I ensure this call will jump back to the correct address?
Code: [Select]
Code:
Push 2D [X Position of the description text string. This is the value the new code will change]call 006F5B03add esp,14
Code:
and the new is this:call 00914237 [Jump to a blank area that I can add my own code toThe 2 instructions below (call 006F5B03 and add esp,14 ) are now nopped]
Code:
and at 00914237:push ebpmov ebp,espmov eax,009A7FF0 push eax [Push string address]call 006F54A2 [Adds all character widths in string]add esp,04cdq sub eax,edxsar eax,1mov edx,00000140sub edx,eaxpush edx [pushes new X position of the string]call 006F5B03 [and now we are back to the original code]add esp,14mov esp,ebppop ebpret
Questions:
1. When making a call, do you always need to use push ebp mov ebp,esp / mov esp,ebp pop ebp ?
2. Is there a better way of doing the above
3. How do I ensure this call will jump back to the correct address?
Last edited: