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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 192 - (show annotations)
Sun Jan 10 22:31:20 2010 UTC (10 years, 2 months ago) by Chema
File size: 25642 byte(s)
More modifications in the alternate scan thing. Also put back tables for player control of the ship.
1 ; Test code for TINE
2
3 #include "ships.h"
4 #include "params.h"
5 #include "tine.h"
6 #include "main.h"
7
8
9 // define where the space for object records starts...
10 #define OBS ($fffa-MAXOBJS*ObjSize)
11 #echo Object records start at
12 #print OBS
13 #echo
14
15 invert .byt 00
16 frame_time .byt 00
17
18 _init_tine
19 .(
20 lda #<OBS ;Object records
21 ldy #>OBS
22 jsr Init3D
23
24 jsr INITSTAR
25 jmp _GenerateTables ;; /* For Wireframe*/
26
27 .)
28
29
30 LoadDefaultCommander
31 .(
32 ldx #(_default_commander_end - _default_commander)-1
33 loop
34 lda _default_commander,x
35 sta _name,x
36 dex
37 bpl loop
38
39 ldx #7
40 stx _dest_num
41
42 rts
43 .)
44
45 init_view_ship
46 .(
47 jsr _EmptyObj3D
48 ; Create our ship
49 lda #0
50 sta _PosX
51 sta _PosX+1
52 sta _PosY
53 sta _PosY+1
54 sta _PosZ
55 sta _PosZ+1
56 lda #<_PosX
57 sta tmp0
58 lda #>_PosX
59 sta tmp0+1
60 lda #SHIP_DEBRIS ;)
61 jsr AddSpaceObject
62
63 ; Create the ship to watch
64 lda #<4100
65 sta _PosZ
66 lda #>4100
67 sta _PosZ+1
68 jsr _gen_rnd_number
69 and #%1111
70 clc
71 adc #15
72 ;lda #SHIP_COBRA3
73 jmp AddSpaceObject
74 .)
75
76 init_intro
77 .(
78 jsr init_view_ship
79 ; initialize front view
80 jsr _DoubleBuffOff
81 jsr clr_hires
82 jsr load_frame
83 jmp _DoubleBuffOn
84 .)
85
86 animate
87 .(
88 ldx #0
89 stx frame_time
90 jsr CalcView
91 jsr SortVis
92 jsr clr_hires2
93 jsr DrawAllVis ;Draw objects
94 jsr print_inflight_message
95 jsr dump_buf
96
97 ldx #1
98 jsr SetCurOb
99 sec
100 jsr Pitch
101 clc
102 jsr Yaw
103 clc
104 jsr Roll
105 clc
106 jsr Roll
107
108 inc frame_number
109
110 lda frame_number
111 cmp #30
112 bcs nonearer
113 ldx #0
114 jsr SetCurOb
115 lda #32
116 jmp MoveForwards
117 nonearer
118 cmp #(30+150)
119 bcc keep
120 cmp #(30+150+30)
121 bcc further
122 lda #0
123 sta frame_number
124 jmp init_view_ship
125 further
126 ldx #0
127 jsr SetCurOb
128 lda #$e0
129 jmp MoveForwards
130
131 keep
132 rts
133 .)
134
135 end_intro
136 .(
137 lda #0
138 sta message_delay
139 jsr _DoubleBuffOff
140 jsr save_frame
141 jmp _EmptyObj3D
142 .)
143
144 _init_screen
145 .(
146 ldx #2
147 jsr flight_message
148 jsr init_intro
149
150 lda #0
151 sta frame_number
152 loop
153 jsr animate
154 ; Check keyboard press
155 jsr ReadKeyNoBounce
156 cmp #"Y"
157 bne noY
158 ;jsr LoadSavedCommander
159 jmp end
160 noY
161 cmp #"N"
162 bne loop
163 jsr LoadDefaultCommander
164 end
165 ;jsr SndPic
166 jsr NewPlayerShip
167 jmp end_intro
168
169 .)
170
171
172 _init_screen2
173 .(
174 ldx #3
175 jsr flight_message
176
177 jsr init_intro
178
179 lda #0
180 sta frame_number
181 loop
182 jsr animate
183 ; Check keyboard press
184 jsr ReadKeyNoBounce
185 cmp #" "
186 bne loop
187 ;jsr SndPic
188 jmp end_intro
189 .)
190
191
192
193 init_front_view
194 .(
195 jsr clr_hires
196 jsr load_frame
197 ;jsr _DrawFrameBorder
198 jsr _DoubleBuffOn
199 ;jmp _FirstFrame ; Let the program flow...
200 .)
201 _FirstFrame
202 .(
203
204 jsr update_all_controls
205
206 lda #PDIST_MASSLOCK
207 sta _planet_dist
208
209 lda #0
210 sta frame_time
211 sta counter
212
213 jsr clr_hires2
214
215 lda invert
216 beq noinvert
217 jsr invertZ
218 noinvert
219
220 ldx VOB ;Calculate view
221 jsr SetRadar
222 jsr CalcView
223 jsr SortVis ;Sort objects
224 jsr DrawAllVis ;Draw objects
225 jsr DrawRadar
226 jsr set_compass
227 jsr set_planet_distance
228
229 lda invert
230 beq noinvert2
231 jsr invertZ
232 noinvert2
233
234 jmp dump_buf
235 .)
236
237
238 frame_number .byt 0
239 player_in_control .byt $0
240 attr_changed .byt 0
241
242 invertZ
243 .(
244 ldx VOB
245 jsr GetObj
246 clc
247 adc #ObjMat
248 bcc cont
249 iny
250 cont
251 sta tmp0
252 sty tmp0+1
253
254 ldy #6
255 ldx #3
256 loop
257 sec
258 lda #0
259 sbc (tmp0),y
260 sta (tmp0),y
261 iny
262 dex
263 bne loop
264
265 rts
266 .)
267
268
269 set_planet_distance
270 .(
271 ; Check distance to planet
272 ldx VOB
273 jsr SetCurOb
274 ldx #2 ;Planet
275 jsr substract_positions
276 jsr getnorm ; Calc distance as A=abs(x)|abs(y)|abs(z)
277 lda op1+1 ; Get high byte
278 sta _planet_dist
279 rts
280 .)
281
282 _TineLoop
283 .(
284 lda _docked
285 beq loop
286 jsr ProcessKeyboard
287 jmp _TineLoop
288
289 loop
290 lda #0
291 ldx NUMOBJS
292 loopcl
293 sta _vertexXLO-1,x
294 sta _vertexXHI-1,x
295 sta _vertexYLO-1,x
296 sta _vertexYHI-1,x
297 dex
298 bne loopcl
299
300
301 lda attr_changed
302 beq nochange
303 lda #A_FWWHITE
304 jsr set_ink
305 lda #0
306 sta attr_changed
307 nochange
308 jsr _Tactics
309
310 lda _planet_dist
311 cmp #06
312 bcs nodock
313
314 ; Docking ship... must call docking sequence
315 lda _current_screen
316 cmp #SCR_FRONT
317 bne l1
318 jsr _DoubleBuffOff
319 jsr save_frame
320 l1
321 dec _docked
322 jsr info
323 jmp _TineLoop
324
325 nodock
326
327 jsr ProcessKeyboard
328
329 lda invert
330 beq noinvert
331 jsr invertZ
332 noinvert
333
334 ldx VOB
335 jsr SetCurOb
336 ;ldx VOB
337 jsr SetRadar
338
339 jsr CalcView
340 jsr SortVis
341
342 lda _current_screen
343 cmp #SCR_FRONT
344 bne nodraw
345
346 lda counter
347 sta frame_time
348 ldx #0
349 stx counter
350
351 //#ifndef ALTSCANS
352 cmp #MAXFRAMETIME+5
353 bcs nodraw
354 //#endif
355
356
357 ;;;;; START OF DRAWING SECTION
358 jsr move_stars
359 sei
360 jsr clr_hires2
361 jsr DrawAllVis ;Draw objects
362 jsr EraseRadar ; Erase radar
363 jsr DrawRadar
364 cli
365 jsr PlotStars
366 jsr _DrawCrosshair
367 jsr _Lasers
368 lda _laser_fired
369 beq nofire
370 inc _laser_fired ; Set back to 0
371 jsr _DrawLaser
372 nofire
373
374 lda message_delay
375 beq nomessage
376 dec message_delay
377 jsr print_inflight_message
378 nomessage
379
380 #ifdef DBGVALUES
381 jsr print_dbgval
382 #endif
383 dec print2dbuffer
384 ldx #(15*6)
385 ldy #0
386 jsr gotoXY
387 lda invert
388 beq noinv
389 lda #<str_rearview
390 ldx #>str_rearview
391 jmp doinv
392 noinv
393 lda #<str_frontview
394 ldx #>str_frontview
395 doinv
396 jsr print
397 inc print2dbuffer
398 sei
399 jsr dump_buf
400 cli
401 lda _planet_dist
402 cmp #PDIST_TOOFAR2
403 bcs nocompass
404 jsr update_compass
405 jmp endcompass
406 nocompass
407 jsr clear_compass
408 endcompass
409 ;;;;;;;;;;;;;;;;;;;;;;;;; END OF DRAWING SECTION
410
411
412 nodraw
413 lda invert
414 beq noinvert2
415 jsr invertZ
416 noinvert2
417
418 lda player_in_control
419 beq cont
420 jsr _CheckHits ; Should be called after DrawAllVis!!!!
421
422 jsr damp
423 lda #0
424 sta yawing
425 sta pitching
426 sta rolling
427
428 lda _current_screen
429 cmp #SCR_FRONT
430 bne cont
431 jsr dorolls
432 cont
433 jsr _MoveShips
434
435 ; remove energy bomb launched if active
436 lda _energy_bomb
437 beq contbomb
438 dec _energy_bomb
439 contbomb
440 ; Perform timely checks
441 ;lda #1
442 ;eor frame_number
443 lda frame_number
444 and #7
445 beq checkthings
446 jmp cont2
447
448 checkthings
449 jsr set_planet_distance
450
451 ; Setup planet distance light indicator
452
453 jsr planet_light
454
455 ; Start with energy and shields
456 lda _energy+1
457 bmi no_energy
458 beq no_energy
459
460 cmp _p_maxenergy
461 bcs noinc_energy
462 inc _energy+1
463 bne done_energy ; branches allways
464 noinc_energy
465 ; If redirecting power to lasers, don't recharge
466 lda _ptla
467 bne done_energy
468
469 lda _front_shield
470 cmp #22
471 beq done_front
472 inc _front_shield
473 cmp #21
474 beq done_front
475 ; If redirecting power to shields, double recharge
476 lda _ptsh
477 beq done_front
478 inc _front_shield
479 done_front
480 lda _rear_shield
481 cmp #22
482 beq done_rear
483 inc _rear_shield
484 cmp #21
485 beq done_rear
486 ; If redirecting power to shields, double recharge
487 lda _ptsh
488 beq done_front
489 inc _rear_shield
490 done_rear
491 jsr update_shields_panel
492 done_energy
493 jmp locking
494 no_energy
495 ; We should be dead here
496
497 lda message_delay
498 ora player_in_control
499 bne locking
500 rts
501
502 locking
503 ; Locking computer
504 lda player_in_control
505 beq notarget
506 lda _missile_armed
507 bpl notarget ; Nothing to do if already locked or unarmed
508 jsr FindTarget
509 lda _ID
510 beq notarget
511 sta _missile_armed
512 ; Print Target Locked message
513 ldx #STR_TARGET_LOCKED
514 jsr flight_message
515 jsr update_missile_panel
516 notarget
517 ; If redirecting power to shields, don't cool
518 lda _ptsh
519 bne notemp
520 ldx LaserTemperature
521 beq notemp
522 dex
523 beq nodoubl
524 ; If redirecting power to laser cooling, double cooling
525 lda _ptla
526 beq nodoubl
527 dex
528 nodoubl
529 stx LaserTemperature
530 donelaser
531 jsr update_temperature_panel
532 notemp
533 lda _ecm_counter
534 beq noecm
535 dec _ecm_counter
536 bne noecm
537 jsr update_ecm_panel
538 noecm
539
540 ; ...
541
542 cont2
543 ; Check for new encounters
544 lda frame_number
545 ;and #%1111111
546 bne cont3
547 jsr random_encounter
548 cont3
549 ; Increment the counter of frames
550 inc frame_number
551
552 ; Update everything that needs to be
553 jsr update_speed_panel
554 jsr update_energy_panel
555 nofr
556 jmp loop
557
558 .)
559
560 str_rearview
561 .asc "Rear View"
562 .byt 0
563
564 str_frontview
565 .asc "Front View"
566 .byt 0
567
568
569 #ifdef DBGVALUES
570 dbg1 .word $0000
571 dbg2 .word $0000
572 dbg3 .word $0000
573
574
575 // DEBUGGING
576
577 print_dbgval
578 .(
579
580 lda _current_screen
581 cmp #SCR_FRONT
582 beq doit
583 jmp end
584 doit
585 dec print2dbuffer
586
587 #ifdef 0
588 ; Debug our energy value
589 ;lda _energy+1
590 ;sta dbg1
591 ;lda #0
592 ;sta dbg1+1
593
594 ; Debug a_y
595 ;lda a_y
596 ;sta dbg2
597 ;lda #0
598 ;sta dbg2+1
599
600 ; Debug ship pos
601 ldx #1
602 jsr GetShipPos
603 ldx #5
604 loop
605 lda _PosX,x
606 sta dbg1,x
607 dex
608 bpl loop
609 #endif
610 lda frame_time
611 sta op2
612 lda #0
613 sta op2+1
614 ldx #0
615 ldy #0
616 jsr gotoXY
617 ldx #5
618 jsr print_num_tab
619 #ifdef 0
620 lda dbg1
621 sta op2
622 lda dbg1+1
623 sta op2+1
624 ldx #47
625 ldy #0
626 jsr gotoXY
627 ldx #5
628 jsr print_num_tab
629
630 lda dbg2
631 sta op2
632 lda dbg2+1
633 sta op2+1
634 ldx #47+48
635 ldy #0
636 jsr gotoXY
637 ldx #5
638 jsr print_num_tab
639
640 lda dbg3
641 sta op2
642 lda dbg3+1
643 sta op2+1
644 ldx #47+48+48
645 ldy #0
646 jsr gotoXY
647 ldx #5
648 jsr print_num_tab
649
650
651 lda _speed+1
652 sta op2
653 lda #0
654 sta op2+1
655 ldx #47+48+48+48
656 ldy #0
657 jsr gotoXY
658 ldx #5
659 jsr print_num_tab
660 #endif
661 inc print2dbuffer
662
663 end
664 rts
665 .)
666 #endif
667
668 ;; Now the keyboard map table
669 #define MAX_KEY 22
670 user_keys
671 .byt "2", "3", "4", "5", "6", "7", "0", "R", "H", "J", "1"
672 .byt "S", "X", "N", "M", "A", "T", "F", "U", "E", "P", "B", "V"
673
674 key_routh
675 .byt >(info), >(sysinfo), >(short_chart), >(gal_chart), >(market), >(equip), >(loadsave), >(splanet), >(galhyper), >(jumphyper), >(frontview)
676 .byt >(keydn), >(keyup), >(keyl), >(keyr), >(sele), >(target), >(fireM), >(unarm), >(ecm_on), >(power_redir), >(energy_bomb), >(rearview)
677 key_routl
678 .byt <(info), <(sysinfo), <(short_chart), <(gal_chart), <(market), <(equip), <(loadsave), <(splanet), <(galhyper), <(jumphyper), <(frontview)
679 .byt <(keydn), <(keyup), <(keyl), <(keyr), <(sele), <(target), <(fireM), <(unarm), <(ecm_on), <(power_redir), <(energy_bomb), <(rearview)
680
681
682 /* M= byte 3 val 1
683 N= byte 1 val 2
684 X= byte 1 val 64
685 S= byte 7 val 64
686 A= byte 7 val 32
687 Q= byte 2 val 64
688 W= byte 7 val 128
689 O= byte 6 val 4
690 L= byte 8 val 2
691 B= byte 3 val 4 */
692
693 #define NUM_SIM_KEYS 8
694 tab_ship_control_byte
695 .byt 2,0,0,6,6,1,6,5,7;,2
696 tab_ship_control_val
697 .byt 1,2,64,64,32,64,128,4,2;,4
698
699 tab_ship_control_routh
700 .byt >yawr,>yawl,>pitchup,>pitchdn,>fireL,>rolll,>rollr,>accel,>deccel;,>fireM
701 tab_ship_control_routl
702 .byt <yawr,<yawl,<pitchup,<pitchdn,<fireL,<rolll,<rollr,<accel,<deccel;,<fireM
703
704
705 ShipControl
706 .(
707 lda _current_screen
708 cmp #SCR_FRONT
709 bne noship
710 ldx #NUM_SIM_KEYS
711 bne loop ; allways branches
712 noship
713 ldx #3
714 loop
715 lda tab_ship_control_byte,x
716 tay
717 lda tab_ship_control_val,x
718 and KeyBank,y
719 beq skip
720 stx savx+1
721 lda tab_ship_control_routl,x
722 sta rout+1
723 lda tab_ship_control_routh,x
724 sta rout+2
725 rout
726 jsr $1234
727 savx
728 ldx #0
729 skip
730 dex
731 bpl loop
732 rts
733 .)
734
735
736 ProcessKeyboard
737 .(
738 lda player_in_control
739 beq end
740
741 jsr ShipControl
742
743 lda _current_screen
744 cmp #SCR_CHART
745 beq cross
746 cmp #SCR_GALAXY
747 bne cont1
748 cross
749 jsr MoveCross
750 cont1
751 jsr ReadKeyNoBounce
752 beq end
753
754
755 ; Ok a key was pressed, let's check
756 ldx #MAX_KEY
757 loop
758 cmp user_keys,x
759 beq found
760 dex
761 bpl loop
762 bmi end
763
764 found
765 lda key_routl,x
766 sta routine+1
767 lda key_routh,x
768 sta routine+2
769
770 cont
771 cpx #8
772 bcs skip
773
774 ; No market or equip or save if not docked
775 lda _docked
776 bne isdock
777 cpx #4
778 beq end
779 cpx #5
780 beq end
781 cpx #6
782 beq end
783 ; No planet search either
784 cpx #7
785 beq end
786
787 isdock
788 lda double_buff
789 beq skip
790 stx savx+1
791 jsr _DoubleBuffOff
792 jsr save_frame
793 savx
794 ldx #0 ; SMC
795
796 skip
797
798 routine
799 ; Call the routine
800 jsr $1234 ; SMC
801
802 end
803 lda _current_screen
804 cmp #SCR_FRONT
805 bne ret
806
807 lda #0
808 ldx #7
809 loopb
810 sta KeyBank,x
811 dex
812 bpl loopb
813 ret
814 rts
815 .)
816
817
818
819 a_y .byt 0
820 a_p .byt 0
821 a_r .byt 0
822
823 yawing .byt 0
824 pitching .byt 0
825 rolling .byt 0
826
827 #define MAXR 7 ;6 ;9 ;6 ;3 ;4
828 #define MINR $f8 ;$fa ;$f7 ;$fa; $fd ;fc
829
830 yawr
831 .(
832 lda a_y
833 bpl doinc
834 lda #0
835 sta a_y
836 beq end
837 doinc
838 inc a_y
839 lda #MAXR
840 cmp a_y
841 bpl end
842 sta a_y
843 end
844 lda #1
845 sta yawing
846 rts
847 .)
848 yawl
849 .(
850 lda a_y
851 bmi doinc
852 beq doinc
853 lda #0
854 sta a_y
855 beq end
856 doinc
857 dec a_y
858 lda #MINR
859 cmp a_y
860 bmi end
861 sta a_y
862 end
863 lda #1
864 sta yawing
865 rts
866 .)
867 pitchdn
868 .(
869 lda a_p
870 bmi doinc
871 beq doinc
872 lda #0
873 sta a_p
874 beq end
875 doinc
876 dec a_p
877 lda #MINR
878 cmp a_p
879 bmi end
880 sta a_p
881 end
882 lda #1
883 sta pitching
884 rts
885
886 .)
887 pitchup
888 .(
889 lda a_p
890 bpl doinc
891 lda #0
892 sta a_p
893 beq end
894 doinc
895 inc a_p
896 lda #MAXR
897 cmp a_p
898 bpl end
899 sta a_p
900 end
901 lda #1
902 sta pitching
903 rts
904 .)
905 rolll
906 .(
907 lda a_r
908 bmi doinc
909 beq doinc
910 lda #0
911 sta a_r
912 beq end
913 doinc
914 dec a_r
915 lda #MINR
916 cmp a_r
917 bmi end
918 sta a_r
919 end
920 lda #1
921 sta rolling
922 rts
923 .)
924 rollr
925 .(
926 lda a_r
927 bpl doinc
928 lda #0
929 sta a_r
930 beq end
931 doinc
932 inc a_r
933 lda #MAXR
934 cmp a_r
935 bpl end
936 sta a_r
937 end
938 lda #1
939 sta rolling
940 rts
941 .)
942
943
944 accel
945 ; Accelerate
946 lda #1
947 .byt $2C
948 deccel
949 lda #$ff
950 sta _accel+1
951 rts
952
953 target
954 .(
955 lda _missiles_left
956 beq no_arm
957 lda _missile_armed
958 bne no_arm
959 ; Arm missile and start target procedure
960 ;jsr SndBell1
961 jsr SndPoc
962 ldx #STR_TARGET_ARMED
963 jsr flight_message
964 dec _missile_armed ; This sets it to $ff
965 jsr update_missile_panel
966 no_arm
967 rts
968 .)
969 unarm
970 .(
971 ; This could simply set it to 0
972 ; and save memory and CPU, but as it also may
973 ; produce some sfx and panel changes, it may be worth a check
974 lda _missile_armed
975 beq no_unarm
976 jsr SndPocLow
977 ldx #STR_TARGET_UNARMED
978 jsr flight_message
979 lda #UNARMED ; Set it to 0
980 sta _missile_armed
981 jsr update_missile_panel
982 no_unarm
983 rts
984 .)
985 fireM
986 .(
987 ; Shoud this be defered to LaunchMissile??
988 lda _missiles_left
989 beq nolock
990 lda _missile_armed
991 beq nolock
992 bmi nolock
993
994 ; Missile is locked, fire it
995 sta AITarget
996 ldx #1
997 jsr SetCurOb
998 jsr LaunchMissile
999 jsr SndMissile
1000 beq nolock
1001 dec _missiles_left
1002 jsr update_missile_panel
1003 nolock
1004 rts
1005 .)
1006 fireL
1007 .(
1008 lda invert
1009 beq dofire
1010 rts
1011 dofire
1012 jmp FireLaser
1013 .)
1014
1015 energy_bomb
1016 .(
1017 ; Player launches energy bomb
1018 ; Check if equipped
1019 lda _equip
1020 and #%100000
1021 beq nobomb
1022 ; It needs energy
1023 lda _energy+1
1024 cmp #21+5 ; Some securiy margin
1025 bcc nobomb
1026 sec
1027 sbc #20
1028 sta _energy+1
1029 ; Remove equip
1030 lda _equip
1031 and #%11011111
1032 sta _equip
1033 ; Activate bomb
1034 inc _energy_bomb
1035 nobomb
1036 rts
1037
1038 .)
1039
1040 ecm_on
1041 .(
1042 ; player sets ECM on.
1043 ; Check if he has ECM equipped
1044 lda _equip
1045 and #%10000
1046 beq noecm
1047 ; It needs energy
1048 lda _energy+1
1049 cmp #11+5 ; Some security margin
1050 bcc noecm
1051 sec
1052 sbc #10
1053 sta _energy+1
1054 jmp SetECMOn
1055 noecm
1056 rts
1057 .)
1058 ; P
1059 power_redir
1060 .(
1061 jsr SndPic
1062 lda _ptla
1063 beq step2
1064 lda #0
1065 sta _ptla
1066 lda #1
1067 sta _ptsh
1068 jmp update_redirection
1069 step2
1070 lda _ptsh
1071 beq step3
1072 lda #0
1073 sta _ptsh
1074 jmp update_redirection
1075 step3
1076 lda #0
1077 sta _ptsh
1078 lda #1
1079 sta _ptla
1080 jmp update_redirection
1081 .)
1082 ;V
1083 rearview
1084 .(
1085 lda #SCR_FRONT
1086 cmp _current_screen
1087 beq lookrear
1088 rts
1089 lookrear
1090 lda invert
1091 eor #$ff
1092 sta invert
1093 jsr update_compass
1094 jmp INITSTAR
1095 .)
1096 ;H
1097 galhyper
1098 .(
1099 lda #SCR_FRONT
1100 cmp _current_screen
1101 bne end
1102 lda invert
1103 bne end
1104
1105 ; Test if we have the Galactic Hyperspace equipped
1106 lda _equip
1107 and #%10000000
1108 beq end
1109
1110 ; If too close to planet cannot jump
1111 lda _planet_dist
1112 cmp #PDIST_MASSLOCK
1113 bcs canjump
1114 ldx #STR_MASS_LOCKED
1115 jmp flight_message
1116 canjump
1117 ; Should start sequence, but not perform the jump right now...
1118 jsr init_hyper_seq
1119 bcc dojump
1120 ldx #STR_PATH_LOCKED
1121 jmp flight_message
1122
1123 dojump
1124 ; Remove Galactic Hyperspace
1125 lda _equip
1126 and #%01111111
1127 sta _equip
1128 jmp do_galjump
1129 end
1130 rts
1131 .)
1132
1133 ;J
1134 jumphyper
1135 .(
1136 lda #SCR_FRONT
1137 cmp _current_screen
1138 bne nothing
1139
1140 lda invert
1141 bne nothing
1142
1143 ; Compare current_planet with dest_planet too see if it is a "bad jump"
1144 ; and simply ignore
1145 lda _dest_num
1146 cmp _currentplanet
1147 bne good
1148 rts
1149 good
1150 ; Compare distance and check it is not a "hyperspace range?"
1151 ; 16-bit unsigned comparison... inlined
1152 lda _fuel ; op1-op2
1153 cmp _dest_dist
1154 lda #0
1155 sbc _dest_dist+1
1156 .(
1157 bvc ret ; N eor V
1158 eor #$80
1159 ret
1160 .)
1161 bcs endjump
1162 ; Cannot jump
1163 ldx #STR_HYPRANGE
1164 jmp flight_message
1165
1166 endjump
1167 ; If too close to planet cannot jump
1168 lda _planet_dist
1169 cmp #PDIST_MASSLOCK
1170 bcs canjump
1171 ldx #STR_MASS_LOCKED
1172 jmp flight_message
1173 canjump
1174 ; Should start sequence, but not perform the jump right now...
1175 jsr init_hyper_seq
1176 bcc dojump
1177 ldx #STR_PATH_LOCKED
1178 jmp flight_message
1179
1180 dojump
1181 jmp do_jump
1182 .)
1183 ;1
1184 frontview
1185 lda #SCR_FRONT
1186 cmp _current_screen
1187 beq nothing
1188 sta _current_screen
1189
1190 lda _docked
1191 beq notdocked
1192 lda #0
1193 sta invert
1194 ; Exit to space...
1195 jsr CreateEnvironment
1196 ; We update the _docked variable AFTER CreateEnvironment, so it can be used
1197 ; to decide if we are exitting hyper or leaving planet.
1198 inc _docked ; docked is either ff or 0, this gets it back to 0,
1199 notdocked
1200 jmp init_front_view ; This is jsr/rts
1201 nothing
1202 rts
1203 ;2
1204 info
1205 jsr SndPic
1206 lda #SCR_INFO
1207 sta _current_screen
1208 jmp _displayinfo
1209 ;3
1210 sysinfo
1211 jsr SndPic
1212 lda #SCR_SYSTEM
1213 sta _current_screen
1214 jmp _printsystem
1215
1216 ;4
1217 short_chart
1218 jsr SndPic
1219 lda #SCR_CHART
1220 sta _current_screen
1221 jmp _plot_chart
1222 ;5
1223 gal_chart
1224 jsr SndPic
1225 lda #SCR_GALAXY
1226 sta _current_screen
1227 jmp _plot_galaxy
1228
1229 ;6
1230 market
1231 jsr SndPic
1232 lda #SCR_MARKET
1233 sta _current_screen
1234 jmp _displaymarket
1235
1236 ;7
1237 equip
1238 jsr SndPic
1239 lda #SCR_EQUIP
1240 sta _current_screen
1241 jmp _displayequip
1242
1243 ;0
1244 loadsave
1245 jsr SndPic
1246 lda #SCR_LOADSAVE
1247 sta _current_screen
1248 jmp _displayloadsave
1249
1250 ;R
1251 splanet
1252 jsr SndPic
1253 lda _current_screen
1254 cmp #SCR_GALAXY
1255 beq doit
1256 ; cmp #SCR_CHART
1257 ; beq doit
1258 rts
1259 doit
1260 ; ask for planet and search it
1261 jsr prepare_area
1262 lda #(A_FWGREEN+A_FWYELLOW*16+128)
1263 jsr put_code
1264 lda #<str_searchplanet
1265 ldx #>str_searchplanet
1266 jsr print
1267 lda #A_FWWHITE
1268 jsr put_code
1269 jsr gets
1270 jmp _search_planet ; This is jsr/rts
1271
1272
1273 ;;;; END OF TABLE
1274
1275
1276
1277 do_jump
1278 .(
1279 ; Remove fuel
1280 lda _fuel
1281 sec
1282 sbc _dest_dist
1283 sta _fuel
1284 lda _fuel+1
1285 sbc _dest_dist+1
1286 sta _fuel+1
1287
1288 ; Perform the jumping
1289 +tailjump
1290 jsr _jump
1291 ; Clear legal status a bit
1292 lda _legal_status
1293 lsr
1294 sta _legal_status
1295 ; Erase radar and compass and create environment
1296 jsr EraseRadar
1297 jsr clear_compass
1298 jsr CreateEnvironment
1299 ; Draw first frame
1300 jmp _FirstFrame
1301 ;rts
1302 .)
1303
1304 do_galjump
1305 .(
1306 jsr _enter_next_galaxy
1307 lda #0
1308 sta _legal_status
1309 jmp tailjump
1310 .)
1311
1312 check_scr
1313 .(
1314 lda _current_screen
1315 ;cmp #SCR_GALAXY
1316 ;beq retnz
1317 ;cmp #SCR_CHART
1318 ;beq retnz
1319 cmp #SCR_MARKET
1320 beq retz
1321 cmp #SCR_EQUIP
1322 beq retz
1323 cmp #SCR_LOADSAVE
1324 beq retz
1325
1326 sec
1327 rts
1328 retz
1329 clc
1330 rts
1331
1332 .)
1333
1334 keydn
1335 .(
1336 jsr check_scr
1337 bcc do
1338 rts
1339 do
1340 jmp _dec_sel
1341
1342 .)
1343
1344
1345 keyup
1346 .(
1347 jsr check_scr
1348 bcc do
1349 rts
1350 do
1351 jmp _inc_sel
1352
1353 .)
1354
1355
1356 keyl
1357 .(
1358 lda _current_screen
1359 cmp #SCR_EQUIP
1360 beq ret
1361 cmp #SCR_LOADSAVE
1362 beq ret
1363 jsr check_scr
1364 bcc do
1365 ret
1366 rts
1367 do
1368 jmp _sell
1369
1370 .)
1371
1372
1373 keyr
1374 .(
1375 lda _current_screen
1376 cmp #SCR_EQUIP
1377 beq ret
1378 cmp #SCR_LOADSAVE
1379 beq ret
1380 jsr check_scr
1381 bcc do
1382 ret
1383 rts
1384 do
1385 jmp _buy
1386
1387 .)
1388
1389 sele
1390 .(
1391 lda _current_screen
1392 cmp #SCR_GALAXY
1393 beq doit2
1394 cmp #SCR_CHART
1395 beq doit2
1396 cmp #SCR_EQUIP
1397 beq bequip
1398 cmp #SCR_LOADSAVE
1399 bne ret
1400 ; Jump to load/save
1401 jmp do_loadsave
1402 bequip
1403 ; Jump to acquire equipment
1404 jmp buy_equip
1405 ret
1406 rts
1407 doit2
1408 jmp _find_planet
1409 .)
1410
1411
1412 #ifdef TABBEDROLLS
1413 tab_rolls .byt 0,1,1,1,2,2,3,4,6
1414
1415 dorolls
1416 .(
1417 .(
1418 ; Transform a_whatever in rot_whatever
1419 lda a_y
1420 bpl notneg
1421 lda #0
1422 sec
1423 sbc a_y
1424 tax
1425 lda tab_rolls,x
1426 ora #%10000000
1427 bmi store
1428 notneg
1429 tax
1430 lda tab_rolls,x
1431
1432 store
1433 sta _roty+1
1434 .)
1435
1436 .(
1437 ; Transform a_whatever in rot_whatever
1438 lda a_p
1439 bpl notneg
1440 lda #0
1441 sec
1442 sbc a_p
1443 tax
1444 lda tab_rolls,x
1445 ora #%10000000
1446 bmi store
1447 notneg
1448 tax
1449 lda tab_rolls,x
1450 store
1451 sta _rotx+1
1452 .)
1453
1454 .(
1455 ; Transform a_whatever in rot_whatever
1456 lda a_r
1457 bpl notneg
1458 lda #0
1459 sec
1460 sbc a_r
1461 tax
1462 lda tab_rolls,x
1463 ora #%10000000
1464 bmi store
1465 notneg
1466 tax
1467 lda tab_rolls,x
1468 store
1469 sta _rotz+1
1470 .)
1471
1472 rts
1473 .)
1474
1475 #else
1476 dorolls
1477 .(
1478 .(
1479 ; Transform a_whatever in rot_whatever
1480 lda a_y
1481 bpl notneg
1482 lda #0
1483 sec
1484 sbc a_y
1485 ora #%10000000
1486 bmi store
1487 notneg
1488 store
1489 sta _roty+1
1490 .)
1491
1492 .(
1493 ; Transform a_whatever in rot_whatever
1494 lda a_p
1495 bpl notneg
1496 lda #0
1497 sec
1498 sbc a_p
1499 ora #%10000000
1500 bmi store
1501 notneg
1502 store
1503 sta _rotx+1
1504 .)
1505
1506 .(
1507 ; Transform a_whatever in rot_whatever
1508 lda a_r
1509 bpl notneg
1510 lda #0
1511 sec
1512 sbc a_r
1513 ora #%10000000
1514 bmi store
1515 notneg
1516 store
1517 sta _rotz+1
1518 .)
1519
1520 rts
1521 .)
1522
1523
1524
1525 #endif
1526
1527
1528
1529 MoveCross
1530 .(
1531 lda pitching
1532 beq next1
1533 lda a_p
1534 beq next1
1535 jsr _move_cross_v
1536 lda #0
1537 sta a_p
1538 next1
1539 lda yawing
1540 beq next2
1541 lda a_y
1542 beq next2
1543 jsr _move_cross_h
1544 lda #0
1545 sta a_y
1546 next2
1547 rts
1548 .)
1549
1550
1551 damp
1552 .(
1553 ; Dampen rotations
1554
1555 .(
1556 lda yawing
1557 bne end
1558 lda a_y
1559 bmi neg
1560 beq end
1561 dec a_y
1562 bpl end
1563 neg
1564 inc a_y
1565 end
1566 .)
1567
1568 .(
1569 lda rolling
1570 bne end
1571 lda a_r
1572 bmi neg
1573 beq end
1574 dec a_r
1575 bpl end
1576 neg
1577 inc a_r
1578 end
1579 .)
1580
1581 .(
1582 lda pitching
1583 bne end
1584 lda a_p
1585 bmi neg
1586 beq end
1587 dec a_p
1588 bpl end
1589 neg
1590 inc a_p
1591 end
1592 .)
1593 rts
1594 .)
1595
1596 init_hyper_seq
1597 .(
1598
1599 ; Check if path is locked (collision danger)
1600 jsr FindTarget
1601 lda _ID
1602 beq pathfree
1603
1604 ; path is locked!
1605 ;return with C=1
1606 sec
1607 rts
1608
1609 pathfree
1610
1611 lda #20
1612 sta co
1613 loop
1614 ldx #1
1615 jsr SetCurOb
1616 lda #50
1617 jsr MoveForwards
1618
1619 ldx #1
1620 jsr CalcView
1621 jsr SortVis
1622 ;jsr clr_hires2
1623 jsr DrawAllVis ;Draw objects
1624
1625 lda #20
1626 sta g_theta
1627 jsr move_stars
1628 jsr PlotStars
1629 ;jsr _DrawCrosshair
1630
1631 jsr dump_buf
1632
1633 dec co
1634 bne loop
1635
1636 ; Return with C=0 to continue jump
1637 clc
1638 rts
1639
1640 co .byt $00
1641 .)
1642
1643
1644 VOB .byt 00 ;View object
1645
1646 ;Pattern table
1647 #define SOLID 0
1648 #define DITHER1 1
1649 #define DITHER2 2
1650 #define ZIGS 3
1651 #define ZAGS 4
1652 #define ZIGZAG 5
1653 #define CROSSSM 6
1654 #define BRICK 7
1655 #define SQUARES 8
1656 #define INVSQ 9
1657 #define HOLES 10
1658 #define HSTRIPES 11
1659 #define VSTRIPES 12
1660
1661
1662
1663 ONEDOT
1664 .byt DEBRIS ;Debris object
1665 .byt 1 ;Number of points
1666 .byt 1 ;Number of faces
1667 .byt 0,0,0 ;Normal (unused)
1668
1669 ; Point list
1670 .byt 0
1671 .byt 0
1672 .byt 0
1673
1674 ; Face list
1675 .byt 1 ;Number of vertices
1676 .byt 0 ;Fill pattern
1677 .byt 0 ;Vertices
1678
1679
1680
1681 ONEPLANET
1682 .byt PLANET ;Sun or planet Object
1683 .byt 1 ;Number of points
1684 .byt 1 ;Number of faces
1685 .byt 0,0,0 ;Normal (unused)
1686 ; Point list
1687
1688 .byt 0
1689 .byt 0
1690 .byt 0
1691
1692 ; Face list
1693 .byt 1 ;Number of vertices
1694 .byt SOLID ;5 ;Fill pattern
1695 .byt 0 ;Vertices
1696
1697 ONEMOON
1698 .byt MOON ;Moon Object
1699 .byt 1 ;Number of points
1700 .byt 1 ;Number of faces
1701 .byt 0,0,0 ;Normal (unused)
1702
1703 ; Point list
1704 .byt 0
1705 .byt 0
1706 .byt 0
1707
1708 ; Face list
1709 .byt 1 ;Number of vertices
1710 .byt 5 ;Fill pattern
1711 .byt 0 ;Vertices

  ViewVC Help
Powered by ViewVC 1.1.26