Merge pull request #1437 from PatrickvL/ptimer_fix

nv2a: Ptimer fixes
This commit is contained in:
Luke Usher 2018-09-17 13:25:18 +01:00 committed by GitHub
commit 521bddba0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -41,15 +41,19 @@
#include "CxbxCommon.h"
#define NANOSECONDS_PER_SECOND 1000000000
/* PTIMER - time measurement and time-based alarms */
static uint64_t ptimer_get_clock(NV2AState * d)
{
// Get time in nanoseconds
uint64_t time = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
return Muldiv64(time,
uint32_t(d->pramdac.core_clock_freq * d->ptimer.numerator),
CLOCKS_PER_SEC * d->ptimer.denominator);
return Muldiv64(Muldiv64(time,
d->pramdac.core_clock_freq,
NANOSECONDS_PER_SECOND), // Was CLOCKS_PER_SEC
d->ptimer.denominator,
d->ptimer.numerator);
}
DEVICE_READ32(PTIMER)

View File

@ -1753,7 +1753,7 @@
#define NV2A_VERTEX_ATTR_RESERVED2 14
#define NV2A_VERTEX_ATTR_RESERVED3 15
#define NV2A_CRYSTAL_FREQ 13500000
#define NV2A_CRYSTAL_FREQ 16666666 // Was 13500000
#define NV2A_NUM_CHANNELS 32
#define NV2A_NUM_SUBCHANNELS 8