home *** CD-ROM | disk | FTP | other *** search
- Program BigClock;
- {$R+}
- {
- Big Clock On Screen
-
- This program is exactly what the name emplies. It is a large clock that ticks
- away only seconds on the screen. The purpose of this program is to provide
- a base for developement of other programs. For example is one wanted to
- write a program that could time certain tasks and display the passage of time
- visually. Other applications might be graphics programs. The basis for many
- functions and patterns on the screen are provided here.
- }
-
- const
- MemorySize = 100;
- One : Array[0..7] of Byte = ($3E,$08,$08,$08,$08,$08,$0A,$0C);
- Two : Array[0..7] of Byte = ($3C,$24,$04,$3C,$20,$20,$24,$3C);
- Three : Array[0..7] of Byte = ($1C,$22,$20,$38,$20,$20,$22,$1C);
- Four : Array[0..7] of Byte = ($38,$10,$10,$10,$3E,$14,$18,$10);
- Five : Array[0..7] of Byte = ($1C,$22,$20,$20,$3E,$02,$02,$3E);
- Six : Array[0..7] of Byte = ($18,$24,$24,$24,$1C,$08,$10,$20);
- Seven : Array[0..7] of Byte = ($08,$08,$08,$08,$10,$20,$24,$3C);
- Eight : Array[0..7] of Byte = ($18,$24,$24,$24,$18,$24,$24,$18);
- Nine : Array[0..7] of Byte = ($04,$08,$10,$38,$24,$24,$24,$18);
- Zero : Array[0..7] of Byte = ($38,$44,$44,$44,$44,$44,$44,$38);
- Hands : Array[0..119] of Integer = (160,12,170,15,180,18,190,21,
- 200,24,211,29,216,35,221,41,226,47,231,53,238,59,240,67,
- 242,75,244,83,246,91,250,100,247,108,244,116,241,124,238,132,
- 234,142,229,149,224,156,219,163,214,170,209,176,199,179,189,182,
- 179,185,169,188,160,190,151,187,142,184,133,181,123,178,113,175,
- 107,169,101,163,95,156,89,149,83,142,81,134,79,126,76,118,
- 73,110,70,100,73,92,76,84,79,75,82,66,85,59,90,53,
- 95,47,100,41,105,35,112,28,121,25,130,22,139,19,149,16);
-
- type RegPack = record
- AX,BX,CX,DX,BP,DI,SI,DS,ES,Flags: Integer;
- end;
-
- var
- X1, X2, Y1, Y2,
- ClockPosition,Pnum : Integer;
- I, Color, HoldSec : Integer;
- Ch : Char;
- Hour,Min,Sec,Fract : Integer;
- Regs : RegPack;
- Xpos,Ypos,Comp2 : Integer;
- Comp1 : Real;
-
- {$I GRAPH.P }
-
- procedure Init;
- begin
- Pnum := 0;
- Xpos := 161;
- Ypos := 101;
- Ch := ' ';
- GraphColorMode;
- Palette(3);
- end;
-
- procedure ClockFace;
- begin
- Circle(160,100,99,2);
- Pattern(One);
- FillPattern (155,04,162,11,1); { First digit of '12' }
- FillPattern (210,20,217,27,1); { Number '1' }
- FillPattern (106,20,113,27,1); { First digit of '11' }
- FillPattern (113,20,120,27,1); { Next digit of '11' }
- FillPattern (77,51,84,58,1); { First digit of '10' }
- Pattern(Two);
- FillPattern (162,04,169,11,1);
- FillPattern (237,51,244,58,1);
- Pattern(Three);
- FillPattern (251,97,258,104,1);
- Pattern(Four);
- FillPattern (235,141,242,148,1);
- Pattern(Five);
- FillPattern (210,174,217,181,1);
- Pattern(Six);
- FillPattern (157,190,164,197,1);
- Pattern(Seven);
- FillPattern (106,174,113,181,1);
- Pattern(Eight);
- FillPattern (77,141,84,148,1);
- Pattern(Nine);
- FillPattern (63,97,70,104,1);
- Pattern(Zero);
- FillPattern (83,51,90,58,1); { Last digit of '10' }
- end;
-
- procedure GetTime;
- begin
- with Regs do
- begin
- AX := $2C00;
- MsDos(Regs);
- Hour := hi(CX);
- Min := lo(CX);
- Sec := hi(DX);
- Fract := lo(DX);
- end;
- end;
-
- procedure ClockTick;
- begin
- GetTime;
- If HoldSec <> Sec
- then Begin
- Sound(20);
- Delay(5);
- NoSound;
- HoldSec := Sec;
- ClockPosition := Sec * 2;
- Draw(160,100,Xpos,Ypos,0);
- Xpos := Hands[ClockPosition];
- Ypos := Hands[ClockPosition + 1];
- Draw(160,100,Xpos,Ypos,2);
- Pnum := Pnum + 1;
- If Pnum = 5
- then Pnum := 0;
- Palette(Pnum);
- End;
- End;
-
- begin
- ClrScr;
- Init;
- ClockFace;
- Repeat
- ClockTick;
- Until Keypressed;
- TextMode;
- end.
-
-