ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sat Nov 18, 2017 12:12 pm

All times are UTC




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun Apr 23, 2017 7:32 pm 

Joined: Sun Jul 10, 2016 11:07 am
Posts: 54
not sure what it is really is called but id like to now how to achieve this by bms script

like if the size it 0xF2DA it will output 0xF300
or if the size it 0x3A2DA it will output 0x3A300


really not sure how to do this

this is my closest miserable attempt to make one but it's still wrong...


set SIZE long 0xF2DA
xmath TEST2 "(SIZE & 0xF00) + 0x100"
xmath TEST3 "(SIZE & 0xF000) + TEST2"


it will output 0xF300 but if I input like 0x2F300 it will still output 0xF300


Top
   
PostPosted: Sun Apr 23, 2017 8:02 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7107
math SIZE x 0x100

Yeah it's really that easy :D


Top
   
PostPosted: Sun Apr 23, 2017 11:18 pm 
User avatar

Joined: Fri Aug 08, 2014 1:06 am
Posts: 349
here try this :D
Code:
set SIZE long 0x3A2DA
print "%SIZE|hex% :size"
xmath CHECK "SIZE % 256"
print "%CHECK|hex% :check"
if CHECK != 0
   xmath SIZE "(SIZE - CHECK) + 256"
   print "%SIZE|hex% :new size"
endif
print "%SIZE|hex% :final size"

_________________
Quickbms.com link thread
Search bms scripts


Top
   
PostPosted: Mon Apr 24, 2017 8:28 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7107
@Acewell
Why? Isn't "math SIZE x 0x100" better?


Top
   
PostPosted: Mon Apr 24, 2017 1:57 pm 

Joined: Sun Dec 28, 2014 3:02 pm
Posts: 12
@aluigi
Could you kindly paste the source code for the math x command? I'd like to port it to a C# tool I'm working on.
Lucky coincidence this showed up on my twitter feed yesterday when I ran into the problem :mrgreen:


Top
   
PostPosted: Mon Apr 24, 2017 3:57 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7107
var1 is the number to round and var2 is the alignment (for example 0x100):
Code:
if(var2 && ((u_int)var1 % (u_int)var2)) { var1 += (var2 - ((u_int)var1 % (u_int)var2)); }


Top
   
PostPosted: Mon Apr 24, 2017 4:47 pm 

Joined: Sun Dec 28, 2014 3:02 pm
Posts: 12
Thank you!


Top
   
PostPosted: Mon Apr 24, 2017 8:10 pm 
User avatar

Joined: Fri Aug 08, 2014 1:06 am
Posts: 349
aluigi wrote:
Isn't "math SIZE x 0x100" better?

oh wait, that "x" is a special operator isn't it?
i was thinking you meant "times", like 2 x 2 = 4 :)

first time i saw that "x" used, you never mentioned this solution to my "maintain a multiple of 4" problem here :P
viewtopic.php?f=13&t=3952

both ways work, but can you round down with your solution?
ah i see you have a "y" operator for that :)

_________________
Quickbms.com link thread
Search bms scripts


Last edited by Acewell on Mon Apr 24, 2017 9:47 pm, edited 2 times in total.

Top
   
PostPosted: Mon Apr 24, 2017 8:48 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7107
Eh, when I see long posts I can't focus on them and, in that case I just focused only on the script you posted almost ignoring the rest :)

Anyway you can find all the operators in quickbms.txt, 'x' is there.


Top
   
PostPosted: Mon Apr 24, 2017 10:25 pm 

Joined: Sun Jul 10, 2016 11:07 am
Posts: 54
thanks for the reply! gonna try some of the examples you guys gave.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 10 posts ] 

All times are UTC


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 post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited