Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Add DDS header..?

Featured Replies

  • Author
  • Localization

sigroon365, posted Mon May 11, 2015 6:30 pm (5212)


Hi, :lol: I made bms script to convert some files to dds.
It extract dds data but can't add dds header yet.

sample https://www.sendspace.com/file/u72dkx

Code:
endian big
goto 0x10
get Header_SIZE long
xmath base_off "Header_SIZE 0x64"

xmath file_num_off "Header_SIZE - 0x10"
goto file_num_off
get files long

goto 0x28
get names_jump long
xmath noff "names_jump 0x81"

for i = 0
goto noff
get name string
strlen namesz name

if name = "Page0"
xmath noff "noff 0xC"
goto noff
get name string
string name = ".dds"
savepos noff

else

string name = ".dds"
savepos noff

endif


goto base_off
get SIZE long
get UNK1 long
get UNK2 long
get WIDTH short
get HEIGHT short
savepos tmp
xmath OFFSET "tmp 0x38"

log name OFFSET SIZE

xmath base_off "OFFSET SIZE 0x50"

next i


How can I use callfunction to add dds header?

Code:
callfunction addDDSheader
startfunction addDDSheader
endian little
set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x07\x10\x0A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x05\x00\x00\x00\x44\x58\x54\x35\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x10\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
putVarChr MEMORY_FILE 0x10 WIDTH long
putVarChr MEMORY_FILE 0xC HEIGHT long

endian big
append
log MEMORY_FILE OFFSET SIZE
append
endfunction
  • Author
  • Localization

sigroon365, posted Tue May 12, 2015 4:12 am (5218)


Ah, I solve it. :D

Code:
endian big
goto 0x10
get Header_SIZE long
xmath base_off "Header_SIZE 0x64"
xmath file_num_off "Header_SIZE - 0x10"
goto file_num_off
get files long

goto 0x28
get names_jump long
xmath noff "names_jump 0x81"

for i = 0 goto noff
get name string
if name = "Page0"
xmath noff "noff 0xC"

goto noff
get name string
string name = ".dds"
savepos noff

else
string name = ".dds"
savepos noff
endif

goto base_off
get SIZE long
get UNK1 long
get UNK2 long
get WIDTH short
get HEIGHT short
savepos tmp
xmath OFFSET "tmp 0x38"

callfunction addDDSheader
log NAME 0 SIZE MEMORY_FILE
append

xmath base_off "OFFSET SIZE 0x50"
next i

startfunction addDDSheader
endian little
set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x07\x10\x0A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x05\x00\x00\x00\x44\x58\x54\x35\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x10\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
putVarChr MEMORY_FILE 0x10 WIDTH long
putVarChr MEMORY_FILE 0xC HEIGHT long
endian big
append
log MEMORY_FILE OFFSET SIZE
endfunction
  • Author
  • Localization

sigroon365, posted Tue May 12, 2015 4:47 am (5219)


Hmm.. unpack works well.
Image

But reimporting cause error. Can some one help me?
Image
  • Author
  • Localization

aluigi, posted Tue May 12, 2015 6:18 am (5220)


Because quickbms can't work with MEMORY_FILEs in reimporting.
It can reimport only files that have been extracted directly to disk.
  • Author
  • Localization

sigroon365, posted Tue May 12, 2015 7:29 am (5224)


aluigi wrote:
Because quickbms can't work with MEMORY_FILEs in reimporting.
It can reimport only files that have been extracted directly to disk.


Hmm.. Then I should remove DDS header and insertion it to original file, right?
Here is the complete version for various type..

Code:
#Naruto ultimate storm 3 full burst xfbin to DDS written by me

endian big

goto 0x1C
get TYPE long

if TYPE < 9
math jump = 0xAC
else
math jump = 0x10C
endif

FindLoc GIDX_off string "GIDX" 0 ""
#goto 0x2A4
#savepos GIDX_off
xmath file_num_off "GIDX_off - jump"

goto file_num_off
get files long

goto 0x20
get names_jump1 long
goto 0x28
get names_jump2 long
goto 0x30
get names_jump3 long
xmath noff "0x44 names_jump1 names_jump2 1"

for i = 0 < files
goto noff
get name string

if name = "Page0"
xmath noff "noff 0xC"
goto noff
get name string
string name = ".dds"
savepos noff

else
string name = ".dds"
savepos noff
endif

goto GIDX_off
xmath base_off "GIDX_off - 0x38"

goto base_off
get SIZE long
get UNK1 long
get UNK2 long
get WIDTH short
get HEIGHT short
savepos tmp
xmath OFFSET "tmp 0x38"

callfunction addDDSheader

get packname filename
string packname = _unpacked/
string packname = name
log packname 0 SIZE MEMORY_FILE
append
xmath GIDX_off "OFFSET SIZE 0x88"

