Advertisement
2002ASP Complete Applications #7892

Bios Clock

It shows your computer's BIOS time. Make sure you don't run it on Windows 2000, becasue Windows 2000 does not fully support BGI in Dos.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
#define PI 3.14152692
void second_hand(int midx,int midy,int d);
void min_hand(int midx,int midy,int d);
void hour_hand(int midx, int midy,int d);
int xc, yc, radius=150, charsize=2,d;  //radius of the circle
char buffer[80];
void digitxy(int d);
 int midx, midy;
void mainpage(void);
  struct time t;

int main(void)
{
  int gdriver = DETECT, gmode, errorcode,color;
  initgraph(&gdriver, &gmode, "c:\\bc5\\bgi");
  errorcode = graphresult();
  if (errorcode != grOk)
  {
  printf("Graphics error: %s\n", grapherrormsg(errorcode));
  printf("Press any key to halt:");
  getch();
  exit(1);
  }
  midx = getmaxx() / 2;
  midy = getmaxy() / 2;
  xc=midx;
  yc=midy;

  circle(midx, midy, radius);
  for(d=5;d<=60;d+=5)
   digitxy(d);
  do{

   gettime(&t);
   second_hand(midx,midy,t.ti_sec);
   min_hand(midx,midy,t.ti_min);
   hour_hand(midx,midy,t.ti_hour);
 	 delay(1000);
   floodfill(midx,midy,15);
  }while(!kbhit());
  getch();
  closegraph();
}
void digitxy(int d)
{
  int dx = (int) (cos((d/60.0)*2.*PI-PI/2.)*140+xc);
  int dy = (int) (sin((d/60.0)*2.*PI-PI/2.)*140+yc);

	sprintf(buffer,"%d",d/5);
  outtextxy(dx,dy,buffer);
  setcolor(WHITE);

}
void second_hand(int midx,int midy,int d)
{
  int dx = (int) (cos((d/60.0)*2.*PI-PI/2.)*140+xc);
  int dy = (int) (sin((d/60.0)*2.*PI-PI/2.)*140+yc);
  if(dy - yc >= 0)
  	dy+=charsize;
  else
  	dy-=charsize/2;
  if(dx -xc >=0)
  	dx+=charsize/2;
  else
setfillstyle(1,4);
 dx-=charsize;
 moveto(midx,midy);
 lineto(dx,dy);
 setcolor(YELLOW);
}
void min_hand(int midx,int midy,int d)
{
  int dx = (int) (cos((d/60.0)*2.*PI-PI/2.)*120+xc);
  int dy = (int) (sin((d/60.0)*2.*PI-PI/2.)*120+yc);
  if(dy - yc >= 0)
  	dy+=charsize;
  else
  	dy-=charsize/2;
  if(dx -xc >=0)
  	dx+=charsize/2;
  else
setfillstyle(1,4);
 dx-=charsize;
 moveto(midx,midy);
 lineto(dx,dy);
 setcolor(BLUE);
}
void hour_hand(int midx, int midy,int d)
{
int dx = (int) (cos((d/60.0)*2.*PI-PI/2.)*100+xc);
  int dy = (int) (sin((d/60.0)*2.*PI-PI/2.)*100+yc);
  if(dy - yc >= 0)
  	dy+=charsize;
  else
  	dy-=charsize/2;
  if(dx -xc >=0)
  	dx+=charsize/2;
  else
setfillstyle(1,4);
 dx-=charsize;
 moveto(midx,midy);
 lineto(dx,dy);
 setcolor(GREEN);
}
Commenti originali (3)
Recuperato da Wayback Machine