ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sat Jul 20, 2019 10:29 pm

All times are UTC




Post new topic  Reply to topic  [ 51 posts ]  Go to page Previous 1 2 3 Next
Author Message
PostPosted: Mon Apr 08, 2019 12:50 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
No idea, maybe they are sprites or something like that... not my field


Top
   
PostPosted: Mon Apr 08, 2019 12:59 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
No problem ;)

Here a C code i have adapted to work to extract every voices from Dune (Mega CD Version).

Code:
#include "stdio.h"

int ConvertToWav()
{
    FILE    *file, *wav;
    int     read = EOF, write, i = 0;
    int    wavheader[] = {
        0x52, 0x49, 0x46, 0x46, 0x04, 0x09, 0x42, 0x13, 0x57, 0x41,
      0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00,
      0x01, 0x00, 0x01, 0x00, 0xCE, 0x56, 0x00, 0x00, 0x9C, 0xAD,
      0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61,
      0xE0, 0x08, 0x42, 0x13, 0x00
            };

    printf("Dune PCM Dumper to Wav Converted Modified by Tgames V1.0\n");
    file = fopen("DUNE.DAT", "r");
    if(!file)
    {
        printf("Could not open DUNE.DAT, please copy it in this folder and restart\n");
        return(0);
    }
    wav = fopen("DUNEMGCD_PCM.wav", "w");
    if(!wav)
    {
        fclose(file);
        printf("Could not create output file\n");
        return(0);
    }

    do
    {
        write = wavheader[i++];
        if(write != 0xFF)
            fputc(write, wav);
    }
    while(write != 0xFF);

    printf("Writing to DUNEMGCD_PCM.wav\n");
    do
    {
        read = fgetc(file);
        if(read != EOF)
        {
            if(read < 0x80)
                write = 0x80 - read;
            else
                write = read;

            if(write == 0xFF)       
            {
                int skip = 0;

                do
                {
                    read = fgetc(file);
                    skip ++;
                }
                while(skip < 12 && read != EOF);
            }
            else
                    fputc(write, wav);
        }
    }
    while(read != EOF);

    fclose(wav);
    fclose(file);
    printf("Conversion complete\n");
    return(1);
}

int main()
{
    if(!ConvertToWav())
        return(1);

    return(0);
}


But it just make a full WAV file and not cut every voices one by one (like a BMS Script do)

Theses Voices (after the C Script) are :

Encoding: Unsigned 8-bit PCM
Bytes order : "Endianness"
22222Hz Mono

Are you sure Dune Mega CD have no header ? It can helps us, because it's really painful to cut every voices in my export xD.
We have everything thanks to this C code, but really really long to cut every voices one by one :mrgreen:

Dune Mega CD : https://we.tl/t-AC7iGRP2Ew


Top
   
PostPosted: Mon Apr 08, 2019 1:07 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
There are only zeroes at the beginning and 'P's at the end.
No structure.


Top
   
PostPosted: Mon Apr 08, 2019 1:09 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
Arf bad :(

And in my export, can a BMS Script auto split each voices ?

Here is my full export of all voices :

https://we.tl/t-Fq7MHjODmG

There is a separator sound between each voices.


Top
   
PostPosted: Mon Apr 08, 2019 1:18 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
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


Top
   
PostPosted: Mon Apr 08, 2019 1:24 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
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.


Top
   
PostPosted: Mon Apr 08, 2019 1:27 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
I think it's more easy if you use that tool, once the files are extracted you can mass converting them on the fly.


Top
   
PostPosted: Mon Apr 08, 2019 1:27 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
Obviously that C code needs some edits, the filename for sure.
I also suggest EVER to use "wb" instead "w" with fopen.


Top
   
PostPosted: Mon Apr 08, 2019 1:30 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
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).


Top
   
PostPosted: Mon Apr 08, 2019 3:14 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
That C code is super bugged


Top
   
PostPosted: Mon Apr 08, 2019 3:20 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
Really it doesn't work at all.
The result is garbage.


Top
   
PostPosted: Mon Apr 08, 2019 6:23 pm 
User avatar

Joined: Fri Aug 08, 2014 1:06 am
Posts: 615
Tgames wrote:
Thanks for the fix for the first script...

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

_________________
Quickbms.com link thread
Search bms scripts


Top
   
PostPosted: Mon Apr 08, 2019 6:25 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
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 :/


Top
   
PostPosted: Mon Apr 08, 2019 6:38 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
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


Top
   
PostPosted: Mon Apr 08, 2019 6:46 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
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.


Top
   
PostPosted: Mon Apr 08, 2019 6:48 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
The correct values for all .meg (after conversion) are :

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


Top
   
PostPosted: Mon Apr 08, 2019 6:56 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
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


Top
   
PostPosted: Mon Apr 08, 2019 6:56 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
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.


Top
   
PostPosted: Mon Apr 08, 2019 6:57 pm 

Joined: Mon Apr 01, 2019 10:49 am
Posts: 73
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.


Top
   
PostPosted: Mon Apr 08, 2019 7:04 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 10553
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?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 51 posts ]  Go to page Previous 1 2 3 Next

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited