; Reserved for one-time initialisation.
NODE 0
ONSTATEENTRY
  SETLINEBANKLO 0
  CHANGENODE 1
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Title Screen.
NODE 1
ONSTATEENTRY
  SETBORDER 0 
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  SETVAR 25, 0
  SETVAR 30, 0
  SETLINEBANKHI 1
  SETPGPHSPACE 1
  FILLSCREEN 255
  FILLAREA 0, 8, 32, 8, 0
  DRAWBITMAP 16, 1, 1
  DRAWBITMAP 16, 25, 1
  DRAWBITMAP 16, 1, 17
  DRAWBITMAP 16, 25, 17
  PRINTLINE 64, 6,  9,  0
  PRINTLINE 65, 8,  12,  0
  PRINTLINE 66, 10, 15,  0
  SETATTRBUFFER
  SETALLATTRIBUTES 120 ; Bright, no flash, White paper, Black ink.
  SETATTRIBUTES 0,  8, 32, 8,  71 ; Bright, no flash, Black paper, White ink.
  SETATTRSCREEN
  COPYATTRBUFFER
ENDSTATE
ONSTATECURRENT
  CALLSUBNODE 14
  IFVAR==(NUM) 22, 5
    ; Start game.
    CHANGENODE 2
  ENDIF
  ; First digit: 2.
  IFVAR==(NUM) 22, 2
    IFVAR==(NUM) 30, 0
      INCVAR 25
    ENDIF
  ENDIF
  ; Second digit: 1.
  IFVAR==(NUM) 22, 1
    IFVAR==(NUM) 30, 1
      INCVAR 25
    ENDIF
  ENDIF
  ; Third digit: 4.
  IFVAR==(NUM) 22, 4
    IFVAR==(NUM) 30, 2
      INCVAR 25
    ENDIF
  ENDIF
  ; Fourth digit: 2.
  IFVAR==(NUM) 22, 2
    IFVAR==(NUM) 30, 3
      INCVAR 25
    ENDIF
  ENDIF
  ; Fifth digit: 1.
  IFVAR==(NUM) 22, 1
    IFVAR==(NUM) 30, 4
      INCVAR 25
    ENDIF
  ENDIF
  ; Sixth digit: 4.
  IFVAR==(NUM) 22, 4
    IFVAR==(NUM) 30, 5
      INCVAR 25
    ENDIF
  ENDIF
  ; Six digits entered?
  IFVAR==(NUM) 30, 6
    IFVAR==(NUM) 25, 6
      ; Do shortcut.
      SETLINEBANKHI 4
      SETVAR 42, 5
      SETPGPHAREA 0, 0, 32, 24
      SETPGPHDELAY 5, 5
      SETPGPHSPACE 0
      CHANGENODE 12
    ENDIF   
    ; Reset counters.
    SETVAR 25, 0
    SETVAR 30, 0
  ENDIF
  INCVAR 30
  ; Cancel increment if no key pressed.
  IFVAR==(NUM) 22, 0
    DECVAR 30
  ENDIF
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Cranetron introduction and 2001.
NODE 2
ONSTATEENTRY
  SETLINEBANKHI 2
  SETVAR 33, 64
  ; Cranetron appears.
  SETVAR 34, 8
  CALLSUBNODE 5
  ; Introduction.
  CALLSUBNODE 3
  ; Cranetron blares.
  SETVAR 36, 3
  CALLSUBNODE 8
  CALLSUBNODE 3
  ;CALLSUBNODE 3
  ; Password check.
  CALLSUBNODE 62
  CALLSUBNODE 10
  CALLSUBNODE 3
  ; Show 2001.
  SETVAR 32, 1
  CALLSUBNODE 60
  SETVAR 33, 69
  CALLSUBNODE 3
  CALLSUBNODE 3
  CALLSUBNODE 3
  CHANGENODE 3  
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Jokes page.
NODE 3
ONSTATEENTRY
  ; Setup screen.
  SETVAR 35, 12
  CALLSUBNODE 6
  ; Introduction.
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  ; Jokes.
  SETVAR 33, 75
  CLEARPGPH
  CALLSUBNODE 3
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  CHANGENODE 4
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Coalface Incorporated and first code number branch.
NODE 4
ONSTATEENTRY
  ; Show Coalface.
  CALLSUBNODE 60
  ; Show text.
  SETVAR 33, 80
  CALLSUBNODE 3
  CALLSUBNODE 3
  CALLSUBNODE 3
  ; Continue to next section if code was correct.
  IFVAR==(NUM) 25, 3
    CHANGENODE 5    
  ENDIF
  ; Happy Cranetron.
  SETVAR 34, 8
  CALLSUBNODE 5
  CALLSUBNODE 3
  CALLSUBNODE 3
  ; Return to title screen.
  CHANGENODE 1
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Second code check and Ghee Lord.
NODE 5
ONSTATEENTRY
  ; Stern Cranetron.
  SETVAR 34, 10
  CALLSUBNODE 5
  SETVAR 33, 85
  CALLSUBNODE 3
  SETPGPHSPACE 0
  CALLSUBNODE 3
  CALLSUBNODE 52
  SETPGPHSPACE 1
  CALLSUBNODE 3
  ;CALLSUBNODE 3
  ; Password check
  CALLSUBNODE 62
  CALLSUBNODE 11
  DRAWBITMAP 8, 14, 1 
  CALLSUBNODE 3
  ; Cranetron blares (only two cycles.)
  SETVAR 36, 2
  CALLSUBNODE 8
  ; Ghee Lord.
  SETVAR 32, 3
  CALLSUBNODE 60
  CALLSUBNODE 3
  CALLSUBNODE 3
  CALLSUBNODE 3
  CHANGENODE 6   
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Quiz page.
NODE 6
ONSTATEENTRY
  ; Setup screen.
  SETVAR 35, 13
  CALLSUBNODE 6
  ; Introduction.
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  ; Questions.
  CALLSUBNODE 3
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 3
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  CALLSUBNODE 52
  WAITFIXED 125
  CALLSUBNODE 52
  ; Scoring.
  CLEARPGPH
  PRINTLINE 111, 0, 5, 0 
  PRINTLINE 112, 0, 7, 0 
  PRINTLINE 113, 0, 8, 0
  WAITFORKEY
  CHANGENODE 7  
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Dream K and second code number branch.
NODE 7
ONSTATEENTRY
  SETVAR 33, 114
  CALLSUBNODE 60
  CALLSUBNODE 3
  CALLSUBNODE 3
  CALLSUBNODE 3
  ; Continue if code was correct.
  IFVAR==(NUM) 25, 3
    CHANGENODE 8    
  ENDIF
  ; Otherwise, return to title screen.
  ; (via Happy Cranetron.)
  SETVAR 34, 8
  CALLSUBNODE 5
  CALLSUBNODE 3
  CALLSUBNODE 3
  SETVAR 33, 84
  CALLSUBNODE 3
  CHANGENODE 1
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Alert deactivation and final warning before remote bunker connection.
NODE 8
ONSTATEENTRY
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  SETLINEBANKHI 3
  FILLSCREEN 0
  SETPGPHAREA 0, 4, 32, 20
  SETPGPHDELAY 1, 1
  PRINTPGPH 64
  PRINTPGPH 65
  WAITFIXED 45
  SETALLATTRIBUTES 66 ; Bright, no flash, Black paper, Red ink.
  PLAYSOUND 0
  PLAYSOUND 1
  PLAYSOUND 0
  PLAYSOUND 1
  PLAYSOUND 0
  PLAYSOUND 1
  PLAYSOUND 0
  PLAYSOUND 1
  SETVAR 33, 66
  CALLSUBNODE 52
  CHANGENODE 9
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Final warning before remote bunker connection.
NODE 9
ONSTATEENTRY
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  FILLSCREEN 0
  CLEARPGPH
  PRINTPGPH 67
  SETALLATTRIBUTES 66 ; Bright, no flash, Black paper, Red ink.
  PLAYSOUND 2
  WAITFORKEY
  SETVAR 33, 68
  PLAYSOUND 2
  CALLSUBNODE 52
  PLAYSOUND 2
  CALLSUBNODE 52
  PRINTPGPH v33
  ; Countdown.
  SETVAR 26, 5
  SETVAR 27, 29
  SETVAR 28, 11
  CALLSUBNODE 16
  PLAYSOUND 2
  CHANGENODE 10
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Establishing bunker connection.
NODE 10
ONSTATEENTRY
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  SETPGPHAREA 0, 0, 32, 24
  SETPGPHDELAY 5, 5
  SETPGPHSPACE 0
  CLEARPGPH
  SETALLATTRIBUTES 71 ; Bright, no flash, Black paper, White ink.
  SETVAR 33, 71
  SETVAR 37, 3
  CALLSUBNODE 7
  ; Communication module probe delay.
  WAITONESEC
  SETVAR 37, 2
  CALLSUBNODE 7
  ; UHF broadcast sound.
  SETVARFULL 8, 40704
  SETVARFULL 9, 1024
  SETVAR 10, 4
  CALLSUBNODE 17
  CALLSUBNODE 13
  ; UHF listening delay.
  WAITTWOSECS
  CALLSUBNODE 13
  ; Received/Embedded text block.
  SETVAR 37, 7
  CALLSUBNODE 7
  ; Received/Embedded processing delay.
  WAITTWOSECS
  SETVAR 37, 2
  CALLSUBNODE 7
  ; X-80 broadcast sound.
  SETVARFULL 8, 41728
  SETVAR 10, 4
  CALLSUBNODE 17
  CALLSUBNODE 13
  ; X-80 listening delay.
  WAITTWOSECS
  WAITTWOSECS
  SETVAR 37, 3
  CALLSUBNODE 7
  ; BROWNRECORD pilot signal.
  PLAYSOUND 3
  WAITONESEC
  CALLSUBNODE 13
  ; Get 2 + RND(4) number of attemps until successful AR connection.
  GETRANDOM 3
  COPYVAR 0, 37
  INCVAR 37
  INCVAR 37
  ; Reset random number (used as line token reference.)
  SETVAR 0, 0
  ; AR signals.
  SETVARFULL 8, 42752
  CALLSUBNODE 20
  CALLSUBNODE 13
  WAITTWOSECS
  ; Random message.
  GETRANDOM 3
  INCVAR 0
  CALLSUBNODE 13
  WAITONESEC
  CHANGENODE 11
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Bunker connection established.
NODE 11
ONSTATEENTRY
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  SETLINEBANKHI 4
  ; Image noise start point (beginning of graphics data.)
  SETVARFULL 8, 40704
  CLEARPGPH
  SETALLATTRIBUTES 71 ; Bright, no flash, Black paper, White ink.
  SETVAR 33, 64
  ; Disabling TX/RX sound monitoring.
  CALLSUBNODE 13
  WAITTWOSECS
  CALLSUBNODE 13
  CALLSUBNODE 13
  CALLSUBNODE 13
  WAITONESEC
  CALLSUBNODE 13
  ; Disabling local VHF.
  CALLSUBNODE 13
  WAITTWOSECS
  CALLSUBNODE 13
  ; Enabling local VHF.
  CALLSUBNODE 13
  WAITTWOSECS
  PRINTPGPH 72
  ; Set current roamer.
  SETVAR 42, 5
  ; Contacting roamer bots (1 of 3)
  PRINTPGPH 73
  WAITTWOSECS
  PRINTPGPH 74
  PRINTPGPH 75
  ; Contacting roamer bots (2 of 3)
  PRINTPGPH 73
  WAITTWOSECS
  PRINTPGPH 76
  PRINTPGPH 77
  ; Contacting roamer bots (3 of 3)
  PRINTPGPH 73
  WAITTWOSECS
  PRINTPGPH 78
  ; Starting ROAMos.
  PRINTPGPH 79
  WAITFIXED 125
  CHANGENODE 12
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; ROAMos.
NODE 12
ONSTATEENTRY
  ; Set next roamer.
  SETVAR 48, 1
  ; Clear all bright flags.
  SETALLATTRIBUTES 0 ; No bright, no flash, Black paper, Black ink.
  ; Load tunnel map pixels to screen.
  DRAWBITMAP 5, 0, 0
  ; Set pixels and attributes for message display area.
  FILLAREA 0, 21, 32, 3, 255
  SETATTRIBUTES 0, 21, 32, 3, 71 ; Bright, no flash, Black paper, White ink.
  ; Load tunnel map attributes to buffer.
  SETATTRBUFFER
  LOADATTRIBUTES 5
  SETATTRSCREEN
  WAITONESEC
  ; Disable roamer mute.
  SETVAR 43, 0
  ; Show RoamOS animation.
  SETVAR 31, 3
  CALLSUBNODE 23 
  ; Move paragraph area to bottom of screen, switch to linefeed mode, minimum delay.
  SETPGPHAREA 0, 21, 32, 3
  SETPGPHDELAY 1, 1
  SETPGPHMODE 1
  PRINTPGPH 74
  WAITONESEC
  ; Scan embedded map data.
  PRINTPGPH 80
  WAITTWOSECS
  ; Request current map data.
  PRINTPGPH 81
  WAITTWOSECS
  ; Request failed.
  PRINTPGPH 82
  WAITTWOSECS
  ; Reveal starting position.
  SETWALKERGFX 19
  SETVAR 12, 5
  CREATEWALKER 17, 9
  ; Generate car registration plate.
  SETVAR 13, 8
  CREATEREGPLATE v13
  ; Prompt player to begin.
  PRINTPGPH 74
  WAITONESEC
  PRINTPGPH 75
  WAITONESEC
  PRINTPGPH 77

  ; DEBUGGING ONLY - show registration plate.
  ;PRINTPGPH 33

  CHANGENODE 13
