Convert old MexScript to BMSScript ?

Doubts, help and support about QuickBMS and other game research tools
Tgames
Posts: 81
Joined: Mon Apr 01, 2019 10:49 am

Re: Convert old MexScript to BMSScript ?

Post by Tgames »

Indeed it's really strange this Sega Mega CD version :mrgreen:

I have send to you everything i have, the ISO itself.

Here in another format :

https://we.tl/t-QM8IDVCsar
Tgames
Posts: 81
Joined: Mon Apr 01, 2019 10:49 am

Re: Convert old MexScript to BMSScript ?

Post by Tgames »

I got zero file extracted with the script.

I do something wrong ? :(

Code: Select all

- GUI mode activated, remember that the tool works also from command-line
  where are available various options like folder scanning, filters and so on

- select BMS script. type ? for using the content of clipboard like a script
- select input archives/files, type * for the whole folder and subfolders
- select output folder where extracting files
- open input file D:\Jeux\QuickBMS\00000000000000a0.meg
- open script D:\Jeux\QuickBMS\DUNEMEG.bms
- set output folder D:\Jeux\QuickBMS\test

  offset           filesize   filename
--------------------------------------

- 0 files found in 0 seconds
  coverage file 0   100%   169595     169448     . offset 0000000000000000
  coverage file -10   0%   0          467        . offset 0000000000000000

Press ENTER or close the window to quit


BMS SCRIPT :

Code: Select all

set MEMORY_FILE10 string "
int convert(unsigned char *data, int size, unsigned char *wav) {
    int read, write, i = 0, x = 0;
    while(i < size) {
        read = data[i++];
        {
            if(read < 0x80)
                write = 0x80 - read;
            else
                write = read;

            if(write == 0xFF)       
            {
                i += 12;
            }
            else
                    wav[x++] = write;
        }
    }
    return x;
}
"

for i = 0
    savepos OFFSET
    findloc EOF binary "PPPPPPPP"
    if OFFSET == EOF
        break
    endif
    math SIZE = EOF
    math SIZE - OFFSET

    string NAME p "%d.wav" i
    #log NAME OFFSET SIZE
    callfunction DUMP

    math EOF x 0x800
    goto EOF
next i

startfunction DUMP
    log MEMORY_FILE2 0 0
    putvarchr MEMORY_FILE2 SIZE 0

    log MEMORY_FILE OFFSET SIZE
    calldll MEMORY_FILE10 "convert" "tcc" SIZE MEMORY_FILE SIZE MEMORY_FILE2

    math CODEC = 1
    math BITS = 8
    math CHANNELS = 1
    math FREQUENCY = 22222

    math BLKALIGN = BITS
    math BLKALIGN / 8
    math BLKALIGN * CHANNELS
    math AVGBYTES = FREQUENCY
    math AVGBYTES * BLKALIGN

    log MEMORY_FILE 0 0
    putdstring "RIFF" 4 MEMORY_FILE
    put 0 long          MEMORY_FILE
    putdstring "WAVE" 4 MEMORY_FILE

    # "fmt "
    putdstring "fmt " 4 MEMORY_FILE
    put 0 long          MEMORY_FILE
    put CODEC short     MEMORY_FILE # wFormatTag: Microsoft PCM Format (0x0001)
    put CHANNELS short  MEMORY_FILE # wChannels
    put FREQUENCY long  MEMORY_FILE # dwSamplesPerSec
    put AVGBYTES long   MEMORY_FILE # dwAvgBytesPerSec
    put BLKALIGN short  MEMORY_FILE # wBlockAlign
    put BITS short      MEMORY_FILE # wBitsPerSample
    get MEM_SIZE asize MEMORY_FILE
    math RIFFTMP = MEM_SIZE
    math RIFFTMP - 0x14
    putvarchr MEMORY_FILE 0x10 RIFFTMP long

    # "data"
    putdstring "data" 4 MEMORY_FILE
    put SIZE long       MEMORY_FILE

    get MEM_SIZE asize MEMORY_FILE
    math RIFFTMP = SIZE
    math RIFFTMP + MEM_SIZE
    math RIFFTMP - 8
    putvarchr MEMORY_FILE 4 RIFFTMP long

    log NAME 0 MEM_SIZE MEMORY_FILE
    append
    log NAME 0 SIZE MEMORY_FILE2
    append
endfunction


If i try directly on the DUNE.DAT i got this :

Code: Select all

 the script needs to load a pre-compiled function from the dll or code
  MEMORY_FILE10
  do you want to continue with this and any other requested dll/code (y/N)?
Last edited by Tgames on Mon Apr 08, 2019 7:14 pm, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Convert old MexScript to BMSScript ?

Post by aluigi »

Input file must be DUNE.DAT
Tgames
Posts: 81
Joined: Mon Apr 01, 2019 10:49 am

Re: Convert old MexScript to BMSScript ?

Post by Tgames »

Ah good it's better indeed to work directly on DUNE.DAT but i got this when trying with DUNE.DAT :

Code: Select all

- select BMS script. type ? for using the content of clipboard like a script
- select input archives/files, type * for the whole folder and subfolders
- select output folder where extracting files
- open input file D:\Jeux\QuickBMS\DUNE.DAT
- open script D:\Jeux\QuickBMS\DUNEMEG.bms
- set output folder D:\Jeux\QuickBMS\test

  offset           filesize   filename
--------------------------------------

- the script needs to load a pre-compiled function from the dll or code
  MEMORY_FILE10
  do you want to continue with this and any other requested dll/code (y/N)?
  y
- library MEMORY_FILE10 loaded at address 011F6910
- function found at offset 011F0700
  0000000000000000 44         0.wav

- The following output file already exists:
  0.wav
  Do you want to overwrite it?
    y = overwrite (you can use also the 'o' key)
    n = skip (default, just press ENTER)
    a = overwrite all the files without asking
    r = automatically rename the files with the same name
    s = skip all the existent files without asking

a
+ 0000000000000000 54630540896220017 0.wav

-------------------
*EXCEPTION HANDLER*
-------------------
An error or crash occurred:

*EH* ExceptionCode      c0000005 access violation
*EH* ExceptionFlags     00000000
*EH* ExceptionAddress   76D6BE07
                        76CE0000 + 0008be07 msvcrt.dll
*EH* NumberParameters   00000002
*EH*                    00000001
*EH*                    06FDE000

Last script line before the error or that produced the error:
  90  log NAME 0 SIZE MEMORY_FILE2

Press ENTER or close the window to quit


I got a "ExceptionHandler".
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Convert old MexScript to BMSScript ?

Post by aluigi »

Use ever quickbms.exe.
quickbms_4gb_files.exe must be used only in specific situations.

Anyway I will check what's wrong although I'm 100% sure it's related to the C compiler which is 32bit.
Tgames
Posts: 81
Joined: Mon Apr 01, 2019 10:49 am

Re: Convert old MexScript to BMSScript ?

Post by Tgames »

Woahh you are incredible aLuigi !

It's work perfectly !!!!!

A huuuuge thanks for your hard work !!

I have every voices already perfect !
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Convert old MexScript to BMSScript ?

Post by aluigi »

They can be even more perfect if we select only the "Megative Voice" files and cut out that header from the output.
Tgames
Posts: 81
Joined: Mon Apr 01, 2019 10:49 am

Re: Convert old MexScript to BMSScript ?

Post by Tgames »

Yes good voices start at 63.wav.

But it's really a huge improvement !
Tgames
Posts: 81
Joined: Mon Apr 01, 2019 10:49 am

Re: Convert old MexScript to BMSScript ?

Post by Tgames »

Acewell wrote:this will replace that spider man script and will extract all files as opposed
to just uncompressed wav and bik files, at least from my tests. :)

