	// Procedure to get offset for desert/snow non-track ground sprites
	1 * 1	02 04 7F // ID
		81
		42 // terrain and track type
		00 FF
		02
		\wx8239 01 01 // if desert: 11C6 - 0F8D = 239
		\wx8239 04 04 // if snowy
		\wx8000 // else


// == Marshalling yard basic ========================================

	1 * 1	00 04 04 01 SY_BASIC
		08 "ISRS"

		// Sprite layout
		1A 02
			// 00 (x)
			41
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register

			// 01 (y)
			41
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042E \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register

		0B 02 // use callback to determine layout
		11 FF // pylon placement (all)

	1 * 1	01 04 01 0A
	1 images/newswitchyard4.pcx   5   7 09 31 64 -31  0 // 042D x, no side rail
	1 images/newswitchyard4.pcx 291   7 09 31 64 -31  0 // 042E y, no side rail
	1 images/newswitchyard4.pcx  74   7 09 31 64 -31  0 // 042F x, S side rail
	1 images/newswitchyard4.pcx 364   7 09 31 64 -31  0 // 0430 y, S side rail
	1 images/newswitchyard4.pcx 145   7 09 31 64 -31  0 // 0431 x, N and S side rails
	1 images/newswitchyard4.pcx 434   7 09 31 64 -31  0 // 0432 y, N and S side rails
	1 images/newswitchyard4.pcx 215   7 09 31 64 -31  0 // 0433 x, N side rail
	1 images/newswitchyard4.pcx 505   7 09 31 64 -31  0 // 0434 y, N side rail
	1 images/newswitchyard4.pcx 576 129 09 16 16  -9 -7 // 0435 x, tower
	1 images/newswitchyard4.pcx 598 129 09 16 16  -5 -7 // 0436 y, tower

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

	// For tiles needing side rail to S: check if next platform N can have side rail
	1 * 1	02 04 30 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8004 SY_BASIC 05 SY_MID_BUFFER_S 05 // side rail to N and S
		\wx8002 // side rail to S only

	// For tiles not needing side rail to S: check if next platform N can have side rail
	1 * 1	02 04 31 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and dir.
		01
		\wx8006 SY_BASIC 05 SY_MID_BUFFER_S 05 // side rail to N only
		\wx8000 // no side rails

	// For all tiles: check if next platform S can have side rail
	1 * 1	02 04 32 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0030 SY_BASIC 05 SY_MID_BUFFER_S 05 // side rail to S
		\wx0031 // no side rail to S

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

	1 * 1	02 04 15 // ID
		85
		7E 32 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0040 \w0 \w0
		\wx0040

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w4 // val = 4
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0040 \w0 \w0
		\wx0040

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_BASIC
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard catwalk ======================================

	1 * 1	00 04 04 01 SY_CATWALK
		08 "ISRS"
		0A SY_BASIC // copy sprite layout
		0B 02 // use callback to determine layout
		11 FF // pylon placement (all)

	1 * 1	01 04 01 08
	1 images/newswitchyard4.pcx   6 47 09 31 64 -31 0 // 042D x, no side rail
	1 images/newswitchyard4.pcx 291 47 09 31 64 -31 0 // 042E y, no side rail
	1 images/newswitchyard4.pcx  75 47 09 31 64 -31 0 // 042F x, S side rail
	1 images/newswitchyard4.pcx 364 47 09 31 64 -31 0 // 0430 y, S side rail
	1 images/newswitchyard4.pcx 146 47 09 31 64 -31 0 // 0431 x, N and S side rails
	1 images/newswitchyard4.pcx 434 47 09 31 64 -31 0 // 0432 y, N and S side rails
	1 images/newswitchyard4.pcx 216 47 09 31 64 -31 0 // 0433 x, N side rail
	1 images/newswitchyard4.pcx 504 47 09 31 64 -31 0 // 0434 y, N side rail

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

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

	1 * 1	02 04 15 // ID
		85
		7E 32 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w4 // val = 4
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_CATWALK
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard crossing =====================================

	1 * 1	00 04 04 01 SY_CROSSING
		08 "ISRS"
		0A SY_BASIC // copy sprite layout
		0B 02 // use callback to determine layout
		11 FF // pylon placement (all)

	1 * 1	01 04 01 08
	1 images/newswitchyard4.pcx   6 89 09 31 64 -31 0 // 042D x, no side rail
	1 images/newswitchyard4.pcx 291 89 09 31 64 -31 0 // 042E y, no side rail
	1 images/newswitchyard4.pcx  75 89 09 31 64 -31 0 // 042F x, S side rail
	1 images/newswitchyard4.pcx 364 89 09 31 64 -31 0 // 0430 y, S side rail
	1 images/newswitchyard4.pcx 146 89 09 31 64 -31 0 // 0431 x, N and S side rails
	1 images/newswitchyard4.pcx 434 89 09 31 64 -31 0 // 0432 y, N and S side rails
	1 images/newswitchyard4.pcx 216 89 09 31 64 -31 0 // 0433 x, N side rail
	1 images/newswitchyard4.pcx 504 89 09 31 64 -31 0 // 0434 y, N side rail

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

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

	1 * 1	02 04 15 // ID
		85
		7E 32 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w4 // val = 4
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_CROSSING
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard tower ========================================

	1 * 1	00 04 04 01 SY_TOWER
		08 "ISRS"

		// Sprite layout
		1A 02
			// 00 (x)
			42
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register
			\dx80000435 \wx0000 // tower
			05 02 00 // x/y/z offset
			06 03 08 // x/y/z extent

			// 01 (y)
			42
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042E \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register
			\dx80000436 \wx0000 // tower
			02 05 00 // x/y/z offset
			03 06 08 // x/y/z extent

		0B 02 // use callback to determine layout
		11 FF // pylon placement (all)

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

	1 * 1	02 04 15 // ID
		85
		7E 32 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0040 \w0 \w0
		\wx0040

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w4 // val = 4
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0040 \w0 \w0
		\wx0040

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_TOWER
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard shelter ======================================

	1 * 1	00 04 07 01 SY_SHELTER
		08 "ISRS"

		// Sprite layout
		1A 04
			// 00 (x - far)
			43
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register
			\dx80000435 \wx0000 // roof - back part
			00 03 0D // x/y/z offset
			10 0D 0D // x/y/z extent
			\dx80000439 \wx0001 // snow
			00 00 80 // x/y/z offset
			03 // register

			// 01 (y - far)
			43
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042E \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register
			\dx80000436 \wx0000 // roof - back part
			03 00 0D // x/y/z offset
			0D 10 0D // x/y/z extent
			\dx8000043A \wx0001 // snow
			00 00 80 // x/y/z offset
			03 // register

			// 02 (x - near)
			43
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx80000431 \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register
			\dx80008437 \wx0000 // shelter - front part
			00 00 00 // x/y/z offset
			10 03 1A // x/y/z extent
			\dx8000043B \wx0001 // snow
			00 00 80 // x/y/z offset
			03 // register

			// 03 (y - near)
			43
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx80000432 \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register
			\dx80008438 \wx0000 // shelter - front part
			00 00 00 // x/y/z offset
			03 10 1A // x/y/z extent
			\dx8000043C \wx0001 // snow
			00 00 80 // x/y/z offset
			03 // register

		0B 02 // use callback to determine layout
		0C FD // only allow width of 2
		0D FE // only allow platform length of 1
		0E 01 02 00 02 00 00 // station layout
		11 CC // pylon placement (11001100)

	1 * 1	01 04 01 10
	1 images/newswitchyard4.pcx   6 169 09 31 64 -31   0 // 042D x, back tile
	1 images/newswitchyard4.pcx   6 217 09 31 64 -31   0 // 042E y, back tile
	1 images/newswitchyard4.pcx  76 169 09 31 64 -31   0 // 042F x, back tile with N side rail
	1 images/newswitchyard4.pcx  77 217 09 31 64 -31   0 // 0430 y, back tile with N side rail
	1 images/newswitchyard4.pcx 178 169 09 31 64 -31   0 // 0431 x, front tile
	1 images/newswitchyard4.pcx 180 217 09 31 64 -31   0 // 0432 y, front tile
	1 images/newswitchyard4.pcx 249 169 09 31 64 -31   0 // 0433 x, front tile with S side rail
	1 images/newswitchyard4.pcx 251 217 09 31 64 -31   0 // 0434 y, front tile with S side rail
	1 images/newswitchyard4.pcx 145 169 09 27 26 -27   6 // 0435 x, back roof
	1 images/newswitchyard4.pcx 147 217 09 27 26   3   6 // 0436 y, back roof
	1 images/newswitchyard4.pcx 318 169 09 41 34 -27 -23 // 0437 x, front roof and side
	1 images/newswitchyard4.pcx 319 217 09 41 34  -5 -23 // 0438 y, front roof and side
	1 images/newswitchyard4.pcx 360 169 01 24 26   0   0 // 0439 x, back roof - snow
	1 images/newswitchyard4.pcx 360 217 01 24 26   0   0 // 043A y, back roof - snow
	1 images/newswitchyard4.pcx 394 169 01 29 34   0   0 // 043B x, front roof and side - snow
	1 images/newswitchyard4.pcx 394 217 01 29 34   0   0 // 043C y, front roof and side - snow

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

	// For north part: check if next platform N can have side rail
	1 * 1	02 04 12 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8002 SY_BASIC 05 SY_MID_BUFFER_S 05 // side rail to N
		\wx8000 // no side rail

	// For south part: check if next platform S can have side rail
	1 * 1	02 04 13 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8002 SY_BASIC 05 SY_MID_BUFFER_S 05 // side rail to S
		\wx8000 // no side rail

	// Test for shelter part at current position
	1 * 1	02 04 14 // ID
		85 68 00 // check tile at current position
		00 \wx1000 // mask for bit 12
		01
		\wx0012 \wx0000 \wx0000 // north part
		\wx0013 // south part

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

	1 * 1	02 04 15 // ID
		85
		7E 14 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E BB // get snow overlay flag
		20 \wx00FF
		\2sto 1A
		20 \wx0003 // store in register - show/hide snow
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2sto 1A
		20 \wx0003 // store in register - show/hide snow
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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