ENDSTATE
ONSTATECURRENT
  ; Nothing.
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Roamer control.
NODE 13
ONSTATEENTRY  
  ; Nothing.
ENDSTATE
ONSTATECURRENT
  CALLSUBNODE 24
ENDSTATE
ONSTATEEXIT
  ; Nothing.
ENDSTATE
ENDNODE

; Clear paragraph area, show next paragraph, then wait for key.
SUBNODE 3
  CALLSUBNODE 62
  WAITFORKEY
ENDSUBNODE

; Set and clear default paragraph and prompt locations.
SUBNODE 4
  SETPGPHAREA 0, 18, 32, 6
  SETPGPHDELAY 5, 50
  SETPGPHPROMPT 0
  CLEARPGPH
  FILLAREA 0, 18, 32, 6, 0
ENDSUBNODE

; Draw Cranetron and his face.
SUBNODE 5
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  DRAWBITMAP 0, 0, 0
  DRAWBITMAP v34, 14, 1
  CALLSUBNODE 4
  WAITONE
  LOADATTRIBUTES 0
  SETATTRIBUTES 0, 18, 32, 6, 71 ; Bright, no flash, Black paper, White ink.
ENDSUBNODE

; Draw Dodgytiser intermission character.
SUBNODE 6
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  SETATTRBUFFER
  FILLSCREEN 255
  FILLAREA 0, 5, 32, 19, 0
  DRAWBITMAP v35, 28, 0
  SETALLATTRIBUTES 120 ; Bright, no flash, White paper, Black ink.
  SETATTRIBUTES 0,  5, 32, 19,  71 ; Bright, no flash, Black paper, White ink.
  SETPGPHAREA 0, 5, 32, 19
  SETPGPHDELAY 5, 25
  SETATTRSCREEN
  COPYATTRBUFFER
ENDSUBNODE

; Print sequence of paragraphs.
SUBNODE 7
  PRINTPGPH v33
  INCVAR 33
  DECVAR 37
  IFVAR==(NUM) 37, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Cranetron blares, with subtitles.
SUBNODE 8
  CLEARPGPH
  PRINTPGPH v33
  INCVAR 33
  WAITONESEC
  CLEARPGPH
  SETVAR 23, 14
  SETVAR 24, 1
  CALLSUBNODE 9
ENDSUBNODE

; Crantron blare cycle.
SUBNODE 9
  WAITONE
  DRAWBITMAP 9, v23, v24
  PRINTLINE 6, 12, 23, 0
  PLAYSOUND 0
  WAITONE
  DRAWBITMAP 8, v23, v24
  PRINTLINE 40, 0, 23, 32
  WAITFIXED 20
  DECVAR 36
  IFVAR==(NUM) 36, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; First code check.
; Correct code = 121.
SUBNODE 10
  ; Set up display
  CALLSUBNODE 61
  ; Get first character.
  CALLSUBNODE 15
  IFVAR==(NUM) 22, 1
    INCVAR 25
  ENDIF
  CALLSUBNODE 15
  IFVAR==(NUM) 22, 2
    INCVAR 25
  ENDIF
  CALLSUBNODE 15
  IFVAR==(NUM) 22, 1
    INCVAR 25
  ENDIF
  ; "Processing" message (regardless of code being correct.)
  CALLSUBNODE 63
ENDSUBNODE

; Second code check.
; Correct code = 214 ("BAD".)
SUBNODE 11
  ; Set up display
  CALLSUBNODE 61
  ; Get first character.
  CALLSUBNODE 15
  IFVAR==(NUM) 22, 2
    INCVAR 25
  ENDIF
  CALLSUBNODE 15
  IFVAR==(NUM) 22, 1
    INCVAR 25
  ENDIF
  CALLSUBNODE 15
  IFVAR==(NUM) 22, 4
    INCVAR 25
  ENDIF
  ; "Processing" message (regardless of code being correct.)
  CALLSUBNODE 63
ENDSUBNODE

; Third code check.
; Correct code set during game by CREATEREGPLATE.
SUBNODE 12
  PRINTLINE 0, 22, 17, 0
  SETVAR 23, 22
  SETVAR 24, 17
  SETVAR 25, 0
  CALLSUBNODE 15
  IFVAR==(VAR) 22, 16
    INCVAR 25
  ENDIF
  CALLSUBNODE 15
  IFVAR==(VAR) 22, 17
    INCVAR 25
  ENDIF
  CALLSUBNODE 15
  IFVAR==(VAR) 22, 18
    INCVAR 25
  ENDIF
  WAITONESEC
  IFVAR==(NUM) 25, 3
    ; FASTROAM message.
    PRINTLINE 30, 21, 19, 0
    ; Explosion sequence.
    SETVAR 29, 50
    SETVAR 31, 10
    ; Store mute flag, disable mute.
    COPYVAR 43, 14
    SETVAR 43, 0
    ; Explosion sequence (with step noises.)
    CALLSUBNODE 41
    ; Restore mute flag.
    COPYVAR 14, 43
    CLEARWALKER
    EXPLODECELL
    ; Respond to explosion.
    CALLSUBNODE v41
    ; Done, reset explosion flag.
    DECVAR 44
    ; Clear roamer display.
    WAITONESEC
    SETVAR 0, 255
    FILLAREA 21, 14, 8, 6, v0
    ; Switch to new roamer, if possible.
    WAITFORKEY
    CALLSUBNODE 21
    BREAKSUB
  ENDIF
  ; SHUTDOWN message.
  PRINTLINE 29, 21, 19, 0
  WAITTWOSECS
  ; Clear roamer display.
  SETVAR 0, 255
  FILLAREA 21, 14, 8, 6, v0
  ; Lost contact with roamer.
  WAITONESEC
  PRINTPGPH 57
  CLEARWALKER
  ; Switch to new roamer, if possible.
  WAITFORKEY
  CALLSUBNODE 21    
ENDSUBNODE

