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

Contents of /users/chema/TINE/stars.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: 11499 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 #include "oobj3d\params.h"
3
4 #define NSTARS 15
5
6 STARX .dsb NSTARS+1
7 STARXREM .dsb NSTARS+1
8 STARY .dsb NSTARS+1
9 STARYREM .dsb NSTARS+1
10
11 ;THETSTEP .byt 2
12
13 #define TEMP3 tmp3
14 #define TEMP1 tmp1
15 #define TEMP2 tmp2
16
17
18 ;
19 ; INITSTAR -- Initialize starfield, etc.
20 ;
21 ; Stars have locations x=-160..160 and y=-100..100
22 ;
23 INITSTAR
24 .(
25 JSR _init_rand
26 LDY #NSTARS
27 LOOP JSR NEWSTAR
28 DEY
29 BPL LOOP
30 RTS
31 .)
32
33 NEWSTAR
34 .( ;.Y contains index into star table
35 JSR _gen_rnd_number
36 CMP #100
37 BCC SETY
38 CMP #156 ;-100
39 BCS SETY
40 AND #%10111111 ;-65..63
41 SETY STA STARY,Y
42
43 lda _rnd_seed
44 cmp #120
45 bcs SETX
46 cmp #136
47 bcs SETX
48 and #%10111111 ;-65..63
49 SETX sta STARX,Y
50 RTS
51 .)
52
53
54 ;
55 ; PLOTSTAR -- Plot stars into bitmap!
56 ;
57 PlotStars
58 .(
59 LDY #NSTARS
60 LOOP STY TEMP
61 LDA STARX,Y
62 CLC
63 ADC #CENTER_X
64 cmp #CLIP_RIGHT
65 bcs bypass
66 cmp #CLIP_LEFT
67 bcc bypass
68 tax
69
70 LDA STARY,Y
71 CLC
72 ADC #CENTER_Y
73 cmp #CLIP_BOTTOM
74 bcs bypass
75 cmp #CLIP_TOP
76 bcc bypass
77 TAY
78 PLOT
79 ; Now plot the star!
80
81 jsr pixel_address
82 ;eor (tmp0),y ; 5
83 ora (tmp0),y ; 5
84 sta (tmp0),y
85
86 bypass
87 LDY TEMP
88 DEY
89 BPL LOOP
90 RTS
91 .)
92
93
94
95 ;; Routine to move stars depending on
96 ;; global:
97 ;; g_alpha Total rotation in X (Pitch)
98 ;; g_beta Total rotation in Y (Yaw)
99 ;; g_delta Total rotation in Z (Roll)
100 ;; g_theta Total speed?
101
102 move_stars
103 .(
104
105 lda invert
106 beq normal1
107 lda g_alpha
108 eor #$80
109 sta g_alpha
110 lda g_beta
111 eor #$80
112 sta g_beta
113 normal1
114
115 lda g_alpha
116 beq nowbeta
117 cmp #$80 ; Get sign into carry
118 bcs negmove1
119 jsr STARADDY
120 jmp nowbeta
121 negmove1
122 jsr STARSUBY
123
124 nowbeta
125 lda g_beta
126 beq nowdelta
127 cmp #$80 ; Get sign into carry
128 bcs negmove2
129 jsr STARSUBX
130 jmp nowdelta
131 negmove2
132 jsr STARADDX
133
134 nowdelta
135 lda g_delta
136 beq nowtheta
137 cmp #$80 ; Get sign into carry
138 bcs negmove3
139 and #$7f
140 sta tmp
141 loop1
142 jsr STARROTP
143 dec tmp
144 bne loop1
145
146 jmp nowtheta
147 negmove3
148 and #$7f
149 sta tmp
150 loop2
151 jsr STARROTM
152 dec tmp
153 bne loop2
154
155 nowtheta
156 lda invert
157 beq normal
158 jsr STARSUBZ
159 jmp more
160 normal
161 jsr STARADDZ ; This can't be negative...
162 more
163 lda #0
164 sta g_alpha
165 sta g_beta
166 sta g_delta
167 sta g_theta
168
169 rts
170 .)
171
172
173 ;
174 ; STARROTP -- Rotate stars about z-axis, positive.
175 ;
176 STARROTP
177 .(
178 LDY #NSTARS
179 LOOP LDA STARX,Y
180 BMI NEGX
181 POSX TAX
182 LDA STARYREM,Y ;y*cos(delta)
183 SEC
184 SBC tab_sindeltarem2,X ;-x*sin(delta)
185 STA STARYREM,Y
186 LDA STARY,Y
187 SBC tab_sindelta2,X
188 LDX STARY,Y
189 STA STARY,Y ;y=-x*sd + y*cd
190 BMI NEGY ;LDX sets flag
191
192 POSY LDA STARXREM,Y
193 CLC
194 ADC tab_sindeltarem2,X ;x*cos(theta) + y*sin(theta)
195 STA STARXREM,Y
196 LDA STARX,Y
197 ADC tab_sindelta2,X
198 STA STARX,Y
199 BMI NEGCHK
200
201 POSCHK
202 cmp #120
203 BCS NEW
204 YCHK LDA STARY,Y
205 BMI NEGYCHK
206 CMP #64
207 BCS NEW
208 DEY
209 BPL LOOP
210 RTS
211
212 NEGYCHK CMP #192 ;#156 ;-100
213 BCS NOTNEW
214 NEW JSR NEWSTAR
215 NOTNEW DEY
216 BPL LOOP
217 RTS
218
219 NEGCHK cmp #136 ;-120
220 BCS YCHK
221 BCC NEW
222
223 NEGX EOR #$FF
224 TAX
225 INX
226 LDA STARYREM,Y ;y*cos(delta)
227 CLC
228 ADC tab_sindeltarem2,X ;-x*sin(delta)
229 STA STARYREM,Y
230 LDA STARY,Y
231 ADC tab_sindelta2,X
232 LDX STARY,Y
233 STA STARY,Y ;y=-x*sd + y*cd
234 BPL POSY ;LDX sets flag
235
236 NEGY TXA
237 EOR #$FF
238 TAX
239 INX
240 LDA STARXREM,Y
241 SEC
242 SBC tab_sindeltarem2,X ;x*cos(theta) + y*sin(theta)
243 STA STARXREM,Y
244 LDA STARX,Y
245 SBC tab_sindelta2,X
246 STA STARX,Y
247 BPL POSCHK
248 BMI NEGCHK
249 .)
250
251 ;
252 ; STARROTM -- Rotate stars, negative.
253 ; (sin -> -sin)
254 ;
255 STARROTM
256 .(
257
258 LDY #NSTARS
259 LOOP LDA STARX,Y
260 BMI NEGX
261 POSX TAX
262 LDA STARYREM,Y ;y*cos(delta)
263 CLC
264 ADC tab_sindeltarem2,X ;+x*sin(delta)
265 STA STARYREM,Y
266 LDA STARY,Y
267 ADC tab_sindelta2,X
268 LDX STARY,Y
269 STA STARY,Y ;y=x*sd + y*cd
270 BMI NEGY ;LDX sets flag
271
272 POSY LDA STARXREM,Y
273 SEC
274 SBC tab_sindeltarem2,X ;x*cos(theta) - y*sin(theta)
275 STA STARXREM,Y
276 LDA STARX,Y
277 SBC tab_sindelta2,X
278 STA STARX,Y
279 BMI NEGCHK
280 POSCHK
281
282 cmp #136
283 BCS NEW
284 YCHK LDA STARY,Y
285 BMI NEGYCHK
286 CMP #100
287 BCS NEW
288 DEY
289 BPL LOOP
290 RTS
291
292 NEGYCHK CMP #156 ;-100
293 BCS NOTNEW
294 NEW JSR NEWSTAR
295 NOTNEW DEY
296 BPL LOOP
297 RTS
298
299 NEGCHK cmp #136
300 BCS YCHK
301 BCC NEW
302
303 NEGX EOR #$FF
304 TAX
305 INX
306 LDA STARYREM,Y ;y*cos(delta)
307 SEC
308 SBC tab_sindeltarem2,X ;+x*sin(delta)
309 STA STARYREM,Y
310 LDA STARY,Y
311 SBC tab_sindelta2,X
312 LDX STARY,Y
313 STA STARY,Y ;y=x*sd + y*cd
314 BPL POSY ;LDX sets flag
315
316 NEGY TXA
317 EOR #$FF
318 TAX
319 INX
320 LDA STARXREM,Y
321 CLC
322 ADC tab_sindeltarem2,X ;x*cos(theta) - y*sin(theta)
323 STA STARXREM,Y
324 LDA STARX,Y
325 ADC tab_sindelta2,X
326 STA STARX,Y
327 BPL POSCHK
328 BMI NEGCHK
329 .)
330
331 ;
332 ; STARADDZ -- Move stars, forwards or backwards. Idea
333 ; is that stars move radially outward from the center
334 ; of the screen, with velocity dependent on the distance
335 ; from the center of the screen.
336 ;
337 STARADDZ
338 .(
339 lda g_theta
340 beq ELRTS
341 lsr
342 lsr
343 lsr
344 tax
345 inx
346 stx tmp
347
348 LDY #NSTARS
349 LOOP
350 ;LDA g_theta; LDX THETSTEP
351 ;BEQ ELRTS
352
353 LDX #0 ; sign
354 LDA STARX,Y
355 bpl C2
356 dex
357 C2
358 STX TEMP2
359 ldx tmp
360
361 L1
362
363 ASL
364 ROL TEMP2
365 DEX
366 BNE L1 ;Divide by 128/64/32/16
367 CLC
368 ADC STARXREM,Y
369 STA STARXREM,Y
370 LDA TEMP2
371 ADC STARX,Y ;x = x + 1/16 x
372 STA STARX,Y
373 BMI NEGCHK
374 ;BNE NEW ;valid high = either 00 or $FF
375
376 POSCHK cmp #120 ;if x>=160 then need a new star
377 BCC ADDY
378 NEW JSR NEWSTAR
379 JMP NEXT
380 NEGCHK
381 cmp #136 ;and if x<=-160
382 ;SBC #$FF ;(Subtract $FF + 97)
383 BCC NEW
384
385 ADDY LDX #00 ;Sign
386 LDA STARY,Y
387 BPL C1
388 DEX
389 C1 STX TEMP1
390 LDX tmp; g_theta ;THETSTEP
391 L2 ASL
392 ROL TEMP1
393 DEX
394 BNE L2
395 CLC
396 ADC STARYREM,Y
397 STA STARYREM,Y
398 LDA TEMP1
399 ADC STARY,Y
400 BVS NEW
401 STA STARY,Y
402 BMI NEGY
403
404 POSY CMP #100 ;if abs(y)>100 then new
405 BCS NEW
406 NEXT DEY
407 BPL LOOP
408 ELRTS RTS
409 NEGY CMP #157
410 BCC NEW
411 DEY
412 BPL LOOP
413 RTS
414 .)
415
416
417
418 STARSUBZ
419 .(
420
421 lda g_theta
422 beq OTRORTS
423 lsr
424 lsr
425 lsr
426 tax
427 inx
428 stx tmp
429
430 LDY #NSTARS
431
432 ;Same thing but subtract
433 LDY #NSTARS
434 LOOP
435 ;ldx THETSTEP
436 ;BEQ OTRORTS
437
438 LDX #0 ; sign
439 LDA STARX,Y
440 bpl C1
441 dex
442 C1
443 STX TEMP2
444 ldx tmp
445
446 L1
447
448 ASL
449 ROL TEMP2
450 DEX
451 BNE L1
452 STA TEMP
453 LDA STARXREM,Y
454 SEC
455 SBC TEMP
456 STA STARXREM,Y
457 LDA STARX,Y ;x = x - 1/16 x
458 SBC TEMP2
459 STA STARX,Y
460 BMI NEGCHK
461
462 POSCHK cmp #16 ;if abs(x)<16 then need a new star
463 BCS ADDY
464 NEW JSR NEWSTAR
465 JMP NEXT
466 NEGCHK cmp #240
467 ;SBC #$FF
468 BCS NEW
469
470 ADDY LDX #00 ;Sign
471 LDA STARY,Y
472 BPL C2
473 DEX
474 C2 STX TEMP1
475 LDX tmp ;THETSTEP
476 L2 ASL
477 ROL TEMP1
478 DEX
479 BNE L2
480 STA TEMP
481 LDA STARYREM,Y
482 SEC
483 SBC TEMP
484 STA STARYREM,Y
485 LDA STARY,Y
486 SBC TEMP1
487 BVS NEW
488 STA STARY,Y
489 BMI NEGY
490
491 POSY CMP #16 ;if abs(y)<6 then new
492 BCC NEW
493 NEXT DEY
494 BPL LOOP
495 OTRORTS RTS
496 NEGY CMP #240
497 BCS NEW
498 DEY
499 BPL LOOP
500 RTS
501 .)
502
503
504
505 ;
506 ; STARADDX, STARSUBX, STARADDY, STARSUBY
507 ; Routines to move stars right/left/up/down to simulate
508 ; rotations around x and y axis.
509 ;
510 ;ADDTAB .byt 0,12,24,36,48,60,72
511 ADDTAB .byt 0,4,8,12,16,20,24,28,32,36,40,44,52,60
512 STARADDX
513 .(
514 LDY #NSTARS
515 LDX g_beta ;THETSTEP
516 BEQ ELRTS
517
518 txa
519 and #$7f ; Get absolute value
520 ;asl
521 tax
522 LDA ADDTAB,X
523
524 STA TEMP
525 LOOP LDA STARX,Y
526 CLC
527 ADC TEMP
528 STA STARX,Y
529 BMI NEXT
530
531 POSCHK cmp #120 ;if x>=160 then need a new star
532 BCC NEXT
533 NEW JSR NEWSTAR
534 NEXT DEY
535 BPL LOOP
536 ELRTS RTS
537 .)
538
539 STARSUBX
540 .(
541 LDY #NSTARS
542 LDX g_beta ;THETSTEP
543 BEQ ELRTS
544 txa
545 and #$7f ; Get absolute value
546 ;asl
547 tax
548 LDA ADDTAB,X
549
550 STA TEMP
551 LOOP LDA STARX,Y
552 SEC
553 SBC TEMP
554 STA STARX,Y
555 BPL NEXT
556
557 POSCHK cmp #136 ;if x<-160 then need a new star
558 BCS NEXT
559 NEW JSR NEWSTAR
560 NEXT DEY
561 BPL LOOP
562 ELRTS RTS
563 .)
564
565
566 STARADDY
567 .(
568 LDY #NSTARS
569 LDX g_alpha ;THETSTEP
570 BEQ ELRTS
571 txa
572 and #$7f ; Get absolute value
573 ;asl
574 tax
575 LDA ADDTAB,X
576
577 STA TEMP
578 LOOP LDA STARY,Y
579 CLC
580 ADC TEMP
581 BVS NEW ;might happen for large temp
582 STA STARY,Y
583 BMI NEXT
584 CMP #100
585 BCC NEXT
586 NEW JSR NEWSTAR
587 NEXT DEY
588 BPL LOOP
589 ELRTS RTS
590 .)
591
592 STARSUBY
593 .(
594 LDY #NSTARS
595 LDX g_alpha ;THETSTEP
596 BEQ ELRTS
597 txa
598 and #$7f ; Get absolute value
599 ; asl
600 tax
601 LDA ADDTAB,X
602
603 STA TEMP
604 LOOP LDA STARY,Y
605 SEC
606 SBC TEMP
607 BVS NEW
608 STA STARY,Y
609 BPL NEXT
610 CMP #156
611 BCS NEXT
612 NEW JSR NEWSTAR
613 NEXT DEY
614 BPL LOOP
615 ELRTS RTS
616 .)
617
618

  ViewVC Help
Powered by ViewVC 1.1.26