	1 * 1	00 04 08 01 MINERAL_PILE
		08 "ISRR"

		// Sprite layout
		1A 02
			// 00 (x)
			42
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0040 // ground overlay sprite (child)
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000842D \wx0006 // mineral pile
			00 00 00 // x/y/z offset
			10 10 10 // x/y/z extent
			05 12 // registers

			// 01 (y)
			42
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0040 // ground overlay sprite (child)
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000842D \wx0006 // mineral pile
			00 00 00 // x/y/z offset
			10 10 10 // x/y/z extent
			05 12 // registers

		0B 02 // use callback to determine layout

		10 \w600 // little/lots threshold

		// Wire and pylon placement
		11 00 // no pylons
		14 FF // no wires

		15 FF // prevent trains entering the tile from any direction

		12 \dx03C04102 // cargo types for randomisation triggers


	1 * 1	01 04 04 04
	// Empty
	1 images/newmines7.pcx      7 347 09  1  1   0   0 // 042D
	1 images/newmines7.pcx      7 347 09  1  1   0   0 // 042E
	1 images/newmines7.pcx      7 347 09  1  1   0   0 // 042F
	1 images/newmines7.pcx      7 347 09  1  1   0   0 // 0430
	// Level 1
	1 images/newmines7.pcx      7 347 09 14 48 -26   7 // 042D type 1
	1 images/newmines7.pcx     65 347 09 15 42 -16   4 // 042E type 2
	1 images/newmines7.pcx    121 347 09 25 18 -10   1 // 042F type 3
	1 images/newmines7.pcx    168 347 09 14 48 -25  10 // 0430 type 4
	// Level 2
	1 images/newmines7.pcx      7 374 09 19 49 -26   3 // 042D type 1
	1 images/newmines7.pcx     65 374 09 24 45 -19  -2 // 042E type 3
	1 images/newmines7.pcx    121 374 09 31 35 -14  -4 // 042F type 3
	1 images/newmines7.pcx    168 374 09 22 48 -25   2 // 0430 type 4
	// Level 3
	1 images/newmines7.pcx      7 410 09 22 55 -26   3 // 042D type 1
	1 images/newmines7.pcx     65 410 09 31 53 -27  -3 // 042E type 2
	1 images/newmines7.pcx    121 410 09 31 45 -18  -4 // 042F type 3
	1 images/newmines7.pcx    168 410 09 27 50 -26  -3 // 0430 type 4

	1 * 1	02 04 10 // ID
		0E 01
		\w0 \w1 \w1 \w1 \w1 \w1 \w2 \w2 \w2 \w2 \w2 \w3 \w3 \w3
		\w3

	1 * 1	02 04 11 // ID
		0E 01
		\w0 \w0 \w1 \w1 \w1 \w1 \w1 \w2 \w2 \w2 \w2 \w2 \w3 \w3
		\w3

	1 * 1	02 04 12 // ID
		0E 01
		\w0 \w0 \w0 \w1 \w1 \w1 \w1 \w1 \w2 \w2 \w2 \w2 \w2 \w3
		\w3

	1 * 1	02 04 13 // ID
		0E 01
		\w0 \w0 \w0 \w0 \w1 \w1 \w1 \w1 \w1 \w2 \w2 \w2 \w2 \w2
		\w3

	1 * 1	02 04 00 // ID
		80
		00 // no more cargo (triggered by random in graphics chain)
		12 // use bits 18 and 19
		04
		\wx0010
		\wx0011
		\wx0012
		\wx0013

	// Empty
	1 * 1	02 04 01 // ID
		00 01
		\w0


	// Test variable 10 for real sprites
	1 * 1	02 04 1B // ID
		81 10 // additional information for sprite selection
		00 0F
		01
		\wx00FF 04 04 // ground overlay sprites
		\wx0000 // mineral pile sprites

	// Test variable 10 for real sprites - empty
	1 * 1	02 04 1C // ID
		81 10 // additional information for sprite selection
		00 0F
		01
		\wx00FF 04 04 // ground overlay sprites
		\wx0001 // mineral pile sprites

	// Random offset for mineral pile variety
	1 * 1	02 04 04 // ID
		80
		00 // no more cargo (triggered by random in graphics chain)
		10 // use bits 16 and 17
		04
		\wx8000
		\wx8001
		\wx8002
		\wx8003


//@@WARNING DISABLE 100
//@@WARNING DISABLE 170

	1 * 1	02 04 20 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w6 // add offset of recolour sprite for coal
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 21 // ID
		85
		1A // all bits on
		20 \wx0000 // no recolour needed for iron ore
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 22 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w7 // add offset of recolour sprite for copper ore
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 23 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w8 // add offset of recolour sprite for clay
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 24 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w9 // add offset of recolour sprite for gravel
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 25 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w10 // add offset of recolour sprite for limestone
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 26 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w11 // add offset of recolour sprite for sand
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 27 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w12 // add offset of recolour sprite for bauxite
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 28 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w13 // add offset of recolour sprite for nitrates
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		7E 04 // get variety offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	// Purchase
	1 * 1	02 04 2E // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		1A // all bits on
		20 \w6 // add offset of recolour sprite for coal
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		1A // all bits on
		20 \wx0000 // val = 0
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		1A // all bits on
		20 \wx0000 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	// Empty
	1 * 1	02 04 2F // ID
		85
		1A // all bits on
		20 \wx0000 // val = 0
		\2sto 1A
		20 \wx0012 // store in register - recolour offset
		\2rst
		1A // all bits on
		20 \wx0000 // val = 0
		\2sto 1A
		20 \wx0005 // store in register - mineral pile sprite offset
		\2rst
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001C \w0 \w0
		\wx001C

//@@WARNING ENABLE 170
//@@WARNING ENABLE 100

	1 * 1	02 04 10 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0020 // real sprites - coal

	1 * 1	02 04 11 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0021 // real sprites - iron ore

	1 * 1	02 04 12 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0022 // real sprites - copper ore

	1 * 1	02 04 13 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0023 // real sprites - clay

	1 * 1	02 04 14 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0024 // real sprites - gravel

	1 * 1	02 04 15 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0025 // real sprites - limestone

	1 * 1	02 04 16 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0026 // real sprites - sand

	1 * 1	02 04 17 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0027 // real sprites - bauxite

	1 * 1	02 04 18 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0028 // real sprites - nitrates

	// Purchase
	1 * 1	02 04 1E // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx002E // real sprites - show coal

//@@WARNING DISABLE 113

	// Random action 2 outside callback triggers re-randomisation
	1 * 1	02 04 07 // ID
		80
		02 // no more cargo
		10 // trigger bits 16 to 19
		10
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F
		\wx002F

//@@WARNING ENABLE 113

	// No suitable cargo
	1 * 1	02 04 1F // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0007 // real sprites - empty

	1 * 1	03 04
		01 MINERAL_PILE
		0A
		01 \wx0010 // coal
		08 \wx0011 // iron ore
		0E \wx0012 // copper ore
		16 \wx0013 // clay
		17 \wx0014 // gravel
		18 \wx0015 // limestone
		19 \wx0016 // sand
		28 \wx0017 // bauxite
		3A \wx0018 // nitrates
		FF \wx001E // purchase
		\wx001F // no suitable cargo

