	1 * 1	00 04 06 01 GOODS_STAT_LOW
		08 "ISRA"

		// Sprite layout
		1A 0A
			// 00 (x) - container/crate platforms
			43
			\dx000003F4 \wx0002 // ground sprite - track
			10 // register
			\dx8000042D \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000842D \wx0000 // containers/crates back
			00 00 00 // x/y/z offset
			10 04 11 // x/y/z extent
			\dx8000842E \wx0000 // containers/crates front
			00 0C 00 // x/y/z offset
			10 04 11 // x/y/z extent

			// 01 (y) - container/crate platforms
			43
			\dx000003F3 \wx0002 // ground sprite - track
			10 // register
			\dx8000042E \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000842F \wx0000 // containers/crates back
			00 00 00 // x/y/z offset
			04 10 11 // x/y/z extent
			\dx80008430 \wx0000 // containers/crates front
			0C 00 00 // x/y/z offset
			04 10 11 // x/y/z extent

			// 02 (x) - office
			43
			\dx000003F4 \wx0002 // ground sprite - track
			10 // register
			\dx8000042D \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000843D \wx0002 // office
			00 00 00 // x/y/z offset
			10 05 0E // x/y/z extent
			09 // register
			\dx8000044F \wx0003 // snow
			00 00 80 // x/y/z offset
			02 09 // registers

			// 03 (y) - office
			43
			\dx000003F3 \wx0002 // ground sprite - track
			10 // register
			\dx8000042E \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000843E \wx0002 // office
			00 00 00 // x/y/z offset
			05 10 0E // x/y/z extent
			09 // register
			\dx80000450 \wx0003 // snow
			00 00 80 // x/y/z offset
			02 09 // registers

			// 04 (x) - crawler crane or empty platform
			42
			\dx000003F4 \wx0002 // ground sprite - track
			10 // register
			\dx8000042D \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000842F \wx0003 // crawler crane
			00 0B 00 // x/y/z offset
			10 05 2B // x/y/z extent
			04 06 // registers

			// 05 (y) - crawler crane or empty platform
			42
			\dx000003F3 \wx0002 // ground sprite - track
			10 // register
			\dx8000042E \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx80008430 \wx0003 // crawler crane
			0B 00 00 // x/y/z offset
			05 10 2B // x/y/z extent
			04 06 // registers

			// 06 (x) - forklift platform
			43
			\dx000003F4 \wx0002 // ground sprite - track
			10 // register
			\dx8000042D \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000842D \wx0002 // forklift
			05 01 00 // x/y/z offset
			06 02 09 // x/y/z extent
			08 // register
			\dx80000433 \wx0003 // cargo (child) - crate
			0A 01 80 // x/y/z offset
			03 06 // registers

			// 07 (y) - forklift platform
			43
			\dx000003F3 \wx0002 // ground sprite - track
			10 // register
			\dx8000042E \wx0040 // ground overlay (child) - platforms
			00 00 80 // x/y/z offset
			04 // value for variable 10
			\dx8000842F \wx0002 // forklift
			01 05 00 // x/y/z offset
			02 06 09 // x/y/z extent
			08 // register
			\dx80000434 \wx0003 // cargo (child) - crate
			00 01 80 // x/y/z offset
			03 06 // registers

			// 08 (x) - purchase
			41
			\dx000003F4 \wx0000 // ground sprite - track
			\dx8000842D \wx0000
			00 00 00 // x/y/z offset
			10 10 20 // x/y/z extent

			// 09 (y) - purchase
			41
			\dx000003F3 \wx0000 // ground sprite - track
			\dx8000842E \wx0000
			00 00 00 // x/y/z offset
			10 10 20 // x/y/z extent


		0B 02 // use callback for sprite layout

		10 \w600 // set little/lots threshold
		12 \dxC0003824 // cargo types for randomisation triggers

		11 FF // pylon placement (all)


	// Purchase list
	1 * 1	01 04 02 02
	1 images/purchaseicons.pcx   19  734  01  58  64 -31 -27 // 042D x, crates
	1 images/purchaseicons.pcx   91  734  01  58  64 -31 -27 // 042E y, crates
	1 images/purchaseicons.pcx  163  734  01  58  64 -31 -27 // 042D x, containers
	1 images/purchaseicons.pcx  235  734  01  58  64 -31 -27 // 042E y, containers

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

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

	// Purchase list real sprites
	1 * 1	02 04 02 // ID
		85 00 // current date
		00 \wxFFFF
		01
		\wx0000 \w0 \w01/01/1960 // date is before 1960 - crates
		\wx0001 // containers


