Files
KataMario/src/game/emutest.h
T
Matt Pharoah febcb71ea3 Added emulator detection (#651)
* Added emulator detection

* Fixed missing assignments

* Disable interrupts around the count factor test

* Added more comments to emutest

* Changed PJ64 enum values so the versions work as a bitfield

* Updated README

* Fixed comments

* Updated enum values so you can safely AND and OR all emulator version flags together

* Remove redundant gIsConsole, gIsVC, and gCacheEmulated global variables

* Changed console check to be more future proof against Ares

* Use assembly file instead of casting to a function pointer

* Moved round_double_to_float back to its own compilation unit

* Moved the ParallelN64 check before the Ares check for better future-proofing

* Align pj64_get_count_factor_asm with cache lines... not that it actually matters for pj64

* Adjusted some comments

* Made emulator check thread-safe on emulators that emulate PI timings

* Added gIsConsole macro for backwards compatibility

* Added cen64 to INSTANT_INPUT_BLACKLIST

* Updated comment
2023-08-28 18:03:26 -04:00

44 lines
1.4 KiB
C

#ifndef EMUTEST_H
#define EMUTEST_H
enum Emulator {
EMU_WIIVC = 0x0001,
EMU_PROJECT64_ANY = 0x001E,
EMU_PROJECT64_1_OR_2 = 0x0006, // PJ64 1.6 or similar (up to 2.3)
EMU_PROJECT64_3 = 0x0008, // PJ64 3.X
EMU_PROJECT64_4 = 0x0010, // PJ64 4.0 or later
EMU_MUPEN_BASED = 0x0060, // mupen64plus or pre-2.12 paralleln64, but NOT simple64 or new paralleln64
EMU_MUPEN_OLD = 0x0020, // Nemu64 and pre-2.12 paralleln64 will also get detected as this
EMU_MUPEN64PLUS_NEXT = 0x040,
EMU_CEN64 = 0x0080,
EMU_SIMPLE64 = 0x0100,
EMU_PARALLELN64 = 0x0200, // ParallelN64 2.12 or later
EMU_ARES = 0x0400,
EMU_CONSOLE = 0x0800
};
// initializes gEmulator
extern void detect_emulator();
/* gEmulator is an enum that identifies the current emulator.
* The enum values work as a bitfield, so you can use the & and | operators
* to test for multiple emulators or versions at once.
*
* Examples:
*
* Test for any version of PJ64:
* if (gEmulator & EMU_PROJECT64_ANY)
*
* Test for only PJ64 < 3.0:
* if (gEmulator & EMU_PROJECT64_1_OR_2)
*
* Test for Console, Ares, or ParallelN64:
* if (gEmulator & (EMU_CONSOLE | EMU_ARES | EMU_PARALLELN64))
*/
extern enum Emulator gEmulator;
// Included for backwards compatibility when upgrading from HackerSM64 2.0
#define gIsConsole ((gEmulator & EMU_CONSOLE) != 0)
#endif