; Show next paragraph.
SUBNODE 13
  PRINTPGPH v33
  INCVAR 33
ENDSUBNODE

; Get key number (if any.)
SUBNODE 14
  SETVAR 22, 0
  ONKEY1
    SETVAR 22, 1
  ENDKEY
  ONKEY2
    SETVAR 22, 2
  ENDKEY
  ONKEY3
    SETVAR 22, 3
  ENDKEY
  ONKEY4
    SETVAR 22, 4
  ENDKEY
  ONKEY5
    SETVAR 22, 5
  ENDKEY
ENDSUBNODE

; Get code digit.
SUBNODE 15
  CALLSUBNODE 14
  IFVAR==(NUM) 22, 0
    REPEATSUB
  ENDIF
  PLAYSOUND 2
  PRINTLINE v22, v23, v24, 0
  INCVAR 23
ENDSUBNODE

; Countdown sequence.
SUBNODE 16
  PLAYSOUND 2
  PRINTLINE v26, v27, v28, 0
  WAITFIXED 45
  DECVAR 26
  IFVAR==(NUM) 26, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Play memory noise on repeat.
SUBNODE 17
  PLAYMEMNOISE v8, v9
  DECVAR 10
  IFVAR==(NUM) 10, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; "Walking" memory noise (initialisation.)
SUBNODE 18
  SETVAR 9, 8
  SETVAR 10, 64
  CALLSUBNODE 19
ENDSUBNODE

; "Walking" memory noise (loop.)
SUBNODE 19
  PLAYMEMNOISE v8, v9
  DECVAR 10
  INCVAR 8
  IFVAR==(NUM) 10, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Generate and display set of AR numbers.
SUBNODE 20
  CREATEFORMNUM 0
  PRINTLINE 9, 7, 20, 0
  CALLSUBNODE 18
  WAITONESEC
  DECVAR 37
  IFVAR==(NUM) 37, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Attempt to switch to new roamer (after loss or explosion.)
SUBNODE 21
  ; Same roamer is respawned if player has met the Explosion Fairie.
  IFVAR==(NUM) 59, 0
    ; Player has not met the Explosion Faerie.
    ; Reset mute flag to play step sounds (new roamer.)
    SETVAR 43, 0
    ; Use TVAR_NEXTROAMER (v48) to help decide what happens now.
    IFVAR==(NUM) 48, 3
      ; No roamers left. Run corresponding ending.
      CALLSUBNODE 59
    ENDIF
    IFVAR==(NUM) 48, 2
      ; RM-4 is the last awake roamer.
      SETVAR 48, 3
      SETVAR 42, 6
    ENDIF
    IFVAR==(NUM) 48, 1
      ; RM-3 or RM-4 exploded. Only RM-6 remains.
      SETVAR 48, 3
      SETVAR 42, 7    
    ENDIF
    IFVAR==(NUM) 48, 0
      ; RM-4 exploded. RM-3 and RM-6 remain.
      SETVAR 48, 1
      SETVAR 42, 5    
    ENDIF
  ENDIF
  ; Create a new (or respawn the existing) walker.
  SETWALKERGFX 19
  CREATEWALKER 17, 9
  ; Show animation and start message.
  SETVAR 31, 3
  CALLSUBNODE 23
  PRINTPGPH 74
  ; Cultist interruption if solider was killed.
  IFVAR==(NUM) 62, 3
    CALLSUBNODE 56
    PRINTPGPH 43
    WAITTWOSECS
    PRINTPGPH 44    
  ENDIF
  ; Restart, as this may have been entered part-way through roamer menu subnodes.
  CHANGENODE 13
ENDSUBNODE

; Redraw roamer menu if movement occoured.
SUBNODE 22
  IFVAR==(NUM) 40, 0
    ; No movement.
    BREAKSUB
  ENDIF
  DRAWBITMAP 32, 21, 14
  ; Don't redraw attributes (allows nice glitches on route to Explosion Faerie.)
  ;SETATTRIBUTES 21, 14, 8, 6, 120 ; Bright, no flash, White paper, Black ink.
ENDSUBNODE

; ROAMos animation cycle.
SUBNODE 23
  SETATTRIBUTES 21, 14, 8, 6, 120 ; Bright, no flash, White paper, Black ink.
  DRAWBITMAP 33, 21, 14
  PLAYSOUND 5
  WAITFIXED 15
  DRAWBITMAP 32, 21, 14
  PLAYSOUND 9
  WAITFIXED 15
  DECVAR 31
  IFVAR==(NUM) 31, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE  

; Tunnel movement handler.
SUBNODE 24
  SETVAR 40, 0
  ONKEY1
    ; Move left.
    SETVAR 40, 8
    SETWALKERGFX 17
  ENDKEY
  ONKEY2
    ; Move right.
    SETVAR 40, 4
    SETWALKERGFX 18
  ENDKEY
  ONKEY3
    ; Move down.
    SETVAR 40, 2
    SETWALKERGFX 19
  ENDKEY
  ONKEY4
    ; Move up.
    SETVAR 40, 1
    SETWALKERGFX 20
  ENDKEY
  ONKEY5
    ; Fire button.
    CALLSUBNODE 25
    BREAKSUB
  ENDKEY
  IFVAR==(NUM) 40, 0
    BREAKSUB
  ENDIF  
  MOVEONMAP v40
  ; Play step sound (or not, if muted.)
  CALLSUBNODE 42
  ; Redraw roamer menu if movement occoured.
  CALLSUBNODE 22
  ; Run cell event.
  CALLSUBNODE v41
ENDSUBNODE

; ROAMos main control menu.
SUBNODE 25
  ; Clear display area.
  WAITONE
  FILLAREA 21, 14, 8, 6, 0 
  ; Show first menu.
  PRINTLINE 20, 21, 14, 0
  SETVAR 22, 21
  ADDVAR 22, v43
  PRINTLINE v22, 23, 15, 0
  PRINTLINE 23, 21, 17, 0  
  PRINTLINE 24, 21, 19, 0
  CALLSUBNODE 26
  ; Show picture again and print "I roam" on exit.
  WAITONE
  DRAWBITMAP 32, 21, 14
  PRINTPGPH 74
ENDSUBNODE

; ROAMos main control menu keyloop.
SUBNODE 26
  ONKEY1
    ; Toggle volume.
    INCVAR 43
    IFVAR==(NUM) 43, 2
      SETVAR 43, 0
    ENDIF
    ; Print new volume.
    SETVAR 22, 21
    ADDVAR 22, v43
    PRINTLINE v22, 23, 15, 0
  ENDKEY
  ONKEY2
    ; Open safety submenu.
    CALLSUBNODE 27    
    BREAKSUB
  ENDKEY
  ONKEY5
    ; Return.
    BREAKSUB    
  ENDKEY
  REPEATSUB
ENDSUBNODE

; ROAMos safety submenu.
SUBNODE 27
  ; Clear display area.
  WAITONE
  FILLAREA 21, 14, 8, 6, 0
  ; Show submenu.
  PRINTLINE 25, 21, 14, 0
  PRINTLINE 26, 21, 15, 0
  PRINTLINE 27, 21, 17, 0
  PRINTLINE 24, 21, 19, 0
  CALLSUBNODE 28
ENDSUBNODE

; ROAMos safety submenu keyloop.
SUBNODE 28
  ONKEY1
    ; Clear space for passcode entry.
    WAITONE
    FILLAREA 21, 16, 8, 4, 0
    ; Request code.
    CALLSUBNODE 12
    BREAKSUB
  ENDKEY
  ONKEY5
    ; Return.
    BREAKSUB    
  ENDKEY
  REPEATSUB
ENDSUBNODE

; Perpetual siren.
SUBNODE 29
  PLAYSOUND 0
  PLAYSOUND 1
  REPEATSUB
ENDSUBNODE

; Wipe current roamer image with noise passes.
SUBNODE 30
  CALLSUBNODE 31
  DECVAR 31
  WAITFIXED 10
  IFVAR==(NUM) 31, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Add noise to current roamer image.
SUBNODE 31
  ADDMEMGRAIN 21, 14, 8, 6, v8, 122 ; Use 85 for even hatch.
  ;Using odd number to prevent column regularity
  ADDVAR 8, 63
  IFVAR==(NUM) 8, 48900
    ; Image noise start address loops through 8k-ish area (graphics data) in 63 byte steps.
    SETVARFULL 8, 40704
  ENDIF
ENDSUBNODE

; Display roamer camera picture (first encounter.)
SUBNODE 32
  ; Blank roamer screen with attributes.
  SETATTRIBUTES 21, 14, 8, 6, 64 ; Bright, no flash, Black paper, Black ink.
  ; Draw bitmap (will be hidden be attributes.)
  DRAWBITMAP v32, 21, 14
  ; Add noise.
  CALLSUBNODE 31
  ; Reveal noisy image.
  PRINTPGPH 18
  SETVAR 24, 14
  CALLSUBNODE 33
  ; Reveal clean image.
  PRINTPGPH 19
  WAITONESEC
  ; Blank roamer screen with attributes.
  SETATTRIBUTES 21, 14, 8, 6, 64 ; Bright, no flash, Black paper, Black ink.
  DRAWBITMAP v32, 21, 14
  ; Draw bitmap (will be hidden be attributes.)
  SETVAR 24, 14
  CALLSUBNODE 34
  PRINTPGPH 34
ENDSUBNODE

; Reveal roamer picture by line loop.
SUBNODE 33
  SETATTRIBUTES 21, v24, 8, 1,  120 ; Bright, no flash, White paper, Black ink.
  INCVAR 24
  WAITFIXED 10
  IFVAR==(NUM) 24, 20
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Reveal roamer picture by cell - master loop.
SUBNODE 34
  SETVAR 23, 21
  CALLSUBNODE 35
  INCVAR 24
  IFVAR==(NUM) 24, 20
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Reveal roamer picture by cell - row loop.
SUBNODE 35
  SETATTRIBUTES v23, v24, 1, 1,  120 ; Bright, no flash, White paper, Black ink.
  INCVAR 23
  WAITFIXED 2
  IFVAR==(NUM) 23, 29
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Display roamer camera picture (from cache.)
SUBNODE 36
  PRINTPGPH 35
  WAITONE
  DRAWBITMAP v32, 21, 14
