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
/
BBS
/
C128PICS.ARC
/
CPMPLUS.CLK
< prev
next >
Wrap
Text File
|
1991-08-11
|
4KB
|
97 lines
{ PICS.CLK - Remote Operating System Clock Routines
Updated 24/6/89 for PICS compatibility by Peter B. Carter }
{ File: CPMPLUS.CLK This is a CP/M+ (generic) BDOS clock modual.
Use DATE.COM to set the correct time/date. }
Var
old_date,old_day,old_month,old_year : integer;
function BCD_to_Bin(BCD : Byte): byte;
{convert packed bcd to binary value}
begin
BCD_to_Bin := (10 * (BCD div 16)) + (BCD mod 16)
end; {bcd to bin}
function BIN_to_Bcd(Bin : byte): byte;
{convert binary value to bcd}
begin
Bin_to_BCD := (16 * (Bin div 10)) + (Bin mod 10)
end; {bin to bcd}
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. }
var
time_buf : array[1..4] of byte;
a,d,year,leap,month : integer;
const
days : array[0..1,0..11] of byte = ((31,28,31,30,31,30,31,31,30,31,30,31)
,(31,29,31,30,31,30,31,31,30,31,30,31));
begin
d := addr(time_buf);
a := bdos(105,d);
t[0] := BCD_to_bin(a); {seconds}
t[1] := BCD_to_bin(time_buf[4]); {minutes}
t[2] := BCD_to_bin(time_buf[3]); {hours}
d := time_buf[1] or (time_buf[2] shl 8);
if d = 0 then {date not set correctly}
begin
t[3] := BCD_to_bin(0); {day}
t[4] := BCD_to_bin(0); {month}
t[5] := BCD_to_bin(0); {year}
exit;
end;
if d = old_date then {why re-calc when same?}
begin
t[3] := old_day;
t[4] := old_month;
t[5] := old_year;
exit;
end;
old_date := d; {mark new date}
d := d-1; {we use base 0 for calcs
as it works out easier}
year := d div 1461; {4 years of 365 days}
d := d - year * 1461; {bump}
leap := d div 365; {act find what is remanding}
year := year * 4 + 1978 + leap; {1978 is base year}
if (leap = 3) or (leap = 4) then leap := 1 else leap := 0;
{conv value for array}
d := d mod 365; {now we just have the
number of days left in 1 year}
month := 0;
while days[leap,month] < (d+1) do
begin
d := d - days[leap,month]; {bump}
month := month+1;
end;
year := year mod 100; {we just want lower nibble}
t[3] := d + 1; {current day}
t[4] := month + 1;
t[5] := year;
old_day := d+1; {mark for short cuts}
old_month := month+1;
old_year := year;
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
{not implemented yet}
end;
procedure tick_a_min;
{ increments global date if no clock is in use}
begin
end;
procedure tick_a_sec;
{increments global date if no clock being used}
begin
end;
{end of C128.CLK}