VB icon

Make a Continous Clock in Turbo C++

Email
Submitted on: 1/6/2015 11:04:00 PM
By: Shyam Sunder Verma (from psc cd)  
Level: Intermediate
User Rating: By 6 Users
Compatibility: C++ (general), Borland C++
Views: 723
 
     This code uses the Video Display Unit (VDU) Concept. this program can compiled and executed on DOS mode (I used Turbo c++ 2.0 compiler) On execution It gives a continue clock at Right-Below corner. After execution It gives promp again to you but clock continues untill you terminate the Dos screen.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Make a Continous Clock in Turbo C++
// Description:This code uses the Video Display Unit (VDU) Concept.
this program can compiled and executed on DOS mode (I used Turbo c++ 2.0 compiler) On execution It gives a continue clock at Right-Below corner. After execution It gives promp again to you but clock continues untill you terminate the Dos screen.
// By: Shyam Sunder Verma (from psc cd)
//
// Inputs:Nothing is required as input
//
// Returns:Show the clock in 00:00:00 mode
Hours 0->23
//
// Assumes:Nothing Just How to execute the code on Dos screen.
//
// Side Effects:I am not encountered any Side effects. But it uses interrupt services so it may cause some side effects.
//**************************************

// Author : Shyam Sunder Verma
// MLVT Institute Bhilwara
// Rajasthan University Jaipur
// " http://www.geocities.com/ssv445 "
// ssv445@rediffmail.com
//ssv445@yahoo.com
// The source code is copyright of author. it can be modified and used. but it should not be provided on web links. 
//you can have the link of this page on your web page.
// This is the program by which you can have a paralle clock in Turbo C++2.0 editor 
// Follow the below guidelines to run programs
// 	1. Compile and Make this program under Turbo C++
//	2. Now go to dos shell and run Exe file of the same Program.
//	3. Now type exit.(exit only from dos Shell)
//Notes-- You have to each time run it manually.
// for any comment or query mail me -- shyam
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include<string.h>
#include<stdlib.h>
char far *v;
char far *vidmem=(char far*)0xB8000000;
char str1[50]="Shyam Sunder Verma-->>",strt[10]="shyam";
//-----------------------------------------------------------------
void putChar(int r,int c,char ch);
void putString(int r,int c,char *ch);
//-----------------------------------------------------------------
#define INTR 0X1C /* The clock tick interrupt */
#ifdef __cplusplus
 #define __CPPARGS ...
#else
 #define __CPPARGS
#endif
void interrupt ( *oldhandler)(__CPPARGS);
struct time t;
void interrupt handler(__CPPARGS);
class Clock
{
public:
	unsigned int h,m,s;
	float hd;
	Clock()
	{
		gettime(&t);
		h= t.ti_hour;
		m=t.ti_min;
		s=t.ti_sec;
		hd=t.ti_hund;
		putString(24,1,"Shyam Sunder Verma");
		oldhandler = getvect(INTR);
		setvect(INTR, handler);
		//Print();
	}
	void Start()
	{
	}
	~Clock()
	{
	//	setvect(INTR, oldhandler);
	}
	void Next()
	{
	hd+=(100/19.2);
	if(hd>99)
	{
		 hd=0;
		 s++;
		 if(s>59)
		 {
			s=0;
			m++;
			 if(m>59)
			 {
				h++;
				m=0;
				 if(h>23)
				 {
					h=0;
				 }
			 }
		 }
		 Print();
	}
	}
	void Print()
	{
	 putString(24,60,"________________");
	 strcpy(str1,"SSV : [");
	 strcat(str1,itoa(h,strt,10));
	 strcat(str1,":");
	 strcat(str1,itoa(m,strt,10));
	 strcat(str1,":");
	 strcat(str1,itoa(s,strt,10));
	 strcat(str1,"]");
	 putString(24,60,str1);
	}
};
Clock clk;
void interrupt handler(__CPPARGS)
{
/* call the old routine */
 clk.Next();
 oldhandler();
}
void main()
{
	clrscr();
	printf("Starting Continue Clock... ");
	delay(2000);
	clrscr();
	delay(2000);
}
//---------------------------------------------------------------
inline void putChar(int r,int c,char ch)
{
	r%=25;
	c%=80;
	v=vidmem+r*160+c*2;
	*v=ch;
	v++;
	*v=(char)78;
}
void putString(int r,int c,char *ch)
{
	for(;*ch;ch++)
		putChar(r,c++,*ch);
}


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.