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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (show annotations)
Sat Nov 28 13:10:37 2009 UTC (10 years, 2 months ago) by dbug
File size: 8250 byte(s)
Added the source code of "Save The Earth", the Atari STe demo presented at Kindergarden 2009
1
2 SECTION TEXT
3
4 even
5
6 SEQUENCER_END equ 0
7 SEQUENCER_PLAY_SAMPLE equ 1
8 SEQUENCER_PLAY_SAMPLES equ 2
9 SEQUENCER_CALLBACK equ 3
10 SEQUENCER_TEMPORIZE equ 4
11 SEQUENCER_SUBTITLE equ 5
12 SEQUENCER_SETPTR equ 6
13 SEQUENCER_IRC_MESSAGE equ 7
14 SEQUENCER_DEPACK_LZSS equ 8
15 SEQUENCER_SETPICTURE equ 9
16 SEQUENCER_GO_NEXT_PART equ 10
17 SEQUENCER_SET_BYTE equ 11
18 SEQUENCER_SET_WORD equ 12
19 SEQUENCER_SET_LONG equ 13
20 SEQUENCER_SETPICTURE_DISPLAYLIST equ 14
21 SEQUENCER_WAIT_BYTE equ 15
22 SEQUENCER_WAIT_WORD equ 16
23 SEQUENCER_WAIT_LONG equ 17
24
25
26 SEQUENCE_END macro
27 dc.w SEQUENCER_END
28 endm
29
30
31 ; 1=start adress
32 ; 2=end adress
33 SEQUENCE_PLAYSAMPLE macro
34 dc.w SEQUENCER_PLAY_SAMPLE
35 dc.l (\1) ; Start adress
36 dc.l (\2) ; End adress
37 endm
38
39 SEQUENCE_PLAYSAMPLES macro
40 REPT \1
41 dc.w SEQUENCER_PLAY_SAMPLES
42 dc.w ((\3-\2)/4)/50 ; Lenght
43 dc.l (\4)+(\2) ; Start adress
44 dc.l (\4)+(\3) ; End adress
45 ENDR
46 endm
47
48 ; 1=routine adress
49 SEQUENCE_CALLBACK macro
50 dc.w SEQUENCER_CALLBACK
51 dc.l \1
52 endm
53
54 ; 1=duration
55 SEQUENCE_TEMPORIZE macro
56 dc.w SEQUENCER_TEMPORIZE
57 dc.w \1
58 endm
59
60 ; 1=zero terminated message string
61 ; This function does nothing if the debugging mode is enabled
62 SEQUENCE_SUBTITLE macro
63 ifeq enable_debug_text
64 dc.w SEQUENCER_SUBTITLE
65 dc.b \1
66 dc.b 0
67 endc
68 endm
69
70 ; 1=destination address
71 ; 2=pointer on the routine to set
72 SEQUENCE_SETPTR macro
73 dc.w SEQUENCER_SETPTR
74 dc.l \1
75 dc.l \2
76 endm
77
78 ; 1=irc nick id
79 ; 2=zero terminated message string
80 SEQUENCE_IRC_MESSAGE macro
81 dc.w SEQUENCER_IRC_MESSAGE
82 dc.w \1
83 dc.b \2
84 dc.b 0
85 even
86 endm
87
88 ; 1=pointer on packed source
89 ; 2=pointer on depack buffer
90 ; 3=size of depacked data
91 SEQUENCE_DEPACK_LZSS macro
92 dc.w SEQUENCER_DEPACK_LZSS
93 dc.l \1
94 dc.l \2
95 dc.l \3
96 endm
97
98 ; 1=pointer on the picture to display
99 SEQUENCE_SETPICTURE macro
100 dc.w SEQUENCER_SETPICTURE
101 dc.l \1
102 endm
103
104 SEQUENCE_GO_NEXT_PART macro
105 dc.w SEQUENCER_GO_NEXT_PART
106 endm
107
108 ; 1=pointer on the byte
109 ; 2=value of the byte
110 SEQUENCE_SET_BYTE macro
111 dc.w SEQUENCER_SET_BYTE
112 dc.l \1
113 dc.w \2
114 endm
115
116 ; 1=pointer on the word
117 ; 2=value of the word
118 SEQUENCE_SET_WORD macro
119 dc.w SEQUENCER_SET_WORD
120 dc.l \1
121 dc.w \2
122 endm
123
124 ; 1=pointer on the long
125 ; 2=value of the long
126 SEQUENCE_SET_LONG macro
127 dc.w SEQUENCER_SET_LONG
128 dc.l \1
129 dc.l \2
130 endm
131
132 ; 1=0 if mono-palette 1 if multipalette
133 ; 1=pointer on the picture to display
134 SEQUENCE_SETPICTURE_DISPLAYLIST macro
135 dc.w SEQUENCER_SETPICTURE_DISPLAYLIST
136 dc.w \1
137 dc.l \2
138 endm
139
140 ; 1=pointer on the byte
141 ; 2=value of the byte value to wait for
142 SEQUENCE_WAIT_BYTE macro
143 dc.w SEQUENCER_WAIT_BYTE
144 dc.l \1
145 dc.w \2
146 endm
147
148 ; 1=pointer on the word
149 ; 2=value of the word value to wait for
150 SEQUENCE_WAIT_WORD macro
151 dc.w SEQUENCER_WAIT_WORD
152 dc.l \1
153 dc.w \2
154 endm
155
156 ; 1=pointer on the long
157 ; 2=value of the long value to wait for
158 SEQUENCE_WAIT_LONG macro
159 dc.w SEQUENCER_WAIT_LONG
160 dc.l \1
161 dc.l \2
162 endm
163
164
165
166
167
168 ; a0=pointer on the sequence
169 SequencerInit
170 move.l a0,sequencer_ptr
171 clr.w sequencer_delay
172 rts
173
174
175 SequencerPlay
176 tst.w sequencer_delay
177 beq.s .next
178 subq.w #1,sequencer_delay
179 rts
180
181 .next
182 move.l sequencer_ptr,a0
183 move.w (a0)+,d0
184
185 ; Dispatches on the correct function
186 lea SequencerFunctionTable,a1
187 add.w d0,d0
188 add.w d0,d0
189 move.l (a1,d0.w),a1
190 jmp (a1)
191
192
193 SequencerFunction_done
194 rts
195
196
197 SequencerFunction_play_samples
198 move.w (a0)+,sequencer_delay
199 SequencerFunction_play_sample
200 lea $ffff8900.w,a1
201
202 move.b 3(a0),$7(a1) ; $ffff8907.w Dma start adress (low)
203 move.b 2(a0),$5(a1) ; $ffff8905.w Dma start adress (mid)
204 move.b 1(a0),$3(a1) ; $ffff8903.w Dma start adress (high)
205
206 move.b 7(a0),$13(a1) ; $ffff8913.w Dma end adress (low)
207 move.b 6(a0),$11(a1) ; $ffff8911.w Dma end adress (mid)
208 move.b 5(a0),$f(a1) ; $ffff890f.w Dma end adress (high)
209
210 lea 8(a0),a0
211
212 move.b #1+128,$21(a1) ; $ffff8921.w DMA mode (128=mono) (0=6258,1=12517,2=25033,3=50066)
213 move.b #1,$1(a1) ; $ffff8901.w DMA control (0=stop, 1=play once, 2=loop)
214
215 move.l a0,sequencer_ptr
216 rts
217
218 SequencerFunction_run_callback
219 move.l (a0)+,a1 ; Callback adress
220
221 movem.l d0-a6,-(sp)
222 jsr (a1)
223 movem.l (sp)+,d0-a6
224 move.l a0,sequencer_ptr
225 rts
226
227 SequencerFunction_temporize
228 move.w (a0)+,sequencer_delay
229 move.l a0,sequencer_ptr
230 rts
231
232 SequencerFunction_subtitle
233 ; a0 points on the message itself
234 move.l a0,a1
235 movem.l d0-a6,-(sp)
236 bsr SubtitleClearBuffer
237 move.l a1,a0
238 st.b character_wait_vbl
239 bsr SubtitleDrawText
240 sf.b character_wait_vbl
241 movem.l (sp)+,d0-a6
242 bsr GetAlignedEndOfString
243 move.l a0,sequencer_ptr
244 rts
245
246 SequencerFunction_set_ptr
247 move.l (a0)+,a1
248 move.l (a0)+,(a1)
249 move.l a0,sequencer_ptr
250 rts
251
252 SequencerFunction_irc_message
253 ifne enable_part_chatroom
254 move.w (a0)+,d0 ; irc nick
255 ; takes a0 as input; and returns in a0 after the zero
256 bsr ChatRoomIrcPrintMessage
257 move.l a0,d0
258 addq.l #1,d0
259 and.l #-2,d0
260 move.l d0,sequencer_ptr
261 endc
262 rts
263
264 SequencerFunction_depack_lzss
265 ; a0=depack block
266 bsr DepackBlock
267 lea 4*3(a0),a0
268 move.l a0,sequencer_ptr
269 rts
270
271 SequencerFunction_set_picture
272 move.l (a0)+,a1
273 move.l a0,sequencer_ptr
274 move #0,pos_scr_x
275 move #0,pos_scr_y
276
277 lea $ffff8240.w,a0
278 moveq #16,d7
279 bsr ComputeGradient
280 move.l a1,ptr_scr_1
281 rts
282
283 SequencerFunction_go_next_part
284 st.b flag_end_part
285 rts
286
287 SequencerFunction_set_byte
288 move.l (a0)+,a1
289 move.w (a0)+,d0
290 move.b d0,(a1)
291 move.l a0,sequencer_ptr
292 rts
293
294 SequencerFunction_set_word
295 move.l (a0)+,a1
296 move.w (a0)+,d0
297 move.w d0,(a1)
298 move.l a0,sequencer_ptr
299 rts
300
301 SequencerFunction_set_long
302 move.l (a0)+,a1
303 move.l (a0)+,d0
304 move.l d0,(a1)
305 move.l a0,sequencer_ptr
306 rts
307
308 SequencerFunction_set_picture_dlist
309 move.w (a0)+,d0 ; Flag palettes
310 beq.s .mono_palette
311 .multi_palette
312 move.l #32*200,d0
313 moveq #32,d1
314 bra.s .continue
315 .mono_palette
316 move.l #32,d0
317 moveq #0,d1
318 .continue
319 move.l (a0)+,a1 ; Base picture
320 move.l a0,sequencer_ptr
321
322 add.l a1,d0
323 lsl.l #8,d0
324 move.l d0,a0
325
326 move.l #208*256,d0
327
328 lea DisplayList,a2 ; Target display list
329 bsr DisplayListInit200
330 rts
331
332 SequencerFunction_wait_byte
333 move.l (a0)+,a1
334 move.w (a0)+,d0
335 cmp.b (a1),d0
336 bgt.s .not_yet
337 move.l a0,sequencer_ptr
338 .not_yet
339 rts
340
341 SequencerFunction_wait_word
342 move.l (a0)+,a1
343 move.w (a0)+,d0
344 cmp.w (a1),d0
345 bgt.s .not_yet
346 move.l a0,sequencer_ptr
347 .not_yet
348 rts
349
350 SequencerFunction_wait_long
351 move.l (a0)+,a1
352 move.l (a0)+,d0
353 cmp.l (a1),d0
354 bgt.s .not_yet
355 move.l a0,sequencer_ptr
356 .not_yet
357 rts
358
359
360 ; a0=pointer on string
361 ; return a0=pointer on the first aligned adress after the null terminator
362 GetAlignedEndOfString
363 .loop_find_end
364 tst.b (a0)+
365 bne.s .loop_find_end
366 move.l d0,-(sp)
367 move.l a0,d0
368 addq.l #1,d0
369 and.l #-2,d0
370 move.l d0,a0
371 move.l (sp)+,d0
372 rts
373
374
375 SECTION DATA
376
377 even
378
379 SequencerFunctionTable
380 dc.l SequencerFunction_done ; SEQUENCER_END
381 dc.l SequencerFunction_play_sample ; SEQUENCER_PLAY_SAMPLE
382 dc.l SequencerFunction_play_samples ; SEQUENCER_PLAY_SAMPLES
383 dc.l SequencerFunction_run_callback ; SEQUENCER_CALLBACK
384 dc.l SequencerFunction_temporize ; SEQUENCER_TEMPORIZE
385 dc.l SequencerFunction_subtitle ; SEQUENCER_SUBTITLE
386 dc.l SequencerFunction_set_ptr ; SEQUENCER_SETPTR
387 dc.l SequencerFunction_irc_message ; SEQUENCER_IRC_MESSAGE
388 dc.l SequencerFunction_depack_lzss ; SEQUENCER_DEPACK_LZSS
389 dc.l SequencerFunction_set_picture ; SEQUENCER_SETPICTURE
390 dc.l SequencerFunction_go_next_part ; SEQUENCER_GO_NEXT_PART
391 dc.l SequencerFunction_set_byte ; SEQUENCER_SET_BYTE
392 dc.l SequencerFunction_set_word ; SEQUENCER_SET_WORD
393 dc.l SequencerFunction_set_long ; SEQUENCER_SET_LONG
394 dc.l SequencerFunction_set_picture_dlist ; SEQUENCER_SETPICTURE_DISPLAYLIST
395 dc.l SequencerFunction_wait_byte ; SEQUENCER_WAIT_BYTE
396 dc.l SequencerFunction_wait_word ; SEQUENCER_WAIT_WORD
397 dc.l SequencerFunction_wait_long ; SEQUENCER_WAIT_LONG
398
399 SECTION BSS
400
401 even
402
403 sequencer_ptr ds.l 1
404 sequencer_delay ds.w 1
405
406
407
408

  ViewVC Help
Powered by ViewVC 1.1.26