/[projet1]/users/chema/TINE/missions/mission1.s
Defence Force logotype

Contents of /users/chema/TINE/missions/mission1.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 327 - (show annotations)
Mon May 24 19:13:37 2010 UTC (9 years, 10 months ago) by Chema
File size: 7896 byte(s)
Solved snapping to planet in short range chart. Added fuel cricle in long range chart
1
2 ;; Mission 1. Transportation of concealed illegal cargo from Xexedi (250) to Teen (209)
3
4
5 .(
6 // Jump table to mission functions
7 // These are kind of event handlers
8 // OnPlayerXXX. The idea is patching these with the necessary jumps. If returns C=1 it means
9 // that text is to be plotted to screen (brief or debrief).
10
11 OnPlayerLaunch
12 jmp PlayerLaunch
13 OnPlayerDock
14 jmp PlayerDock
15 OnPlayerHyper
16 clc
17 rts
18 .byt 00
19 OnExplodeShip
20 clc
21 rts
22 .byt 00
23 OnDockedShip
24 clc
25 rts
26 .byt 00
27 OnHyperShip
28 clc
29 rts
30 .byt 00
31 OnEnteringSystem
32 clc
33 rts
34 .byt 00
35 OnNewEncounter
36 clc
37 rts
38 .byt 00
39
40 // OnScoopObject return with carry =1 if it has handled the scooping, so the main program
41 // avoids doing so.
42
43 OnScoopObject
44 clc
45 rts
46 .byt 00
47
48 // OnGameLoaded, called whenever the game has been loaded from disk, for initializing things...
49 OnGameLoaded
50 jmp InitMission
51
52 // Some public variables
53 NeedsDiskLoad .byt 0 ; Will be set to $ff when a new mission needs to be loaded from disk
54 MissionSummary .word str_Summary1
55 MissionCargo .byt 0 ; Cargo for this mission
56
57 // Some internal variables and code
58
59 #define CARGO_AMOUNT 15
60
61 #define NEXTMISSION_LEGAL 5
62
63 tab_sumlo
64 .byt <str_Summary1,<str_Summary
65 tab_sumhi
66 .byt >str_Summary1,>str_Summary
67 tab_cargo
68 .byt 0,CARGO_AMOUNT,0,0
69
70 InitMission
71 .(
72 lda _mission
73 and #%11
74 tax
75 ldy tab_cargo,x
76 sty MissionCargo
77 lsr
78 tax
79 lda tab_sumlo,x
80 sta MissionSummary
81 lda tab_sumhi,x
82 sta MissionSummary+1
83 rts
84 .)
85
86
87 PlayerLaunch
88 .(
89 ; What needs to be done when player launches?
90 ; basically either brief mission or load cargo.
91
92 ; Check mission state
93 lda _mission
94 cmp #THISMISSION+2
95 bne firststart
96
97 ; If it is 2, then mission has been launched.
98 ; check if at origin
99 lda _galaxynum
100 cmp #1
101 bne nolaunch
102 lda _currentplanet
103 cmp #250 ;Xexedi
104 bne nolaunch
105
106 ; We are at origin, therefor load cargo
107 ; if enough space, else hit a problem
108
109 lda _holdspace
110 cmp #CARGO_AMOUNT
111 bcs doit
112 ; No cargo left!
113 lda #<str_MissionProblem
114 sta TXTPTRLO
115 lda #>str_MissionProblem
116 sta TXTPTRHI
117
118 sec
119 rts
120
121 doit
122 lda #CARGO_AMOUNT
123 ;ldx #3
124 clc
125 adc _shipshold ;,x
126 sta _shipshold ;,x
127 lda _holdspace
128 sec
129 sbc #CARGO_AMOUNT
130 sta _holdspace
131
132 ; Loaded, set MissionCargo to 0 and increment state to 3
133 lda #0
134 sta MissionCargo
135
136 inc _mission
137
138 ; Issue the alert message from the police
139 lda #<str_CargoRevealed
140 sta TXTPTRLO
141 lda #>str_CargoRevealed
142 sta TXTPTRHI
143 end
144 sec
145 rts
146
147
148 firststart
149 ;It was not at state 2... maybe not launched yet? (that is state 0)
150 cmp #THISMISSION
151 beq launch
152
153 ; No, it wasnot, so either state 1 or 3. Nothing to be done
154 ; so just return
155 nolaunch
156 clc
157 rts
158
159 launch
160 ; Ok, we are about to launch mission here.
161 ; Check preconditions
162
163 lda _score+1
164 beq nolaunch
165
166 ; Launch mission, increment state to 1
167 inc _mission
168
169 ; Prepare brief message
170 lda #<str_MissionBrief
171 sta TXTPTRLO
172 lda #>str_MissionBrief
173 sta TXTPTRHI
174
175 ; Setup MissionCargo variable
176 lda #CARGO_AMOUNT
177 sta MissionCargo
178
179 ; Return with message to be printed
180 sec
181 rts
182 .)
183
184
185 PlayerDock
186 .(
187 ; What needs to be done when player docks?
188 ; If mission is at state 1
189 lda _mission
190 cmp #THISMISSION+1
191 bne finished
192
193 ; Check if we have arrived at origin, then issue
194 ; second brief, clarifiying what cargo needs to be
195 ; transported and where.
196 lda _galaxynum
197 cmp #1
198 bne notlaunched
199 lda _currentplanet
200 cmp #250 ;Xexedi
201 bne notlaunched
202
203 ; Increment mission state to 2
204 inc _mission
205
206 ; Second briefing
207 lda #<str_MissionBrief2
208 sta TXTPTRLO
209 lda #>str_MissionBrief2
210 sta TXTPTRHI
211
212 ; Change summary which prints on status page
213 lda #<str_Summary
214 sta MissionSummary
215 lda #>str_Summary
216 sta MissionSummary+1
217
218 ; Return with a message to be printed
219 sec
220 rts
221
222
223 finished
224 ; Check if state is 3, then we need to see if
225 ; we have successfuly transported the goods to
226 ; destination.
227
228 cmp #THISMISSION+3
229 beq checksuccess
230
231 ; Not even launched
232 ; Just return
233 notlaunched
234 clc
235 rts
236
237 checksuccess
238 lda _galaxynum
239 cmp #1
240 bne notlaunched
241 lda _currentplanet
242 cmp #209 ;Teen
243 bne legalway
244
245 ; Remove cargo
246 ; Do we have it?
247 ;ldx #3
248 lda _shipshold ;,x
249 cmp #CARGO_AMOUNT
250 bcs okcargo
251
252 ; Uh, oh... we don't have the cargo
253 lda #NEXTMISSIONFAIL
254 sta _mission
255 lda #<str_MissionFailed
256 sta TXTPTRLO
257 lda #>str_MissionFailed
258 sta TXTPTRHI
259 sec
260 rts
261
262 okcargo
263 ; Remove cargo from ship
264 sec
265 sbc #CARGO_AMOUNT
266 sta _shipshold ;,x
267 clc
268 lda #CARGO_AMOUNT
269 adc _holdspace
270 sta _holdspace
271
272 ; Pay the player
273 lda #<5000
274 clc
275 adc _cash
276 sta _cash
277 lda #>5000
278 adc _cash+1
279 sta _cash+1
280 bcc nomore
281 inc _cash+2
282 bne nomore
283 inc _cash+3
284 nomore
285
286 ; Set next mission
287 lda #NEXTMISSION
288 sta _mission
289
290 ; Prepare debriefing
291 lda #<str_MissionDebrief
292 sta TXTPTRLO
293 lda #>str_MissionDebrief
294 sta TXTPTRHI
295
296 ; Flag that we need to load mission from disk
297 dec NeedsDiskLoad
298
299 ; Return with message to be printed.
300 sec
301 rts
302
303 legalway
304 ; Check if player acted the legal way
305 lda _galaxynum
306 cmp #1
307 bne notlaunched
308 lda _currentplanet
309 cmp #109 ;Usatqura
310 bne notlaunched
311
312 ; Remove cargo
313 ; Do we have it?
314 ;ldx #3
315 lda _shipshold ;,x
316 cmp #CARGO_AMOUNT
317 bcs okcargo2
318
319 clc
320 rts
321
322 okcargo2
323 ; Remove cargo from ship
324 sec
325 sbc #CARGO_AMOUNT
326 sta _shipshold ;,x
327 clc
328 lda #CARGO_AMOUNT
329 adc _holdspace
330 sta _holdspace
331
332 ; Pay the player
333 lda #<1000
334 clc
335 adc _cash
336 sta _cash
337 lda #>1000
338 adc _cash+1
339 sta _cash+1
340 bcc nomore
341 inc _cash+2
342 bne nomore
343 inc _cash+3
344
345 ; Clear legal status
346 lda #0
347 sta _legal_status
348
349 ; Set next mission
350 lda #NEXTMISSION_LEGAL
351 sta _mission
352
353 ; Prepare debriefing
354 lda #<str_MissionDebrief2
355 sta TXTPTRLO
356 lda #>str_MissionDebrief2
357 sta TXTPTRHI
358
359 ; Flag that we need to load mission from disk
360 dec NeedsDiskLoad
361
362 ; Return with message to be printed.
363 sec
364 rts
365
366 .)
367
368
369 str_MissionBrief
370 .asc "Greetings Commander."
371 .byt 13
372 .asc "This is Milto Zaxx again and I have a"
373 .byt 13
374 .asc "another bussiness of your interest."
375 .byt 13
376 .asc "Come to Xexedi for a transport."
377 .byt 0
378
379 str_MissionBrief2
380 .asc "Welcome to Xexedi, Commander."
381 .byt 13
382 .asc "Transport 15 tons of food to Teen."
383 .byt 13
384 .asc "Be sure to have such space free before"
385 .byt 13
386 .asc "leaving. You will be paid 500 Cr."
387 .byt 0
388
389 str_MissionDebrief
390 .asc "Good job. I have sent the credits."
391 .byt 13
392 .asc "I see you like risky bussiness."
393 .byt 13
394 .asc "I will contact you again soon..."
395 .byt 0
396
397 str_MissionProblem
398 .asc "You didn't have enough space for"
399 .byt 13
400 .asc "our cargo!"
401 .byt 13
402 .byt 13
403 .asc "Get back to Xexedi inmediately!"
404 .byt 0
405
406 str_MissionFailed
407 .asc "What did you do with my cargo?"
408 .byt 13
409 .asc "I will make sure nobody else hires you!"
410 .byt 0
411
412
413 str_CargoRevealed
414 .asc "ATTENTION Message from GalCop Police."
415 .byt 13
416 .asc "We have heard that a smuggler called"
417 .byt 13
418 .asc "Milto Zaxx has concealed illegal"
419 .byt 13
420 .asc "cargo as food in one ship leaving"
421 .byt 13
422 .asc "this system. If you suspect you are"
423 .byt 13
424 .asc "transporting this, come inmediately"
425 .byt 13
426 .asc "to Usatqura for interrogation."
427 .byt 0
428
429 str_MissionDebrief2
430 .asc "Thanks commander."
431 .byt 13
432 .asc "For your help to the GalCop police,"
433 .byt 13
434 .asc "your legal status has been cleaerd and"
435 .byt 13
436 .asc "a reward of 100 Cr has been sent to you."
437 .byt 0
438
439
440 str_Summary1
441 .byt 2
442 .asc "Current mission:"
443 .byt 13
444 .byt 2
445 .asc "Go to Xexedi for a transport."
446 .byt 13
447 .byt 0
448
449 str_Summary
450 .byt 2
451 .asc "Current mission:"
452 .byt 13
453 .byt 2
454 .asc "Transport food to Teen."
455 .byt 13
456 .byt 0
457
458 .)
459
460

  ViewVC Help
Powered by ViewVC 1.1.26