// Callback 14
	1 * 1	02 04 10 // ID
		85 68 00 // check tile at current position
		00 \wx1000 // mask for bit 12
		01
		\wx8000 \w0 \w0 // north part
		\wx8002 // south part

	1 * 1	02 04 20 // ID
		81 0C // callback
		00 FF 01
		\wx0010 14 14 // sprite layout
		\wx0015 // real sprites

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF 01
		\wx8002 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	 03 04
		01 SY_SHELTER
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard track switcher (N) ===========================

	1 * 1	00 04 07 01 SY_SWITCH_N
		08 "ISRS"
		0A SY_BASIC // copy sprite layout
		0B 02 // use callback to determine layout
		0C FD // only allow width of 2
		0D FE // only allow platform length of 1
		0E 01 02 00 02 00 00 // station layout
		11 FF // pylon placement (all)

	1 * 1	01 04 01 08
	1 images/newswitchyard4.pcx   6 266 09 31 64 -31 0 // 042D x, back tile
	1 images/newswitchyard4.pcx   7 309 09 31 64 -31 0 // 042E y, back tile
	1 images/newswitchyard4.pcx 293 266 09 31 64 -31 0 // 042F x, front tile
	1 images/newswitchyard4.pcx 293 309 09 31 64 -31 0 // 0430 y, front tile
	1 images/newswitchyard4.pcx  77 266 09 31 64 -31 0 // 0431 x, back tile with N side rail
	1 images/newswitchyard4.pcx  79 309 09 31 64 -31 0 // 0432 y, back tile with N side rail
	1 images/newswitchyard4.pcx 366 266 09 31 64 -31 0 // 0433 x, front tile with S side rail
	1 images/newswitchyard4.pcx 363 309 09 31 64 -31 0 // 0434 y, front tile with S side rail

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

