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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 204 - (hide annotations)
Thu Jan 21 18:29:33 2010 UTC (10 years, 4 months ago) by Chema
File size: 29935 byte(s)
Small minor additions and some cleaning of code.

Added a worm and a missile counter, so we can limit their number for computer AIs. Limits in defines in tine.h

Radar and scanner are updated only every 2 frames.

Asteroids now rotate.

Found a bug in the radar. It needs a lot of space to work with all the possible objects, but that is indeed a waste, so need to clean up that code, which is indeed a mess.

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

  ViewVC Help
Powered by ViewVC 1.1.26