base:scrolltext_using_sprites
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:scrolltext_using_sprites [2015-04-17 04:33] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | ; ---------------------------------------------------------------------------------------------------- | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; coding: testicle/ | ||
+ | ; logo: fabu/payday | ||
+ | ; | ||
+ | ; | ||
+ | ; contact and payday-releases: | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; this source code is part of an intro, so many code is missing here, | ||
+ | ; while only the interesting parts for the sprite scroller are shown. | ||
+ | ; it shows how to use sprites for text scrolling, so the scroll text | ||
+ | ; can easily be placed above pictures. | ||
+ | ; | ||
+ | ; this sourcecode is best view with the font " | ||
+ | ; you can compile this code using the ACME crossassembler. | ||
+ | ; | ||
+ | ; the code was written with Relaunch64, the c64-crossassembler-tool | ||
+ | ; for windows-pc. grab it at www.popelganda.de! | ||
+ | ; | ||
+ | ; ---------------------------------------------------------------------------------------------------- | ||
+ | |||
+ | |||
+ | ; | ||
+ | ;----- Paragraph @Globale Variablen@ ----- | ||
+ | ; | ||
+ | |||
+ | spritexpos = 128 | ||
+ | spriteypos = 140 ;sprite y-position | ||
+ | spritechar = $3300 ; | ||
+ | text = $3a00 | ||
+ | |||
+ | |||
+ | ; | ||
+ | ;----- Paragraph @Includes@ ----- | ||
+ | ; | ||
+ | |||
+ | ; init text pointer | ||
+ | |||
+ | lda #<text | ||
+ | sta $50 | ||
+ | lda #>text | ||
+ | sta $51 | ||
+ | |||
+ | ; | ||
+ | ;----- Paragraph @clear sprite-memory@ ----- | ||
+ | ; | ||
+ | |||
+ | ldx #0 | ||
+ | lda #$00 | ||
+ | .loop4 sta $3800,x | ||
+ | inx | ||
+ | bne .loop4 | ||
+ | ldx #0 | ||
+ | lda #$00 | ||
+ | .loop6 sta $3900,x | ||
+ | inx | ||
+ | cpx #64 | ||
+ | bne .loop6 | ||
+ | |||
+ | ldx #7 | ||
+ | lda #0 | ||
+ | .loop5 sta spritechar, | ||
+ | dex | ||
+ | bpl .loop5 | ||
+ | |||
+ | jsr sprscrollinit ; | ||
+ | |||
+ | cli ; | ||
+ | ;(see comment on top for further information) | ||
+ | loading lda #0 | ||
+ | beq loading ; | ||
+ | ;to a value of 1 when the user presses the space-bar | ||
+ | ;add something here to clear screen/move next demo part/ | ||
+ | |||
+ | |||
+ | ; | ||
+ | ; | ||
+ | ;----- Paragraph @init sprites above@ ----- | ||
+ | ; | ||
+ | ; | ||
+ | |||
+ | !zone | ||
+ | sprscrollinit lda #spritexpos | ||
+ | sta $d000 | ||
+ | lda # | ||
+ | sta $d002 | ||
+ | lda # | ||
+ | sta $d004 | ||
+ | lda # | ||
+ | sta $d006 | ||
+ | lda # | ||
+ | sta $d008 | ||
+ | lda #spriteypos | ||
+ | sta $d001 | ||
+ | sta $d003 | ||
+ | sta $d005 | ||
+ | sta $d007 | ||
+ | sta $d009 | ||
+ | |||
+ | lda # | ||
+ | sta $d015 | ||
+ | lda #0 | ||
+ | sta $d01b | ||
+ | sta $d01c | ||
+ | lda #11 | ||
+ | sta $d027 | ||
+ | sta $d028 | ||
+ | sta $d029 | ||
+ | sta $d02a | ||
+ | sta $d02b | ||
+ | |||
+ | ; | ||
+ | ; sprites at $3800 | ||
+ | ; | ||
+ | |||
+ | lda #224 | ||
+ | sta $07f8 | ||
+ | lda #225 | ||
+ | sta $07f9 | ||
+ | lda #226 | ||
+ | sta $07fa | ||
+ | lda #227 | ||
+ | sta $07fb | ||
+ | lda #228 | ||
+ | sta $07fc | ||
+ | rts | ||
+ | |||
+ | |||
+ | ; | ||
+ | ; | ||
+ | ;----- Paragraph @Sub-Route: Spritescrolling@ ----- | ||
+ | ; | ||
+ | ; | ||
+ | |||
+ | ;this is the main routine which is responsible for scrolling | ||
+ | ;a text through sprites | ||
+ | |||
+ | !zone | ||
+ | spritescroll dec .cnt+1 | ||
+ | .cnt lda # | ||
+ | beq .neuchar ; | ||
+ | jmp .softscroll ; | ||
+ | |||
+ | .neuchar ldy #0 ;read new char | ||
+ | lda ($50), | ||
+ | bne .undlos ; | ||
+ | |||
+ | ; | ||
+ | |||
+ | lda #<next | ||
+ | sta jumper+1 | ||
+ | lda #>next | ||
+ | sta jumper+2 | ||
+ | |||
+ | ; | ||
+ | |||
+ | lda #0 ;if yes, reset text-vector | ||
+ | sta $50 | ||
+ | lda #>text | ||
+ | sta $51 | ||
+ | lda #$20 | ||
+ | |||
+ | .undlos clc ; | ||
+ | rol ; | ||
+ | rol ; | ||
+ | rol | ||
+ | sta .loop2+1 | ||
+ | bcc .weiter | ||
+ | inc .loop2+2 | ||
+ | |||
+ | .weiter ldx #7 ;read 8 bytes (one char from the charset) | ||
+ | .loop2 lda $3000, | ||
+ | sta spritechar, | ||
+ | dex ; | ||
+ | bpl .loop2 | ||
+ | |||
+ | lda #0 ;reset adresses | ||
+ | sta .loop2+1 | ||
+ | lda #$30 | ||
+ | sta .loop2+2 | ||
+ | |||
+ | inc $50 ; | ||
+ | lda $50 | ||
+ | bne .nixneu | ||
+ | inc $51 | ||
+ | |||
+ | .nixneu lda #8 ;reset scrolltext-counter | ||
+ | sta .cnt+1 | ||
+ | |||
+ | .softscroll ldy #0 | ||
+ | ldx #0 | ||
+ | |||
+ | ; | ||
+ | ; move chars in sprites | ||
+ | ; to the left (soft-scrolling) | ||
+ | ; | ||
+ | |||
+ | .loop1 clc | ||
+ | .origin rol spritechar ;" | ||
+ | rol $3902, | ||
+ | rol $3901,x | ||
+ | rol $3900,x | ||
+ | rol $38c2, | ||
+ | rol $38c1,x | ||
+ | rol $38c0,x | ||
+ | rol $3882, | ||
+ | rol $3881,x | ||
+ | rol $3880,x | ||
+ | rol $3842, | ||
+ | rol $3841,x | ||
+ | rol $3840,x | ||
+ | rol $3802, | ||
+ | rol $3801,x | ||
+ | rol $3800,x | ||
+ | iny | ||
+ | inc .origin+1 ; | ||
+ | txa | ||
+ | clc:adc #3 | ||
+ | tax | ||
+ | cpy #8 | ||
+ | bne .loop1 | ||
+ | lda #< | ||
+ | sta .origin+1 | ||
+ | rts | ||
+ | |||
+ | ; | ||
+ | ; | ||
+ | ;----- Paragraph @Scrolltext@ ----- | ||
+ | ; | ||
+ | ; | ||
+ | |||
+ | *= text | ||
+ | |||
+ | !ct scr | ||
+ | !tx " | ||
+ | !tx " | ||
+ | !tx " | ||
+ | |||
+ | !tx " | ||
+ | !byte 0 | ||
+ | </ |
base/scrolltext_using_sprites.txt · Last modified: 2015-04-17 04:33 by 127.0.0.1