// Real sprites
// ------------
	// Cargo platform real sprites
	1 * 1	02 04 23 // ID
		85 FA
		00 FF FF
		01
		\wx00DA \w0 \w01/01/1960 // before 1960 - crate sprites
		\wx00DC // container sprites

	// Cargo platform real sprites - empty
	1 * 1	02 04 24 // ID
		85 FA
		00 FF FF
		01
		\wx00D9 \w0 \w01/01/1960 // before 1960 - crate sprites
		\wx00DB // container sprites

	// Test variable 10 for real sprites - cargo
	1 * 1	02 04 1B // ID
		81 10 // additional information for sprite selection
		00 0F
		01
		\wx00FD 04 04 // ground overlay sprites
		\wx0023

	// Test variable 10 for real sprites - cargo empty
	1 * 1	02 04 1C // ID
		81 10 // additional information for sprite selection
		00 0F
		01
		\wx00FD 04 04 // ground overlay sprites
		\wx0024

	// Test variable 10 for real sprites - office
	1 * 1	02 04 2C // ID
		81 10 // additional information for sprite selection
		00 0F
		01
		\wx00FD 04 04 // ground overlay sprites
		\wx00EE // office sprites

	// Test variable 10 for real sprites - crawler crane
	1 * 1	02 04 2D // ID
		81 10 // additional information for sprite selection
		00 0F
		01
		\wx00FD 04 04 // ground overlay sprites
		\wx00CF // crawler crane sprites

	// Test variable 10 for real sprites - forklift
	1 * 1	02 04 2E // ID
		81 10 // additional information for sprite selection
		00 0F
		01
		\wx00FD 04 04 // ground overlay sprites
		\wx00D1 // forklift sprites


// Forklift
	// Random cargo thresholds
	1 * 1	02 04 42 // ID
		80
		00 // no more cargo (triggered by random in graphics chain)
		12 // use bits 18 and 19
		04
		\wx8000
		\wx8019
		\wx8032
		\wx804B

	// Cargo show/hide
	1 * 1	02 04 43 // ID
		85 
		7D 20 // read register 20 for this cargo type
		20 \wxFFFF
		\2rst
		7B 60 // get amount of cargo waiting
		20 \wxFFFF
		\2+
		7E 42 // add random value
		00 \wx00FF
		01
		\wx8000 \w0 \w100 // hide cargo
		\wx8001 // show cargo

	// Random forklift variety
	1 * 1	02 04 44 // ID
		80
		00 // don't re-randomise
		10 // use bit 16
		02
		\wx8000
		\wx8001

	// Random forklift crate variety
	1 * 1	02 04 45 // ID
		80
		00 // no more cargo (triggered by random in graphics chain)
		11 // use bit 17
		02
		\wx8000
		\wx8002

// Offices
	// Office variety
	1 * 1	02 04 47 // ID
		80
		00 // don't re-randomise
		10 // use bit 16
		02
		\wx8000
		\wx8006

