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
/
CPM
/
22RSX
/
BYERSX.ARK
/
BRTV-1.BYE
< prev
next >
Wrap
Text File
|
1985-12-06
|
10KB
|
376 lines
; BRTV-1.BYE - BYERSX insert for TeleVideo TS-802 - 85/11/14
;
; Rename this file RSXIO.INC for automatic inclusion in BYERSX.
;
; SIO I/O and CTC baudrate generator
;
; Note: This is an insert, not an overlay.
;
; = = = = = = = = = = = = = = = = =
;
; 85/12/04 Created from BRKP-1.BYE - C.B. Falconer
;
; = = = = = = = = = = = = = = = = =
;
;
; Modem port equates
datport equ 20H; Modem data port
stport equ datport+2; Modem status port
bport equ 08H; Modem baud rate port
;
; Status port masks
drdy equ 1; Data available
ordy equ 4; Transmit buffer empty
dcd equ 8; Data carrier detect
;
; First Byte of CTC Command for baud rate changes
bdcmd equ 47H
;
; Baudrate table
;
bd110 equ 0ffh; not available
bd300 equ 80H; 300 baud
bd450 equ 0ffh; not available
bd600 equ 40H; 600 baud
bd710 equ 0ffh; not available
bd1200 equ 20H; 1200 bps
bd2400 equ 10H; 2400 bps
bd4800 equ 08h; 4800 bps
bd9600 equ 04h; 9600 bps
bd19200 equ 02h; 19200 bps
;
; ZSIO WRn bits and fields (selected)
; WR0: (low 3 bits are next reg. id)
noop equ 0
rsints equ 10h; reset external/status interrupts
chreset equ 18h; channel reset
;
; WR1:
rxintdis equ 0; (on mask 38h). Disable rcv. interrupts
;
; WR2: (interrupt vector, channel B only)
;
; WR3:
rxmask equ 0c0h; mask for rx wd. lgh. commands
rx7bit equ 040h; 7 bits per char
rx8bit equ 0c0h; 8 bits per char
;
rxenbl equ 1; rx enable
;
; WR4:
; mask 0c0h. internal clock divider
clkx16 equ 040h; divide by 16
; mask 00ch. stop bits
stops1 equ 4; 1 stop bit
stops15 equ 8; 1.5 stop bits
stops2 equ 0ch; 2 stop bits
stopmsk equ 00ch; mask stop bits field
; mask 003h. Parity, values 0,1,3 useful only
pareven equ 2
parodd equ 0; bit 1 field
parenbl equ 1
paroff equ 0; bit 0 field
parmask equ 3; parity field mask
;
; WR5:
dtr equ 080h; data terminal ready output
; mask 060h. Transmit bits/char
tx7bit equ 020h
tx8bit equ 060h
txmask equ 060h; mask for transmit field
; individual bits
sndbrk equ 10h; send a break
txenbl equ 8; transmit enable
rts equ 2; request to send output
;
; -----------------------------------------------
;
; Disconnect and initialize the ZSIO. Connect any interrupt
; systems here. MDQUIT is the inverse procedure
; a,f
mdinit: call mdgo; reinit port, synchronize
call mdstop; drop dtr line, hangup
push d
lxi d,2000
call dodelay; 2000 millisec delay
pop d
; " "
; enable the modem. Set stop bits, parity, word length
; Zsio/Televideo/Kaypro II/4/20/2x initialization
; a,f
mdgo: push h
push b
lxi h,tbl1; init the SIO chip
mov b,m; count of items
inx h
mov c,m; port id
inx h
db 0edh,0b3h; outir/otir ** Z80 code ** <<
pop b
pop h
ori 0ffh; signal success
ret
;
; This table sets the default configuration.
; It is modified by the SETBAUD command (wd lgh, stops, parity)
tbl1: db tbl1lgh,stport
db noop; force ctl reg access
db chreset; throw out of mode
db 1,rxintdis; disable all interrupts
wr3: db 3,rx8bit + rxenbl; reg 3, enable receive
wr4: db 4,clkx16+stops1; reg 4, set ascii params
wr5: db 5,dtr+tx8bit+txenbl+rts; reg 5, enable send,dtr,rts
tbl1lgh equ $-tbl1-2
;
; Reinitialize the modem and hang up the phone by dropping DTR and
; leaving it inactive. This can inactivate interrupt systems.
; Inverse of mdinit. Return 0ffh for success, 0 failure, w/flags
; a,f
mdquit:
; " "
; Hang up by dropping DTR and leaving it inactive.
; Return 0ffh for success, 0 for failure, with flags.
; Inverse of mdgo.
; a,f
mdstop: mvi a,5; Setup to write register 5
out stport
lda wr5+1; get present configuration
ani (NOT dtr) AND (NOT rts)
out stport
ori 0ffh; Success
ret
;
; See if we still have a carrier
; if not, return with the zero flag set
; a,f
mdcarck:
mvi a,rsints; Reset status
out stport
in stport; Get status
ani dcd; Check for carrier detect
rz
ori 0ffh
ret
;
; Input a character from the modem port. No check for ready
; a,f
mdinp: in datport; Get character
ret
;
; Check the status to see if a character is available. If not, return
; with the zero flag set. If yes, use 0FFH to clear the flag.
; a,f
mdinst: in stport
ani drdy; Check receive ready bit
rz; not ready
ori 0ffh; ready, set flags
ret
;
; Send a character to the modem. No check for ready
; f (allowed)
mdoutp: out datport; Send it
ret
;
; See if the output is ready for another character
; a,f
mdoutst:
in stport
ani ordy; Check transmit ready bit
rz; not ready
ori 0ffh; ready, set flags
ret
;
; Send a break (a) millisec long. Return nz and 0ffh.
; Don't drop DTR. We want to keep the connection up.
; If not capable, return 0 and z flag
; a,f
sendbk: push d
push psw
mvi a,5
out stport
lda wr5+1; get present configuration
ori sndbrk
out stport
pop d; orig (a) to d
mov e,d
mvi d,0
call dodelay
pop d; restore entry
jmp mdgo; end break and signal success
;
; Generalized baud setting per (a).
; Input 0 for no action
; 0 and zero flag if good, else 0ffh and nz flag.
; a,f
setbaud:
push psw
call setparity; uses hi order bits
pop psw
ani 0fh; baud field
rz; 0, ignore
cpi 11
jnc badbd; invalid request
push h
lxi h,bdtbl-1; for 1 based value
add l
mov l,a
adc h
sub l
mov h,a
mov a,m
pop h
inr a
jz badbd; baud rate not available
dcr a
push psw
mvi a,bdcmd
out bport; Send 1st byte of command
pop psw
out bport; Send the byte
xra a; Say rate is OK
ret
badbd: ori 0ffh; with error signal
ret
;
; Table of bit patterns for baud rates. Not visible externally
bdtbl: db bd110, bd300, bd450, bd600, bd710
db bd1200, bd2400, bd4800, bd9600, bd19200
;
; set parity on bit weights 20,10h of (a).
; values: 10h = no parity, 20h=odd, 30h = even parity
; set stop bits on bit weights 80h,40h
; values: 40h = 1 stop, 80h = 1.5 stops, 0c0h = 2 stops
; zero fields for no change.
; a,f
setparity:
push b
push d
push h
mov e,a; save configuration
ani 030h
jz sp2; no parity changes
mvi d,paroff
lxi b,256*tx8bit + rx8bit; 8 bits for no parity
cpi 20h
jc sp1; parity is turned off
mvi d,pareven + parenbl
lxi b,256*tx7bit + rx7bit; 7 bits for parity
cpi 30h
jz sp1; even parity
mvi d,parodd + parenbl
sp1: lxi h,wr3+1; b holds new txbits, c new rxbits,
mov a,m; d new parity bits
ani NOT rxmask
ora c
mov m,a; set receive wd length
lxi h,wr5+1
mov a,m
ani NOT txmask
ora b
mov m,a; set transmit wd length
lxi h,wr4+1
mov a,m
ani NOT parmask
ora d
mov m,a; set parity
sp2: mov a,e
ani 0c0h
jz sp4; no stop bit changes
mvi b,stops1
cpi 010h
jz sp3; 1 stop bit
mvi b,stops15
cpi 020h
jz sp3; 1.5 stop bits
mvi b,stops2; else 2 stop bits
sp3: lxi h,wr4+1; b holds new stop configuration
mov a,m
ani NOT stopmsk
ora b
mov m,a; set stop bits
sp4: pop h
pop d
pop b
jmp mdgo; make the physical changes
;
; For non-intelligent modems. Go off hook and connect.
; Return 0ffh for success, else 0 (with flags)
; a,f
mdansw:
xra a; not implemented here
ret
;
; For non intelligent modems. Is the phone ringing
; 0 and z flag if not, 0ffh and nz flag if ringing
mdring: xra a; not ringing
ret
;
; For disk control, the following indicates that the application
; will not require disk access in the immediate future. If possible
; drive motors should be stopped. No harm if unable to perform
; a,f
dskstp: ret
;
; For disk control, the following indicates that the application
; will require disk access in the immediate future. If possible
; drive motors should be started. No harm if unable to perform
; a,f
dskrun: ret
;
; ----------------------- Timer interface --------------------------
;
; ---- CUSTOMIZE TO YOUR INSTALLATION ----
;
; These two routines are called with either
; de = 0ffffh for a query (return current value in hl) )
; de = other to set the appropriate value, and return in (hl)
; The returned value should be 0ffffh if no timer system installed.
;
; The date is kept in the following format (note 0ffffh is invalid)
; MSbit yyyyyyy mmmm ddddd LSbit
; with y field (0..127) the offset from 1980 (dates to 2107)
; m field (1..12) the numerical month (Jan to Dec)
; d field (1..31) the day of month
; (Identical to MSDOS format)
; a,f,h,l
sgdate: lxi h,0ffffh; Not implemented
ret
;
; The time is kept in the following format (note 0ffffh is invalid)
; MSbit hhhhh mmmmmm sssss LS bit
; with h field (0..23) hour of day (0 is midnight)
; m field (0..59) minute of hour
; s field (0..29) seconds DIV 2 (resolution 2 seconds)
; (Identical to MSDOS format)
; a,f,h,l
sgtime: lxi h,0ffffh; Not implemented
ret
;
; This is used only where the host system has no real-time clock.
; This allows simulation of that clock, with lousy accuracy.
; Adds 1 minute to the internally stored time value. If a clock
; system exists this should simply return.
; a,f,h,l (allowed)
add1min:
ret
;
; ------------ I/O Dependant Function Key actions -------------
;
; The following are called when the ATTN char is followed by one
; of the digits '0' thru '9'. It is suggested that the digit '0'
; be reserved for performing screen dumps. A simple "ret"
; eliminates any key from the function repetoire.
; a,f,h,l (allowed)
f0k:
f1k:
f2k:
f3k:
f4k:
f5k:
f6k:
f7k:
f8k:
f9k: ret; eliminate all these
; end
; ------------------------------------------------
╙o