Tes2Mod:BLOCKS.BSA/Map Block Records

Map Block Records describes the exterior block data for locations from MAPS.BSA. Each Map Block Record describes one exterior block, which fits into a two-dimensional grid with the other blocks for that location's exterior. The architecture, the doors, the automap, flats, etc are all here.

Each Map Block Record name must be one of the defined combinations found in Block Record Indexes and must end with the string ".RMB". Ex: "TVRNAL00.RMB".

General File Layout
The Map Block Record (RMB) is the most common type found in the file. It is a variably sized record, but the RmbHeader is fixed at 6776 bytes long. This contains all the necessary information to compute the record's total length. It is a composite structure organized as follows:



RmbHeader
Each Map Block Record begins with a 6776 byte long header structure. This structure itself is a composite structure organized as follows:



These substructures are contiguous within the RmbHeader; this is to say the FileNameList immediately follows the Automap. Some of these subsections are to be subdivided into 32 further subrecords as described in each section below.

ObjectCount
This structure reports the counts of the variably-sized data which compose the Map Block Record.



BlockPositionList
The BlockPositionList is a contiguous list of 32 BlockPosition structures, each 20 bytes long. Only ObjectCount.BlockCount elements are used; the remainder may be ignored but all 32 must be read. The BlockPosition structure is detailed below:



BuildingDataList
Found immediately following the BlockPositionList is a contiguous list of 32 BuildingData elements, as found in MAPS.BSA.

Section2
Immediately following the BuildingDataList is the following structure:



GroundData
The GroundData structure immediately follows the BlockSizeList. This 512 byte fixed-size structure is a composite structure which specifies the ground textures and one additional piece of unknown data.



GroundTextureList
Following the GroundDataHeader structure is a contiguous list of 256 GroundTexture structures, each a 1 byte long. These are to be considered a 16x16 GroundTexture grid, detailed as follows:



GroundDecoration
Immediately following the GroundTextureList is a byte array, 256 bytes long. It corresponds to the same 16x16 grid.

The unspecified bytes seem to have a value of 0xff.

Automap
Immediately following the GroundData are 4096 bytes used to generate a 64x64 pixel bitmap. This is the location's automap, as displayed in the game. The bitmap does not control the placement of any architecture; it is merely displayed to the user. Value 0x00 indicates a transparent pixel; otherwise subtract one from the value and it conforms to the Building Type enumeration values. Ship, Special1, Special2, Special3, and Special4 are never displayed on the automap.

FileNameList


BlockList
Following the RmbHeader is a contiguous list Block structures, RmbHeader.ObjectCount.BlockCount elements in count. The byte length of each element is reported by the BlockSizeList.

A Block structure is a composite structure containing two BlockData structures; the first structure defines the exterior of the block and the second BlockData structure defines the interior of the block. A Block structure is variably-sized. The size of each Block structure is provided by the BlockSizeList in the RmbHeader via ordinal index; that is to say the second element of the BlockSizeList declares the size of the second Block element of the BlockList. Therefore these two lists must be synchronized for proper operation.

Fundamental Structures
Before delving into the Block structure it is important to understand some basic types used by Daggerfall.

BlockSectionBase
This structure is used as a base template for the Section3, Flat, Person, and Door structures. The format is as follows:



The structures which rely on BlockSectionBase each redefine the BaseField1 and BaseField2 fields for their own specific purposes.

Section3
The Section3 structure is a standard BlockSectionBase, with the following redefinitions:


Door
The Door structure both extends and redefines the BlockSectionBase. These describe the doors which one may open and close within a scene, such as those found in buildings.






FlatBase
The FlatBase structure is an extension of the BlockSectionBase. The structure is as follows:





Flat
Flat structures redefine the FlatBase structure. Flat structures are just that: merely textures painted on planes which always face the viewer (often called "decals" or "billboards" in Direct3D or OpenGL).



Person
Person structures redefine the FlatBase structure. These are the people with whom the character may interact (receive quests, ask for directions, etc).



Model
The Model structure is a composite structure which reports the 3D object information for the block.



The ModelId structure is used to reference an ARCH3D.BSA record.


To compute the RecordId for the ARCH3D.BSA record to which this structure refers, multiply Id1 by 100 and add Id2:  .

BlockDataHeader
The BlockDataHeader structure reports the counts of Models, Flats, etc. found within the BlockData the header describes.



BlockData
A BlockData structure is a composite structure containing a BlockDataHeader, and the data described by that header.



The count for each of the list is provided by the BlockDataHeader structure.

Block
A Block structure is a composite structure which defines all external and internal elements for the block. It consists of two BlockData structures. Some records include an additional padding byte, which editors can safely ignore and omit. The BlockSize array



ModelList
Following the BlockList, there is a contiguous list of Model elements. These further decorate the scene described by the current block. Models can be placed arbitrarily within the scene via this list, rather than associating them with specific BlockData elements. There are RmbHeader.ObjectCount.ModelCount elements.

FlatList
Following the ModelList, there is a contiguous list of Flat elements. These further decorate the scene described by the current block. Flats can be placed arbitrarily within the scene via this list, rather than associating them with specific BlockData elements. There are RmbHeader.ObjectCount.FlatCount elements.