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
/
MBUG
/
MBUG184.ARC
/
ROS34BEE.LBR
/
ROSBEE.IZC
/
ROSBEE.INC
Wrap
Text File
|
1979-12-31
|
14KB
|
406 lines
{ ROSBEE.INC - Routines for Microbee Australia }
{ Includes routines from ROS.MCH ROS.MDM & ROS.CLK }
{ Microbee Version 2.16r for ROS 3.4 }
{ Use designed for manual BEEMODEM }
{ See ROSBEECH.INC for installation instructions }
{ ROSMCH.INC - Remote Operating System Machine Dependent Routines }
{** Remote channel routines **}
(* ================================================================= *)
(* MODEM - Routines and Global variables for Microbee (Australia) *)
(* Set up for TURBO based on MXOBEEnn code. *)
(* From here to Interrupt Handler is common to Ros and QK-Kermit *)
(* Author - Robert Munro *)
(* ================================================================= *)
const
(* Modem Registers - Port assignment *)
ModemData = $02 ; (* Port B - Data Port *)
ModemControl = $03 ; (* Port B - Control Port *)
(* Port B Data Port bit assignments *)
DTR = $04 ; (* RS232 Data Transmit Ready *)
CTS = $08 ; (* RS232 Clear to Send *)
RSin = $10 ; (* RS232 input char bit *)
RSout = $20 ; (* RS232 output char bit *)
(* Microbee serial I/O routines - Data areas used in Inline code.*)
(* Can only use 6 char size names ex .REL file *)
xflag : boolean = false ; (* indicates if automatic XOFF sent *)
sendfl : byte = 0 ; (* NZ while sending data *)
ndata : byte = 8 ; (* 8 data bits *)
npdata : byte = 8 ; (* ndata + parity bit (if req) *)
stopbi : byte = 1 ; (* 1 stop bit *)
bparit : byte = 1 ; (* 1=none, 2=odd, else even *)
baud : byte = $40 ; (* 300 baud receive *)
bauds : byte = $40 ; (* 300 baud send *)
rs_rpt : integer = 0 ; (* read pointer into buffer *)
rs_wpt : integer = 0 ; (* write " " " *)
DefaultBaudRate = 300 ;
MaxBuffsize = $800 ; (* Do not alter - This size used in Inline code *)
CloseSize = $100 ; (* When buffer has < CloseSize free then Xoff sent *)
Gversion : string[23] = ' Microbee 2.16r ' ;
VDate : string[18] = '25th April 1987 ' ;
type
ParityType = (MarkP, NoneP, OddP, EvenP) ; (* 0 1 2 or 3 put in bparit *)
var
OldVCB : integer ;
BaudSend,
BaudReceive : integer ;
Parity : ParityType ;
{ rs_buf : array [0..$800] of byte ; (* data buffer *)
RWM because of interrupt difficulties with memory bank switching
rs_buf had to be made a constant to force it into the lower 32k.
It was thus removed to a separate file rather than clutter up this one.}
procedure ch_out(char: byte) ; { Ros }
{ Procedure SendChar(char : byte) ; } { Kermit }
(* -------------------------------------------------------- *)
(* Send a character thru the modem port. *)
(* It waits for the previous character to be sent before *)
(* sending the current character. *)
(* -------------------------------------------------------- *)
(* Do not put additional code between SendChar (Kermit) or chout (Ros) *)
(* and inthan as there are machine code jumps across the boundaries. *)
(* And remember to delete the last C9 in SendChar (Kermit) or chout (Ros) *)
(* of inline code else there will be incorrect distance between these *)
(* two procedures. *)
Begin (* odata from MXOBEE16 is where SendChar or ch_out begin *)
inline ( $D3/ $09/ $F5/ $C5/ $D9/ $C5/ $E5/ $D9/
$D5/ $E5/ $21/ ndata/ $46/ $58/ $2E/ $00/
$0F/ $CB/ $15/ $10/ $FB/ $3A/ bparit/ $3D/
$28/ $08/ $AD/ $EA/ *+3/ $37/ $ED/ $6A/
$1C/ $3E/ $0D/ $93/ $47/ $29/ $23/ $10/
$FC/ $3A/ stopbi/ $83/ $3C/ $5F/ $48/ $3A/
bauds/ $57/ $47/ $3E/ $04/ $32/ sendfl/ $D3/
$02/ $C3/ *+65/ $D9/ $3E/ $B7/ $10/ $64/
$D3/ $03/ $DB/ $02/ $E6/ $10/ $7C/ $20/
$03/ $CB/ $85/ $B5/ $2A/ rs_rpt/ $ED/ $4B/
rs_wpt/ $03/ $CB/ $98/ $ED/ $42/ $28/ $4E/
$ED/ $43/ rs_wpt/ $21/ rs_buf/ $09/ $77/ $3E/
$EF/ $D3/ $03/ $D9/ $0D/ $CD/ *+179/ $10/
$4B/ $1D/ $28/ $3B/ $29/ $7C/ $E6/ $20/
$F6/ $04/ $D3/ $02/ $42/ $79/ $3D/ $CA/
*-66/ $3C/ $28/ $14/ $D9/ $05/ $20/ $1F/
$DB/ $02/ $E6/ $10/ $7C/ $20/ $01/ $B5/
$67/ $CB/ $05/ $41/ $D9/ $0D/ $18/ $D6/
$3A/ sendfl/ $B7/ $CA/ *+40/ $FB/ $18/ $00/
$18/ $00/ $18/ $F0/ $7E/ $D9/ $18/ $F6/
$3E/ $FF/ $18/ $B9/ $E1/ $D1/ $AF/ $32/
sendfl/ $C3/ *-57/ $B7/ $D8/ $18/ $C1/ $3A/
sendfl/ $B7/ $20/ $F6/ $04/ $B1/ $20/ $08/
$D9/ $E1/ $C1/ $D9/ $C1/ $F1/ $FB/ $C9/
$C3/ *-81)
end;
procedure inthan;
begin
inline ( $F5/ $D3/ $09/ $DB/ $02/ $E6/ $10/ $20/
$04/ $F1/ $FB/ $ED/ $4D/ $3A/ sendfl/ $B7/
$28/ $1B/ $3A/ npdata/ $4F/ $D9/ $21/ $01/
$00/ $3A/ baud/ $4F/ $1F/ $81/ $47/ $28/
$03/ $D9/ $F1/ $C9/ $06/ $80/ $68/ $D9/
$0C/ $F1/ $C9/ $C5/ $47/ $3A/ npdata/ $4F/
$D9/ $C5/ $E5/ $21/ $01/ $00/ $3A/ baud/
$4F/ $1F/ $81/ $47/ $D9/ $C2/ *-152/ $D9/
$06/ $80/ $68/ $D9/ $0C/ $C3/ *-161/ $ED/
$4D)
end;
procedure setvcb;
begin
inline ( $21/ rs_buf/ $24/ $24/ $2E/ $00/ $4C/ $54/
$5D/ $1B/ $06/ $80/ $3E/ $C9/ $12/ $73/
$23/ $72/ $23/ $1B/ $3E/ $3C/ $10/ $F6/
$3E/ $03/ $D3/ $01/ $59/ $DB/ $02/ $E6/
$BF/ $D3/ $02/ $21/ *+56/ $01/ $03/ $04/
$F3/ $ED/ $B3/ $ED/ $5E/ $F6/ $40/ $D3/
$02/ $ED/ $57/ $57/ $7B/ $ED/ $47/ $AF/
$CD/ *+32/ $FB/ $76/ $F3/ $87/ $5F/ $7A/
$ED/ $47/ $ED/ $A3/ $ED/ $A3/ $3E/ $83/
$D3/ $01/ $ED/ $4B/ oldvcb/ $EB/ $5E/ $71/
$23/ $56/ $70/ $ED/ $53/ oldvcb/ $ED/ $4D/
$FF/ $9B/ $B7/ $BF/ $B7/ $EF)
end;
(* ------------------------------------------------------------------ *)
(* IntHandler - Interrupt Handler. (ABOVE HERE) *)
(* SetVCB - Determines loc of interrupt vector, saves and resets it *)
(* Uses OldVCB for new vector and saves the old one there. *)
(* ------------------------------------------------------------------ *)
(* ------------------------------------------------------------------ *)
(* rec_reti - to enable or re-enable interrupts. *)
(* ------------------------------------------------------------------ *)
Procedure rec_reti;
begin
port[ModemControl] := $B7; (* Set port to allow interrupts *)
port[ModemControl] := $EF;
Inline($FB/ (* ei enable interrupt *)
$ED/$4D) ; (* reti *)
end;
(* ------------------------------------------------------------------ *)
(* End of Modem I/O code *)
(* ------------------------------------------------------------------ *)
procedure ch_set ;
{ Set the bps rate, baud, parity & no. of stop bits }
function BaudTranslate(var BaudTemp : integer ) : byte;
{ Get the baud rate factor }
Begin
Case BaudTemp of
75 : BaudTranslate := 0;
300 : BaudTranslate := 64;
600 : BaudTranslate := 32;
1200 : BaudTranslate := 16;
2400 : BaudTranslate := 8;
4800 : BaudTranslate := 4;
9600 : BaudTranslate := 2;
19200 : BaudTranslate := 1;
End
End ;
Begin { ch_set }
{writeln('ch_set');}
BaudReceive := rate;
case rate of
75: begin (* 75/1200 Baud - They Send/We Send *)
baud := BaudTranslate(rate);
rate := 1200;
bauds := BaudTranslate(rate);
end;
80: begin (* 1200/75 Baud *)
rate := 1200;
baud := BaudTranslate(rate);
rate := 75;
bauds := BaudTranslate(rate);
end;
else begin
baud := BaudTranslate(rate);
bauds := baud;
end;
end;
bparit := Ord(Parity);
npdata := ndata; { No of data + parity bits }
if bparit > 1 then npdata := ndata + 1; { +1 if parity is odd/even }
end ; { ch_set }
procedure ch_init;
{ Initialize the remote channel }
begin
{writeln('ch_init');}
end;
procedure ch_on;
{ Turn on remote channel (usually by enabling DTR) }
begin
{writeln('ch_on');}
rec_reti; { enable interrupts }
port[ModemData] := DTR + RSout;
end;
procedure ch_off;
{ Turn off remote channel (usually by disabling DTR) }
begin
{writeln('ch_off');}
port[ModemControl] := $87 ; (* Do NOT allow interrupts *)
end;
function ch_carck: boolean;
{ Check to see if carrier is present }
begin
ch_carck := true;
end;
function ch_inprdy: boolean;
{ Check for ready to input from port }
const
Xon = $11;
Xoff = $13 ;
var
temp : integer ;
begin
if rs_rpt = rs_wpt then ch_inprdy := false
else ch_inprdy := true;
{ test for buffer almost full and send Xon }
{ when empty send Xoff }
temp := rs_wpt - rs_rpt;
if xflag then
begin
if temp = 0 then
begin (* Buffer now empty send Xon *)
rec_reti;
ch_out(Xon);
xflag := false;
end
end
else
begin
if (temp < - CloseSize) then
else
if (temp < 0) or (temp > MaxBuffsize - CloseSize) then
begin (* Buffer close to full send Xoff *)
ch_out(Xoff);
xflag := true;
end;
end;
end;
function ch_inp: byte;
{ Input a byte from port - no wait - assumed ready }
begin
rs_rpt := rs_rpt + 1 ;
if rs_rpt = MaxBuffsize then rs_rpt := 0 ;
ch_inp := rs_buf[rs_rpt] ;
end; { ch_inp }
{ ROS.MDM - Remote Operating System Modem Dependent Routines }
procedure mdinit;
{ Initialize modem }
begin
{writeln('mdinit');}
{ ch_init; does nothing}
rate := DefaultBaudRate;
ch_set;
{ ch_on; for auto answer code }
ch_off; { until manual answer and rate is set }
end;
function mdring: boolean;
{ Determine if the phone is ringing }
begin
{writeln('mdring');}
if delay_down then mdring := false
else mdring := true
end;
procedure mdans;
{ Detect and set system to rate at which modem answered phone }
begin
{writeln('mdans');}
write('Baud Rate of user 75 <CR> or 300 <Sp>');
ch := ' ';
readln(ch);
if ch = ' ' then rate := 300 else rate := 75 ;
ch_set;
ch_on;
end;
procedure mdhangup;
{ Hangup modem }
begin
{writeln('mdhangup');}
rate := DefaultBaudRate;
ch_set;
ch_off;
mdring := false
end;
procedure mdbusy;
{ Take modem off hook to present a busy signal to incoming callers }
begin
{writeln('mdbusy');}
mdhangup
end;
{** System routines **}
var
StatusLine : string[80] absolute $F780 ; { Line 25 }
procedure system_init;
{ Initialization to be done once when ROS first starts }
const
Scr80by25by11 : array[0..15] of byte = { 11 scan lines per char }
($6B,$50,$57,$37,$1B,$05,$19,$1B,$48,$0A,$2A,$0B,$20,0,0,0);
var
i : byte ;
begin
{writeln('system_init');}
global_date[0] := 0;
global_date[1] := 0;
global_date[2] := 0;
global_date[3] := 25;
global_date[4] := 04;
global_date[5] := 88;
{ Initialize fields for i/o through modem. Most are set up as constants above }
OldVCB := addr(IntHan) ; { Where pio interrupts go to }
SetVCB ; { Save & set interrupt vector & set modem port }
ch_off ; { don't want interrupts until ready to ans call }
BaudSend := DefaultBaudRate ;
BaudReceive := DefaultBaudRate ;
FillChar(StatusLine,80,' ') ; { Space out line 25 }
for i := 0 to 15 do { Set 25 line screen. Line 25 is status line }
begin
port[$0C] := i ;
port[$0D] := Scr80by25by11[i] ;
end ;
end ;
procedure system_de_init;
{ De-initialization to be done once when ROS terminates }
const
Scr80by24 : array[0..15] of byte = { 11 scan lines per char }
($6B,$50,$57,$37,$1B,$05,$18,$1A,$48,$0A,$2A,$0A,$20,0,0,0);
var
i : byte ;
begin
{writeln('system_de_init');}
Port[ModemData] := RSout ; { Disable modem }
SetVCB ; { Restore interrupt vector from OldVCB }
ch_off ;
for i := 0 to 15 do { Reset 24 line screen }
begin
port[$0C] := i ;
port[$0D] := Scr80by24[i] ;
end ;
end ;
procedure putstat(st: StrStd);
{ Display 'st' on status line }
begin
fillchar(StatusLine,80,' ') ; { Space out line 25 }
move(st[1],StatusLine,length(st)) ;
end;
(* ------------------------------------------------------------------ *)
(* End of MODEM routines for Microbee computers *)
(* ------------------------------------------------------------------ *)
{ ROS.CLK - Clock Routines }
{ If your machine does not have a real time clock (RTC), you can still
install ROS by using the following procedures for time keeping. The
time and date are maintained in 'global_date' defined in ROSDEF.INC
While the time may be set to any value, I recommend 00:00:00.
}
procedure GetTAD(var t: tad_array);
{ Return a 6 element integer array of the current system time in
seconds, minutes, hours, day, month, and year. }
begin
move(global_date, t, 6)
end;
procedure SetTAD(var t: tad_array);
{ Set the system time using a 6 element integer array which contains
seconds, minutes, hours, day, month, and year. }
begin
move(t, global_date, 6)
end;