colysis/utils/MapFile.hexpat
2025-03-18 23:00:42 +01:00

80 lines
No EOL
1.1 KiB
Text

#pragma endian little
struct Version {
u8 major;
u8 minor;
u8 patch;
};
bitfield OptionFlags {
bool CustomeTilemap : 1;
};
struct vec2<T> {
T x,y;
}[[single_color]];
struct TilemapInfo {
vec2<u32> dimentions;
vec2<u32> tile_size;
vec2<u32> tile_count;
u32 wall_tiles;
u32 other_tiles;
u32 special_tiles;
};
struct Options {
OptionFlags flags;
if (flags.CustomeTilemap) {
u32 filepath_length;
char filepath[filepath_length];
TilemapInfo info;
}
};
struct SpecialData {
u32 data;
};
struct Tile {
u32 type;
if (type == 0) {
SpecialData special;
}
}[[single_color]];
struct Map
{
u32 width;
u32 height;
u32 specials;
Tile tiles[width * height];
};
struct Spawn {
u32 x,y;
}[[single_color]];
struct EnemySpawns {
u32 count;
Spawn spawns[count];
};
import std.io as io;
char magic[4] @$;
if (magic != "CYMF") {
io::warning("Magic does not match: \"" + magic + "\"; Expected: \"CYMF\"");
}
Version version @$ [[single_color]];
Options options @$;
Map map @$;
Spawn player @$ [[single_color]];
EnemySpawns enemies @$;