	1 * 1	01 04 01 18
	1 images/vehicles.pcx   21  159  01   20  24  -16  -7  // 042D x, loader down empty
	1 images/vehicles.pcx   51  159  01   20  26  -18  -7  // 042E x, loader down full
	1 images/vehicles.pcx  180  159  01   17  26  -18  -7  // 042F x, loader mid empty
	1 images/vehicles.pcx   83  159  01   17  28  -20  -7  // 0430 x, loader mid full
	1 images/vehicles.pcx  150  159  01   17  25  -17  -7  // 0431 x, loader up empty
	1 images/vehicles.pcx  117  159  01   17  27  -19  -7  // 0432 x, loader up full

	1 images/vehicles.pcx   21  133  01   20  24   -8  -7  // 0433 y, loader down empty
	1 images/vehicles.pcx   51  133  01   20  26   -8  -7  // 0434 y, loader down full
	1 images/vehicles.pcx  180  133  01   17  26   -8  -7  // 0435 y, loader mid empty
	1 images/vehicles.pcx   83  133  01   17  28   -8  -7  // 0436 y, loader mid full
	1 images/vehicles.pcx  150  133  01   17  25   -8  -7  // 0437 y, loader up empty
	1 images/vehicles.pcx  117  133  01   17  27   -8  -7  // 0438 y, loader up full

	1 images/vehicles.pcx  254  159  01   11  17  -10  -5  // 0439 x, loader front mid empty
	1 images/vehicles.pcx  230  159  01   11  19  -12  -5  // 043A x, loader front mid full
	1 images/vehicles.pcx  254  133  01   11  17   -7  -5  // 043B y, loader front mid empty
	1 images/vehicles.pcx  230  133  01   11  19   -7  -5  // 043C y, loader front mid full

	1 images/vehicles.pcx  129  185  01    7  11   -5  -1  // 043D f, loader front mid empty
	1 images/vehicles.pcx  114  185  01    7  11   -5  -1  // 043E f, loader front mid full

	1 images/vehicles.pcx  211  159  01   14  14   -6  -7  // 043F x, loader rear
	1 images/vehicles.pcx  211  133  01   14  14   -8  -7  // 0440 y, loader rear
	1 images/vehicles.pcx   98  185  01   16   9   -6  -9  // 0441 f, loader rear X view
	1 images/vehicles.pcx   98  185  01   16   9   -2  -9  // 0442 f, loader rear Y view

	1 images/vehicles.pcx   58  185  09   19  34   -4  -2  // 0443 x, mineral pile
	1 images/vehicles.pcx   21  185  09   18  32  -27  -2  // 0444 y, mineral pile


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


	1 * 1	00 04 0C 01 LW_BUCKET_LOAD
		08 "ISRR"

		// Sprite layout
		1A 06
			// 00 (x) - move forward/scoop/back
			43
			\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 \wx0016 // bucket loader
			00 03 00 // x/y/z offset
			0A 04 0E // x/y/z extent
			05 12 08 09 // registers - sp offset, recolour, x, y
			\dx80008443 \wx0005 // mineral pile
			0C 00 00 // x/y/z offset
			04 0F 08 // x/y/z extent
			01 12 // registers - show, recolour

			// 01 (y) - move forward/scoop/back
			43
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0040 // ground overlay sprite (child)
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx80008433 \wx0016 // bucket loader
			03 00 00 // x/y/z offset
			04 0A 0E // x/y/z extent
			05 12 09 08 // registers - sp offset, recolour, x, y
			\dx80008444 \wx0005 // mineral pile
			00 0C 00 // x/y/z offset
			0F 04 08 // x/y/z extent
			01 12 // registers - show, recolour

			// 02 (x) - turn
			44
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0040 // ground overlay sprite (child)
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000043F \wx0012 // bucket loader rear
			01 03 00 // x/y/z offset
			06 04 0E // x/y/z extent
			06 03 04 // registers - sp offset, recolour, x, y
			\dx8000843B \wx0016 // bucket loader front
			04 04 00 // x/y/z offset
			04 06 0E // x/y/z extent
			05 12 08 09 // registers - sp offset, recolour, x, y
			\dx80008443 \wx0005 // mineral pile
			0C 00 00 // x/y/z offset
			04 0F 08 // x/y/z extent
			01 12 // registers - show, recolour

			// 03 (y) - turn
			44
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0040 // ground overlay sprite (child)
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx80000440 \wx0012 // bucket loader rear
			03 01 00 // x/y/z offset
			04 06 0E // x/y/z extent
			06 04 03 // registers - sp offset, recolour, x, y
			\dx80008439 \wx0016 // bucket loader front
			04 04 00 // x/y/z offset
			06 04 0E // x/y/z extent
			15 12 09 08 // registers - sp offset, recolour, x, y
			\dx80008444 \wx0005 // mineral pile
			00 0C 00 // x/y/z offset
			0F 04 08 // x/y/z extent
			01 12 // registers - show, recolour

			// 04 (x) - move forward/dump
			43
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0040 // ground overlay sprite (child)
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx80008433 \wx0016 // bucket loader
			07 05 00 // x/y/z offset
			04 0A 0E // x/y/z extent
			05 12 08 09 // registers - sp offset, recolour, x, y
			\dx80008443 \wx0005 // mineral pile
			0C 00 00 // x/y/z offset
			04 0F 08 // x/y/z extent
			01 12 // registers - show, recolour

			// 05 (y) - move forward/dump
			43
			\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 \wx0016 // bucket loader
			05 07 00 // x/y/z offset
			0A 04 0E // x/y/z extent
			05 12 09 08 // registers - sp offset, recolour, x, y
			\dx80008444 \wx0005 // mineral pile
			00 0C 00 // x/y/z offset
			0F 04 08 // x/y/z extent
			01 12 // registers - show, recolour


		0B 03 // use callback to determine date availability (1) and layout (2)

		// Only allow a 1 x 1 layout
		0C FE
		0D FE

		12 \dx03C04102 // cargo types for randomisation triggers

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

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

		16 \wx0123 // animation info 36 frames looping
		17 04      // animation speed 2^4 ticks per frame
		18 \wx0006 // animation triggers - cargo arrives (2), cargo removed (4)


	// 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 // bucket loader sprites

	// Check for availability
	1 * 1	02 04 0C // ID
		81 01
		00 FF
		01
		\wx8000 00 \b1970 // do not allow build before 1970
		\wx8001

