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

  ViewVC Help
Powered by ViewVC 1.1.26