Category : C Source Code
Archive   : ZTIMER20.ZIP
Filename : ZTIMER.CPP

 
Output of file : ZTIMER.CPP contained in archive : ZTIMER20.ZIP
/****************************************************************************
*
* The Zen Timer Library
*
* From the book
* "Zen of Assembly Language"
* Volume 1, Knowledge
*
* by Michael Abrash
*
* Modifications by Kendall Bennett
* Copyright (C) 1993-4 SciTech Software
*
* Filename: $RCSfile: ztimer.cpp $
* Version: $Revision: 1.6 $
*
* Language: C++ 2.1
* Environment: IBM PC (MS DOS)
*
* Description: Non-inline member functions for the C++ class interface
* to the Zen Timer Library.
*
* $Id: ztimer.cpp 1.6 1994/08/22 11:56:13 kjb release $
*
****************************************************************************/

#include
#include
#include "pmode.h"
#include "ztimer.h"

/*----------------------------- Implementation ----------------------------*/

// Compute the time elapsed between calls to LZTimerOn() and LZTimerOff()
// and add it to the current count.

void LZTimer::computeTime()
{
if (!overflow()) {
ulong newcount = LZTimerCount();
if (newcount == 0xFFFFFFFFL)
_overflow = true;
else
_count += newcount;
}
}

// Routine to stop the ultra long period timer. The timer resolution is low
// enough to make this routine non-inline.

void ULZTimer::stop()
{
_finish = ULZReadTime();
_count += ULZElapsedTime(_start,_finish);
}

ostream& operator << (ostream& o,LZTimer& timer)
{
char buf[40];

if (!timer.overflow()) {
sprintf(buf, "%.6f", timer.count() * timer.resolution());
o << buf;
}
else
o << "overflow";
return o;
}

ostream& operator << (ostream& o,ULZTimer& timer)
{
char buf[40];

sprintf(buf, "%.1f", timer.count() * timer.resolution());
return o << buf;
}


  3 Responses to “Category : C Source Code
Archive   : ZTIMER20.ZIP
Filename : ZTIMER.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/