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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 177 - (show annotations)
Tue Dec 22 19:21:26 2009 UTC (10 years, 5 months ago) by Chema
File size: 12100 byte(s)
Corrected a bug where thargons were not given the ECM. Also thargoids carried are random (0-3).

Tested that it is possible to fight a thargon. It is, if well equipped, but the trick of firing a missile when very close is quite helpful.

Adapted the ship size to the scaled-down versions.

Corrected the bug where planet_distance was not correctly set at the first frame. Now you can't jump just after undocking.

Corrected the visibility distance, so it is no more possible that a ship in front of you fires, while it is not visible (lasers incorrectly drawn).

Added shipdatal.xls (with the scaling factor and size) to the repository.
1
2 ; Routines to print HUD strings
3
4 #include "cockpit.h"
5 #include "main.h"
6
7
8 message_delay .byt 00
9 message_buffer .dsb 30
10 message_X .byt 00
11
12 ; Needs to center strings
13
14 ; Calculate the length of the string
15 strlen
16 .(
17 ldx #$ff
18 loop
19 inx
20 lda str_buffer,x
21 bne loop
22
23 rts
24 .)
25
26
27
28 flight_message_loot
29 .(
30
31 inc capson
32 inc print2buffer
33 lda #0
34 sta buffercounter
35 lda #<Goodnames
36 sta tmp0
37 lda #>Goodnames
38 sta tmp0+1
39 jsr search_string_and_print
40
41 dec print2buffer
42 dec capson
43
44 jmp flight_message_end
45 .)
46
47
48
49 flight_message_bounty
50 .(
51
52 inc capson
53 inc print2buffer
54 lda #0
55 sta buffercounter
56 jsr print_float
57 jsr put_space
58 lda #<str_credits
59 ldx #>str_credits
60 jsr print
61 dec print2buffer
62 dec capson
63
64 jmp flight_message_end
65 .)
66
67
68 ; Pass X=message id
69
70 patchmsg .byt 0
71 flight_message
72 .(
73 cpx #STR_ENERGY_LOW
74 bne nopatch
75 inc patchmsg
76 nopatch
77 lda #<flight_message_base
78 sta tmp0
79 lda #>flight_message_base
80 sta tmp0+1
81
82 ; Print message id to buffer
83 inc print2buffer
84 inc capson
85 lda #0
86 sta buffercounter
87 jsr search_string_and_print
88 dec print2buffer
89 dec capson
90
91 +flight_message_end
92 ; Calculate length of string
93 jsr strlen
94 txa
95 tay
96 lda #0
97 sta message_buffer,y
98 dey
99 loop
100 lda str_buffer,y
101 sta message_buffer,y
102 dey
103 bpl loop
104
105 txa
106 ; This is in characters, translate to pixels
107 ; That is, multiply by 6, so we need to do
108 ; A/2*6=A*3=A*2+A
109 sta tmp
110 asl
111 clc
112 adc tmp
113
114 ; That is it, now store calculated position
115 sta tmp
116 lda #120
117 sec
118 sbc tmp
119 sta message_X
120
121 ; Now setup the counter to delete the string at the main loop
122 lda #HUD_MESSAGE_DELAY
123 sta message_delay
124
125 lda patchmsg
126 beq normal
127 dec patchmsg
128 rts
129 normal
130 jmp SndMsg
131 .)
132
133
134 print_inflight_message
135 .(
136 dec print2dbuffer
137 ldx message_X
138 ldy #HUD_MSG_Y
139 jsr gotoXY
140 lda #<message_buffer
141 ldx #>message_buffer
142 jsr print
143 inc print2dbuffer
144 rts
145 .)
146
147
148
149
150 ;;;;;;;;;;;;;; Control for panels
151
152 update_all_controls
153 .(
154 lda #0
155 sta warnlight_colour
156 lda _planet_dist
157 jsr planet_light
158 jsr update_energy_panel
159 jsr update_temperature_panel
160 jsr update_speed_panel
161 jsr update_shields_panel
162 jsr update_ecm_panel
163 jsr update_redirection
164 jmp update_missile_panel
165 .)
166
167
168 ;****** Missile boxes(Missiles) ******
169 ;A07B - Slot 1 - Poke Inversed Colour (See below for codes)
170 ;A07D - Slot 2 - Poke Inversed Colour (See below for codes)
171 ;A07F - Slot 3 - Poke Inversed Colour (See below for codes)
172 ;A081 - Slot 4 - Poke Inversed Colour (See below for codes)
173
174 ;Inversed Colours
175 ;$80 - Black(Empty/Off)
176 ;$81 - Red
177 ;$82 - Green
178 ;$83 - Yellow
179 ;$84 - Blue(low visibility)
180 ;$85 - Magenta
181 ;$86 - Cyan
182 ;$87 - White
183
184 tab_miss_pos
185 .byt $7b,$7d,$7f,$81
186
187 update_missile_panel
188 .(
189 ldx _missiles_left
190 beq noleft
191 lda #$86
192 ldy _missile_armed
193 beq loop
194 bpl locked
195 lda #$83
196 .byt $2c
197 locked
198 lda #$85
199 loop
200 ldy tab_miss_pos-1,x
201 sta $a000,y
202 dex
203 bne loop
204
205 noleft
206 ldx #4
207 cpx _missiles_left
208 beq end
209
210 lda #$80
211 loop2
212 ldy tab_miss_pos-1,x
213 sta $a000,y
214 dex
215 cpx _missiles_left
216 bne loop2
217 end
218
219 jsr update_ship_id
220 rts
221
222 .)
223
224 ;****** 8 character Text row(System) *******
225 ;$A060 - Top Left of first character of 8
226
227
228 update_ship_id
229 .(
230 lda #$60
231 sta screen
232 lda #$a0
233 sta screen+1
234
235 lda _missile_armed
236 bmi clear
237 beq clear
238
239 tax
240 jsr GetShipType
241 and #%01111111
242 tax
243
244 lda #<str_ship_names
245 sta tmp0
246 lda #>str_ship_names
247 sta tmp0+1
248
249 dex
250
251 ; Print message id to buffer
252 inc capson
253 jsr search_string_and_print
254 dec capson
255 rts
256 clear
257 lda #<str_blank
258 ldx #>str_blank
259 jmp print
260 .)
261
262
263 ;****** Warning Light ******
264
265 ; Sets the planet distance light indicator.
266 ; Needs A=planet_dist
267 planet_light
268 .(
269 cmp #PDIST_DOCK
270 bcs noneardock
271 ldx #INV_MAGENTA
272 bmi set
273 noneardock
274 cmp #PDIST_MASSLOCK
275 bcs nonearplanet
276 ldx #INV_YELLOW
277 bmi set
278 nonearplanet
279 cmp #PDIST_TOOFAR
280 bcc nofar
281 ldx #INV_RED
282 bmi set
283 nofar
284 ldx #INV_GREEN
285 set
286 cpx warnlight_colour
287 beq end
288 stx warnlight_colour
289 cpx #INV_GREEN
290 beq noflash
291 jmp flash_warning_on
292 noflash
293 jmp flash_warning_off
294 end
295 rts
296 .)
297
298
299
300
301 ;Version sent has green flashing light
302 ;To set colour poke $A073,$A09B,$A0C3 with Inversed colour (see above for values)
303 ;To Set Flashing, poke $A074,$A09C,$A0C4 with $8C
304 ;To Disable flashing, poke $A074,$A09C,$A0C4 with $88
305
306 warnlight_colour .byt INV_GREEN
307
308 flash_warning_off
309 .(
310 lda #$88
311 .byt $2c
312 +flash_warning_on
313 lda #$8c
314
315 ldx _current_screen
316 cpx #SCR_FRONT
317 bne end
318
319 sta $a074
320 sta $a09c
321 sta $a0c4
322
323 +set_warning_light
324 lda warnlight_colour
325 sta $a073
326 sta $a09b
327 sta $a0c3
328 end
329 rts
330 .)
331
332 ;****** Shield bars ******
333 ;The Cyan bar can be set at pixel(0-22) or byte resolution(0-3)
334 ;The black hole to right is the warning light when the shield is empty
335 ;See below for routine i'd use for pixel res
336
337 ;****** Fore shield ******
338 ;$B60C - Left byte of bar
339 ;$B610 - Warning Light
340
341 ;****** Aft shield ******
342 ;$B6FC - Left byte of bar
343 ;$B700 - Warning Light
344
345 update_shields_panel
346 .(
347 lda _current_screen
348 cmp #SCR_FRONT
349 bne end
350
351 ldx _front_shield
352 lda BarSegment0,x
353 sta $B60C
354 lda BarSegment1,x
355 sta $B60D
356 lda BarSegment2,x
357 sta $B60E
358 lda BarSegment3,x
359 sta $B60F
360
361 ldx _rear_shield
362 lda BarSegment0,x
363 sta $B6FC
364 lda BarSegment1,x
365 sta $B6FD
366 lda BarSegment2,x
367 sta $B6FE
368 lda BarSegment3,x
369 sta $B6FF
370 end
371 rts
372 .)
373
374
375 ;******** Speed *********
376 ;$B954 - Top left
377 ;Pretty much same as Fore and Aft shields except different pattern, twice written and half pixel res(0-14)
378 ;Personally what i'd do is use the tables above for aft shields (avoids excessive tables) together with
379 ;one more (BarSegment4) and mask(AND) the fetched bar byte with %01010101
380
381 update_speed_panel
382 .(
383 lda _current_screen
384 cmp #SCR_FRONT
385 bne end
386
387
388 ldx _speed+1
389 lda BarSegment0,x
390 and #%01010101
391 sta $B954
392 sta $B954+40
393 lda BarSegment1,x
394 and #%01010101
395 sta $B955
396 sta $B955+40
397 lda BarSegment2,x
398 and #%01010101
399 sta $B956
400 sta $B956+40
401 lda BarSegment3,x
402 and #%01010101
403 sta $B957
404 sta $B957+40
405 lda BarSegment4,x
406 and #%01010101
407 sta $B958
408 sta $B958+40
409 end
410 rts
411 .)
412
413
414 BarSegment4
415 .byt %01000000,%01000000,%01000000,%01000000,%01000000,%01000000
416 BarSegment3
417 .byt %01000000,%01000000,%01000000,%01000000,%01000000,%01000000
418 BarSegment2
419 .byt %01000000,%01000000,%01000000,%01000000,%01000000,%01000000
420 BarSegment1
421 .byt %01000000,%01000000,%01000000,%01000000,%01000000,%01000000
422 BarSegment0
423 .byt %01000000,%01100000,%01110000,%01111000,%01111100,%01111110,%01111111
424 .byt %01111111,%01111111,%01111111,%01111111,%01111111,%01111111,%01111111
425 .byt %01111111,%01111111,%01111111,%01111111,%01111111,%01111111,%01111111
426 .byt %01111111,%01111111,%01111111
427 .byt %01111111,%01111111,%01111111,%01111111,%01111111
428
429
430 ;******** Laser Temperature ********
431 ;This looks more complicated than it really is.
432 ;For colour of pointer..
433 ;$FF Red
434 ;$C0 White
435 ;$40 Black
436 ;The range is 1-10 and i'd use this routine
437
438 OldLaserTemperature .byt 0
439 LaserTemperature .byt 0
440
441 update_temperature_panel
442 .(
443 lda _current_screen
444 cmp #SCR_FRONT
445 bne skip1
446
447
448 ldx OldLaserTemperature
449 cpx LaserTemperature
450
451 beq skip1
452
453 ;Delete Old pointer
454 lda TemperatureIndicatorScreenLocLo,x
455 sta vector1+1
456 lda TemperatureIndicatorScreenLocHi,x
457 sta vector1+2
458 lda #$40
459 vector1 sta $dead
460
461 ;Plot new pointer
462 ldx LaserTemperature
463 stx OldLaserTemperature
464 lda TemperatureIndicatorScreenLocLo,x
465 sta vector2+1
466 lda TemperatureIndicatorScreenLocHi,x
467 sta vector2+2
468 lda #$C0
469 vector2 sta $dead
470 skip1 rts
471 .)
472
473
474 TemperatureIndicatorScreenLocLo
475 .byt $E0
476 .byt $90
477 .byt $40
478 .byt $F0
479 .byt $A0
480 .byt $50
481 .byt $00
482 .byt $B0
483 .byt $60
484 .byt $10
485 TemperatureIndicatorScreenLocHi
486 .byt $BD
487 .byt $BD
488 .byt $BD
489 .byt $BC
490 .byt $BC
491 .byt $BC
492 .byt $BC
493 .byt $BB
494 .byt $BB
495 .byt $BB
496
497
498 ;****** Power Redirection *******
499 ;$B742 - Top left corner of plotted graphic
500 ;This requires three 4x5 graphics (60 Bytes) to represent the three positions the switch may be in.
501
502 update_redirection
503 .(
504
505 lda #<$b742+(40*4)
506 sta tmp
507 lda #>$b742+(40*4)
508 sta tmp+1
509
510 lda _ptsh
511 beq nosh
512 lda #<SelectorLeft
513 ldx #>SelectorLeft
514 jmp setit
515 nosh
516 lda _ptla
517 beq nola
518 lda #<SelectorRight
519 ldx #>SelectorRight
520 jmp setit
521 nola
522 lda #<SelectorMiddle
523 ldx #>SelectorMiddle
524 setit
525 sta loop1+1
526 stx loop1+2
527
528 ldx #19
529 ldy #3
530 loop1
531 lda SelectorLeft,x
532 dest_p
533 sta (tmp),y
534 dey
535 bpl cont
536 ldy #3
537 sec
538 lda tmp
539 sbc #40
540 sta tmp
541 bcs cont
542 dec tmp+1
543 cont
544 dex
545 bpl loop1
546 rts
547 .)
548
549
550 SelectorLeft
551 .byt $5F,$4F,$7F,$7E
552 .byt $E1,$D8,$C0,$C1
553 .byt $5D,$73,$7F,$7E
554 .byt $E4,$78,$FF,$F1
555 .byt $58,$41,$7F,$7E
556 SelectorMiddle
557 .byt $5F,$7E,$5F,$7E
558 .byt $E0,$C2,$F0,$C1
559 .byt $5F,$7B,$67,$7E
560 .byt $E3,$F8,$70,$F1
561 .byt $5F,$70,$43,$7E
562 SelectorRight
563 .byt $5F,$7F,$7C,$7E
564 .byt $E0,$C0,$C5,$E1
565 .byt $5F,$7F,$77,$4E
566 .byt $E3,$FF,$4F,$D9
567 .byt $5F,$7F,$40,$46
568
569 ;******* Energy Banks *******
570 ;Again i would use similar table to horizontal bar since there are only 5 positions(0-5)
571 ;Didn't get time tonight to sort u out a routine, though i suspect you won't have a problem with that
572 ;$BB4E $BB50 $BB52 $BB54
573 ;$BB9E $BBA0 $BBA2 $BBA4
574 ;$BBEE $BBF0 $BBF2 $BBF4
575 ;$BC3E $BC40 $BC42 $BC44
576 ;$BC8E $BC90 $BC92 $BC94
577
578 update_energy_panel
579 .(
580 lda _current_screen
581 cmp #SCR_FRONT
582 beq correct
583 rts
584 correct
585 lda _energy+1
586 bpl doit
587 lda #0
588 doit
589 lsr
590 lsr
591 sta tmp
592
593 cmp #6
594 bcc l6a
595 ldx #6
596 bne conta
597 l6a
598 tax
599 conta
600 lda table1,x
601 sta $bb4e
602 lda table2,x
603 sta $bb4e+80
604 lda table3,x
605 sta $bb4e+80*1
606 lda table3,x
607 sta $bb4e+80*2
608 lda table4,x
609 sta $bb4e+80*3
610 lda table5,x
611 sta $bb4e+80*4
612 lda table6,x
613 sta $bb4e+80*4
614
615 lda tmp
616 sec
617 sbc #6
618 sta tmp
619 bpl normalb
620 lda #0
621 beq l6b
622 normalb
623 cmp #6
624 bcc l6b
625 ldx #6
626 bne contb
627 l6b
628 tax
629 contb
630
631 lda table1,x
632 sta $BB50
633 lda table2,x
634 sta $BB50+80
635 lda table3,x
636 sta $BB50+80*1
637 lda table3,x
638 sta $BB50+80*2
639 lda table4,x
640 sta $BB50+80*3
641 lda table5,x
642 sta $BB50+80*4
643 lda table6,x
644 sta $BB50+80*4
645
646 lda tmp
647 sec
648 sbc #6
649 sta tmp
650 bpl normalc
651 lda #0
652 beq l6c
653 normalc
654
655 cmp #6
656 bcc l6c
657 ldx #6
658 bne contc
659 l6c
660 tax
661 contc
662
663 lda table1,x
664 sta $BB52
665 lda table2,x
666 sta $BB52+80
667 lda table3,x
668 sta $BB52+80*1
669 lda table3,x
670 sta $BB52+80*2
671 lda table4,x
672 sta $BB52+80*3
673 lda table5,x
674 sta $BB52+80*4
675 lda table6,x
676 sta $BB52+80*4
677
678 lda tmp
679 sec
680 sbc #6
681 sta tmp
682 bpl normald
683 lda #0
684 beq l6d
685 normald
686 cmp #6
687 bcc l6d
688 ldx #6
689 bne contd
690 l6d
691 tax
692 contd
693
694 lda table1,x
695 sta $BB54
696 lda table2,x
697 sta $BB54+80
698 lda table3,x
699 sta $BB54+80*1
700 lda table3,x
701 sta $BB54+80*2
702 lda table4,x
703 sta $BB54+80*3
704 lda table5,x
705 sta $BB54+80*4
706 lda table6,x
707 sta $BB54+80*4
708
709 rts
710
711 .)
712
713
714 table1
715 .byt $40
716 table2
717 .byt $40
718 table3
719 .byt $40
720 table4
721 .byt $40
722 table5
723 .byt $40
724 table6
725 .byt $40,$f3,$f3,$f3,$f3,$f3,$f3
726
727
728 update_ecm_panel
729 .(
730 lda _current_screen
731 cmp #SCR_FRONT
732 beq correct
733 rts
734 correct
735 lda #<$A095+40*5
736 sta loop+3
737 lda #>$A095+40*5
738 sta loop+3+1
739
740 lda _ecm_counter
741 beq no_ecm_active
742 lda #<panel_ecm_on
743 ldx #>panel_ecm_on
744 bne done ; Trick that assumes high byte cannot be zero!
745 no_ecm_active
746 lda #<panel_ecm_off
747 ldx #>panel_ecm_off
748 done
749 sta tmp1
750 stx tmp1+1
751
752 ldy #23
753 loopo
754 ldx #3
755 loop
756 lda (tmp1),y
757 sta $dead,x
758 dey
759 bmi end
760 dex
761 bpl loop
762
763 lda loop+3
764 sec
765 sbc #40
766 sta loop+3
767 bcs nocarry
768 dec loop+3+1
769 nocarry
770 jmp loopo
771 end
772 rts
773
774 .)
775
776 panel_ecm_on
777 .byt $D7,$FC,$CF,$FA
778 .byt $6A,$60,$41,$55
779 .byt $D5,$D6,$DA,$EA
780 .byt $6A,$69,$65,$55
781 .byt $D5,$DF,$FE,$EA
782 .byt $68,$43,$70,$45
783 panel_ecm_off
784 .byt $FF,$FF,$FF,$FF
785 .byt $40,$40,$40,$40
786 .byt $FF,$FF,$FF,$FF
787 .byt $40,$40,$40,$40
788 .byt $FF,$FF,$FF,$FF
789 .byt $40,$40,$40,$40
790
791
792
793

  ViewVC Help
Powered by ViewVC 1.1.26