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

Contents of /public/atari/demos/defenceforce/savetheearth/full.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (show annotations)
Sat Nov 28 13:10:37 2009 UTC (10 years, 3 months ago) by dbug
File size: 11882 byte(s)
Added the source code of "Save The Earth", the Atari STe demo presented at Kindergarden 2009
1
2 ; Normal scanline: 160 bytes
3 ; STE Fullscreen scanline: 208 bytes
4 ; STF Fullscreen scanline: 230 bytes
5 ; Extend scanline: 256 bytes
6 ;
7 ; Panoramic modes:
8 ; 160*200=32000
9 ; 208*200=41600
10 ; 230*200=46000
11 ; 256*200=51200
12 ;
13 ; Fullscreen modes:
14 ; 208*313=65104
15 ;
16 ; Subitles:
17 ; 160*50=8000 (stored in subtitle.s)
18 ;
19 ; Size for 4 screens:
20 ; 208*200*4=41600*4=166400
21
22
23 SECTION TEXT
24
25 even
26
27 FullStart
28
29
30
31 ;
32 ; Display list related code
33 ;
34 ; a0=screen adress (*256 + pixelshift in low byte)
35 ; a1=palette adress
36 ; a2=display list pointer
37 ; d0=screen increment (*256)
38 ; d1=palette increment
39 ;
40 DisplayListInit200
41 REPT 67
42 move.l a0,(a2)+
43 move.l a1,(a2)+
44 add.l d0,a0
45 add.l d1,a1
46 ENDR
47 DisplayListInit133
48 REPT 33
49 move.l a0,(a2)+
50 move.l a1,(a2)+
51 add.l d0,a0
52 add.l d1,a1
53 ENDR
54 DisplayListInit100
55 REPT 50
56 move.l a0,(a2)+
57 move.l a1,(a2)+
58 add.l d0,a0
59 add.l d1,a1
60 ENDR
61 DisplayListInit50
62 REPT 25
63 move.l a0,(a2)+
64 move.l a1,(a2)+
65 add.l d0,a0
66 add.l d1,a1
67 ENDR
68 DisplayListInit25
69 REPT 25
70 move.l a0,(a2)+
71 move.l a1,(a2)+
72 add.l d0,a0
73 add.l d1,a1
74 ENDR
75 rts
76
77 ; a0=screen adress
78 ; a1=palette
79 DisplayListInitStatic
80 lea DisplayList,a2
81 REPT 200
82 move.l a0,(a2)+
83 move.l a1,(a2)+
84 ENDR
85 rts
86
87 DisplayListInitBlack
88 move.l #empty_line,d0
89 move.l d0,a1 ; Palette
90 lsl.l #8,d0
91 move.l d0,a0 ; Screen
92 lea DisplayList,a2
93 moveq #0,d0
94 moveq #0,d1
95 bsr DisplayListInit200
96 rts
97
98
99
100
101 ; Using the template data, we generate the fullscreen
102 ; a0=template buffer
103 ; a1=destination buffer
104 ;
105 ; Format of the template buffer:
106 ; - Header
107 ; .b timer A delay value
108 ; .b timer A divider value
109 ; .l Adress of the Timer routine
110 ; - Scanline description
111 ; .w count
112 ; .w size
113 ; .w adress
114 ; Null count means that the generation is done
115 GenerateOverscan
116 move.l a1,_AdrFullRoutine
117
118 movem.l d0-a6,-(sp)
119 move.b (a0)+,timera_delay
120 move.b (a0)+,timera_div
121
122 move #$2700,sr ; Disable interrupts
123 move.l (a0)+,$134.w ; timer a vector
124 bset #5,$fffffa07.w ; iera: enable timer A
125 bset #5,$fffffa13.w ; imra: enable timer A
126 bclr #3,$fffffa17.w ; vr: automatic end of interrupt
127
128 clr.b $fffffa19.w ; stop timer a
129 move #$2300,sr ; Enable interrupts
130
131 .loop_entry
132 move.w (a0)+,d0 ; count
133 beq.s .done
134 subq #1,d0 ; for the dbra
135 move.w (a0)+,d1 ; size (in word -1)
136 move.l (a0)+,a2 ; source adress
137 .loop_copy_count
138 move d1,d2 ; copy size
139 move.l a2,a3 ; copy adress
140 .loop_copy_line
141 move.w (a3)+,(a1)+
142 dbra d2,.loop_copy_line
143 dbra d0,.loop_copy_count
144
145 bra.s .loop_entry
146 .done
147 ; Force black display list
148 bsr DisplayListInitBlack
149
150 ; Setup the timers
151 move #$2700,sr ; Disable interrupts
152 move.l #DummyHbl,$68.w ; Used in the timer to synchronize on the hbl interrupt
153 move.l #FullTimerVbl,$70.w ; vbl vector
154 move #$2300,sr ; Enable interrupts
155
156 movem.l (sp)+,d0-a6
157 rts
158
159
160 DummyHbl
161 rte
162
163
164
165 TerminateFullscreenTimer
166 move #$2700,sr ; Disable interrupts
167 move.l #routine_vbl_nothing,$70.w
168 clr.b $fffffa19.w ; stop timer a
169
170 movem.l black_palette,d0-d7
171 movem.l d0-d7,$ffff8240.w
172 movem.l d0-d7,palette_vbl_fade
173
174 move.l #DummyRoutine,_AdrPartVblRoutine
175
176 move #$2300,sr ; Enable interrupts
177 rts
178
179
180 ; 0-200
181 ; 245/7 for 50hz interrupt (7=prediv 200)
182 ; 150/5 for normal screen sync
183 ; 99/4 for top border (4=prediv 50)
184 FullTimerVbl
185 clr.b $fffffa19.w ; timer-a setup
186 move.b timera_delay,$fffffa1f.w ; tadr: delay
187 move.b timera_div,$fffffa19.w ; tacr: divider
188
189 ;_AdrFullTimerDelay=*+2
190 ; move.b #123,$fffffa1f.w ; tadr: delay
191 ; nop
192 ;_AdrFullTimerDiv=*+2
193 ; move.b #123,$fffffa19.w ; tacr: divider
194 ; nop
195
196 ifne enable_music
197 COLORHELP #$730
198 _AdrMusicVblRoutine=*+2
199 jsr DummyRoutine
200 ;bsr PlayMusic
201 COLORHELP #$000
202 endc
203
204 ifne enable_colorhelpers
205 move.w #$200,$ffff8240.w ; Dark red
206 else
207 move.w #$000,$ffff8240.w ; Black (4)
208 endc
209 rte
210
211
212 FullOverscanTimer
213 opt o-
214
215 pause 41
216
217 move.w #$2100,sr ; Wait for the next hardware HBL
218 stop #$2100
219
220 move.w #$2700,sr ; Disable interrupts
221 clr.b $fffffa19.w ; stop timer a
222
223 movem.l d0-a6,-(sp)
224 pause 52-2-2-3-3-4
225
226 lea $ffff8260.w,a0 ; 8/2 resolution
227 lea $ffff820a.w,a1 ; 8/2 frequence
228
229 lea shifter_data,a4 ; 12/3
230 move.l (a4)+,d4 ; 12/3 screen adress
231 move.l (a4)+,d6 ; 12/3 screen stride
232
233 move.b #0,$ffff820a.w ; remove top border
234 pause 9
235 move.b #2,$ffff820a.w
236
237 bra.s SyncOverscan ; 12/3
238
239 PanoramicTimer
240 clr.b $fffffa19.w ; stop timer a
241 move #$2700,sr ; Disable interrupts
242 ifne enable_colorhelpers
243 move.w #$070,$ffff8240.w ; Green
244 endc
245 movem.l d0-a6,-(sp)
246
247 lea $ffff8260.w,a0 ; 8/2 resolution
248 lea $ffff820a.w,a1 ; 8/2 frequence
249
250 bra.s SyncOverscan ; 12/3
251
252 nop
253
254 SyncOverscan
255 opt o-
256
257 ; STE hardware compatible synchronization code
258 move.b #0,$ffff8209.w
259
260 moveq #16,d2
261 .wait_sync
262 move.b $ffff8209.w,d0
263 beq.s .wait_sync
264 sub.b d0,d2
265 lsl.b d2,d0
266
267 ; Fullscreen routine
268 pause 96-11-5-64
269
270 ; jsr=20/5
271 _AdrFullRoutine=*+2
272 jsr $12345678
273
274 ; Put back the border in black at the end (cinemascope effect)
275 move.w #$000,$ffff8240.w
276
277 ; Finished :)
278 opt o+
279
280 ; Set the correct palette for the subtitle area
281 movem.l font_subtitles,d0-d7
282 movem.l d0-d7,$ffff8240.w
283
284 bsr ComputeVideoParameters
285 bsr CommonVblSubRoutine
286
287
288 ifne enable_colorhelpers
289 move.w #$002,$ffff8240.w ; Dark Blue
290 endc
291 movem.l (sp)+,d0-a6
292 rte
293
294
295
296
297 ; Code generation part --------------------------
298
299
300
301 ; *1
302 ; Used registers:
303 ; - a0 = fullscreen
304 ; - a1 = fullscreen
305 ; - a2 = display list pointer
306 ; - a3 = palette pointer
307 ; - a6 = hardware palette ($ffff8240)
308 ; - d0 = fullscreen
309 ; - d1 = screen adress parameters
310 PanoramicRoutine_DisplayList_Prolog
311 lea $ffff8240.w,a6 ; 8/2
312 pause 64-2-9-19-7
313
314 lea DisplayList,a2 ; 12/3
315 move.l (a2)+,d1 ; 12/3 (adress + offset)
316 move.l (a2)+,a3 ; 12/3
317 ; -> 3+3+3=9
318
319 ; Load the first palette
320 movem.l (a3)+,d2/d3/d4/d5/d6/d7/a4/a5 ; 12+8*8=12+64=76/19
321 movem.l a4/a5,24(a6) ; 12+8*2=12+16=28/7
322
323 .end
324 PanoramicRoutine_DisplayList_Prolog_Size equ .end-PanoramicRoutine_DisplayList_Prolog
325
326
327 ; *199
328 PanoramicRoutine_DisplayList_Line
329 ; **** Left ****
330 pause 11-3-6
331 movep.l d1,-5(a1) ; (6) $ffff8205/07/09/0B
332 move.b d1,91(a1) ; (3)
333
334 ; Left Border
335 move.w a0,(a0) ; 8/2 (Resolution=high [a0=$ffff8|2|60])
336 move.b d0,(a0) ; 8/2 (Resolution=low [d0=0] )
337
338 ; Change the colors
339 movem.l d2/d3/d4/d5/d6/d7,(a6) ; 8+8*6=8+48=56/14
340
341 move.l (a2)+,d1 ; 12/3
342 move.l (a2)+,a3 ; 12/3
343
344 ; Load the next palette
345 movem.l (a3)+,d2/d3/d4/d5/d6/d7/a4/a5 ; 12+8*8=12+64=76/19
346
347 pause 91-14-3-3-19
348
349 ; Right border
350 move.b d0,(a1) ; 8/2 (Frequence=60hz [d0=0])
351 move.w a0,(a1) ; 8/2 (Frequence=50hz [a0=$ffff8|2|60])
352
353 pause 18-7
354 movem.l a4/a5,24(a6) ; 12+8*2=12+16=28/7
355 .end
356 PanoramicRoutine_DisplayList_Line_Size equ .end-PanoramicRoutine_DisplayList_Line
357
358 ; Free time per scanline:
359 ;
360 ; pause 11-3-6 =2
361 ; pause 91-14-3-3-19=52
362 ; pause 18-7 =11
363 ; ->65 nops
364 ; 65*200=13000 nops = 52000 cycles = 32.44% of cpu time free
365
366
367
368 ; *1
369 Panoramic_DisplayList_Epilog
370 ; Bottom border switch
371 move.b d0,(a1) ;8/2 Low border start
372 move.w #$000,$ffff8240.w ;16/4
373 pause 10-4
374 move.w a0,(a1) ;8/2 Low border end
375
376 move.l #buffer_subtitles,d4
377 moveq #0,d5
378 move.b d5,91(a1) ; (3)
379 movep.l d4,-7(a1) ; (6) $ffff8203/05/07/09
380 rts
381 .end
382 Panoramic_DisplayList_Epilog_Size equ .end-Panoramic_DisplayList_Epilog
383
384
385
386
387
388
389 ; Prolog routine
390 ; *1
391 FullTemplate_NoColorChange_Prolog
392 pause 64-48
393
394 ; Change the entire palette before the screen starts, finishing by the color 0
395 lea palette_vbl_fade+4,a4 ; 12/3
396 lea ($ffff8240+4).w,a5 ; 8/2
397 move.l (a4)+,(a5)+ ; 20/5
398 move.l (a4)+,(a5)+ ; 20/5
399 move.l (a4)+,(a5)+ ; 20/5
400 move.l (a4)+,(a5)+ ; 20/5
401 move.l (a4)+,(a5)+ ; 20/5
402 move.l (a4)+,(a5)+ ; 20/5
403 move.l (a4)+,(a5)+ ; 20/5
404 move.l palette_vbl_fade,$ffff8240.w ; 32/8
405 ; -> 3+2+(5*7)+8=3+2+35+8=48
406 .end
407 FullTemplate_NoColorChange_Prolog_Size equ .end-FullTemplate_NoColorChange_Prolog
408
409
410 ; Standard fullscreen routine
411 ; *228
412 FullTemplate_NoColorChange_Line
413 pause 11-3-6
414 movep.l d4,-5(a1) ; (6) $ffff8205/07/09/0B
415 move.b d4,91(a1) ; (3)
416
417 ; Left Border
418 move.w a0,(a0) ;8/2
419 move.b d0,(a0) ;8/2
420
421 add.l d6,d4 ; 2
422 pause 91-2
423
424 ; Right border
425 move.b d0,(a1) ;8/2
426 move.w a0,(a1) ;8/2
427
428 pause 18
429 .end
430 FullTemplate_NoColorChange_Size equ .end-FullTemplate_NoColorChange_Line
431
432
433 ; Bottom border switch
434 ; *1
435 FullTemplate_NoColorChange_BottomSwitch
436 pause 11-3-6-2
437 movep.l d4,-5(a1) ; (6) $ffff8205/07/09/0B
438 move.b d4,91(a1) ; (3)
439
440 ; Left Border
441 move.b d0,(a1) ;8/2 Low border start
442 move.w a0,(a0) ;8/2
443 move.b d0,(a0) ;8/2
444 move.w a0,(a1) ;8/2 Low border end
445
446 add.l d6,d4 ; 2
447 pause 91-2-2
448
449 ; Right border
450 move.b d0,(a1) ;8/2
451 move.w a0,(a1) ;8/2
452
453 pause 18
454 .end
455 FullTemplate_NoColorChange_BottomSwitch_Size equ .end-FullTemplate_NoColorChange_BottomSwitch
456
457
458
459 ; Set the buffer to the subtitles to avoid glitches
460 ; *1
461 FullTemplate_NoColorChange_Epilog
462 move.l #buffer_subtitles,d0
463 movep.l d0,-7(a1) ; 24/6 $ffff8203/05/07/09
464 move.b #0,91(a1) ; 12/3 $ffff8265 (Pixel skip)
465 rts
466 .end
467 FullTemplate_NoColorChange_Epilog_Size equ .end-FullTemplate_NoColorChange_Epilog
468
469
470
471
472
473 FullEnd
474
475 SECTION DATA
476
477 even
478
479 ; Count, Start Adress, Size
480 FULLTEMPLATE macro
481 count set \1
482 size set \3
483 dc.w count,(size/2)-1
484 dc.l \2
485 fullroutinesize set fullroutinesize+(count*size)
486 endm
487
488 fullroutinesize set 0
489
490 ;
491 ; The full full routine, no color change, used by:
492 ; - TV Snow effect
493 ;
494 FullTemplateList_Fullscreen
495 dc.b 99,4
496 dc.l FullOverscanTimer
497 FULLTEMPLATE 1,FullTemplate_NoColorChange_Prolog,FullTemplate_NoColorChange_Prolog_Size
498 FULLTEMPLATE 228,FullTemplate_NoColorChange_Line,FullTemplate_NoColorChange_Size
499 FULLTEMPLATE 1,FullTemplate_NoColorChange_BottomSwitch,FullTemplate_NoColorChange_BottomSwitch_Size
500 FULLTEMPLATE 38,FullTemplate_NoColorChange_Line,FullTemplate_NoColorChange_Size
501 FULLTEMPLATE 1,FullTemplate_NoColorChange_Epilog,FullTemplate_NoColorChange_Epilog_Size
502 dc.w 0 ; End marker
503 Size_Fullscreen equ fullroutinesize
504
505
506 ;
507 ; The panoramic routine, using advanced display list, used by:
508 ; - Piracy
509 ; - Cinemascope display
510 ; - Defence Force logo
511 ; - Night city
512 ; - Insert Disk
513 ; - Desktop Office
514 ; - Motherboard
515 ; - Chatroom
516 ; - Out Run
517 ; - Credits
518 ;
519 fullroutinesize set 0
520 PanoramicTemplate_DisplayList
521 dc.b 150,5
522 dc.l PanoramicTimer
523 FULLTEMPLATE 1,PanoramicRoutine_DisplayList_Prolog,PanoramicRoutine_DisplayList_Prolog_Size
524 FULLTEMPLATE 199,PanoramicRoutine_DisplayList_Line,PanoramicRoutine_DisplayList_Line_Size
525 FULLTEMPLATE 1,Panoramic_DisplayList_Epilog,Panoramic_DisplayList_Epilog_Size
526 dc.w 0 ; End marker
527 Size_PanoramicRoutine_DisplayList equ fullroutinesize
528
529
530 even
531
532
533 TableShifterShift
534 var set 0
535 REPT 512
536 dc.b (var>>4)<<3 ; Adress
537 dc.b var&15 ; Pixelshift
538 var set var+1
539 ENDR
540
541
542
543 SECTION BSS
544
545 even
546
547 timera_delay ds.b 1
548 timera_div ds.b 1
549
550 ; Various types of contents in a Display List:
551 ; - Line adress (4) + pixel shift (1->2)
552 ; - Palette pointer (4)
553
554
555 DisplayList_Top ds.b 200*(4+4) ; Security crap
556 DisplayList ds.b 200*(4+4) ; Screen Pointer + Pixel offset + Palette adress, for each line
557 ds.b 200*(4+4) ; Security crap
558
559 even
560
561 ;
562 ; Restore compiler optimizations
563 ;
564 opt o+
565
566
567

  ViewVC Help
Powered by ViewVC 1.1.26