ENDSUBNODE

; Display summary cell event message.
SUBNODE 37
  SETLINEBANKHI 5
  PRINTPGPH v45
  SETLINEBANKHI 4
ENDSUBNODE

; Display summary and detailed cell event messages.
SUBNODE 38
  SETLINEBANKHI 5  
  PRINTPGPH v45
  SETLINEBANKHI 6
  PRINTPGPH v45
  SETLINEBANKHI 4
ENDSUBNODE

; Show description, and deactive cell (if not already inactive.) 
SUBNODE 39
  IFVAR==(NUM) 39, 1
    ; Show brief description.
    CALLSUBNODE 37
  ENDIF
  IFVAR==(NUM) 39, 0
    ; Alert sound and delay.
    CALLSUBNODE 58
    ; Show full description.
    CALLSUBNODE 38
    SETCELLINACTIVE 1
  ENDIF
ENDSUBNODE

; Show picture, description, and deactive cell (if not already inactive.) 
SUBNODE 40
  IFVAR==(NUM) 39, 1
    CALLSUBNODE 36
    CALLSUBNODE 37
  ENDIF
  IFVAR==(NUM) 39, 0
    CALLSUBNODE 58
    CALLSUBNODE 32
    CALLSUBNODE 38
    SETCELLINACTIVE 1
  ENDIF
ENDSUBNODE

; Fastroam out of control message loop.
SUBNODE 41
  ; Steps, speeding up.
  PRINTPGPH 84
  CALLSUBNODE 42
  WAITFIXED v29
  ; Speed up step rate.
  SUBVAR 29, 5
  PRINTPGPH 83
  CALLSUBNODE 42
  WAITFIXED v29
  ; Speed up step rate.
  SUBVAR 29, 5
  ; Set random orientation.
  GETRANDOM 3
  ADDVAR 0, 17
  SETWALKERGFX v0
  REFRESHWALKER
  IFVAR==(NUM) 29, 0
    ; Pause for dramatic effect.
    WAITONESEC
    ; Final set of rapid tones (no graphical movement.)
    CALLSUBNODE 43
    ; Add noise to roamer display.
    CALLSUBNODE 31
    ; Explosion tone.
    PLAYSOUND 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Play random, alternating, roamer step sound.
SUBNODE 42
  ; Pick step sound at random.
  GETRANDOM 3
  ADDVAR 12, v0
  ; Step sound can be disabled.
  PLAYSOUNDMUTE v12, v43
  SUBVAR 12, v0
  ; Alternate step sound.
  ADDVAR 12, 4
  IFVAR==(NUM) 12, 13
    SETVAR 12, 5
  ENDIF
ENDSUBNODE

; End of fastroam out of control (seperated for minimum delay between sounds.)
SUBNODE 43
  DECVAR 31
  IFVAR==(NUM) 31, 0
    BREAKSUB
  ENDIF
  CALLSUBNODE 42
  REPEATSUB
ENDSUBNODE

; Inconsequential explosion.
SUBNODE 44
  SETLINEBANKHI 7
  PRINTPGPH 64
  PRINTPGPH v45
  SETLINEBANKHI 4
ENDSUBNODE

; Vortex in meltdown ending.
SUBNODE 45
  ; Set paragraph area to cover whole screen.
  SETPGPHAREA 0, 0, 32, 24
  SETPGPHDELAY 1, 1
  ; TO DO - message/attributes/image/sound/snow barrage.
  ; - set up variables, then call a subnode loop.
  ; Set: noise start, bank number, line number, attributes number, bitmap xpos, bitmap ypos.
  SETVARFULL 8, 40704
  SETVAR 16, 2
  SETVAR 17, 64
  SETVAR 18, 7
  SETVAR 19, 2
  SETVAR 20, 2
  SETLINEBANKHI v2
  ; Print barrage of lines, bitmaps, and attributes with noise.
  CALLSUBNODE 46
  ; Freeze on red and black, with pilot tone.
  SETALLATTRIBUTES 66 ; Bright, no flash, Black paper, Red ink.
  PLAYSOUND 3
  ; Fake reset.
  CALLSUBNODE 48
  ; Wait.
  WAITTWOSECS
  ; Set: attributes bitmap xpos, bitmap ypos.
  SETVAR 19, 28
  SETVAR 20, 18
  ; Cranetron blares, forever.
  CALLSUBNODE 49
ENDSUBNODE

SUBNODE 46
  ; Print two paragraphs for each bitmap and noise.
  CALLSUBNODE 47
  CALLSUBNODE 47
  ; Draw Xenoxxx bitmap.
  DRAWBITMAP 16, v19, v20
  ; Play noise.
  PLAYMEMNOISE v8, 3
  ADDVAR 8, 3
  INCVAR 19
  INCVAR 19
  ; End of row?
  IFVAR==(NUM) 19, 24
    ; Only change attributes at end of row.
    LOADATTRIBUTES v18
    INCVAR 18
    ; Move down one row.
    INCVAR 20
    SETVAR 19, 2
    ; End of display?
    IFVAR==(NUM) 20, 17
      BREAKSUB
    ENDIF
  ENDIF
  REPEATSUB
ENDSUBNODE

; Prints paragraphs in bank then line sequence (banks 2-5, lines 0-19.)
SUBNODE 47
  PRINTPGPH v17
  ; Next bank.
  INCVAR 16
  ; End of bank set?
  IFVAR==(NUM) 16, 8
    ; Next line
    INCVAR 17
    SETVAR 16, 2
    ; End of line set?
    IFVAR==(NUM) 17, 84
      SETVAR 17, 64
    ENDIF
  ENDIF
  SETLINEBANKHI v16
ENDSUBNODE

; Fake reset sequence.
SUBNODE 48
  SETBORDER 7
  FILLSCREEN 0
  WAITONESEC
  SETALLATTRIBUTES 56 ; No bright, no flash, White paper, Black ink.
  ; (C) character and Xenoxxx copyright message.
  PRINTGFXCHAR 1, 0, 23
  PRINTLINE 54, 2, 23, 0  
ENDSUBNODE

; Perpetual blaring Cranetron.
SUBNODE 49
  DRAWBITMAP 9, v19, v20
  PRINTLINE 6, 12, 12, 0
  PLAYSOUND 0
  DRAWBITMAP 8, v19, v20
  PRINTLINE 40, 0, 12, 32
  WAITFIXED 40
  DECVAR 19
  IFVAR==(NUM) 19, 255
    SETVAR 19, 28
    DECVAR 20
    IFVAR==(NUM) 20, 255
      SETVAR 20, 18
    ENDIF
  ENDIF
  REPEATSUB
ENDSUBNODE

; Vortex in meltdown prelude.
SUBNODE 50
    SETLINEBANKHI 9 
    ; Change minimum delay between paragraphs.
    SETPGPHAREA 0, 21, 32, 3
    SETPGPHDELAY 100, 100
    ; Pause (for explosion to take effect.)
    WAITONESEC
    PRINTPGPH 89
    WAITTWOSECS
    ; Load non-existent attributes.
    LOADATTRIBUTES 6
    ; Message can be "overload" or "both offline."
    PRINTPGPH v33
    ; Dramatic pause.
    WAITTWOSECS
    ; Meltdown.
    CALLSUBNODE 45
ENDSUBNODE

; Irregular link termination.
SUBNODE 51
  ; Pause for disconnection to register.
  WAITTWOSECS
  WAITTWOSECS
  ; Change attributes to red+black and clear screen.
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  FILLSCREEN 0
  WAITONE
  ; Draw messages.
  SETLINEBANKHI 9
  PRINTLINE 92, 2, 10, 0
  PRINTLINE 93, 3, 12, 0
  PRINTLINE 94, 2, 14, 0
  ; Reveal messages.
  SETALLATTRIBUTES 66 ; Bright, no flash, Black paper, Red ink.
  ; Perpetual blaring.
  CALLSUBNODE 29
ENDSUBNODE

; Show next paragraph, then wait for key.
SUBNODE 52
  PRINTPGPH v33
  INCVAR 33
  WAITFORKEY
ENDSUBNODE

; Fire spread.
SUBNODE 53
  SCRATTRTOBUFF
  SPREADFIRE
  COPYATTRBUFFER
  PLAYSOUND 9
  DECVAR 31
  IFVAR==(NUM) 31, 0
    BREAKSUB
  ENDIF
  REPEATSUB
ENDSUBNODE

; Black and red screen of death.
SUBNODE 54
  ; Disconnection pause.
  WAITTWOSECS
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  FILLSCREEN 0
  WAITONE
  SETALLATTRIBUTES 66 ; Bright, no flash, Black paper, Red ink.
  PRINTLINE 88, 5, 8, 0
  SETLINEBANKHI 1
  PRINTLINE 66, 10, 12, 0
  ; Perpetual siren.
  CALLSUBNODE 29  
ENDSUBNODE

; Lost contact with roamer.
SUBNODE 55
  WAITONESEC
  ; Clear roamer display.
  SETATTRIBUTES 21, 14, 8, 6, 64 ; Bright, no flash, Black paper, Black ink.
  WAITTWOSECS
  ; Show "lost contact" message.
  PRINTPGPH 57
  ; Ensure roamer is cleared from occupied cell (loss can be triggered by non-occupiable.)
  REFRESHWALKER
  ; Clear and respawn.
  CLEARWALKER
  CALLSUBNODE 21
ENDSUBNODE

