Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mkolakovic authored Oct 7, 2017
1 parent b3e036e commit fce53bb
Show file tree
Hide file tree
Showing 57 changed files with 8,002 additions and 0 deletions.
Binary file added Bitmaps/Shield.bmp
Binary file not shown.
Binary file added Bitmaps/bullet.bmp
Binary file not shown.
Binary file added Bitmaps/bullet.bmp.ufo
Binary file not shown.
Binary file added Bitmaps/logo.bmp
Binary file not shown.
Binary file added Bitmaps/ship.bmp
Binary file not shown.
Binary file added Bitmaps/si.bmp
Binary file not shown.
Binary file added Bitmaps/title.bmp
Binary file not shown.
Binary file added Bitmaps/ufo.bmp
Binary file not shown.
101 changes: 101 additions & 0 deletions CDXAddons/CDXHPC/cdxhpc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////
// Project Name: [ CDX Class Library - CDX.lib ]
// Source File: [ CDX High Performance Counter Implementation]
// Author: [ Bil Simser - [email protected] ]
// Contributions: [ Michael Rich, Jimb Esser ]
// Revision: [ 2.0 ]
/////////////////////////////////////////////////////////////////////

#include "cdxhpc.h"


/////////////////////////////////////////////////////////////////////
// constructor
/////////////////////////////////////////////////////////////////////
CDXHPC::CDXHPC()
{
// init to zero
freq.QuadPart = 0;
restart.QuadPart = 0;
bPaused = FALSE;
}

/////////////////////////////////////////////////////////////////////
// starts the counter
/////////////////////////////////////////////////////////////////////
BOOL CDXHPC::Start()
{
QueryPerformanceCounter(&restart);
if (!QueryPerformanceFrequency(&freq)) return FALSE;
// convert it down to milliseconds
freq.QuadPart /= 1000;
return TRUE;
}

/////////////////////////////////////////////////////////////////////
// returns the current # of ms since counter was started
/////////////////////////////////////////////////////////////////////
DWORD CDXHPC::GetValue()
{
if (bPaused)
return (DWORD)((paused.QuadPart - restart.QuadPart) / freq.QuadPart);
LARGE_INTEGER timer;
QueryPerformanceCounter(&timer);
return (DWORD)((timer.QuadPart - restart.QuadPart) / freq.QuadPart);
}

/////////////////////////////////////////////////////////////////////
// waits for a specified ms since the counter was started
// note that if its already been that long since it was started
// the function would exit immediately
/////////////////////////////////////////////////////////////////////
void CDXHPC::Wait(DWORD dwMilliSecs)
{
while (TRUE)
{
if (GetValue()>=dwMilliSecs) break;
}
}

/////////////////////////////////////////////////////////////////////
// waits for a specified ms after the function is called
/////////////////////////////////////////////////////////////////////
void CDXHPC::WaitFor(DWORD dwWaitTime)
{
DWORD dwStart = GetValue();
while (TRUE)
{
if (GetValue() - dwStart >= dwWaitTime) break;
}
}


/////////////////////////////////////////////////////////////////////
// resets the counter back to zero
/////////////////////////////////////////////////////////////////////
void CDXHPC::Reset()
{
LARGE_INTEGER timer, excess;
QueryPerformanceCounter(&timer);
excess.QuadPart = (timer.QuadPart - restart.QuadPart) % freq.QuadPart;
QueryPerformanceCounter(&restart);
restart.QuadPart -= excess.QuadPart;
}

void CDXHPC::Pause()
{
if (!bPaused) {
QueryPerformanceCounter(&paused);
bPaused = TRUE;
}
}

void CDXHPC::Resume()
{
if (bPaused) {
LARGE_INTEGER timer;
QueryPerformanceCounter(&timer);
restart.QuadPart += timer.QuadPart - paused.QuadPart;
bPaused = FALSE;
}
}
40 changes: 40 additions & 0 deletions CDXAddons/CDXHPC/cdxhpc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// CDXHPC class, with additional functions - Pause and Resume added by Jimb Esser

#ifndef _H_CDXHPC
#define _H_CDXHPC

#define WIN32_EXTRA_LEAN
#include <windows.h>

class CDXHPC
{
public:
// constructor
CDXHPC();
// destructor
virtual ~CDXHPC() {};

// starts the counter
BOOL Start();
// returns the current # of ms since counter was started
DWORD GetValue();
// waits for a specified ms since the counter was started
// note that if its already been that long since it was started
// the function would exit immediately
void Wait(DWORD dwStopTime);
// waits for a specified ms after the function is called
void WaitFor(DWORD dwWaitTime);

// resets the counter back to zero
void Reset();

void Pause();
void Resume();

protected:
// counter variables
LARGE_INTEGER freq, restart, paused;
BOOL bPaused;
};

#endif /* #ifndef _H_CDXHPC */
Loading

0 comments on commit fce53bb

Please sign in to comment.