home *** CD-ROM | disk | FTP | other *** search
- { PICS.CLK - Remote Operating System Clock Routines
- Updated 8/24/86 for PICS compatibility by Les Archambault }
-
- { File: OSBEXEC.CLK
- Description: This driver set is designed to support the Osborne Executive.
- I have done little here but extract and reformat this code
- from Maurice's file (which I believe is originally from a
- Kaypro .INC file). In fact, I have only the vaguest idea of
- what some of this code is doing.
- Date: 9/10/85
- Author: Mick Gaitor
- CURA1 RBBS: 1-718-625-5931
- Based on: OX-MAC.INC for ROS 3.2 by Maurice Thaler.
- }
-
- var
- Year,Hour,Minute,Second,Day,Month : byte; { CPM+ time variables }
- JulDate : integer;
- {
- These routines do conversion between single bytes of BCD data, which
- the Exec's clock outputs by default and single bytes of binary data,
- which ROS expects. They were written by Kevin Karns (with thanks to
- Steve Fox for finding them for me). [MAG]
- }
- function BCD_to_Bin(BCD : Byte): byte;
- { Convert packed BCD value to binary }
- 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 packed BCD }
- begin
- Bin_to_BCD := (16*(Bin div 10))+(Bin mod 10)
- end; {Bin_to_BCD}
-
- procedure Jul_to_Day(Year : byte; JulDate : integer; var Month,Day : Byte);
- const
- DaysInMonth = ' 312831303130313130313031';
- var
- DayInMon, ResCode : integer;
- Finished : boolean;
- begin
- Month := 1;
- Finished := false;
- while not Finished do
- begin
- val(copy(DaysInMonth,2*Month,2),DayInMon,ResCode);
- if Month = 2
- then if (Year mod 4) = 0
- then DayInMon := succ(DayInMon);
- if JulDate <= DayInMon
- then Finished := true
- else
- begin
- JulDate := JulDate - DayInMon;
- Month := succ(Month)
- end
- end;
- Day := JulDate
- end;
-
- procedure CPM_to_Julian(CPMdate: integer; var Year: byte; var JulDate: integer);
- const
- BaseYear = 78;
- begin
- Year := CPMdate div 365;
- JulDate := (CPMdate mod 365) - ((succ(Year)) div 4);
- Year := Year + BaseYear
- end;
-
- procedure GetTimeAndDate(var Year: byte; var JulDate: integer;
- var Hour, Minute, Second: byte);
- const
- SysTimDat = 105;
- var
- DateRec : record
- DateInt : integer;
- HourByte : byte;
- MinByte : byte
- end;
- begin
- Second := BCD_to_Bin(bdos(SysTimDat, Addr(DateRec)));
- with DateRec do
- begin
- Hour := BCD_to_Bin(HourByte);
- Minute := BCD_to_Bin(MinByte);
- CPM_to_Julian(DateInt, Year, JulDate)
- end
- end;
-
- 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
- GetTimeAndDate(Year,JulDate,Hour,Minute,Second);
- Jul_to_Day (Year,JulDate,Month,Day);
- t[0] := Second;
- t[1] := Minute;
- t[2] := Hour;
- t[3] := Day;
- t[4] := Month;
- t[5] := Year
- end;
-
- procedure SetTAD(var t: tad_array);
- { Set the system time using a 6 element byte array which contains
- seconds, minutes, hours, day, month, and year.
- }
- begin
- { **************************************************************
- Sorry guys, but you're on your own here. After all that mess
- up above to get the time out, I wouldn't even BEGIN to ATTEMPT
- to TRY to put it back in. Good luck... [MAG]
- **************************************************************
- }
- end;
-
- {The following two procedures MUST remain here to maintain compatibility
- with systems not using a clock. Please don't remove them.}
-
- Procedure tick_a_min;
- begin
- end;
-
- procedure tick_a_sec;
- begin
- end;