; Cultist broadcast interruption.
SUBNODE 56
  PRINTPGPH 58
  CALLSUBNODE 58
  DRAWBITMAP 37, 21, 14
ENDSUBNODE

; Clear (Black/Black) one attribute on screen and buffer.
SUBNODE 57
  SETATTRIBUTES v23, v24, 1, 1, 0
  SETATTRBUFFER
  SETATTRIBUTES v23, v24, 1, 1, 0
  SETATTRSCREEN
ENDSUBNODE

; Message alert.
SUBNODE 58
  PLAYSOUND 2
  PLAYSOUND 2
  WAITONESEC
ENDSUBNODE

; "No roamers left" ending.
SUBNODE 59
  SETLINEBANKHI 9
  PRINTPGPH 107
  WAITTWOSECS
  PRINTPGPH 108
  WAITONESEC
  ; Irregular link termination.
  CALLSUBNODE 51
ENDSUBNODE

; Load next image and attributes..
SUBNODE 60
  SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
  DRAWBITMAP v32, 0, 0
  CALLSUBNODE 4
  WAITONE
  LOADATTRIBUTES v32
  INCVAR 32
  SETATTRIBUTES 0, 18, 32, 6, 71 ; Bright, no flash, Black paper, White ink.
ENDSUBNODE

; Set up for code check in first part of game.
SUBNODE 61
  PRINTLINE 0, 0, 23, 32
  SETVAR 23, 0
  SETVAR 24, 23
  SETVAR 25, 0
ENDSUBNODE

; Clear paragraph area and show next paragraph.
SUBNODE 62
  CLEARPGPH
  PRINTPGPH v33
  INCVAR 33
ENDSUBNODE

; "Processing" message after part 1 code checks.
SUBNODE 63
  WAITONESEC
  PRINTLINE 7, 11, 23, 0
  WAITTWOSECS
  PRINTLINE 40, 0, 23, 32
  CLEARPGPH  
ENDSUBNODE

; MapEvent: Empty corridor (nothing happens.)
SUBNODE 64
  IFVAR==(NUM) 44, 1
    SETVAR 45, 65
    CALLSUBNODE 44
  ENDIF
ENDSUBNODE

; MapEvent: Nothing but high-level coolant pipes.
SUBNODE 65
  ; Only show description for first tile of this type encountered.
  IFVAR==(NUM) 63, 0
    INCVAR 63
    SETVAR 45, 64
    CALLSUBNODE 39    
  ENDIF
  IFVAR==(NUM) 44, 1
    SETVAR 45, 66
    CALLSUBNODE 44
  ENDIF
ENDSUBNODE

; MapEvent: Unusual passage.
SUBNODE 66
  IFVAR==(NUM) 44, 1
    SETVAR 45, 67
    CALLSUBNODE 44
  ENDIF
ENDSUBNODE

; MapEvent: Draft door central (explosion capture only.)
SUBNODE 67
  ; Set last draft door approached (used in case of explosion on a door space.)
  SETVAR 49, 1
  IFVAR==(NUM) 44, 1
    SETLINEBANKHI 7
    PRINTPGPH 72
    SETLINEBANKHI 4
    ; Mark as exploded (only required for this door, as RM-4 sleeps adjacent.)
    INCVAR 47
    ; Overdraw door with exploded door.
    DRAWBITMAP 46, 14, 9
    ; Replace door and South cell with "Empty" code after explosion.
    SETCELLCODEAT 14, 9, 64
    SETCELLCODEAT 14, 10, 64
    ; If RM4 is awake, also replace the North cell with "Empty" code.
    IFVAR==(NUM) 57, 2
      SETCELLCODEAT 14, 8, 64
    ENDIF
  ENDIF
ENDSUBNODE

; MapEvent: Dormitory (extension explosion capture only.)
SUBNODE 68
  IFVAR==(NUM) 44, 1
    SETVAR 45, 69
    CALLSUBNODE 44
  ENDIF
ENDSUBNODE

; MapEvent: Deep Brown (extension explosion capture only.)
SUBNODE 69
  ; Explosion triggers "Vortex stabalised" ending.
  IFVAR==(NUM) 44, 1
    SETLINEBANKHI 9 
    ; Change minimum delay between paragraphs.
    SETPGPHAREA 0, 21, 32, 3
    SETPGPHDELAY 100, 100
    PRINTPGPH 64
    ; Cultist.
    DRAWBITMAP 37, 21, 14
    PRINTPGPH 65
    ; Reboot delay.
    WAITTWOSECS
    ; Restore ROAMos picture.
    DRAWBITMAP 32, 21, 14
    ; Line sequence.
    SETVAR 37, 6
    SETVAR 33, 66
    CALLSUBNODE 7
    ; Operatives standing down delay
    WAITTWOSECS
    ; If solider was killed, vortex melts down instead.
    IFVAR==(NUM) 62, 3
      WAITTWOSECS
      PRINTPGPH 112
      WAITTWOSECS
      PRINTPGPH 113
      SETVAR 33, 90
      CALLSUBNODE 50
    ENDIF
    ; Soldier.
    DRAWBITMAP 41, 21, 14
    ; Line sequence.
    SETVAR 37, 4
    CALLSUBNODE 7
    ; Vortex stabilisation delay.
    WAITTWOSECS
    ; Line sequence.
    SETVAR 37, 3
    CALLSUBNODE 7
    ; Fade out soldier.
    SETVAR 31, 10
    CALLSUBNODE 30
    ; Dramatic pause.
    WAITTWOSECS
    ; Clear everthing and reset paragraph area.
    SETALLATTRIBUTES 64 ; Bright, no flash, Black paper, Black ink.
    FILLSCREEN 0
    WAITONE
    SETALLATTRIBUTES 71 ; Bright, no flash, Black paper, White ink.
    ; Line sequence.
    SETVAR 37, 3
    CALLSUBNODE 7
    ; Let twist ending sink in.
    WAITFORKEY
    ; Line sequence.
    SETVAR 37, 6
    CALLSUBNODE 7
    ; Black and red screen of death.
    CALLSUBNODE 54
  ENDIF
ENDSUBNODE

; MapEvent: Coolant compressor (extension explosion capture only.)
SUBNODE 70
  IFVAR==(NUM) 44, 1
    ; Explosion triggers "Vortex meltdown" ending, with "overload" message.
    SETVAR 33, 90
    CALLSUBNODE 50
  ENDIF
ENDSUBNODE

; MapEvent: Card Door to server room. (explosion capture only.)
SUBNODE 71
  ; Can blow hole. Changes graphic, enables access.
  ; - also triggers CO2 release and appearance of unconcious monster.
  IFVAR==(NUM) 44, 1
    IFVAR==(NUM) 51, 1
      ; Door already breached.
      SETVAR 45, 87
      CALLSUBNODE 44  
      BREAKSUB
    ENDIF
    ; Mark door as breached.
    INCVAR 51
    ; Overdraw door with exploded graphic (different to draft doors, includes edge of servers.)
    DRAWBITMAP 48, 6, 17
    ; Show explosion message.
    SETLINEBANKHI 7
    PRINTPGPH 72
    SETLINEBANKHI 4
    ; Pause for smoke to spread.
    WAITTWOSECS
    ; Server room fire detection and CO2 release.
    PRINTPGPH 55
    WAITONESEC
    PRINTPGPH 52
    WAITTWOSECS
    PRINTPGPH 53
    WAITTWOSECS
    WAITTWOSECS
    PRINTPGPH 56
    ; Spawn unconcious monster outside server room.
    SETCELLCODE 105
    ; Replace door cell with "Empty" code.
    SETCELLCODEAT 6, 17, 64
    ; Make coolant compresser cells accessible (monsters have left.)
    SETCELLCODEAT 28, 2, 93
    SETCELLCODEAT 28, 6, 94
  ENDIF
ENDSUBNODE

; MapEvent: Blast door (welded shut.)
SUBNODE 72
  IFVAR==(NUM) 44, 1
    SETVAR 45, 68
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 66
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Generator door.
SUBNODE 73
  IFVAR==(NUM) 44, 1
    SETVAR 45, 71
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 67
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Blast door (wedged open.)
SUBNODE 74
  IFVAR==(NUM) 44, 1
    SETVAR 45, 71
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 68
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Vehicle door (too tough for roamer explosions.)
SUBNODE 75
  IFVAR==(NUM) 44, 1
    SETVAR 45, 68
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 69
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Draft door (initially held shut by pressure.)
SUBNODE 76
  ; Explosion handler, for when no longer held shut by pressure.
  IFVAR==(NUM) 44, 1
    IFVAR==(NUM) 49, 0
      ; West door was last approached
      CALLSUBNODE 108
      BREAKSUB
    ENDIF
    IFVAR==(NUM) 49, 1
      ; Central door was last approached
      CALLSUBNODE 67
      BREAKSUB
    ENDIF
    ; Otherwise, East door was last approached.
    CALLSUBNODE 109
    BREAKSUB
  ENDIF
  ; Roamer can open door once AHU is turned off.
  IFVAR==(NUM) 55, 1
    PRINTPGPH 60
    BREAKSUB
  ENDIF
  ; Always shows alert and full description while way is blocked.
  SETVAR 45, 70
  CALLSUBNODE 58
  CALLSUBNODE 38
ENDSUBNODE

; MapEvent: Card access door (for Deep Brown.)
SUBNODE 77
  IFVAR==(NUM) 44, 1
    CALLSUBNODE 71
    BREAKSUB
  ENDIF
  ; Always shows alert and full description while way is blocked.
  SETVAR 45, 71
  CALLSUBNODE 58
  CALLSUBNODE 38
ENDSUBNODE

