/*
 * Lords of the Realm 2 — l2_maps.dat campaign map record
 *
 * Fixed 0x80c1-byte records indexed from file start.
 * See docs/structs/lotr2_maps_dat_record.md
 * Confidence: likely
 */
#ifndef LOTR2_MAPS_DAT_RECORD_H
#define LOTR2_MAPS_DAT_RECORD_H

#include <stdint.h>

#define LOTR2_MAPS_DAT_RECORD_SIZE   0x80c1u
#define LOTR2_MAPS_DAT_GRID_SIZE     0x40u   /* 64 */
#define LOTR2_MAPS_DAT_PLANE_SIZE    0x1000u /* 64 * 64 */
#define LOTR2_MAPS_DAT_VISIBLE_ROWS  0x81u
#define LOTR2_MAPS_DAT_VISIBLE_COLS  0x41u
#define LOTR2_MAPS_DAT_VISIBLE_SIZE  0x20c1u /* 0x81 * 0x41 */
#define LOTR2_MAPS_DAT_TILE_BASE     0xfff0000u

#define LOTR2_MAPS_DAT_OFF_FLAGS       0x0000u
#define LOTR2_MAPS_DAT_OFF_LAYER_A     0x1000u
#define LOTR2_MAPS_DAT_OFF_LAYER_B     0x2000u
#define LOTR2_MAPS_DAT_OFF_LAYER_C     0x3000u
#define LOTR2_MAPS_DAT_OFF_LAYER_INDEX 0x4000u
#define LOTR2_MAPS_DAT_OFF_PROVINCE_ID 0x5000u
#define LOTR2_MAPS_DAT_OFF_VISIBLE     0x6000u

#pragma pack(push, 1)

typedef struct lotr2_maps_dat_record {
    uint8_t flags_plane[LOTR2_MAPS_DAT_PLANE_SIZE];
    uint8_t layer_a_plane[LOTR2_MAPS_DAT_PLANE_SIZE];
    uint8_t layer_b_plane[LOTR2_MAPS_DAT_PLANE_SIZE];
    uint8_t layer_c_plane[LOTR2_MAPS_DAT_PLANE_SIZE];
    uint8_t layer_index_plane[LOTR2_MAPS_DAT_PLANE_SIZE];
    uint8_t province_id_plane[LOTR2_MAPS_DAT_PLANE_SIZE];
    uint8_t visible_tile_plane[LOTR2_MAPS_DAT_VISIBLE_SIZE];
} lotr2_maps_dat_record;

#pragma pack(pop)

#endif /* LOTR2_MAPS_DAT_RECORD_H */
