This commit is contained in:
RobertoFresca 2018-01-26 03:53:22 -03:00
commit d5bef691cb
2 changed files with 18 additions and 10 deletions

View File

@ -35,6 +35,9 @@
#pragma once
#include "emucore.h"
#include "xtal.h"
#include <math.h>
#undef min
#undef max
@ -48,13 +51,13 @@ typedef s64 attoseconds_t;
typedef s32 seconds_t;
// core definitions
const attoseconds_t ATTOSECONDS_PER_SECOND_SQRT = 1'000'000'000;
const attoseconds_t ATTOSECONDS_PER_SECOND = ATTOSECONDS_PER_SECOND_SQRT * ATTOSECONDS_PER_SECOND_SQRT;
const attoseconds_t ATTOSECONDS_PER_MILLISECOND = ATTOSECONDS_PER_SECOND / 1'000;
const attoseconds_t ATTOSECONDS_PER_MICROSECOND = ATTOSECONDS_PER_SECOND / 1'000'000;
const attoseconds_t ATTOSECONDS_PER_NANOSECOND = ATTOSECONDS_PER_SECOND / 1'000'000'000;
constexpr attoseconds_t ATTOSECONDS_PER_SECOND_SQRT = 1'000'000'000;
constexpr attoseconds_t ATTOSECONDS_PER_SECOND = ATTOSECONDS_PER_SECOND_SQRT * ATTOSECONDS_PER_SECOND_SQRT;
constexpr attoseconds_t ATTOSECONDS_PER_MILLISECOND = ATTOSECONDS_PER_SECOND / 1'000;
constexpr attoseconds_t ATTOSECONDS_PER_MICROSECOND = ATTOSECONDS_PER_SECOND / 1'000'000;
constexpr attoseconds_t ATTOSECONDS_PER_NANOSECOND = ATTOSECONDS_PER_SECOND / 1'000'000'000;
const seconds_t ATTOTIME_MAX_SECONDS = 1'000'000'000;
constexpr seconds_t ATTOTIME_MAX_SECONDS = 1'000'000'000;
@ -70,7 +73,6 @@ inline constexpr attoseconds_t DOUBLE_TO_ATTOSECONDS(double x) { return attoseco
inline constexpr double ATTOSECONDS_TO_HZ(attoseconds_t x) { return double(ATTOSECONDS_PER_SECOND) / double(x); }
template <typename T> inline constexpr attoseconds_t HZ_TO_ATTOSECONDS(T &&x) { return attoseconds_t(ATTOSECONDS_PER_SECOND / x); }
inline constexpr attoseconds_t HZ_TO_ATTOSECONDS(const XTAL &x) { return attoseconds_t(ATTOSECONDS_PER_SECOND / x.dvalue()); }
inline constexpr attoseconds_t HZ_TO_ATTOSECONDS(XTAL &&x) { return attoseconds_t(ATTOSECONDS_PER_SECOND / x.dvalue()); }
// macros for converting other seconds types to attoseconds
template <typename T> inline constexpr attoseconds_t ATTOSECONDS_IN_SEC(T &&x) { return attoseconds_t(x) * ATTOSECONDS_PER_SECOND; }

View File

@ -36,8 +36,10 @@ Usage:
***************************************************************************/
#ifndef MAME_EMU_DRIVERS_XTAL_H
#define MAME_EMU_DRIVERS_XTAL_H
#ifndef MAME_EMU_XTAL_H
#define MAME_EMU_XTAL_H
#include "emucore.h"
#pragma once
@ -90,4 +92,8 @@ constexpr XTAL operator ""_Hz_XTAL(long double clock) { return XTAL(double(clock
constexpr XTAL operator ""_kHz_XTAL(long double clock) { return XTAL(double(clock * 1e3)); }
constexpr XTAL operator ""_MHz_XTAL(long double clock) { return XTAL(double(clock * 1e6)); }
#endif // MAME_EMU_DRIVERS_XTAL_H
constexpr XTAL operator ""_Hz_XTAL(unsigned long long clock) { return XTAL(double(clock)); }
constexpr XTAL operator ""_kHz_XTAL(unsigned long long clock) { return XTAL(double(clock) * 1e3); }
constexpr XTAL operator ""_MHz_XTAL(unsigned long long clock) { return XTAL(double(clock) * 1e6); }
#endif // MAME_EMU_XTAL_H