ZenHAX
https://zenhax.com/

divided by a number
https://zenhax.com/viewtopic.php?f=11&t=8930
Page 1 of 1

Author:  Shokoniraya [ Thu Nov 22, 2018 6:47 am ]
Post subject:  divided by a number

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...

Author:  aluigi [ Thu Nov 22, 2018 7:32 am ]
Post subject:  Re: divided by a number

math OFFSET x 16

It performs an automatic alignment to 16.

Author:  Shokoniraya [ Thu Nov 22, 2018 8:28 am ]
Post subject:  Re: divided by a number

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 11 times

Author:  aluigi [ Thu Nov 22, 2018 8:55 am ]
Post subject:  Re: divided by a number

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

Author:  Shokoniraya [ Fri Nov 23, 2018 3:41 am ]
Post subject:  Re: divided by a number

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 9 times

Author:  aluigi [ Fri Nov 23, 2018 7:03 am ]
Post subject:  Re: divided by a number

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 :)

Author:  Shokoniraya [ Fri Nov 23, 2018 8:14 am ]
Post subject:  Re: divided by a number

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?

Author:  Shokoniraya [ Sun Nov 25, 2018 7:55 am ]
Post subject:  Re: divided by a number

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?

Author:  aluigi [ Sun Nov 25, 2018 9:26 am ]
Post subject:  Re: divided by a number

Sorry, currently I can't.

Author:  GHOST DEAD [ Thu Nov 29, 2018 6:54 am ]
Post subject:  Re: divided by a number

aluigi wrote:
Sorry, currently I can't.

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

Author:  aluigi [ Thu Nov 29, 2018 8:01 am ]
Post subject:  Re: divided by a number

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.

Author:  GHOST DEAD [ Tue Dec 11, 2018 5:02 am ]
Post subject:  Re: divided by a number

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 8 times
File comment: reCreated Based on Shokoniraya script
recreated_LIS_BNK_Import.bms [1.38 KiB]
Downloaded 9 times

Author:  GHOST DEAD [ Thu Dec 20, 2018 4:36 am ]
Post subject:  Re: divided by a number

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

Author:  GHOST DEAD [ Sat Jan 05, 2019 8:41 pm ]
Post subject:  Re: divided by a number

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?

Author:  aluigi [ Thu Jan 10, 2019 4:17 pm ]
Post subject:  Re: divided by a number

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.

Author:  Shokoniraya [ Sat Jan 19, 2019 10:38 am ]
Post subject:  Re: divided by a number

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.

Author:  Shokoniraya [ Sun Jan 20, 2019 10:50 am ]
Post subject:  Re: divided by a number

Sorry. here a edited part

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/