home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
COMMS
/
ZMP-OV16.ARC
/
ZMO-BW05.Z80
< prev
next >
Wrap
Text File
|
1991-02-02
|
17KB
|
835 lines
;-----------------------------------------------------------------------------
;
; Sample Overlay for ZMP (Z-Modem Program)
;
; Name ZMO-BW05.Z80
;
; Dated Sep 14, 1988
;
; Written by -
; Ron Murray, c/o Z-Node 62, 061-9-450-0200, Perth, Western Australia.
;
; Modified to ZMP v1.2 standard rjm 15/9/88
; Modified to ZMP v1.3 standard rjm 11/10/88
; Modified to ZMP v1.4 standard rjm 20/11/88
; Modified to ZMP v1.5 standard rjm 25/3/89
;
; Customized for Bondwell 14 es 16/04/89
;
;-----------------------------------------------------------------------------
;
; This overlay is set up for a BONDWELL 12/14 using serial port A.
; The 'setport' routine has not been implemented.
;
; Uses: Z80SIO Uart
; 8253 Timer
; 6845 Crtc
;
; This file was assembled using the ZASM assembler and Ron Fowler's
; loader MLOAD. Both of these should be available from any CP/M
; bulletin board.
;
; To assemble:
; ZASM ZMO-BW05.AAZ HEX
; MLOAD ZMP.COM=ZMPX.COM,ZMO-BW05.HEX
;
; - es 16/4/89
;
;-----------------------------------------------------------------------------
;
;
; System-dependent code overlay for ZMODEM
;
;
;
; Insert your own code as necessary in this file. Code contained herein
; has been written in Z80 code for use with M80 or SLR. Assemble as follows:
;
; SLR ZMO-xx01/h
; MLOAD ZMP.COM=ZMODEM.COM,ZMO-xx01.HEX
; or
; M80 =ZMO-xx01.Z80
; RELHEX ZMO-xx01
; MLOAD ZMP.COM=ZMODEM.COM,ZMO-xx01.HEX
;
;
; (Don't use L80 without changing the source for assembly as a
; cseg file.)
;
;-----------------------------------------------------------------------------
;
;
; Notes on modifying this file:
;
; C requires that functions do not change either index register (IX or IY).
; If your overlay requires either of these to be changed, ensure they are
; restored to the original values on return.
; Since collecting parameters from C functions can be tricky, only change
; the parts marked 'Insert your own code here'. Do NOT modify the jump
; table at the start. Do NOT modify the entry/exit sections of each
; function. Do NOT pass 'GO'. Do NOT collect $200.
; Apart from defining modem functions, this file also defines terminal
; characteristics. Examples provided are for ADM-3A (with a few of my own
; additions). Modify to suit your own terminal. An inline print routine
; is provided for printing strings in the usual way: usage is
;
; call print
; db 'required string',0
;
;-----------------------------------------------------------------------------
;
;
; Don't forget to set your clock speed at the clkspd variable.
;
;
; If you find your overlay exceeds the maximum size (currently 0400h),
; you will have to contact me for another version. If too many people need
; to do it, we haven't allowed enough room.
;
; Ron Murray 15/8/88
;
;
;
;---------------------------------------------------------------------------
false equ 0
true equ not false
;------------------------------------------------------------------------------
; User-set variables:
clkspd equ 4 ; Processor clock speed in MHz
debug equ false ; to allow debugging of overlay with Z8E etc.
;Set the following two equates to the drive and user area which will contain
; ZMP's .OVR files, .CFG file, .FON file and .HLP file. Set both to zero
; (null) to locate them on the drive from which ZMP was invoked.
overdrive equ 'A' ; Drive to find overlay files on ('A'-'P')
overuser equ 0 ; User area to find files
;------------------------------------------------------------------------------
; NOT user-set variables
userdef equ 0145h ; origin of this overlay
; This address should not change with
; subsequent revisions.
mspeed equ 03ch ; location of current baud rate.
ovsize equ 0400h ; max size of this overlay
; .z80 ; use z80 code
; aseg ; absolute
if debug
org 100h ; so you can debug it with cebug, zsid, etc
else
org userdef
endif
esc equ 1bh
ctrlq equ 11h
cr equ 0dh
lf equ 0ah
bdos equ 5
; Bondwell 12/14 equates
porta equ true ; change to 'false' if using port B
if porta
mdata equ 40h ; SIO data register
mstat equ 41h ; SIO control register
else ; port B
mdata equ 42h
mstat equ 43h
endif
rda equ 0 ; SIO rx char available
tbe equ 2 ; SIO tx buffer empty
onhook equ 7fh
online equ 80h
error equ 70h
break equ 0f8h
reset equ 30h
timrctl equ 63h ; 8253 control register
if porta
timrdat equ 60h ; 8253 timer 0
mode equ 00110110b ; 8253 mode select
else ; port B
timrdat equ 61h
mode equ 01110110b
endif
crtc equ 10h ; 6845 control register
crtcdat equ 11h ; 6845 data register
scrnloc equ 0f800h ; memory mapped video
;
codebgn equ $
;Jump table for the overlay: do NOT change this
jump_tab:
jp scrnpr ; screen print
jp mrd ; modem read with timeout
jp mchin ; get a character from modem
jp mchout ; send a character to the modem
jp mordy ; test for tx buffer empty
jp mirdy ; test for character received
jp sndbrk ; send break
jp cursadd ; cursor addressing
jp cls ; clear screen
jp invon ; inverse video on
jp invoff ; inverse video off
jp hide ; hide cursor
jp show ; show cursor
jp savecu ; save cursor position
jp rescu ; restore cursor position
jp mint ; service modem interrupt
jp invec ; initialise interrupt vectors
jp dinvec ; de-initialise interrupt vectors
jp mdmerr ; test uart flags for error
jp dtron ; turn DTR on
jp dtroff ; turn DTR OFF
jp init ; initialise uart
jp wait ; wait seconds
jp mswait ; wait milliseconds
jp userin ; user-defined entry routine
jp userout ; user-defined exit routine
jp getvars ; get system variables
jp setport ; set port (0 or 1)
; Spare jumps for compatibility with future versions
jp spare ; spare for later use
jp spare ; spare for later use
jp spare ; spare for later use
jp spare ; spare for later use
jp spare ; spare for later use
jp spare ; spare for later use
;
; Main code starts here
;
;Screen print function
scrnpr:
; <== Insert your own code here
push bc
ld bc,2000 ; determine number of characters
ld hl,scrnloc ; to print
add hl,bc
inc bc
scrnp1:
dec bc
dec hl
ld a,(hl)
and 7fh
jp z,scrnp1
cp 20h
jp z,scrnp1
ld hl,scrnloc ; begin screen print
scrnp2:
ld a,(hl)
and 7fh
jp nz,scrnp3
ld a,20h ; if null, make it a space
scrnp3:
call lstout ; output character
inc hl
dec bc
ld a,b
or c
jp nz,scrnp2
ld a,cr ; crlf
call lstout
ld a,lf
call lstout
pop bc
ret
lstout: ; output char (a) to list device
push bc
push hl
ld e,a
ld c,5
call bdos
pop hl
pop bc
ret
; <== End of your own code
spare:
ret
; User-defined entry routine: leave empty if not needed
userin:
ret
; User-defined exit routine: leave empty if not needed
userout:
ret
;Get a character from the modem: return in HL
mchin:
push bc
; <== Insert your own code here
mchin2:
in a,(mstat) ; check for char waiting
bit rda,a
jr z,mchin2
in a,(mdata) ; read the char
; <== End of your own code
ld l,a ; put in HL
ld h,0
or a ; set/clear Z
pop bc
ret
;Send a character to the modem
mchout:
ld hl,2 ; get the character
add hl,sp
ld a,(hl)
; <== Insert your own code here
push bc
ld b,a ; save the character
mchout2:
in a,(mstat) ; check for uart ready
bit tbe,a
jr z,mchout2
ld a,b ; char in a
out (mdata),a ; send it
pop bc
; <== End of your own code
ret ; done
;Test for output ready: return TRUE (1) in HL if ok
mordy:
; <== Insert your own code here
ld hl,0
in a,(mstat)
bit tbe,a ; transmit buffer empty
jr z,mordy1
inc hl
mordy1:
; <== End of your own code
ld a,l ; set/clear Z
or a
ret
;Test for character at modem: return TRUE (1) in HL if so
mirdy:
; <== Insert your own code here
ld hl,0
in a,(mstat)
bit rda,a ; received data available
jr z,mirdy1
inc hl
mirdy1:
; <== End of your own code
ld a,l ; set/clear Z
or a
ret
;Send a break to the modem: leave empty if your system can't do it
sndbrk:
; <== Insert your own code here
ld a,5 ; SIO WR5
out (mstat),a
ld a,break ; 0f8h
out (mstat),a
ld hl,300 ; wait 300 mS
call waithlms
ld a,5 ; SIO WR5
out (mstat),a
ld a,online
out (mstat),a
ld a,3 ; SIO WR3
out (mstat),a
ld a,0e1h ; 0e1h
out (mstat),a
; <== End of your own code
ret
;Test UART flags for error: return TRUE (1) in HL if error.
mdmerr:
; <== Insert your own code here
ld hl,0
in a,(mstat)
and a,error
jr z,mdmer2
inc hl
mdmer2:
; <== End of your own code
ld a,l ; set/clear Z
or a
ret
;Turn DTR ON
dtron:
; <== Insert your own code here
ld a,5 ; SIO WR5
ld (mstat),a
ld a,(combyt) ; get the one we used last time
or a,online ; 80h - set bit 7 high
ld (combyt),a ; save it for next time
out (mstat),a ; go
; <== End of your own code
ret
;Turn DTR OFF
dtroff:
; <== Insert your own code here
ld a,5 ; SIO WR5
out (mstat),a
ld a,(combyt) ; get the one we used last time
and onhook ; 7fh - clear bit 7
ld (combyt),a ; save it for next time
out (mstat),a ; go
; <== End of your own code
ret
;Initialise the uart
init:
ld hl,2 ; get parameters
add hl,sp
ex de,hl
call getparm ; in HL
ld (brate),hl ; baud rate
call getparm
ld (parity),hl ; parity
call getparm
ld (data),hl ; data bits (BINARY 7 or 8)
call getparm
ld (stop),hl ; stop bits (BINARY 1 or 2)
; <== Insert your own code here
; The SIO is set up in four steps:
; 1) Reset
; 2) Reg 4 - clock, stop bits, parity
; 3) Reg 5 - dtr, Tx bits, Brk, TxEn, rts
; 4) Reg 3 - Rx bits, RxEn
push bc
ld a,0
out (mstat),a ; point to reg 0
ld a,18h ; reset
out (mstat),a ; *** step 1
ld a,4 ; point to wrt reg 4
out (mstat),a
ld e,44h ; assume x16, 1 stop, No parity
ld a,(stop) ; set stop bits
cp 2 ; set 2 if required
jr nz,setpar
set 3,e
setpar:
ld a,(parity) ; set parity bits
cp 'O'
jr nz,setpa2
set 0,e ; ODD
jr setpa3
setpa2: cp 'E'
jr nz,setpa3
set 0,e
set 1,e ; EVEN
setpa3: ld a,e
out (mstat),a ; *** step 2
ld a,5 ; point to wrt reg 5 - dtr, Tx bits, etc
out (mstat),a
ld e,0EAh ; assume dtr, TX 8 bits, TxEn, rts
ld a,(data)
cp 7
jr nz,setbi2
res 6,e ; 7 bits
setbi2: ld a,e
out (mstat),a ; *** step 3
ld a,3 ; point to wrt reg 3
out (mstat),a
ld e,0C1h ; assume 8 bits
ld a,(data)
cp 7
jr nz,setbi3
res 7,e ; 7 bits
setbi3:
ld a,e
out (mstat),a ; *** step 4
setbrate:
push ix ; save ix
ld ix,(brate) ; get baud rate value (0-10)
add ix,ix ; *2
ld de,brval
add ix,de
ld a,(ix) ; see if it's valid
or (ix+1) ; 0 if not
jr z,setbrx
ld a,mode ; select timer and mode
out (timrctl),a
ld a,(ix) ; lsb
out (timrdat),a
ld a,(ix+1) ; msb
out (timrdat),a
ld a,(brate) ; tell zmp it's valid
ld (mspeed),a
setbrx:
pop ix
pop bc
ret
combyt: db 0EAh ; save it here
; <== End of your own code
;--------------------------------------------------------------------------
stop: dw 1 ; stop bits
parity: dw 'N' ; parity
data: dw 8 ; data bits
brate: dw 5 ; baud rate
;--------------------------------------------------------------------------
;Values of brate for each baud rate
;
brval: ; 8253 values baud rate brate
dw 0417h ; 110 0
dw 0180h ; 300 1
dw 0100h ; 450 2
dw 00C0h ; 600 3
dw 00A2h ; 710 4
dw 0060h ; 1200 5
dw 0030h ; 2400 6
dw 0018h ; 4800 7
dw 000Ch ; 9600 8
dw 0006h ; 19200 9
dw 0003h ; 38400 10
dw 0002h ; 57600 11
dw 0 ; 76800 12
;
; Set the port. ZMP supplies either 0 or 1 as a parameter. You're on your
; own here -- your system is bound to be different from any other! You may
; implement a software switch on all the modem-dependent routines, or perhaps
; you can have one or two centralised routines for accessing the UARTs and
; modify the code from this routine to select one or the other. (Who said
; there was anything wrong with self-modifying code?). If you have only one
; UART port, or if you don't want to go through all the hassles, just have
; this routine returning with no changes made. Note that ZMP calls this
; routine with both values for the port on initialisation.
;
setport:
ld hl,2 ; get port number
add hl,sp
ex de,hl
call getparm ; in HL (values are 0 and 1)
; <== Insert your own code here
; <== End of your own code
ret
port: ds 1
;****************************************************************************
;Video terminal sequences: these are for Bondwell 12/14: Modify as you wish
;Cursor addressing:
cursadd:
ld hl,2 ; get parameters
add hl,sp
ex de,hl
call getparm ; in HL
ld (row),hl ; row
call getparm
ld (col),hl ; column
; <== Insert your own code here
; using values in row and col
cursadd1:
call print
db esc,'=',0 ; leadin
ld a,(row) ; row first
add a,' ' ; add offset
call cout
ld a,(col) ; same for column
add a,' '
call cout
; <== end of your own code
ret
row: ds 2 ; row
col: ds 2 ; column
;Clear screen:
cls:
call print
db esc,'*',0
ret
;Inverse video on:
invon:
call print
db esc,'I',0
ret
;Inverse video off:
invoff:
call print
db esc,'N',0
ret
;Turn off cursor:
hide:
ld a,10 ; 6845 R10
out (crtc),a
ld a,20h
out (crtcdat),a ; blank cursor
ret
;Turn on cursor:
show:
ld a,10 ; 6845 R10
out (crtc),a
ld a,40h
out (crtcdat),a ; restore cursor (slow blink)
ret
;Save cursor position:
savecu:
ld a,14 ; 6845 R14
out (crtc),a
in a,(crtcdat)
and 7
ld h,a
ld a,15 ; 6845 R15
out (crtc),a
in a,(crtcdat)
ld l,a
ld (curpos),hl
ret
;Restore cursor position:
rescu:
ld hl,(curpos)
ld de,1000h ; convert to row/col
resc1:
add hl,hl
ld a,e
adc a,e
ld e,a
sub 80
jp c,resc2
ld e,a
inc hl
resc2:
dec d
jp nz,resc1
ld (row),hl ; load xy positions
ld (col),de
call cursadd1 ; move cursor
ret
curpos:
ds 2 ; current cursor position
;****************************************************************************
;Service modem interrupt:
mint:
ret ; my system doesn't need this
;Initialise interrupt vectors:
invec:
ret ; ditto
;De-initialise interrupt vectors:
dinvec:
ret ; ditto
;****************** End of user-defined code ********************************
; Do not change anything below here.
;Modem character test for 100 ms
mrd:
push bc ; save bc
ld bc,100 ; set limit
mrd1:
call mirdy ; char at modem?
jr nz,mrd2 ; yes, exit
ld hl,1 ; else wait 1ms
call waithlms
dec bc ; loop till done
ld a,b
or c
jr nz,mrd1
ld hl,0 ; none there, result=0
xor a
mrd2:
pop bc
ret
; Inline print routine: destroys A and HL
print:
ex (sp),hl ; get address of string
ploop:
ld a,(hl) ; get next
inc hl ; bump pointer
or a ; done if zero
jr z,pdone
call cout ; else print
jr ploop ; and loop
pdone:
ex (sp),hl ; restore return address
ret ; and quit
;
;Output a character in A to the console
;
cout:
push bc ; save regs
push de
push hl
ld e,a ; character to E
ld c,2
call bdos ; print it
pop hl
pop de
pop bc
ret
;Wait(seconds)
wait:
ld hl,2
add hl,sp
ex de,hl ; get delay size
call getparm
; fall thru to..
;Wait seconds in HL
waithls:
push bc ; save bc
push de ; de
push ix ; and ix
ld ix,0 ; then point ix to 0
; so we don't upset memory-mapped i/o
;Calculate values for loop constants. Need to have two loops to avoid
; 16-bit overflow with clock speeds above 9 MHz.
outerval equ (clkspd / 10) + 1
innerval equ (6667 / outerval) * clkspd
wait10:
ld b,outerval
wait11:
ld de,innerval
wait12:
bit 0,(ix) ; time-wasters
bit 0,(ix)
bit 0,(ix) ; 20 T-states each
bit 0,(ix)
bit 0,(ix)
bit 0,(ix)
dec de
ld a,e
ld a,d
or e
jr nz,wait12 ; 150 T-states per inner loop
djnz wait11 ; decrement outer loop
dec hl ; ok, decrement count in hl
ld a,h
or l
jr nz,wait10
pop ix ; done -- restore ix
pop de ; de
pop bc ; and bc
ret
;Wait milliseconds
mswait:
ld hl,2
add hl,sp
ex de,hl ; get delay size
call getparm
; fall thru to..
;Wait milliseconds in HL
waithlms:
push de
w1ms0:
ld de,39 * clkspd
w1ms1:
dec de
ld a,d
or e
jr nz,w1ms1
dec hl
ld a,h
or l
jr nz,w1ms0
pop de
ret
;Get next parameter from (de) into hl
getparm:
ex de,hl ; get address into hl
ld e,(hl) ; get lo
inc hl
ld d,(hl) ; then hi
inc hl ; bump for next
ex de,hl ; result in hl, address still in de
ret
;Get address of user-defined variables
getvars:
ld hl,uservars
ret
uservars:
dw overdrive ; .OVR etc. drive/user
dw overuser
if ($ - codebgn) gt ovsize
toobig: jp errval ; Overlay too large!
endif
end