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

Contents of /public/oric/demos/SlideShowDemo/code/scroller.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1071 - (show annotations)
Mon Jan 6 20:20:59 2014 UTC (5 years, 10 months ago) by dbug
File size: 9126 byte(s)
More work on the code:
- The switch to HIRES is now more optimal and in the boot sector, so the loader code itself is more compact which leaves more room for the file info tables.
- Reorganized all the buffers in a new file, in order to avoid wasting room with the alignment
- There's now a small intro before the main slide
- The music player now cleanly stops after the end of a music has been reached and informed the main code so it can load the next track
- Removed a lot of redundant code in the scroller code
1
2 #define SCROLLER_BUFFER_WIDTH 91
3
4 #define SCROLLER_EFFECT_GARBAGE 1
5
6
7 .zero
8
9 _MessageScrollerPtr .dsb 2
10 scroll_ptr_0 .dsb 2
11 scroll_ptr_1 .dsb 2
12 scroll_tmp_0 .dsb 2
13 scroll_tmp_1 .dsb 2
14
15 .text
16
17
18 DitheringLeft
19 .byt %001110
20 .byt %010101
21 .byt %101011
22 .byt %010101
23 .byt %001110
24 .byt %010001
25 .byt %101111
26 .byt %010101
27 .byt %001010
28 .byt %010101
29 .byt %101111
30 .byt %010001
31 .byt %001110
32 .byt %010101
33 .byt %101011
34 .byt %010101
35
36 DitheringRight
37 .byt %011100
38 .byt %101010
39 .byt %110101
40 .byt %101010
41 .byt %011100
42 .byt %100010
43 .byt %111101
44 .byt %101010
45 .byt %010100
46 .byt %101010
47 .byt %111101
48 .byt %100010
49 .byt %011100
50 .byt %101010
51 .byt %110101
52 .byt %101010
53
54 _MessageScroller
55 .asc ":p"
56
57
58 .asc "The End :) Let's wrap... "
59
60 .asc " "
61 .byt 0
62
63 _NarrowCharacterList
64 .asc "iIl,;.:!'"
65 .byt 0
66
67
68 ByteMaskRight .byt 0
69 ByteMaskLeft .byt 0
70 column .byt 0
71 columnCopy .byt 20
72 tempWhatever .byt 0
73
74 ScrollerCharacterColumn .byt 0
75 ScrollerCurChar .byt 0
76 ScrollCurCharWidth .byt 0
77 StupidRotatingMask .byt 0
78
79
80
81
82 ; xx111111
83 ;
84 ; xx011111
85 ; xx100000
86
87 GenerateScrollTable
88 .(
89 ldx #0
90 loop
91 txa
92 and #%00111111
93 lsr
94 ora #64
95 sta ScrollTableLeft,x
96
97 txa
98 and #%00000001
99 lsr
100 bcc skip
101 ora #%00100000
102 skip
103 ora #64
104
105 sta ScrollTableRight,x
106 inx
107 cpx #0
108 bne loop
109
110
111 ; Then the font character address table, first make all unknown characters
112 ; point to the space character.
113 ldx #0
114 loop_init_car
115 lda #<_FontBuffer
116 sta _FontAddrLow,x
117 lda #>_FontBuffer
118 sta _FontAddrHigh,x
119
120 lda #2
121 sta _FontCharacterWidth,x
122 inx
123 cpx #128
124 bne loop_init_car
125
126 .(
127 ldx #0
128 loop_init_width
129 lda _NarrowCharacterList,x
130 beq end_loop
131 tay
132 lda #1
133 sta _FontCharacterWidth,y
134 inx
135 bne loop_init_width
136 end_loop
137 .)
138
139 ; Then the font character address table, first make all unknown characters
140 ; point to the space character.
141 lda #<_FontBuffer
142 sta tmp0+0
143 lda #>_FontBuffer
144 sta tmp0+1
145
146 ldx #32
147 loop_set_car
148 clc
149 lda tmp0+0
150 sta _FontAddrLow,x
151 adc #32
152 sta tmp0+0
153 lda tmp0+1
154 sta _FontAddrHigh,x
155 adc #0
156 sta tmp0+1
157 inx
158 cpx #128
159 bne loop_set_car
160
161 rts
162 .)
163
164
165 _ScrollerInit
166 ; Write the characters in the bottom text area
167 ldy #32
168 ldx #0
169 loop_fill_text
170 tya
171 sta $bb80+40*26,x
172 iny
173 tya
174 sta $bb80+40*27,x
175 iny
176 inx
177 cpx #40
178 bne loop_fill_text
179
180
181 jsr GenerateScrollTable
182
183 ldy #44
184 sty column
185
186 jsr ScrollerDisplayReset
187
188 ;
189 ; Install the IRQ
190 ;
191 sei
192 lda #<_ScrollerDisplay
193 sta _InterruptCallBack_2+1
194 lda #>_ScrollerDisplay
195 sta _InterruptCallBack_2+2
196 cli
197 rts
198
199
200
201 ScrollBufferAddrLow
202 .byt <ScrollerBuffer1
203 .byt <ScrollerBuffer2
204 .byt <ScrollerBuffer3
205 .byt <ScrollerBuffer4
206 .byt <ScrollerBuffer5
207 .byt <ScrollerBuffer6
208 ; Garbage
209 .byt <_ScrollerDisplay
210
211 ScrollBufferAddrHigh
212 .byt >ScrollerBuffer1
213 .byt >ScrollerBuffer2
214 .byt >ScrollerBuffer3
215 .byt >ScrollerBuffer4
216 .byt >ScrollerBuffer5
217 .byt >ScrollerBuffer6
218 ; Garbage
219 .byt >_ScrollerDisplay
220
221 ScrollBufferCounter .byt 1
222
223 _ScrollerDisplay
224 jsr __auto_jump
225
226 .(
227 ldx ScrollBufferCounter
228 dex
229 bne skip
230 ldx #6
231 skip
232 stx ScrollBufferCounter
233 .)
234
235 .(
236 lda _FlagGarbageEnabled
237 beq skip
238 lda _SystemFrameCounter_low
239 and #1
240 beq skip
241 ldx #7
242 skip
243 .)
244
245 lda ScrollBufferAddrLow-1,x
246 sta scroll_ptr_0+0
247 lda ScrollBufferAddrHigh-1,x
248 sta scroll_ptr_0+1
249 jmp CopyToCharset
250
251 __auto_jump
252 jmp (ScrollerJumpTable)
253
254
255
256 _ScrollerPhase1
257 ;jmp _ScrollerPhase1
258
259 ldx column
260 inx
261 cpx #45
262 bcc skip_reset
263 ldx #0
264 skip_reset
265 stx column
266 clc
267 txa
268 adc #45
269 sta columnCopy
270
271
272 lda ScrollerCharacterColumn
273 cmp ScrollCurCharWidth
274 bne WriteCharData
275
276 InsertNewChar
277 ;jmp InsertNewChar
278 ; Get character and write into the buffer
279 ldy #0
280 sty ScrollerCharacterColumn
281
282 lda (_MessageScrollerPtr),y
283 cmp #32
284 bcs NoSpecialEffect
285 beq ScrollerDisplayReset
286 bne ScrollerSpecialCode
287 NoSpecialEffect
288 sta ScrollerCurChar
289 tay
290 lda _FontCharacterWidth,y
291 sta ScrollCurCharWidth
292
293 jsr ScrollerIncPointer
294
295 WriteCharData
296 ldx ScrollerCurChar
297 jsr InsertCharacter
298
299 inc __auto_jump+1
300 inc __auto_jump+1
301 rts
302
303 _FlagGarbageEnabled .byt 0
304
305 ScrollerSpecialCode
306 cmp #SCROLLER_EFFECT_GARBAGE
307 beq ScrollerEffectGarbage
308 jsr ScrollerIncPointer
309 jmp InsertNewChar
310
311 ScrollerEffectGarbage
312 ;inc $bb80+40*25+1
313 lda _FlagGarbageEnabled
314 eor #255
315 sta _FlagGarbageEnabled
316 jsr ScrollerIncPointer
317 jmp InsertNewChar
318
319
320 _ScrollerPhase2
321 _ScrollerPhase3
322 _ScrollerPhase4
323 _ScrollerPhase5
324 jsr CopyAndShift
325 inc __auto_jump+1
326 inc __auto_jump+1
327 rts
328
329 _ScrollerPhase6
330 jsr CopyAndShift
331 ; Reset to the start of the table
332 lda #<ScrollerJumpTable
333 sta __auto_jump+1
334 rts
335
336
337 ScrollerDisplayReset
338 lda #<_MessageScroller
339 sta _MessageScrollerPtr+0
340 lda #>_MessageScroller
341 sta _MessageScrollerPtr+1
342 rts
343
344
345
346
347 ScrollerIncPointer
348 inc _MessageScrollerPtr
349 bne skipscrollermove
350 inc _MessageScrollerPtr+1
351 skipscrollermove
352 rts
353
354
355
356 InsertCharacter
357 lda _FontAddrLow,x
358 sta __auto_font+1
359 lda _FontAddrHigh,x
360 sta __auto_font+2
361
362 lda #<ScrollerBuffer1
363 sta scroll_tmp_0+0
364 sta scroll_tmp_1+0
365 lda #>ScrollerBuffer1
366 sta scroll_tmp_0+1
367 sta scroll_tmp_1+1
368
369 ldx ScrollerCharacterColumn
370 loop_insert_character
371 __auto_font
372 lda $1234,x
373 ora #64
374 ldy column
375 sta (scroll_tmp_1),y
376 ldy columnCopy
377 sta (scroll_tmp_1),y
378
379 clc
380 lda scroll_tmp_1+0
381 adc #SCROLLER_BUFFER_WIDTH
382 sta scroll_tmp_1+0
383 lda scroll_tmp_1+1
384 adc #0
385 sta scroll_tmp_1+1
386
387 inx
388 inx
389 cpx #32
390 bcc loop_insert_character
391
392 inc ScrollerCharacterColumn
393
394 lda #0
395 sta StupidRotatingMask
396
397 rts
398
399
400 CopyAndShift
401 lda StupidRotatingMask
402 lsr
403 ora #%11100000
404 sta StupidRotatingMask
405
406 ldx #0
407 loop_shift_character
408 ldy column
409 lda (scroll_tmp_0),y
410
411 tay
412 lda ScrollTableRight,y
413 sta ByteMaskRight
414 lda ScrollTableLeft,y
415 sta ByteMaskLeft
416 ldy column
417 lda (scroll_tmp_1),y
418 and #%11100000
419 ora ByteMaskLeft
420 sta (scroll_tmp_1),y
421
422 ldy columnCopy
423 sta tempWhatever
424 lda (scroll_tmp_1),y
425 and StupidRotatingMask
426 ora tempWhatever
427 sta (scroll_tmp_1),y
428
429
430 ldy column
431 iny
432
433 lda (scroll_tmp_0),y
434 tay
435 lda ScrollTableLeft,y
436 ora ByteMaskRight
437 ldy column
438 iny
439 sta (scroll_tmp_1),y
440
441 ldy columnCopy
442 iny
443 sta (scroll_tmp_1),y
444
445 clc
446 lda scroll_tmp_0+0
447 adc #SCROLLER_BUFFER_WIDTH
448 sta scroll_tmp_0+0
449 lda scroll_tmp_0+1
450 adc #0
451 sta scroll_tmp_0+1
452
453 clc
454 lda scroll_tmp_1+0
455 adc #SCROLLER_BUFFER_WIDTH
456 sta scroll_tmp_1+0
457 lda scroll_tmp_1+1
458 adc #0
459 sta scroll_tmp_1+1
460
461 inx
462 cpx #16
463 bne loop_shift_character
464
465 rts
466
467
468 CopyToCharset
469 .(
470 ldx #0
471 loop
472 ldy column
473 iny
474 iny
475
476 lda (scroll_ptr_0),y
477 and DitheringLeft,x
478 sta $9800+32*8,x
479
480 iny
481 lda (scroll_ptr_0),y
482 sta $9800+34*8,x
483
484 iny
485 lda (scroll_ptr_0),y
486 sta $9800+36*8,x
487
488 iny
489 lda (scroll_ptr_0),y
490 sta $9800+38*8,x
491
492 iny
493 lda (scroll_ptr_0),y
494 sta $9800+40*8,x
495
496 iny
497 lda (scroll_ptr_0),y
498 sta $9800+42*8,x
499
500 iny
501 lda (scroll_ptr_0),y
502 sta $9800+44*8,x
503
504 iny
505 lda (scroll_ptr_0),y
506 sta $9800+46*8,x
507
508 iny
509 lda (scroll_ptr_0),y
510 sta $9800+48*8,x
511
512 iny
513 lda (scroll_ptr_0),y
514 sta $9800+50*8,x
515
516 iny
517 lda (scroll_ptr_0),y
518 sta $9800+52*8,x
519
520 iny
521 lda (scroll_ptr_0),y
522 sta $9800+54*8,x
523
524 iny
525 lda (scroll_ptr_0),y
526 sta $9800+56*8,x
527
528 iny
529 lda (scroll_ptr_0),y
530 sta $9800+58*8,x
531
532 iny
533 lda (scroll_ptr_0),y
534 sta $9800+60*8,x
535
536 iny
537 lda (scroll_ptr_0),y
538 sta $9800+62*8,x
539
540 iny
541 lda (scroll_ptr_0),y
542 sta $9800+64*8,x
543
544 iny
545 lda (scroll_ptr_0),y
546 sta $9800+66*8,x
547
548 iny
549 lda (scroll_ptr_0),y
550 sta $9800+68*8,x
551
552 iny
553 lda (scroll_ptr_0),y
554 sta $9800+70*8,x
555
556 iny
557 lda (scroll_ptr_0),y
558 sta $9800+72*8,x
559
560 iny
561 lda (scroll_ptr_0),y
562 sta $9800+74*8,x
563
564 iny
565 lda (scroll_ptr_0),y
566 sta $9800+76*8,x
567
568 iny
569 lda (scroll_ptr_0),y
570 sta $9800+78*8,x
571
572 iny
573 lda (scroll_ptr_0),y
574 sta $9800+80*8,x
575
576 iny
577 lda (scroll_ptr_0),y
578 sta $9800+82*8,x
579
580 iny
581 lda (scroll_ptr_0),y
582 sta $9800+84*8,x
583
584 iny
585 lda (scroll_ptr_0),y
586 sta $9800+86*8,x
587
588 iny
589 lda (scroll_ptr_0),y
590 sta $9800+88*8,x
591
592 iny
593 lda (scroll_ptr_0),y
594 sta $9800+90*8,x
595
596 iny
597 lda (scroll_ptr_0),y
598 sta $9800+92*8,x
599
600 iny
601 lda (scroll_ptr_0),y
602 sta $9800+94*8,x
603
604 iny
605 lda (scroll_ptr_0),y
606 sta $9800+96*8,x
607
608 iny
609 lda (scroll_ptr_0),y
610 sta $9800+98*8,x
611
612 iny
613 lda (scroll_ptr_0),y
614 sta $9800+100*8,x
615
616 iny
617 lda (scroll_ptr_0),y
618 sta $9800+102*8,x
619
620 iny
621 lda (scroll_ptr_0),y
622 sta $9800+104*8,x
623
624 iny
625 lda (scroll_ptr_0),y
626 sta $9800+106*8,x
627
628 iny
629 lda (scroll_ptr_0),y
630 sta $9800+108*8,x
631
632 iny
633 lda (scroll_ptr_0),y
634 and DitheringRight,x
635 sta $9800+110*8,x
636
637 clc
638 lda scroll_ptr_0+0
639 adc #SCROLLER_BUFFER_WIDTH
640 sta scroll_ptr_0+0
641 lda scroll_ptr_0+1
642 adc #0
643 sta scroll_ptr_0+1
644
645 inx
646 cpx #16
647 beq end
648 jmp loop
649 end
650
651 rts
652 .)
653
654

  ViewVC Help
Powered by ViewVC 1.1.26