// For north part of switch
	// If a pair of switches have another immediately 'upstream' no side rail is shown
	// Test upstream for another switch
	1 * 1	02 04 20 // ID
		85 68 01 // station info param 0/+1; check tile along platform to S
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		03
		\wx8000 SY_SWITCH_N 15 SY_SWITCH_N 15 // if S part of switch - N part no side rail
		\wx8000 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // if mid-buffer - N part no side rail
		\wx8000 SY_MID_BUFFER_N 15 SY_MID_BUFFER_N 15 // if mid-buffer - N part no side rail
		\wx8004 // else - N part with side rail

	// Check for another switch to N
	1 * 1	02 04 21 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		01
		\wx0020 SY_SWITCH_N 15 SY_SWITCH_N 15 // if S part of switch
		\wx8004 // else - N part with side rail

	// Check tile to N
	1 * 1	02 04 11 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0021 SY_BASIC 05 SY_MID_BUFFER_S 05 // if tile can have side rail
		\wx8000 // else - N part no side rail

// For south part of switch
	// If a pair of switches have another immediately 'upstream' no side rail is shown
	// Test upstream for another switch
	1 * 1	02 04 22 // ID
		85 68 01 // station info param 0/+1; check tile along platform to S
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		03
		\wx8002 SY_SWITCH_N 05 SY_SWITCH_N 05 // if N part of switch - S part no side rail
		\wx8002 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // if mid-buffer - S part no side rail
		\wx8002 SY_MID_BUFFER_N 15 SY_MID_BUFFER_N 15 // if mid-buffer - S part no side rail
		\wx8006 // else - S part with side rail

	// Check for another switch to S
	1 * 1	02 04 23 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		01
		\wx0022 SY_SWITCH_N 05 SY_SWITCH_N 05 // if N part of switch
		\wx8006 // else - S part with side rail

	// Check tile to S
	1 * 1	02 04 12 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0023 SY_BASIC 05 SY_MID_BUFFER_S 05 // if tile can have side rail
		\wx8002 // else - S part no side rail
