ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Mon Mar 25, 2019 3:37 am

All times are UTC




Post new topic  Reply to topic  [ 17 posts ] 
Author Message
 Post subject: divided by a number
PostPosted: Thu Nov 22, 2018 6:47 am 
User avatar

Joined: Sat Sep 15, 2018 5:22 am
Posts: 138
i need a little help with a script


get FILE-SIZE asize
get CRC long
math CRC += 1024
get OFFSET longlong

How can i do that: (If FILE-SIZE not was divided by 16, then do that: math OFFSET += 12)

divided by 16: like 16, 32, 48, 64, 80, 96, 112, 128, 144...


Top
   
 Post subject: Re: divided by a number
PostPosted: Thu Nov 22, 2018 7:32 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9946
math OFFSET x 16

It performs an automatic alignment to 16.


Top
   
 Post subject: Re: divided by a number
PostPosted: Thu Nov 22, 2018 8:28 am 
User avatar

Joined: Sat Sep 15, 2018 5:22 am
Posts: 138
in LIS_BNK_Import.bms, Line 53

i need to set alignment all of files as (divided by 16), just like original, or if i dont, then game cant read files, if i do it with hex, game can read files


Attachments:
BNK_FILE.zip [82.84 KiB]
Downloaded 17 times
Top
   
 Post subject: Re: divided by a number
PostPosted: Thu Nov 22, 2018 8:55 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9946
That's a bit different than the original simpler question of how to align an offset :)
Basically you should first calculate the aligned offset, then use "append 1" that allows to move on any desired offset of MEMORY_FILE, then fix that OFFLEN... not exactly a one-line fix.

I did some edit on the fly, try it:
Code:
open FDDE header_bnk 0
open FDDE footer_bnk 1
open FDDE bnk 2
get NAME basename
string BNK_NAME p "%s%s.bnk" NAME "_NEW"


get HEADER_SIZE asize 0
get FSB_SIZE asize 1
log MEMORY_FILE 0 HEADER_SIZE 0


get MEM_SIZE asize MEMORY_FILE



goto 0x0 0
findloc DATA binary "\x44\x41\x54\x41" 0
goto DATA 0
get DATA long 0
get CHUNK long #all extracted size 0
math ALL_SIZE = CHUNK 0
savepos SSSSA 0
math E_HEADING = DATA 0
goto 0x0 0
findloc HEADER_TWO_SCOUND binary "\x44\x49\x44\x58" 0
goto HEADER_TWO_SCOUND 0
get DIDX_HEADER long 0
get HEADER_TWO long 0
math HEADER_COUNT = HEADER_TWO 0
math HEADER_TWO /= 12 #12, (CRC, OFFSET, SIZE long) 0

math DUMMY_ADDER = 24 0
math HEADER_HEADING + HEADER_ONE 0
math HEADER_HEADING + DUMMY_ADDER 0


get MAHPE asize 0
for i = 0 < HEADER_TWO 0

get CRC long 0
savepos OFFSET_OFF 0
get OFFSET long 0
savepos SIZE_OFF 0
get SIZE long 0
math OFFSET == 0 0
math OFFSET + HEADER_HEADING 0
string CRC p "%s.wem" CRC 0

open FDSE CRC 4
get WEM_SIZE asize 4
savepos OFFLEN MEMORY_FILE
math OFFLEN x 16
append 1
goto OFFLEN MEMORY_FILE
log MEMORY_FILE 0 WEM_SIZE 4
append




putvarchr MEMORY_FILE OFFSET_OFF OFFLEN long
putvarchr MEMORY_FILE SIZE_OFF WEM_SIZE long



next i





append
log MEMORY_FILE 0 FSB_SIZE 1
append



get MEM_SIZE asize MEMORY_FILE
log BNK_NAME 0 MEM_SIZE MEMORY_FILE


Top
   
 Post subject: Re: divided by a number
PostPosted: Fri Nov 23, 2018 3:41 am 
User avatar

Joined: Sat Sep 15, 2018 5:22 am
Posts: 138
Sorry, nut BKHD Header cant add!
alignment is works fine! but when you change (append) to (append 1), then header cant add on top of file!

math OFFLEN x 16
append 1


i upload a better sample


Attachments:
BNK_Sample.zip [83.23 KiB]
Downloaded 14 times
Top
   
 Post subject: Re: divided by a number
PostPosted: Fri Nov 23, 2018 7:03 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9946
You can use both, I mean "append 1" for moving to the aligned position, followed by "append" (for closing the previous mode) and another "append" for opening the classical append mode.

Otherwise just go directly to the end of the file in "append 1":
Code:
get TMP asize MEMORY_FILE
goto TMP MEMORY_FILE
log MEMORY_FILE OFFSET SIZE

Many choices :)


Top
   
 Post subject: Re: divided by a number
PostPosted: Fri Nov 23, 2018 8:14 am 
User avatar

Joined: Sat Sep 15, 2018 5:22 am
Posts: 138
aluigi wrote:
You can use both, I mean "append 1" for moving to the aligned position, followed by "append" (for closing the previous mode) and another "append" for opening the classical append mode.

