ADMIN, DELETE.

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
zeaofsuos
Posts: 104
Joined: Sun Jan 13, 2019 11:45 pm

ADMIN, DELETE.

Post by zeaofsuos »

ADMIN, DELETE.
Last edited by zeaofsuos on Wed Apr 14, 2021 5:58 pm, edited 1 time in total.
Pepper
Posts: 2
Joined: Mon Nov 17, 2014 9:24 pm

Re: Death by Cube (XBLA) SGB File BGM Music

Post by Pepper »

looks like xma starting at 0x800
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Death by Cube (XBLA) SGB File BGM Music

Post by aluigi »

Yes xma.
Not sure what tool should be used to play that data and how the final WAV should look like, the following is an experiment:

Code: Select all

endian big
idstring "PASX"
get ZERO long
get SOME_OFF long
get SIZE long
get INFO_OFF long
get DUMMY_SIZE long
get OFFSET long
goto INFO_OFF
get CODEC short
get CHANNELS short
get FREQUENCY long
get BLKALIGN long
get BITS short
get WAV_BITS short
get NAME basename
string NAME + ".wav"

endian little
callfunction TOWAV 1

# Requirements: CODEC, BITS, FREQUENCY, CHANNELS, OFFSET, SIZE and NAME
# Optional:     RIFF_MORE/RIFF_MORE_SIZE, BLKALIGN and SAMPLES
startfunction TOWAV # (aka DUMP_WAV) 0.2
    math AVGBYTES = 0
    if BLKALIGN == 0
        if BITS >= 8
            math BLKALIGN = BITS
            math BLKALIGN / 8
        else
            math BLKALIGN = 1
        endif
        math BLKALIGN * CHANNELS
        math AVGBYTES = FREQUENCY
        math AVGBYTES * BLKALIGN
    endif
    if CODEC == 0x69
        xmath BLOCKALIGN "36 * CHANNELS"
        xmath AVGBYTES "(689 * BLOCKALIGN) + 4"
    endif

    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
    if RIFF_MORE_SIZE > 0
        putdstring RIFF_MORE RIFF_MORE_SIZE MEMORY_FILE
    endif
    get MEM_SIZE asize MEMORY_FILE
    math RIFFTMP = MEM_SIZE
    math RIFFTMP - 0x14
    putvarchr MEMORY_FILE 0x10 RIFFTMP long

    # "fact"
    if CODEC != 1
        if SAMPLES > 0
            putdstring "fact" 4 MEMORY_FILE
            put 4 long          MEMORY_FILE
            put SAMPLES long    MEMORY_FILE
        endif
    endif

    # "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 OFFSET SIZE
    append
endfunction