-
Notifications
You must be signed in to change notification settings - Fork 10
/
script.s
324 lines (282 loc) · 9.2 KB
/
script.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
EP_TITLE = $0000
EP_SCIENTIST1 = $0100
EP_INTROCUTSCENE = $0101
EP_THEATRECOMPUTER = $0200
EP_LOBBYCOMPUTER = $0201
EP_OFFICECOMPUTER1 = $0202
EP_OFFICECOMPUTER2 = $0203
EP_OFFICECOMPUTER3 = $0204
EP_OFFICECOMPUTER4 = $0205
EP_RADIOUPPERLABSENTRANCE = $0300
EP_OFFICECOMPUTER5 = $0301
EP_ITCOMPUTER = $0302
EP_SCREENSAVEREFFECT = $0303
EP_CONFIGUREUPGRADE = $0400
EP_INSTALLUPGRADE = $0401
EP_INSTALLEFFECT = $0402
EP_RADIOSECURITYCENTER = $0500
EP_SECURITYCOMPUTER1 = $0501
EP_SECURITYCOMPUTER2 = $0502
EP_SECURITYCOMPUTER3 = $0503
EP_SECURITYCOMPUTER4 = $0504
EP_SECURITYCOMPUTER5 = $0505
EP_SECURITYCOMPUTER6 = $0506
EP_RECYCLINGSTATION = $0600
EP_CONSTRUCTSPEECH = $0601
EP_ENTERCODE = $0602
EP_ENTERCODELOOP = $0603
EP_USEHEALTHRECHARGER = $0604
EP_USEBATTERYRECHARGER = $0605
EP_RECHARGEREFFECT = $0606
EP_LABCOMPUTER1 = $0700
EP_LABCOMPUTER2 = $0701
EP_LABCOMPUTER3 = $0702
EP_LABCOMPUTER4 = $0703
EP_LABCOMPUTER5 = $0704
EP_LABCOMPUTER6 = $0705
EP_LABCOMPUTER7 = $0706
EP_LABCOMPUTER8 = $0707
EP_LABCOMPUTER9 = $0708
EP_ELEVATOR = $0800
EP_ELEVATORLOOP = $0801
EP_RADIOUPPERLABSELEVATOR = $0802
EP_RADIOSECURITYPASS = $0803
EP_ESCORTSCIENTISTSREFRESH = $0804
EP_ESCORTSCIENTISTSZONE = $0805
EP_HACKERFOLLOW = $0806
EP_HACKERFOLLOWZONE = $0807
EP_MOVEROTORDRONE = $0900
EP_DESTROYROTORDRONE = $0901
EP_HACKER = $0902
EP_HACKER2 = $0903
EP_HACKER3 = $0904
EP_HACKER4 = $0905
EP_LOWERLABSCOMPUTER1 = $0a00
EP_LOWERLABSCOMPUTER2 = $0a01
EP_LOWERLABSCOMPUTER3 = $0a02
EP_LOWERLABSCOMPUTER4 = $0a03
EP_LOWERLABSCOMPUTER5 = $0a04
EP_LOWERLABSCOMPUTER6 = $0a05
EP_LOWERLABSCOMPUTER7 = $0a06
EP_LOWERLABSCOMPUTER8 = $0a07
EP_LOWERLABSCOMPUTER9 = $0a08
EP_RADIOCAVES = $0b00
EP_MOVEBAT = $0b01
EP_MOVESPIDER = $0b02
EP_MOVELARGESPIDER = $0b03
EP_OPENWALL = $0b04
EP_MOVEACID = $0b05
EP_INSTALLAMPLIFIER = $0b06
EP_RUNLASER = $0b07
EP_SWITCHGENERATOR = $0b08
EP_SWITCHLASER = $0b09
EP_SUBNETROUTER = $0c00
EP_SERVERROOMCOMPUTER = $0c01
EP_MOVESCIENTISTS = $0c02
EP_RADIOCONSTRUCT = $0c03
EP_RADIOLOWERLABS = $0c04
EP_COMBATROBOTSABOTEUR = $0c05
EP_DESTROYCOMBATROBOTSABOTEUR = $0c06
EP_ESCORTSCIENTISTSSTART = $0d00
EP_ESCORTSCIENTISTSFINISH = $0d01
EP_RADIOFINDFILTER = $0d02
EP_SCIENTIST2 = $0e00
EP_GARAGECOMPUTER = $0e01
EP_BEGINSURGERY = $0f00
EP_BEGINSURGERY2 = $0f01
EP_AFTERSURGERY = $0f02
EP_AFTERSURGERYRUN = $0f03
EP_AFTERSURGERYZONE = $0f04
EP_AFTERSURGERYNOAIR = $0f05
EP_AFTERSURGERYFOLLOW = $0f06
EP_AFTERSURGERYNOAIRDIE = $0f07
EP_AFTERSURGERYNOAIRRADIO = $0f08
EP_THRONECHIEF = $1000
EP_BEGINAMBUSH = $1001
EP_HACKERAMBUSH = $1002
EP_GIVELAPTOP = $1003
EP_ENTERBIODOME = $1004
EP_BIODOMEENDING = $1005
EP_LOWERSECURITYCOMPUTER1 = $1100
EP_LOWERSECURITYCOMPUTER2 = $1101
EP_LOWERSECURITYCOMPUTER3 = $1102
EP_LOWERSECURITYCOMPUTER4 = $1103
EP_LOWERSECURITYCOMPUTER5 = $1104
EP_TUNNELMACHINE = $1200
EP_TUNNELMACHINEITEMS = $1201
EP_TUNNELMACHINERUN = $1202
EP_RADIOJORMUNGANDR = $1203
EP_RADIOJORMUNGANDRRUN = $1204
EP_DESTROYPLAN = $1205
EP_MOVELARGETANK = $1206
EP_MOVEFIREBALL = $1207
EP_RADIOHACKERWARNING = $1208
EP_REACHOLDTUNNELS = $1300
EP_HACKERFOLLOWFINISH = $1301
EP_ENTERLAB = $1302
EP_HACKERENTERLAB = $1303
EP_SCIENTISTENTERLAB = $1304
EP_HAZMAT = $1305
EP_HAZMATLEAVE = $1306
EP_DESTROYCOMMENT = $1307
EP_LABNOTE4 = $1400
EP_GIVELAPTOP2 = $1401
EP_LABNOTE1 = $1402
EP_LABNOTE2 = $1403
EP_LABNOTE3 = $1404
EP_HACKERFINAL = $1405
EP_MOVESECURITYCHIEF = $1500
EP_DESTROYSECURITYCHIEF = $1501
EP_SECURITYCHIEFSPEECH = $1502
EP_THRONESUITECOMPUTER = $1503
EP_GUARDHOUSECOMPUTER = $1504
EP_INSTALLLAPTOP = $1600
EP_INSTALLLAPTOPWORK = $1601
EP_INSTALLLAPTOPFINISH = $1602
EP_MOVEEYESTAGE1 = $1603
EP_MOVEEYESTAGE2 = $1604
EP_DESTROYEYE = $1605
EP_CONSTRUCTENDING = $1606
EP_CONSTRUCTINTERLUDE = $1607
EP_MOVEJORMUNGANDR = $1700
EP_JORMUNGANDRINTERLUDE = $1701
EP_ENDSEQUENCE = $1800
PLOT_ELEVATOR1 = $00 ;Upper <-> lower lab
PLOT_ELEVATOR2 = $01 ;Jormungandr <-> Bio-Dome
PLOT_GENERATOR = $02 ;Upper labs generator switched on
PLOT_AMPINSTALLED = $03 ;Laser amplifier installed
PLOT_HIDEOUTOPEN = $04 ;Rotordrone boss destroyed
PLOT_BATTERY = $05 ;Tunnel machine battery installed
PLOT_FUEL = $06 ;Tunnel machine refueled
PLOT_DISRUPTCOMMS = $07 ;AI communication disrupted with the laptop
PLOT_LOWERLABSNOAIR = $08 ;Air being sucked from lower labs (must be plotbit 8)
PLOT_MOVESCIENTISTS = $09 ;Scientists moved to wait in upper labs
PLOT_ELEVATORMSG = $0a ;Player attempted lower lab elevator entry
PLOT_ESCORTCOMPLETE = $0b ;Scientists got to the operating room
PLOT_OLDTUNNELSLAB1 = $0c ;Linda reached old tunnels lab
PLOT_OLDTUNNELSLAB2 = $0d ;Jeff reached old tunnels lab
PLOT_HIDEOUTAMBUSH = $0e ;Robot ambush to Jeff's hideout ongoing
PLOT_RIGTUNNELMACHINE = $0f ;Tunnel machine prepared with explosives for simultaneous destruction
SPEECHBUBBLEOFFSET = -40*8
; Execute a script
;
; Parameters: A script entrypoint, X script file, ES_ParamX+1, ES_ParamY+1 (or Y in ExecScriptParam)
; Returns: -
; Modifies: A,X,Y,loader temp vars
ExecScriptParam:sty ES_ParamY+1
ExecScript: pha
ES_LoadedScriptFile:
cpx #$ff ;Check if same file already loaded
beq ES_SameFile
stx ES_LoadedScriptFile+1
txa
ldx #F_SCRIPT
jsr MakeFileName
lda #$00 ;Reset any text printing in case it was from
sta textHi ;script and will be overwritten
lda #<scriptCodeStart
ldx #>scriptCodeStart
jsr LoadFileRetry
ES_SameFile: pla
bmi ES_LoadOnly
asl
tax
lda scriptCodeStart,x
sta ES_ScriptJump+1
lda scriptCodeStart+1,x
sta ES_ScriptJump+2
ES_ParamX: ldx #$00
ES_ParamY: ldy #$00
ES_ScriptJump: jmp $1000
; Set/stop a continuous script
;
; Parameters: A script entrypoint, X script file (0 = stop)
; Returns: -
; Modifies: -
StopScript: ldx #$00
SetScript: stx scriptF
sta scriptEP
ES_LoadOnly: rts
; Set/stop zone transition script
;
; Parameters: A script entrypoint, X script file (0 = stop)
; Returns: -
; Modifies: -
StopZoneScript: ldx #$00
SetZoneScript: stx zoneScriptF
sta zoneScriptEP
rts
; NPC speak a line
;
; Parameters: Y actor type, A,X text address
; Returns: -
; Modifies: A,X,Y,temp1-temp4
SpeakLine: sty SL_ActT+1
jsr PrintPanelTextIndefinite
SL_ActT: lda #$00
jsr FindActor
bcc SL_NoSpeechBubble
SL_ExplicitActor:
lda #ACTI_FIRSTEFFECT
ldy #ACTI_LASTEFFECT
jsr GetFreeActor
bcc SL_NoSpeechBubble
lda #$00
sta temp1
sta temp2
lda #<SPEECHBUBBLEOFFSET
sta temp3
lda #>SPEECHBUBBLEOFFSET
sta temp4
lda #ACT_SPEECHBUBBLE
jsr SpawnWithOffset
SL_NoSpeechBubble:
lda #$00 ;Reset controls during conversation
sta actCtrl+ACTI_PLAYER
sta actMoveCtrl+ACTI_PLAYER
ldx #MENU_DIALOGUE
jmp SetMenuMode
; Get the value of a plotbit
;
; Parameters: A plotbit number
; Returns: A nonzero if set
; Modifies: A,Y
GetPlotBit: jsr DecodeBit
and plotBits,y
rts
; Set a plotbit
;
; Parameters: A plotbit number
; Returns: -
; Modifies: A,Y
SetPlotBit: jsr DecodeBit
ora plotBits,y
bne CPB_Store
; Clear a plotbit
;
; Parameters: A plotbit number
; Returns: -
; Modifies: A,Y
ClearPlotBit: jsr DecodeBit
eor #$ff
and plotBits,y
CPB_Store: sta plotBits,y
rts
; Turn a number into a byte offset into a bit-table and a bitmask
;
; Parameters: A number
; Returns: A bitmask, Y byte offset
; Modifies: A,Y
DecodeBit: pha
and #$07
tay
lda keyRowBit,y
eor #$ff
sta DB_Value+1
pla
lsr
lsr
lsr
tay
DB_Value: lda #$00
rts