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.

Convert old MexScript to BMSScript ?

Featured Replies

  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 1:18 pm (46648)


Those separators you see are the 'P's I said before.
Every file is aligned to 2048 bytes and the 'P's are used for padding.
The index file contains both offsets and sizes, without them it's just a waste of time.

You can use this script on DUNE.DAT and it will use the 'P's for dumping the files separately:
Code:
for
    savepos OFFSET
    findloc EOF binary "PPPPPPPP"
    if OFFSET == EOF
        break
    endif
    math SIZE = EOF
    math SIZE - OFFSET
    log "" OFFSET SIZE
    math EOF x 0x800
    goto EOF
next
  • Replies 51
  • Views 3
  • Created
  • Last Reply

Top Posters In This Topic

  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 1:24 pm (46650)


Thanks for the script !

It's possible to include the convert of each files generated or i can just convert them with the C code ?

Best Regards.
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 1:27 pm (46651)


I think it's more easy if you use that tool, once the files are extracted you can mass converting them on the fly.
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 1:27 pm (46652)


Obviously that C code needs some edits, the filename for sure.
I also suggest EVER to use "wb" instead "w" with fopen.
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 1:30 pm (46654)


Thanks for all your answers :)
Can you write what i need to change on the C code (if you can, otherwhise i will search myself don't worry).
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 3:14 pm (46657)


That C code is super bugged
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 3:20 pm (46658)


Really it doesn't work at all.
The result is garbage.
  • Author
  • Localization

Acewell, posted Mon Apr 08, 2019 6:23 pm (46660)


Tgames wrote:
Thanks for the fix for the first script...

um, you're welcome? :roll:
the spiderman mexscript was also incomplete...
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 6:25 pm (46661)


I used this code to convert the audio to something readable aLuigi :

http://junkerhq.net/Snatcher/PCM2WAV/

Thanks Acewell for the Spider Man Extract code but i got an error when trying to extract a package :/
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 6:38 pm (46663)


Something readable? I hear only noise which means that it uses a specific codec and the trick used in that C code doesn't work.

Anyway the following is the script, once you have the codec code it's easy to put it in the convert() function:
Code:
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 = 16
    math CHANNELS = 1
    math FREQUENCY = 22050

    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
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 6:46 pm (46664)


This is the original code of the PCM Extractor tool :

http://junkerhq.net/Snatcher/PCM2WAV/Sn ... CM2WAV.zip

1) Just rename any .meg to < PCMLD_01.BIN >
2) Throw this file into spcm2wav.exe
3) It will generate a file < Snatcher_PCM.wav >
4) Open this file with Audacity in < Raw Mode >
5) Set values to :
Encoding: Unsigned 8-bit PCM
Bytes order : "big endian"
22222Hz Mono
6) That's all, the audio is correct, just remove 1 second at the beginning
7) It can be exported to WAV

But Indeed the original source code seems a bit buggy !

By following theses step it's work on each files but indeed the code is buggy :/

Thanks a lot for the script !
But it's seems to do nothing on .meg files.
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 6:48 pm (46665)


The correct values for all .meg (after conversion) are :

Encoding: Unsigned 8-bit PCM
Bytes order : "big endian"
22222Hz Mono
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 6:56 pm (46666)


Here is a english sample converted to .VOC with correct values taken from the Mega CD version :

https://we.tl/t-gLY8d05ks0

All voices are in the same values :

Encoding: Unsigned 8-bit PCM
Bytes order : "big endian"
22222Hz Mono
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 6:56 pm (46667)


endianess doesn't exist in 8bits, frequency is 22050 as stated in the script (why it should be 22222???).
For setting 8 bits it's enough to use BITS = 8 in the script where it's currently 16

Those audio files are "Megative Voice File" while the others are different things.
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 6:57 pm (46668)


It's big endian.

I badly translated to english "Gros boutisme" in french ^^

It's really 22222hz ! We are sure about that, because in all Dune port it's 22222hz.

And we have a 1:1 comparaison between english voices from the Mega CD and PC in 22222hz it's totally identical.
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 7:04 pm (46669)


Interesting that thing of the sample rate, developers are crazy :)

Now the main question remains: we have DUNE.DAT but where are the other files and executables that contain the index?
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 7:05 pm (46670)


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
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 7:10 pm (46671)


I got zero file extracted with the script.

I do something wrong ? :(

Code:
- 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:
set MEMORY_FILE10 string "
int convert(unsigned char *data, int size, unsigned char *wav) {
    int read, write, i = 0, x = 0;
    while(i         read = data[i ];
        {
            if(read                 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:
 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)?
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 7:13 pm (46673)


Input file must be DUNE.DAT
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 7:15 pm (46674)


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

Code:
- 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".
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 7:29 pm (46675)


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.
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 7:33 pm (46676)


Woahh you are incredible aLuigi !

It's work perfectly !!!!!

A huuuuge thanks for your hard work !!

I have every voices already perfect !
  • Author
  • Localization

aluigi, posted Mon Apr 08, 2019 7:38 pm (46677)


They can be even more perfect if we select only the "Megative Voice" files and cut out that header from the output.
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 7:41 pm (46678)


Yes good voices start at 63.wav.

But it's really a huge improvement !
  • Author
  • Localization

Tgames, posted Mon Apr 08, 2019 8:05 pm (46679)


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:
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     goto FOLDERSTART
    getdstring FOLDERNAME 0x20
    get TPF long
    get FILES long
    savepos FOLDERSTART
    goto TMP
    for j = 0         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             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
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.