function Carmack
{	
	loop while (file.remaining-bytes > 0)
	{
		read unsigned16 aWord

		if ((aWord & 0xFF00) == 0xA700)
		{
			//near copy
			length: aWord & 0xFF

			if (length == 0)
			{
				//not a copy
				read unsigned8 lowByte
				write unsigned16 ((aWord & 0xFF00) + lowByte)
			}
			else
			{
				read unsigned8 relativeOffset
				copy(from: 0-(relativeOffset*2), amount: length*2)		
			}
		}
		else if ((aWord & 0xFF00) == 0xA800)
		{
			//far copy
			length: aWord & 0xFF

			if (length == 0)
			{
				//not a copy

				read unsigned8 lowByte
				write unsigned16 ((aWord & 0xFF00) + lowByte)
			}
			else
			{
				read unsigned16 absoluteOffset
				copy(from: absoluteOffset * 2, amount: length*2)				
			}
		}
		else
		{
			write unsigned16 aWord
		}		
	}	
}