-
Notifications
You must be signed in to change notification settings - Fork 10
/
script18.s
391 lines (359 loc) · 12.3 KB
/
script18.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
include macros.s
include mainsym.s
; Script 18, nether tunnel
org scriptCodeStart
dc.w TunnelMachine
dc.w TunnelMachineItems
dc.w TunnelMachineRun
dc.w RadioJormungandr
dc.w RadioJormungandrRun
dc.w DestroyPlan
dc.w MoveLargeTank
dc.w MoveFireball
dc.w RadioHackerWarning
; Tunnel machine script routine
;
; Parameters: -
; Returns: -
; Modifies: various
tmChoice = menuCounter
TunnelMachine: lda scriptF ;If the destroy plan script running,
bne TM_Wait ;do not exec this script yet
lda #PLOT_BATTERY
jsr GetPlotBit
beq TM_NoBattery
lda #PLOT_FUEL
jsr GetPlotBit
beq TM_NoFuel
lda #$00
sta tmTime1
sta tmTime2
sta tmChoice
lda #<EP_TUNNELMACHINERUN
ldx #>EP_TUNNELMACHINERUN
jsr SetScript
ldx #MENU_INTERACTION
jsr SetMenuMode
lda #<txtReady
ldx #>txtReady
jsr PrintPanelTextIndefinite
jmp TMR_RedrawNoSound
TM_NoBattery: lda #<txtNoBattery
ldx #>txtNoBattery
bne TM_TextCommon
TM_NoFuel: lda #1
sta shakeScreen
lda #SFX_GENERATOR
jsr PlaySfx
lda #<txtNoFuel
ldx #>txtNoFuel
TM_TextCommon: ldy #REQUIREMENT_TEXT_DURATION
jmp PrintPanelText
TM_Wait: rts
; Tunnel machine decision runloop
;
; Parameters: -
; Returns: -
; Modifies: various
TunnelMachineRun:
inc tmTime1
lda tmTime1
and #$01
sta shakeScreen
inc tmTime2
lda tmTime2
cmp #3
bcc TMR_NoSound
lda #$00
sta tmTime2
lda #SFX_GENERATOR
jsr PlaySfx
TMR_NoSound: lda joystick
and #JOY_DOWN
bne TMR_Finish
lda keyType
bpl TMR_Finish
jsr GetFireClick
bcs TMR_Decision
jsr MenuControl
ldy tmChoice
lsr
bcs TMR_MoveLeft
lsr
bcs TMR_MoveRight
TMR_NoMove: rts
TMR_MoveLeft: tya
beq TMR_NoMove
dey
sty tmChoice
TMR_Redraw: lda #SFX_SELECT
jsr PlaySfx
TMR_RedrawNoSound:
ldy #$00
TMR_RedrawLoop: ldx tmArrowPosTbl,y
lda #$20
cpy tmChoice
bne TMR_NoArrow
lda #62
TMR_NoArrow: jsr PrintPanelChar
iny
cpy #2
bcc TMR_RedrawLoop
rts
TMR_MoveRight: tya
bne TMR_NoMove
iny
sty tmChoice
bne TMR_Redraw
TMR_Decision: lda tmChoice
bne TMR_Drive
TMR_Finish: jsr StopScript
jmp SetMenuMode ;X=0 on return
TMR_Drive: jsr AddQuestScore
jsr TMR_Finish
lda #$00
sta tmTime1 ;TODO: replace with cutscene
jsr BlankScreen
TMR_BreakWallLoop:
jsr WaitBottom
jsr Random
cmp #$40
bcs TMR_BreakWallNoSound
lda #$00
sta PSfx_LastSfx+1
lda #SFX_EXPLOSION
jsr PlaySfx
TMR_BreakWallNoSound:
inc tmTime1
bpl TMR_BreakWallLoop
lda #$32
jmp ULO_EnterDoorDest
; Tunnel machine item installation script routines
;
; Parameters: -
; Returns: -
; Modifies: various
TunnelMachineItems:
lda itemIndex
cmp #ITEM_TRUCKBATTERY
bne TMI_Fuel
TMI_Battery: lda #PLOT_BATTERY
jsr SetPlotBit
lda #<txtBatteryInstalled
ldx #>txtBatteryInstalled
bne TMI_Common
TMI_Fuel: lda #PLOT_FUEL
jsr SetPlotBit
lda #<txtRefueled
ldx #>txtRefueled
TMI_Common: jsr TM_TextCommon
ldy itemIndex
jsr RemoveItem
lda #$00
sta UM_ForceRefresh+1
jsr AddQuestScore
lda #SFX_POWERUP
jsr PlaySfx
lda plotBits
and #$20+$40+$80 ;If laptop in place, the destroy plan
cmp #$20+$40 ;is not necessary
bne TMI_NoPlan
lda plotBits+1 ;Any NPCs in lab?
and #$10+$20
beq TMI_NoPlan
lda #<EP_DESTROYPLAN
ldx #>EP_DESTROYPLAN
jmp SetScript
TMI_NoPlan: rts
; Jormungandr speaks
;
; Parameters: -
; Returns: -
; Modifies: various
RadioJormungandr:
lda #<EP_RADIOJORMUNGANDRRUN
ldx #>EP_RADIOJORMUNGANDRRUN
jsr SetScript
gettext txtRadioJormungandr
RadioMsg: ldy #ACT_PLAYER
jsr SpeakLine
lda #SFX_RADIO
jmp PlaySfx
; Jormungandr speaks, running script (screen shake)
;
; Parameters: -
; Returns: -
; Modifies: various
RadioJormungandrRun:
lda menuMode
beq RJR_Stop
jsr Random
and #$01
sta shakeScreen
DP_Wait: rts
RJR_Stop: jmp StopScript
; Radio message for simultaneous destruction
;
; Parameters: -
; Returns: -
; Modifies: various
DestroyPlan: lda textTime ;Wait until the fuel/battery message gone
bne DP_Wait
jsr StopScript
lda plotBits+1
and #$20
bne DP_Jeff
DP_Linda: lda #ACT_SCIENTIST3
jsr DP_SetPosCommon
lda #<txtRadioDestroyLinda
ldx #>txtRadioDestroyLinda
jmp RadioMsg
DP_Jeff: lda #ACT_SCIENTIST3
jsr FindLevelActor ;Require old tunnels level to be sure (if player
bcc DP_NoComment ;is cheating, the surgery scene could be
lda lvlActOrg,y ;skipped and this script would trigger in the
cmp #$0f+ORG_GLOBAL ;wrong place)
bne DP_NoComment
lda #<EP_DESTROYCOMMENT
ldx #>EP_DESTROYCOMMENT
sta actScriptEP+1
stx actScriptF+1
DP_NoComment: lda #ACT_HACKER
jsr DP_SetPosCommon
lda #<txtRadioDestroyJeff
ldx #>txtRadioDestroyJeff
jmp RadioMsg
DP_SetPosCommon:
jsr FindLevelActor
lda #ACT_HAZMAT
sta lvlActT,y
lda #$61
sta lvlActX,y
lda #$55
sta lvlActY,y
lda #$10+AIMODE_TURNTO
sta lvlActF,y
lda #$0f+ORG_GLOBAL
sta lvlActOrg,y
lda #<EP_HAZMAT
ldx #>EP_HAZMAT
sta actScriptEP+3
stx actScriptF+3
ldy lvlDataActBitsStart+$0f
lda lvlStateBits,y ;Remove the hazmat item
and #$fe
sta lvlStateBits,y
rts
; Large tank update routine
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars
MoveLargeTank: ldy #C_LARGETANK
jsr EnsureSpriteFile
jsr MoveGeneric ;Use human movement for physics
jsr AttackGeneric
lda actSX,x ;Then overwrite animation
beq MLT_NoCenterFrame
eor actD,x ;If direction & speed don't agree, show the
bmi MLT_CenterFrame ;center frame (turning)
MLT_NoCenterFrame:
jsr GetAbsXSpeed
clc
adc actFd,x
cmp #$60
bcc MLT_NoWrap
sbc #$60
MLT_NoWrap: sta actFd,x
lsr
lsr
lsr
lsr
lsr
skip2
MLT_CenterFrame:lda #3
sta actF1,x
rts
; Fireball movement
;
; Parameters: X actor index
; Returns: -
; Modifies: A,Y,temp1-temp8,loader temp vars
MoveFireball: ldy #C_HIGHWALKER
jsr EnsureSpriteFile
lda actTime,x ;Randomize X-speed on first frame
bne MFB_HasRandomSpeed ;and set upward motion
inc actTime,x
jsr Random
and #$0f
sec
sbc #$08
sta actSX,x
jsr Random
and #$0f
sec
sbc #5*8+8
sta actSY,x
lda #SFX_GRENADELAUNCHER
jsr PlaySfx
MFB_HasRandomSpeed:
lda #DMG_FIREBALL
jsr CollideAndDamagePlayer
lda #1
ldy #3
jsr LoopingAnimation
lda #GRENADE_ACCEL-2
ldy #GRENADE_MAX_YSPEED
jsr AccActorY
lda actSX,x
jsr MoveActorX
lda actSY,x
jmp MoveActorY
; Radio message when entering Jormungandr's lair without biometric ID
;
; Parameters: -
; Returns: -
; Modifies: various
RadioHackerWarning:
lda #ACT_HACKER ;Make sure Jeff is alive
jsr FindLevelActor
bcc RHW_NoActor
ldy #ITEM_BIOMETRICID
jsr FindItem
bcs RHW_HasItem
gettext txtRadioHackerWarning
jmp RadioMsg
RHW_NoActor:
RHW_HasItem: rts
; Tables & variables
tmArrowPosTbl: dc.b 9,14
tmTime1: dc.b 0
tmTime2: dc.b 0
; Messages
txtNoBattery: dc.b "BATTERY DEAD",0
txtNoFuel: dc.b "NO FUEL",0
txtBatteryInstalled:
dc.b "NEW BATTERY INSTALLED",0
txtRefueled: dc.b "REFUELED",0
txtReady: dc.b " STOP DRIVE",0
txtRadioDestroyJeff:
dc.b 34,"JEFF HERE. "
textjump txtRadioDestroyCommon
txtRadioDestroyLinda:
dc.b 34,"IT'S LINDA. "
txtRadioDestroyCommon:
dc.b "DON'T START THE MACHINE YET. IF I LOAD IT WITH "
dc.b "EXPLOSIVES FROM THE RECYCLER, MAYBE I CAN DESTROY JORMUNGANDR AS YOU DEAL WITH THE AI. "
dc.b "A HAZMAT SUIT SHOULD ALLOW ME TO SURVIVE LONG ENOUGH. "
dc.b "THE DOOR IN THE UPPER STORAGE LEADS BACK HERE. I'LL BE WAITING.",34,0
txtRadioJormungandr:
dc.b 34,"GREETINGS SEMI-HUMAN. I AM JORMUNGANDR. I RESIDE BEYOND THE DEAD END IN FRONT OF YOU. "
dc.b "TURN BACK NOW, THERE IS NOTHING YOU CAN GAIN BY PROCEEDING. WHEN I RECEIVE THE SIGNAL "
dc.b "FROM MY MASTER, OR IF HE SHOULD FALL SILENT, I WILL TRAVEL THE CRUST AND MAKE THE EARTH BREATHE "
dc.b "FIRE AND ASH, BRINGING THE POST-HUMAN AGE. AND SHOULD I FALL, HE WILL AVENGE ME.",34,0
txtRadioHackerWarning:
dc.b 34,"IT'S JEFF. YOU MUST BE CLOSE NOW. THERE'S ONE THING I FOUND.. THE DEDICATED MILITARY NETWORK "
dc.b "LINK IS ACTIVE, THOUGH ALL OTHER OUTSIDE LINES ARE DOWN. HAS TO BE THE AI. "
dc.b "THE SCARIEST OPTION WOULD BE THAT IT HAS WORMED ITS WAY INTO "
dc.b "NUCLEAR LAUNCH SYSTEMS OR SOMETHING. BUT NO. THAT CAN'T HAPPEN IN REALITY.",34,0
checkscriptend