; MapEvent: Old communications room (X-80 and roamers.)
SUBNODE 80
  IFVAR==(NUM) 44, 1
    IFVAR==(NUM) 62, 3
      ; Extra cultist sequence if soldier was killed.
      CALLSUBNODE 56
      SETLINEBANKHI 9
      PRINTPGPH 95
      WAITTWOSECS
      PRINTPGPH 96
      WAITTWOSECS
      PRINTPGPH 97
      SETLINEBANKHI 4
      WAITFORKEY
    ENDIF
    ; Continue with "lost communication link" ending.
    CALLSUBNODE 51
  ENDIF
  SETVAR 45, 72
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Dormitory (entrance space.)
SUBNODE 81
  IFVAR==(NUM) 44, 1
    CALLSUBNODE 68
    BREAKSUB
  ENDIF
  SETVAR 45, 73
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Bins (within bin store.)
SUBNODE 82
  IFVAR==(NUM) 44, 1
    IFVAR==(NUM) 53, 0
      ; First explosion triggers TBOT message.
      SETLINEBANKHI 7
      PRINTPGPH 73
      SETLINEBANKHI 4
      INCVAR 53
      BREAKSUB
    ENDIF
    ; Second explosion triggers wrath of TBOT.
    SETLINEBANKHI 7
    PRINTPGPH 88
    ; Disconnection ending (as TBOT smashes X-80 system.)
    CALLSUBNODE 51
  ENDIF
  SETVAR 45, 74
  CALLSUBNODE 39
ENDSUBNODE


; MapEvent: Sick bay (bumcrawler.)
SUBNODE 83
  IFVAR==(NUM) 44, 1
    SETVAR 45, 74
    CALLSUBNODE 44
    SETVAR 52, 1
    BREAKSUB
  ENDIF
  SETVAR 32, 34
  SETVAR 45, 75
  IFVAR==(NUM) 52, 0
    ; Only show picture if no explosion.
    CALLSUBNODE 40
    BREAKSUB
  ENDIF
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Kitchen (goujon croutons.)
SUBNODE 84
  IFVAR==(NUM) 44, 1
    IFVAR==(NUM) 54, 0
      SETLINEBANKHI 7
      PRINTPGPH 75
      SETLINEBANKHI 4
      INCVAR 54
      BREAKSUB
    ENDIF
    SETVAR 45, 90
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 32, 36
  SETVAR 45, 76
  IFVAR==(NUM) 54, 0
    ; Only show picture if no explosion.
    CALLSUBNODE 40
    BREAKSUB
  ENDIF
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Abandoned studio.
SUBNODE 85
  IFVAR==(NUM) 44, 1
    SETVAR 45, 76
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 32, 42
  SETVAR 45, 77
  CALLSUBNODE 40
ENDSUBNODE

; MapEvent: Switchgear (interferes with poorly-shieled roamer.)
SUBNODE 86
  SETVAR 45, 78
  CALLSUBNODE 39
  IFVAR==(NUM) 57, 0
    INCVAR 57
    ; Interference.
    SNOWFOR 50
    ; Retuning and discovery of dormant RM-4.
    PRINTPGPH 85
    SNOWFOR 50
    WAITONESEC
    PRINTPGPH 86
    WAITTWOSECS
    PRINTPGPH 87
    WAITTWOSECS
    PRINTPGPH 88
    ; REMOVED - Show sleeping roamer facing North.
    ;DRAWBITMAP 20, 14, 8
    ; Set wake-up cell positions.
    SETVAR 38, 107
    SETCELLCODEAT 13, 7, v38
    SETCELLCODEAT 14, 6, v38
    SETCELLCODEAT 15, 7, v38
    SETCELLCODEAT 14, 10, 107
  ENDIF
  IFVAR==(NUM) 44, 1
    ; Run "Deep Brown has backup power, legacy system doesn't" ending.
    SETLINEBANKHI 9
    SNOWFOR 50
    PRINTPGPH 109
    SNOWFOR 50
    WAITONESEC
    PRINTPGPH 110
    WAITTWOSECS
    PRINTPGPH 102
    WAITONESEC
    PRINTPGPH 111
    ; Unexpected link termination ending.
    CALLSUBNODE 51
  ENDIF
  ; Has roamer been woken?
  IFVAR==(NUM) 57, 2
    BREAKSUB
  ENDIF
  ; If not, highlight sleeping roamer location again.
  SETATTRIBUTES 14, 8, 1, 1, 199 ; Bright, flash, Black paper, White ink.
  WAITTWOSECS
  SETATTRIBUTES 14, 8, 1, 1, 120 ; Bright, no flash, White paper, Black ink.
ENDSUBNODE

; MapEvent: Diesel generator.
SUBNODE 87
  IFVAR==(NUM) 44, 1 
    ; Change minimum delay between paragraphs.
    SETPGPHAREA 0, 21, 32, 3
    SETPGPHDELAY 100, 100
    ; Junk begins to smoulder (for both endings.)
    SETLINEBANKHI 9
    PRINTPGPH 98
    ; Seed the fire at generator.
    SETATTRIBUTES 11, 19, 1, 1, 80 ; Bright, no flash, Red paper, Black ink.
    IFVAR==(NUM) 55, 0
      ; Fire controlled, generator shut down.
      PRINTPGPH 99
      IFVAR==(NUM) 58, 1
        ; Extra message if DB-E had given "destroy" directive.
        PRINTPGPH 100
      ENDIF
      PRINTPGPH 101
      PRINTPGPH 102
      PRINTPGPH 103
      PRINTPGPH 111
      ; Fire goes out.
      SETATTRIBUTES 11, 19, 1, 1, 120 ; Bright, no flash, White paper, Black ink.
      PRINTPGPH 56
      PRINTPGPH 110
      ; Unexpected link termination ending.
      CALLSUBNODE 51
    ENDIF
    ; Plug some holes (prevents fire spreading to text area and hidden passage.)
    SETCELLCODEAT 11, 21, 0
    SETCELLCODEAT 17, 21, 0
    SETCELLCODEAT 27, 10, 0
    IFVAR==(NUM) 58, 1
      ; Extra messages as fire grows, if DB-E had given "destroy" directive.
      PRINTPGPH 104
      WAITTWOSECS
      PRINTPGPH 105
      WAITTWOSECS
      PRINTPGPH 106
      WAITTWOSECS
      ; Thank you, fire discovery, death squad notified.
      PRINTPGPH 80
      PRINTPGPH 81
    ENDIF
    WAITFORKEY
    IFVAR==(NUM) 58, 1
      ; Extra messages as fire grows, if DB-E had given "destroy" directive.
      PRINTPGPH 82
    ENDIF
	PRINTPGPH 102
    WAITONESEC
    IFVAR==(NUM) 58, 1
      ; Extra messages as fire grows, if DB-E had given "destroy" directive.
      PRINTPGPH 84
    ENDIF
    PRINTPGPH 101
    ; Fire breaks out (38 in total cycles fills whole tunnel area precisely.)
    SETVAR 31, 8
    CALLSUBNODE 53 
    ; Change minimum delay between paragraphs.
    SETPGPHAREA 0, 21, 32, 3
    SETPGPHDELAY 1, 1
    PRINTPGPH 110    
    SETVAR 31, 30
    CALLSUBNODE 53
    IFVAR==(NUM) 58, 1
      ; Black and red screen of death, if DB-E had given "destroy" directive.
      CALLSUBNODE 54
    ENDIF
    ; Otherwise, "unexpected link termination" ending.
    CALLSUBNODE 51
  ENDIF
  SETVAR 45, 79
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Server room entrance (Deep Brown.)
SUBNODE 88
  IFVAR==(NUM) 44, 1
    ; Subnode 69 ends game, so no need to break afterwards.
    CALLSUBNODE 69
  ENDIF
  SETVAR 45, 80
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Air handling unit (causing negative pressure in South section.)
SUBNODE 89
  IFVAR==(NUM) 44, 1
    IFVAR==(NUM) 55, 0
      ; Disable negative pressure on first explosion only.
      SETLINEBANKHI 7
      PRINTPGPH 77
      WAITTWOSECS
      PRINTPGPH 78
      SETLINEBANKHI 4
      ; Make all pressure door cells accessible.
      SETCELLACCESSAT 1, 11, 1
      SETCELLACCESSAT 14, 9, 1
      SETCELLACCESSAT 23, 12, 1
      ; Extra message if DB-A has advised destruction of tunnel.
      IFVAR==(NUM) 58, 1
        PRINTPGPH 14
      ENDIF
      INCVAR 55
      BREAKSUB
    ENDIF
    SETVAR 45, 89
    CALLSUBNODE 44
    BREAKSUB    
  ENDIF
  SETVAR 45, 81
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Abandoned car (registration plate holds the roamer safety code.)
SUBNODE 90
  IFVAR==(NUM) 44, 1
    SETVAR 45, 79
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 32, 35
  SETVAR 45, 82
  CALLSUBNODE 40
  ; Print registration plate even if cell was inactive.
  PRINTPGPH 33
ENDSUBNODE

; MapEvent: Vortex entrance.
SUBNODE 91
  ; Cannot cause explosion here, as entering loses contact with roamer.
  ; Final transmission as the roamer disappears forever.
  SETVAR 45, 83
  CALLSUBNODE 39
  ; Fade out roamer display.
  SETVAR 31, 10
  CALLSUBNODE 30
  ; Lose signal.
  CALLSUBNODE 55
ENDSUBNODE

