/[projet1]/public/oric/demos/AlchimieX/scroller.s
Defence Force logotype

Contents of /public/oric/demos/AlchimieX/scroller.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1355 - (show annotations)
Sun Jan 17 15:19:38 2016 UTC (3 years, 10 months ago) by dbug
File size: 6881 byte(s)
Sounds better with the music.
1
2 #define ENABLE_MUSIC
3
4 #include "script.h"
5
6 #define via_portb $0300
7 #define via_t1cl $0304
8 #define via_t1ch $0305
9 #define via_t1ll $0306
10 #define via_t1lh $0307
11 #define via_t2ll $0308
12 #define via_t2ch $0309
13 #define via_sr $030A
14 #define via_acr $030b
15 #define via_pcr $030c
16 #define via_ifr $030D
17 #define via_ier $030E
18 #define via_porta $030f
19
20
21 .zero
22
23 _VblCounter .dsb 1
24
25 _SystemFrameCounter
26 _SystemFrameCounter_low .dsb 1
27 _SystemFrameCounter_high .dsb 1
28
29 _MessageScrollerPtr .dsb 2
30
31 _ScrollerCommand .dsb 1
32 _ScrollerCommandParam1 .dsb 1
33 _ScrollerCommandParam2 .dsb 1
34 _ScrollerCommandParam3 .dsb 1
35 _ScrollerCommandParam4 .dsb 1
36
37
38 .text
39
40
41 _MessageScroller
42 .byt SCROLLER_START_CHESSBOARD
43 .asc "Good news everyone! "
44 .byt SCROLLER_SHOW_KGLOGO
45 .asc "It is 7:56 on this mild norwegian morning, "
46 .byt SCROLLER_START_GAMEOFLIFE
47 .asc "here at Kindergarden. "
48 .byt SCROLLER_SHOW_EVOLUTIONLOGO
49 .asc "Since party coding rules, I'm working on a small intro for the Alchimie-X. "
50 .byt SCROLLER_SHOW_LOGO
51 .asc "This logo was (hand) converted from H2O's original, the music is from David Whittaker, "
52 .asc "the rest was built by Dbug on the party place."
53 .byt SCROLLER_SHOW_SPACESHIP
54 .asc "Looks like our friends from space are back??? "
55 .asc "Greeting to everybody at Kindergarden and Alchimie, and anyone else who deserves it :)"
56 .asc " "
57 .asc "The End :) Let's wrap..."
58
59 .asc " "
60 .byt SCROLLER_END
61
62
63 /*
64 ;
65 ; Installs a simple 50hz Irq
66 ;
67 ; 304
68 ; 306
69 ; 307
70 bit $304 // VIA_T1CL ; Turn off interrupt early. (More on that below
71
72 ;Based on setting T1 to FFFF and adding to global counter in IRQ for up to 16.5
73 ;Million Clock Cycles.
74
75
76 #define VIA_T1CL $0304
77 #define VIA_T1CH $0305
78
79 #define VIA_T1LL $0306
80 #define VIA_T1LH $0307
81
82 _VSync
83 lda $300
84 vsync_wait
85 lda $30D
86 and #%00010000 ;test du bit cb1 du registre d'indicateur d'IRQ
87 beq vsync_wait
88 rts
89
90 */
91 _System_InstallIRQ_SimpleVbl
92 .(
93 sei
94
95 //
96 // Switch OFF interrupts, and enable Overlay RAM
97 // Because writing in ROM, is basicaly very hard !
98 //
99 sei
100 lda #%11111101
101 sta $314
102
103 // Set the VIA parameters
104 lda #<19966 ; 20000
105 sta $306
106 lda #>19966 ; 20000
107 sta $307
108
109 lda #0
110 sta _VblCounter
111 sta _SystemFrameCounter_low
112 sta _SystemFrameCounter_high
113
114 lda #SCROLLER_NOTHING
115 sta _ScrollerCommand
116 lda #0
117 sta _ScrollerCommandParam1
118 sta _ScrollerCommandParam2
119
120 ;
121 ; Scroller
122 ;
123 jsr ScrollerDisplayReset
124
125 ;
126 ; Music player
127 ;
128 #ifdef ENABLE_MUSIC
129 jsr _Mym_Initialize
130 #endif
131
132 // Install interrupt (this works only if overlay ram is disabled)
133 lda #<_InterruptCode_SimpleVbl
134 sta $FFFE
135 lda #>_InterruptCode_SimpleVbl
136 sta $FFFF
137
138 cli
139 rts
140 .)
141
142
143
144
145 _VSync
146 lda _VblCounter
147 beq _VSync
148 lda #0
149 sta _VblCounter
150 rts
151
152
153 _InterruptCode_SimpleVbl
154 _InterruptCode
155 bit $304
156 inc _VblCounter
157
158 .(
159 inc _SystemFrameCounter_low
160 bne skip
161 inc _SystemFrameCounter_high
162 skip
163 .)
164
165 pha
166 txa
167 pha
168 tya
169 pha
170
171 jsr _ScrollerDisplay
172
173 #ifdef ENABLE_MUSIC
174 jsr _Mym_PlayFrame
175 #endif
176
177 _InterruptCodeEnd
178 pla
179 tay
180 pla
181 tax
182 pla
183
184 rti
185
186
187
188
189 _ScrollerInit
190 lda #SCROLLER_NOTHING
191 sta _ScrollerCommand
192
193 ; Clear the scroller area
194 ldx #39
195 lda #64
196 ScrollerInitEraseLoop
197 sta $a000+40*0,x
198 sta $a000+40*1,x
199 sta $a000+40*2,x
200 sta $a000+40*3,x
201 sta $a000+40*4,x
202 sta $a000+40*5,x
203 sta $a000+40*6,x
204 sta $a000+40*7,x
205 dex
206 bne ScrollerInitEraseLoop
207
208 ; Small gradient
209 lda #7
210 sta $a000+40*0
211 lda #7
212 sta $a000+40*1
213 lda #3
214 sta $a000+40*2
215 lda #3
216 sta $a000+40*3
217 lda #3
218 sta $a000+40*4
219 lda #2
220 sta $a000+40*5
221 lda #2
222 sta $a000+40*6
223 lda #2
224 sta $a000+40*7
225
226 ;lda #16+1
227 ;sta $a000+40*7
228
229 ; HIRES switch
230 lda #30
231 sta $bb80
232
233 ; TEXT switch
234 lda #26
235 sta $a000+40*8+40+40*75
236
237 ;
238 ; Minigradient test under the logos
239 ;
240 lda #16+6
241 sta $a000+40*87
242 lda #16+4
243 sta $a000+40*86
244 lda #16+6
245 sta $a000+40*87
246
247 rts
248
249
250
251
252
253
254
255
256
257 ScrollerCounter .byt 0
258
259 ScrollerCharBuffer .byt 0,0,0,0,0,0,0,0 ; Buffer with character to scroll
260
261
262 _ScrollerDisplay
263 ;Break jmp Break
264
265 lda ScrollerCounter
266 beq ScrollerNewCharacter
267
268 dec ScrollerCounter
269 jmp ScrollerEndNewCharacter
270
271 ScrollerNewCharacter
272 lda #6
273 sta ScrollerCounter
274
275 readCharacter
276 ; Get character and write into the buffer
277 ldy #0
278 lda (_MessageScrollerPtr),y
279 beq ScrollerDisplayReset
280 cmp #32
281 bcc SpecialCommand
282
283 jsr ScrollerIncPointer
284
285 ; Multiply by 8 the ASCII code to point in the font
286 sta tmp7
287 lda #0
288 sta tmp7+1
289
290 asl tmp7
291 rol tmp7+1
292
293 asl tmp7
294 rol tmp7+1
295
296 asl tmp7
297 rol tmp7+1
298
299 ; Add the font pointer
300 clc
301 lda #<_picture_font_2-32*8
302 adc tmp7
303 sta tmp7
304 lda #>_picture_font_2-32*8
305 adc tmp7+1
306 sta tmp7+1
307
308 ; Copy the character data to the scroller buffer
309 ldy #0
310 loopcopychar
311 lda (tmp7),y
312 ora #64
313 sta ScrollerCharBuffer,y
314 iny
315 cpy #8
316 bne loopcopychar
317
318 ScrollerEndNewCharacter
319
320
321 ;Break jmp Break
322
323 lda #<$a000
324 sta tmp6
325 lda #>$a000
326 sta tmp6+1
327
328
329 ldx #0
330 ScrollerDisplayLoopMessageY
331 ; Get pixel from character
332 clc
333 lda ScrollerCharBuffer,x
334 rol
335 cmp #192
336 and #$3F
337 ora #64
338 sta ScrollerCharBuffer,x
339
340 ; And then scroll the whole scanline
341 ldy #39
342 ScrollerDisplayLoopMessageX
343 lda (tmp6),y
344 rol
345 cmp #192
346 and #%00111111
347 ora #%01000000
348 sta (tmp6),y
349
350 dey
351 bne ScrollerDisplayLoopMessageX
352
353 clc
354 lda tmp6
355 adc #40
356 sta tmp6
357 bcc skipkipppp
358 inc tmp6+1
359 skipkipppp
360
361 inx
362 cpx #8
363 bne ScrollerDisplayLoopMessageY
364
365 rts
366
367
368 ScrollerDisplayReset
369 lda #<_MessageScroller
370 sta _MessageScrollerPtr
371 lda #>_MessageScroller
372 sta _MessageScrollerPtr+1
373 rts
374
375 SpecialCommand
376 ;cmp #SCROLLER_MOVE_MAP
377 ;beq ScrollerCommandThreeByte
378 ;cmp #SCROLLER_HIGHLIGHTE
379 ;beq ScrollerCommandFiveByte
380 ; ...default commands are one byte
381
382 ScrollerCommandOneByte
383 ldx #1
384 jmp ReadParameters
385
386 ScrollerCommandThreeByte
387 ldx #3
388 jmp ReadParameters
389
390 ScrollerCommandFiveByte
391 ldx #5
392 jmp ReadParameters
393
394 ParamCounter .byt 0
395
396 ReadParameters
397 .(
398 stx ParamCounter
399 ldx #0
400 ldy #0
401 loop
402 lda (_MessageScrollerPtr),y
403 sta _ScrollerCommand,x
404 inx
405
406 jsr ScrollerIncPointer
407
408 dec ParamCounter
409 bne loop
410 jmp readCharacter
411 .)
412
413
414
415 ScrollerIncPointer
416 inc _MessageScrollerPtr
417 bne skipscrollermove
418 inc _MessageScrollerPtr+1
419 skipscrollermove
420 rts

  ViewVC Help
Powered by ViewVC 1.1.26