diff options
-rw-r--r-- | src/devices/machine/rescap.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/devices/machine/rescap.h b/src/devices/machine/rescap.h index 452df332de3..71b9cd55216 100644 --- a/src/devices/machine/rescap.h +++ b/src/devices/machine/rescap.h @@ -4,19 +4,19 @@ #define MAME_MACHINE_RESCAP_H // Little helpers for magnitude conversions -#define RES_R(res) ((double)(res)) -#define RES_K(res) ((double)(res) * 1e3) -#define RES_M(res) ((double)(res) * 1e6) +constexpr double RES_R(double res) { return res; } +constexpr double RES_K(double res) { return res * 1e3; } +constexpr double RES_M(double res) { return res * 1e6; } #define RES_INF (-1) -#define CAP_U(cap) ((double)(cap) * 1e-6) -#define CAP_N(cap) ((double)(cap) * 1e-9) -#define CAP_P(cap) ((double)(cap) * 1e-12) -#define IND_U(ind) ((double)(ind) * 1e-6) -#define IND_N(ind) ((double)(ind) * 1e-9) -#define IND_P(ind) ((double)(ind) * 1e-12) +constexpr double CAP_U(double cap) { return cap * 1e-6; } +constexpr double CAP_N(double cap) { return cap * 1e-9; } +constexpr double CAP_P(double cap) { return cap * 1e-12; } +constexpr double IND_U(double ind) { return ind * 1e-6; } +constexpr double IND_N(double ind) { return ind * 1e-9; } +constexpr double IND_P(double ind) { return ind * 1e-12; } // vin --/\r1/\-- out --/\r2/\-- gnd -#define RES_VOLTAGE_DIVIDER(r1, r2) ((double)(r2) / ((double)(r1) + (double)(r2))) +constexpr double RES_VOLTAGE_DIVIDER(double r1, double r2) { return r2 / (r1 + r2); } #define RES_2_PARALLEL(r1, r2) (((r1) * (r2)) / ((r1) + (r2))) #define RES_3_PARALLEL(r1, r2, r3) (1.0 / (1.0 / (r1) + 1.0 / (r2) + 1.0 / (r3))) @@ -28,13 +28,13 @@ // macro for the RC time constant on a 74LS123 with C > 1000pF // R is in ohms, C is in farads -#define TIME_OF_74LS123(r,c) (0.45 * (double)(r) * (double)(c)) +constexpr double TIME_OF_74LS123(double r, double c) { return 0.45 * r * c; } // macros for the RC time constant on a 555 timer IC // R is in ohms, C is in farads -#define PERIOD_OF_555_MONOSTABLE_NSEC(r,c) ((attoseconds_t)(1100000000 * (double)(r) * (double)(c))) -#define PERIOD_OF_555_ASTABLE_NSEC(r1,r2,c) ((attoseconds_t)( 693000000 * ((double)(r1) + 2.0 * (double)(r2)) * (double)(c))) -#define PERIOD_OF_555_MONOSTABLE(r,c) attotime::from_nsec(PERIOD_OF_555_MONOSTABLE_NSEC(r,c)) -#define PERIOD_OF_555_ASTABLE(r1,r2,c) attotime::from_nsec(PERIOD_OF_555_ASTABLE_NSEC(r1,r2,c)) +constexpr attoseconds_t PERIOD_OF_555_MONOSTABLE_NSEC(double r, double c) { return attoseconds_t(1100000000 * r * c); } +constexpr attoseconds_t PERIOD_OF_555_ASTABLE_NSEC(double r1, double r2, double c) { return attoseconds_t( 693000000 * (r1 + 2.0 * r2) * c); } +constexpr attotime PERIOD_OF_555_MONOSTABLE(double r, double c) { return attotime::from_nsec(PERIOD_OF_555_MONOSTABLE_NSEC(r, c)); } +constexpr attotime PERIOD_OF_555_ASTABLE(double r1, double r2, double c) { return attotime::from_nsec(PERIOD_OF_555_ASTABLE_NSEC(r1, r2, c)); } #endif // MAME_MACHINE_RESCAP_H |