;;
;; This file is part of "VirtuaMUnstaz Demo Distribution".
;;
;; This is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; "VirtuaMUnstaz Demo Distribution" is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;;
;; scroll.s
;;
;; version 0.5
;;
;; by
;;
;; Need aslc86k v1.3+ to assemble this.
;;
.include "sfr.i"
index = $32
time0 = $37
time1 = $38
ixbnk = $33
ptrbackup = $36
startptr = $34
count = $35
scrollbuffer = $3b
; - $41
;; Reset and interrupt vectors
.org 0
jmpf start
.org $3
jmp nop_irq
.org $b
jmp nop_irq
.org $13
jmp nop_irq
.org $1b
jmp t1int
.org $23
jmp nop_irq
.org $2b
jmp nop_irq
.org $33
jmp nop_irq
.org $3b
jmp nop_irq
.org $43
jmp nop_irq
.org $4b
clr1 p3int,0
clr1 p3int,1
nop_irq:
reti
.org $130
t1int:
push ie
clr1 ie,7
not1 ext,0
jmpf t1int
pop ie
reti
.org $1f0
goodbye:
not1 ext,0
jmpf goodbye
.include "header.i"
;; Main program
.org $680
start:
mov #$a1,ocr
mov #$09,mcr
mov #$80,vccr
clr1 p3int,0
clr1 p1,7
mov #$ff,p3
call clrscr
call loadlogo
waitstart:
call getkeys
and #$30
bnz waitstart
mov #1,xbnk
mov #$80+16+6,2
mov #$80+16*7+5,3
call drawline_double
mov #0,index
mov #0,c
mov #font,trh
mov #scrollbuffer,1
call set_scrollbuffer ; offset to char is in c
charloop:
mov #0,c ; loop 8 times over (scroll one bit left)
endless:
mov #scrollbuffer,1
mov #$80+5+16*3,2 ; start drawinf position
mov #0,b ; loop over 8 lines in screen
line:
ld @R1 ; load data from scrollbuffer in acc
call scrollline
st @R1
inc 1 ; scrollbuffer next byte
ld 2 ; next screen line
add #6
st 2
ld @R1
call scrollline
st @R1
inc 1
ld 2
add #10
st 2
inc b
ld b
bne #4, line
call waitloop
inc c
ld c
bne #8, endless ; after we scrolled 8 times 1 bit left
; we have to insert a new char in
; scrollbuffer
call getkeys
; get next char from scrolltext
; we are using a pointer to the scrolltext in index
; suprisingly this works although the pointer range
; exceeds 256
mov #text,trh
ld index
add #1
st index
ldc
bnz skip ; zero byte ?
; set pointers back to beginning of
; scrolltext
mov #text,trh
mov #0,acc
st index
ldc
skip:
sub #1
add acc ; ACC = ACC * 8 (*8=*2*2*2)
add acc
add acc
st c ; char offset is now in c
mov #font,trh
mov #scrollbuffer,1
call set_scrollbuffer ; offset to char is in c
br charloop
getkeys:
bp p7,0,quit
ld p3
bn acc,6,quit
bn acc,7,sleep
ret
quit:
jmp goodbye
sleep:
bn p3,7,sleep ; Wait for SLEEP to be depressed
mov #0,vccr ; Blank LCD
sleepmore:
set1 pcon,0 ; Enter HALT mode
bp p7,0,quit ; Docked?
bp p3,7,sleepmore ; No SLEEP press yet
mov #$80,vccr ; Reenable LCD
waitsleepup:
bn p3,7,waitsleepup
br getkeys
waitloop:
push c
push acc
mov #$50,c
.wloop:
dec c
ld c
bnz .wloop
pop acc
pop c
ret
waitloop2:
; not used
; can be used to wait longer than waitloop
mov #$1,time1
.extwloop:
mov #$FF,time0
.intwloop:
dbnz time0,.intwloop
dbnz time1,.extwloop
ret
drawline_double:
; draws two lines from the left to the right
; linestart 1: R2
; linestart 2: R3
push 2
push 3
push c
push b
mov #0,b
outerloop:
mov #0,c
innerloop:
ld @R2
set1 PSW,7
rorc
st @R2
ld @R3
set1 PSW,7
rolc
st @R3
call waitloop
inc c
ld c
bne #8,innerloop
inc 2
dec 3
inc b
ld b
bne #6,outerloop
pop b
pop c
pop 3
pop 2
ret
scrollline:
; scroll 6 bytes at once without loop
; because of performance considerations
clr1 ocr,5
push 2
rolc ; scroll input line from scrollbuffer one bit
push acc ; to the left and store it then
; (so it's already complete for next line)
ld @R2
rolc
st @R2
dec 2
ld @R2
rolc
st @R2
dec 2
ld @R2
rolc
st @R2
dec 2
ld @R2
rolc
st @R2
dec 2
ld @R2
rolc
st @R2
dec 2
ld @R2
rolc
st @R2
pop acc
pop 2
set1 ocr,5
ret
set_scrollbuffer:
; will copy a new char to the scrollbuffer
; from the font pixel data buffer
; 1 scrollbuffer
; c offset
; trh, trl pointer to chardata
push 1
push b
push c
xor acc
st b
bufferloop:
ld c
ldc
st @R1
inc 1
inc c
inc b
ld b
bne #8,bufferloop
pop c
pop b
pop 1
ret
clrscr:
; clears the LCD screen
; from marcus
clr1 ocr,5
push acc
push xbnk
push 2
mov #0,xbnk
.cbank: mov #$80,2
.cloop: mov #$00,@R2
inc 2
ld 2
and #$f
bne #$c,.cskip
ld 2
add #4
st 2
.cskip: ld 2
bnz .cloop
bp xbnk,0,.cexit
mov #1,xbnk
br .cbank
.cexit: pop 2
pop xbnk
pop acc
set1 ocr,5
ret
loadlogo:
; copies data to LCD screen
clr1 ocr,5
push acc
push xbnk
push c
push b
push 2
mov #>logo,trh
mov #