The 5bg format (which a file having an extension .lz5bg, is likely to just be an LZ-compressed version of) the BG/OBJ graphics file format of iMageStudio 5.
These take the structure of a binary block sequence (the same one as in an NCLR, NCGR, etc format file). These files have a file signature of NTBG. They contain these blocks:
[TABLE=full]
[TR]
[td]Block[/td][td]Usage[/td]
[/TR]
[TR]
[td]PALT[/td][td]Color palette. Required for all indexed graphics formats.[/td]
[/TR]
[TR]
[td]BGDT[/td][td]BG data. Contains character/bitmap data and BG screen data, if appplicable. This block's presence means this is a BG data file.[/td]
[/TR]
[TR]
[td]OBJD[/td][td]OBJ data. This block's presence means this is an OBJ data file.[/td]
[/TR]
[TR]
[td]DFPL[/td][td]Character attribute data.[/td]
[/TR]
[TR]
[td]COMT[/td][td]Comment data (optional).[/td]
[/TR]
[TR]
[td]XTRA[/td][td]Extra data (optional).[/td]
[/TR]
[/TABLE]
PALT Block
This block stores the color palette. Its structure is:
[TABLE=full]
[TR]
[td]Offset[/td][td]Type[/td][td]Meaning[/td]
[/TR]
[TR]
[td]00[/td][td]u32[/td][td]Number of palette colors.[/td]
[/TR]
[TR]
[td]04[/td][td]u16[][/td][td]Palette colors.[/td]
[/TR]
[/TABLE]
BGDT Block
This block stores the BG data. Its structure is:
[TABLE=full]
[TR]
[td]Offset[/td][td]Type[/td][td]Meaning[/td]
[/TR]
[TR]
[td]00[/td][td]u8[/td][td]BG type[/td]
[/TR]
[TR]
[td]01[/td][td]u8[/td][td]BG size[/td]
[/TR]
[TR]
[td]02[/td][td]u8[/td][td]BG screen unit size[/td]
[/TR]
[TR]
[td]03[/td][td]u8[/td][td]Padding (not used)[/td]
[/TR]
[TR]
[td]04[/td][td]u32[/td][td]BG screen size[/td]
[/TR]
[TR]
[td]08[/td][td]u16[/td][td]BG height tiles[/td]
[/TR]
[TR]
[td]0A[/td][td]u16[/td][td]BG width tiles[/td]
[/TR]
[TR]
[td]0C[/td][td]u16[/td][td]Character width tiles[/td]
[/TR]
[TR]
[td]0E[/td][td]u16[/td][td]Character height tiles[/td]
[/TR]
[TR]
[td]10[/td][td]u32[/td][td]Character data size[/td]
[/TR]
[/TABLE]
The BG type field takes on a value from these:
[TABLE=full]
[TR]
[td]Value[/td][td]Meaning[/td]
[/TR]
[TR]
[td]00[/td][td]Text BG (16x16)[/td]
[/TR]
[TR]
[td]01[/td][td]Text BG (256x1)[/td]
[/TR]
[TR]
[td]02[/td][td][/td]
[/TR]
[TR]
[td]03[/td][td]Affine BG (256x1)[/td]
[/TR]
[TR]
[td]04[/td][td][/td]
[/TR]
[TR]
[td]10[/td][td]Bitmap BG (256x1)[/td]
[/TR]
[TR]
[td]11[/td][td]Large Bitmap BG (256x1)[/td]
[/TR]
[TR]
[td]12[/td][td]Direct Color BG[/td]
[/TR]
[/TABLE]
The value of the BG type is used to give meaning to the BG size field, which may take on a value between 0 and 3, or FF. Values 0-3 correspond to the size parameter of the size parameter for a background layer of a given type, and FF indicates the "free size" (i.e. size is not constrained to hardware-supported background size). For the large bitmap BG format, this may not be 2 or 3.
The BG screen unit size field controls how the BG screen data is interpreted. It may be 0, 1, 2, 4, 6, 8, or 10 (decimal). For the bitmap BG formats, this field must be 0, and for other formats it must be nonzero. The format of screen data depends on this size parameter, and these are following:
[TABLE=full]
[TR]
[td]Size[/td][td]Format[/td]
[/TR]
[TR]
[td]0[/td][td]No BG screen data exists.[/td]
[/TR]
[TR]
[td]1[/td][td]Screen data is an 8-bit character name.[/td]
[/TR]
[TR]
[td]2[/td][td]Screen data format is the same as text/affine extended screen data format.[/td]
[/TR]
[TR]
[td]4[/td][td]Screen data format is extended to 32 bits, with low 16 bits holding the character name, and upper 6 bits holding the palette index and flipping mode.[/td]
[/TR]
[TR]
[td]6[/td][td]...[/td]
[/TR]
[TR]
[td]8[/td][td][/td]
[/TR]
[TR]
[td]10[/td][td][/td]
[/TR]
[/TABLE]
Following the header is the BG screen data (if it exists), then the character/bitmap data. The size of character data may be less than the size indicated by the character dimensions in the header.
OBJD Block
This block stores the OBJ mode graphics data. It takes the structure:
[TABLE=full]
[TR]
[td]Offset[/td][td]Type[/td][td]Meaning[/td]
[/TR]
[TR]
[td]00[/td][td]u32[/td][td]OBJ attribute info[/td]
[/TR]
[TR]
[td]04[/td][td]u32[/td][td]OBJ data size[/td]
[/TR]
[TR]
[td]08[/td][td]u16[/td][td]OBJ screen width[/td]
[/TR]
[TR]
[td]0A[/td][td]u16[/td][td]OBJ screen height[/td]
[/TR]
[TR]
[td]0C[/td][td]u32[/td][td][/td]
[/TR]
[TR]
[td]10[/td][td]u16[/td][td]Character width tiles[/td]
[/TR]
[TR]
[td]12[/td][td]u16[/td][td]Character height tiles[/td]
[/TR]
[TR]
[td]14[/td][td]u32[/td][td]Character graphics size[/td]
[/TR]
[/TABLE]
Following the header is the OBJ data array. Following the OBJ data array is the character data.
DFPL Block
This block stores attribute data for the character graphics and is optional.
COMT Block
This block st ores comment information in the file and is optional. It takes the form of a 16-bit comment length, followed by the comment string.
XTRA Block
This block is optional.