/[projet1]/public/atari/demos/defenceforce/savetheearth/cinescop.s
Defence Force logotype

Annotation of /public/atari/demos/defenceforce/savetheearth/cinescop.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (hide annotations)
Sat Nov 28 13:10:37 2009 UTC (10 years, 4 months ago) by dbug
File size: 29096 byte(s)
Added the source code of "Save The Earth", the Atari STe demo presented at Kindergarden 2009
1 dbug 172
2     ZOOMER_BUFFER_WIDTH equ (416+16+16)
3     ZOOMER_STEPS equ 32
4     ZOOMER_WIDTH equ 374
5     ZOOMER_HEIGHT equ 85
6    
7    
8     ; Background rectangle: 42,87 - 327,173 <- Theorical values
9    
10     XCENTER equ 207
11     YCENTER equ 99
12     XSCALE equ 326 ;310 ;200
13     YSCALE equ 213 ;220 ;300
14     ZSCALE equ 512
15     ; 336x120 -> 168x60
16     ; Z0->639
17    
18     ;SPRITES_HEIGHT equ 44 ; Old ones
19     SPRITES_HEIGHT equ 39 ; New ones by crem
20    
21     SPRITES_CURVE_SPEED equ 4
22     SPRITES_CURVE_LENGHT equ 128
23    
24    
25    
26     SECTION TEXT
27    
28     even
29    
30     CinemaScopeInit
31     ; Depack the logo
32     lea PackInfoCinemascope,a0
33     bsr DepackBlock
34    
35     lea PackInfoDefenceForceSprites,a0
36     bsr DepackBlock
37    
38     move.l #big_buffer_start+cinemascope_screenbuffer,ptr_scr_1
39    
40     move.w #0,ZoomerAngle
41    
42     bsr ZoomerGenerate
43    
44     ; These two functions use the blitter, would corrupt the fullscreen
45     bsr LogoPrepareScreens
46     bsr DrawPlanScanLines
47    
48     bsr CreateDefaultZoomerDisplayList
49    
50     ; Generate the mask from the sprite data - if not done yet
51     bsr DefenceForceGenerateMasks
52    
53     clr Scaler_Factor
54    
55     ;bsr DefenceForceLogoSetup
56    
57     move.l #big_buffer_start+defenceforce_screen,ptr_scr_1
58    
59     ifne enable_music
60     lea music,a0
61     bsr StartMusicIfNotStarted
62     endc
63    
64     ; Picture palette
65     lea black_palette,a0
66     lea big_buffer_start+cinemascope_logo_depacked,a1
67     moveq #16,d7
68     bsr ComputeGradient
69    
70     ; Using the template data, we generate the fullscreen
71     lea PanoramicTemplate_DisplayList,a0
72     lea big_buffer_start+cinemascope_fullscreen,a1
73     bsr GenerateOverscan
74     rts
75    
76     CinemaScopePlay
77     COLORHELP #$777
78     _AdrCinemascopeVblRoutine=*+2
79     jsr DummyRoutine
80     COLORHELP #$000
81    
82     bsr SequencerPlay
83     rts
84    
85     DefenceForceLogoSetup
86     move #64,blue_plane_angle
87     move #ZSCALE,blue_plane_zoom
88    
89     ; Compute the gradient color for the rotating plane
90     move #$046,big_buffer_start+RotatingPlanPaletteEnd ; Clear blue
91     move #$f70,big_buffer_start+RotatingPlanPaletteEnd+2 ; Yellow
92     lea big_buffer_start+RotatingPlanPaletteStart,a0
93     lea big_buffer_start+RotatingPlanPaletteEnd,a1
94     lea big_buffer_start+RotatingPlanPaletteFade,a2
95     move #2,d7
96     bsr ComputeFullGradient
97    
98     ; Picture palette for the logo
99     lea big_buffer_start+cinemascope_logo_depacked,a0
100     lea big_buffer_start+cinemascope_sprites_depacked,a1
101     move #$fff,(a1) ; Replace the purple by white
102     moveq #16,d7
103     bsr ComputeGradient
104     rts
105    
106    
107    
108     CinemaScopeTerminate
109     ; Fade to white
110     lea big_buffer_start+cinemascope_sprites_depacked,a0
111     lea white_palette,a1
112     moveq #16,d7
113     bsr ComputeGradient
114    
115     move.l #DummyRoutine,_AdrCinemascopeVblRoutine
116     move.l #LogoTwistAndShout,_AdrEndOfFadeRoutine
117    
118     bsr WaitEndOfFade
119    
120     ; Fade to black
121     lea white_palette,a0
122     lea black_palette,a1
123     moveq #16,d7
124     bsr ComputeGradient
125    
126     move.l #DummyRoutine,_AdrEndOfFadeRoutine
127     bsr WaitEndOfFade
128    
129     bsr TerminateFullscreenTimer
130     rts
131    
132    
133    
134     CinemaScopeAnimateSquish
135     ; Reset screen positions
136     bsr CreateDefaultZoomerDisplayList
137    
138     lea sine_255,a3
139     move ZoomerAngle,d1
140     and #255,d1
141     add d1,d1
142     move 0(a3,d1),d1 ; 16 bits, between 00 and 127
143     move d1,d0
144    
145     lsr #2,d0
146     ; Get the correct rescale table
147     and #ZOOMER_STEPS-1,d0
148     add d0,d0
149     add d0,d0
150    
151     lea big_buffer_start+cinemascope_scanlines,a3
152     add d0,a3
153    
154     lea DisplayList+8*58,a1
155    
156     lea palette_vbl_fade,a2
157     moveq #ZOOMER_HEIGHT-1,d7
158     .loop
159     move.l (a3),(a1)+
160     move.l a2,(a1)+
161     lea ZOOMER_STEPS*4(a3),a3
162     dbra d7,.loop
163    
164     move ZoomerAngle,d1
165     addq #8,d1
166     and #255,d1
167     move d1,ZoomerAngle
168     cmp #$50,d1
169     bne.s .skip
170     move.l #CinemaScopeAnimateZoom,_AdrCinemascopeVblRoutine
171     .skip
172     rts
173    
174    
175     CinemaScopeAnimateZoom
176     ; Reset screen positions
177     bsr CreateDefaultZoomerDisplayList
178    
179     lea DisplayList,a1
180    
181     lea sine_255,a3
182     move ZoomerAngle,d1
183     and #255,d1
184     add d1,d1
185     move 0(a3,d1),d1 ; 16 bits, between 00 and 127
186     move d1,d0
187    
188     lsr #2,d0
189     ; Get the correct rescale table
190     and #ZOOMER_STEPS-1,d0
191     add d0,d0
192     add d0,d0
193     lea Scaler_Tables,a0
194     move.l (a0,d0),a0
195    
196     move.w 4+2*17(a0),d4 ; Width in 16 pixels blocks
197     move.w 4+2*17+2(a0),d5 ; Width in pixels
198     move.w 4+2*17+2+2(a0),d7 ; Height
199     move.l (a0),a0 ; Start adress
200    
201     lsl #4,d4
202     move d4,d5
203    
204     ; 416/16=26 blocks
205     ; 26/2=13 blocks
206     ; 13*8=104 bytes
207    
208     lea -104(a0),a0
209     move d5,d0
210     lsr #5,d0 ; /2 /16
211     lsl #3,d0
212     add d0,a0
213    
214     move d7,d6
215     lsr d6
216     move #100,d0
217     sub d6,d0
218     lsl #3,d0
219     add d0,a1
220    
221     lsr d5 ; Width / 2
222     and #15,d5
223     move d5,d0
224    
225     move.l a0,d1
226     lsl.l #8,d1
227     add.b d0,d1
228     move.l d1,d0
229    
230     lea palette_vbl_fade,a2
231     subq #1,d7
232     .loop
233     move.l d0,(a1)+
234     move.l a2,(a1)+
235     add.l #208*256,d0
236     dbra d7,.loop
237    
238     move ZoomerAngle,d1
239     addq #4,d1
240     and #255,d1
241     move d1,ZoomerAngle
242     cmp #$50,d1
243     bne.s .skip
244     move.l #CinemaScopeAnimateSquish,_AdrCinemascopeVblRoutine
245     .skip
246     rts
247    
248    
249     CreateDefaultZoomerDisplayList
250     move.l #big_buffer_start+cinemascope_screenbuffer,d0
251     lsl.l #8,d0
252     move.l d0,a0
253     lea palette_vbl_fade,a1
254     bsr DisplayListInitStatic
255     rts
256    
257    
258     ZoomerGenerate
259     ; Convert to chunky
260     move.l #big_buffer_start+cinemascope_logo_depacked+32,Scaler_PtrSrc
261     move.l #big_buffer_start+zoomer_buffer_chunky,Scaler_PtrDst
262     move.w #26-1,Scaler_Width
263     move.w #100-1,Scaler_Height
264     move.w #208,Scaler_StrideSrc
265     move.w #ZOOMER_BUFFER_WIDTH,Scaler_StrideDst
266     bsr ZoomerPlannarToChunky
267    
268     ; Display the zoomed pictures
269     move.l ptr_scr_1,Scaler_PtrDst
270     add.l #8+208,Scaler_PtrDst
271    
272     ; Display again using a zoom
273     clr Scaler_Factor
274     moveq #ZOOMER_STEPS-1,d7
275     .loop_generate_zoom
276     move.l #big_buffer_start+zoomer_buffer_chunky,Scaler_PtrSrc
277     move.w #26,Scaler_Width
278     move.w #100,Scaler_Height
279     move.w #ZOOMER_BUFFER_WIDTH,Scaler_StrideSrc
280     move.w #208,Scaler_StrideDst
281     bsr ZoomerRescaledChunkyToPlannar
282    
283     addq #1,Scaler_Factor
284     dbra d7,.loop_generate_zoom
285    
286     bsr GenerateScanlinePointers
287     rts
288    
289    
290     GenerateScanlinePointers
291     lea big_buffer_start+cinemascope_scanlines,a2
292     move.w #0,Scaler_Factor
293     .loop_size
294     move.l a2,a3
295     addq #4,a2
296    
297     ; Now we have to update the buffer with the right scanlines
298     move Scaler_Factor,d0
299     add d0,d0
300     add d0,d0
301     lea Scaler_Tables,a0
302     move.l (a0,d0),a0
303    
304     move.w 4+2*17(a0),d4 ; Width in 16 pixels blocks
305     move.w 4+2*17+2(a0),d5 ; Width in pixels
306     move.w 4+2*17+2+2(a0),d7 ; Height
307     move.l (a0),a0 ; Start adress
308    
309     lsl #4,d4
310     move d4,d5
311    
312     ; 416/16=26 blocks
313     ; 26/2=13 blocks
314     ; 13*8=104 bytes
315    
316     lea -104(a0),a0
317     move d5,d0
318     lsr #5,d0 ; /2 /16
319     lsl #3,d0
320     add d0,a0
321    
322     move d7,d6
323     lsr d6
324     move #100,d0
325     sub d6,d0
326     lsl #3,d0 ;*8
327     add d0,a1
328    
329     lsr d5 ; Width / 2
330     and #15,d5
331     move d5,d0
332    
333     move.l a0,d1
334     lsl.l #8,d1
335     add.b d0,d1
336     move.l d1,d0
337    
338     ; d0=first line
339     ; d7=number of lines
340     moveq #0,d6
341     .loop_insert_lines
342     move.l d6,d1
343     mulu d7,d1
344     divu #ZOOMER_HEIGHT,d1
345     mulu #208*256,d1
346     add.l d0,d1
347     move.l d1,(a3)
348     lea ZOOMER_STEPS*4(a3),a3
349     addq #1,d6
350     cmp #ZOOMER_HEIGHT,d6
351     bne .loop_insert_lines
352    
353     addq #1,Scaler_Factor
354     cmp #ZOOMER_STEPS,Scaler_Factor
355     bne .loop_size
356     rts
357    
358    
359    
360     ; Scaler_PtrSrc=source buffer (chunky)
361     ; Scaler_PtrDst=destination buffer (plannar)
362     ; Scaler_Width
363     ; Scaler_Height
364     ZoomerRescaledChunkyToPlannar
365     movem.l d0-a6,-(sp)
366    
367     ; Get the correct rescale table
368     move Scaler_Factor,d0
369     and #ZOOMER_STEPS-1,d0
370     add d0,d0
371     add d0,d0
372     lea Scaler_Tables,a0
373    
374     add d0,a0
375     move.l (a0),a0
376    
377     ; Set the start adress
378     move.l Scaler_PtrDst,(a0)+
379    
380     ; Then patch the code
381     var set 0
382     REPT 16
383     move.w (a0)+,.patch_start+2+var*(.patch_end-.patch_start)/16
384     var set var+1
385     ENDR
386     move.w (a0)+,.patch_end+2
387     move.w (a0)+,Scaler_Width ; Nb blocs
388     addq #2,a0 ; Skip width in pixels
389     move.w (a0)+,Scaler_Height ; Nb scanlines
390     move.w (a0)+,Scaler_DestOffset ; Offset to add to the dest scanline start to center the picture
391     move.l a0,a2 ; Point on the vertical rescale table...
392     moveq #0,d6 ; Index in the table...
393    
394     move Scaler_Height,Scaler_CurHeight
395     .loop_y
396    
397     move.l Scaler_PtrSrc,a0
398     add.l (a2,d6),a0
399     addq #4,d6
400    
401     cmp #16*4,d6
402     bne.s .skip
403     move.l Scaler_PtrSrc,a0
404     add.l (a2,d6),a0
405     moveq #0,d6 ; Index in the table...
406     move.l a0,Scaler_PtrSrc
407     .skip
408    
409     move.l Scaler_PtrDst,a1
410    
411     move Scaler_Width,d5
412     .loop_x
413    
414     ; Shift until we get 16 bytes
415     .patch_start
416     REPT 16
417     move.b $1234(a0),d4 ; 12/3
418     addx.b d4,d4 ; 4/1
419     addx.w d0,d0
420     addx.b d4,d4
421     addx.w d1,d1
422     addx.b d4,d4
423     addx.w d2,d2
424     addx.b d4,d4
425     addx.w d3,d3
426     ; 12/3 + 8*(4/1) = 3+8 = 44/11 per pixel
427     ENDR
428     .patch_end
429     ; 16*11=176 nops for 16 bytes
430     lea $1234(a0),a0 ; 8/2
431    
432     ; Write the four bitplans
433     move.w d0,(a1)+ ; 8/2
434     move.w d1,(a1)+ ; 8/2
435     move.w d2,(a1)+ ; 8/2
436     move.w d3,(a1)+ ; 8/2
437     ; 32/8
438    
439     ; Grand total:
440     ; 16*11+2+8 = 744/186
441    
442     ; movem.w d0/d1/d2/d3,-(a1) ; 8+4n=8+4*4=24/6
443     ; movep.l dn,16(an) ; 24/6
444    
445     dbra d5,.loop_x
446    
447     move.l Scaler_PtrDst,a1
448     add.w Scaler_StrideDst,a1
449     move.l a1,Scaler_PtrDst
450    
451     subq #1,Scaler_CurHeight
452     bne .loop_y
453    
454     movem.l (sp)+,d0-a6
455     rts
456    
457    
458    
459     ; a0=source buffer (plannar)
460     ; a1=destination buffer (chunky)
461     ; d0=size of the buffer
462     ZoomerPlannarToChunky
463     move.l Scaler_PtrSrc,a2
464     move.l Scaler_PtrDst,a3
465    
466     move.w Scaler_Height,d7
467     .loop_y
468     move.l a2,a0
469     add.w Scaler_StrideSrc,a2
470    
471     move.l a3,a1
472     add.w Scaler_StrideDst,a3
473    
474     move.w Scaler_Width,d6
475     .loop_x
476     movem.w (a0)+,d0/d1/d2/d3 ; Read the four bitplans
477    
478     ; Shift until we get 16 bytes
479     REPT 16
480     moveq #0,d4
481     lsl.w d0
482     roxl.w d4
483     lsl.w d1
484     roxl.w d4
485     lsl.w d2
486     roxl.w d4
487     lsl.w d3
488     roxl.w d4
489    
490     move.b d4,d5 ; Duplicate the low nibble
491     lsl.b #4,d5
492     or.b d5,d4
493    
494     move.b d4,(a1)+ ; Write the chunky pixel
495     ENDR
496     dbra d6,.loop_x
497    
498    
499     dbra d7,.loop_y
500     rts
501    
502    
503    
504     ; ------------------
505     ; Rotating plan
506     ; ------------------
507    
508     AnimateRotatingPlan
509     move.w blue_plane_angle,d0
510     add.b blue_plane_speed,d0
511     and.w #255,d0
512     move.w d0,blue_plane_angle
513    
514     COLORHELP #$030
515    
516     ; First we reset the display list to point on an empty scanline
517     move.l #big_buffer_start+defenceforce_screen+65535,d0
518     clr.w d0
519     lsl.l #8,d0
520     move.l d0,a0
521    
522     lea big_buffer_start+cinemascope_sprites_depacked,a1
523     bsr DisplayListInitStatic
524    
525     COLORHELP #$003
526    
527     ; Compute the 3D coordinates
528     lea table_sine_16,a0 ; 256*2
529     lea table_sine_16+128,a1 ; 256*2
530    
531     ; FFFFFFFFFFFF8001
532     ; FFFFFFFFFFFF809f
533     move blue_plane_angle,d0
534     and #255,d0
535     add d0,d0
536    
537     ; p0
538     move #-32767,blue_plane_x0
539     move (a0,d0),blue_plane_y0 ; -32767,+32767
540     move (a1,d0),blue_plane_z0 ; -32767,+32767
541    
542     ; p1
543     add #256,d0 ; +half circle
544     move #-32767,blue_plane_x1
545     move (a0,d0),blue_plane_y1 ; -32767,+32767
546     move (a1,d0),blue_plane_z1 ; -32767,+32767
547    
548     ; Compute projection Z0
549     move blue_plane_z0,d7
550     add #32767,d7 ; z: 0,65535
551     lsr #8,d7 ; Z: 0,255
552     add blue_plane_zoom,d7 ; z: 255,511
553     move d7,blue_plane_z0
554    
555     ; Compute projection Z1
556     move blue_plane_z1,d7
557     add #32767,d7 ; z: 0,65535
558     lsr #8,d7 ; Z: 0,255
559     add blue_plane_zoom,d7 ; z: 255,511
560     move d7,blue_plane_z1
561    
562     ; Compute 2D X0
563     move blue_plane_x0,d0
564     asr #8,d0 ; -255,+255
565     muls #XSCALE,d0 ; DX
566     divs blue_plane_z1,d0
567     add #XCENTER,d0 ; CX
568     move d0,blue_plane_xx0
569    
570     ; Compute 2D Y0
571     move blue_plane_y0,d0
572     asr #8,d0 ; -255,+255
573     muls #YSCALE,d0 ; DY
574     divs blue_plane_z0,d0 ; /255-511
575     add #YCENTER,d0 ; CY
576     move d0,blue_plane_yy0
577    
578     ; Compute 2D X1
579     move blue_plane_x1,d0
580     asr #8,d0 ; -255,+255
581     muls #XSCALE,d0 ; DX
582     divs blue_plane_z0,d0
583     add #XCENTER,d0 ; CX
584     move d0,blue_plane_xx1
585    
586     ; Compute 2D Y1
587     move blue_plane_y1,d0
588     asr #8,d0 ; -255,+255
589     muls #YSCALE,d0 ; DY
590     divs blue_plane_z1,d0 ; /255-511
591     add #YCENTER,d0 ; CY
592     move d0,blue_plane_yy1
593    
594     COLORHELP #$303
595    
596     move blue_plane_xx0,d0
597     move blue_plane_yy0,d1
598     move blue_plane_xx1,d2
599     move blue_plane_yy1,d3
600     bsr.s DrawPolygoneLine
601    
602     ; Change the color of the plan depending of the angle and sign
603     moveq #0,d0
604     move blue_plane_y0,d0 ; -32767,+32767
605     bpl.s .not_neg
606     neg d0 ; 0,+32767
607     .not_neg
608     lsr #8,d0
609     lsr #3,d0
610    
611     lsl #2,d0
612     move blue_plane_yy0,d1
613     move blue_plane_yy1,d3
614     sub d1,d3
615     bpl.s .no_flip_color
616     addq #2,d0
617     .no_flip_color
618     lea big_buffer_start+RotatingPlanPaletteFade,a0
619     move (a0,d0),big_buffer_start+cinemascope_sprites_depacked+2*8
620     rts
621    
622    
623     ; d0.w=x0
624     ; d1.w=y0
625     ; d2.w=x1
626     ; d3.w=y1
627     DrawPolygoneLine
628     moveq #1,d4 ; ix
629     sub.w d0,d2 ; dx
630     bpl.s .dx_positive
631     .dx_negative
632     neg.w d2 ; abs(dx)
633     moveq #-1,d4
634     .dx_positive
635    
636     ; Compute scanline adress
637     lea DisplayList+1,a1
638     move d1,d5
639     add d5,d5
640     add d5,d5
641     add d5,d5
642     add d5,a1
643    
644     moveq.l #8,d5 ; iy
645     sub.w d1,d3 ; dy
646     bpl.s .dy_positive
647     .dy_negative
648     neg.w d3 ; abs(dy)
649     moveq.l #-8,d5
650     .dy_positive
651    
652     ; d0=x0
653     ; d1=x1
654     ; d2=abs(dx)
655     ; d3=abs(dy)
656     ; d4=ix
657     ; d5=iy
658     ; d6=err
659    
660     cmp.w d2,d3
661     bhi.s .draw_vertical
662    
663     .draw_horizontal
664     move d2,d6
665    
666     move d3,d7
667     add d3,d7
668     sub d2,d7
669    
670     add d3,d3
671     add d2,d2
672    
673     .horizontal_loop
674     move.b d0,(a1)
675    
676     tst.w d7
677     bmi .skipa
678     sub d2,d7
679     add d5,a1
680     .skipa
681     add d3,d7
682     add.w d4,d0
683     dbra d6,.horizontal_loop
684     rts
685    
686     .draw_vertical
687     move d3,d6
688    
689     move d2,d7
690     add d2,d7
691     sub d3,d7
692    
693     add d3,d3
694     add d2,d2
695    
696     .vertical_loop
697     move.b d0,(a1)
698    
699     tst.w d7
700     bmi .skip
701     add.w d4,d0
702     sub d3,d7
703     .skip
704     add d5,a1
705     add d2,d7
706     dbra d6,.vertical_loop
707     rts
708    
709    
710    
711    
712     DrawPlanScanLines
713     move blit_stride,-(sp)
714    
715     move #256,blit_stride
716    
717     move.l #big_buffer_start+defenceforce_screen+65535,d0
718     clr.w d0
719     move.l d0,a0
720    
721     move #208,d0 ; x0
722     move #0,d1 ; y0
723     move #208,d2 ; x1
724     move #1,d3 ; y1
725    
726     move.l #$000f0008,d4
727    
728     move.w #208-1,d7
729     .next_line
730     bsr BlitterDrawRectangle
731     subq #1,d0
732     addq #1,d2
733     addq #1,d1
734     addq #1,d3
735     dbra d7,.next_line
736    
737     move (sp)+,blit_stride
738     rts
739    
740    
741    
742     ; ------------------
743     ; Sprites
744     ; ------------------
745    
746     LogoSetUpSprites
747     ;
748     ; Force the palette to have only white and blue
749     ;
750     lea palette_vbl_fade,a0
751     move.w #$046,2*10(a0) ; Blue shadow
752     move.w #$fff,2*14(a0) ; Dark grey shadow
753     move.w #$fff,2*15(a0) ; Black frame
754    
755    
756     move.l #big_buffer_start+defenceforce_screen_1,d0
757     lsl.l #8,d0
758     move.l d0,a0
759    
760     move.l #SpritePos,ptr_current_sprite
761    
762     lea palette_vbl_fade,a1
763     lea DisplayList,a2
764     move.l #416*256,d0
765     moveq #0,d1
766     bsr DisplayListInit200
767    
768     ; Prepare fade to make details on the logo to appear
769     lea palette_vbl_fade,a0
770     lea big_buffer_start+cinemascope_sprites_depacked,a1
771     moveq #16,d7
772     bsr ComputeGradient
773    
774    
775     move.l #LogoInitSprite,_AdrCinemascopeVblRoutine
776     rts
777    
778    
779    
780     LogoInitSprite
781     move.l ptr_current_sprite,a0
782     move.w (a0)+,d0
783     bmi .done
784     move.w (a0)+,d1
785     move.w (a0)+,d2
786     move.w (a0)+,d3
787     move.l (a0)+,ptr_sprite_data
788     move.l a0,ptr_current_sprite
789    
790     lea CurveData,a0
791     move d2,curve_start_x(a0)
792     move d3,curve_start_y(a0)
793     move #90,curve_midle_x(a0)
794     move #90,curve_midle_y(a0)
795     move d0,curve_final_x(a0)
796     move d1,curve_final_y(a0)
797     move #SPRITES_CURVE_LENGHT,curve_lenght(a0)
798     move #0,curve_offset(a0)
799     move.l #416,sprite_screen_offset
800    
801     ; Need to precalculate the curve due to the damn music :-/
802     lea CurveData,a0
803     move #0,curve_offset(a0)
804     lea big_buffer_start+defenceforce_sprite_curve,a1
805     move.w #(SPRITES_CURVE_LENGHT/SPRITES_CURVE_SPEED),d7
806     .loop_precalc
807     bsr BezierInterpolate
808     move.w d0,(a1)+
809     move.w d1,(a1)+
810     addq #4,curve_offset(a0)
811     dbra d7,.loop_precalc
812     move #SPRITES_CURVE_LENGHT,curve_offset(a0)
813    
814     move.l #LogoUpdateSprites,_AdrCinemascopeVblRoutine
815     rts
816     .done
817     move.l #LogoTwistAndShoutInit,_AdrCinemascopeVblRoutine
818     rts
819    
820    
821     LogoUpdateSprites
822     move blit_stride,-(sp)
823     move #416,blit_stride
824    
825     bsr LogoEraseSprites
826     bsr SpritesMove
827    
828     move (sp)+,blit_stride
829     rts
830    
831    
832     SpritesMove
833     lea CurveData,a0
834    
835     lea big_buffer_start+defenceforce_sprite_curve,a1
836     move curve_offset(a0),d0
837     add.w d0,a1
838     move.w (a1)+,d0
839     move.w (a1)+,d1
840    
841     move d0,d4
842    
843     mulu blit_stride,d1
844    
845     lsr.w #4,d0
846     lsl.w #3,d0
847     add.w d0,d1
848    
849     move.l d1,sprite_screen_offset
850     lea big_buffer_start+defenceforce_screen_1,a1
851     add.l d1,a1
852    
853     move.l ptr_sprite_data,a0
854     move.l (a0)+,a3 ; Sprite bitmap
855     move.l (a0)+,a2 ; Sprite mask
856     move.w (a0)+,d0
857     move.w d0,d1
858     lsl #3,d1
859     move #160+2+6,d2
860     move #416+2+6,d3
861     sub d1,d2
862     sub d1,d3
863     move #SPRITES_HEIGHT,d1
864     and #15,d4
865     move.l a3,a0
866     bsr BlitterDrawSprite
867    
868     lea CurveData,a0
869     subq #4,curve_offset(a0)
870     bmi.s .done
871     rts
872     .done
873     move.l #LogoFixSprite,_AdrCinemascopeVblRoutine
874     rts
875    
876     LogoFixSprite
877     lea big_buffer_start+defenceforce_screen_1,a0
878     lea big_buffer_start+defenceforce_screen_2,a1
879     bsr.s LogoDoBlit
880     move.l #LogoInitSprite,_AdrCinemascopeVblRoutine
881     rts
882    
883     LogoEraseSprites
884     lea big_buffer_start+defenceforce_screen_2,a0
885     lea big_buffer_start+defenceforce_screen_1,a1
886     LogoDoBlit
887    
888     move.l sprite_screen_offset,d2
889    
890     add.l d2,a0
891     add.l d2,a1
892    
893     move #4*4,d0
894     move #SPRITES_HEIGHT,d1
895     move #416-(4*8)+2,d2
896     move #416-(4*8)+2,d3
897     and #15,d4
898    
899     bra BlitterCopyBlock
900    
901    
902    
903     DefenceForceGenerateMasks
904     lea big_buffer_start+cinemascope_sprites_depacked+32,a0
905     lea big_buffer_start+masks_defenceforcelogo,a1
906     move.w #20*SPRITES_HEIGHT,d1
907     .loop
908     move.w (a0)+,d0
909     or.w (a0)+,d0
910     or.w (a0)+,d0
911     or.w (a0)+,d0
912     not.w d0
913     move.w d0,(a1)+
914     dbra d1,.loop
915     rts
916    
917    
918     LogoTwistAndShoutInit
919     move.w #192,ZoomerAngle
920     move.w #0,defenceforce_pos_x
921     move.w #0,defenceforce_offset_y
922     lea big_buffer_start+defenceforce_offsets,a0
923     move #128-1,d7
924     .loop
925     move.w #0,(a0)+
926     dbra d7,.loop
927    
928     move.l #LogoTwistAndShout,_AdrCinemascopeVblRoutine
929     rts
930    
931     LogoTwistAndShout
932     move.l #big_buffer_start+defenceforce_screen_1+(49*416),d0
933     lsl.l #8,d0
934     move.l d0,a0
935    
936     ; Global offset
937     move.w defenceforce_pos_x,d4
938     addq.w #1,d4
939     cmp.w #416,d4
940     blt.s .continue
941     ; Done with the whole intro
942     st.b flag_end_part
943     .continue
944     move.w d4,defenceforce_pos_x
945    
946     move.w ZoomerAngle,d0
947     addq.w #1,d0
948     and.w #255,d0
949     move.w d0,ZoomerAngle
950     add.w d0,d0
951     lea sine_255,a5 ; 16 bits, unsigned between 00 and 127
952     add.w (a5,d0.w),d4
953    
954     cmp.w #416,d4
955     blt.s .skip
956     move.w #416,d4
957     .skip
958    
959     lea TableShifterShift,a3 ; Dist table
960     add.w d4,d4
961    
962     lea big_buffer_start+defenceforce_offsets,a2
963     move defenceforce_offset_y,d5
964     add #1,defenceforce_offset_y
965     add d5,d5
966     and.w #255-1,d5
967    
968     move (a3,d4.w),(a2,d5.w)
969    
970     move.l #416*256,d7 ; Offset
971     lea DisplayList+(49*8),a6 ; Target display list
972     lea sine_255,a5 ; 16 bits, unsigned between 00 and 127
973     moveq #0,d6
974    
975     var set 0
976     REPT 103
977     move.l a0,a1
978     add.l d7,a0
979    
980     add.w #2,d5
981     and.w #255-1,d5
982     move.w (a2,d5.w),d6
983     add.l d6,a1
984    
985     move.l a1,var*8(a6)
986    
987     var set var+1
988     ENDR
989    
990     rts
991    
992    
993     LogoPrepareScreens
994     move blit_stride,-(sp)
995     move #416,blit_stride
996    
997     lea big_buffer_start+cinemascope_sprites_depacked+(2*16),a1 ; Palette
998    
999     move #62+4+3,d0 ; x0
1000     move #56+4,d1 ; y0
1001     move #349+4+2,d2 ; x1
1002     move #143+4,d3 ; y1
1003     move.l #$000f000e,d4
1004     move.w #$111,big_buffer_start+cinemascope_sprites_depacked+(2*14)
1005    
1006     lea big_buffer_start+defenceforce_screen_1,a0
1007     bsr BlitterDrawRectangle
1008    
1009     lea big_buffer_start+defenceforce_screen_2,a0
1010     bsr BlitterDrawRectangle
1011    
1012    
1013     ; Black frame one
1014     subq #4,d0
1015     subq #4,d1
1016     subq #4,d2
1017     subq #4,d3
1018     move.l #$000f000f,d4
1019     move.w #$000,big_buffer_start+cinemascope_sprites_depacked+(2*15)
1020    
1021     lea big_buffer_start+defenceforce_screen_1,a0
1022     bsr BlitterDrawRectangle
1023    
1024     lea big_buffer_start+defenceforce_screen_2,a0
1025     bsr BlitterDrawRectangle
1026    
1027    
1028     ; Blue one - dark
1029     addq #1,d0
1030     addq #1,d1
1031     subq #1,d2
1032     subq #1,d3
1033     move.l #$000f000a,d4
1034     move.w #$035,big_buffer_start+cinemascope_sprites_depacked+(2*10)
1035    
1036     lea big_buffer_start+defenceforce_screen_1,a0
1037     bsr BlitterDrawRectangle
1038    
1039     lea big_buffer_start+defenceforce_screen_2,a0
1040     bsr BlitterDrawRectangle
1041    
1042    
1043     ; Blue one
1044     addq #1,d0
1045     addq #1,d1
1046     move.l #$000f0008,d4
1047     move.w #$046,big_buffer_start+cinemascope_sprites_depacked+(2*8)
1048    
1049     lea big_buffer_start+defenceforce_screen_1,a0
1050     bsr BlitterDrawRectangle
1051    
1052     lea big_buffer_start+defenceforce_screen_2,a0
1053     bsr BlitterDrawRectangle
1054    
1055     move (sp)+,blit_stride
1056    
1057     rts
1058    
1059    
1060    
1061    
1062    
1063    
1064     SECTION DATA
1065    
1066     even
1067    
1068     enable_zoomer equ 1
1069     enable_rotation equ 1
1070    
1071     enable_test_size equ 0
1072    
1073     CinemascopeSequencer
1074    
1075     ifne enable_zoomer
1076     SEQUENCE_SETPTR _AdrCinemascopeVblRoutine,CinemaScopeAnimateZoom
1077    
1078     SEQUENCE_TEMPORIZE 50*2
1079     endc
1080    
1081     SEQUENCE_SETPTR _AdrCinemascopeVblRoutine,DummyRoutine
1082     SEQUENCE_CALLBACK DefenceForceLogoSetup
1083    
1084     ifne enable_rotation
1085     SEQUENCE_SET_WORD blue_plane_angle,0
1086     SEQUENCE_SETPTR _AdrCinemascopeVblRoutine,AnimateRotatingPlan
1087    
1088     SEQUENCE_SET_BYTE blue_plane_speed,10
1089    
1090    
1091     SEQUENCE_TEMPORIZE 5
1092     SEQUENCE_SET_BYTE blue_plane_speed,9
1093     SEQUENCE_TEMPORIZE 10
1094     SEQUENCE_SET_BYTE blue_plane_speed,8
1095     SEQUENCE_TEMPORIZE 15
1096     SEQUENCE_SET_BYTE blue_plane_speed,7
1097     SEQUENCE_TEMPORIZE 20
1098     SEQUENCE_SET_BYTE blue_plane_speed,6
1099     SEQUENCE_TEMPORIZE 25
1100     SEQUENCE_SET_BYTE blue_plane_speed,5
1101     SEQUENCE_TEMPORIZE 30
1102     SEQUENCE_SET_BYTE blue_plane_speed,4
1103     SEQUENCE_TEMPORIZE 35
1104     SEQUENCE_SET_BYTE blue_plane_speed,3
1105     SEQUENCE_TEMPORIZE 40
1106     SEQUENCE_SET_BYTE blue_plane_speed,2
1107     SEQUENCE_TEMPORIZE 45
1108     SEQUENCE_SET_BYTE blue_plane_speed,1
1109     SEQUENCE_TEMPORIZE 50
1110     SEQUENCE_SET_BYTE blue_plane_speed,0
1111     endc
1112    
1113     ifne enable_test_size
1114     SEQUENCE_SET_WORD blue_plane_angle,192
1115     SEQUENCE_SETPTR _AdrCinemascopeVblRoutine,AnimateRotatingPlan
1116     SEQUENCE_TEMPORIZE 50*5
1117     endc
1118    
1119    
1120     SEQUENCE_SETPTR _AdrCinemascopeVblRoutine,DummyRoutine
1121     SEQUENCE_CALLBACK LogoSetUpSprites
1122     SEQUENCE_TEMPORIZE 50*3
1123    
1124     SEQUENCE_TEMPORIZE 50*10
1125    
1126     ifne enable_auto_skip
1127     SEQUENCE_GO_NEXT_PART ; And leave
1128     endc
1129     SEQUENCE_END
1130    
1131    
1132    
1133    
1134     even
1135    
1136    
1137     ; Unpacked: 20832
1138     ; Packed: 8386
1139     FILE "cinescop.pik",packed_cinemascope
1140    
1141     ; Unpacked: 7712
1142     ; Packed: 4206
1143     FILE "dfncfrce.pik",packed_defenceforce_sprites
1144    
1145     even
1146    
1147     PackInfoCinemascope
1148     dc.l packed_cinemascope
1149     dc.l big_buffer_start+cinemascope_logo_depacked
1150     dc.l 20832
1151    
1152     PackInfoDefenceForceSprites
1153     dc.l packed_defenceforce_sprites
1154     dc.l big_buffer_start+cinemascope_sprites_depacked
1155     dc.l 7712
1156    
1157    
1158     rsreset
1159     zoomer_ptr_start rs.l 1
1160     zoomer_x_offsets rs.w 16+1
1161     zoomer_width_blocs rs.w 1
1162     zoomer_width_pixels rs.w 1
1163     zoomer_height rs.w 1
1164     zoomer_start_offset rs.w 1
1165     zoomer_y_offsets rs.l 16+1
1166    
1167     zoomer_size equ __RS
1168    
1169     ; Percentage,Width,height
1170     SCALE_TABLE macro
1171     percent set \1
1172     source_width set \2
1173     source_height set \3
1174     dest_width set (source_width*percent)/100
1175     dest_height set (source_height*percent)/100
1176     bloc_count set dest_width/16
1177    
1178     ; Start adress (patched by the scaler code)
1179     dc.l 0
1180    
1181     ; X-Offset
1182     dc.w (0*source_width)/dest_width
1183     dc.w (1*source_width)/dest_width
1184     dc.w (2*source_width)/dest_width
1185     dc.w (3*source_width)/dest_width
1186     dc.w (4*source_width)/dest_width
1187     dc.w (5*source_width)/dest_width
1188     dc.w (6*source_width)/dest_width
1189     dc.w (7*source_width)/dest_width
1190     dc.w (8*source_width)/dest_width
1191     dc.w (9*source_width)/dest_width
1192     dc.w (10*source_width)/dest_width
1193     dc.w (11*source_width)/dest_width
1194     dc.w (12*source_width)/dest_width
1195     dc.w (13*source_width)/dest_width
1196     dc.w (14*source_width)/dest_width
1197     dc.w (15*source_width)/dest_width
1198    
1199     dc.w (16*source_width)/dest_width
1200    
1201     ;dc.w bloc_count
1202     dc.w (source_width)/((16*source_width)/dest_width)
1203    
1204     dc.w dest_width
1205     dc.w dest_height
1206     dc.w (((source_width/2)-(dest_width/2))/16)*8 ; Start offset
1207    
1208     ; Y-Offset
1209     dc.l ((0*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1210     dc.l ((1*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1211     dc.l ((2*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1212     dc.l ((3*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1213     dc.l ((4*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1214     dc.l ((5*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1215     dc.l ((6*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1216     dc.l ((7*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1217     dc.l ((8*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1218     dc.l ((9*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1219     dc.l ((10*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1220     dc.l ((11*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1221     dc.l ((12*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1222     dc.l ((13*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1223     dc.l ((14*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1224     dc.l ((15*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1225    
1226     dc.l ((16*source_height)/dest_height)*ZOOMER_BUFFER_WIDTH
1227    
1228     cinemascope_buffer_size set cinemascope_buffer_size+(dest_height*ZOOMER_BUFFER_WIDTH)
1229     endm
1230    
1231    
1232     ; Initialize with a first line containing neutral values
1233     cinemascope_buffer_size set ZOOMER_BUFFER_WIDTH
1234    
1235     Scaler_Table_Start
1236     var set 0
1237     REPT ZOOMER_STEPS
1238     var set var+1
1239     percentage set (var*100)/ZOOMER_STEPS
1240     SCALE_TABLE percentage,ZOOMER_WIDTH,ZOOMER_HEIGHT
1241     ENDR
1242    
1243     Scaler_Tables
1244     var set 0
1245     REPT ZOOMER_STEPS
1246     dc.l Scaler_Table_Start+var*zoomer_size
1247     var set var+1
1248     ENDR
1249    
1250    
1251     SpriteData_D
1252     ;0
1253     dc.l big_buffer_start+cinemascope_sprites_depacked+32+(0*8) ; D
1254     dc.l big_buffer_start+masks_defenceforcelogo+(0*2)
1255     dc.w 2
1256    
1257     SpriteData_C
1258     ;1
1259     dc.l big_buffer_start+cinemascope_sprites_depacked+32+(3*8) ; C
1260     dc.l big_buffer_start+masks_defenceforcelogo+(3*2)
1261     dc.w 2
1262    
1263     SpriteData_O
1264     ;2
1265     dc.l big_buffer_start+cinemascope_sprites_depacked+32+(6*8) ; O
1266     dc.l big_buffer_start+masks_defenceforcelogo+(6*2)
1267     dc.w 2
1268    
1269     SpriteData_N
1270     ;3
1271     dc.l big_buffer_start+cinemascope_sprites_depacked+32+(9*8) ; N
1272     dc.l big_buffer_start+masks_defenceforcelogo+(9*2)
1273     dc.w 2
1274    
1275     SpriteData_E
1276     ;4
1277     dc.l big_buffer_start+cinemascope_sprites_depacked+32+(12*8) ; E
1278     dc.l big_buffer_start+masks_defenceforcelogo+(12*2)
1279     dc.w 2
1280    
1281     SpriteData_F
1282     ;5
1283     dc.l big_buffer_start+cinemascope_sprites_depacked+32+(15*8) ; F
1284     dc.l big_buffer_start+masks_defenceforcelogo+(15*2)
1285     dc.w 2
1286    
1287     SpriteData_R
1288     ;6
1289     dc.l big_buffer_start+cinemascope_sprites_depacked+32+(18*8) ; R
1290     dc.l big_buffer_start+masks_defenceforcelogo+(18*2)
1291     dc.w 2
1292    
1293    
1294     sprite_offset_x equ 20
1295     sprite_offset_y equ -31
1296    
1297     SpritePos
1298     dc.w 0,150
1299     dc.w 76,49 ; D
1300     dc.l SpriteData_D
1301     dc.w 416,0
1302     dc.w 114,49 ; E
1303     dc.l SpriteData_E
1304     dc.w 416,100
1305     dc.w 152,49 ; F
1306     dc.l SpriteData_F
1307     dc.w 0,150
1308     dc.w 190,49 ; E
1309     dc.l SpriteData_E
1310     dc.w 416,30
1311     dc.w 228,49 ; N
1312     dc.l SpriteData_N
1313     dc.w 416,160
1314     dc.w 266,49 ; C
1315     dc.l SpriteData_C
1316     dc.w 0,30
1317     dc.w 304,49 ; E
1318     dc.l SpriteData_E
1319    
1320     dc.w 416,200
1321     dc.w 114,113 ; F
1322     dc.l SpriteData_F
1323     dc.w 0,40
1324     dc.w 152,113 ; O
1325     dc.l SpriteData_O
1326     dc.w 0,150
1327     dc.w 190,113 ; R
1328     dc.l SpriteData_R
1329     dc.w 416,20
1330     dc.w 228,113 ; C
1331     dc.l SpriteData_C
1332     dc.w 0,0
1333     dc.w 266,113 ; E
1334     dc.l SpriteData_E
1335    
1336     dc.w -1,-1
1337     dc.w -1,-1
1338     dc.l 0
1339    
1340     ; Background rectangle: 42,87 - 327,173
1341    
1342    
1343     SECTION BSS
1344    
1345     even
1346    
1347     Scaler_Factor ds.w 1
1348    
1349     Scaler_Width ds.w 1
1350     Scaler_Height ds.w 1
1351    
1352     Scaler_CurWidth ds.w 1
1353     Scaler_CurHeight ds.w 1
1354    
1355     Scaler_StrideSrc ds.w 1
1356     Scaler_StrideDst ds.w 1
1357    
1358     Scaler_PtrSrc ds.l 1
1359     Scaler_PtrDst ds.l 1
1360    
1361     Scaler_DestOffset ds.w 1
1362    
1363     even
1364    
1365     defenceforce_pos_x ds.w 1
1366     defenceforce_offset_y ds.w 1
1367    
1368     ZoomerAngle ds.w 1
1369    
1370     ptr_sprite_data ds.l 1
1371     ptr_current_sprite ds.l 1
1372     sprite_screen_offset ds.l 1
1373     blue_plane_speed ds.b 1
1374    
1375     even
1376    
1377     blue_plane_angle ds.w 1
1378     blue_plane_zoom ds.w 1
1379    
1380     blue_plane_x0 ds.w 1
1381     blue_plane_y0 ds.w 1
1382     blue_plane_z0 ds.w 1
1383     blue_plane_x1 ds.w 1
1384     blue_plane_y1 ds.w 1
1385     blue_plane_z1 ds.w 1
1386    
1387     blue_plane_xx0 ds.w 1
1388     blue_plane_yy0 ds.w 1
1389    
1390     blue_plane_xx1 ds.w 1
1391     blue_plane_yy1 ds.w 1
1392    
1393     blue_plane_light ds.w 1 ; +0,+15
1394    
1395     ;
1396     ; The content of this buffer is going to be stored in
1397     ; the big common table.
1398     ;
1399     rsreset
1400     cinemascope_screenbuffer rs.b cinemascope_buffer_size ; about 616448 bytes for 32 levels
1401    
1402     cinemascope_fullscreen rs.b Size_PanoramicRoutine_DisplayList
1403     zoomer_buffer_chunky rs.b ZOOMER_BUFFER_WIDTH*100
1404     cinemascope_logo_depacked rs.b 20832
1405     cinemascope_sprites_depacked rs.b 7712
1406     cinemascope_scanlines rs.l ZOOMER_HEIGHT*ZOOMER_STEPS ; 85*32 - interlaced
1407    
1408     defenceforce_offsets rs.w 128 ; Line offsets
1409    
1410     defenceforce_sprite_curve rs.w ((SPRITES_CURVE_LENGHT/SPRITES_CURVE_SPEED)+1)*2
1411    
1412     RotatingPlanPaletteStart rs.w 2 ; Black, Black
1413     RotatingPlanPaletteEnd rs.w 2 ; Blue, Orange
1414     RotatingPlanPaletteFade rs.w 2*16 ; All the gradient colors
1415    
1416     masks_defenceforcelogo rs.b 160*SPRITES_HEIGHT
1417     defenceforce_screen rs.b 256*200+65536 ; Screen data for the scanlines
1418     defenceforce_screen_1 rs.b 416*200 ; Screen data for the sprites (front buffer)
1419     defenceforce_screen_2 rs.b 416*200 ; Screen data for the sprites (back buffer)
1420    
1421    
1422    
1423     update_buffer_size
1424    
1425    
1426    

  ViewVC Help
Powered by ViewVC 1.1.26