-
Notifications
You must be signed in to change notification settings - Fork 10
/
script08.s
507 lines (465 loc) · 15.5 KB
/
script08.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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
include macros.s
include mainsym.s
; Script 8, nether tunnels interactions
org scriptCodeStart
dc.w TunnelMachine
dc.w TunnelMachineItems
dc.w TunnelMachineRun
dc.w RadioJormungandr
dc.w RadioJormungandrRun
dc.w AfterSurgery
dc.w AfterSurgeryRun
dc.w AfterSurgeryZone
dc.w AfterSurgeryNoAir
dc.w AfterSurgeryFollow
dc.w AfterSurgeryNoAirDie
; Tunnel machine script routine
;
; Parameters: -
; Returns: -
; Modifies: various
tmChoice = menuCounter
TunnelMachine: 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
; 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 #PLOT_WALLBREACHED
jsr SetPlotBit
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
jsr AddQuestScore
lda #SFX_POWERUP
jmp PlaySfx
; Jormungandr speaks
;
; Parameters: -
; Returns: -
; Modifies: various
RadioJormungandr:lda #<EP_RADIOJORMUNGANDRRUN
ldx #>EP_RADIOJORMUNGANDRRUN
jsr SetScript
lda #SFX_RADIO
jsr PlaySfx
ldy #ACT_PLAYER
lda #<txtRadioJormungandr
ldx #>txtRadioJormungandr
jmp SpeakLine
; Jormungandr speaks, running script (screen shake)
;
; Parameters: -
; Returns: -
; Modifies: various
RadioJormungandrRun:
lda menuMode
beq RJR_Stop
jsr Random
and #$01
sta shakeScreen
rts
RJR_Stop: jmp StopScript
; After surgery ambush
;
; Parameters: -
; Returns: -
; Modifies: various
AfterSurgery: lda scriptVariable
asl
tay
lda asJumpTbl,y
sta AS_Jump+1
lda asJumpTbl+1,y
sta AS_Jump+2
AS_Jump: jmp $0000
AS_1: jsr AfterSurgeryRun ;Ensure player position right when the screen turns on
lda upgrade
ora #UPG_TOXINFILTER
sta upgrade ;Has the filter upgrade now
lda #HP_PLAYER ;Always full HP, as there will be an attack
sta actHp+ACTI_PLAYER
lda battery+1 ;Ensure minimal battery, as there will be EMP attacks
cmp #LOW_BATTERY
bcs AS_1BatteryOK
lda #LOW_BATTERY
sta battery+1
AS_1BatteryOK: jsr AddQuestScore
lda #SFX_POWERUP
jsr PlaySfx
inc scriptVariable
ldy #ACT_SCIENTIST2
lda #<txtAfterSurgery_1
ldx #>txtAfterSurgery_1
jmp SpeakLine
AS_2: jsr Random
and #$01
sta shakeScreen
jsr Random
cmp #$10
bcs AS_2NoExplosion
jsr HeavyShake
AS_2NoExplosion:lda #ACT_SCIENTIST3
jsr FindActor
inc actTime,x
lda actTime,x
cmp #50
bcc AS_2Wait
inc scriptVariable
AS_2Wait: rts
AS_3: inc scriptVariable
ldy #ACT_SCIENTIST3
lda #<txtAfterSurgery_2
ldx #>txtAfterSurgery_2
jmp SpeakLine
AS_4: lda #ACT_HIGHWALKER
jsr FindLevelActor
lda lvlActY,y ;Unhide waiting enemy now
and #$7f
sta lvlActY,y
inc scriptVariable
lda #ACT_SCIENTIST2
jsr FindActor
lda #AIMODE_IDLE
sta actAIMode,x
lda #HP_SCIENTIST1 ;Make possible to die
sta actHp,x
HeavyShake: lda #SFX_EXPLOSION ;One final shake + explosion
jsr PlaySfx
lda #$02
sta shakeScreen
rts
AS_5: lda #ACT_HIGHWALKER
jsr FindActor
bcc AS_5Wait
lda actXH,x
cmp #$46
php
lda #ACT_SCIENTIST2
jsr FindActor
plp
lda #JOY_DOWN+JOY_RIGHT
bcc AS_5Duck
lda #0
AS_5Duck: sta actMoveCtrl,x
lda actF1,x
cmp #FR_DIE+2
bcc AS_5Wait
AS_5Done: lda #ACT_SCIENTIST3
jsr FindActor
lda #AIMODE_SNIPER
sta actAIMode,x
inc scriptVariable
AS_6Wait:
AS_5Wait: rts
AS_6: lda #ACT_HIGHWALKER
jsr FindActor
bcs AS_6Wait
lda #ACT_EXPLOSIONGENERATORRISING
jsr FindActor
bcs AS_6Wait
inc scriptVariable
ldy #ACT_SCIENTIST3
lda #<txtAfterSurgery_3
ldx #>txtAfterSurgery_3
jmp SpeakLine
AS_7: ldx #ACTI_PLAYER ;Player regains control
lda #-9*8
jsr MoveActorX
lda #8*8
jsr MoveActorY
jsr NoInterpolation
jsr StopScript
lda #FR_STAND
sta actF1+ACTI_PLAYER
sta actF2+ACTI_PLAYER
inc scriptVariable
AS_8Wait: rts
AS_8: lda actXH+ACTI_PLAYER
cmp #$40
beq AS_8Wait
lda #<EP_AFTERSURGERYFOLLOW ;Change to following script
sta actScriptEP+1
ldy #ACT_SCIENTIST3
lda #<txtAfterSurgery_4
ldx #>txtAfterSurgery_4
jmp SpeakLine
asJumpTbl: dc.w AS_1
dc.w AS_2
dc.w AS_3
dc.w AS_4
dc.w AS_5
dc.w AS_6
dc.w AS_7
dc.w AS_8
; After surgery continuous script, keep player in place
;
; Parameters: -
; Returns: -
; Modifies: various
AfterSurgeryRun:lda joystick
and #JOY_FIRE ;Fire must be possible to advance dialogue
sta joystick
lda #$00
sta actXL+ACTI_PLAYER
sta actD+ACTI_PLAYER
sta actSY+ACTI_PLAYER
lda #FR_DIE+2
sta actF1+ACTI_PLAYER
sta actF2+ACTI_PLAYER
lda #$58
sta actYL+ACTI_PLAYER
lda #$41
sta actXH+ACTI_PLAYER
lda #$55
sta actYH+ACTI_PLAYER
ASZ_AlreadySet: rts
; After surgery zone script
;
; Parameters: -
; Returns: -
; Modifies: various
AfterSurgeryZone:
lda levelNum
cmp #$08
bne ASZ_Stop
lda #ACT_SCIENTIST3
jsr TransportNPCToPlayer
lda #PLOT_LOWERLABSNOAIR
jsr GetPlotBit
bne ASZ_AlreadySet
lda #$00
sta UA_SpawnDelay+1 ;Wait a bit before next dialogue, ensure
lda #<EP_AFTERSURGERYNOAIR ;no enemy spawn in the meanwhile
sta actScriptEP+1
lda #PLOT_LOWERLABSNOAIR
jmp SetPlotBit
ASZ_Stop: jmp StopZoneScript
; After surgery follow script (refresh follow mode & zone script)
;
; Parameters: -
; Returns: -
; Modifies: various
AfterSurgeryFollow:
ldx actIndex
lda oxygen ;Die if run out of oxygen,
beq ASF_Die ;almost reach lift,
lda actXH+ACTI_PLAYER ;or if player goes to nether tunnel
cmp #$39
bcc ASF_Die
cmp #$6d
bcc ASF_CoordOK
lda actYH+ACTI_PLAYER
cmp #$53
bcs ASF_Die
ASF_CoordOK: lda #AIMODE_FOLLOW
sta actAIMode,x
lda #ACTI_PLAYER
sta actAITarget,x
lda #<EP_AFTERSURGERYZONE
ldx #>EP_AFTERSURGERYZONE
jmp SetZoneScript
ASF_Die: ldx actIndex
lda #AIMODE_IDLE
sta actAIMode,x
lda #JOY_DOWN
sta actMoveCtrl,x
lda #75
sta actTime,x
lda actSX,x ;Wait for zero X-speed for the speech bubble
bne ASF_DieWait
jsr StopZoneScript
ldx actIndex
lda #-15*8
sta temp4
lda #ITEM_EMPGENERATOR
jsr DI_ItemNumber
lda #ITEM_NONE
sta actWpn,x
lda #<EP_AFTERSURGERYNOAIRDIE
sta actScriptEP+1
ldy #ACT_SCIENTIST3
lda #<txtAfterSurgeryNoAirDie
ldx #>txtAfterSurgeryNoAirDie
jmp SpeakLine
ASF_DieWait: rts
; After surgery "no air" dialogue
;
; Parameters: -
; Returns: -
; Modifies: various
AfterSurgeryNoAir:
ldx actIndex ;Stay in place until dialogue
lda #AIMODE_TURNTO ;so that speech bubble doesn't levitate
sta actAIMode,x
lda oxygen ;Let player notice first
cmp #MAX_OXYGEN-5
bcs ASNA_Wait
lda #<EP_AFTERSURGERYFOLLOW ;Restore follow script again
sta actScriptEP+1
ldy #ACT_SCIENTIST3
lda #<txtAfterSurgeryNoAir
ldx #>txtAfterSurgeryNoAir
jmp SpeakLine
ASNAD_NotRemoved:
ASNA_Wait: rts
; NPC death when running out of oxygen
;
; Parameters: -
; Returns: -
; Modifies: various
AfterSurgeryNoAirDie:
ldx actIndex
jsr SetNotPersistent
lda #JOY_DOWN
sta actMoveCtrl,x
jmp DeathFlickerAndRemove
; 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
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
txtAfterSurgery_1:
dc.b 34,"MINOR COMPLICATIONS. THE RESTORATIVE NANO-BOTS WILL TAKE CARE.",34,0
txtAfterSurgery_2:
dc.b 34,"WHAT'S THAT?",34,0
txtAfterSurgery_3:
dc.b 34,"AMOS.. TOO LATE.",34,0
txtAfterSurgery_4:
dc.b 34,"YOU OK? WE NEED TO GET OUT OF HERE.",34,0
txtAfterSurgeryNoAir:
dc.b 34,"DO YOU NOTICE? IT'S HARDER TO BREATH. DAMN.. IT'S THE AI DOING THIS!",34,0
txtAfterSurgeryNoAirDie:
dc.b 34,"CAN'T.. MAKE IT FURTHER. YOU GO..",34,0
checkscriptend