; MapEvent: Ventilation shaft.
SUBNODE 92
  IFVAR==(NUM) 44, 1
    SETVAR 45, 80
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 84
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Coolant compressor (North.)
SUBNODE 93
  ; If monsters have not already left to protect Deep Brown:
  IFVAR==(NUM) 51, 0
    ; First attempt draws picture and gives "do not proceed" warning.
    IFVAR==(NUM) 39, 0
      SETVAR 32, 39
      SETVAR 45, 96
      CALLSUBNODE 40
      ; Set relevant cell as inactive (because all cells are initially inaccessible.)
      IFVAR==(NUM) 41, 93
        SETCELLINACTIVEAT 28, 2, 1
        BREAKSUB
      ENDIF
      SETCELLINACTIVEAT 28, 6, 1
      BREAKSUB
    ENDIF
    ; Roamer lost on subsequent attempts.
    CALLSUBNODE 55
  ENDIF
  ; If explosion, call game-ending subnode 70.
  IFVAR==(NUM) 44, 1
    CALLSUBNODE 70
  ENDIF
  ; If monsters have left to protect Deep Brown (which resets 93 & 94 inactive flags):
  SETVAR 45, 85
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Heat exchanger (South.)
SUBNODE 94
  ; Same behaviour as North compressor.
  CALLSUBNODE 93
ENDSUBNODE

; MapEvent: Coolant control (never accessible due to bum monsters.)
SUBNODE 95
  ; Roamer lost on subsequent entry attempts.
  IFVAR==(NUM) 39, 1
    CALLSUBNODE 55    
  ENDIF
  ; First attempt draws picture and gives "do not proceed" warning.
  SETVAR 32, 39
  SETVAR 45, 96
  CALLSUBNODE 40
  ; Set inactive flag for cell, as cannot done via roamer access.
  SETCELLINACTIVEAT 28, 4, 1  
ENDSUBNODE

; MapEvent: Filthy floor.
SUBNODE 96
  IFVAR==(NUM) 44, 1
    SETVAR 45, 81
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 86
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Canteen area (message only on first activation.)
SUBNODE 97
  IFVAR==(NUM) 44, 1
    SETVAR 45, 82
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 87
  CALLSUBNODE 39
  ; Clear active flag of both cells.
  SETCELLINACTIVEAT 13, 13, 1
  SETCELLINACTIVEAT 13, 14, 1
ENDSUBNODE

; MapEvent: Automated turret outside.
SUBNODE 98
  ; Roamer destroyed after first warning.
  IFVAR==(NUM) 39, 1
    CALLSUBNODE 55
    BREAKSUB
  ENDIF
  SETVAR 45, 88
  ; N.B. Subnode 39 sets the approach cell inactive, rather than this cell.
  CALLSUBNODE 39
  ; Set inactive flag manually.
  SETCELLINACTIVEAT 17, 21, 1
ENDSUBNODE

