XPlor/definitions/asura/chunks/fcsr_chunk.xscript

74 lines
1.8 KiB
Plaintext
Raw Normal View History

// FCSR - File/Resource Chunk (reversed "RSCF")
// Contains embedded file data with path and type information
// Primary chunk type for storing assets in Asura archives
type fcsr_chunk [display="FCSR Resource"] byteorder BE
{
// Save chunk start position
chunk_start = pos();
// Standard 16-byte Asura chunk header
chunk_id = ascii(read(4));
u32 chunk_size;
u32 version;
u32 flags;
chunk_id = chunk_id;
ui("chunk_id", "Chunk ID");
chunk_size = chunk_size;
ui("chunk_size", "Chunk Size");
version = version;
ui("version", "Version");
flags = flags;
ui("flags", "Flags");
// Resource metadata
u32 resource_type;
u32 unknown1;
u32 resource_size;
resource_type = resource_type;
ui("resource_type", "Resource Type");
unknown1 = unknown1;
ui("unknown1", "Unknown");
resource_size = resource_size;
ui("resource_size", "Resource Size");
// Resource file path (null-terminated)
resource_path = cstring();
resource_path = resource_path;
ui("resource_path", "Resource Path");
// Get filename from path and set as chunk name for tree display
export_name = basename(resource_path);
set_name(export_name);
// Calculate where resource data starts
resource_offset = chunk_start + chunk_size - resource_size;
// Export resource if size > 0
if (resource_size > 0 && resource_offset >= pos()) {
// Seek to resource data
seek(resource_offset);
// Read resource data
resource_data = read(resource_size);
// Export the file
write_file(export_name, resource_data);
// Preview all resources (C++ handles routing to image/audio/hex viewer)
set_preview(export_name, resource_data);
}
}