diff --git a/asm/emux.s b/asm/emux.s new file mode 100644 index 00000000..ef8467da --- /dev/null +++ b/asm/emux.s @@ -0,0 +1,11 @@ +// Detect if the emux emulator extension is supported +// https://hackmd.io/@rasky/r1k7na6Jn + +.include "macros.inc" +.section .text, "ax" +.set noreorder + +glabel emux_detect +or $v0, $0, $0 +jr $ra +tne $v0, $v0, 0x0 diff --git a/sm64.ld b/sm64.ld index 89a29f31..e9f92c74 100755 --- a/sm64.ld +++ b/sm64.ld @@ -160,6 +160,7 @@ SECTIONS #ifdef EEP KEEP(BUILD_DIR/asm/vc_bin.o(.text*)); #endif + KEEP(BUILD_DIR/asm/emux.o(.text*)); KEEP(BUILD_DIR/asm/pj64_get_count_factor_asm.o(.text*)); KEEP(BUILD_DIR/asm/round.o(.text*)); KEEP(BUILD_DIR/asm/fcr31.o(.text*)); diff --git a/src/game/emutest.c b/src/game/emutest.c index b6666662..ca427026 100644 --- a/src/game/emutest.c +++ b/src/game/emutest.c @@ -22,6 +22,7 @@ extern void __osPiRelAccess(void); enum Emulator gEmulator = EMU_CONSOLE; u32 pj64_get_count_factor_asm(void); // defined in asm/pj64_get_count_factor_asm.s +u32 emux_detect(void); // defined in asm/emux.s static inline u32 check_count_factor() { const u32 saved = __osDisableInt(); @@ -86,7 +87,7 @@ static u8 check_cache_emulation() { void detect_emulator() { if ((u32)IO_READ(DPC_PIPEBUSY_REG) | (u32)IO_READ(DPC_TMEM_REG) | (u32)IO_READ(DPC_BUFBUSY_REG)) { - gEmulator = EMU_CONSOLE; + gEmulator = emux_detect() ? EMU_ARES : EMU_CONSOLE; return; }