; MapEvent: Slippery steps (roamer cannot climb them.)
SUBNODE 99
  ; Cannot access for explosion.
  ; Roamer can only open door to this area once AHU is turned off.
  IFVAR==(NUM) 55, 1
    SETVAR 45, 89
    ; N.B. adjacent cell becomes inactive, but no problem in this case (was already inactive.)
    CALLSUBNODE 39
    BREAKSUB
  ENDIF
  ; Prints full generator door message (to remind player what needs doing.
  CALLSUBNODE 73
ENDSUBNODE

; MapEvent: Dead soldier.
SUBNODE 100
  IFVAR==(NUM) 44, 1
    SETVAR 45, 83
    CALLSUBNODE 44
    SETVAR 60, 1
    BREAKSUB
  ENDIF
  SETVAR 32, 38
  SETVAR 45, 90
  IFVAR==(NUM) 60, 1
    ; Do not show picture after first explosion.
    CALLSUBNODE 39
    BREAKSUB
  ENDIF
  CALLSUBNODE 40
ENDSUBNODE

; MapEvent: Live soldier (communicates, cultist banter, can be exploded.)
SUBNODE 101
  IFVAR==(NUM) 44, 1
    ; Solider appears.
    DRAWBITMAP 41, 21, 14
    SETLINEBANKHI 9
    PRINTPGPH 65
    SETLINEBANKHI 4
    ; Soldier is removed from game (too injured to hide from alerted monsters.)
    SETCELLCODE 64
    ; Mark solider as dead (will affect Deep Brown explosion.)
    SETVAR 62, 3
    ; Cultist instructions will trigger after the next roamer (if any) respawns.
    BREAKSUB
  ENDIF
  IFVAR==(NUM) 39, 0
    SETCELLINACTIVE 1
    CALLSUBNODE 58
    ; Soldier's picture appears.
    SETVAR 32, 41
    CALLSUBNODE 32
    ; Soldier explains the situation.
    PRINTPGPH 45
    ; Request to distract monsters only appears if Deep Brown door still secure.
    IFVAR==(NUM) 51, 0
      SETVAR 62, 1
      WAITTWOSECS
      PRINTPGPH 46
      WAITTWOSECS
      PRINTPGPH 47
    ENDIF
    WAITFORKEY
    ; Cultist interrupts.
    CALLSUBNODE 56
    PRINTPGPH 41
    WAITTWOSECS
    PRINTPGPH 42
    WAITFORKEY
    ; Solider retorts.
    DRAWBITMAP 41, 21, 14
    PRINTPGPH 48
    WAITFORKEY
    ; Request to disable Deep Brown if door has already been breached.
    IFVAR==(NUM) 51, 1
      SETVAR 62, 2
      WAITTWOSECS
      PRINTPGPH 59
      WAITTWOSECS
      PRINTPGPH 51
      WAITFORKEY      
    ENDIF
    ; Show roamer picture again.
    DRAWBITMAP 32, 21, 14
    ; Deep Brown Alpha provides different objectives.
    PRINTPGPH 10
    WAITTWOSECS
    PRINTPGPH 11
    WAITTWOSECS
    PRINTPGPH 12
    WAITTWOSECS
    WAITTWOSECS
    PRINTPGPH 13
    IFVAR==(NUM) 55, 0
      ; Extra directive if South AHU still active.
      PRINTPGPH 61
    ENDIF
    ; Flag request from DB-A.
    SETVAR 58, 1
    BREAKSUB
  ENDIF
  ; Soldier's picture appears regardless if encountered when cell inactive.
  SETVAR 32, 41
  CALLSUBNODE 36
  IFVAR==(NUM) 62, 1
    ; Deep Brown door still secure.
    IFVAR==(NUM) 51, 0
      ; Distraction request.
      PRINTPGPH 47
      BREAKSUB
    ENDIF
    ; Deep Brown door breached, "still too many", and change of request.
    SETVAR 62, 2
    PRINTPGPH 49
    WAITTWOSECS
    PRINTPGPH 50
    WAITTWOSECS
    PRINTPGPH 51
    BREAKSUB    
  ENDIF
  ; Summary of Deep Brown request.
  PRINTPGPH 51
ENDSUBNODE

; MapEvent: Goujons (moist, then dry if exploded, and disappears if exploded again.)
SUBNODE 102
  IFVAR==(NUM) 44, 1
    IFVAR==(NUM) 61, 0
      ; Moist goujons become dry.
      INCVAR 61
      ; Reactivate cell (so "Dry" message appears on next encounter.)
      ; Former bug with SETCELLINACTIVE 0: so used SETCELLCODE 102 instead as a workaround.
      ;SETCELLINACTIVE 0
      SETCELLCODE 102
      BREAKSUB
    ENDIF
    ; Dry goujons disappear.
    SETCELLCODE 64
    BREAKSUB
  ENDIF
  IFVAR==(NUM) 61, 1
    SETVAR 32, 40
    CALLSUBNODE 36
    ; Different message for dry goujons.
    SETLINEBANKHI 5  
    PRINTPGPH 91
    IFVAR==(NUM) 39, 0
      SETLINEBANKHI 6
      PRINTPGPH 97
      SETCELLINACTIVE 1
    ENDIF
    SETLINEBANKHI 4
    BREAKSUB
  ENDIF
  ; Standard message for moist goujons.
  SETVAR 32, 40
  SETVAR 45, 91
  CALLSUBNODE 40
ENDSUBNODE

; MapEvent: Magic door (push three times to open.)
SUBNODE 103
  IFVAR==(NUM) 56, 2
    SETCELLCODEAT 27, 10, 66
    SETVAR 45, 65
    CALLSUBNODE 39
  ENDIF
  INCVAR 56
ENDSUBNODE

; MapEvent: The Explosion Fairy (grants infinite explosions.)
SUBNODE 104
  ; Record visit.
  SETVAR 59, 1
  IFVAR==(NUM) 44, 1
    ; Draw cross face over fairy picture.
    DRAWBITMAP 44, 21, 14
    DRAWBITMAP 45, 24, 16
    WAITTWOSECS
    ; Indignant message.
    SETLINEBANKHI 7
    PRINTPGPH 84
    ; Revenge of the Explosion Faerie (irregular link termination.)
    CALLSUBNODE 51
  ENDIF
  SETVAR 32, 44
  SETVAR 45, 92
  CALLSUBNODE 40
ENDSUBNODE

; MapEvent: Unconcious monster (dormant until triggered by DB-E CO2 release.)
SUBNODE 105
  ; Monster runs off if awakened by explosion.
  IFVAR==(NUM) 44, 1
    SETLINEBANKHI 7
    PRINTPGPH 85
    SETLINEBANKHI 4
    SETCELLCODEAT 6, 18, 64
    BREAKSUB
  ENDIF
  SETVAR 32, 43
  SETVAR 45, 93
  CALLSUBNODE 40
ENDSUBNODE

; MapEvent: Not used (was going to be for temporarily blocking exits.)
SUBNODE 106
ENDSUBNODE

; MapEvent: North roamer awakens (dormant initially.)
SUBNODE 107
  ; Message alert.
  CALLSUBNODE 58
  ; Reset current cell and dormant roamer cell, however discovery took place.
  SETCELLCODE 64
  SETCELLCODEAT 14, 8, 64    
  IFVAR==(NUM) 57, 1
    ; Roamer location was discovered by retuning earlier.
    ; Clear wake-up cell positions.
    SETVAR 38, 65
    SETCELLCODEAT 13, 7, v38
    SETCELLCODEAT 14, 6, v38
    SETCELLCODEAT 15, 7, v38
    SETCELLCODEAT 14, 10, 64
  ENDIF
  IFVAR==(NUM) 57, 0
    ; Roamer has been stumbled upon.
    ; Extra messages.
    PRINTPGPH 86
    WAITONESEC
    PRINTPGPH 85
    WAITTWOSECS
  ENDIF
  IFVAR==(NUM) 47, 0
    ; If central door not already exploded:
    ; Set dormant roamer cell to explosion capture.
    SETCELLCODEAT 14, 8, 67
    ; Set south side of door to explosion capture.
    SETCELLCODEAT 14, 10, 67
    ; Also make central door last one approached.
    ; (in case player explodes roamer before re-entering the cell.)
    SETVAR 49, 1
  ENDIF  
  ; Handover sequence is the same from here.
  PRINTPGPH 74
  WAITONESEC
  PRINTPGPH 95
  WAITONESEC
  PRINTPGPH 74
  WAITTWOSECS
  PRINTPGPH 90
  WAITTWOSECS
  ; Remove current roamer.
  CLEARWALKER
  PRINTPGPH 89
  WAITONESEC
  ; Change current roamer number.
  SETVAR 42, 6
  ; Change next roamer number.
  IFVAR==(NUM) 48, 1
    ; RM-3 made discovery.
    SETVAR 48, 0
  ENDIF
  IFVAR==(NUM) 48, 3
    ; RM-6 made discovery.
    SETVAR 48, 1
  ENDIF
  ; Hand control to discovered roamer.
  SETWALKERGFX 20
  CREATEWALKER 14, 8
  ; Mark discovered roamer as awake.
  SETVAR 57, 2
  ; Reset mute flag to play step sounds with new roamer.
  SETVAR 43, 0
  ; Show animation and start message.
  SETVAR 31, 3
  CALLSUBNODE 23
  PRINTPGPH 74
ENDSUBNODE

; MapEvent: Draft door East (explosion capture only.)
SUBNODE 108
  ; Set last draft door approached (used in case of explosion on a door space.)
  SETVAR 49, 0
  IFVAR==(NUM) 44, 1
    SETLINEBANKHI 7
    PRINTPGPH 72
    SETLINEBANKHI 4
    ; Overdraw door with exploded door.
    DRAWBITMAP 46, 1, 11
    ; Replace door, South, and North cells with "Empty" code after explosion.
    SETCELLCODEAT 1, 10, 64
    SETCELLCODEAT 1, 11, 64
    SETCELLCODEAT 1, 12, 64
  ENDIF
ENDSUBNODE

; MapEvent: Draft door West (explosion capture only.)
SUBNODE 109
  ; Set last draft door approached (used in case of explosion on a door space.)
  SETVAR 49, 2
  IFVAR==(NUM) 44, 1
    SETLINEBANKHI 7
    PRINTPGPH 72
    SETLINEBANKHI 4
    ; Overdraw door with exploded door.
    DRAWBITMAP 47, 23, 12
    ; Replace door, South, and North cells with "Empty" code after explosion.
    SETCELLCODEAT 22, 12, 64
    SETCELLCODEAT 23, 12, 64
    SETCELLCODEAT 24, 12, 64
  ENDIF
ENDSUBNODE

; MapEvent: Lift car debris.
SUBNODE 110
  IFVAR==(NUM) 44, 1
    SETVAR 45, 86
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 94
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Crater.
SUBNODE 111
  IFVAR==(NUM) 44, 1
    SETVAR 45, 86
    CALLSUBNODE 44
    BREAKSUB
  ENDIF
  SETVAR 45, 95
  CALLSUBNODE 39
ENDSUBNODE

; MapEvent: Cultist message ("Flesh is weak.")
SUBNODE 112
  CALLSUBNODE 56
  PRINTPGPH 36
  SETCELLCODE 65
ENDSUBNODE

; MapEvent: Cultist message ("He is coming.")
SUBNODE 113
  CALLSUBNODE 56
  PRINTPGPH 37
  SETCELLCODE 65
ENDSUBNODE

; MapEvent: Cultist message ("Taste them.")
SUBNODE 114
  CALLSUBNODE 56
  PRINTPGPH 38
  SETCELLCODE 65
ENDSUBNODE

; MapEvent: Cultist message ("Join us.")
SUBNODE 115
  CALLSUBNODE 56
  PRINTPGPH 39
  SETCELLCODE 65
ENDSUBNODE

; MapEvent: Ambient observation (Skittering.)
SUBNODE 116
  PRINTPGPH 91
  SETCELLCODE 64
ENDSUBNODE

; MapEvent: Ambient observation (Echoing fart.)
SUBNODE 117
  PRINTPGPH 92
  SETCELLCODE 65
ENDSUBNODE

; MapEvent: Ambient observation (Banging pipes.)
SUBNODE 118
  PRINTPGPH 93
  SETCELLCODE 65
ENDSUBNODE

; MapEvent: Ambient observation (Figure crosses in distance.)
SUBNODE 119
  PRINTPGPH 94
  SETCELLCODE 64
ENDSUBNODE

; MapEvent: Anomaly (crab smells.)
SUBNODE 120
  CALLSUBNODE 58
  SETLINEBANKHI 8
  PRINTPGPH 71
  WAITTWOSECS
  PRINTPGPH 72
  SETCELLCODE 65
  SETLINEBANKHI 4
ENDSUBNODE

; MapEvent: Anomaly (warp.)
SUBNODE 121
  IFVAR==(NUM) 50, 0
    ; Set warp flag.
    INCVAR 50
    ; Clear cell code.
    SETCELLCODE 65
    ; Warp walker and change facing towards the secret passage.
    SETWALKERGFX 18
    WARPWALKER 26, 10
    ; Set cell codes for return warp.
    SETCELLCODEAT 26, 8, 121
    SETCELLCODEAT 26, 12, 121
    BREAKSUB
  ENDIF
  ; Return warp.
  WARPWALKER 2, 7
  ; Clear both return warp cell codes.
  SETCELLCODEAT 26, 8, 64
  SETCELLCODEAT 26, 12, 64
ENDSUBNODE

; MapEvent: Anomaly (fake reset)
SUBNODE 122
  ; Disable cell.
  SETCELLCODE 65
  ; Preserve tunnel attributes.
  SCRATTRTOBUFF
  ; Clear display with attributes.
  SETBORDER 7
  SETALLATTRIBUTES 0 ; No bright, no flash, Black paper, Black ink.
  WAITONESEC
  SETALLATTRIBUTES 63 ; No bright, no flash, White paper, White ink.
  ; Clear bottom line.
  PRINTPGPH 40
  ; Print (C) character and Xenoxxx copyright message on bottom row.
  PRINTGFXCHAR 1, 0, 23
  PRINTLINE 54, 2, 23, 30
  ; Reveal message.
  SETATTRIBUTES 0, 23, 32, 1, 56 ; No bright, no flash, White paper, Black ink.
  WAITONESEC
  WAITFORKEY
  ; Restore border, blank screen.
  SETBORDER 0
  SETALLATTRIBUTES 0 ; No bright, no flash, Black paper, Black ink.
  WAITONESEC
  ; Restore border and tunnel attributes.
  COPYATTRBUFFER
  ; Reload tunnel attribute map to buffer.
  SETATTRBUFFER
  LOADATTRIBUTES 5  
  SETATTRSCREEN
ENDSUBNODE

; MapEvent: Anomaly (block exits.)
SUBNODE 123
  ; Clear cell.
  SETCELLCODE 65
  ; Hide South exit.
  SETVAR 23, 1
  SETVAR 24, 6
  CALLSUBNODE 57
  ; Hide NE exit
  SETVAR 23, 5
  SETVAR 24, 1
  CALLSUBNODE 57
ENDSUBNODE

; MapEvent: Anomaly (computer love.)
SUBNODE 124
  CALLSUBNODE 58
  SETLINEBANKHI 8
  PRINTPGPH 67
  WAITTWOSECS
  PRINTPGPH 68
  WAITONESEC
  PRINTPGPH 69
  WAITTWOSECS
  PRINTPGPH 70
  PRINTPGPH 70
  PRINTPGPH 70
  SETCELLCODE 65
  SETLINEBANKHI 4
ENDSUBNODE

; MapEvent: Anomaly (snow effect.)
SUBNODE 125
  SNOWFOR 50
  SETCELLCODE 65
ENDSUBNODE

; MapEvent: Anomaly (Knock-knock joke.)
SUBNODE 126
  WAITONE
  ; Clear roamer display.
  SETVAR 0, 255
  FILLAREA 21, 14, 8, 6, v0
  WAITONE
  ; Show the Chap's Papa.
  DRAWBITMAP 12, 23, 15
  ; The joke.
  SETLINEBANKHI 8
  PRINTPGPH 64
  WAITTWOSECS
  PRINTPGPH 65
  WAITTWOSECS
  PRINTPGPH 66
  WAITTWOSECS
  ; Restore roamer display.
  DRAWBITMAP 32, 21, 14
  SETCELLCODE 65
  SETLINEBANKHI 4  
ENDSUBNODE

; MapEvent: Anomaly (Cranetron.)
SUBNODE 127
  ; Preserve tunnel attributes.
  SCRATTRTOBUFF
  ; Load Cranetron's attributes.
  LOADATTRIBUTES 0
  WAITONE  
  ; Cranetron blares (two cycles.)
  SETVAR 23, 21
  SETVAR 24, 15
  SETVAR 36, 2
  CALLSUBNODE 9
  ; Restore tunnel attributes.
  COPYATTRBUFFER
  ; Reload tunnel attribute map to buffer.
  SETATTRBUFFER
  LOADATTRIBUTES 5  
  SETATTRSCREEN
  ; Restore roamer display.
  DRAWBITMAP 32, 21, 14
  ; Change cell to pipe only.
  SETCELLCODE 65
ENDSUBNODE