//----------------------------------

	// Test for switch part at current position
	1 * 1	02 04 13 // ID
		85 68 00 // station info param 0/0; check this tile
		00 \wx1000 // mask for bit 12
		01
		\wx0011 \wx0000 \wx0000 // north part
		\wx0012 // south part

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

	1 * 1	02 04 15 // ID
		85
		7E 13 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w6 // val = 6
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_SWITCH_N
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard track switcher (S) ===========================

	1 * 1	00 04 07 01 SY_SWITCH_S
		08 "ISRS"
		0A SY_BASIC // copy sprite layout
		0B 02 // use callback to determine layout
		0C FD // only allow width of 2
		0D FE // only allow platform length of 1
		0E 01 02 00 02 00 00 // station layout
		11 FF // pylon placement (all)

	1 * 1	01 04 01 08
	1 images/newswitchyard4.pcx 149 266 09 31 64 -31 0 // 042D x, back tile
	1 images/newswitchyard4.pcx 149 309 09 31 64 -31 0 // 042E y, back tile
	1 images/newswitchyard4.pcx 438 266 09 31 64 -31 0 // 042F x, front tile
	1 images/newswitchyard4.pcx 434 309 09 31 64 -31 0 // 0430 y, front tile
	1 images/newswitchyard4.pcx 221 266 09 31 64 -31 0 // 0431 x, back tile with N side rail
	1 images/newswitchyard4.pcx 222 309 09 31 64 -31 0 // 0432 y, back tile with N side rail
	1 images/newswitchyard4.pcx 507 266 09 31 64 -31 0 // 0433 x, front tile with S side rail
	1 images/newswitchyard4.pcx 506 309 09 31 64 -31 0 // 0434 y, front tile with S side rail

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

// For north part of switch
	// If a pair of switches have another immediately 'upstream' no side rail is shown
	// Test upstream for another switch
	1 * 1	02 04 20 // ID
		85 68 0F // station info param 0/-1; check tile along platform to N
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		03
		\wx8000 SY_SWITCH_S 15 SY_SWITCH_S 15 // if S part of switch - N part no side rail
		\wx8000 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // if mid-buffer - N part no side rail
		\wx8000 SY_MID_BUFFER_S 15 SY_MID_BUFFER_S 15 // if mid-buffer - N part no side rail
		\wx8004 // else - N part with side rail

	// Check for another switch to N
	1 * 1	02 04 21 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		01
		\wx0020 SY_SWITCH_S 15 SY_SWITCH_S 15 // if S part of switch
		\wx8004 // else - N part with side rail

	// Check tile to N
	1 * 1	02 04 11 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0021 SY_BASIC 05 SY_MID_BUFFER_S 05 // if tile can have side rail
		\wx8000 // else - N part no side rail

// For south part of switch
	// If a pair of switches have another immediately 'upstream' no side rail is shown
	// Test upstream for another switch
	1 * 1	02 04 22 // ID
		85 68 0F // station info param 0/-1; check tile along platform to N
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		03
		\wx8002 SY_SWITCH_S 05 SY_SWITCH_S 05 // if N part of switch - S part no side rail
		\wx8002 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // if mid-buffer - S part no side rail
		\wx8002 SY_MID_BUFFER_S 15 SY_MID_BUFFER_S 15 // if mid-buffer - S part no side rail
		\wx8006 // else - S part with side rail

	// Check for another switch to S
	1 * 1	02 04 23 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		01
		\wx0022 SY_SWITCH_S 05 SY_SWITCH_S 05 // if N part of switch
		\wx8006 // else - S part with side rail

	// Check tile to S
	1 * 1	02 04 12 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0023 SY_BASIC 05 SY_MID_BUFFER_S 05 // if tile can have side rail
		\wx8002 // else - S part no side rail
