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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (show annotations)
Sat Nov 28 13:10:37 2009 UTC (10 years ago) by dbug
File size: 4692 byte(s)
Added the source code of "Save The Earth", the Atari STe demo presented at Kindergarden 2009
1
2
3 TVSNOW_WIDTH equ 416
4 TVSNOW_HEIGHT equ (273+16)
5
6 PRNLOOP macro
7 add.l d0,d0 ; shift left 1 bit
8 bcc.s .\@ ; branch if bit 32 not set
9 eor.b d1,d0 ; do galois LFSR feedback
10 .\@
11 endm
12
13 SECTION TEXT
14
15 even
16
17 TvSnowInit
18 ifne enable_music
19 bsr StopMusic
20 endc
21
22 bsr GenerateWhiteNoisePicture
23
24 ; Set the volume down
25 move.w #LMC_MASTERVOL+%100010,d0 ; volume -12dB
26 bsr SetMixer
27
28 ; Static noise
29 lea big_buffer_start+tvsnow_picture,a0
30 lea big_buffer_start+tvsnow_picture_end,a1
31 bsr StartReplay
32 move.l d0,big_buffer_start+tvsnow_counter
33
34 ; Set the screen information (static fullscreen picture)
35 lea big_buffer_start+tvsnow_picture,a0
36 move.l a0,ptr_scr_1
37
38 ; Picture palette
39 lea black_palette,a0
40 lea GreyPalette,a1
41 moveq #16,d7
42 bsr ComputeGradient
43
44 ; Using the template data, we generate the fullscreen
45 lea FullTemplateList_Fullscreen,a0
46 lea big_buffer_start+tvsnow_fullscreen,a1
47 bsr GenerateOverscan
48 rts
49
50 TvSnowPlay
51 subq.l #1,big_buffer_start+tvsnow_counter
52 bpl.s TvSnowShake
53 ; We are done with this part
54 st.b flag_end_part
55 rts
56
57 TvSnowShakeFadeOut
58 ; Set the volume down
59 subq.w #2,big_buffer_start+tvsnow_master_volume
60 move.w big_buffer_start+tvsnow_master_volume,d0
61 add.w #LMC_MASTERVOL,d0
62 bsr SetMixer
63 TvSnowShake
64 move pos_scr_x,d0
65 add #47,d0
66 and #$00ff,d0
67 move d0,pos_scr_x
68
69 move pos_scr_y,d0
70 addq #7,d0
71 and #$000f,d0
72 move d0,pos_scr_y
73 rts
74
75 TvSnowTerminate
76 ; Picture palette
77 lea GreyPalette,a0
78 lea black_palette,a1
79 moveq #16,d7
80 bsr ComputeGradient
81
82 move.w #%100010,big_buffer_start+tvsnow_master_volume
83 move.l #TvSnowShakeFadeOut,_AdrEndOfFadeRoutine
84 bsr WaitEndOfFade
85
86 bsr TerminateFullscreenTimer
87
88 ; Cut the sample playing
89 bsr EndReplay
90
91 ; Reset the volume
92 move.w #LMC_MASTERVOL+%101000,d0 ; -0db master volume
93 bsr SetMixer
94
95 rts
96
97
98
99 GenerateWhiteNoisePicture
100 COLORHELP #$700
101
102 ;
103 ; Noise picture generation - chunky
104 ;
105 moveq #$AF-$100,d1 ; set EOR value
106 move.l Prng32,d0 ; get current
107
108 lea big_buffer_start+tvsnow_chunky_buffer,a0 ; 113568 bytes
109 move.w #TVSNOW_WIDTH*TVSNOW_HEIGHT/8-1,d7
110 .loop_generate
111
112 REPT 19
113 PRNLOOP
114 ENDR
115
116 move.l d0,d3
117 and.l #$0f0f0f0f,d3
118 move.l d3,(a0)+
119
120 move.l d0,d3
121 lsr.l #4,d3
122 and.l #$0f0f0f0f,d3
123 move.l d3,(a0)+
124
125 dbra d7,.loop_generate
126
127 move.l d0,Prng32 ; save back to seed word
128
129 COLORHELP #$007
130
131 ;
132 ; 2x2 matrix blur
133 ;
134 lea big_buffer_start+tvsnow_chunky_buffer,a0 ; 113568 bytes
135 moveq #0,d0
136 moveq #0,d1
137 moveq #0,d2
138 moveq #0,d3
139 move #TVSNOW_HEIGHT-1-1,d7
140 .loop_blur_y
141
142 move.l a0,a1
143 lea TVSNOW_WIDTH(a1),a2
144
145 move.b (a1)+,d0
146 move.b (a2)+,d1
147
148 move #TVSNOW_WIDTH/4-1,d6
149 .loop_blur_x
150
151 REPT 4
152 move.b (a1),d2
153 move.b (a2)+,d3
154 add d2,d0
155 add d3,d1
156 add d1,d0
157 lsr #2,d0
158 move.b d0,(a1)+
159 move d2,d0
160 move d3,d1
161 ENDR
162
163 dbra d6,.loop_blur_x
164
165 lea TVSNOW_WIDTH(a0),a0
166 dbra d7,.loop_blur_y
167
168 COLORHELP #$707
169
170 ;
171 ; Motion blur
172 ;
173 lea big_buffer_start+tvsnow_chunky_buffer,a0 ; 113568 bytes
174 moveq #0,d0
175 move.b (a0),d0
176 moveq #0,d1
177 move.w #TVSNOW_WIDTH*TVSNOW_HEIGHT/4-1,d7
178 .loop_blur
179 REPT 4
180 move.b (a0),d1
181 add.w d1,d0
182 lsr.w d0
183 move.b d0,(a0)+
184 ENDR
185 dbra d7,.loop_blur
186
187 COLORHELP #$770
188
189 ; Chunky to planar conversion
190 ; a0=source buffer (chunky)
191 ; a1=destination buffer (plannar)
192 ; d0=size of the buffer in 16 pixels blocs
193 lea big_buffer_start+tvsnow_chunky_buffer,a0
194 lea big_buffer_start+tvsnow_picture,a1
195 move.l #TVSNOW_WIDTH*TVSNOW_HEIGHT/16,d0
196 bsr.s ZoomerChunkyToPlannar
197
198 COLORHELP #$000
199
200 rts
201
202 ; a0=source buffer (chunky)
203 ; a1=destination buffer (plannar)
204 ; d0=size of the buffer in 16 pixels blocs
205 ZoomerChunkyToPlannar
206 move.l d0,d7
207 .loop
208 moveq #0,d0
209 move d0,d1
210 move d0,d2
211 move d0,d3
212
213 ; Shift until we get 16 bytes
214 REPT 16
215 moveq #0,d4
216 move.b (a0)+,d4
217 lsr.w d4
218 roxl.w d3
219 lsr.w d4
220 roxl.w d2
221 lsr.w d4
222 roxl.w d1
223 lsr.w d4
224 roxl.w d0
225 ENDR
226 ; Write the four bitplans
227 move.w d3,(a1)+
228 move.w d2,(a1)+
229 move.w d1,(a1)+
230 move.w d0,(a1)+
231
232 subq.l #1,d7
233 bne .loop
234 rts
235
236
237
238 SECTION DATA
239
240 even
241
242
243 SECTION BSS
244
245 even
246
247 ;
248 ; The content of this buffer is going to be stored in
249 ; the big common table.
250 ;
251 rsreset
252
253 tvsnow_counter rs.l 1
254 tvsnow_fullscreen rs.b Size_Fullscreen
255
256 tvsnow_picture rs.b (TVSNOW_WIDTH/2)*TVSNOW_HEIGHT ; Plannar buffer
257 tvsnow_picture_end rs.b 0
258
259 tvsnow_chunky_buffer rs.b TVSNOW_WIDTH*TVSNOW_HEIGHT ; Chunky buffer
260 tvsnow_master_volume rs.w 1
261
262 update_buffer_size
263
264
265
266

  ViewVC Help
Powered by ViewVC 1.1.26