// Animation
	// Sprite offset for bucket full
	1 * 1	02 04 70 // ID
		81 4A // animation frame 0 to 35
		00 FF
		01
		\wx8001 \b06 \b22
		\wx8000

	// Sprite offset - X
	1 * 1	02 04 71 // ID
		81 4A // animation frame 0 to 35
		00 FF
		05
		\wx8002 \b07 \b16
		\wx8002 \b18 \b19
		\wx8004 \b20 \b27
		\wx8002 \b28 \b29
		\wx8002 \b31 \b35
		\wx8000

	// Sprite offset - Y
	1 * 1	02 04 77 // ID
		81 4A // animation frame 0 to 35
		00 FF
		07
		\wx8002 \b07 \b13
		\wx8004 \b14 \b16
		\wx8002 \b18 \b19
		\wx8004 \b20 \b27
		\wx8002 \b28 \b29
		\wx8004 \b31 \b33
		\wx8002 \b34 \b35
		\wx8000

	// Sprite offset for rear (turning)
	1 * 1	02 04 74 // ID
		81 4A // animation frame 0 to 35
		00 FF
		02
		\wx8002 \b15 \b17
		\wx8002 \b30 \b32
		\wx8000


	// Offset for movement x
	1 * 1	02 04 72 // ID
		81 4A // animation frame 0 to 35
		00 FF
		\b13
		\wx8001 \b01 \b01
		\wx8002 \b02 \b02
		\wx8003 \b03 \b03
		\wx8004 \b04 \b08
		\wx8003 \b09 \b09
		\wx8002 \b10 \b10
		\wx8001 \b11 \b11
		\wx8001 \b15 \b15
		\wx8002 \b16 \b16
		\wx8003 \b17 \b17
		\wx8003 \b30 \b30
		\wx8002 \b31 \b31
		\wx8001 \b32 \b32
		\wx8000

	// Offset for movement y
	1 * 1	02 04 73 // ID
		81 4A // animation frame 0 to 35
		00 FF
		\b11
		\wx8001 \b15 \b15
		\wx8002 \b16 \b16
		\wx8004 \b17 \b17
		\wx8001 \b19 \b19
		\wx8002 \b20 \b20
		\wx8003 \b21 \b26
		\wx8002 \b27 \b27
		\wx8001 \b28 \b28
		\wx8004 \b30 \b30
		\wx8002 \b31 \b31
		\wx8001 \b32 \b32
		\wx8000

	// Offset for movement x for rear
	1 * 1	02 04 75 // ID
		81 4A // animation frame 0 to 35
		00 FF
		\b6
		\wx8001 \b15 \b15
		\wx8002 \b16 \b16
		\wx8003 \b17 \b17
		\wx8003 \b30 \b30
		\wx8002 \b31 \b31
		\wx8001 \b32 \b32
		\wx8000

	// Offset for movement y for rear
	1 * 1	02 04 76 // ID
		81 4A // animation frame 0 to 35
		00 FF
		\b4
		\wx8001 \b16 \b16
		\wx8002 \b17 \b17
		\wx8002 \b30 \b30
		\wx8001 \b31 \b31
		\wx8000