//----------------------------------

	// Test for switch part at current position
	1 * 1	02 04 13 // ID
		85 68 00 // station info param 0/0; check this tile
		00 \wx1000 // mask for bit 12
		01
		\wx0011 \wx0000 \wx0000 // north part
		\wx0012 // south part

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

	1 * 1	02 04 15 // ID
		85
		7E 13 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w6 // val = 6
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

	1 * 1	02 04 20 // ID
		81 0C
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0015 // real sprites

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_SWITCH_S
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard middle buffers (N) ===========================

	1 * 1	00 04 07 01 SY_MID_BUFFER_N
		08 "ISRS"

		// Sprite layout
		1A 02
			// 00 (x)
			41
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register

			// 01 (y)
			41
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042E \wx0002 // ground overlay (child)
			00 00 80 // x/y/z offset
			06 // register

		0B 02 // use callback to determine layout
		0C 01 // only allow width of > 1
		0D FE // only allow platform length of 1
		15 00 // train can enter tile
		11 FF // pylon placement (all)

	1 * 1	01 04 01 0A
	1 images/newswitchyard4.pcx   7 351 09 31 64 -31 0 // 042D x, S side rail buffer
	1 images/newswitchyard4.pcx 227 351 09 31 64 -31 0 // 042E y, S side rail buffer
	1 images/newswitchyard4.pcx  80 351 09 31 64 -31 0 // 042F x, N and S side rail buffers
	1 images/newswitchyard4.pcx 300 351 09 31 64 -31 0 // 0430 y, N and S side rail buffers
	1 images/newswitchyard4.pcx 153 351 09 31 64 -31 0 // 0431 x, N side rail buffer
	1 images/newswitchyard4.pcx 373 351 09 31 64 -31 0 // 0432 y, N side rail buffer
	1 images/newswitchyard4.pcx 450 351 09 31 64 -31 0 // 0433 x, S side rail buffer, N side rail
	1 images/newswitchyard4.pcx 589 351 09 31 64 -31 0 // 0434 y, S side rail buffer, N side rail
	1 images/newswitchyard4.pcx 518 351 09 31 64 -31 0 // 0435 x, N side rail buffer, S side rail
	1 images/newswitchyard4.pcx 658 351 09 31 64 -31 0 // 0436 x, N side rail buffer, S side rail

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

	// For tiles with buffers to S
	1 * 1	02 04 10 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		03
		\wx8002 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // side rail buffer to N and S
		\wx8006 SY_BASIC 05 SY_SWITCH_S 05 // side rail buffer to S, side rail to N
		\wx8006 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // side rail buffer to S, side rail to N
		\wx8000 // side rail buffer to S only

	// For all tiles
	1 * 1	02 04 12 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		03
		\wx0010 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // side rail buffer to S, check N
		\wx8008 SY_BASIC 05 SY_SWITCH_S 05 // side rail buffer to N, side rail to S
		\wx8008 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // side rail buffer to N, side rail to S
		\wx8004 // side rail buffer to N only

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

	1 * 1	02 04 15 // ID
		85
		7E 12 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w2 // val = 2
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_MID_BUFFER_N
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard middle buffers (S) ===========================

	1 * 1	00 04 07 01 SY_MID_BUFFER_S
		08 "ISRS"
		0A SY_MID_BUFFER_N // copy sprite layout
		0B 02 // use callback to determine layout
		0C 01 // only allow width of > 1
		0D FE // only allow platform length of 1
		15 00 // train can enter tile
		11 FF // pylon placement (all)

	1 * 1	01 04 01 0A
	1 images/newswitchyard4.pcx   7 389 09 31 64 -31 0 // 042D x, S side rail buffer
	1 images/newswitchyard4.pcx 227 389 09 31 64 -31 0 // 042E y, S side rail buffer
	1 images/newswitchyard4.pcx  80 389 09 31 64 -31 0 // 042F x, N and S side rail buffers
	1 images/newswitchyard4.pcx 300 389 09 31 64 -31 0 // 0430 y, N and S side rail buffers
	1 images/newswitchyard4.pcx 153 389 09 31 64 -31 0 // 0431 x, N side rail buffer
	1 images/newswitchyard4.pcx 373 389 09 31 64 -31 0 // 0432 y, N side rail buffer
	1 images/newswitchyard4.pcx 450 389 09 31 64 -31 0 // 0433 x, S side rail buffer, N side rail
	1 images/newswitchyard4.pcx 589 389 09 31 64 -31 0 // 0434 y, S side rail buffer, N side rail
	1 images/newswitchyard4.pcx 518 389 09 31 64 -31 0 // 0435 x, N side rail buffer, S side rail
	1 images/newswitchyard4.pcx 658 389 09 31 64 -31 0 // 0436 x, N side rail buffer, S side rail

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

	// For tiles with buffers to S
	1 * 1	02 04 10 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		03
		\wx8002 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // side rail buffer to N and S
		\wx8006 SY_BASIC 05 SY_SWITCH_S 05 // side rail buffer to S, side rail to N
		\wx8006 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // side rail buffer to S, side rail to N
		\wx8000 // side rail buffer to S only

	// For all tiles
	1 * 1	02 04 12 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		03
		\wx0010 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // side rail buffer to S, check N
		\wx8008 SY_BASIC 05 SY_SWITCH_S 05 // side rail buffer to N, side rail to S
		\wx8008 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // side rail buffer to N, side rail to S
		\wx8004 // side rail buffer to N only

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

	1 * 1	02 04 15 // ID
		85
		7E 12 // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w2 // val = 2
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_MID_BUFFER_S
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard buffers (N) ==================================

	1 * 1	00 04 08 01 SY_BUFFER_N
		08 "ISRS"
		0A SY_BASIC // copy sprite layout
		0B 02 // use callback to determine layout
		0C 00 // allow any width
		0D FE // only allow platform length of 1
		15 FF // train can enter tile
		14 FF // wires (none)
		11 00 // pylon placement (none)

	1 * 1	01 04 01 08
	1 images/newswitchyard4.pcx   7 427 09 31 64 -31 0 // 042D x, no side rail
	1 images/newswitchyard4.pcx 291 427 09 31 64 -31 0 // 042E y, no side rail
	1 images/newswitchyard4.pcx  76 427 09 31 64 -31 0 // 042F x, S side rail
	1 images/newswitchyard4.pcx 364 427 09 31 64 -31 0 // 0430 y, S side rail
	1 images/newswitchyard4.pcx 147 427 09 31 64 -31 0 // 0431 x, N and S side rails
	1 images/newswitchyard4.pcx 434 427 09 31 64 -31 0 // 0432 y, N and S side rails
	1 images/newswitchyard4.pcx 217 427 09 31 64 -31 0 // 0433 x, N side rail
	1 images/newswitchyard4.pcx 505 427 09 31 64 -31 0 // 0434 y, N side rail

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

	// For tiles with buffers to S
	1 * 1	02 04 10 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8004 SY_BUFFER_N 05 SY_BUFFER_N 05 // side rail buffer to N and S
		\wx8002 // side rail buffer to S only

	// For tiles with no buffers to S
	1 * 1	02 04 11 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8006 SY_BUFFER_N 05 SY_BUFFER_N 05 // side rail buffer to N only
		\wx8000 // no side rails

	// For tiles with no middle buffers or non-middle-rail tiles in tiles to S
	1 * 1	02 04 12 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0010 SY_BUFFER_N 05 SY_BUFFER_N 05 // side rail buffer to S maybe to N
		\wx0011 // no side rail buffer to S maybe to N

	// For tiles with no side rail to N
	1 * 1	02 04 1D // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8002 SY_BUFFER_N 05 SY_BUFFER_N 05 // side rail buffer to S only
		\wx8000 // no side rails

	// For tiles with no non-middle-rail tiles 'upstream' extending to S
	1 * 1	02 04 1C // ID
		85 68 F1 // station info param -1/+1; check tile along platform to S, across to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx001D SY_NO_MID 05 SY_NO_MID 05 // if tile has no side rail to N
		\wx0012 // else

	// For tiles with no non-middle-rail tiles 'upstream'
	1 * 1	02 04 1B // ID
		85 68 11 // station info param +1/+1; check tile along platform to S, across to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0011 SY_NO_MID 05 SY_NO_MID 05 // if tile has no side rail to S
		\wx001C // else

	// For tiles with switch tile N part 'upstream'
	1 * 1	02 04 1E // ID
		85 68 F1 // station info param -1/+1; check tile along platform to S, across to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8000 SY_NO_MID 05 SY_NO_MID 05 // no side rails
		\wx0011 // no side rail buffer to S maybe to N

	// For tiles with switch tiles S part 'upstream'
	1 * 1	02 04 1F // ID
		85 68 11 // station info param +1/+1; check tile along platform to S, across to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8000 SY_NO_MID 05 SY_NO_MID 05 // no side rails
		\wx001D // no side rail buffer to N maybe to S

	// For tiles with middle-buffers 'upstream' extending to S
	1 * 1	02 04 21 // ID
		85 68 F1 // station info param -1/+1; check tile along platform to S, across to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8000 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // no side rails
		\wx001E // no side rail buffer to S maybe to N

	// For tiles with middle-buffers 'upstream'
	1 * 1	02 04 20 // ID
		85 68 11 // station info param +1/+1; check tile along platform to S, across to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0021 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // if tile is mid-buffer N
		\wx001F // else

	// For all tiles
	1 * 1	02 04 1A // ID
		85 68 01 // station info param 0/+1; check tile along platform to S
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		06
		\wx8000 SY_NO_MID 05 SY_NO_MID 05 // if tile has no side rail
		\wx8000 SY_NO_MID 15 SY_NO_MID 15 // if tile has no side rail
		\wx001E SY_SWITCH_N 05 SY_SWITCH_N 05 // if tile is N part of switch
		\wx001F SY_SWITCH_N 15 SY_SWITCH_N 15 // if tile is S part of switch
		\wx0020 SY_MID_BUFFER_N 05 SY_MID_BUFFER_N 05 // if tile is mid-buffer N
		\wx0020 SY_MID_BUFFER_N 15 SY_MID_BUFFER_N 15 // if tile is mid-buffer N
		\wx001B // else

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

	1 * 1	02 04 15 // ID
		85
		7E 1A // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w4 // val = 4
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_BUFFER_N
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard buffers (S) ==================================

	1 * 1	00 04 08 01 SY_BUFFER_S
		08 "ISRS"
		0A SY_BASIC // copy sprite layout
		0B 02 // use callback to determine layout
		0C 00 // allow any width
		0D FE // only allow platform length of 1
		15 FF // train can enter tile
		14 FF // wires (none)
		11 00 // pylon placement (none)

	1 * 1	01 04 01 08
	1 images/newswitchyard4.pcx   7 466 09 31 64 -31 0 // 042D x, no side rail
	1 images/newswitchyard4.pcx 291 466 09 31 64 -31 0 // 042E y, no side rail
	1 images/newswitchyard4.pcx  76 466 09 31 64 -31 0 // 042F x, S side rail
	1 images/newswitchyard4.pcx 364 466 09 31 64 -31 0 // 0430 y, S side rail
	1 images/newswitchyard4.pcx 147 466 09 31 64 -31 0 // 0431 x, N and S side rails
	1 images/newswitchyard4.pcx 434 466 09 31 64 -31 0 // 0432 y, N and S side rails
	1 images/newswitchyard4.pcx 217 466 09 31 64 -31 0 // 0433 x, N side rail
	1 images/newswitchyard4.pcx 505 466 09 31 64 -31 0 // 0434 y, N side rail

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

	// For tiles with buffers to S
	1 * 1	02 04 10 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8004 SY_BUFFER_S 05 SY_BUFFER_S 05 // side rail buffer to N and S
		\wx8002 // side rail buffer to S only

	// For tiles with no buffers to S
	1 * 1	02 04 11 // ID
		85 68 F0 // station info param -1/0; check tile to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8006 SY_BUFFER_S 05 SY_BUFFER_S 05 // side rail buffer to N only
		\wx8000 // no side rails

	// For tiles with no middle buffers or non-middle-rail tiles in tiles to S
	1 * 1	02 04 12 // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0010 SY_BUFFER_S 05 SY_BUFFER_S 05 // side rail buffer to S maybe to N
		\wx0011 // no side rail buffer to S maybe to N

	// For tiles with no side rail to N
	1 * 1	02 04 1D // ID
		85 68 10 // station info param +1/0; check tile to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8002 SY_BUFFER_S 05 SY_BUFFER_S 05 // side rail buffer to S only
		\wx8000 // no side rails

	// For tiles with no non-middle-rail tiles 'upstream' extending to S
	1 * 1	02 04 1C // ID
		85 68 FF // station info param -1/-1; check tile along platform to N, across to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx001D SY_NO_MID 05 SY_NO_MID 05 // if tile has no side rail to N
		\wx0012 // else

	// For tiles with no non-middle-rail1 tiles 'upstream'
	1 * 1	02 04 1B // ID
		85 68 1F // station info param +1/-1; check tile along platform to N, across to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0011 SY_NO_MID 05 SY_NO_MID 05 // if tile has no side rail to S
		\wx001C // else

	// For tiles with switch tile N part 'upstream'
	1 * 1	02 04 1E // ID
		85 68 FF // station info param -1/-1; check tile along platform to N, across to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8000 SY_NO_MID 05 SY_NO_MID 05 // no side rails
		\wx0011 // no side rail buffer to S maybe to N

	// For tiles with switch tile S part 'upstream'
	1 * 1	02 04 1F // ID
		85 68 1F // station info param +1/-1; check tile along platform to N, across to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8000 SY_NO_MID 05 SY_NO_MID 05 // no side rails
		\wx001D // no side rail buffer to N maybe to S

	// For tiles with middle-buffers 'upstream' extending to S
	1 * 1	02 04 21 // ID
		85 68 FF // station info param -1/-1; check tile along platform to N, across to N
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx8000 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // no side rails
		\wx001E // no side rail buffer to S maybe to N

	// For tiles with middle-buffers 'upstream'
	1 * 1	02 04 20 // ID
		85 68 1F // station info param +1/-1; check tile along platform to N, across to S
		00 \wx0FFF // mask 12 bits for tile ID, type and direction
		01
		\wx0021 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // if tile is mid-buffer S
		\wx001F // else

	// For all tiles
	1 * 1	02 04 1A // ID
		85 68 0F // station info param 0/-1; check tile along platform to N
		00 \wx1FFF // mask 13 bits for tile ID, type, direction and part
		06
		\wx8000 SY_NO_MID 05 SY_NO_MID 05 // if tile has no side rail
		\wx8000 SY_NO_MID 15 SY_NO_MID 15 // if tile has no side rail
		\wx001E SY_SWITCH_S 05 SY_SWITCH_S 05 // if tile is N part of switch
		\wx001F SY_SWITCH_S 15 SY_SWITCH_S 15 // if tile is S part of switch
		\wx0020 SY_MID_BUFFER_S 05 SY_MID_BUFFER_S 05 // if tile is mid-buffer N
		\wx0020 SY_MID_BUFFER_S 15 SY_MID_BUFFER_S 15 // if tile is mid-buffer N
		\wx001B // else

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

	1 * 1	02 04 15 // ID
		85
		7E 1A // get variety
		20 \wx00FF
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w4 // val = 4
		\2sto 1A
		20 \wx0006 // store in register - ground overlay offset
		\2rst
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_BUFFER_S
		01
		FF \wx0021 // purchase
		\wx0020