Otherwise just go directly to the end of the file in "append 1":
Code:
get TMP asize MEMORY_FILE
goto TMP MEMORY_FILE
log MEMORY_FILE OFFSET SIZE

Many choices :)


infact, i cant understand why cant add header! because i did it before!

can you fix script? to make NEW .bnk Just like original?


Top
   
 Post subject: Re: divided by a number
PostPosted: Sun Nov 25, 2018 7:55 am 
User avatar

Joined: Sat Sep 15, 2018 5:22 am
Posts: 138
Shokoniraya wrote:
aluigi wrote:
You can use both, I mean "append 1" for moving to the aligned position, followed by "append" (for closing the previous mode) and another "append" for opening the classical append mode.

Otherwise just go directly to the end of the file in "append 1":
Code:
get TMP asize MEMORY_FILE
goto TMP MEMORY_FILE
log MEMORY_FILE OFFSET SIZE

Many choices :)


infact, i cant understand why cant add header! because i did it before!

can you fix script? to make NEW .bnk Just like original?


aluigi, i dont unrestand why (append 1) will disable header log?
can you fix it yourself for test?


Top
   
 Post subject: Re: divided by a number
PostPosted: Sun Nov 25, 2018 9:26 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9946
Sorry, currently I can't.


Top
   
 Post subject: Re: divided by a number
PostPosted: Thu Nov 29, 2018 6:54 am 
User avatar

Joined: Wed Jul 19, 2017 5:04 am
Posts: 203
aluigi wrote:
Sorry, currently I can't.

hmmm... adding another append not working
do you think QuickBMS need a Update? because i think so

_________________
Be Good, Even in distressing or defamation and chill, Even Everyone's Called You a Bad Guy Or Lier and Mad


Top
   
 Post subject: Re: divided by a number
PostPosted: Thu Nov 29, 2018 8:01 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9946
No, everything works perfectly.
It's just that I can't spend time understanding what the script is meant to do and then fixing or rewriting it from scratch.
Sorry.


Top
   
 Post subject: Re: divided by a number
PostPosted: Tue Dec 11, 2018 5:02 am 
User avatar

Joined: Wed Jul 19, 2017 5:04 am
Posts: 203
Shoko, your script had some Problem, in this days, im working on audio modding to change music in game
i made a recreated script based on your script

You did something wrong and in this code, when i change (append) to (append 1), header still can be added in template

only problem is:
Code:
append
math WEM_OFFSET x 16
log MEMORY_FILE WEM_OFFSET WEM_SIZE 4
append

not working, me too
and i don't think that just using (x 16) will works
aluigi, which code? can you tell me what can i do? (x 16) not working
for example, can you fix 16-alignment in LIS_BNK.bms? if it's solved, other problem will solve


Attachments:
File comment: Need to fix 16-alignment
LIS_BNK.bms [686 Bytes]
Downloaded 32 times
File comment: reCreated Based on Shokoniraya script
recreated_LIS_BNK_Import.bms [1.38 KiB]
Downloaded 31 times

_________________
Be Good, Even in distressing or defamation and chill, Even Everyone's Called You a Bad Guy Or Lier and Mad
Top
   
 Post subject: Re: divided by a number
PostPosted: Thu Dec 20, 2018 4:36 am 
User avatar

Joined: Wed Jul 19, 2017 5:04 am
Posts: 203
i forgot to say, but x can set a size a special number, not just put in OFFSET, got to use for set a size, not rewrite them!
i really need it, too

_________________
Be Good, Even in distressing or defamation and chill, Even Everyone's Called You a Bad Guy Or Lier and Mad


Top
   
 Post subject: Re: divided by a number
PostPosted: Sat Jan 05, 2019 8:41 pm 
User avatar

Joined: Wed Jul 19, 2017 5:04 am
Posts: 203
i found problem now
Seems like quickbms can't set offset by 16 in reimport2 and just add file in -0x0. anyway, game can't read files without (math offset x 16) in new offset, a problem or not avable?

_________________
Be Good, Even in distressing or defamation and chill, Even Everyone's Called You a Bad Guy Or Lier and Mad


Top
   
 Post subject: Re: divided by a number
PostPosted: Thu Jan 10, 2019 4:17 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 9946
The 'x' command is a non-reversible since you can't calculate the old value to store back in the original field, but that should not be a problem.

I will check it anyway.


Top
   
 Post subject: Re: divided by a number
PostPosted: Sat Jan 19, 2019 10:38 am 
User avatar

Joined: Sat Sep 15, 2018 5:22 am
Posts: 138
i want to reimport2 a file with x16 offset. but QuickBMS always adding file in end of file. that is right
solution?

For instance
i want to create a script for a simple file. And i can extract it as well with real size and hash and offset
And for reimporting i must use reimport2
But game juat can read offset as x16. Like 16 and 32 or more
Now Tool just can add file in end of archive
And if archive are 37 byte. Then my new offset is 38. But must be 64!
What we need for now: adding file by X16 offset.


Top
   
 Post subject: Re: divided by a number
PostPosted: Sun Jan 20, 2019 10:50 am 
User avatar

Joined: Sat Sep 15, 2018 5:22 am
Posts: 138
Sorry. here a edited part

if archive are 37 byte. Then my new offset is 38. But must be 48!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 17 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