if GIDX_off > EOF
cleanexit

else

goto GIDX_off
getdstring TEST 0x4
    if TEST == "GIDX"
    else
    cleanexit
    endif
endif

next i

startfunction addDDSheader
endian little
set MEMORY_FILE binary "\x44\x44\x53\x20\x7C\x00\x00\x00\x07\x10\x0A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x05\x00\x00\x00\x44\x58\x54\x35\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x10\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
putVarChr MEMORY_FILE 0x10 WIDTH long
putVarChr MEMORY_FILE 0xC HEIGHT long
endian big
append

log MEMORY_FILE OFFSET SIZE
endfunction
  • Author
  • Localization

aluigi, posted Tue May 12, 2015 7:43 am (5226)


Basically you should dump the file as-is, log NAME OFFSET SIZE.
The reimport feature is meant to reimport the extracted files while in this case you have "generated" a new file using the content of an archive file.

The reimport feature consists just in replacing the function that dumps the file on the disk with a function that reads the file from the disk and copies it in the original archive, just that.
  • Author
  • Localization

sigroon365, posted Tue May 12, 2015 8:33 am (5229)


aluigi wrote:
Basically you should dump the file as-is, log NAME OFFSET SIZE.
The reimport feature is meant to reimport the extracted files while in this case you have "generated" a new file using the content of an archive file.

The reimport feature consists just in replacing the function that dumps the file on the disk with a function that reads the file from the disk and copies it in the original archive, just that.


Ok, I understand it. Then.. After I extract it, it needs to remove header for reimporting.
But how can I remove DDS header from DDS file?
Image
...
Image

Code:
idstring "DDS"
goto 0x80
savepos OFFSET

xmath SIZE "EOF - 0x80"
log "" OFFSET SIZE


Error
Image

I think EOF may cause error?
  • Author
  • Localization

aluigi, posted Tue May 12, 2015 8:38 am (5232)


No, you must NOT log to MEMORY_FILE, that's the only thing to do.
  • Author
  • Localization

sigroon365, posted Tue May 12, 2015 8:54 am (5236)


aluigi wrote:
No, you must NOT log to MEMORY_FILE, that's the only thing to do.

Uhm.. But if I change "log MEMORY_FILE OFFSET SIZE" to "log name OFFSET SIZE", it causes error.

Code:
callfunction addDDSheader
log NAME 0 SIZE MEMORY_FILE
append
...
log MEMORY_FILE OFFSET SIZE

to
Code:
callfunction addDDSheader
log NAME 0 SIZE MEMORY_FILE
append
...
log name OFFSET SIZE


Actually, I have difficult in understand well MEMORY_FILE yet.
In my opinion, in order to reimport, I have to follow below progress.
First, generate dds file. Second, remove dds header. Third, reimporting.

- extract only SIZE and reimport
Code:
endian big

goto 0x1C
get TYPE long

if TYPE < 9
math jump = 0xAC
else
math jump = 0x10C
endif

FindLoc GIDX_off string "GIDX" 0 ""
#goto 0x2A4
#savepos GIDX_off
xmath file_num_off "GIDX_off - jump"

goto file_num_off
get files long

goto 0x20
get names_jump1 long
goto 0x28
get names_jump2 long
goto 0x30
get names_jump3 long
xmath noff "0x44 names_jump1 names_jump2 1"

for i = 0 < files
goto noff
get name string

if name = "Page0"
xmath noff "noff 0xC"
goto noff
get name string
string name = ".dds"
savepos noff

else
string name = ".dds"
savepos noff
endif

goto GIDX_off
xmath base_off "GIDX_off - 0x38"

goto base_off
get SIZE long
get UNK1 long
get UNK2 long
get WIDTH short
get HEIGHT short
savepos tmp
xmath OFFSET "tmp 0x38"

get packname filename
string packname = _unpacked/
string packname = name
log packname OFFSET SIZE
xmath GIDX_off "OFFSET SIZE 0x88"

if GIDX_off > EOF
cleanexit

else

goto GIDX_off
getdstring TEST 0x4
    if TEST == "GIDX"
    else
    cleanexit
    endif
endif

next i


However, you mean, if I modify my script(Not log to memory_file) then reimporting works on?
But I don't know how to generate dds file without memory_file.
So, I think that the above step is needed to reimport.

p.s. remove DDS header
Code:
goto 0x80
savepos OFFSET

goto EOF
savepos End

xmath SIZE "End - OFFSET"
log "" OFFSET SIZE
  • Author
  • Localization

sigroon365, posted Tue May 12, 2015 9:29 am (5237)


Anyway, I success to edit dds image. :D

Original
Image

After reimporting
Image
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.