Humongous CUP

From MultimediaWiki
Jump to navigation Jump to search

Humongous CUP files are used as demo movies for games from Humongous Entertainment. CUP files have the file signature 'BEAN' and are played with an executable called coffee.exe. They appear to contain non-interleaved audio and video data; all of the audio data is stored in the file first and the video data second.

Data Format

Multi-byte numbers may be little or big endian

 bytes 0-3     chunk type FourCC
 bytes 4-7     chunk size (including this 8-byte preamble); big endian
 bytes 8..     chunk payload

The top-level chunk in a CUP file is the BEAN chunk which encapsulates the entire file and can also serve as a file signature:

 bytes 0-3     'BEAN' FourCC
 bytes 4-7     size of entire CUP file (including this preamble); big endian
 bytes 8..     CUP file

Following the BEAN signature is a HEAD chunk with the following format:

 bytes 0-3     'HEAD' FourCC
 bytes 4-7     size = 0x0E = 14 bytes; big endian
 bytes 8-9     unknown, always seems to be 0x0042 (66) in little endian
 bytes 10-11   video width
 bytes 12-13   video height

An RGBS chunk often appears after the HEAD chunk in a CUP file. It has the following layout:

 bytes 0-3     'RGBS' FourCC
 bytes 4-7     chunk size = 0x0308 = 776 bytes; big endian
 bytes 8..775  palette entries

The palette entries are 256 3-byte triplets of red-green-blue palette components. Each component is 8 bits (as opposed to 6 bits which is often seen in palettized formats).

The RGBS chunk is generally followed by the SFXB chunk which contains audio data. This is the typical hierarchical organization of the SFXB chunk and its constituent chunks:

  • SFXB
    • WRAP
      • OFFS
      • DATA
      • DATA
      • ..

The SFXB chunk contains its preamble and the WRAP chunk. The WRAP chunk contains its preamble, an OFFS chunk and a series of DATA chunks. The OFFS chunk has the following format:

 bytes 0-3    'OFFS' FourCC
 bytes 4-7    chunk size; big endian
 bytes 8..    DATA chunk offsets; little endian

The DATA chunk offsets are 4-byte numbers stored in little endian format that fill the remainder of the OFFS chunk after the preamble. They indicate the offsets (and, implicitly, the count) of audio DATA chunks. The offsets are relative to the start of the OFFS chunk. It is instructive to note that since the first DATA chunk immediately follows the OFFS chunk, its offset will be the same as the size of the OFFS chunk, though stored in the opposite byte order. For example, if there were only one audio DATA chunk in the file, and the OFFS chunk began at 0x32E:

 0x32E  4F 46 46 53  00 00 00 0C  0C 00 00 00  44 41 54 41  OFFS........DATA
 0x33E  ....

The audio DATA chunks usually contain uncompressed PCM in 8-bit, unsigned format. But they sometimes contain the following hierarchical organizations:

  • DATA
    • TALK
      • HSHD
      • SDAT

In this case, the DATA chunk contains its preamble and the TALK chunk. The TALK chunk contains its preamble followed by the HSHD and SDAT chunks. The HSHD chunk has the following layout:

 bytes 0-3    'HSHD' FourCC
 bytes 4-7    chunk size = 0x18 = 24 bytes; big endian
 bytes 8-13   unknown
 bytes 14-15  sample rate; little endian
 bytes 16-23  unknown

The SDAT chunk contains uncompressed, unsigned, 8-bit PCM data.

After the SFXB is another chunk marked DATA. DATA has many meanings in this formats. This data chunk encapsulates a number of BLOK chunks. This is the hierarchical organization of BLOCK chunk:

  • BLOK
    • RGBS
    • RATE
    • SNDE
    • TOIL
    • SRLE
    • LZSS

The RGBS chunk, already described, indicates that the palette can change during playback. The RATE chunk has the following layout:

 bytes 0-3    'RATE'
 bytes 4-7    chunk size = 0xA = 10 bytes; big endian
 bytes 8-9    unknown

It is possible that this defines a change in the playback rate.

The SNDE chunk has the following format:

 bytes 0-3    'SNDE'
 bytes 4-7    chunk size = 0x12 = 18 bytes; big endian
 bytes 8-17   unknown

While the purpose of this block is unknown, some of the numbers may reference back into the AUDIO data chunks to specify which piece of audio should be playing at the current time.

The TOIL chunk has the following format:

 bytes 0-3    'TOIL'
 bytes 4-7    chunk size = 0x10 = 16 bytes; big endian
 bytes 8-15   unknown

SRLE and LZSS indicated video compression types and will be explained in their own sections.

Chunk Types

BEAN: file signature

HEAD: contains 10-byte payload including unknown 16-bit quantity and 32-bit width and height stored as little-endian

RGBS: palette triplets; payload should be 0x300 (768, 256x3) bytes long; values range from 0..255; must be a constant length since it has no provision for palette replacement

SFXB..WRAP..OFFS: apparently a setup for audio data

DATA: audio or video data; audio data is 8-bit, unsigned PCM

BLOK: video data block?

SRLE: apparently the video compression type, possibly based on lzss.c

SNDE: reference into audio data?

RATE: