/[projet1]/public/oric/games/Space 1999/Sources/trailer/draw.s
Defence Force logotype

Contents of /public/oric/games/Space 1999/Sources/trailer/draw.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 365 - (show annotations)
Mon Jul 19 10:58:27 2010 UTC (9 years ago) by dbug
File size: 11351 byte(s)
Added the Space:1999 Trailer to the repository.

1 // ============================================================================
2 //
3 // Draw.s
4 //
5 // ============================================================================
6 //
7 // Code that draw the planet
8 //
9 // ============================================================================
10
11 .zero
12
13 _X0 .dsb 1
14 _X1 .dsb 1
15 _CURY .dsb 1
16 _CX .dsb 1
17 _CY .dsb 1
18 _RAY .dsb 1
19
20 _X .dsb 1
21 _Y .dsb 1
22 _A .dsb 1
23
24
25 y_modulo_3 .dsb 1
26
27 ptr_scanline
28 ptr_scanline_low .dsb 1
29 ptr_scanline_high .dsb 1
30
31 shading_offset_low .dsb 1
32 shading_offset_high .dsb 1
33
34 shading_step_low .dsb 1
35 shading_step_high .dsb 1
36
37
38 left_mask .dsb 1
39 right_mask .dsb 1
40
41 left_offset .dsb 1
42
43 block_lenght .dsb 1
44
45 shading_table .dsb 1
46
47 .text
48
49
50 _DrawDisc
51 .(
52 ;unsigned char x;
53 ;int y;
54 ;char a;
55
56 ;
57 ; Top part
58 ;
59
60 ;y = RAY;
61 ;x = 0;
62 ;a = RAY/2;
63 lda #0
64 sta _X
65
66 lda _RAY
67 sta _Y
68
69 lsr
70 sta _A
71 ;do
72 ;{
73 .(
74 loop
75 ; x++;
76 ; a-=x;
77 inc _X
78
79 sec
80 lda _A
81 sbc _X
82 sta _A
83 ; if (a<0)
84 bpl test
85
86 neg
87 ; X0=CX-x;
88 ; X1=CX+x;
89 ; Y=CY-y;
90 ; DrawSegment();
91 sec
92 lda _CX
93 sbc _X
94 sta _X0
95
96 clc
97 lda _CX
98 adc _X
99 sta _X1
100
101 sec
102 lda _CY
103 sbc _Y
104 sta _CURY
105
106 jsr _DrawSegment
107
108 ; Y=CY+y;
109 ; DrawSegment();
110 clc
111 lda _CY
112 adc _Y
113 sta _CURY
114
115 jsr _DrawSegment
116
117 ; a+=y;
118 ; y--;
119 clc
120 lda _A
121 adc _Y
122 sta _A
123
124 dec _Y
125
126 test
127 ;while (x<y);
128 lda _X
129 cmp _Y
130 bcc loop
131
132
133 .)
134
135 lda _Y
136 beq end_of_disc
137 ;jmp end_of_disc
138 ;
139 ; Middle part
140 ;
141 // Now more or less reverse the above to get the other eighth
142 ;a = -RAY/2 - 1;
143 lda _RAY
144 lsr
145 sta tmp
146
147 sec
148 lda #0
149 sbc tmp
150 sec
151 sbc #1
152 sta _A
153
154 ;do
155 ;{
156 .(
157 loop
158 ; X0=CX-x;
159 ; X1=CX+x;
160 ; Y=CY-y;
161 ; DrawSegment();
162 sec
163 lda _CX
164 sbc _X
165 sta _X0
166
167 clc
168 lda _CX
169 adc _X
170 sta _X1
171
172 sec
173 lda _CY
174 sbc _Y
175 sta _CURY
176
177 jsr _DrawSegment
178
179 ; Y=CY+y;
180 ; DrawSegment();
181 clc
182 lda _CY
183 adc _Y
184 sta _CURY
185
186 jsr _DrawSegment
187
188 ; a+=y;
189 ; y--;
190 clc
191 lda _A
192 adc _Y
193 sta _A
194
195 dec _Y
196
197 ; if (a>0)
198 ; {
199 ; x++;
200 ; a-=x;
201 ; }
202 ;}
203 lda _A
204 bmi end_test
205
206 inc _X
207
208 sec
209 lda _A
210 sbc _X
211 sta _A
212
213 end_test
214 ;while (y>0)
215 lda _Y
216 bne loop
217
218 .)
219
220 ;
221 ; Final segment in the middle
222 ; Actually that one is not drawn at all due to the odd/even line thingy :)
223 ;
224 sec
225 lda _CX
226 sbc _RAY
227 sta _X0
228
229 clc
230 lda _CX
231 adc _RAY
232 sta _X1
233
234 lda _CY
235 sta _CURY
236
237 jsr _DrawSegment
238 end_of_disc
239
240 rts
241 .)
242
243
244 _DrawSegment
245 .(
246 ;unsigned char left_offset=TableDiv6[x0];
247 ;unsigned char left_mask=64|Mod6Left[x0];
248 ldx _X0
249
250 lda _TableDiv6,x
251 sta left_offset
252
253 lda _Mod6Left,x
254 sta left_mask
255
256
257 ;unsigned char right_offset=TableDiv6[x1];
258 ;unsigned char block_lenght=right_offset-left_offset;
259 ;unsigned char right_mask=64|Mod6Right[x1];
260 ;unsigned int shading_step=SteppingTableDitherWord[block_lenght];
261 ldx _X1
262
263 lda _Mod6Right,x
264 sta right_mask
265
266 lda _TableDiv6,x
267 sec
268 sbc left_offset
269 sta block_lenght
270
271 tax
272 lda _SteppingTableDitherLow,x
273 sta shading_step_low
274 lda _SteppingTableDitherHigh,x
275 sta shading_step_high
276
277 ;unsigned int shading_offset=gShadingAngle;
278 ;shading_offset <<=8;
279 lda _CURY
280 asr a
281 clc
282 adc _gShadingAngle
283 sta shading_offset_high
284 lda #0
285 sta shading_offset_low
286
287
288 ;
289 ;unsigned int offset_line=HiresAddrHigh[y];
290 ;offset_line<<=8;
291 ;offset_line|=HiresAddrLow[y];
292
293 ;ptr_line=(unsigned char*)offset_line;
294
295 ldy _CURY
296 lda _HiresAddrLow,y
297 sta ptr_scanline_low
298 lda _HiresAddrHigh,y
299 sta ptr_scanline_high
300
301 tya
302 and #3
303 sta y_modulo_3
304
305
306 ;if (y&1)
307 ;{
308 ; ptr_line[left_offset-1]=4; // Blue
309 ;}
310 ;else
311 ;{
312 ; ptr_line[left_offset-1]=2; // Green
313 ; //ptr_line[left_offset-1]=0; // Black
314 ;}
315 .(
316 ldy left_offset
317
318 lda _CURY
319 and #1
320 beq even
321
322 odd
323 lda #4 ;4 ;+16
324 sta (ptr_scanline),y
325 jmp end
326
327 even
328 rts
329 lda #5 ;2 ;+16
330 sta (ptr_scanline),y
331
332 end
333 iny
334 .)
335
336 ;
337 ; Check if it's more than one byte long
338 ; if (!block_lenght)
339 ;
340 .(
341 lda block_lenght
342 bne long_line
343
344 short_line
345 // Same block segment
346 ;shading_table=CosTableDither[shading_offset>>8];
347 ;shading_value=64|LabelBumpReconf[shading_table|(y&3)];
348 ;ptr_line[left_offset]=left_mask&right_mask&shading_value;
349 ldx shading_offset_high
350 lda _CosTableDither,x
351 ora y_modulo_3
352 tax
353 lda _TableDithering,x
354 and left_mask
355 and right_mask
356
357 sta (ptr_scanline),y
358
359 rts
360
361 long_line
362 // Repeat segment
363 ;shading_offset+=shading_step;
364 clc
365 lda shading_offset_low
366 adc shading_step_low
367 sta shading_offset_low
368 lda shading_offset_high
369 tax
370 adc shading_step_high
371 sta shading_offset_high
372
373 ;shading_table=CosTableDither[shading_offset>>8];
374 ;shading_value=64|LabelBumpReconf[shading_table|(y&3)];
375 ;ptr_line[left_offset]=left_mask&shading_value;
376 lda _CosTableDither,x
377 ora y_modulo_3
378 tax
379 lda _TableDithering,x
380 and left_mask
381
382 sta (ptr_scanline),y
383 iny
384
385 ;
386 ; Loop on intermediate elements
387 ;
388 dec block_lenght
389 beq end
390 loop
391 ; shading_offset+=shading_step;
392 clc
393 lda shading_offset_low
394 adc shading_step_low
395 sta shading_offset_low
396 lda shading_offset_high
397 tax
398 adc shading_step_high
399 sta shading_offset_high
400
401 ; shading_table=CosTableDither[shading_offset>>8];
402 ; shading_value=64|LabelBumpReconf[shading_table|(y&3)];
403 ; ptr_line[left_offset]=64+32+16+8+4+2+1&shading_value;
404 lda _CosTableDither,x
405 ora y_modulo_3
406 tax
407 lda _TableDithering,x
408
409 sta (ptr_scanline),y
410 iny
411
412 dec block_lenght
413 bne loop
414 end
415
416 ;
417 ; Final bloc
418 ;
419 ;shading_table=CosTableDither[shading_offset>>8];
420 ;shading_value=64|LabelBumpReconf[shading_table|(y&3)];
421 ;ptr_line[left_offset]=right_mask&shading_value;
422 ldx shading_offset_high
423 lda _CosTableDither,x
424 ora y_modulo_3
425 tax
426 lda _TableDithering,x
427 and right_mask
428
429 sta (ptr_scanline),y
430 .)
431
432 rts
433 .)
434
435
436 // 8000/256=31.25
437 _FlipToScreen
438 .(
439 ldx #0
440 loop_x
441 lda _BufferUnpack+256*0,x
442 sta $a000+256*0,x
443 lda _BufferUnpack+256*1,x
444 sta $a000+256*1,x
445 lda _BufferUnpack+256*2,x
446 sta $a000+256*2,x
447 lda _BufferUnpack+256*3,x
448 sta $a000+256*3,x
449 lda _BufferUnpack+256*4,x
450 sta $a000+256*4,x
451 lda _BufferUnpack+256*5,x
452 sta $a000+256*5,x
453 lda _BufferUnpack+256*6,x
454 sta $a000+256*6,x
455 lda _BufferUnpack+256*7,x
456 sta $a000+256*7,x
457 lda _BufferUnpack+256*8,x
458 sta $a000+256*8,x
459 lda _BufferUnpack+256*9,x
460 sta $a000+256*9,x
461
462 lda _BufferUnpack+256*10,x
463 sta $a000+256*10,x
464 lda _BufferUnpack+256*11,x
465 sta $a000+256*11,x
466 lda _BufferUnpack+256*12,x
467 sta $a000+256*12,x
468 lda _BufferUnpack+256*13,x
469 sta $a000+256*13,x
470 lda _BufferUnpack+256*14,x
471 sta $a000+256*14,x
472 lda _BufferUnpack+256*15,x
473 sta $a000+256*15,x
474 lda _BufferUnpack+256*16,x
475 sta $a000+256*16,x
476 lda _BufferUnpack+256*17,x
477 sta $a000+256*17,x
478 lda _BufferUnpack+256*18,x
479 sta $a000+256*18,x
480 lda _BufferUnpack+256*19,x
481 sta $a000+256*19,x
482
483 lda _BufferUnpack+256*20,x
484 sta $a000+256*20,x
485 lda _BufferUnpack+256*21,x
486 sta $a000+256*21,x
487 lda _BufferUnpack+256*22,x
488 sta $a000+256*22,x
489 lda _BufferUnpack+256*23,x
490 sta $a000+256*23,x
491 lda _BufferUnpack+256*24,x
492 sta $a000+256*24,x
493 lda _BufferUnpack+256*25,x
494 sta $a000+256*25,x
495 lda _BufferUnpack+256*26,x
496 sta $a000+256*26,x
497 lda _BufferUnpack+256*27,x
498 sta $a000+256*27,x
499 lda _BufferUnpack+256*28,x
500 sta $a000+256*28,x
501 lda _BufferUnpack+256*29,x
502 sta $a000+256*29,x
503
504 lda _BufferUnpack+256*30,x
505 sta $a000+256*30,x
506
507 lda _BufferUnpack+8000-256,x
508 sta $a000+8000-256,x
509
510 dex
511 beq end
512 jmp loop_x
513 end
514
515 rts
516 .)
517
518
519
520
521 /*
522 void DrawNuclearBoom(unsigned char base)
523 {
524 unsigned char color_value;
525 unsigned char x,y;
526 unsigned char* ptr_screen;
527 unsigned char* ptr_full_buffer;
528 unsigned int nSquareDistance;
529 unsigned char nSquareRoot;
530
531 ptr_screen=(unsigned char*)0xa000;
532 ptr_full_buffer=DiscFullTable;
533 for (y=0;y<110;y++)
534 {
535 for (x=1;x<40;x++)
536 {
537 nSquareRoot=ptr_full_buffer[x];
538 if (nSquareRoot==255)
539 {
540 // Do nothing
541 ptr_screen[x]=16+2;
542 }
543 else
544 if (nSquareRoot==254)
545 {
546 ptr_screen[x]=16;
547 }
548 else
549 {
550 color_value=16+BoomColor[(base+nSquareRoot)&15];
551 ptr_screen[x]=color_value;
552 }
553 }
554 ptr_screen+=40;
555 ptr_full_buffer+=40;
556 }
557 }
558 */
559
560 ; White, yellow, red, magenta, blue, dark
561 _GlowColor
562 .byt 16+7,16+3,16+1,16+5,16+4,16+0
563
564
565 _BoomColorMinus16
566 .byt 16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0 ; 16
567 _BoomColor
568 .byt 16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0 ; 16
569 .byt 16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0 ; 16
570 .byt 16+0,16+0,16+0,16+0,16+0
571 ; 37 values
572 .byt 16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0,16+0 ; 16
573
574 ;.byt 16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1
575 ;.byt 16+7,16+7,16+7,16+3,16+7,16+3,16+3,16+1,16+3,16+1,16+5,16+1,16+5,16+4,16+0,16+0
576 ;.byt 16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1
577 ;.byt 16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1
578 ;.byt 16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1
579 ;.byt 16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1
580 ;.byt 16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1,16+1
581
582 _BoomColorBase .byt 0
583 _BoomCounter .byt 0
584
585 bob
586 _DrawNuclearBoom
587 .(
588 lda #<_DiscFullTable
589 sta __patch_src+1
590 lda #>_DiscFullTable
591 sta __patch_src+2
592
593 lda #<$a000
594 sta __patch_dst+1
595 lda #>$a000
596 sta __patch_dst+2
597
598 lda #110
599 sta _BoomCounter
600 loop_y
601
602 ldy #39
603 loop_x
604 __patch_src
605 lda $1234,y
606 cmp #254
607 bcs test_high
608
609 patch_color
610 ; color_value=16+BoomColor[(base+nSquareRoot)&15];
611 ; ptr_screen[x]=color_value;
612 ;clc
613 ;adc _BoomColorBase
614 ;and #15
615 tax
616 lda _BoomColor,x
617
618 do_it
619 __patch_dst
620 sta $1234,y
621 skip_it
622
623 dey
624 bne loop_x
625
626 .(
627 clc
628 lda __patch_src+1
629 adc #40
630 sta __patch_src+1
631 sta __patch_dst+1
632 bcc skip
633 inc __patch_src+2
634 inc __patch_dst+2
635 skip
636 .)
637
638 dec _BoomCounter
639 bne loop_y
640 rts
641
642 test_high
643 cmp #255
644 beq do_nothing
645
646 paper_black
647 lda #16
648 bne do_it
649
650 do_nothing
651 lda #16+2
652 bne skip_it
653 bne do_it
654 .)
655
656
657
658
659 ; unsigned char* psrc -> tmp0
660 ; unsigned char* pdst -> tmp1
661 ; unsigned char width -> _W
662 ; unsigned char height -> _H
663 ; a/x -> pointer on description
664 _CopyRectangle
665 .(
666 sta tmp0+0
667 stx tmp0+1
668
669 ldy #0
670
671 sec
672 lda (tmp0),y
673 iny
674 sbc #1
675 sta __patch_src+1
676 lda (tmp0),y
677 iny
678 sbc #0
679 sta __patch_src+2
680
681 sec
682 lda (tmp0),y
683 iny
684 sbc #1
685 sta __patch_dst+1
686 lda (tmp0),y
687 iny
688 sbc #0
689 sta __patch_dst+2
690
691 lda (tmp0),y
692 iny
693 sta _W
694
695 lda (tmp0),y
696 iny
697 sta _H
698
699 ldy _H
700 loop_y
701 ldx _W
702 loop_x
703 __patch_src
704 lda $1234,x
705 __patch_dst
706 sta $1234,x
707 dex
708 bne loop_x
709
710 .(
711 clc
712 lda __patch_src+1
713 adc #40
714 sta __patch_src+1
715 bcc skip
716 inc __patch_src+2
717 skip
718 .)
719
720 .(
721 clc
722 lda __patch_dst+1
723 adc #40
724 sta __patch_dst+1
725 bcc skip
726 inc __patch_dst+2
727 skip
728 .)
729
730 dey
731 bne loop_y
732
733 rts
734 .)
735
736
737

  ViewVC Help
Powered by ViewVC 1.1.26