// == Marshalling yard no middle-rail ===============================

	1 * 1	00 04 04 01 SY_NO_MID
		08 "ISRS"

		// Sprite layout
		1A 02
			// 00 (x)
			41
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042D \wx0000 // ground overlay (child)
			00 00 80 // x/y/z offset

			// 01 (y)
			41
			\dx00000F8D \wx0002 // ground sprite
			10 // register
			\dx8000042E \wx0000 // ground overlay (child)
			00 00 80 // x/y/z offset

		0B 02 // use callback to determine layout
		11 FF // pylon placement (all)

	1 * 1	01 04 01 02
	1 images/newswitchyard4.pcx   5 7 09 31 64 -31 0 // 042D x
	1 images/newswitchyard4.pcx 291 7 09 31 64 -31 0 // 042E y

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

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

	1 * 1	02 04 15 // ID
		85
		7E 7F // get normal/snow/desert offset
		20 \wx7FFF
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

	// Purchase
	1 * 1	02 04 16 // ID
		85
		1A // all bits on
		20 \w0 // val = 0
		\2sto 1A
		00 \wx0010 // store in register - ground sprite offset
		01
		\wx0000 \w0 \w0
		\wx0000

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

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

	// For purchase list
	1 * 1	02 04 21 // ID
		81 0C // callback
		00 FF
		01
		\wx8000 14 14 // sprite layout
		\wx0016 // real sprites

	1 * 1	03 04
		01 SY_NO_MID
		01
		FF \wx0021 // purchase
		\wx0020
