display-name: "Containers/IFF"

file-format iff
{
	//Hack for IFFs that start with full size i.e. Sink or Swim ILBMs
	unsigned8 size-test
	at 0:
	if (size-test == 0)
	{
		unsigned32 size-discard
	}

	file while (file.remaining-bytes > 0)
	{
		fixed-string(4) name
		unsigned32be size

		if (size > file.remaining-bytes)
		{
			size = file.remaining-bytes
		}

		offset: file.position

		if (name == "FORM")
		{
			fixed-string(4) form-name
			name = form-name
			offset = offset + 4
			size = size - 4
			interpret-as "iff"
		}

		data(size) file-data

		if ((size % 2) == 1)
		{
			unsigned8 padding-byte
		}
	}
}