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
/
ZCAT
/
ROS-CLK.LBR
/
KP84-ROS.CZK
/
KP84-ROS.CLK
Wrap
Text File
|
2000-06-30
|
3KB
|
119 lines
{ ROS.CLK - adapted from the following file by removal of non-clock code}
{ ROSMAC.INC - Remote Operating System Machine Dependent Routines }
{ Modified for Kaypro 4'84 with original clock }
{ By Kevin E. Karns - July 3, 1985 }
Const
sec = 2; {clk functions}
minu = 3;
hour = 4;
day = 6;
mon = 7;
year = 9;
func = 32; {clk function port}
clock = 36; {clk read/write port}
init = 34; {Z80 PIO initialization port}
initch = 15; {Z80 PIO initialization char}
make_one_pass: boolean = false;
Type
abyte = byte;
Var
hours, minutes, seconds, months, days, years: abyte;
Function Bcd(intval: abyte): abyte;
(* convert an integer value (intval) to byte in packed BCD format
before sending it to clock.
*)
Var
hinybble, lonybble: byte;
begin
hinybble := intval div 10;
lonybble := intval - (10 * hinybble);
hinybble := hinybble * 16;
Bcd := hinybble + lonybble;
End;
Function Ascii(bcdbyte: abyte): abyte;
(* convert packed BCD byte read from clock to integer value that Turbo
will display as an ASCII string.
*)
Var
hinybble, lonybble: byte;
begin
lonybble := bcdbyte and $0F;
hinybble := 10 * (bcdbyte div 16);
Ascii := hinybble + lonybble;
End; {ascii}
Procedure GetTAD(var t : tad_array);
{ Return a 6 element byte array of the current system time in
seconds, minutes, hours, day, month, and year. }
begin
port[init] := initch; {initialize PIO}
port[func] := hour;
hours := port[clock];
t[2] := Ascii(hours);
port[func] := minu;
minutes := port[clock];
t[1] := Ascii(minutes);
port[func] := sec;
seconds := port[clock];
t[0] := Ascii(seconds);
port[func] := mon;
months := port[clock];
t[4] := Ascii(months);
port[func] := day;
days := port[clock];
t[3] := Ascii(days);
port[func] := year;
years := port[clock];
t[5] := Ascii(years);
End; {GetTAD}
Procedure SetTAD(var t : tad_array);
{ Set the system time using a 6 element byte array }
begin
port[init] := initch; {initialize PIO}
port[func] := hour;
hours := Bcd(t[2]);
port[clock] := hours;
port[func] := minu;
minutes := Bcd(t[1]);
port[clock] := minutes;
port[func] := sec;
seconds := Bcd(t[0]);
port[clock] := seconds;
port[func] := mon;
months := Bcd(t[4]);
port[clock] := months;
port[func] := day;
days := Bcd(t[3]);
port[clock] := days;
port[func] := year;
years := Bcd(t[5]);
port[clock] := years;
End;