// Animation start/stop control
// ----------------------------
	// Animation control - maybe start animation
	1 * 1	02 04 56 // ID
		81 10 // extra callback info - random bits
		00 03
		01
		\wx80FE 00 02 // 75% chance of start
		\wx80FD // do nothing

	1 * 1	02 04 30 // ID
		85
		7D 20 // read register 20 for this cargo type
		20 \wxFFFF
		\2rst
		7B 60 // get amount of cargo waiting
		20 \wxFFFF
		\2+
		5F // add random value (use bits 24 and 25 - different for each tile)
		14 \wx0030 // shift and mask to give value between 0 and 0x30 (48)
		01
		\wx80FD \w0 \w178 // if not much cargo - do nothing
		\wx0056 // maybe start

	1 * 1	02 04 31 // ID
		85
		7D 20 // read register 20 for this cargo type
		20 \wxFFFF
		\2rst
		7B 60 // get amount of cargo waiting
		20 \wxFFFF
		\2+
		5F // add random value (use bits 24 and 25 - different for each tile)
		14 \wx0030 // shift and mask to give value between 0 and 0x30 (48)
		01
		\wx80FF \w0 \w64 // if not much cargo - stop
		\wx80FD // do nothing

	// Animation start/stop control
	1 * 1	02 04 60 // ID
		81 18 // extra callback info - reason for call
		00 FF
		02
		\wx0030 01 01 // cargo arrives - maybe start
		\wx0031 02 02 // cargo removed - maybe stop
		\wx80FD // do nothing

