VB icon

Bios Clock

Email
Submitted on: 1/2/2015 12:59:00 PM
By: D/D++ (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: C, C++ (general), Borland C++, UNIX C++
Views: 899
 
     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.
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :Bios Clock
//**************************************
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
#include <string.h>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Bios Clock
// Description: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.
// By: D/D++ (from psc cd)
//
// Inputs:Sends Minutes, hours, and seconds to the bios function.
//
// Returns:returns the current time.
//
// Assumes:Make sure you don't run it on Windows 2000, becasue Windows 2000 does not fully support BGI in Dos.
//**************************************

#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);
}


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.