Backgrounds - Gemini-Loboto3/DC2-Mod-SDK GitHub Wiki
DBS files inside the DATA folder are used to store backgrounds and masking graphics + data. These files are arranged like Dino Crisis packages, but can hold multiple containers instead of just a series of packed entries. They store in the following manner:
|-Package
|--Mask data
|--JPEG background
|--Mask palette (optional)
|--Mask graphics (optional)
|-Package
|-[...]
|-Package
Mask data
The masking data is stored with 4 leading bytes counting how many mask entries there are in the structure, and the following structure to dictate how masks are assembled on screen:
typedef struct mask_t
{
uint8_t x; // screen position: x / 16
uint8_t y: 4; // screen position: y / 16
uint8_t dummy : 4; // unused
uint16_t depth; // z-depth value
} mask_s;
Each entry represents a 16x16 square in the masking graphics, with no uv maps required.
The whole structure can be represented like this:
typedef struct maskdata_t
{
uint32_t count; // amount of mask_s entries following
mask_s data[1]; // the actual data
} maskdata_s;
When a background has no mask, this entry will be 4 bytes in size with a count of 0.
JPEG background
Nothing much to say about this. It's a standard 320x240 JPEG image for the background.
Mask palette
This data is only used when a background uses a full screen mask (indicated by a type ID of 8). When this is used, it's stored as PlayStation cluts, with 16 bits to represent each color.
Mask graphics
Regular mask (type 0)
These are the graphics used to mask parts of the background so that entities can seamlessly pass through a pseudo 3D environment. They are lzss compressed (despite type 0 marking no compression usage) with no swizzling, and are stored as 18x18 blocks of images in 16 bits per pixel. These 18x18 tiles generally have the same color format as cluts, but use the MSB (0x8000) to indicate if a pixel is fully transparent or not. Note: On PlayStation these are assembled as 16x16 blocks of graphics and are stored as swizzle-compressed textures. On PC format and size have been changed so that masks can be filtered with no visible seams, yet are still treated in terms of screen placement as 16x16 blocks.
Large mask (type 8)
These are the graphics used to generate very large masks that usually overlap on the entire background. Type 8 is only ever used in this case and it represents lzss compressed textures with no swizzling applied to them. They are stored as 8 bit per pixel images and the size of these graphics can be derived directly from the a sub-DBS header chunk. These are typically 256x448 pixel images, with the first 3 slices assembled to compose a 320x240 lossless image. Example of these masks can be found in the boat section and in the introduction sequence with the big fence covering the players.