Code: Select all

idstring "PKR3"
get INFO_OFF long
goto INFO_OFF
get UKN long
get NUM_FOLDERS long
get TOTAL_FILES long
savepos FOLDERSTART
math TMP = NUM_FOLDERS
math TMP * 40
math TMP + FOLDERSTART
for i = 0 < NUM_FOLDERS
    goto FOLDERSTART
    getdstring FOLDERNAME 0x20
    get TPF long
    get FILES long
    savepos FOLDERSTART
    goto TMP
    for j = 0 < FILES
        getdstring FNAME 0x20
        get UKN2 long
        get FLAG long
        get OFFSET long
        get SIZE long
        get ZSIZE long
        string NAME p "%s%s" FOLDERNAME FNAME
        if FLAG < 2
            log NAME OFFSET ZSIZE
        else
            clog NAME OFFSET ZSIZE SIZE
        endif
    next j
    savepos TMP
next i


Works perfectly fine with normal QuickBMS !
A huge thanks to you too, Acewell !

@Acewell, do you have a full script also for the PS1 version of Spider Man ?
To extract each voices from COMPILED.XA and files from CD.WAD ?
For @Acewell : https://we.tl/t-iLerGIgo37
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Convert old MexScript to BMSScript ?

Post by aluigi »

Code: Select all

