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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 369 - (show annotations)
Mon Jul 26 11:15:13 2010 UTC (9 years, 10 months ago) by Chema
File size: 30868 byte(s)
Solved problems with mission10.s and other issues with missions stated in todolist.txt

Missions checked, but more tweaks can be done (todolist.txt)
1
2 #include "..\main.h"
3 #include "..\ships.h"
4
5
6 // tine.h cannot be included... defines here.
7
8 /* Values for the _flags field */
9
10 #define IS_EXPLODING 1
11 #define IS_DISAPPEARING 2
12 #define IS_HYPERSPACING 4
13 #define IS_DOCKING 8
14 #define FLG_FLY_TO_PLANET 16
15 #define FLG_FLY_TO_HYPER 32
16 #define FLG_INNOCENT 64
17 #define FLG_HARD 128
18
19
20 /* Values for the _ai_state field */
21
22 #define IS_AICONTROLED 128
23
24 #define FLG_SLOW 1
25 #define FLG_BOLD 2
26 #define FLG_POLICE 4
27 #define FLG_DEFENCELESS 8
28 #define FLG_TRADER 16
29 #define FLG_BOUNTYHUNTER 32
30 #define FLG_PIRATE 64
31
32
33
34 /* Values for _target field */
35
36 #define IS_ANGRY 128
37
38 /* Values for equipment (user Byte in OBJ3D record) */
39 #define HAS_ECM 1
40 #define HAS_MILLASER 2
41 #define HAS_ESCAPEPOD 4
42 #define HAS_ANTIRADAR 8
43 #define HAS_GALHYPER 16
44 #define HAS_SCOOPS 32
45 #define HAS_EXTRACARGO 64
46 #define HAS_ITEM3 128
47
48
49
50 #ifdef HAVE_MISSIONS
51
52 #define TXTPTRLO $fe
53 #define TXTPTRHI $ff
54
55
56 // Jump table for routines accessible from mission code
57
58 #define IndFlightMessage MISSION_CODE_START-3*8
59 #define IndAddSpaceObject MISSION_CODE_START-3*7
60 #define IndSetShipEquip MISSION_CODE_START-3*6
61 #define IndRnd MISSION_CODE_START-3*5
62 #define IndSetCurOb MISSION_CODE_START-3*4
63 #define IndLaunchShip MISSION_CODE_START-3*3
64 #define IndGetShipPos MISSION_CODE_START-3*2
65 #define IndGetShipType MISSION_CODE_START-3*1
66
67 // Variables accessible from mission code
68
69 // From page 0
70 #define tmp0 $06
71 #define tmp1 $08
72 #define tmp2 $0a
73 #define tmp3 $0c
74 #define op1 $16
75 #define op2 $18
76 #define tmp $1a
77
78
79 // From page 4
80
81 // Player's data
82 #define _name $400
83 #define _shipshold $40b
84 #define _currentplanet $41c
85 #define _galaxynum $41d
86 #define _cash $41e
87 #define _fuel $422
88 #define _holdspace $424
89 #define _legal_status $425
90 #define _score_rem $426
91 #define _score $427
92 #define _mission $429
93 #define _equip $42a
94
95 // Used for getting ship's position
96 #define _PosX $4e7
97 #define _PosY $4e9
98 #define _PosZ $4eb
99
100 // frame counter
101 #define frame_number $4f9
102
103 // From overlay ram, ship data
104 #define _rotz $f9e1
105 #define _target $fa41
106 #define _flags $fa61
107 #define _ttl $fa81
108 #define _energy $faa1
109 #define _missiles $fac1
110 #define _ai_state $fae1
111
112 #define THISMISSION 0
113 #define NEXTMISSION 4
114 #define NEXTMISSIONFAIL $fc
115
116
117 *=MISSION_CODE_START
118
119 #include "../missions/mission0.s"
120
121 ;---
122
123 ; This is fixed... each mission included has a number which is the previous
124 ; plus 4.
125 #define MISSIONTEMP THISMISSION+4
126 #undef THISMISSION
127 #define THISMISSION MISSIONTEMP
128 #undef MISSIONTEMP
129
130 ; This should vary, as the next mission both in case of success or failure
131 ; could not be the next in list, but any other...
132
133 #define MISSIONTEMP NEXTMISSION+4
134 #define NEXTMISSION MISSIONTEMP
135 #undef MISSIONTEMP
136 #undef NEXTMISSIONFAIL
137 #define NEXTMISSIONFAIL $fc
138
139 .dsb $a000-*
140
141
142 *=MISSION_CODE_START
143
144
145 #include "../missions/mission1.s"
146
147 ;---
148
149 ; This is fixed... each mission included has a number which is the previous
150 ; plus 4.
151 #define MISSIONTEMP THISMISSION+4
152 #undef THISMISSION
153 #define THISMISSION MISSIONTEMP
154 #undef MISSIONTEMP
155
156 ; This should vary, as the next mission both in case of success or failure
157 ; could not be the next in list, but any other...
158
159 #define MISSIONTEMP NEXTMISSION+4
160 #define NEXTMISSION 28
161 #undef MISSIONTEMP
162 #undef NEXTMISSIONFAIL
163 #define NEXTMISSIONFAIL $fc
164
165 .dsb $a000-*
166
167
168 *=MISSION_CODE_START
169
170 #include "../missions/mission2.s"
171
172 ;---
173
174 ; This is fixed... each mission included has a number which is the previous
175 ; plus 4.
176 #define MISSIONTEMP THISMISSION+4
177 #undef THISMISSION
178 #define THISMISSION MISSIONTEMP
179 #undef MISSIONTEMP
180
181 ; This should vary, as the next mission both in case of success or failure
182 ; could not be the next in list, but any other...
183
184 #define MISSIONTEMP 16
185 #define NEXTMISSION MISSIONTEMP
186 #undef MISSIONTEMP
187 #undef NEXTMISSIONFAIL
188 #define NEXTMISSIONFAIL $fc
189
190 .dsb $a000-*
191
192
193 *=MISSION_CODE_START
194
195 #include "../missions/tutorial0.s"
196
197 ;---
198
199 ; This is fixed... each mission included has a number which is the previous
200 ; plus 4.
201 #define MISSIONTEMP THISMISSION+4
202 #undef THISMISSION
203 #define THISMISSION MISSIONTEMP
204 #undef MISSIONTEMP
205
206 ; This should vary, as the next mission both in case of success or failure
207 ; could not be the next in list, but any other...
208
209 #define MISSIONTEMP NEXTMISSION+4
210 #define NEXTMISSION MISSIONTEMP
211 #undef MISSIONTEMP
212 #undef NEXTMISSIONFAIL
213 #define NEXTMISSIONFAIL $fc
214
215 .dsb $a000-*
216
217
218 *=MISSION_CODE_START
219
220 #include "../missions/tutorial1.s"
221
222 ;---
223
224 ; This is fixed... each mission included has a number which is the previous
225 ; plus 4.
226 #define MISSIONTEMP THISMISSION+4
227 #undef THISMISSION
228 #define THISMISSION MISSIONTEMP
229 #undef MISSIONTEMP
230
231 ; This should vary, as the next mission both in case of success or failure
232 ; could not be the next in list, but any other...
233
234 #define MISSIONTEMP NEXTMISSION+4
235 #define NEXTMISSION MISSIONTEMP
236 #undef MISSIONTEMP
237 #undef NEXTMISSIONFAIL
238 #define NEXTMISSIONFAIL $fc
239
240 .dsb $a000-*
241
242
243 *=MISSION_CODE_START
244
245 #include "../missions/tutorial2.s"
246
247 ;---
248
249 ; This is fixed... each mission included has a number which is the previous
250 ; plus 4.
251 #define MISSIONTEMP THISMISSION+4
252 #undef THISMISSION
253 #define THISMISSION MISSIONTEMP
254 #undef MISSIONTEMP
255
256 ; This should vary, as the next mission both in case of success or failure
257 ; could not be the next in list, but any other...
258
259 #define MISSIONTEMP 0
260 #define NEXTMISSION MISSIONTEMP
261 #undef MISSIONTEMP
262 #undef NEXTMISSIONFAIL
263 #define NEXTMISSIONFAIL $fc
264
265 .dsb $a000-*
266
267
268 *=MISSION_CODE_START
269
270
271 #include "../missions/tutorial3.s"
272
273
274
275 ;;;;;;;;;;;;;; MISSION NUMBER 28 ;;;;;;;;;;;;;;;
276
277
278 ;---
279
280 ; This is fixed... each mission included has a number which is the previous
281 ; plus 4.
282 #define MISSIONTEMP THISMISSION+4
283 #undef THISMISSION
284 #define THISMISSION MISSIONTEMP
285 #undef MISSIONTEMP
286
287 ; This should vary, as the next mission both in case of success or failure
288 ; could not be the next in list, but any other...
289
290 #define MISSIONTEMP 32
291 #define NEXTMISSION MISSIONTEMP
292 #undef MISSIONTEMP
293 #undef NEXTMISSIONFAIL
294 #define NEXTMISSIONFAIL $fc
295
296 .dsb $a000-*
297
298
299 *=MISSION_CODE_START
300
301 #include "../missions/mission3.s"
302
303 ;---
304
305 ; This is fixed... each mission included has a number which is the previous
306 ; plus 4.
307 #define MISSIONTEMP THISMISSION+4
308 #undef THISMISSION
309 #define THISMISSION MISSIONTEMP
310 #undef MISSIONTEMP
311
312 ; This should vary, as the next mission both in case of success or failure
313 ; could not be the next in list, but any other...
314
315 #define MISSIONTEMP NEXTMISSION+4
316 #define NEXTMISSION MISSIONTEMP
317 #undef MISSIONTEMP
318 #undef NEXTMISSIONFAIL
319 #define NEXTMISSIONFAIL $fc
320
321 .dsb $a000-*
322
323
324 *=MISSION_CODE_START
325
326 #include "../missions/mission4.s"
327
328 ;---
329
330 ; This is fixed... each mission included has a number which is the previous
331 ; plus 4.
332 #define MISSIONTEMP THISMISSION+4
333 #undef THISMISSION
334 #define THISMISSION MISSIONTEMP
335 #undef MISSIONTEMP
336
337 ; This should vary, as the next mission both in case of success or failure
338 ; could not be the next in list, but any other...
339
340 #define MISSIONTEMP NEXTMISSION+4+1
341 #define NEXTMISSION MISSIONTEMP
342 #undef MISSIONTEMP
343 #undef NEXTMISSIONFAIL
344 #define NEXTMISSIONFAIL $fc
345
346 .dsb $a000-*
347
348
349 *=MISSION_CODE_START
350
351
352 #include "../missions/mission5.s"
353
354
355 ;---
356
357 ; This is fixed... each mission included has a number which is the previous
358 ; plus 4.
359 #define MISSIONTEMP THISMISSION+4
360 #undef THISMISSION
361 #define THISMISSION MISSIONTEMP
362 #undef MISSIONTEMP
363
364 ; This should vary, as the next mission both in case of success or failure
365 ; could not be the next in list, but any other...
366
367 #define MISSIONTEMP NEXTMISSION+4
368 #define NEXTMISSION MISSIONTEMP
369 #undef MISSIONTEMP
370 #undef NEXTMISSIONFAIL
371 #define NEXTMISSIONFAIL $fc
372
373 .dsb $a000-*
374
375
376 *=MISSION_CODE_START
377
378 #include "../missions/mission6.s"
379
380 ;---
381
382 ; This is fixed... each mission included has a number which is the previous
383 ; plus 4.
384 #define MISSIONTEMP THISMISSION+4
385 #undef THISMISSION
386 #define THISMISSION MISSIONTEMP
387 #undef MISSIONTEMP
388
389 ; This should vary, as the next mission both in case of success or failure
390 ; could not be the next in list, but any other...
391
392 #define MISSIONTEMP NEXTMISSION+4-1
393 #define NEXTMISSION MISSIONTEMP
394 #undef MISSIONTEMP
395 #undef NEXTMISSIONFAIL
396 #define NEXTMISSIONFAIL $fc
397
398 .dsb $a000-*
399
400
401 *=MISSION_CODE_START
402
403 #include "../missions/mission7.s"
404
405 ;---
406
407 ; This is fixed... each mission included has a number which is the previous
408 ; plus 4.
409 #define MISSIONTEMP THISMISSION+4
410 #undef THISMISSION
411 #define THISMISSION MISSIONTEMP
412 #undef MISSIONTEMP
413
414 ; This should vary, as the next mission both in case of success or failure
415 ; could not be the next in list, but any other...
416
417 #define MISSIONTEMP NEXTMISSION+4+1
418 #define NEXTMISSION MISSIONTEMP
419 #undef MISSIONTEMP
420 #undef NEXTMISSIONFAIL
421 #define NEXTMISSIONFAIL $fc
422
423 .dsb $a000-*
424
425
426 *=MISSION_CODE_START
427
428 #include "../missions/mission8.s"
429
430 ;---
431
432 ; This is fixed... each mission included has a number which is the previous
433 ; plus 4.
434 #define MISSIONTEMP THISMISSION+4
435 #undef THISMISSION
436 #define THISMISSION MISSIONTEMP
437 #undef MISSIONTEMP
438
439 ; This should vary, as the next mission both in case of success or failure
440 ; could not be the next in list, but any other...
441
442 #define MISSIONTEMP NEXTMISSION+4-1
443 #define NEXTMISSION MISSIONTEMP
444 #undef MISSIONTEMP
445 #undef NEXTMISSIONFAIL
446 #define NEXTMISSIONFAIL $fc
447
448 .dsb $a000-*
449
450
451 *=MISSION_CODE_START
452
453
454 #include "../missions/mission9.s"
455
456 ;---
457
458 ; This is fixed... each mission included has a number which is the previous
459 ; plus 4.
460 #define MISSIONTEMP THISMISSION+4
461 #undef THISMISSION
462 #define THISMISSION MISSIONTEMP
463 #undef MISSIONTEMP
464
465 ; This should vary, as the next mission both in case of success or failure
466 ; could not be the next in list, but any other...
467
468 #define MISSIONTEMP NEXTMISSION+4
469 #define NEXTMISSION $f8
470 #undef MISSIONTEMP
471 #undef NEXTMISSIONFAIL
472 #define NEXTMISSIONFAIL $fc
473
474 .dsb $a000-*
475
476
477 *=MISSION_CODE_START
478
479 __start_mission0_code
480
481 #include "../missions/mission10.s"
482
483 __end_mission0_code
484
485
486
487 #echo ***** Missions start:
488 #print (__start_mission0_code)
489 #echo ***** Mission memory:
490 #print (__end_mission0_code - __start_mission0_code)
491 #echo
492
493
494
495
496 #ifdef TESTINGMISSIONS
497
498
499 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
500 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
501 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
502 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
503 ; Mission minus one
504 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
505 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
506 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
507
508
509 *=MISSION_CODE_START
510
511 .(
512 __start_mission0_code
513 // Jump table to mission functions
514 // These are kind of event handlers
515 // OnPlayerXXX. The idea is patching these with the necessary jumps. If returns C=1 it means
516 // that text is to be plotted to screen (brief or debrief).
517
518 OnPlayerLaunch
519 jmp MissionStart
520 OnPlayerDock
521 jmp MissionSuccess
522 OnPlayerHyper
523 clc
524 rts
525 .byt 00
526 OnExplodeShip
527 clc
528 rts
529 .byt 00
530 OnDockedShip
531 clc
532 rts
533 .byt 00
534 OnHyperShip
535 clc
536 rts
537 .byt 00
538 OnEnteringSystem
539 clc
540 rts
541 .byt 00
542 OnNewEncounter
543 jmp CreateItemForScoop
544
545 // OnScoopObject return with carry =1 if it has handled the scooping, so the main program
546 // avoids doing so.
547
548 OnScoopObject
549 jmp CheckScoop
550
551
552 // Some public variables
553 NeedsDiskLoad .byt 0 ; Will be set to $ff when a new mission needs to be loaded from disk
554 MissionSummary .word str_Summary
555 MissionCargo .byt 0 ; Cargo for this mission
556
557 // Some internal variables and code
558
559 Success .byt 0 ; Cannot use Success here, as it is not saved. Better inc _mission
560 IdItem .byt 0
561 ItemCreated .byt 0 ; Should get this to zero at hyper or launch, if not gotten. Else inconsistent if loading after saved game.
562
563 MissionStart
564 .(
565 lda _mission
566 cmp #THISMISSION
567 bne nolaunch
568 lda _score+1
569 beq nolaunch
570
571 ; launch mission
572 inc _mission
573 lda #<str_MissionBrief
574 sta TXTPTRLO
575 lda #>str_MissionBrief
576 sta TXTPTRHI
577
578 sec
579 rts
580 nolaunch
581 clc
582 rts
583 .)
584
585
586 MissionSuccess
587 .(
588 lda _mission
589 cmp #THISMISSION+1
590 bne notlaunched
591 lda _galaxynum
592 cmp #2
593 bne notlaunched
594 lda _currentplanet
595 cmp #$8
596 bne notlaunched
597
598 lda Success
599 beq notlaunched
600
601 lda #<10000
602 clc
603 adc _cash
604 sta _cash
605 lda #>10000
606 adc _cash+1
607 sta _cash+1
608
609
610 lda #NEXTMISSION
611 sta _mission
612
613 lda #<str_MissionDebrief
614 sta TXTPTRLO
615 lda #>str_MissionDebrief
616 sta TXTPTRHI
617
618 dec NeedsDiskLoad
619
620 sec
621 rts
622
623 notlaunched
624 clc
625 rts
626 .)
627 POS1
628 .word 0
629 .word 0
630 .word 0
631
632 CreateItemForScoop
633 .(
634
635 lda _mission
636 cmp #THISMISSION+1
637 bne nolaunch
638
639 lda Success
640 bne nolaunch
641
642 ldx ItemCreated
643 bne nolaunch
644 inx
645 stx ItemCreated
646
647 lda _galaxynum
648 cmp #2
649 bne nolaunch
650 lda _currentplanet
651 cmp #$a5
652 bne nolaunch
653
654 lda #<POS1
655 sta tmp0
656 lda #>POS1
657 sta tmp0+1
658 lda #SHIP_CARGO
659 jsr IndAddSpaceObject
660 stx IdItem
661 clc
662 rts
663
664 nolaunch
665 clc
666 rts
667 .)
668
669
670 CheckScoop
671 .(
672 lda Success
673 bne itsnot
674 cpx IdItem
675 bne itsnot
676 inc Success
677 lda #<str_gotit
678 sta tmp0
679 lda #>str_gotit
680 sta tmp0+1
681 ldx #0
682 jsr IndFlightMessage
683 itsnot
684 rts
685 .)
686
687
688 str_gotit
689 .asc "Stolen Hi-Tech"
690 .byt 0
691
692 str_MissionBrief
693 .asc "I have a profitable bussiness for you."
694 .byt 13
695 .asc "Get cannister at GEMA and bring it"
696 .byt 13
697 .asc "to ESRASOCE"
698 .byt 0
699
700 str_MissionDebrief
701 .asc "Good job. I have sent the credits."
702 .byt 0
703
704 str_Summary
705 .byt 2
706 .asc "Current mission:"
707 .byt 13
708 .byt 2
709 .asc "Get cannister at Gema. Bring it to"
710 .byt 13
711 .byt 2
712 .asc "Esrasoce."
713 .byt 0
714
715
716 __end_mission0_code
717
718 #echo ***** Missions start:
719 #print (__start_mission0_code)
720 #echo ***** Mission memory:
721 #print (__end_mission0_code - __start_mission0_code)
722 #echo
723
724
725 .)
726
727
728
729
730 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
731 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
732 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
733 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
734 ; Mission zero
735 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
736 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
737 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
738
739
740 .dsb $a000-*
741
742
743
744 #define MISSIONTEMP THISMISSION+4
745 #undef THISMISSION
746 #define THISMISSION MISSIONTEMP
747 #undef MISSIONTEMP
748 #define MISSIONTEMP NEXTMISSION+4
749 #define NEXTMISSION MISSIONTEMP
750 #undef MISSIONTEMP
751 #undef NEXTMISSIONFAIL
752 #define NEXTMISSIONFAIL $ff
753
754
755
756 *=MISSION_CODE_START
757
758 .(
759 __start_mission0_code
760 // Jump table to mission functions
761 // These are kind of event handlers
762 // OnPlayerXXX. The idea is patching these with the necessary jumps. If returns C=1 it means
763 // that text is to be plotted to screen (brief or debrief).
764
765 OnPlayerLaunch
766 jmp MissionStart
767 OnPlayerDock
768 jmp MissionSuccess
769 OnPlayerHyper
770 clc
771 rts
772 .byt 00
773 OnExplodeShip
774 clc
775 rts
776 .byt 00
777 OnDockedShip
778 clc
779 rts
780 .byt 00
781 OnHyperShip
782 clc
783 rts
784 .byt 00
785 OnEnteringSystem
786 clc
787 rts
788 .byt 00
789 OnNewEncounter
790 clc
791 rts
792 .byt 00
793
794 // OnScoopObject return with carry =1 if it has handled the scooping, so the main program
795 // avoids doing so.
796
797 OnScoopObject
798 clc
799 rts
800 .byt 00
801
802
803 // Some public variables
804 NeedsDiskLoad .byt 0 ; Will be set to $ff when a new mission needs to be loaded from disk
805 MissionSummary .word str_Summary1
806 MissionCargo .byt 0 ; Cargo for this mission
807
808 // Some internal variables and code
809
810
811 MissionStart
812 .(
813 lda _mission
814 cmp #THISMISSION+2
815 bne firststart
816
817 lda _galaxynum
818 cmp #2
819 bne nolaunch
820 lda _currentplanet
821 cmp #$a5
822 bne nolaunch
823
824 ; Load Cargo
825 lda _holdspace
826 cmp #3
827 bcs doit
828 ; No cargo left!
829 lda #<str_MissionProblem
830 sta TXTPTRLO
831 lda #>str_MissionProblem
832 sta TXTPTRHI
833
834 sec
835 rts
836
837 doit
838 lda #3
839 ldx #3
840 clc
841 adc _shipshold,x
842 sta _shipshold,x
843 lda _holdspace
844 sec
845 sbc #3
846 sta _holdspace
847
848 lda #0
849 sta MissionCargo
850
851 clc
852 rts
853
854
855
856 firststart
857 cmp #THISMISSION
858 bne nolaunch
859 lda _score+1
860 beq nolaunch
861
862 ; launch mission
863 inc _mission
864 lda #<str_MissionBrief
865 sta TXTPTRLO
866 lda #>str_MissionBrief
867 sta TXTPTRHI
868
869 lda #3
870 sta MissionCargo
871
872 sec
873 rts
874 nolaunch
875 clc
876 rts
877 .)
878
879
880 MissionSuccess
881 .(
882
883 lda _mission
884 cmp #THISMISSION+1
885 bne finished
886 lda _galaxynum
887 cmp #2
888 bne notlaunched
889 lda _currentplanet
890 cmp #$a5
891 bne notlaunched
892
893 ; launch mission
894 inc _mission
895 lda #<str_MissionBrief2
896 sta TXTPTRLO
897 lda #>str_MissionBrief2
898 sta TXTPTRHI
899
900 lda #<str_Summary
901 sta MissionSummary
902 lda #>str_Summary
903 sta MissionSummary+1
904
905
906 sec
907 rts
908
909
910 finished
911 lda _mission
912 cmp #THISMISSION+2
913 bne notlaunched
914 lda _galaxynum
915 cmp #2
916 bne notlaunched
917 lda _currentplanet
918 cmp #$3
919 bne notlaunched
920
921 ; Remove cargo
922 ldx #3
923 lda _shipshold,x
924 cmp #3
925 bcs okcargo
926
927 lda #NEXTMISSIONFAIL
928 sta _mission
929 lda #<str_MissionFailed
930 sta TXTPTRLO
931 lda #>str_MissionFailed
932 sta TXTPTRHI
933 sec
934 rts
935
936 okcargo
937 sec
938 sbc #3
939 sta _shipshold,x
940 clc
941 lda #3
942 adc _holdspace
943 sta _holdspace
944
945 lda #<10000
946 clc
947 adc _cash
948 sta _cash
949 lda #>10000
950 adc _cash+1
951 sta _cash+1
952
953
954 lda #NEXTMISSION
955 sta _mission
956
957 lda #<str_MissionDebrief
958 sta TXTPTRLO
959 lda #>str_MissionDebrief
960 sta TXTPTRHI
961
962 dec NeedsDiskLoad
963
964 sec
965 rts
966
967
968 notlaunched
969 clc
970 rts
971 .)
972
973
974 str_MissionBrief
975 .asc "I have a profitable bussiness for you."
976 .byt 13
977 .asc "Come to GEMA for a transport."
978 .byt 0
979
980 str_MissionBrief2
981 .asc "Transport 3 tons of slaves to Maisso."
982 .byt 13
983 .asc "Be sure to have such space free before"
984 .byt 13
985 .asc "leaving. You will be paid 1000 Cr."
986 .byt 0
987
988 str_MissionDebrief
989 .asc "Good job. I have sent the credits."
990 .byt 0
991
992 str_MissionProblem
993 .asc "You didn't have enough space for our cargo!"
994 .byt 13
995 .asc "Get back to GEMA inmediately!"
996 .byt 0
997
998 str_MissionFailed
999 .asc "What did you do with my cargo?"
1000 .byt 13
1001 .asc "I will make sure nobody else hires you!"
1002 .byt 0
1003
1004 str_Summary1
1005 .byt 2
1006 .asc "Current mission:"
1007 .byt 13
1008 .byt 2
1009 .asc "Go to Gema for a transport."
1010 .byt 13
1011 .byt 0
1012
1013 str_Summary
1014 .byt 2
1015 .asc "Current mission:"
1016 .byt 13
1017 .byt 2
1018 .asc "Transport slaves to Maisso."
1019 .byt 13
1020 .byt 0
1021
1022 __end_mission0_code
1023
1024 #echo ***** Missions start:
1025 #print (__start_mission0_code)
1026 #echo ***** Mission memory:
1027 #print (__end_mission0_code - __start_mission0_code)
1028 #echo
1029
1030
1031 .)
1032
1033
1034
1035 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1036 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1037 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1038 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1039 ; Mission one
1040 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1041 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1042 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1043 .dsb $a000-*
1044
1045
1046
1047 #define MISSIONTEMP THISMISSION+4
1048 #undef THISMISSION
1049 #define THISMISSION MISSIONTEMP
1050 #undef MISSIONTEMP
1051 #define MISSIONTEMP NEXTMISSION+4
1052 #define NEXTMISSION MISSIONTEMP
1053 #undef MISSIONTEMP
1054 #undef NEXTMISSIONFAIL
1055 #define NEXTMISSIONFAIL $ff
1056
1057
1058 *=MISSION_CODE_START
1059
1060 .(
1061 __start_mission1_code
1062 // Jump table to mission functions
1063 // These are kind of event handlers
1064 // OnPlayerXXX. The idea is patching these with the necessary jumps. If returns C=1 it means
1065 // that text is to be plotted to screen (brief or debrief).
1066
1067 OnPlayerLaunch
1068 jmp MissionStart
1069 OnPlayerDock
1070 jmp MissionSuccess
1071 OnPlayerHyper
1072 jmp MissionSuccess
1073 OnExplodeShip
1074 jmp ShipKilled
1075 OnDockedShip
1076 jmp ShipDocked
1077 OnHyperShip
1078 clc
1079 rts
1080 .byt 00
1081 OnEnteringSystem
1082 jmp MissionEncounters
1083 OnNewEncounter
1084 clc
1085 rts
1086 .byt 00
1087
1088 // OnScoopObject return with carry =1 if it has handled the scooping, so the main program
1089 // avoids doing so.
1090
1091 OnScoopObject
1092 clc
1093 rts
1094 .byt 00
1095
1096
1097 // Some public variables
1098 NeedsDiskLoad .byt 0 ; Will be set to $ff when a new mission needs to be loaded from disk
1099 MissionSummary .word str_Summary
1100 MissionCargo .byt 0 ; Cargo for this mission
1101
1102 // Some internal variables and code
1103
1104 ShipToProtect .byt 00
1105 Succeeded .byt 00
1106
1107 MissionStart
1108 .(
1109 lda _mission
1110 cmp #THISMISSION
1111 bne nolaunch
1112 lda _score+1
1113 beq nolaunch
1114
1115 ; launch mission
1116 inc _mission
1117 lda #<str_MissionBrief
1118 sta TXTPTRLO
1119 lda #>str_MissionBrief
1120 sta TXTPTRHI
1121
1122 sec
1123 rts
1124 nolaunch
1125 clc
1126 rts
1127 .)
1128
1129 MissionEncounters
1130 .(
1131 lda _mission
1132 cmp #THISMISSION+1
1133 bne nolaunch
1134 lda _galaxynum
1135 cmp #2
1136 bne nolaunch
1137 lda _currentplanet
1138 cmp #$1b
1139 bne nolaunch
1140 jsr CreateMissionShips
1141 inc _mission
1142 clc
1143 rts
1144 nolaunch
1145 clc
1146 rts
1147 .)
1148
1149 MissionSuccess
1150 .(
1151 lda _mission
1152 cmp #THISMISSION+2
1153 bne notlaunched
1154
1155 lda Succeeded
1156 beq failure
1157
1158 lda #NEXTMISSION
1159 sta _mission
1160
1161 lda #<str_MissionDebrief
1162 sta TXTPTRLO
1163 lda #>str_MissionDebrief
1164 sta TXTPTRHI
1165
1166 dec NeedsDiskLoad
1167
1168 sec
1169 rts
1170
1171 failure
1172 lda #<str_MissionFailure
1173 sta TXTPTRLO
1174 lda #>str_MissionFailure
1175 sta TXTPTRHI
1176
1177 lda #NEXTMISSIONFAIL
1178 sta _mission
1179 sec
1180 rts
1181
1182 notlaunched
1183 clc
1184 rts
1185 .)
1186
1187 POS1
1188 .word 0
1189 .word 0
1190 .word 0
1191 POS2
1192 .word 4500
1193 .word 0
1194 .word -6000
1195 POS3
1196 .word -4500
1197 .word 0
1198 .word -6000
1199 POS4
1200 .word -4500
1201 .word -4500
1202 .word -6000
1203
1204 CreateMissionShips
1205 .(
1206 ; Create ship fleeing...
1207 lda #<POS1
1208 sta tmp0
1209 lda #>POS1
1210 sta tmp0+1
1211 lda #SHIP_COBRA1
1212 jsr IndAddSpaceObject
1213 stx ShipToProtect
1214 lda #(FLG_FLY_TO_PLANET|FLG_INNOCENT)
1215 sta _flags,x
1216 lda #(IS_AICONTROLED|FLG_DEFENCELESS|FLG_BOLD)
1217 sta _ai_state,x
1218 lda #2
1219 sta _target,x
1220
1221 ; Create bad guys
1222 lda #<POS2
1223 sta tmp0
1224 lda #>POS2
1225 sta tmp0+1
1226 lda #SHIP_MAMBA
1227 jsr IndAddSpaceObject
1228 lda #(IS_AICONTROLED|FLG_BOLD|FLG_PIRATE)
1229 sta _ai_state,x
1230 lda ShipToProtect
1231 ora #IS_ANGRY
1232 sta _target,x
1233
1234 ; Set number of missiles to zero
1235 lda #%11111000
1236 and _missiles,x
1237 sta _missiles,x
1238
1239 lda #<POS3
1240 sta tmp0
1241 lda #>POS3
1242 sta tmp0+1
1243 lda #SHIP_MAMBA
1244 jsr IndAddSpaceObject
1245 lda #(IS_AICONTROLED|FLG_BOLD|FLG_PIRATE)
1246 sta _ai_state,x
1247 lda ShipToProtect
1248 ora #IS_ANGRY
1249 sta _target,x
1250
1251 ; Set number of missiles to zero
1252 lda #%11111000
1253 and _missiles,x
1254 sta _missiles,x
1255
1256 lda #<POS4
1257 sta tmp0
1258 lda #>POS4
1259 sta tmp0+1
1260 lda #SHIP_MAMBA
1261 jsr IndAddSpaceObject
1262 lda #(IS_AICONTROLED|FLG_PIRATE)
1263 sta _ai_state,x
1264 lda ShipToProtect
1265 ora #IS_ANGRY
1266 sta _target,x
1267
1268 ; Set number of missiles to zero
1269 lda #%11111000
1270 and _missiles,x
1271 sta _missiles,x
1272 clc
1273 rts
1274
1275 .)
1276
1277 ShipDocked
1278 .(
1279 lda _mission
1280 cmp #THISMISSION+2
1281 beq cont
1282 nothing
1283 clc
1284 rts
1285 cont
1286 cpx ShipToProtect
1287 bne nothing
1288 dec Succeeded
1289 lda #<str_hedocked
1290 sta tmp0
1291 lda #>str_hedocked
1292 sta tmp0+1
1293 ldx #0
1294 jsr IndFlightMessage
1295
1296 clc
1297 rts
1298 .)
1299
1300
1301 ShipKilled
1302 .(
1303 lda _mission
1304 cmp #THISMISSION+2
1305 beq cont
1306 nothing
1307 clc
1308 rts
1309 cont
1310 cpx ShipToProtect
1311 bne nothing
1312 lda #<str_hekilled
1313 sta tmp0
1314 lda #>str_hekilled
1315 sta tmp0+1
1316 ldx #0
1317 jsr IndFlightMessage
1318
1319 clc
1320 rts
1321 .)
1322
1323 str_MissionBrief
1324 .asc " MAYDAY -- MAYDAY "
1325 .byt 13
1326 .asc "My Cobra-I ship is damaged and"
1327 .byt 13
1328 .asc "I am pursued by pirates on Beanen."
1329 .byt 13
1330 .byt 13
1331 .asc "Please help me!."
1332 .byt 13
1333 .asc "---MESSAGE ENDS."
1334 .byt 0
1335
1336 str_MissionDebrief
1337 .asc "You have saved my life and I shall"
1338 .byt 13
1339 .asc "remember."
1340 .byt 0
1341
1342 str_MissionFailure
1343 .asc "Thanks for your attempt. Sadly you did"
1344 .byt 13
1345 .asc "not succeed. It was clearly too much"
1346 .byt 13
1347 .asc "for your skills."
1348 .byt 0
1349 str_hedocked
1350 .asc "Zantor docked safely!"
1351 .byt 0
1352 .asc "Mission successful"
1353 .byt 0
1354 str_hekilled
1355 .asc "Zantor has been killed!"
1356 .byt 0
1357 .asc "Mission failed"
1358 .byt 0
1359 str_Summary
1360 .byt 2
1361 .asc "Current mission:"
1362 .byt 13
1363 .byt 2
1364 .asc "Go to Beanen. Save Zantor from pirates"
1365 .byt 13
1366 .byt 2
1367 .asc "so he can land safely."
1368 .byt 0
1369
1370 __end_mission1_code
1371
1372 #echo ***** Missions start:
1373 #print (__start_mission1_code)
1374 #echo ***** Mission memory:
1375 #print (__end_mission1_code - __start_mission1_code)
1376 #echo
1377
1378
1379 .)
1380
1381
1382 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1383 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1384 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1385 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1386 ; Mission two
1387 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1388 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1390 .dsb $a000-*
1391
1392
1393 #define MISSIONTEMP THISMISSION+4
1394 #undef THISMISSION
1395 #define THISMISSION MISSIONTEMP
1396 #undef MISSIONTEMP
1397 #define MISSIONTEMP NEXTMISSION+4
1398 #define NEXTMISSION MISSIONTEMP
1399 #undef MISSIONTEMP
1400 #undef NEXTMISSIONFAIL
1401 #define NEXTMISSIONFAIL $ff
1402
1403 *=MISSION_CODE_START
1404 .(
1405
1406 __start_mission2_code
1407 // Jump table to mission functions
1408 // These are kind of event handlers
1409 // OnPlayerXXX. The idea is patching these with the necessary jumps. If returns C=1 it means
1410 // that text is to be plotted to screen (brief or debrief).
1411
1412 OnPlayerLaunch
1413 jmp MissionStart
1414 OnPlayerDock
1415 jmp MissionSuccess
1416 OnPlayerHyper
1417 jmp MissionSuccess
1418 OnExplodeShip
1419 jmp ShipKilled
1420 OnDockedShip
1421 jmp ShipDocked
1422 OnHyperShip
1423 clc
1424 rts
1425 .byt 00
1426 OnEnteringSystem
1427 jmp MissionEncounters
1428 OnNewEncounter
1429 clc
1430 rts
1431 .byt 00
1432
1433 // OnScoopObject return with carry =1 if it has handled the scooping, so the main program
1434 // avoids doing so.
1435
1436 OnScoopObject
1437 clc
1438 rts
1439 .byt 00
1440
1441 // Some public variables
1442 NeedsDiskLoad .byt 0 ; Will be set to $ff when a new mission needs to be loaded from disk
1443 MissionSummary .word str_Summary
1444 MissionCargo .byt 0 ; Cargo for this mission
1445
1446 // Some internal variables and code
1447
1448 ShipToProtect .byt 00
1449 Succeeded .byt 00
1450
1451 MissionStart
1452 .(
1453 lda _mission
1454 cmp #THISMISSION
1455 bne nolaunch
1456 lda _score+1
1457 beq nolaunch
1458
1459 ; launch mission
1460 inc _mission
1461 lda #<str_MissionBrief
1462 sta TXTPTRLO
1463 lda #>str_MissionBrief
1464 sta TXTPTRHI
1465
1466 sec
1467 rts
1468 nolaunch
1469 clc
1470 rts
1471 .)
1472
1473 MissionEncounters
1474 .(
1475 lda _mission
1476 cmp #THISMISSION+1
1477 bne nolaunch
1478 lda _galaxynum
1479 cmp #2
1480 bne nolaunch
1481 lda _currentplanet
1482 cmp #$8
1483 bne nolaunch
1484 jsr CreateMissionShips
1485 inc _mission
1486 clc
1487 rts
1488 nolaunch
1489 clc
1490 rts
1491 .)
1492
1493 MissionSuccess
1494 .(
1495 lda _mission
1496 cmp #THISMISSION+2
1497 bne notlaunched
1498
1499 lda Succeeded
1500 beq failure
1501
1502 lda #NEXTMISSION
1503 sta _mission
1504
1505 lda #<str_MissionDebrief
1506 sta TXTPTRLO
1507 lda #>str_MissionDebrief
1508 sta TXTPTRHI
1509
1510 sec
1511 rts
1512
1513 failure
1514 lda #<str_MissionFailure
1515 sta TXTPTRLO
1516 lda #>str_MissionFailure
1517 sta TXTPTRHI
1518
1519 lda #NEXTMISSIONFAIL
1520 sta _mission
1521 sec
1522 rts
1523
1524 notlaunched
1525 clc
1526 rts
1527 .)
1528
1529 POS1
1530 .word 0
1531 .word 0
1532 .word 0
1533 POS2
1534 .word 4500
1535 .word 0
1536 .word -6000
1537 POS3
1538 .word -4500
1539 .word 0
1540 .word -6000
1541 POS4
1542 .word -4500
1543 .word -4500
1544 .word -6000
1545
1546 CreateMissionShips
1547 .(
1548 ; Create ship fleeing...
1549 lda #<POS1
1550 sta tmp0
1551 lda #>POS1
1552 sta tmp0+1
1553 lda #SHIP_COBRA1
1554 jsr IndAddSpaceObject
1555 stx ShipToProtect
1556 lda #(FLG_FLY_TO_PLANET|FLG_INNOCENT)
1557 sta _flags,x
1558 lda #(IS_AICONTROLED|FLG_DEFENCELESS|FLG_BOLD)
1559 sta _ai_state,x
1560 lda #2
1561 sta _target,x
1562
1563 ; Create bad guys
1564 lda #<POS2
1565 sta tmp0
1566 lda #>POS2
1567 sta tmp0+1
1568 lda #SHIP_MAMBA
1569 jsr IndAddSpaceObject
1570 lda #(IS_AICONTROLED|FLG_BOLD|FLG_PIRATE)
1571 sta _ai_state,x
1572 lda ShipToProtect
1573 ora #IS_ANGRY
1574 sta _target,x
1575
1576 ; Set number of missiles to zero
1577 lda #%11111000
1578 and _missiles,x
1579 sta _missiles,x
1580
1581 lda #<POS3
1582 sta tmp0
1583 lda #>POS3
1584 sta tmp0+1
1585 lda #SHIP_MAMBA
1586 jsr IndAddSpaceObject
1587 lda #(IS_AICONTROLED|FLG_BOLD|FLG_PIRATE)
1588 sta _ai_state,x
1589 lda ShipToProtect
1590 ora #IS_ANGRY
1591 sta _target,x
1592
1593 ; Set number of missiles to zero
1594 lda #%11111000
1595 and _missiles,x
1596 sta _missiles,x
1597
1598 lda #<POS4
1599 sta tmp0
1600 lda #>POS4
1601 sta tmp0+1
1602 lda #SHIP_MAMBA
1603 jsr IndAddSpaceObject
1604 lda #(IS_AICONTROLED|FLG_PIRATE)
1605 sta _ai_state,x
1606 lda ShipToProtect
1607 ora #IS_ANGRY
1608 sta _target,x
1609
1610 ; Set number of missiles to zero
1611 lda #%11111000
1612 and _missiles,x
1613 sta _missiles,x
1614 clc
1615 rts
1616
1617 .)
1618
1619 ShipDocked
1620 .(
1621 lda _mission
1622 cmp #THISMISSION+2
1623 beq cont
1624 nothing
1625 clc
1626 rts
1627 cont
1628 cpx ShipToProtect
1629 bne nothing
1630 dec Succeeded
1631 lda #<str_hedocked
1632 sta TXTPTRLO
1633 lda #>str_hedocked
1634 sta TXTPTRHI
1635 sec
1636 rts
1637 .)
1638
1639
1640 ShipKilled
1641 .(
1642 lda _mission
1643 cmp #THISMISSION+2
1644 beq cont
1645 nothing
1646 clc
1647 rts
1648 cont
1649 cpx ShipToProtect
1650 bne nothing
1651 lda #<str_hekilled
1652 sta TXTPTRLO
1653 lda #>str_hekilled
1654 sta TXTPTRHI
1655 sec
1656 rts
1657 .)
1658
1659 str_MissionBrief
1660 .asc "MAYDAY -- MAYDAY "
1661 .byt 13
1662 .asc "My Cobra-I ship is damaged and"
1663 .byt 13
1664 .asc "I am pursued by pirates on Esrasoce."
1665 .byt 13
1666 .asc "Please help me!."
1667 .byt 0
1668
1669 str_MissionDebrief
1670 .asc "You have saved my life and I shall"
1671 .byt 13
1672 .asc "remember."
1673 .byt 0
1674
1675 str_MissionFailure
1676 .asc "Thanks for your attempt. Sadly you did"
1677 .byt 13
1678 .asc "not succeed. It was clearly too much"
1679 .byt 13
1680 .asc "for your skills."
1681 .byt 0
1682 str_hedocked
1683 .asc "Zantor docked safely!"
1684 .byt 13
1685 .asc "Mission successful"
1686 .byt 0
1687 str_hekilled
1688 .asc "Zantor has been killed!"
1689 .byt 13
1690 .asc "Mission failed"
1691 .byt 0
1692 str_Summary
1693 .byt 2
1694 .asc "Current mission:"
1695 .byt 13
1696 .byt 2
1697 .asc "Go to Esrasoce. Save Zantor from"
1698 .byt 13
1699 .byt 2
1700 .asc "pirates so he can land safely."
1701 .byt 0
1702
1703 __end_mission2_code
1704
1705 #echo ***** Missions start:
1706 #print (__start_mission2_code)
1707 #echo ***** Mission memory:
1708 #print (__end_mission2_code - __start_mission2_code)
1709 #echo
1710
1711 .)
1712
1713
1714 #endif // TESTINGMISSIONS
1715
1716
1717
1718
1719
1720
1721 #endif
1722
1723

  ViewVC Help
Powered by ViewVC 1.1.26