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
This commit is contained in:
1 parent
0138b8ea53
commit
febcb71ea3
20 files changed
+278
-92
No files matched your search
+3
-27
@@ -15,7 +15,6 @@
|
||||
#include "game/main.h"
|
||||
#include "game/rumble_init.h"
|
||||
#include "game/version.h"
|
||||
#include "game/vc_check.h"
|
||||
#ifdef UNF
|
||||
#include "usb/usb.h"
|
||||
#include "usb/debug.h"
|
||||
@@ -23,8 +22,7 @@
|
||||
#include "game/puppyprint.h"
|
||||
#include "game/puppylights.h"
|
||||
#include "game/profiling.h"
|
||||
|
||||
#include "game/vc_check.h"
|
||||
#include "game/emutest.h"
|
||||
|
||||
// Message IDs
|
||||
enum MessageIDs {
|
||||
@@ -318,21 +316,6 @@ void alert_rcp_hung_up(void) {
|
||||
error("RCP is HUNG UP!! Oh! MY GOD!!");
|
||||
}
|
||||
|
||||
void check_cache_emulation() {
|
||||
// Disable interrupts to ensure that nothing evicts the variable from cache while we're using it.
|
||||
u32 saved = __osDisableInt();
|
||||
// Create a variable with an initial value of 1. This value will remain cached.
|
||||
volatile u8 sCachedValue = 1;
|
||||
// Overwrite the variable directly in RDRAM without going through cache.
|
||||
// This should preserve its value of 1 in dcache if dcache is emulated correctly.
|
||||
*(u8*)(K0_TO_K1(&sCachedValue)) = 0;
|
||||
// Read the variable back from dcache, if it's still 1 then cache is emulated correctly.
|
||||
// If it's zero, then dcache is not emulated correctly.
|
||||
gCacheEmulated = sCachedValue;
|
||||
// Restore interrupts
|
||||
__osRestoreInt(saved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the first and last values of the stack.
|
||||
* If they're different, that means an error has occured, so trigger a crash.
|
||||
@@ -366,7 +349,7 @@ void thread3_main(UNUSED void *arg) {
|
||||
setup_mesg_queues();
|
||||
alloc_pool();
|
||||
load_engine_code_segment();
|
||||
gIsVC = IS_VC();
|
||||
detect_emulator();
|
||||
#ifndef UNF
|
||||
crash_screen_init();
|
||||
#endif
|
||||
@@ -384,14 +367,8 @@ void thread3_main(UNUSED void *arg) {
|
||||
osSyncPrintf("Linker : %s\n", __linker__);
|
||||
#endif
|
||||
|
||||
if (IO_READ(DPC_CLOCK_REG) == 0) {
|
||||
gIsConsole = FALSE;
|
||||
if (!(gEmulator & EMU_CONSOLE)) {
|
||||
gBorderHeight = BORDER_HEIGHT_EMULATOR;
|
||||
if (!gIsVC) {
|
||||
check_cache_emulation();
|
||||
} else {
|
||||
gCacheEmulated = FALSE;
|
||||
}
|
||||
#ifdef RCVI_HACK
|
||||
VI.comRegs.vSync = 525*20;
|
||||
change_vi(&VI, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
@@ -400,7 +377,6 @@ void thread3_main(UNUSED void *arg) {
|
||||
osViSetSpecialFeatures(OS_VI_GAMMA_OFF);
|
||||
#endif
|
||||
} else {
|
||||
gIsConsole = TRUE;
|
||||
gBorderHeight = BORDER_HEIGHT_CONSOLE;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
||||
Reference in new issue
Block a user