set MEMORY_FILE10 string "
int convert(unsigned char *data, int size, unsigned char *wav) {
    int read, write, i = 0, x = 0;
    while(i < size) {
        read = data[i++];
        {
            if(read < 0x80)
                write = 0x80 - read;
            else
                write = read;

            if(write == 0xFF)       
            {
                i += 12;
            }
            else
                    wav[x++] = write;
        }
    }
    return x;
}
"

for i = 0
    savepos OFFSET
    findloc EOF binary "PPPPPPPP"
    if OFFSET == EOF
        break
    endif
    math SIZE = EOF
    math SIZE - OFFSET

    getdstring MAGIC 8
    if MAGIC u== "Megative"
        math OFFSET + 0x800
        math SIZE   - 0x800
        string NAME p "%d.wav" i
        callfunction DUMP
    else
        string NAME p "DAT/%d.dat" i
        log NAME OFFSET SIZE
    endif

    math EOF x 0x800
    goto EOF
next i

startfunction DUMP
    log MEMORY_FILE2 0 0
    putvarchr MEMORY_FILE2 SIZE 0

    log MEMORY_FILE OFFSET SIZE
    calldll MEMORY_FILE10 "convert" "tcc" SIZE MEMORY_FILE SIZE MEMORY_FILE2

    math CODEC = 1
    math BITS = 8
    math CHANNELS = 1
    math FREQUENCY = 22222

    math BLKALIGN = BITS
    math BLKALIGN / 8
    math BLKALIGN * CHANNELS
    math AVGBYTES = FREQUENCY
    math AVGBYTES * BLKALIGN

    log MEMORY_FILE 0 0
    putdstring "RIFF" 4 MEMORY_FILE
    put 0 long          MEMORY_FILE
    putdstring "WAVE" 4 MEMORY_FILE

    # "fmt "
    putdstring "fmt " 4 MEMORY_FILE
    put 0 long          MEMORY_FILE
    put CODEC short     MEMORY_FILE # wFormatTag: Microsoft PCM Format (0x0001)
    put CHANNELS short  MEMORY_FILE # wChannels
    put FREQUENCY long  MEMORY_FILE # dwSamplesPerSec
    put AVGBYTES long   MEMORY_FILE # dwAvgBytesPerSec
    put BLKALIGN short  MEMORY_FILE # wBlockAlign
    put BITS short      MEMORY_FILE # wBitsPerSample
    get MEM_SIZE asize MEMORY_FILE
    math RIFFTMP = MEM_SIZE
    math RIFFTMP - 0x14
    putvarchr MEMORY_FILE 0x10 RIFFTMP long

    # "data"
    putdstring "data" 4 MEMORY_FILE
    put SIZE long       MEMORY_FILE

    get MEM_SIZE asize MEMORY_FILE
    math RIFFTMP = SIZE
    math RIFFTMP + MEM_SIZE
    math RIFFTMP - 8
    putvarchr MEMORY_FILE 4 RIFFTMP long

    log NAME 0 MEM_SIZE MEMORY_FILE
    append
    log NAME 0 SIZE MEMORY_FILE2
    append
endfunction
Tgames
Posts: 81
Joined: Mon Apr 01, 2019 10:49 am

Re: Convert old MexScript to BMSScript ?

Post by Tgames »

Woah :D

No more glitch on beginning of each WAV.

Thanks a lot aLuigi !!

Now the script is perfect for me !