display-name: "Games/Major Stryker"
meta: {"Working": ["All images", "Audio"]}

if (file.name like "volume*.ms*")
{
	file
	{
		fixed-string(12) name
		unsigned32 offset
		unsigned32 size
	} while (size > 0)
}

if (file.name like "*.imf")
{
	folder: "Music"
	interpret-as "music-imf-560"
}

level-remapping: {
	["*.dr1"]: "volume1a.ms1",
	["*.dr2"]: "volume2a.ms2",
	["*.dr3"]: "volume3a.ms3"
}

if (file.name like "worldal*")
{
	folder: "Levels"

	fixed-string(12) mask-tiles
	fixed-string(12) solid-tiles
	fixed-string(12) backdrop

	fixed-string(12) unused-filename
	fixed-string(12) unused-filename-2

	fixed-string(12) music-file

	fixed-string(12) unused-filename-3
	unsigned16 flags

	unsigned16 width
	unsigned16 actor-count

	actor-start: file.position
	data(actor-count * 2) actors

	unsigned8[240] mask-attributes
	unsigned8[240] solid-attributes

	height: (file.remaining-bytes / 2) / width

	layer-start: file.position

	level
	{
		grid-x: 16
		grid-y: 16
		compressed[file.remaining-bytes] "GetBgTiles-ms"
		{
			level-layer
			{
				data-type: "unsigned8"
				order: 1
				layer-image: level-remapping[file.name] + "\\" + solid-tiles						
				ignore-tile: 0xFF
				layer-name: "Background"
			}
		}

		at layer-start:
		compressed[file.remaining-bytes] "GetFgTiles-ms"
		{
			level-layer
			{
				data-type: "unsigned8"
				order: 1
				layer-image: level-remapping[file.name] + "\\" + mask-tiles						
				ignore-tile: 0xFF
				layer-name: "Foreground"
			}
		}

		/*at actor-start:
		loop (actor-count / 3)
		{
			level-object
			{
				unsigned16 actor-type
				unsigned16 pos-x
				unsigned16 pos-y

				offset-x: pos-x * 16
				offset-y: pos-y * 16
				debug-string: "" + actor-type
			}
		}*/
	}
}

function GetFgTiles-ms
{
	loop while (file.remaining-bytes > 0)
	{
		read unsigned16 tile
		if (tile < 0xF0)
		{
			write unsigned8 tile			
		}
		else
		{
			write unsigned8 0xFF
		}
	}
}

function GetBgTiles-ms
{
	loop while (file.remaining-bytes > 0)
	{
		read unsigned16 tile
		if (tile >= 0xF0)
		{
			write unsigned8 ((tile - 0xF0) / 32)			
		}
		else
		{
			write unsigned8 0xFF
		}
	}
}

if (file.name like "*.voc")
{
	interpret-as "sound-VOC"
}

if (file.name like "*.snd")
{
	interpret-as "archive-SND_DOS"
}

bit-stride: 8

if (file.size == 30720)
{
	folder: "Background Tiles"

	image
	{
		format: "I4" //? EGA?
		width: 16
		height: 16
		tiles-across: 20
		data-size: file.size
	}
}


if (file.name like "*.ms*")
{
	text
}

if (file.size == 32000)
{
	folder: "Fullscreen Images"

	image
	{
		format: "I4"
		width: 320
		height: 200
		bit-stride: width * height
	}
}

if (file.size == 38400)
{
	folder: "Foreground Tiles"

	image
	{
		format: "A1I4" // ? EGA ? 
		width: 16
		height: 16
		tiles-across: 20
		data-size: file.size
	}
}

if (file.size == 4000)
{
	b800-text
}

if (file.name == "kiss.dr3")
{
	image
	{
		format: "I1"
		width: 16
		height: 16
		tiles-across: 20
		data-size: file.size
	}
}

if (file.size == 20480)
{
	image
	{
		format: "I4"
		width: 16
		height: 16
		tiles-across: 16
		data-size: file.size
	}
}

if (file.size == 4800)
{
	image
	{
		format: "A1I4"
		width: 8
		height: 8
		tiles-across: 40
		data-size: file.size
	}
}

if (file.size == 3528)
{
	image
	{
		format: "I1"
		//planes: 1
		width: 8
		height: 8
		tiles-across: 40
		data-size: 680
	}
	
	image
	{
		format: "I1"
		width: 16
		height: 16
		tiles-across: 20
		data-size: file.remaining-bytes
	}
}