// Crawler crane
	// Random crane variety for modern cranes
	1 * 1	02 04 48 // ID
		80
		00 // don't re-randomise
		10 // use bit 16
		02
		\wx8000 // cc crane
		\wx8004 // red/white crane

	// Select age related crane variety
	1 * 1	02 04 49 // ID
		85 FA // date station was built
		00 \wxFFFF
		01
		\wx8008 \w0 \w01/01/1950 // before 1950 - steam crane
		\wx0048

	// Maybe show crane
	1 * 1	02 04 4A // ID
		80
		00 // don't re-randomise
		12 // use bits 18 and 19
		04
		\wx8000
		\wx8001
		\wx8000
		\wx8000

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

	// Container/crate platform
	1 * 1	02 04 21 // ID
		85
		7E BE // get normal/snow/desert offset
		20 \wx7FFF
		\2+
		7E BD // add monorail/maglev offset
		20 \wx00FF
		\2sto 1A
		00 \wx0010 // store in register
		01
		\wx001B \w0 \w0
		\wx001B

	// Container/crate platform - empty
	1 * 1	02 04 26 // ID
		85
		7E BE // get normal/snow/desert offset
		20 \wx7FFF
		\2+
		7E BD // add monorail/maglev offset
		20 \wx00FF
		\2sto 1A
		00 \wx0010 // store in register
		01
		\wx001C \w0 \w0
		\wx001C

	// Office
	1 * 1	02 04 22 // ID
		85 
		7E 47 // get random office variety offset
		20 \wx00FF
		\2sto 1A
		20 \wx0009 // store in register
		\2rst
		7E BB // get snow overlay flag
		20 \wx00FF
		\2sto 1A
		20 \wx0002 // store in register
		\2rst
		7E BE // get normal/snow/desert offset
		20 \wx7FFF
		\2+
		7E BD // add monorail/maglev offset
		20 \wx00FF
		\2sto 1A
		00 \wx0010 // store in register
		01
		\wx002C \w0 \w0
		\wx002C

	// Crawler crane or empty platform
	1 * 1	02 04 23 // ID
		85 
		7E 49 // get crane type offset
		20 FF 00
		\2sto 1A
		20 \wx0006 // store in register
		\2rst
		7E 4A // get random crane visibility flag
		20 FF 00
		\2sto 1A
		20 \wx0004 // store in register
		\2rst
		7E BE // get normal/snow/desert offset
		20 \wx7FFF
		\2+
		7E BD // add monorail/maglev offset
		20 \wx00FF
		\2sto 1A
		00 \wx0010 // store in register
		01
		\wx002D \w0 \w0
		\wx002D

	// Forklift
	1 * 1	02 04 24 // ID
		85 
		7E 44 // get random offset for forklift
		20 \wx00FF
		\2sto 1A
		20 \wx0008 // store in register
		\2rst
		7E 45 // get random offset for crate
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register
		\2rst
		7E 43 // get show/hide flag for crate
		20 \wx00FF
		\2sto 1A
		20 \wx0003 // store in register
		\2rst
		7E BE // get normal/snow/desert offset
		20 \wx7FFF
		\2+
		7E BD // add monorail/maglev offset
		20 \wx00FF
		\2sto 1A
		00 \wx0010 // store in register
		01
		\wx002E \w0 \w0
		\wx002E

	// Forklift - no suitable cargo
	1 * 1	02 04 25 // ID
		85 
		7E 44 // get random offset for forklift
		20 \wx00FF
		\2sto 1A
		20 \wx0008 // store in register
		\2rst 1A
		20 \w0 // always hide cargo
		\2sto 1A
		20 \wx0006 // store in register
		\2sto 1A
		20 \wx0003 // store in register
		\2rst
		7E BE // get normal/snow/desert offset
		20 \wx7FFF
		\2+
		7E BD // add monorail/maglev offset
		20 \wx00FF
		\2sto 1A
		00 \wx0010 // store in register
		01
		\wx002E \w0 \w0
		\wx002E

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

	1 * 1	02 04 20 // ID
		81 68 00 // station info - check this tile
		0A 0F
		03
		\wx0021 01 01 // part 00/01 - container/crate platforms
		\wx0022 05 05 // part 02/03 - office
		\wx0023 09 09 // part 04/05 - crawler crane (or empty platform)
		\wx0024 // part 06/07 - forklift

	// No suitable cargo
	1 * 1	02 04 1F // ID
		81 68 00 // station info - check this tile
		0A 0F
		03
		\wx0026 01 01 // part 00/01 - container/crate platforms - empty
		\wx0022 05 05 // part 02/03 - office
		\wx0023 09 09 // part 04/05 - crawler crane (or empty platform)
		\wx0025 // part 06/07 - forklift - no suitable cargo


// Callback 14
// -----------
	1 * 1	02 04 10 // ID
		81 68 00 // station info - check this tile
		0A 0F
		03
		\wx8000 01 01 // part 00/01 - container/crate platforms
		\wx8002 05 05 // part 02/03 - office
		\wx8004 09 09 // part 04/05 - crawler crane (or empty platform)
		\wx8006 // part 06/07 - forklift