// ----------------------------

	// Return recolour sprite offset for cargo id in register 20
	1 * 1	02 04 79 // ID
		81
		7D 20 // read register 20 for this cargo type
		00 FF
		08
		\wx8006 01 01 // coal
		\wx8007 0E 0E // copper ore
		\wx8008 16 16 // clay
		\wx8009 17 17 // gravel
		\wx800A 18 18 // limestone
		\wx800B 19 19 // sand
		\wx800C 28 28 // bauxite
		\wx800D 3A 3A // nitrates
		\wx8000

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

	// Set registers
	1 * 1	02 04 78 // ID
		85
		// mineral piles
		1A // all bits on
		20 \wx0001 // val = 1
		\2sto 1A
		20 \wx0001 // store in register - show/hide mineral pile flag
		\2rst
		// loader
		7E 70 // get offset for bucket full
		20 \wx7FFF
		\2+
		7E 71 // add offset for sprite - X
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register - sprite offset
		\2rst
		7E 70 // get offset for bucket full
		20 \wx7FFF
		\2+
		7E 77 // add offset for sprite - Y
		20 \wx7FFF
		\2sto 1A
		20 \wx0015 // store in register - sprite offset
		\2rst
		7E 72 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0008 // store in register - x offset
		\2rst
		7E 73 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0009 // store in register - y offset
		\2rst
		// loader rear
		7E 74 // get rear sprite offset
		20 \wx7FFF
		\2sto 1A
		20 \wx0006 // store in register - sprite offset
		\2rst
		7E 75 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0003 // store in register - x offset
		\2rst
		7E 76 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0004 // store in register - y offset
		\2rst
		// ground
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx8000 \w0 \w0
		\wx8000

	1 * 1	02 04 20 // ID
		85
		7F 10 // read parameter for recolour sprite base
		20 \wx7FFF
		\2+
		7E 79 // add offset of recolour sprite for this cargo
		20 \wx7FFF
		\2sto 1A
		20 \wx0012 // store in register - recolour sprite
		\2rst
		7E 78 // set registers
		00 \w0
		01
		\wx001B \w0 \w0
		\wx001B

	1 * 1	02 04 21 // ID
		85
		1A // all bits on
		20 \wx0000 // no recolour for iron ore
		\2sto 1A
		20 \wx0012 // store in register - recolour sprite
		\2rst
		7E 78 // set registers
		00 \w0
		01
		\wx001B \w0 \w0
		\wx001B

	// Purchase
	1 * 1	02 04 2E // ID
		85
		// Mineral pile
		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 sprite
		\2rst
		1A // all bits on
		20 \wx0001 // val = 1
		\2sto 1A
		20 \wx0001 // store in register - show/hide mineral pile flag
		\2rst
		// Loader
		1A // all bits on
		20 \wx0001 // val = 1
		\2sto 1A
		20 \wx0005 // store in register - sprite offset - X
		\2sto 1A
		20 \wx0015 // store in register - sprite offset - Y
		\2rst
		// Position offsets
		1A // all bits on
		20 \wx0000 // val = 0
		\2sto 1A
		20 \wx0008 // store in register - x offset
		\2sto 1A
		20 \wx0009 // store in register - y offset
		\2sto 1A
		20 \wx0006 // store in register - sprite offset - rear
		\2sto 1A
		20 \wx0003 // store in register - x offset - rear
		\2sto 1A
		20 \wx0004 // store in register - y offset - rear
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

	// No suitable cargo
	1 * 1	02 04 2F // ID
		85
		// Mineral pile
		1A // all bits on
		20 \wx0000 // val = 0
		\2sto 1A
		20 \wx0012 // store in register - recolour sprite
		\2rst
		1A // all bits on
		20 \wx0000 // val = 0
		\2sto 1A
		20 \wx0001 // store in register - show/hide mineral pile flag
		\2rst
		// loader
		7E 71 // get sprite offset - X
		20 \wx7FFF
		\2sto 1A
		20 \wx0005 // store in register
		\2rst
		7E 77 // get sprite offset - Y
		20 \wx7FFF
		\2sto 1A
		20 \wx0015 // store in register
		\2rst
		7E 72 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0008 // store in register - x offset
		\2rst
		7E 73 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0009 // store in register - y offset
		\2rst
		// loader rear
		7E 74 // get sprite offset - X/Y
		20 \wx7FFF
		\2sto 1A
		20 \wx0006 // store in register
		\2rst
		7E 75 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0003 // store in register - x offset
		\2rst
		7E 76 // get offset for movement
		20 \wx7FFF
		\2sto 1A
		20 \wx0004 // store in register - y offset
		\2rst
		// ground
		7E BF // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx001B \w0 \w0
		\wx001B

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


	1 * 1	02 04 40 // ID
		85
		7D 20 // read register 20 for this cargo type
		20 \wxFFFF
		\2rst
		7B 60 // get amount of cargo waiting
		20 \wxFFFF
		\2+
		5F // add random value (use bits 26 and 27 - different for each tile)
		16 \wx0030 // shift and mask to give value between 0 and 0x30 (48)
		01
		\wx002F \w0 \w120 // if not much cargo - empty
		\wx0020

	// Iron ore is handled separately as it isn't recoloured
	1 * 1	02 04 41 // ID
		85 60 08 // cargo waiting - iron ore
		20 \wxFFFF
		\2+
		5F // add random value (use bits 26 and 27 - different for each tile)
		16 \wx0030 // shift and mask to give value between 0 and 0x30 (48)
		01
		\wx002F \w0 \w120 // if not much cargo - empty
		\wx0021


	// Callback 14
	1 * 1	02 04 28 // ID
		85 4A // animation frame 0 to 35
		00 \wx00FF
		03
		\wx8002 \w14 \w17
		\wx8004 \w18 \w29
		\wx8002 \w30 \w33
		\wx8000

	1 * 1	02 04 10 // ID
		85 1A // all bits on
		20 \wx0001 // cargo id for coal
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

	1 * 1	02 04 11 // ID
		85 1A // all bits on
		20 \wx0008 // cargo id for iron ore
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0041 // real sprites - iron ore

	1 * 1	02 04 12 // ID
		85 1A // all bits on
		20 \wx000E // cargo id for copper ore
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

	1 * 1	02 04 13 // ID
		85 1A // all bits on
		20 \wx0016 // cargo id for clay
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

	1 * 1	02 04 14 // ID
		85 1A // all bits on
		20 \wx0017 // cargo id for gravel
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

	1 * 1	02 04 15 // ID
		85 1A // all bits on
		20 \wx0018 // cargo id for limestone
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

	1 * 1	02 04 16 // ID
		85 1A // all bits on
		20 \wx0019 // cargo id for sand
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

	1 * 1	02 04 17 // ID
		85 1A // all bits on
		20 \wx0028 // cargo id for bauxite
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

	1 * 1	02 04 18 // ID
		85 1A // all bits on
		20 \wx003A // cargo id for nitrates
		\2sto 1A
		20 \wx0020 // store in register
		\2rst
		0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx0060 \wx0140 \wx0140 // animation control
		\wx0040 // real sprites

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

//@@WARNING DISABLE 113

	// Dummy random action 2 triggers re-randomisation
	1 * 1	02 04 26 // 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

	// Empty
	1 * 1	02 04 1F // ID
		85 0C // callback
		00 \wxFFFF
		02
		\wx0028 \wx0014 \wx0014 // sprite layout
		\wx80FF \wx0140 \wx0140 // animation control - stop
		\wx0026 // real sprites - empty

	1 * 1	03 04
		01 LW_BUCKET_LOAD
		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
