display-name: "Games/Heroes of Might & Magic 2"
meta: {"Working": ["Packed file extraction", "Some images", "Sounds"]}

if (file.name like "*.agg")
{
	unsigned16 file-count

	first-name: file.size - (15 * file-count)

	file-number: 0
	file [file-count]
	{
		data(4) unknown
		unsigned32 offset
		unsigned32 size

		at first-name + (file-number * 15)
		{
			fixed-string(15) name
		}
		file-number = file-number + 1

	}
}

if (file.name like ["*.bmp", "*.bkg"])
{
	data(2) unknown
	unsigned16 width
	unsigned16 height

	image
	{
		format: "I8"
		palette: "kb.pal"
	}
}

if (file.name like "*.pal")
{
	palette
	{
		size: 256
		format: "R6G6B6"
	}

	palette[0] = 0
	palette[1] = 0
	palette[2] = 0
			   
	palette[3] = 0x80
	palette[4] = 0
	palette[5] = 0
			   
	palette[6] = 0
	palette[7] = 0x80
	palette[8] = 0
			   
	palette[9] = 0x80
	palette[10] = 0x80
	palette[11] = 0

	palette[12] = 0
	palette[13] = 0
	palette[14] = 0x80

	palette[15] = 0x80
	palette[16] = 0
	palette[17] = 0x80
			    
	palette[18] = 0
	palette[19] = 0x80
	palette[20] = 0x80
			    
	palette[21] = 0xC0
	palette[22] = 0xC0
	palette[23] = 0xC0
			    
	palette[24] = 0xC0
	palette[25] = 0xDC
	palette[26] = 0xC0

	palette[27] = 0xA6
	palette[28] = 0xCA
	palette[29] = 0xF0

	palette[738] = 0xFF
	palette[739] = 0xFB
	palette[740] = 0xF0

	palette[741] = 0xA0
	palette[742] = 0xA0
	palette[743] = 0xA4

	palette[744] = 0x80
	palette[745] = 0x80
	palette[746] = 0x80

	palette[747] = 0xFF
	palette[748] = 0
	palette[749] = 0

	palette[750] = 0
	palette[751] = 0xFF
	palette[752] = 0

	palette[753] = 0xFF
	palette[754] = 0xFF
	palette[755] = 0

	palette[756] = 0
	palette[757] = 0
	palette[758] = 0xFF

	palette[759] = 0xFF
	palette[760] = 0
	palette[761] = 0xFF

	palette[762] = 0
	palette[763] = 0xFF
	palette[764] = 0xFF

	palette[765] = 0xFF
	palette[766] = 0xFF
	palette[767] = 0xFF
}

if (file.name like "*.82m")
{
	folder: "Sound"

	sound
	{
		channels: 1
		bits-per-sample: 8
		samples-per-second: 22050
		sound-signed: true
	}
}