// Callback 24
// -----------
	// Platform 0
	1 * 1	02 04 31 // ID
		81 10 // platform info and relative position
		00 07 // position along platform from N mod 8
		03
		\wx8002 01 01 // office
		\wx8004 02 02 // crawler crane (or empty platform)
		\wx8006 05 05 // forklift
		\wx8000 // container/crate platforms

	// Platform 1
	1 * 1	02 04 32 // ID
		81 10 // platform info and relative position
		00 07 // position along platform from N mod 8
		03
		\wx8004 00 00 // crawler crane (or empty platform)
		\wx8006 02 02 // forklift
		\wx8004 06 06 // crawler crane (or empty platform)
		\wx8000 // container/crate platforms

	// Platform 2
	1 * 1	02 04 33 // ID
		81 10 // platform info and relative position
		00 07 // position along platform from N mod 8
		04
		\wx8004 00 00 // crawler crane (or empty platform)
		\wx8002 02 02 // office
		\wx8004 03 03 // crawler crane (or empty platform)
		\wx8006 07 07 // forklift
		\wx8000 // container/crate platforms

	// Platform 3
	1 * 1	02 04 34 // ID
		81 10 // platform info and relative position
		00 07 // position along platform from N mod 8
		03
		\wx8006 03 03 // forklift
		\wx8002 05 05 // office
		\wx8004 06 06 // crawler crane (or empty platform)
		\wx8000 // container/crate platforms

	1 * 1	02 04 35 // ID
		81 10 // platform info and relative position
		08 03 // platform number from N mod 4
		03
		\wx0031 00 00
		\wx0032 01 01
		\wx0033 02 02
		\wx0034

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

// Store cargo id in register 0x20 and check for callback 0x14
#define CCB(a, b) 1 * 1	02 04 a 85 1A 20 b 00 \2sto 1A 20 \wx0020 \2rst 0C 00 \wxFFFF 01 \wx0010 \wx0014 \wx0014 \wx0020

	// (ID, cargo id)
	CCB(50, 02) // mail
	CCB(51, 05) // goods
	CCB(52, 0B) // paper
	CCB(53, 0C) // food
	CCB(54, 0D) // fruit
	CCB(55, 1E) // fish
	CCB(56, 1F) // wool
	CCB(57, 20) // glass
	CCB(58, 21) // ceramics
	CCB(59, 22) // bricks
	CCB(5A, 23) // vehicles
	CCB(5B, 2A) // building materials
	CCB(5C, 2B) // engineering supplies
	CCB(5D, 2D) // farm supplies
	CCB(5E, 30) // manufacturing supplies
	CCB(5F, 31) // recyclables
	CCB(60, 32) // scrap metal
	CCB(61, 37) // sugar
	CCB(62, 38) // coffee
	CCB(63, 3B) // vehicle parts

#undef CCB

	// Purchase
	1 * 1	02 04 08 // ID
		81 0C // callback
		00 FF
		02
		\wx8008 14 14 // sprite layout
		\wx0035 24 24 // station layout
		\wx0002 // real sprites

//@@WARNING DISABLE 113

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

	// Forklifts
	// Random action 2 outside callback triggers re-randomisation
	1 * 1	02 04 0C // ID
		80
		02 // no more cargo
		11 // trigger bits 17 to 19
		08
		\wx001F
		\wx001F
		\wx001F
		\wx001F
		\wx001F
		\wx001F
		\wx001F
		\wx001F

//@@WARNING ENABLE 113

	// Only re-randomise bits 17 to 19 for forklift
	1 * 1	02 04 0D // ID
		81 68 00 // station info - check this tile
		0A 0F
		03
		\wx000B 01 01 // part 00/01 - container/crate platforms
		\wx001F 05 05 // part 02/03 - office
		\wx001F 09 09 // part 04/05 - crawler crane (or empty platform)
		\wx000C // part 06/07 - forklift

	// No suitable cargo
	1 * 1	02 04 09 // ID
		81 0C // callback
		00 FF
		01
		\wx0010 14 14 // sprite layout
		\wx000D // real sprites

	1 * 1	03 04
		01 GOODS_STAT_LOW
		15
		02 \wx0050 // mail
		05 \wx0051 // goods
		0B \wx0052 // paper
		0C \wx0053 // food
		0D \wx0054 // fruit
		1E \wx0055 // fish
		1F \wx0056 // wool
		20 \wx0057 // glass
		21 \wx0058 // ceramics
		22 \wx0059 // bricks
		23 \wx005A // vehicles
		2A \wx005B // building materials
		2B \wx005C // engineering supplies
		2D \wx005D // farm supplies
		30 \wx005E // manufacturing supplies
		31 \wx005F // recyclables
		32 \wx0060 // scrap metal
		37 \wx0061 // sugar
		38 \wx0062 // coffee
		3B \wx0063 // vehicle parts
		FF \wx0008 // purchase
		\wx0009 // no suitable cargo
