Post by VDC 8x2 on Jun 21, 2014 18:23:06 GMT
A scrolling text Demo I whipped up.
The text is moved via the VDC copy command. A nice side effect is when the copy is done, the vdc address regs are right were we need them. so just put in our next letter.
The code polls the vblank bit to make sure the scroll only happens during a vblank.
Any ideas or suguestions?
VDCADR = $D600
VDCDAT = $D601
txtptr = $a9
smooth = $ab
defm WaitVDC
bit $d600
bpl *-3
endm
*=$1300
start lda #$07
sta smooth
lda #$18
sta vdcadr
lda vdcdat
ora #$80 ;set copy bit
sta vdcdat
jsr zp0
mainloop lda #$20 ;bit 5 we checking
bit vdcadr ;waiting for vblank
beq *-3
sei ;don't want to be interupted
jsr scroll
lda #$19
sta vdcadr
lda vdcdat
and #%11110000
ora smooth
sta vdcdat ;scroll left
cli ;done so release interupts
lda #$20
bit vdcadr
bne *-3 ;waiting for start of frame
jmp mainloop
scroll lda smooth
sec
sbc #$01 ;$01 to $07 for scroll speed. $07 is the fastest
bcc movetext
sta smooth
rts
movetext lda #$07
sta smooth
ldx #$20
stx vdcadr
lda #$00 ;high byte source
sta vdcdat
inx
stx vdcadr
lda #$01 ;low byte source
sta vdcdat
ldx #$12
stx vdcadr
WaitVDC ;wait for ready bit
lda #$00 ;high byte destination
sta vdcdat
inx
stx vdcadr
lda #$00 ;low byte destination
sta vdcdat ;target adress
lda #$1e
sta vdcadr
lda #$4f ;copy 79 bytes
sta vdcdat
ldy #$00 ;we can continue with non VDC code. rock on cpu! lol
lda (txtptr),y
cmp #$ff
beq zp0
inc txtptr
bne @skip
inc txtptr+1
@skip ldx #$1f
stx vdcadr
WaitVDC ;wait for vdc to be ready
sta vdcdat ;put in next letter
rts
zp0 lda #<scrolltxt
sta txtptr
lda #>scrolltxt
sta txtptr+1
WaitVDC
rts
scrolltxt text 'this is a test of the scrolling demo.....'
byte $ff
The text is moved via the VDC copy command. A nice side effect is when the copy is done, the vdc address regs are right were we need them. so just put in our next letter.
The code polls the vblank bit to make sure the scroll only happens during a vblank.
Any ideas or suguestions?