Level-5 Dark Cloud - .MDS Extracting from .SCN [COMPLETED]

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Dayuppy
Posts: 5
Joined: Tue May 12, 2020 8:07 am

Level-5 Dark Cloud - .MDS Extracting from .SCN [COMPLETED]

Post by Dayuppy »

I've been trying to create another BMS script but it fails to extract all the MDS images in a file. I've attached an example archive of a file containing MDS models.

The problem is that the MDS files are of unknown size. There is information in the SCN header about the files contained within and their filesizes but I don't know how to parse all that data.

I'm trying to find a way to scan for \x4D\x44\x53\x00\x01\x00\x00\x00 which is the start of the MDS file, then I try to find the second instance of the same header and extract the data in between.

This is what I'm experimenting with:

Code: Select all

for FILES = 0
FindLoc OFFSET1 string "\x4D\x44\x53\x00\x01\x00\x00\x00"
goto OFFSET1
idstring "\x4D\x44\x53\x00\x01\x00\x00\x00"

print "offset1: %offset1%"

FindLoc OFFSET2 string "\x4D\x44\x53\x00\x01\x00\x00\x00"
goto OFFSET2
idstring "\x4D\x44\x53\x00\x01\x00\x00\x00"

print "offset2: %offset2%"

set SIZE LONG OFFSET2
math SIZE -= OFFSET1 #Subtract OFFSET1 from OFFSET 2

Log "" OFFSET1 SIZE
math OFFSET1 += SIZE
goto OFFSET1
print "SIZE %SIZE%"


next FILES
- This appears to be working for now. More testing needed.

scene.zip



NOTES: There's a PTS header that contain the filenames within each model set and the size.

My current script only extracts some of the files successfully, the rest don't open correctly.

More simply, I'm trying to find the first MDS to the second MDS and extract the file in between. Then move on to the next.

Thanks in advance
Last edited by Dayuppy on Fri May 15, 2020 12:03 am, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Level-5 Dark Cloud - .MDS Extracting from .SCN [Partially Complete]

Post by aluigi »

Code: Select all

findloc OFFSET binary "\x4D\x44\x53\x00\x01\x00\x00\x00"
do
    goto OFFSET
    get DUMMY long
    findloc NEXT_OFFSET binary "\x4D\x44\x53\x00\x01\x00\x00\x00" 0 ""
    if NEXT_OFFSET == ""
        get SIZE asize
    else
        math SIZE = NEXT_OFFSET
    endif
    math SIZE -= OFFSET
    log "" OFFSET SIZE
    math OFFSET = NEXT_OFFSET
while NEXT_OFFSET != ""
Dayuppy
Posts: 5
Joined: Tue May 12, 2020 8:07 am

Re: Level-5 Dark Cloud - .MDS Extracting from .SCN [Partially Complete]

Post by Dayuppy »

Thank you aluigi. This appears to be working great and is much cleaner than mine.