home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disk User Volume 4 #1
/
Commodore_Disk_User_Vol.4_1_1990_-.d64
/
smooth24.asm
< prev
next >
Wrap
Assembly Source File
|
2022-10-26
|
7KB
|
334 lines
;
; Smooth scroller, Copyright A.Millett
;
*=$9c00
;
vic = 53248 ; Vic chip
sprptrs = 33784
hibits = vic + 16 ; MSB of sprite posns
zptr = $fb
zptr2= $fd
zmsgptr = $fb
kbhit = 198 ; Set if char typed.
vdu = 32768 ; Loc of screen
colram = $d800 ; Loc of color ram
;
; Jump vector table..
dosmooth.
jmp main
resetsmooth.
jmp init
jspecialfx.
jmp specialfx
jdorotate.
jsr dorotatechar
jwait1scr.
jmp wait1scr
jfillvdu.
jmp fillvdu
jdo1dot.
jmp do1dot
;
.byte 0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
; Ok, flags start at $9c28
;
msgptr. ; If any scroll of edge, this is ptr to new spr
.word $9000
msgloc.
.word $9000
chrsetloc. ; Loc of user def char set
.word $8800
index.
.byte 0
rmarg. ; Reset pos for new spr
.byte 112
lmarg.
.byte 24
hspacing. ; Horizontal spacing of sprites.
.byte 46
scolor. ; Sprite color
.byte 1
widemode. ; Double width sprites
.byte 255
wiggleflag. ; Set for jumping scroll
.byte 0
speed. ; Scroll speed in x/50 sec/dot
.byte 0
sproffset. ; Start of sprites
.byte 127
hline. ; Screen line for scroll
.byte 224
moveby2flag. ; Move scroll by 2 if bit 7 set
.byte 0
fillchar. ; Char for screen fill
.byte 87
tickchar. ; Char used for 'tick' fx
.byte 209
rotchar. ; Char rotated for moving background
.byte 87
rotlen. ; No of pixels to rotate
.byte 7
fillcolor. ; Color for screen fill
.byte 0
mask.
.byte 1,2,4,8,16,32,64,128
wiggle. ; Vert wiggle factor
.byte 7,5,4,3,2,1,1,0,0,0,1,1,2,3,4,5
;
;
main.
mainloop.
jsr dorotatechar ; Rotate scrolling background
ldx speed ; First wait for a time & sync to screen
wloop.
jsr wait1scr
dex
bpl wloop
jsr do1dot ; Scroll message 1 dot..
bit moveby2flag ; 2 dot move ?
bpl no2move ; No..
jsr do1dot ; Scroll message 1 more dot..
no2move.
lda kbhit
beq mainloop ; No key hit, reloop..
rts ; Ok, done!
;
do1dot. ; Scroll 1 dot left,
ldx #$00 ; Index into sprites
ldy #$00
sty index
more.
lda vic,x
bne nohi ; No overflow..
lda mask,y ; Get hi bit
and hibits
bne nonew ; Set, so clear..
jsr newsprite ; Start a new sprite
clc
bcc nohi
nonew. ; Lo byte overflow, clr hi bit
lda mask,y
eor # $ff ; Calc mask for hi bit
and hibits
sta hibits
nohi. ; Ok, now set vert pos
dec vic,x ; Move spr left
ldy index
lda #0
bit wiggleflag ; Do we wiggle ?
bpl nowiggle
lda vic,x ; use hpos as index to wiggle
and # $0f
tay
lda wiggle,y
nowiggle.
clc ; Now add in norm vert line
adc hline
sta vic+1,x ; Store vert pos for sprite.
inc index ; Ok, next sprite..
ldy index
inx
inx
cpy # 8
bne more ; next sprite..
rts ; Ok, done!
;
newsprite. ; Start a new sprite
lda rmarg ; Start new sprite far right
sta vic,x
lda mask,y
ora hibits ; Set hi bit
sta hibits
nextmsg. ; Advance message pointer
inc msgptr
bne getmsg
inc msgptr+1
getmsg. ; Get char from msg string
lda msgptr ; Mov ptr to zero page
sta zmsgptr
lda msgptr+1
sta zmsgptr+1
ldy #0
lda (zmsgptr),y ; Get msg char
bne new2 ; Not null yet, so print..
lda msgloc ; End of message, so reset msg to start
sta msgptr
lda msgloc+1
sta msgptr+1
clc
bcc getmsg
new2.
bpl normlet ; No special effects
cmp #128 ; Toggle wiggle ?
bne new3
lda #$80
eor wiggleflag
sta wiggleflag
clc
bcc nextmsg ; Another msg char..
new3.
cmp #129 ; Toggle 2 dot speed?
bne new4
lda #$80
eor moveby2flag
sta moveby2flag
clc
bcc nextmsg ; Another msg char..
new4.
and #$1f
sta speed
clc
bcc nextmsg ; Another msg char..
normlet. ; Ok norm letter in acc, store in sprite ptr
ldy index
clc
adc sproffset
sta sprptrs,y
jsr specialfx ; Move line in ball chr
rts
;
specialfx. ; Move line in ball chr
tya
pha ; stash y reg
lda tickchar ; Character to tick
jsr setchrptr ; Set up (zptr) to char
ldy #3
lda (zptr),y
pha
iny
lda (zptr),y
dey
sta (zptr),y
pla
iny
sta (zptr),y
pla
tay
rts
;
dorotatechar. ; Rotate special char vertically for effect
tya
pha ; stash y reg
lda rotchar ; Character to rotate
jsr setchrptr ; Set up (zptr) to char
ldy rotlen ; No to rotate
lda (zptr),y ; Stash top one
pha
spec1.
dey ; Ripple bytes down..
lda (zptr),y
iny
sta (zptr),y
dey
bne spec1
pla
sta (zptr),y ; Reget top val and put at bottom
pla ; Reget y reg
tay
rts
;
setchrptr. ; Set up (zptr) to point to loc of char in Acc
ldy #0 ; Clr hi byte zptr
sty zptr+1
asl a ; Mult char by 8
rol zptr+1
asl a
rol zptr+1
asl a
rol zptr+1
clc ; Add in chr address to chrset location
adc chrsetloc
sta zptr
lda zptr+1
adc chrsetloc+1
sta zptr+1
rts
;
fillvdu. ; Fill vdu with (fillchar)
jsr setcolor ; Fill color ram
lda fillchar
ldy #0
fill1.
sta vdu,y
sta vdu+256,y
sta vdu+512,y
sta vdu+768,y
iny
bne fill1
rts
;
setcolor. ; Fill color ram with (fillcolor)
lda fillcolor
ldy #0
fill2.
sta colram,y
sta colram+256,y
sta colram+512,y
sta colram+768,y
iny
bne fill2
rts
;
wait1scr. ; Wait for screen to finish
lda vic+18 ; Current raster val
cmp #250
bcc wait1scr
wait2.
lda vic+18 ; Current raster val
cmp #250
bcs wait2
rts
;
init. ; Initialise sprite positions and switch them on
lda #0
sta hibits
sta wiggleflag ; No wiggle to start
sta moveby2flag ; Slow to start
lda msgloc ; Reset message pointer
sta msgptr
lda msgloc+1
sta msgptr+1
ldx #0
ldy #0
lda lmarg ; Xpos index lo
sta zptr
stx zptr+1 ; Xpos hi
init1.
lda hline
sta vic+1,x ; Set Y pos of sprite
lda zptr
sta vic,x ; Set sprite X pos lo byte
lda zptr+1 ; Any hi bit for sprite?
beq init2 ; Leave hi bit clr
lda mask,y ; Set sprite(y) hi bit
ora hibits
sta hibits
init2.
lda scolor ; Ok, Set color for sprite
sta vic+39,y
lda sproffset
clc
adc #1 ; all sprite start spc
sta sprptrs,y
lda zptr
clc
adc hspacing
sta zptr
bcc init3
inc zptr+1
init3.
inx
inx
iny
cpy #8
bne init1
lda widemode
sta vic+29
lda #255
sta vic+21 ; Switch on sprites
rts
;