view Time.cpp @ 1:ac0fb48cd27a

Texture, hwl loading, video player
author Nomad
date Tue, 09 Oct 2012 13:09:08 +0200
parents 8b8875f5b359
children fd64b06a39a8
line wrap: on
line source

#include "OSAPI.h"

#include "Time.h"
#include "Keyboard.h"

#include "mm7_data.h"





Timer *pMiscTimer;
Timer *pEventTimer;






//----- (00426317) --------------------------------------------------------
unsigned __int64 Timer::Time()
{
  uint v2 = (timeGetTime() << 7) / 0x3E8;
  if (v2 < uStartTime)
    uStartTime = 0;
  return v2;
}



//----- (00426349) --------------------------------------------------------
void Timer::Pause()
{
  if (!bPaused)
  {
    uStopTime = Time();
    bPaused = true;
  }
}


//----- (00426363) --------------------------------------------------------
void Timer::Resume()
{
  if (bPaused)
  {
    pKeyActionMap->ResetKeys();
    bPaused = 0;
    uStartTime = Time();
  }
}

//----- (00426386) --------------------------------------------------------
void Timer::TrackGameTime()
{
  if (!bTackGameTime)
  {
    uGameTimeStart = Time();
    bTackGameTime = true;
  }
}



//----- (004263A0) --------------------------------------------------------
void Timer::StopGameTime()
{
  if (bTackGameTime)
  {
    bTackGameTime = 0;
    uStartTime = Time();
  }
}

//----- (004263B7) --------------------------------------------------------
int Timer::Update()
{
  Timer *v1; // esi@1
  unsigned int v2; // eax@2
  signed int v3; // eax@3
  char v4; // zf@5
  int result; // eax@8

  v1 = this;
  do
  {
    v2 = Time() - v1->uStartTime;
    v1->uTimeElapsed = v2;
  }
  while ( (signed int)v2 <= 0 );
  v1->uStartTime = Time();
  v3 = v1->uTimeElapsed;
  if ( v3 > 32 )
    v3 = 32;
  v4 = v1->bPaused == 0;
  v1->uTimeElapsed = v3;
  if ( v4 && !v1->bTackGameTime )
    v1->uTotalGameTimeElapsed += v3;
  result = (v3 << 16) / 128;
  v1->dt_in_some_format = result;
  return result;
}

//----- (00426402) --------------------------------------------------------
void Timer::Initialize()
{
  uTotalGameTimeElapsed = 0;
  bReady = true;
}