TrainStationScript::
	mapregion
	scriptstartasm
	ld a, [hScriptVar]
	ld [wScriptBuffer], a
	ld b, a
	ld c, 0
	ld hl, wTrainStationMenuItems
	ld a, 4
	ld [hli], a
.loop
	ld a, c
	cp b
	jr z, .skip
	ld [hli], a
.skip
	inc a
	ld c, a
	cp 5
	jr c, .loop
	ld [hl], $ff
	xor a
	ld [wWhichIndexSet], a
	scriptstopasm
	opentext
	writetext .magnet_train_greetings_text
	loadmenudata .MenuDataHeader
	verticalmenu
	closewindow
	sif >, 3, then
		closetext
		end
	sendif
	sif >, 1, then
		pushvar
		checkitem MAGNET_PASS
		sif false, then
			popvar
			jumptext .need_pass_text
		sendif
		popvar
	sendif
	writetext .enter_train_text
	closetext
	applymovement 2, .employee_enter_train
	applymovement 0, .player_enter_train
	playmusic MUSIC_MAGNET_TRAIN
	pushvar
	comparevartobyte wScriptBuffer ; var = destination, byte = source
	special Special_MagnetTrain
	wait 14
	popvar
	callasm ForceMapMusicRestart
	loadarray .MagnetTrainDestinationMapsArray
	cmdwitharrayargs
	db warp_command, %1, 0, 11, 6
	endcmdwitharrayargs
	applymovement 2, .employee_exit_train
	applymovement 0, .player_exit_train
	applymovement 2, .employee_walk_back
	mapnametotext 0
	getnthstring .Strings, 0
	jumptext .arrived_in_city_text

.MenuDataHeader:
	db $40 ; flags
	db 01, 10 ; start coords
	db 11, 19 ; end coords
	dw .MenuData2
	db 1 ; default option

.MenuData2:
	db $80
	db 0
	dw wTrainStationMenuItems
	dw PlaceMenuStrings
	dw .Strings

.Strings:
	db "Naljo@"
	db "Rijon@"
	db "Johto@"
	db "Kanto@"
	db "Cancel@"

.MagnetTrainDestinationMapsArray:
	map TORENIA_MAGNET_TRAIN
.MagnetTrainDestinationMapsArrayEntrySizeEnd:
	map BOTAN_MAGNET_TRAIN
	map GOLDENROD_MAGNET_TRAIN
	map SAFFRON_MAGNET_TRAIN

.employee_enter_train
	step_up
	step_up
	step_left
	step_end

.player_enter_train
	step_up
	step_up
	step_up
	step_up
	step_left
	step_left
	step_left
	step_up
	step_end

.employee_exit_train
	step_down
	step_left
	step_end

.player_exit_train
	step_left
	step_left
	step_down
	step_down
	step_down
	step_down
	step_down
	turn_head_up
	step_end

.employee_walk_back
	step_right
	step_up
	turn_head_down
	step_end

.magnet_train_greetings_text
	db TX_COMPRESSED, $62, $7d, $e8

	db $7c, $01, $ba, $4d, $67, $32, $18, $08, $2d, $4a, $b4
	db $96, $f5, $86, $72, $1a
	db $50, $73

.enter_train_text
	db TX_COMPRESSED, $76, $26, $3f, $04, $74, $f5, $07, $0c, $96, $6b
	db $7a, $d2, $71, $fd, $e4, $87, $72, $d7, $a3, $27
	db $a9, $e2

.need_pass_text
	db TX_COMPRESSED, $72, $85, $a8, $43, $3c, $cd, $82, $bb, $c9, $0e
	db $de, $e1, $d4, $22, $58, $67, $21, $96, $93, $59
	db $fa, $9a

.arrived_in_city_text
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9c, $b0
	db $bd, $4f, $2f
	db $aa, $07, $23
	db $d4, $d0
