diff --git a/src/core/kernel/address_arbiter.cpp b/src/core/kernel/address_arbiter.cpp index fc24fdb5..d8be5d66 100644 --- a/src/core/kernel/address_arbiter.cpp +++ b/src/core/kernel/address_arbiter.cpp @@ -58,7 +58,7 @@ void Kernel::arbitrateAddress() { regs[0] = SVCResult::Success; switch (static_cast(type)) { - // Puts this thread to sleep if word < value until another thread signals the address with the type SIGNAL + // Puts this thread to sleep if word < value until another thread arbitrates the address using SIGNAL case ArbitrationType::WaitIfLess: { s32 word = static_cast(mem.read32(address)); // Yes this is meant to be signed if (word < value) { @@ -67,6 +67,17 @@ void Kernel::arbitrateAddress() { break; } + // Puts this thread to sleep if word < value until another thread arbitrates the address using SIGNAL + // If the thread is put to sleep, the arbiter address is decremented + case ArbitrationType::DecrementAndWaitIfLess: { + s32 word = static_cast(mem.read32(address)); // Yes this is meant to be signed + if (word < value) { + mem.write32(address, word - 1); + sleepThreadOnArbiter(address); + } + break; + } + case ArbitrationType::Signal: signalArbiter(address, value); break; diff --git a/src/core/kernel/events.cpp b/src/core/kernel/events.cpp index a0c0d299..23937759 100644 --- a/src/core/kernel/events.cpp +++ b/src/core/kernel/events.cpp @@ -73,8 +73,7 @@ void Kernel::waitSynchronizationN() { logSVC("WaitSynchronizationN (STUBBED)\n"); regs[0] = SVCResult::Success; - if (currentThreadIndex == 1) { - printf("WaitSynchN OoT hack triggered\n"); - switchThread(0); - } + printf("Hacky WaitSync stuff for OoT triggered!!!\n"); + threads[currentThreadIndex].status = ThreadStatus::Ready; + switchThread(rand() % threadCount); } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index b2254df6..d1ce592a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,7 @@ int main (int argc, char *argv[]) { emu.initGraphicsContext(); - auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "SimplerTri.elf"); + auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "OoT.3ds"); if (!emu.loadROM(romPath)) { // For some reason just .c_str() doesn't show the proper path Helpers::panic("Failed to load ROM file: %s", romPath.string().c_str());