home *** CD-ROM | disk | FTP | other *** search
- type monthname = string[3];
- monames = array[1..12] of monthname;
-
- const months: monames = ('Jan','Feb','Mar','Apr','May','Jun',
- 'Jul','Aug','Sep','Oct','Nov','Dec');
- rtca = $20; { }
- rtcs = $22; { Real-time clock control registers }
- rtcd = $24; { }
-
- procedure clock(var month,date,hour,min,sec: byte);
-
- var
- temp: byte;
-
- function bcd_to_dec(bcd: byte): byte;
-
- begin
- bcd_to_dec := (bcd and 15) + 10 * (bcd div 16);
- end;
-
- function inport(loc: byte): byte;
-
- begin
- port[rtca] := loc;
- inport := bcd_to_dec(port[rtcd]);
- end;
-
- procedure setupclock;
-
- var
- junk: byte;
-
- begin
- port[rtcs] := $CF;
- port[rtcs] := $E0;
- port[rtcs] := $03;
- junk := inport($14);
- end;
-
- begin
- if clockin then begin
- setupclock;
- repeat
- sec := inport(2);
- min := inport(3);
- hour := inport(4);
- date := inport(6);
- month := inport(7);
- temp := inport(2);
- until temp = sec;
- end;
- end;
-
- function time(month, date, hour, min, sec: byte): name;
-
- var
- temps,
- tempm,
- tempd,
- temph: string[2];
-
- begin
- if clockin then begin
- str(sec:2,temps);
- str(min:2,tempm);
- str(hour:2,temph);
- str(date:2,tempd);
- if sec < 10 then temps := '0' + temps[2];
- if min < 10 then tempm := '0' + tempm[2];
- if date < 10 then tempd := '0' + tempd[2];
- time := temph + ':' + tempm + ':' + temps + ' ' + months[month] + tempd;
- end
- else time := '';
- end;
-
- procedure showtime;
-
- var
- message: name;
-
- begin
- if clockin then begin
- clock(month, date, hour, min, sec);
- message := time(month, date, hour, min, sec);
- lineout('Time is: ' + message);
- end;
- end;
-
- procedure connecttime;
-
- var
- message: name;
-
- begin
- if clockin then begin
- clock(month, date, hour, min, sec);
- usemin := 0;
- usehour := 0;
- usesec := sec - onsec;
- if usesec < 0 then begin
- usesec := usesec + 60;
- usemin := -1;
- end;
- usemin := min - onmin + usemin;
- if usemin < 0 then begin
- usemin := usemin + 60;
- usehour := -1;
- end;
- usehour := hour - onhour + usehour;
- if usehour < 0 then usehour := usehour + 24;
- message := copy(time(1, 1, usehour, usemin, usesec), 1, 8);
- lineout('Connect time: ' + message);
- end;
- end;
- əəəəəəəəəəəəəəəəəəəəəəəəəəəə