diff --git a/CMakeLists.txt b/CMakeLists.txt index 36f71bfb8b..95f44d9753 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -898,6 +898,8 @@ add_library(${CoreLibName} ${CoreLinkType} Core/HLE/scePauth.h Core/HW/atrac3plus.cpp Core/HW/atrac3plus.h + Core/HW/AsyncIOManager.cpp + Core/HW/AsyncIOManager.h Core/HW/MediaEngine.cpp Core/HW/MediaEngine.h Core/HW/MpegDemux.cpp diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 9d1b4bf89c..90dbf87d39 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -74,6 +74,7 @@ set(SRCS HLE/sceParseHttp.cpp HLE/sceVaudio.cpp HLE/sceAudiocodec.cpp + HW/AsyncIOManager.cpp HW/MemoryStick.cpp HW/MediaEngine.cpp HW/SasAudio.cpp diff --git a/Core/Config.cpp b/Core/Config.cpp index e3c614c6e0..863184e3df 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -90,6 +90,7 @@ void Config::Load(const char *iniFileName) cpu->Get("Jit", &bJit, true); #endif cpu->Get("SeparateCPUThread", &bSeparateCPUThread, false); + cpu->Get("SeparateIOThread", &bSeparateIOThread, true); cpu->Get("FastMemory", &bFastMemory, false); cpu->Get("CPUSpeed", &iLockedCPUSpeed, false); @@ -228,6 +229,7 @@ void Config::Save() IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU"); cpu->Set("Jit", bJit); cpu->Set("SeparateCPUThread", bSeparateCPUThread); + cpu->Set("SeparateIOThread", bSeparateIOThread); cpu->Set("FastMemory", bFastMemory); cpu->Set("CPUSpeed", iLockedCPUSpeed); diff --git a/Core/Config.h b/Core/Config.h index 042dc6786b..094e08dc4c 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -58,6 +58,7 @@ public: bool bJit; // Definitely cannot be changed while game is running. bool bSeparateCPUThread; + bool bSeparateIOThread; int iLockedCPUSpeed; bool bAutoSaveSymbolMap; std::string sReportHost; diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 1416bbb4d0..60a98ee845 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -251,6 +251,7 @@ + @@ -437,6 +438,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index d9861b0b99..e96aaf9a55 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -451,6 +451,9 @@ FileSystems + + HW + @@ -840,6 +843,9 @@ Core + + HW + diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index d47d68a994..ae8f15ab5c 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -631,7 +631,7 @@ int PSPSaveDialog::Update() DisplaySaveIcon(); DisplaySaveDataInfo2(); - DisplayMessage(d->T("Do you want to overwrite the data?"), true); + DisplayMessage(d->T("Confirm Overwrite","Do you want to overwrite the data?"), true); DisplayButtons(DS_BUTTON_OK | DS_BUTTON_CANCEL); DisplayBanner(DB_SAVE); diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index b05dd6a07c..a61223146a 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -411,7 +411,6 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { framebuf = latchedFramebuf; framebufIsLatched = false; gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat); - gpuStats.numFlips++; } } @@ -427,6 +426,8 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { // non-buffered rendering. The interaction with frame skipping seems to need // some work. if (gpu->FramebufferDirty()) { + gpuStats.numFlips++; + bool wasSkipped = (gstate_c.skipDrawReason & SKIPDRAW_SKIPFRAME) != 0; gstate_c.skipDrawReason &= ~SKIPDRAW_SKIPFRAME; @@ -515,7 +516,6 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync) if (topaddr != framebuf.topaddr) { framebuf = fbstate; gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat); - gpuStats.numFlips++; } } else { WARN_LOG(HLE, "%s: PSP_DISPLAY_SETBUF_IMMEDIATE without topaddr?", __FUNCTION__); diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index 6a6dd271e2..405682b57a 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -40,6 +40,11 @@ struct GeInterruptData static std::list ge_pending_cb; static int geSyncEvent; static int geInterruptEvent; +static int geCycleEvent; + +// Let's try updating 10 times per vblank. +const int geIntervalUs = 1000000 / (60 * 10); +const int geBehindThresholdUs = 1000000 / (60 * 10); class GeIntrHandler : public IntrHandler { @@ -162,6 +167,20 @@ void __GeExecuteInterrupt(u64 userdata, int cyclesLate) __TriggerInterrupt(PSP_INTR_IMMEDIATE, PSP_GE_INTR, PSP_INTR_SUB_NONE); } +void __GeCheckCycles(u64 userdata, int cyclesLate) +{ + u64 geTicks = gpu->GetTickEstimate(); + if (geTicks != 0) + { + if (CoreTiming::GetTicks() > geTicks + usToCycles(geBehindThresholdUs)) { + u64 diff = CoreTiming::GetTicks() - geTicks; + gpu->SyncThread(); + CoreTiming::Advance(); + } + } + CoreTiming::ScheduleEvent(usToCycles(geIntervalUs), geCycleEvent, 0); +} + void __GeInit() { memset(&ge_used_callbacks, 0, sizeof(ge_used_callbacks)); @@ -170,6 +189,12 @@ void __GeInit() geSyncEvent = CoreTiming::RegisterEvent("GeSyncEvent", &__GeExecuteSync); geInterruptEvent = CoreTiming::RegisterEvent("GeInterruptEvent", &__GeExecuteInterrupt); + geCycleEvent = CoreTiming::RegisterEvent("GeCycleEvent", &__GeCheckCycles); + + // When we're using separate CPU/GPU threads, we need to keep them in sync. + if (IsOnSeparateCPUThread()) { + CoreTiming::ScheduleEvent(usToCycles(geIntervalUs), geCycleEvent, 0); + } } void __GeDoState(PointerWrap &p) @@ -182,6 +207,8 @@ void __GeDoState(PointerWrap &p) CoreTiming::RestoreRegisterEvent(geSyncEvent, "GeSyncEvent", &__GeExecuteSync); p.Do(geInterruptEvent); CoreTiming::RestoreRegisterEvent(geInterruptEvent, "GeInterruptEvent", &__GeExecuteInterrupt); + p.Do(geCycleEvent); + CoreTiming::RestoreRegisterEvent(geCycleEvent, "GeCycleEvent", &__GeCheckCycles); // Everything else is done in sceDisplay. p.DoMarker("sceGe"); diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index f34ff7d9c6..b26c828206 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -16,33 +16,36 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include "native/thread/thread.h" +#include "native/thread/threadutil.h" #include "Core/Config.h" #include "Core/System.h" #include "Core/Host.h" #include "Core/SaveState.h" -#include "HLE.h" +#include "Core/HLE/HLE.h" #include "Core/MIPS/MIPS.h" #include "Core/HW/MemoryStick.h" +#include "Core/HW/AsyncIOManager.h" #include "Core/CoreTiming.h" #include "Core/Reporting.h" -#include "../FileSystems/FileSystem.h" -#include "../FileSystems/MetaFileSystem.h" -#include "../FileSystems/ISOFileSystem.h" -#include "../FileSystems/DirectoryFileSystem.h" +#include "Core/FileSystems/FileSystem.h" +#include "Core/FileSystems/MetaFileSystem.h" +#include "Core/FileSystems/ISOFileSystem.h" +#include "Core/FileSystems/DirectoryFileSystem.h" extern "C" { #include "ext/libkirk/amctrl.h" }; -#include "sceIo.h" -#include "sceRtc.h" -#include "sceKernel.h" -#include "sceKernelMemory.h" -#include "sceKernelThread.h" +#include "Core/HLE/sceIo.h" +#include "Core/HLE/sceRtc.h" +#include "Core/HLE/sceKernel.h" +#include "Core/HLE/sceKernelMemory.h" +#include "Core/HLE/sceKernelThread.h" // For headless screenshots. -#include "sceDisplay.h" +#include "Core/HLE/sceDisplay.h" const int ERROR_ERRNO_FILE_NOT_FOUND = 0x80010002; const int ERROR_ERRNO_FILE_ALREADY_EXISTS = 0x80010011; @@ -101,7 +104,14 @@ const int PSP_COUNT_FDS = 64; // TODO: Should be 3, and stdin/stdout/stderr are special values aliased to 0? const int PSP_MIN_FD = 4; static int asyncNotifyEvent = -1; +static int syncNotifyEvent = -1; static SceUID fds[PSP_COUNT_FDS]; +static AsyncIOManager ioManager; +static bool ioManagerThreadEnabled = false; +static std::thread *ioManagerThread; + +// TODO: Is it better to just put all on the thread? +const int IO_THREAD_MIN_DATA_SIZE = 256; #define SCE_STM_FDIR 0x1000 #define SCE_STM_FREG 0x2000 @@ -292,6 +302,31 @@ void __IoAsyncNotify(u64 userdata, int cyclesLate) { } } +void __IoSyncNotify(u64 userdata, int cyclesLate) { + SceUID threadID = userdata >> 32; + int fd = (int) (userdata & 0xFFFFFFFF); + + s64 result = -1; + u32 error; + FileNode *f = __IoGetFd(fd, error); + if (f) { + f->pendingAsyncResult = false; + f->hasAsyncResult = true; + + AsyncIOResult managerResult; + if (ioManager.WaitResult(f->handle, managerResult)) { + result = managerResult; + } else { + ERROR_LOG(HLE, "Unable to complete IO operation."); + } + } + + SceUID waitID = __KernelGetWaitID(threadID, WAITTYPE_IO, error); + if (waitID == fd && error == 0) { + __KernelResumeThreadFromWait(threadID, result); + } +} + static DirectoryFileSystem *memstickSystem = NULL; #ifdef ANDROID static VFSFileSystem *flash0System = NULL; @@ -299,12 +334,20 @@ static VFSFileSystem *flash0System = NULL; static DirectoryFileSystem *flash0System = NULL; #endif +void __IoManagerThread() { + setCurrentThreadName("IOThread"); + while (ioManagerThreadEnabled) { + ioManager.RunEventsUntil(CoreTiming::GetTicks() + msToCycles(1000)); + } +} + void __IoInit() { INFO_LOG(HLE, "Starting up I/O..."); MemoryStick_SetFatState(PSP_FAT_MEMORYSTICK_STATE_ASSIGNED); asyncNotifyEvent = CoreTiming::RegisterEvent("IoAsyncNotify", __IoAsyncNotify); + syncNotifyEvent = CoreTiming::RegisterEvent("IoSyncNotify", __IoSyncNotify); std::string memstickpath; std::string flash0path; @@ -324,15 +367,33 @@ void __IoInit() { __KernelListenThreadEnd(&TellFsThreadEnded); memset(fds, 0, sizeof(fds)); + + ioManagerThreadEnabled = g_Config.bSeparateIOThread; + ioManager.SetThreadEnabled(ioManagerThreadEnabled); + if (ioManagerThreadEnabled) { + ioManagerThread = new std::thread(&__IoManagerThread); + } } void __IoDoState(PointerWrap &p) { + ioManager.DoState(p); p.DoArray(fds, ARRAY_SIZE(fds)); p.Do(asyncNotifyEvent); CoreTiming::RestoreRegisterEvent(asyncNotifyEvent, "IoAsyncNotify", __IoAsyncNotify); + p.Do(syncNotifyEvent); + CoreTiming::RestoreRegisterEvent(syncNotifyEvent, "IoSyncNotify", __IoSyncNotify); + p.DoMarker("sceIo"); } void __IoShutdown() { + ioManagerThreadEnabled = false; + ioManager.SyncThread(); + ioManager.FinishEventLoop(); + if (ioManagerThread != NULL) { + delete ioManagerThread; + ioManagerThread = NULL; + } + pspFileSystem.Unmount("ms0:", memstickSystem); pspFileSystem.Unmount("fatms0:", memstickSystem); pspFileSystem.Unmount("fatms:", memstickSystem); @@ -400,6 +461,12 @@ void __IoCompleteAsyncIO(int fd) { u32 error; FileNode *f = __IoGetFd(fd, error); if (f) { + AsyncIOResult managerResult; + if (ioManager.WaitResult(f->handle, managerResult)) { + f->asyncResult = managerResult; + } else { + // It's okay, not all operations are deferred. + } if (f->callbackID) { __KernelNotifyCallback(THREAD_CALLBACK_IO, f->callbackID, f->callbackArg); } @@ -446,6 +513,14 @@ void __IoSchedAsync(FileNode *f, int fd, int usec) { f->hasAsyncResult = false; } +void __IoSchedSync(FileNode *f, int fd, int usec) { + u64 param = ((u64)__KernelGetCurThread()) << 32 | fd; + CoreTiming::ScheduleEvent(usToCycles(usec), syncNotifyEvent, param); + + f->pendingAsyncResult = true; + f->hasAsyncResult = false; +} + u32 sceIoGetstat(const char *filename, u32 addr) { // TODO: Improve timing (although this seems normally slow..) int usec = 1000; @@ -525,7 +600,7 @@ u32 npdrmRead(FileNode *f, u8 *data, int size) { return size; } -int __IoRead(int id, u32 data_addr, int size) { +bool __IoRead(int &result, int id, u32 data_addr, int size) { if (id == 3) { DEBUG_LOG(HLE, "sceIoRead STDIN"); return 0; //stdin @@ -534,58 +609,88 @@ int __IoRead(int id, u32 data_addr, int size) { u32 error; FileNode *f = __IoGetFd(id, error); if (f) { - if(!(f->openMode & FILEACCESS_READ)) - { - return ERROR_KERNEL_BAD_FILE_DESCRIPTOR; - } - else if (Memory::IsValidAddress(data_addr)) { + if (!(f->openMode & FILEACCESS_READ)) { + result = ERROR_KERNEL_BAD_FILE_DESCRIPTOR; + return true; + } else if (Memory::IsValidAddress(data_addr)) { u8 *data = (u8*) Memory::GetPointer(data_addr); - if(f->npdrm){ - return npdrmRead(f, data, size); - }else{ - return (int) pspFileSystem.ReadFile(f->handle, data, size); + if (f->npdrm) { + result = npdrmRead(f, data, size); + return true; + } else if (__KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE) { + AsyncIOEvent ev = IO_EVENT_READ; + ev.handle = f->handle; + ev.buf = data; + ev.bytes = size; + ioManager.ScheduleOperation(ev); + return false; + } else { + result = (int) pspFileSystem.ReadFile(f->handle, data, size); + return true; } } else { ERROR_LOG(HLE, "sceIoRead Reading into bad pointer %08x", data_addr); // TODO: Returning 0 because it wasn't being sign-extended in async result before. // What should this do? - return 0; + result = 0; + return true; } } else { ERROR_LOG(HLE, "sceIoRead ERROR: no file open"); - return error; + result = error; + return true; } } u32 sceIoRead(int id, u32 data_addr, int size) { // TODO: Check id is valid first? - if (!__KernelIsDispatchEnabled() && id > 2) + if (!__KernelIsDispatchEnabled() && id > 2) { return -1; - - int result = __IoRead(id, data_addr, size); - if (result >= 0) { - DEBUG_LOG(HLE, "%x=sceIoRead(%d, %08x, %x)", result, id, data_addr, size); - // TODO: Timing is probably not very accurate, low estimate. - int us = result/100; - if(us==0) - us = 100; - return hleDelayResult(result, "io read", us); } - else + + // TODO: Timing is probably not very accurate, low estimate. + int us = size / 100; + if (us < 100) { + us = 100; + } + + int result; + bool complete = __IoRead(result, id, data_addr, size); + if (!complete) { + DEBUG_LOG(HLE, "sceIoRead(%d, %08x, %x): deferring result", id, data_addr, size); + + u32 error; + FileNode *f = __IoGetFd(id, error); + __IoSchedSync(f, id, us); + __KernelWaitCurThread(WAITTYPE_IO, id, 0, 0, false, "io read"); + return 0; + } else if (result >= 0) { + DEBUG_LOG(HLE, "%x=sceIoRead(%d, %08x, %x)", result, id, data_addr, size); + return hleDelayResult(result, "io read", us); + } else { return result; + } } u32 sceIoReadAsync(int id, u32 data_addr, int size) { + // TODO: Not sure what the correct delay is (and technically we shouldn't read into the buffer yet...) + int us = size / 100; + if (us < 100) { + us = 100; + } + u32 error; FileNode *f = __IoGetFd(id, error); if (f) { - f->asyncResult = __IoRead(id, data_addr, size); - // TODO: Not sure what the correct delay is (and technically we shouldn't read into the buffer yet...) - int us = f->asyncResult/100; - if(us==0) - us = 100; + int result; + bool complete = __IoRead(result, id, data_addr, size); + if (complete) { + f->asyncResult = result; + DEBUG_LOG(HLE, "%llx=sceIoReadAsync(%d, %08x, %x)", f->asyncResult, id, data_addr, size); + } else { + DEBUG_LOG(HLE, "sceIoReadAsync(%d, %08x, %x): deferring result", id, data_addr, size); + } __IoSchedAsync(f, id, us); - DEBUG_LOG(HLE, "%llx=sceIoReadAsync(%d, %08x, %x)", f->asyncResult, id, data_addr, size); return 0; } else { ERROR_LOG(HLE, "sceIoReadAsync: bad file %d", id); @@ -593,24 +698,37 @@ u32 sceIoReadAsync(int id, u32 data_addr, int size) { } } -int __IoWrite(int id, void *data_ptr, int size) { +bool __IoWrite(int &result, int id, void *data_ptr, int size) { // Let's handle stdout/stderr specially. if (id == 1 || id == 2) { const char *str = (const char *) data_ptr; const int str_size = size == 0 ? 0 : (str[size - 1] == '\n' ? size - 1 : size); INFO_LOG(HLE, "%s: %.*s", id == 1 ? "stdout" : "stderr", str_size, str); - return size; + result = size; + return true; } u32 error; FileNode *f = __IoGetFd(id, error); if (f) { - if(!(f->openMode & FILEACCESS_WRITE)) { - return ERROR_KERNEL_BAD_FILE_DESCRIPTOR; + if (!(f->openMode & FILEACCESS_WRITE)) { + result = ERROR_KERNEL_BAD_FILE_DESCRIPTOR; + return true; } - return (int) pspFileSystem.WriteFile(f->handle, (u8*) data_ptr, size); + if (__KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE) { + AsyncIOEvent ev = IO_EVENT_WRITE; + ev.handle = f->handle; + ev.buf = (u8 *) data_ptr; + ev.bytes = size; + ioManager.ScheduleOperation(ev); + return false; + } else { + result = (int) pspFileSystem.WriteFile(f->handle, (u8 *) data_ptr, size); + } + return true; } else { ERROR_LOG(HLE, "sceIoWrite ERROR: no file open"); - return (s32) error; + result = (s32) error; + return true; } } @@ -619,33 +737,53 @@ u32 sceIoWrite(int id, u32 data_addr, int size) { if (!__KernelIsDispatchEnabled() && id > 2) return -1; - int result = __IoWrite(id, Memory::GetPointer(data_addr), size); - if (result >= 0) { - DEBUG_LOG(HLE, "%x=sceIoWrite(%d, %08x, %x)", result, id, data_addr, size); - // TODO: Timing is probably not very accurate, low estimate. - int us = result/100; - if(us==0) - us = 100; - if (__KernelIsDispatchEnabled()) - return hleDelayResult(result, "io write", us); - else - return result; + // TODO: Timing is probably not very accurate, low estimate. + int us = size / 100; + if (us < 100) { + us = 100; } - else + + int result; + bool complete = __IoWrite(result, id, Memory::GetPointer(data_addr), size); + if (!complete) { + DEBUG_LOG(HLE, "sceIoWrite(%d, %08x, %x): deferring result", id, data_addr, size); + + u32 error; + FileNode *f = __IoGetFd(id, error); + __IoSchedSync(f, id, us); + __KernelWaitCurThread(WAITTYPE_IO, id, 0, 0, false, "io write"); + return 0; + } else if (result >= 0) { + DEBUG_LOG(HLE, "%x=sceIoWrite(%d, %08x, %x)", result, id, data_addr, size); + if (__KernelIsDispatchEnabled()) { + return hleDelayResult(result, "io write", us); + } else { + return result; + } + } else { return result; + } } u32 sceIoWriteAsync(int id, u32 data_addr, int size) { + // TODO: Not sure what the correct delay is (and technically we shouldn't read from the buffer yet...) + int us = size / 100; + if (us < 100) { + us = 100; + } + u32 error; FileNode *f = __IoGetFd(id, error); if (f) { - f->asyncResult = __IoWrite(id, Memory::GetPointer(data_addr), size); - // TODO: Not sure what the correct delay is (and technically we shouldn't read into the buffer yet...) - int us = f->asyncResult/100; - if(us==0) - us = 100; + int result; + bool complete = __IoWrite(result, id, Memory::GetPointer(data_addr), size); + if (complete) { + f->asyncResult = result; + DEBUG_LOG(HLE, "%llx=sceIoWriteAsync(%d, %08x, %x)", f->asyncResult, id, data_addr, size); + } else { + DEBUG_LOG(HLE, "sceIoWriteAsync(%d, %08x, %x): deferring result", id, data_addr, size); + } __IoSchedAsync(f, id, us); - DEBUG_LOG(HLE, "%llx=sceIoWriteAsync(%d, %08x, %x)", f->asyncResult, id, data_addr, size); return 0; } else { ERROR_LOG(HLE, "sceIoWriteAsync: bad file %d", id); diff --git a/Core/HLE/sceIo.h b/Core/HLE/sceIo.h index 2945a396c1..961b763eb5 100644 --- a/Core/HLE/sceIo.h +++ b/Core/HLE/sceIo.h @@ -19,9 +19,9 @@ #include -#include "../System.h" -#include "HLE.h" -#include "sceKernel.h" +#include "Core/System.h" +#include "Core/HLE/HLE.h" +#include "Core/HLE/sceKernel.h" void __IoInit(); void __IoDoState(PointerWrap &p); diff --git a/Core/HW/AsyncIOManager.cpp b/Core/HW/AsyncIOManager.cpp new file mode 100644 index 0000000000..062fab6880 --- /dev/null +++ b/Core/HW/AsyncIOManager.cpp @@ -0,0 +1,97 @@ +// Copyright (c) 2012- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include "Core/Reporting.h" +#include "Core/System.h" +#include "Core/HW/AsyncIOManager.h" +#include "Core/FileSystems/MetaFileSystem.h" + +void AsyncIOManager::ScheduleOperation(AsyncIOEvent ev) { + lock_guard guard(resultsLock_); + resultsPending_.insert(ev.handle); + ScheduleEvent(ev); +} + +bool AsyncIOManager::PopResult(u32 handle, AsyncIOResult &result) { + lock_guard guard(resultsLock_); + if (results_.find(handle) != results_.end()) { + result = results_[handle]; + results_.erase(handle); + resultsPending_.erase(handle); + return true; + } else { + return false; + } +} + +bool AsyncIOManager::WaitResult(u32 handle, AsyncIOResult &result) { + lock_guard guard(resultsLock_); + ScheduleEvent(IO_EVENT_SYNC); + while (HasEvents() && resultsPending_.find(handle) != resultsPending_.end()) { + if (PopResult(handle, result)) { + return true; + } + resultsWait_.wait_for(resultsLock_, 16); + } + if (PopResult(handle, result)) { + return true; + } + + return false; +} + +void AsyncIOManager::ProcessEvent(AsyncIOEvent ev) { + switch (ev.type) { + case IO_EVENT_READ: + Read(ev.handle, ev.buf, ev.bytes); + break; + + case IO_EVENT_WRITE: + Write(ev.handle, ev.buf, ev.bytes); + break; + + default: + ERROR_LOG(HLE, "Unsupported IO event type"); + } +} + +void AsyncIOManager::Read(u32 handle, u8 *buf, size_t bytes) { + size_t result = pspFileSystem.ReadFile(handle, buf, bytes); + EventResult(handle, result); +} + +void AsyncIOManager::Write(u32 handle, u8 *buf, size_t bytes) { + size_t result = pspFileSystem.WriteFile(handle, buf, bytes); + EventResult(handle, result); +} + +void AsyncIOManager::EventResult(u32 handle, AsyncIOResult result) { + lock_guard guard(resultsLock_); + if (results_.find(handle) != results_.end()) { + ERROR_LOG_REPORT(HLE, "Overwriting previous result for file action on handle %d", handle); + } + results_[handle] = result; + resultsWait_.notify_one(); +} + +void AsyncIOManager::DoState(PointerWrap &p) { + SyncThread(); + lock_guard guard(resultsLock_); + p.Do(resultsPending_); + p.Do(results_); + p.DoMarker("AsyncIOManager"); +} diff --git a/Core/HW/AsyncIOManager.h b/Core/HW/AsyncIOManager.h new file mode 100644 index 0000000000..6c057da9b1 --- /dev/null +++ b/Core/HW/AsyncIOManager.h @@ -0,0 +1,75 @@ +// Copyright (c) 2012- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include +#include +#include "native/base/mutex.h" +#include "Core/ThreadEventQueue.h" + +class NoBase { +}; + +enum AsyncIOEventType { + IO_EVENT_INVALID, + IO_EVENT_SYNC, + IO_EVENT_FINISH, + IO_EVENT_READ, + IO_EVENT_WRITE, +}; + +struct AsyncIOEvent { + AsyncIOEvent(AsyncIOEventType t) : type(t) {} + AsyncIOEventType type; + u32 handle; + u8 *buf; + size_t bytes; + + operator AsyncIOEventType() const { + return type; + } +}; + +// TODO: Something better. +typedef size_t AsyncIOResult; + +typedef ThreadEventQueue IOThreadEventQueue; +class AsyncIOManager : public IOThreadEventQueue { +public: + void DoState(PointerWrap &p); + + void ScheduleOperation(AsyncIOEvent ev); + + bool PopResult(u32 handle, AsyncIOResult &result); + bool WaitResult(u32 handle, AsyncIOResult &result); + +protected: + virtual void ProcessEvent(AsyncIOEvent ref); + virtual bool ShouldExitEventLoop() { + return coreState == CORE_ERROR || coreState == CORE_POWERDOWN; + } + +private: + void Read(u32 handle, u8 *buf, size_t bytes); + void Write(u32 handle, u8 *buf, size_t bytes); + + void EventResult(u32 handle, AsyncIOResult result); + + recursive_mutex resultsLock_; + condition_variable resultsWait_; + std::set resultsPending_; + std::map results_; +}; \ No newline at end of file diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index f3d995345b..43eb720aab 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -112,6 +112,10 @@ IdentifiedFileType Identify_File(std::string &filename) if (psar_id == 'MUPN') { return FILETYPE_PSP_ISO_NP; } + // PS1 PSAR begins with "PSISOIMG0000" + if (psar_id == 'SISP') { + return FILETYPE_PSP_PS1_PBP; + } // Let's check if we got pointed to a PBP within such a directory. // If so we just move up and return the directory itself as the game. @@ -177,6 +181,10 @@ bool LoadFile(std::string &filename, std::string *error_string) { pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR"); return Load_PSP_ISO(filename.c_str(), error_string); + case FILETYPE_PSP_PS1_PBP: + *error_string = "PS1 EBOOTs are not supported by PPSSPP."; + break; + case FILETYPE_ERROR: ERROR_LOG(LOADER, "Could not read file"); *error_string = "Error reading file"; diff --git a/Core/Loaders.h b/Core/Loaders.h index 30dee7b448..1c79a65dbc 100644 --- a/Core/Loaders.h +++ b/Core/Loaders.h @@ -35,6 +35,7 @@ enum IdentifiedFileType { // Try to reduce support emails... FILETYPE_ARCHIVE_RAR, FILETYPE_ARCHIVE_ZIP, + FILETYPE_PSP_PS1_PBP, FILETYPE_UNKNOWN }; diff --git a/Core/MIPS/ARM/ArmCompVFPU.cpp b/Core/MIPS/ARM/ArmCompVFPU.cpp index afe85e8489..e2b06abde0 100644 --- a/Core/MIPS/ARM/ArmCompVFPU.cpp +++ b/Core/MIPS/ARM/ArmCompVFPU.cpp @@ -592,12 +592,22 @@ namespace MIPSComp fpr.ReleaseSpillLocksAndDiscardTemps(); } + void Jit::Comp_Vhoriz(u32 op) { + DISABLE; + + switch ((op >> 16) & 31) { + case 6: // vfad + break; + case 7: // vavg + break; + } + } + void Jit::Comp_VHdp(u32 op) { // Similar to vdot DISABLE; } - void Jit::Comp_VecDo3(u32 op) { CONDITIONAL_DISABLE; @@ -1535,10 +1545,6 @@ namespace MIPSComp fpr.ReleaseSpillLocksAndDiscardTemps(); } - void Jit::Comp_Vhoriz(u32 op) { - DISABLE; - } - static float sincostemp[2]; void SinCos(float angle) { diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 18986fe3f4..f20a76219a 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -25,6 +25,7 @@ #include "Core/MIPS/MIPSDebugInterface.h" #include "Core/MIPS/MIPSVFPUUtils.h" #include "Core/MIPS/JitCommon/JitBlockCache.h" +#include "Core/Reporting.h" #include "Core/System.h" #include "Core/HLE/sceDisplay.h" @@ -203,6 +204,7 @@ void MIPSState::WriteFCR(int reg, int value) } else { + WARN_LOG_REPORT(CPU, "WriteFCR: Unexpected reg %d (value %08x)", reg, value); // MessageBox(0, "Invalid FCR","...",0); } DEBUG_LOG(CPU, "FCR%i written to, value %08x", reg, value); @@ -222,6 +224,7 @@ u32 MIPSState::ReadFCR(int reg) } else { + WARN_LOG_REPORT(CPU, "ReadFCR: Unexpected reg %d", reg); // MessageBox(0, "Invalid FCR","...",0); } return 0; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 9b7bbbce75..5f16b37c37 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -54,7 +54,7 @@ namespace MIPSAnalyst if (MIPS_GET_RT(opinfo) == reg) return true; } - if (opinfo & (IN_RS | IN_RS_ADDR | IN_RS_SHIFT)) + if (opinfo & IN_RS) { if (MIPS_GET_RS(opinfo) == reg) return true; @@ -87,75 +87,26 @@ namespace MIPSAnalyst } } - // Temporary, returns true for common ops which have proper flags in the table. - bool IsDelaySlotInfoSafe(u32 op) - { - const char *safeOps[] = { - "addi", "addiu", "slti", "sltiu", "andi", "ori", "xori", "lui", - "lb", "lh", "lwl", "lw", "lbu", "lhu", "lwr", - "sb", "sh", "swl", "sw", "swr", - "sll", "srl", "sra", "sllv", "srlv", "srav", - "add", "addu", "sub", "subu", "and", "or", "xor", "nor", - "slt", "sltu", - }; - const char *opName = MIPSGetName(op); - for (size_t i = 0; i < ARRAY_SIZE(safeOps); ++i) - { - if (!strcmp(safeOps[i], opName)) - return true; - } - - return false; - } - bool IsDelaySlotNiceReg(u32 branchOp, u32 op, int reg1, int reg2) { - // NOOPs are always nice. - if (op == 0) - return true; + // $0 is never an out reg, it's always 0. + if (reg1 != 0 && GetOutReg(op) == reg1) + return false; + if (reg2 != 0 && GetOutReg(op) == reg2) + return false; - // TODO: Once the flags are all correct on the tables, remove this safety. - if (IsDelaySlotInfoSafe(op)) - { - // $0 is never an out reg, it's always 0. - if (reg1 != 0 && GetOutReg(op) == reg1) - return false; - if (reg2 != 0 && GetOutReg(op) == reg2) - return false; - - return true; - } - - return false; + return true; } bool IsDelaySlotNiceVFPU(u32 branchOp, u32 op) { - // NOOPs are always nice. - if (op == 0) - return true; - - // TODO: Once the flags are all correct on the tables, remove this safety. - if (IsDelaySlotInfoSafe(op)) - { - // TODO: There may be IS_VFPU cases which are safe... - return (MIPSGetInfo(op) & IS_VFPU) == 0; - } - - return false; + // TODO: There may be IS_VFPU cases which are safe... + return (MIPSGetInfo(op) & IS_VFPU) == 0; } bool IsDelaySlotNiceFPU(u32 branchOp, u32 op) { - // NOOPs are always nice. - if (op == 0) - return true; - - // TODO: Once the flags are all correct on the tables, remove this safety. - if (IsDelaySlotInfoSafe(op)) - return (MIPSGetInfo(op) & OUT_FPUFLAG) == 0; - - return false; + return (MIPSGetInfo(op) & OUT_FPUFLAG) == 0; } bool IsSyscall(u32 op) @@ -190,8 +141,7 @@ namespace MIPSAnalyst int rd = MIPS_GET_RD(op); if ( - ((info & IN_RS) && (rs == reg)) || - ((info & IN_RS_SHIFT) && (rs == reg)) || + ((info & IN_RS) && !(info & IN_RS_ADDR) && (rs == reg)) || ((info & IN_RT) && (rt == reg))) { if (regAnal[reg].firstRead == -1) @@ -293,13 +243,7 @@ namespace MIPSAnalyst u32 op = Memory::Read_Instruction(addr); u32 info = MIPSGetInfo(op); - if ( - ((info & IN_RS) || - (info & IN_RS_SHIFT) || - (info & IN_RS_ADDR)) - && - (MIPS_GET_RS(op) == reg) - ) + if ((info & IN_RS) && (MIPS_GET_RS(op) == reg)) return true; if ((info & IN_RT) && (MIPS_GET_RT(op) == reg)) return true; @@ -644,8 +588,12 @@ namespace MIPSAnalyst info.dataSize = 2; break; case MEMTYPE_WORD: + case MEMTYPE_FLOAT: info.dataSize = 4; break; + + case MEMTYPE_VQUAD: + info.dataSize = 16; } u32 rs = cpu->GetRegValue(0,MIPS_GET_RS(op)); diff --git a/Core/MIPS/MIPSCodeUtils.cpp b/Core/MIPS/MIPSCodeUtils.cpp index 9d5c0444a9..e4fc59053a 100644 --- a/Core/MIPS/MIPSCodeUtils.cpp +++ b/Core/MIPS/MIPSCodeUtils.cpp @@ -26,14 +26,16 @@ namespace MIPSCodeUtils #define FULLOP_JR_RA 0x03e00008 #define OP_SYSCALL 0x0000000c #define OP_SYSCALL_MASK 0xFC00003F +#define _RS ((op>>21) & 0x1F) +#define _RT ((op>>16) & 0x1F) u32 GetJumpTarget(u32 addr) { u32 op = Memory::Read_Instruction(addr); if (op) { - u32 maskedOp = op & 0xFC000000; - if (maskedOp == 0x0C000000 || maskedOp == 0x08000000) //jal + u32 info = MIPSGetInfo(op); + if ((info & IS_JUMP) && (info & IN_IMM26)) { u32 target = (addr & 0xF0000000) | ((op&0x03FFFFFF) << 2); return target; @@ -87,9 +89,37 @@ namespace MIPSCodeUtils u32 info = MIPSGetInfo(op); if (info & IS_CONDBRANCH) { - //TODO: safer check - if ((op & 0xFFFF0000) == 0x10000000) + bool sure; + bool takeBranch; + switch (info & CONDTYPE_MASK) + { + case CONDTYPE_EQ: + sure = _RS == _RT; + takeBranch = true; + break; + + case CONDTYPE_NE: + sure = _RS == _RT; + takeBranch = false; + break; + + case CONDTYPE_LEZ: + case CONDTYPE_GEZ: + sure = _RS == 0; + takeBranch = true; + break; + + case CONDTYPE_LTZ: + case CONDTYPE_GTZ: + sure = _RS == 0; + takeBranch = false; + break; + } + + if (sure && takeBranch) return addr + ((signed short)(op&0xFFFF)<<2); + else if (sure && !takeBranch) + return addr + 8; else return INVALIDTARGET; } diff --git a/Core/MIPS/MIPSInt.cpp b/Core/MIPS/MIPSInt.cpp index d2175c3620..a71377b7d6 100644 --- a/Core/MIPS/MIPSInt.cpp +++ b/Core/MIPS/MIPSInt.cpp @@ -230,6 +230,7 @@ namespace MIPSInt int imm = (signed short)(op&0xFFFF)<<2; u32 addr = PC + imm + 4; + // x, y, z, w, any, all, (invalid), (invalid) int imm3 = (op>>18)&7; int val = (currentMIPS->vfpuCtrl[VFPU_CTRL_CC] >> imm3) & 1; @@ -290,7 +291,7 @@ namespace MIPSInt _dbg_assert_msg_(CPU,0,"Jump in delay slot :("); } - int rs = (op>>21)&0x1f; + int rs = _RS; u32 addr = R(rs); switch (op & 0x3f) { @@ -339,10 +340,10 @@ namespace MIPSInt void Int_StoreSync(u32 op) { - s32 imm = (signed short)(op&0xFFFF); - int base = ((op >> 21) & 0x1f); - int rt = (op >> 16) & 0x1f; - u32 addr = R(base) + imm; + int imm = (signed short)(op&0xFFFF); + int rt = _RT; + int rs = _RS; + u32 addr = R(rs) + imm; switch (op >> 26) { @@ -946,7 +947,7 @@ namespace MIPSInt { case 0: if (!reported) { - Reporting::ReportMessage("INTERRUPT instruction hit"); + Reporting::ReportMessage("INTERRUPT instruction hit (%08x) at %08x", op, currentMIPS->pc); WARN_LOG(CPU,"Disable/Enable Interrupt CPU instruction"); reported = 1; } diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index 58bc52f38b..ac440fb7ad 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -215,31 +215,29 @@ namespace MIPSInt switch (op >> 26) { case 53: //lvl.q/lvr.q - if (addr & 0x3) { - _dbg_assert_msg_(CPU, 0, "Misaligned lvX.q"); - } - if ((op&2) == 0) - { - // It's an LVL - float d[4]; - ReadVector(d, V_Quad, vt); - int offset = (addr >> 2) & 3; - for (int i = 0; i < offset + 1; i++) + if (addr & 0x3) { - d[3 - i] = Memory::Read_Float(addr - i * 4); + _dbg_assert_msg_(CPU, 0, "Misaligned lvX.q"); } - WriteVector(d, V_Quad, vt); - } - else - { - // It's an LVR float d[4]; ReadVector(d, V_Quad, vt); int offset = (addr >> 2) & 3; - for (int i = 0; i < (3 - offset) + 1; i++) + if ((op & 2) == 0) { - d[i] = Memory::Read_Float(addr + 4 * i); + // It's an LVL + for (int i = 0; i < offset + 1; i++) + { + d[3 - i] = Memory::Read_Float(addr - 4 * i); + } + } + else + { + // It's an LVR + for (int i = 0; i < (3 - offset) + 1; i++) + { + d[i] = Memory::Read_Float(addr + 4 * i); + } } WriteVector(d, V_Quad, vt); } @@ -254,33 +252,32 @@ namespace MIPSInt break; case 61: // svl.q/svr.q - if (addr & 0x3) { - _dbg_assert_msg_(CPU, 0, "Misaligned svX.q"); - } - if ((op&2) == 0) - { - // It's an SVL + if (addr & 0x3) + { + _dbg_assert_msg_(CPU, 0, "Misaligned svX.q"); + } float d[4]; ReadVector(d, V_Quad, vt); int offset = (addr >> 2) & 3; - for (int i = 0; i < offset + 1; i++) + if ((op&2) == 0) { - Memory::Write_Float(d[3 - i], addr - i * 4); + // It's an SVL + for (int i = 0; i < offset + 1; i++) + { + Memory::Write_Float(d[3 - i], addr - i * 4); + } } - } - else - { - // It's an SVR - float d[4]; - ReadVector(d, V_Quad, vt); - int offset = (addr >> 2) & 3; - for (int i = 0; i < (3 - offset) + 1; i++) + else { - Memory::Write_Float(d[i], addr + 4 * i); + // It's an SVR + for (int i = 0; i < (3 - offset) + 1; i++) + { + Memory::Write_Float(d[i], addr + 4 * i); + } } + break; } - break; case 62: //sv.q if (addr & 0xF) @@ -331,6 +328,8 @@ namespace MIPSInt case 7: m=one; break; // vmone default: _dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted"); + PC += 4; + EatPrefixes(); return; } @@ -353,6 +352,8 @@ namespace MIPSInt case 7: v=ones; break; //vone default: _dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted"); + PC += 4; + EatPrefixes(); return; } float o[4]; @@ -1258,7 +1259,7 @@ namespace MIPSInt case 1: d[i] = (float)currentMIPS->rng.R32(); break; // vrndi - TODO: copy bits instead? case 2: d[i] = 1.0f + ((float)currentMIPS->rng.R32() / 0xFFFFFFFF); break; // vrndf1 TODO: make more accurate case 3: d[i] = 2.0f + 2 * ((float)currentMIPS->rng.R32() / 0xFFFFFFFF); break; // vrndf2 TODO: make more accurate - case 4: d[i] = 0.0f; // Should not get here + default: _dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted"); } } ApplyPrefixD(d, sz); @@ -1354,7 +1355,7 @@ namespace MIPSInt { s32 imm = (signed short)(op&0xFFFC); int vt = ((op >> 16) & 0x1f) | ((op & 3) << 5); - int rs = (op >> 21) & 0x1f; + int rs = _RS; u32 addr = R(rs) + imm; switch (op >> 26) @@ -1532,6 +1533,8 @@ namespace MIPSInt break; default: _dbg_assert_msg_(CPU,0,"unknown min/max op %d", cond); + PC += 4; + EatPrefixes(); return; } ApplyPrefixD(d, sz); diff --git a/Core/MIPS/MIPSTables.cpp b/Core/MIPS/MIPSTables.cpp index 352c37286c..4375b92235 100644 --- a/Core/MIPS/MIPSTables.cpp +++ b/Core/MIPS/MIPSTables.cpp @@ -24,26 +24,29 @@ #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/MIPSTables.h" #include "Core/CoreTiming.h" +#include "Core/Reporting.h" #include "Core/Debugger/Breakpoints.h" #include "JitCommon/JitCommon.h" enum MipsEncoding { - Imme, - Spec, - Spe2, - Spe3, - RegI, - Cop0, - Cop0CO, + Imme, + Spec, + Spe2, + Spe3, + RegI, + Cop0, + Cop0CO, Cop1, Cop1BC, - Cop2, - Cop2BC2, + Cop1S, + Cop1W, + Cop2, + Cop2BC2, Cop2Rese, - VFPU0, - VFPU1, + VFPU0, + VFPU1, VFPU3, VFPU4Jump, VFPU7, @@ -53,9 +56,9 @@ enum MipsEncoding VFPUMatrix1, VFPU9, ALLEGREX0, - Emu, - Rese, - NumEncodings + Emu, + Rese, + NumEncodings, }; struct MIPSInstruction @@ -72,6 +75,7 @@ struct MIPSInstruction }; #define INVALID {-2} +#define INVALID_X_8 INVALID,INVALID,INVALID,INVALID,INVALID,INVALID,INVALID,INVALID #define N(a) a #ifndef FINAL @@ -87,17 +91,17 @@ using namespace MIPSDis; using namespace MIPSInt; using namespace MIPSComp; //regregreg instructions -const MIPSInstruction tableImmediate[64] = //xxxxxx ..... +const MIPSInstruction tableImmediate[64] = // xxxxxx ..... ..... ................ { //0 ENCODING(Spec), ENCODING(RegI), INSTR("j", &Jit::Comp_Jump, Dis_JumpType, Int_JumpType, IS_JUMP|IN_IMM26|DELAYSLOT), INSTR("jal", &Jit::Comp_Jump, Dis_JumpType, Int_JumpType, IS_JUMP|IN_IMM26|OUT_RA|DELAYSLOT), - INSTR("beq", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_RS|IN_RT|DELAYSLOT|CONDTYPE_EQ), - INSTR("bne", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_RS|IN_RT|DELAYSLOT|CONDTYPE_NE), - INSTR("blez", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_RS|DELAYSLOT|CONDTYPE_LEZ), - INSTR("bgtz", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_RS|DELAYSLOT|CONDTYPE_GTZ), + INSTR("beq", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|IN_RT|DELAYSLOT|CONDTYPE_EQ), + INSTR("bne", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|IN_RT|DELAYSLOT|CONDTYPE_NE), + INSTR("blez", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|CONDTYPE_LEZ), + INSTR("bgtz", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|CONDTYPE_GTZ), //8 INSTR("addi", &Jit::Comp_IType, Dis_addi, Int_IType, IN_RS|IN_IMM16|OUT_RT), INSTR("addiu", &Jit::Comp_IType, Dis_addi, Int_IType, IN_RS|IN_IMM16|OUT_RT), @@ -113,19 +117,19 @@ const MIPSInstruction tableImmediate[64] = //xxxxxx ..... ENCODING(Cop2), //cop2 INVALID, //copU - INSTR("beql", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_RS|IN_RT|DELAYSLOT|LIKELY|CONDTYPE_EQ), //L = likely - INSTR("bnel", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_RS|IN_RT|DELAYSLOT|LIKELY|CONDTYPE_NE), - INSTR("blezl", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_LEZ), - INSTR("bgtzl", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_GTZ), + INSTR("beql", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|IN_RT|DELAYSLOT|LIKELY|CONDTYPE_EQ), //L = likely + INSTR("bnel", &Jit::Comp_RelBranch, Dis_RelBranch2, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|IN_RT|DELAYSLOT|LIKELY|CONDTYPE_NE), + INSTR("blezl", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_LEZ), + INSTR("bgtzl", &Jit::Comp_RelBranch, Dis_RelBranch, Int_RelBranch, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_GTZ), //24 - {VFPU0}, - {VFPU1}, - {Emu}, - {VFPU3}, - {Spe2},//special2 - {-2}, //, "jalx", 0, Dis_JumpType, Int_JumpType}, - {-2}, - {Spe3},//special3 + ENCODING(VFPU0), + ENCODING(VFPU1), + ENCODING(Emu), + ENCODING(VFPU3), + ENCODING(Spe2),//special2 + INVALID, //, "jalx", 0, Dis_JumpType, Int_JumpType}, + INVALID, + ENCODING(Spe3),//special3 //32 INSTR("lb", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_RT|MEMTYPE_BYTE), INSTR("lh", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_RT|MEMTYPE_HWORD), @@ -134,46 +138,47 @@ const MIPSInstruction tableImmediate[64] = //xxxxxx ..... INSTR("lbu", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_RT|MEMTYPE_BYTE), INSTR("lhu", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_RT|MEMTYPE_HWORD), INSTR("lwr", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_RT|MEMTYPE_WORD), - {-2}, + INVALID, //40 INSTR("sb", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_IMM16|IN_RS_ADDR|IN_RT|OUT_MEM|MEMTYPE_BYTE), INSTR("sh", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_IMM16|IN_RS_ADDR|IN_RT|OUT_MEM|MEMTYPE_HWORD), INSTR("swl", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_IMM16|IN_RS_ADDR|IN_RT|OUT_MEM|MEMTYPE_WORD), INSTR("sw", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_IMM16|IN_RS_ADDR|IN_RT|OUT_MEM|MEMTYPE_WORD), - {-2}, - {-2}, + INVALID, + INVALID, INSTR("swr", &Jit::Comp_ITypeMem, Dis_ITypeMem, Int_ITypeMem, IN_IMM16|IN_RS_ADDR|IN_RT|OUT_MEM|MEMTYPE_WORD), - INSTR("cache", &Jit::Comp_Generic, Dis_Generic, Int_Cache, 0), + INSTR("cache", &Jit::Comp_Generic, Dis_Generic, Int_Cache, IN_MEM|IN_IMM16|IN_RS_ADDR|IN_OTHER|OUT_OTHER), //48 - INSTR("ll", &Jit::Comp_Generic, Dis_Generic, Int_StoreSync, 0), - INSTR("lwc1", &Jit::Comp_FPULS, Dis_FPULS, Int_FPULS, IN_RT|IN_RS_ADDR), - INSTR("lv.s", &Jit::Comp_SV, Dis_SV, Int_SV, IS_VFPU|VFPU_NO_PREFIX), - {-2}, // HIT THIS IN WIPEOUT - {VFPU4Jump}, - INSTR("lv", &Jit::Comp_SVQ, Dis_SVLRQ, Int_SVQ, IS_VFPU|VFPU_NO_PREFIX), - INSTR("lv.q", &Jit::Comp_SVQ, Dis_SVQ, Int_SVQ, IS_VFPU|VFPU_NO_PREFIX), //copU - {VFPU5}, + INSTR("ll", &Jit::Comp_Generic, Dis_Generic, Int_StoreSync, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_RT|OUT_OTHER|MEMTYPE_WORD), + INSTR("lwc1", &Jit::Comp_FPULS, Dis_FPULS, Int_FPULS, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_OTHER|MEMTYPE_FLOAT), + INSTR("lv.s", &Jit::Comp_SV, Dis_SV, Int_SV, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_OTHER|IS_VFPU|VFPU_NO_PREFIX|MEMTYPE_FLOAT), + INVALID, // HIT THIS IN WIPEOUT + ENCODING(VFPU4Jump), + INSTR("lv", &Jit::Comp_SVQ, Dis_SVLRQ, Int_SVQ, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_OTHER|IS_VFPU|VFPU_NO_PREFIX|MEMTYPE_VQUAD), + INSTR("lv.q", &Jit::Comp_SVQ, Dis_SVQ, Int_SVQ, IN_MEM|IN_IMM16|IN_RS_ADDR|OUT_OTHER|IS_VFPU|VFPU_NO_PREFIX|MEMTYPE_VQUAD), //copU + ENCODING(VFPU5), //56 - INSTR("sc", &Jit::Comp_Generic, Dis_Generic, Int_StoreSync, 0), - INSTR("swc1", &Jit::Comp_FPULS, Dis_FPULS, Int_FPULS, 0), //copU - INSTR("sv.s", &Jit::Comp_SV, Dis_SV, Int_SV,IS_VFPU|VFPU_NO_PREFIX), - {-2}, + INSTR("sc", &Jit::Comp_Generic, Dis_Generic, Int_StoreSync, IN_IMM16|IN_RS_ADDR|IN_OTHER|IN_RT|OUT_RT|OUT_MEM|MEMTYPE_WORD), + INSTR("swc1", &Jit::Comp_FPULS, Dis_FPULS, Int_FPULS, IN_IMM16|IN_RS_ADDR|IN_OTHER|OUT_MEM|MEMTYPE_FLOAT), //copU + INSTR("sv.s", &Jit::Comp_SV, Dis_SV, Int_SV, IN_IMM16|IN_RS_ADDR|IN_OTHER|OUT_MEM|IS_VFPU|VFPU_NO_PREFIX|MEMTYPE_FLOAT), + INVALID, //60 - {VFPU6}, - INSTR("sv", &Jit::Comp_SVQ, Dis_SVLRQ, Int_SVQ, IS_VFPU|VFPU_NO_PREFIX), //copU - INSTR("sv.q", &Jit::Comp_SVQ, Dis_SVQ, Int_SVQ, IS_VFPU|VFPU_NO_PREFIX), - INSTR("vflush", &Jit::Comp_Generic, Dis_Vflush, Int_Vflush, IS_VFPU|VFPU_NO_PREFIX), + ENCODING(VFPU6), + INSTR("sv", &Jit::Comp_SVQ, Dis_SVLRQ, Int_SVQ, IN_IMM16|IN_RS_ADDR|IN_OTHER|OUT_MEM|IS_VFPU|VFPU_NO_PREFIX|MEMTYPE_VQUAD), //copU + INSTR("sv.q", &Jit::Comp_SVQ, Dis_SVQ, Int_SVQ, IN_IMM16|IN_RS_ADDR|IN_OTHER|OUT_MEM|IS_VFPU|VFPU_NO_PREFIX|MEMTYPE_VQUAD), + // Some call this VFPU7 (vflush/vnop/vsync), but it's not super important. + INSTR("vflush", &Jit::Comp_DoNothing, Dis_Vflush, Int_Vflush, IS_VFPU|VFPU_NO_PREFIX), }; -const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxxxxx +const MIPSInstruction tableSpecial[64] = // 000000 ..... ..... ..... ..... xxxxxx { INSTR("sll", &Jit::Comp_ShiftType, Dis_ShiftType, Int_ShiftType, OUT_RD|IN_RT|IN_SA), - {-2}, // copu - + INVALID, // copu + INSTR("srl", &Jit::Comp_ShiftType, Dis_ShiftType, Int_ShiftType, OUT_RD|IN_RT|IN_SA), INSTR("sra", &Jit::Comp_ShiftType, Dis_ShiftType, Int_ShiftType, OUT_RD|IN_RT|IN_SA), INSTR("sllv", &Jit::Comp_ShiftType, Dis_VarShiftType, Int_ShiftType, OUT_RD|IN_RT|IN_RS_SHIFT), - {-2}, + INVALID, INSTR("srlv", &Jit::Comp_ShiftType, Dis_VarShiftType, Int_ShiftType, OUT_RD|IN_RT|IN_RS_SHIFT), INSTR("srav", &Jit::Comp_ShiftType, Dis_VarShiftType, Int_ShiftType, OUT_RD|IN_RT|IN_RS_SHIFT), @@ -182,9 +187,9 @@ const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxx INSTR("jalr", &Jit::Comp_JumpReg, Dis_JumpRegType, Int_JumpRegType, IS_JUMP|IN_RS|OUT_RA|DELAYSLOT), INSTR("movz", &Jit::Comp_RType3, Dis_RType3, Int_RType3, OUT_RD|IN_RS|IN_RT|IS_CONDMOVE|CONDTYPE_EQ), INSTR("movn", &Jit::Comp_RType3, Dis_RType3, Int_RType3, OUT_RD|IN_RS|IN_RT|IS_CONDMOVE|CONDTYPE_NE), - INSTR("syscall", &Jit::Comp_Syscall, Dis_Syscall, Int_Syscall,0), + INSTR("syscall", &Jit::Comp_Syscall, Dis_Syscall, Int_Syscall, IN_MEM|IN_OTHER|OUT_MEM|OUT_OTHER), INSTR("break", &Jit::Comp_Break, Dis_Generic, Int_Break, 0), - {-2}, + INVALID, INSTR("sync", &Jit::Comp_DoNothing, Dis_Generic, Int_Sync, 0), //16 @@ -192,40 +197,40 @@ const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxx INSTR("mthi", &Jit::Comp_MulDivType, Dis_ToHiloTransfer, Int_MulDivType, IN_RS|OUT_OTHER), INSTR("mflo", &Jit::Comp_MulDivType, Dis_FromHiloTransfer, Int_MulDivType, OUT_RD|IN_OTHER), INSTR("mtlo", &Jit::Comp_MulDivType, Dis_ToHiloTransfer, Int_MulDivType, IN_RS|OUT_OTHER), - {-2}, - {-2}, - INSTR("clz", &Jit::Comp_RType2, Dis_RType2, Int_RType2, OUT_RD|IN_RS|IN_RT), - INSTR("clo", &Jit::Comp_RType2, Dis_RType2, Int_RType2, OUT_RD|IN_RS|IN_RT), + INVALID, + INVALID, + INSTR("clz", &Jit::Comp_RType2, Dis_RType2, Int_RType2, OUT_RD|IN_RS), + INSTR("clo", &Jit::Comp_RType2, Dis_RType2, Int_RType2, OUT_RD|IN_RS), //24 INSTR("mult", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), INSTR("multu", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), INSTR("div", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), INSTR("divu", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), - INSTR("madd", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), - INSTR("maddu", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), - {-2}, - {-2}, + INSTR("madd", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|IN_OTHER|OUT_OTHER), + INSTR("maddu", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|IN_OTHER|OUT_OTHER), + INVALID, + INVALID, //32 - INSTR("add", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("addu", &Jit::Comp_RType3, Dis_addu, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("sub", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("subu", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("and", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("or", &Jit::Comp_RType3, Dis_addu, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("xor", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("nor", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), + INSTR("add", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("addu", &Jit::Comp_RType3, Dis_addu, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("sub", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("subu", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("and", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("or", &Jit::Comp_RType3, Dis_addu, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("xor", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("nor", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), //40 - {-2}, - {-2}, - INSTR("slt", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("sltu", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("max", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("min", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("msub", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), - INSTR("msubu", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), + INVALID, + INVALID, + INSTR("slt", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("sltu", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("max", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("min", &Jit::Comp_RType3, Dis_RType3, Int_RType3, IN_RS|IN_RT|OUT_RD), + INSTR("msub", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|IN_OTHER|OUT_OTHER), + INSTR("msubu", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|IN_OTHER|OUT_OTHER), //48 INSTR("tge", &Jit::Comp_Generic, Dis_RType3, 0, 0), @@ -233,143 +238,110 @@ const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxx INSTR("tlt", &Jit::Comp_Generic, Dis_RType3, 0, 0), INSTR("tltu", &Jit::Comp_Generic, Dis_RType3, 0, 0), INSTR("teq", &Jit::Comp_Generic, Dis_RType3, 0, 0), - {-2}, + INVALID, INSTR("tne", &Jit::Comp_Generic, Dis_RType3, 0, 0), - {-2}, + INVALID, //56 - {-2}, {-2}, {-2}, {-2}, {-2}, - - {-2}, - {-2}, - {-2}, + INVALID_X_8, }; -const MIPSInstruction tableSpecial2[64] = +// Theoretically should not hit these. +const MIPSInstruction tableSpecial2[64] = // 011100 ..... ..... ..... ..... xxxxxx { - INSTR("add.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, 0), - INSTR("sub.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, 0), - INSTR("mul.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, 0), - INSTR("div.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, 0), - INSTR("sqrt.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - INSTR("abs.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - INSTR("mov.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - INSTR("neg.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), -//8 - {-2}, {-2}, {-2}, {-2}, - INSTR("round.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - INSTR("trunc.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - INSTR("ceil.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - INSTR("floor.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), -//16 - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, -//24 - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, -//32 - INSTR("cvt.s.w", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - {-2}, {-2}, {-2}, -//36 - INSTR("cvt.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, 0), - {-2}, - INSTR("dis.int", &Jit::Comp_Generic, Dis_Generic, Int_Interrupt, 0), - {-2}, -//40 - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, -//48 - INSTR("c.f", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.un", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.eq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.ueq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.olt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.ult", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.ole", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.ule", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.sf", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.ngle",&Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.seq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.ngl", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.lt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.nge", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.le", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), - INSTR("c.ngt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, OUT_FPUFLAG), + INSTR("halt", &Jit::Comp_Generic, Dis_Generic, 0, 0), + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, + //8 + INVALID_X_8, + INVALID_X_8, + INVALID_X_8, + //32 + INVALID, INVALID, INVALID, INVALID, + INSTR("mfic", &Jit::Comp_Generic, Dis_Generic, 0, 0), + INVALID, + INSTR("mtic", &Jit::Comp_Generic, Dis_Generic, 0, 0), + INVALID, + //40 + INVALID_X_8, + INVALID_X_8, + INVALID_X_8, }; - -const MIPSInstruction tableSpecial3[64] = +const MIPSInstruction tableSpecial3[64] = // 011111 ..... ..... ..... ..... xxxxxx { INSTR("ext", &Jit::Comp_Special3, Dis_Special3, Int_Special3, IN_RS|OUT_RT), - {-2}, - {-2}, - {-2}, - INSTR("ins", &Jit::Comp_Special3, Dis_Special3, Int_Special3, IN_RS|OUT_RT), - {-2}, - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, + INSTR("ins", &Jit::Comp_Special3, Dis_Special3, Int_Special3, IN_RS|IN_RT|OUT_RT), + INVALID, + INVALID, + INVALID, //8 - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, + INVALID_X_8, //16 - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, + INVALID_X_8, + //24 + // TODO: Is this right? Or should it only be 32? Comment above (24) was mistakenly 32 before. + ENCODING(ALLEGREX0), + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, //32 - {ALLEGREX0}, - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, + ENCODING(ALLEGREX0), + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, //40 - {ALLEGREX0}, - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - - {-2}, {-2}, {-2}, + INVALID_X_8, + INVALID_X_8, + //56 + INVALID, INVALID, INVALID, INSTR("rdhwr", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, {-2}, {-2}, {-2}, + INVALID, INVALID, INVALID, INVALID, }; - -const MIPSInstruction tableRegImm[32] = +const MIPSInstruction tableRegImm[32] = // 000001 ..... xxxxx ................ { - INSTR("bltz", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|DELAYSLOT|CONDTYPE_LTZ), - INSTR("bgez", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|DELAYSLOT|CONDTYPE_GEZ), - INSTR("bltzl", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_LTZ), - INSTR("bgezl", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_GEZ), - {-2}, - {-2}, - {-2}, - {-2}, - + INSTR("bltz", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|CONDTYPE_LTZ), + INSTR("bgez", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|CONDTYPE_GEZ), + INSTR("bltzl", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_LTZ), + INSTR("bgezl", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|DELAYSLOT|LIKELY|CONDTYPE_GEZ), + INVALID, + INVALID, + INVALID, + INVALID, + //8 INSTR("tgei", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("tgeiu", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("tlti", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("tltiu", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("teqi", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, + INVALID, INSTR("tnei", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, - - INSTR("bltzal", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|OUT_RA|DELAYSLOT|CONDTYPE_LTZ), - INSTR("bgezal", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|OUT_RA|DELAYSLOT|CONDTYPE_GEZ), - INSTR("bltzall", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|OUT_RA|DELAYSLOT|LIKELY|CONDTYPE_LTZ), //L = likely - INSTR("bgezall", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_RS|OUT_RA|DELAYSLOT|LIKELY|CONDTYPE_GEZ), - {-2}, - {-2}, - {-2}, - {-2}, - - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, + INVALID, + //16 + INSTR("bltzal", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|OUT_RA|DELAYSLOT|CONDTYPE_LTZ), + INSTR("bgezal", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|OUT_RA|DELAYSLOT|CONDTYPE_GEZ), + INSTR("bltzall", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|OUT_RA|DELAYSLOT|LIKELY|CONDTYPE_LTZ), //L = likely + INSTR("bgezall", &Jit::Comp_RelBranchRI, Dis_RelBranch, Int_RelBranchRI, IS_CONDBRANCH|IN_IMM16|IN_RS|OUT_RA|DELAYSLOT|LIKELY|CONDTYPE_GEZ), + INVALID, + INVALID, + INVALID, + INVALID, + //24 + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INSTR("synci", &Jit::Comp_Generic, Dis_Generic, 0, 0), }; -const MIPSInstruction tableCop2[32] = +const MIPSInstruction tableCop2[32] = // 010010 xxxxx ..... ................ { INSTR("mfc2", &Jit::Comp_Generic, Dis_Generic, 0, OUT_RT), - {-2}, + INVALID, INSTR("cfc2", &Jit::Comp_Generic, Dis_Generic, 0, 0), - INSTR("mfv", &Jit::Comp_Mftv, Dis_Mftv, Int_Mftv, IS_VFPU), + INSTR("mfv", &Jit::Comp_Mftv, Dis_Mftv, Int_Mftv, IN_OTHER|OUT_RT|IS_VFPU), INSTR("mtc2", &Jit::Comp_Generic, Dis_Generic, 0, IN_RT), - {-2}, + INVALID, INSTR("ctc2", &Jit::Comp_Generic, Dis_Generic, 0, 0), - INSTR("mtv", &Jit::Comp_Mftv, Dis_Mftv, Int_Mftv, IS_VFPU), - - {Cop2BC2}, + INSTR("mtv", &Jit::Comp_Mftv, Dis_Mftv, Int_Mftv, IN_RT|OUT_OTHER|IS_VFPU), + //8 + ENCODING(Cop2BC2), INSTR("??", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("??", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("??", &Jit::Comp_Generic, Dis_Generic, 0, 0), @@ -377,402 +349,485 @@ const MIPSInstruction tableCop2[32] = INSTR("??", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("??", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("??", &Jit::Comp_Generic, Dis_Generic, 0, 0), - - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, + //16 + INVALID_X_8, + INVALID_X_8, }; -const MIPSInstruction tableCop2BC2[4] = +const MIPSInstruction tableCop2BC2[4] = // 010010 01000 ...xx ................ { - INSTR("bvf", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|DELAYSLOT), - INSTR("bvt", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|DELAYSLOT), - INSTR("bvfl", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|DELAYSLOT|LIKELY), - INSTR("bvtl", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|DELAYSLOT|LIKELY), + INSTR("bvf", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|IN_IMM16|IN_OTHER|DELAYSLOT|IS_VFPU), + INSTR("bvt", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|IN_IMM16|IN_OTHER|DELAYSLOT|IS_VFPU), + INSTR("bvfl", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|IN_IMM16|IN_OTHER|DELAYSLOT|LIKELY|IS_VFPU), + INSTR("bvtl", &Jit::Comp_VBranch, Dis_VBranch, Int_VBranch, IS_CONDBRANCH|IN_IMM16|IN_OTHER|DELAYSLOT|LIKELY|IS_VFPU), }; -const MIPSInstruction tableCop0[32] = +const MIPSInstruction tableCop0[32] = // 010000 xxxxx ..... ................ { INSTR("mfc0", &Jit::Comp_Generic, Dis_Generic, 0, OUT_RT), - {-2}, - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, INSTR("mtc0", &Jit::Comp_Generic, Dis_Generic, 0, IN_RT), - {-2}, - {-2}, - {-2}, - - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, + //8 + INVALID, + INVALID, INSTR("rdpgpr", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("mfmc0", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, - {-2}, + INVALID, + INVALID, INSTR("wrpgpr", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, - - {Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO}, - {Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO},{Cop0CO}, + INVALID, + //16 + ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), + ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), ENCODING(Cop0CO), }; // we won't encounter these since we only do user mode emulation -const MIPSInstruction tableCop0CO[64] = +const MIPSInstruction tableCop0CO[64] = // 010000 1.... ..... ..... ..... xxxxxx { - {-2}, + INVALID, INSTR("tlbr", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("tlbwi", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, INSTR("tlbwr", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, - + INVALID, + //8 INSTR("tlbp", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, + INVALID_X_8, + //24 INSTR("eret", &Jit::Comp_Generic, Dis_Generic, 0, 0), INSTR("iack", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, {-2}, {-2}, {-2}, {-2}, + INVALID, INVALID, INVALID, INVALID, INVALID, INSTR("deret", &Jit::Comp_Generic, Dis_Generic, 0, 0), - + //32 INSTR("wait", &Jit::Comp_Generic, Dis_Generic, 0, 0), - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, + INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, + //40 + INVALID_X_8, + INVALID_X_8, + INVALID_X_8, }; - -const MIPSInstruction tableCop1[32] = +const MIPSInstruction tableCop1[32] = // 010001 xxxxx ..... ..... ........... { - INSTR("mfc1",&Jit::Comp_mxc1, Dis_mxc1,Int_mxc1, OUT_RT), - {-2}, - INSTR("cfc1",&Jit::Comp_mxc1, Dis_mxc1,Int_mxc1, 0), - {-2}, - INSTR("mtc1",&Jit::Comp_mxc1, Dis_mxc1,Int_mxc1, IN_RT), - {-2}, - INSTR("ctc1",&Jit::Comp_mxc1, Dis_mxc1,Int_mxc1, 0), - {-2}, - - {Cop1BC}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, - - {Spe2}, {-2}, {-2}, {-2}, - {Spe2}, {-2}, {-2}, {-2}, - - {-2},{-2},{-2},{-2},{-2},{-2},{-2},{-2}, -}; - -const MIPSInstruction tableCop1BC[32] = -{ - {-1,"bc1f", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_FPUFLAG|DELAYSLOT}, - {-1,"bc1t", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_FPUFLAG|DELAYSLOT}, - {-1,"bc1fl", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_FPUFLAG|DELAYSLOT|LIKELY}, - {-1,"bc1tl", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_FPUFLAG|DELAYSLOT|LIKELY}, - {-2},{-2},{-2},{-2}, - {-2},{-2},{-2},{-2},{-2},{-2},{-2},{-2}, - {-2},{-2},{-2},{-2},{-2},{-2},{-2},{-2}, - {-2},{-2},{-2},{-2},{-2},{-2},{-2},{-2}, -}; - -const MIPSInstruction tableVFPU0[8] = -{ - INSTR("vadd",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vsub",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vsbn",&Jit::Comp_Generic, Dis_VectorSet3, Int_Vsbn, IS_VFPU), - {-2}, {-2}, {-2}, {-2}, - - INSTR("vdiv",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IS_VFPU|OUT_EAT_PREFIX), -}; - -const MIPSInstruction tableVFPU1[8] = // 011001 xxx -{ - INSTR("vmul",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vdot",&Jit::Comp_VDot, Dis_VectorDot, Int_VDot, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vscl",&Jit::Comp_VScl, Dis_VScl, Int_VScl, IS_VFPU|OUT_EAT_PREFIX), - {-2}, - INSTR("vhdp",&Jit::Comp_VHdp, Dis_Generic, Int_VHdp, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vcrs",&Jit::Comp_VCrs, Dis_Vcrs, Int_Vcrs, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vdet",&Jit::Comp_VDet, Dis_Generic, Int_Vdet, IS_VFPU|OUT_EAT_PREFIX), - {-2}, -}; - -const MIPSInstruction tableVFPU3[8] = //011011 xxx -{ - INSTR("vcmp",&Jit::Comp_Vcmp, Dis_Vcmp, Int_Vcmp, IS_VFPU|OUT_EAT_PREFIX), - {-2}, - INSTR("vmin",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vminmax, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmax",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vminmax, IS_VFPU|OUT_EAT_PREFIX), - {-2}, - INSTR("vscmp",&Jit::Comp_Generic, Dis_VectorSet3, Int_Vscmp, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vsge",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vsge, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vslt",&Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vslt, IS_VFPU|OUT_EAT_PREFIX), -}; - -const MIPSInstruction tableVFPU4Jump[32] = //110100 xxxxx -{ - {VFPU4}, - {VFPU7}, - {VFPU9}, - INSTR("vcst", &Jit::Comp_Vcst, Dis_Vcst, Int_Vcst, IS_VFPU|OUT_EAT_PREFIX), - {-2},{-2},{-2},{-2}, - + INSTR("mfc1", &Jit::Comp_mxc1, Dis_mxc1, Int_mxc1, IN_OTHER|OUT_RT), + INVALID, + INSTR("cfc1", &Jit::Comp_mxc1, Dis_mxc1, Int_mxc1, IN_OTHER|IN_FPUFLAG|OUT_RT), + INVALID, + INSTR("mtc1", &Jit::Comp_mxc1, Dis_mxc1, Int_mxc1, IN_RT|OUT_OTHER), + INVALID, + INSTR("ctc1", &Jit::Comp_mxc1, Dis_mxc1, Int_mxc1, IN_RT|OUT_FPUFLAG|OUT_OTHER), + INVALID, //8 - {-2},{-2},{-2},{-2}, - {-2},{-2},{-2},{-2}, - + ENCODING(Cop1BC), INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, //16 - INSTR("vf2in", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vf2iz", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vf2iu", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vf2id", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IS_VFPU|OUT_EAT_PREFIX), - //20 - INSTR("vi2f", &Jit::Comp_Vi2f, Dis_Vf2i, Int_Vi2f, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vcmov", &Jit::Comp_Vcmov, Dis_Vcmov,Int_Vcmov,IS_VFPU|OUT_EAT_PREFIX), - {-2}, - {-2}, - - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), - INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IS_VFPU), -}; - -const MIPSInstruction tableVFPU7[32] = -{ - INSTR("vrnds", &Jit::Comp_Generic, Dis_Generic, Int_Vrnds, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vrndi", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vrndf1", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vrndf2", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IS_VFPU|OUT_EAT_PREFIX), - - {-2},{-2},{-2},{-2}, - //8 - {-2},{-2},{-2},{-2}, - INSTR("vsbz", &Jit::Comp_Generic, Dis_Generic, Int_Vsbz, IS_VFPU), - {-2},{-2},{-2}, - //16 - {-2}, - {-2}, - INSTR("vf2h", &Jit::Comp_Generic, Dis_Generic, Int_Vf2h, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vh2f", &Jit::Comp_Generic, Dis_Generic, Int_Vh2f, IS_VFPU|OUT_EAT_PREFIX), - - {-2}, - {-2}, - {-2}, - INSTR("vlgb", &Jit::Comp_Generic, Dis_Generic, Int_Vlgb, IS_VFPU), + ENCODING(Cop1S), INVALID, INVALID, INVALID, + ENCODING(Cop1W), INVALID, INVALID, INVALID, //24 - INSTR("vuc2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IS_VFPU|OUT_EAT_PREFIX), // Seen in BraveStory, initialization 110100 00001110000 000 0001 0000 0000 - INSTR("vc2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vus2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vs2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IS_VFPU|OUT_EAT_PREFIX), + INVALID_X_8, +}; - INSTR("vi2uc", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vi2c", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vi2us", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vi2s", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IS_VFPU|OUT_EAT_PREFIX), +const MIPSInstruction tableCop1BC[32] = // 010001 01000 xxxxx ................ +{ + INSTR("bc1f", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_IMM16|IN_FPUFLAG|DELAYSLOT), + INSTR("bc1t", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_IMM16|IN_FPUFLAG|DELAYSLOT), + INSTR("bc1fl", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_IMM16|IN_FPUFLAG|DELAYSLOT|LIKELY), + INSTR("bc1tl", &Jit::Comp_FPUBranch, Dis_FPUBranch, Int_FPUBranch, IS_CONDBRANCH|IN_IMM16|IN_FPUFLAG|DELAYSLOT|LIKELY), + INVALID, INVALID, INVALID, INVALID, + //8 + INVALID_X_8, + INVALID_X_8, + INVALID_X_8, +}; + +const MIPSInstruction tableCop1S[64] = // 010001 10000 ..... ..... ..... xxxxxx +{ + INSTR("add.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, IN_OTHER|OUT_OTHER), + INSTR("sub.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, IN_OTHER|OUT_OTHER), + INSTR("mul.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, IN_OTHER|OUT_OTHER), + INSTR("div.s", &Jit::Comp_FPU3op, Dis_FPU3op, Int_FPU3op, IN_OTHER|OUT_OTHER), + INSTR("sqrt.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INSTR("abs.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INSTR("mov.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INSTR("neg.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + //8 + INVALID, INVALID, INVALID, INVALID, + INSTR("round.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INSTR("trunc.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INSTR("ceil.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INSTR("floor.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + //16 + INVALID_X_8, + //24 + INVALID_X_8, + //32 + INVALID, INVALID, INVALID, INVALID, + //36 + INSTR("cvt.w.s", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INVALID, + INSTR("dis.int", &Jit::Comp_Generic, Dis_Generic, Int_Interrupt, 0), + INVALID, + //40 + INVALID_X_8, + //48 - 010001 10000 ..... ..... ..... 11xxxx + INSTR("c.f", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.un", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.eq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.ueq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.olt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.ult", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.ole", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.ule", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.sf", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.ngle",&Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.seq", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.ngl", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.lt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.nge", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.le", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), + INSTR("c.ngt", &Jit::Comp_FPUComp, Dis_FPUComp, Int_FPUComp, IN_OTHER|OUT_FPUFLAG), +}; + +const MIPSInstruction tableCop1W[64] = // 010001 10100 ..... ..... ..... xxxxxx +{ + INVALID_X_8, + //8 + INVALID_X_8, + //16 + INVALID_X_8, + //24 + INVALID_X_8, + //32 + INSTR("cvt.s.w", &Jit::Comp_FPU2op, Dis_FPU2op, Int_FPU2op, IN_OTHER|OUT_OTHER), + INVALID, INVALID, INVALID, + //36 + INVALID, + INVALID, + INVALID, + INVALID, + //40 + INVALID_X_8, + //48 + INVALID_X_8, + INVALID_X_8, +}; + +const MIPSInstruction tableVFPU0[8] = // 011000 xxx ....... . ....... . ....... +{ + INSTR("vadd", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vsub", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vsbn", &Jit::Comp_Generic, Dis_VectorSet3, Int_Vsbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INVALID, INVALID, INVALID, INVALID, + + INSTR("vdiv", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), +}; + +const MIPSInstruction tableVFPU1[8] = // 011001 xxx ....... . ....... . ....... +{ + INSTR("vmul", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_VecDo3, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vdot", &Jit::Comp_VDot, Dis_VectorDot, Int_VDot, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vscl", &Jit::Comp_VScl, Dis_VScl, Int_VScl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INSTR("vhdp", &Jit::Comp_VHdp, Dis_Generic, Int_VHdp, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vcrs", &Jit::Comp_VCrs, Dis_Vcrs, Int_Vcrs, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vdet", &Jit::Comp_VDet, Dis_Generic, Int_Vdet, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, +}; + +const MIPSInstruction tableVFPU3[8] = // 011011 xxx ....... . ....... . ....... +{ + INSTR("vcmp", &Jit::Comp_Vcmp, Dis_Vcmp, Int_Vcmp, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INSTR("vmin", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vminmax, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmax", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vminmax, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INSTR("vscmp", &Jit::Comp_Generic, Dis_VectorSet3, Int_Vscmp, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vsge", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vsge, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vslt", &Jit::Comp_VecDo3, Dis_VectorSet3, Int_Vslt, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), +}; + +const MIPSInstruction tableVFPU4Jump[32] = // 110100 xxxxx ..... . ....... . ....... +{ + ENCODING(VFPU4), + ENCODING(VFPU7), + ENCODING(VFPU9), + INSTR("vcst", &Jit::Comp_Vcst, Dis_Vcst, Int_Vcst, OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, INVALID, INVALID, INVALID, + + //8 + INVALID_X_8, + + //16 + INSTR("vf2in", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vf2iz", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vf2iu", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vf2id", &Jit::Comp_Vf2i, Dis_Vf2i, Int_Vf2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + //20 + INSTR("vi2f", &Jit::Comp_Vi2f, Dis_Vf2i, Int_Vi2f, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vcmov", &Jit::Comp_Vcmov, Dis_Vcmov, Int_Vcmov, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INVALID, + //24 - 110100 11 ........ . ....... . ....... + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vwbn.s", &Jit::Comp_Generic, Dis_Generic, Int_Vwbn, IN_OTHER|OUT_OTHER|IS_VFPU), +}; + +const MIPSInstruction tableVFPU7[32] = // 110100 00001 xxxxx . ....... . ....... +{ + INSTR("vrnds", &Jit::Comp_Generic, Dis_Generic, Int_Vrnds, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vrndi", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vrndf1", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vrndf2", &Jit::Comp_Generic, Dis_Generic, Int_VrndX, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INVALID, INVALID, INVALID, INVALID, + //8 + INVALID, INVALID, INVALID, INVALID, + // TODO: Flags may not be correct (prefixes, etc.) Is this the correct encoding? Others say 10110. + INSTR("vsbz", &Jit::Comp_Generic, Dis_Generic, Int_Vsbz, IN_OTHER|OUT_OTHER|IS_VFPU), + INVALID, INVALID, INVALID, + //16 + INVALID, + INVALID, + INSTR("vf2h", &Jit::Comp_Generic, Dis_Generic, Int_Vf2h, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vh2f", &Jit::Comp_Generic, Dis_Generic, Int_Vh2f, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INVALID, + INVALID, + INVALID, + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vlgb", &Jit::Comp_Generic, Dis_Generic, Int_Vlgb, IN_OTHER|OUT_OTHER|IS_VFPU), + //24 + INSTR("vuc2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), // Seen in BraveStory, initialization 110100 00001110000 000 0001 0000 0000 + INSTR("vc2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vus2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vs2i", &Jit::Comp_Vx2i, Dis_Vs2i, Int_Vx2i, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INSTR("vi2uc", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vi2c", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vi2us", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vi2s", &Jit::Comp_Vi2x, Dis_Vi2x, Int_Vi2x, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), }; // 110100 00000 10100 0000000000000000 // 110100 00000 10111 0000000000000000 -const MIPSInstruction tableVFPU4[32] = //110100 00000 xxxxx +const MIPSInstruction tableVFPU4[32] = // 110100 00000 xxxxx . ....... . ....... { - INSTR("vmov", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX), - INSTR("vabs", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX), - INSTR("vneg", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX), - INSTR("vidt", &Jit::Comp_VIdt, Dis_VectorSet1, Int_Vidt,IS_VFPU|OUT_EAT_PREFIX), - INSTR("vsat0", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vsat1", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vzero", &Jit::Comp_VVectorInit, Dis_VectorSet1, Int_VVectorInit, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vone", &Jit::Comp_VVectorInit, Dis_VectorSet1, Int_VVectorInit, IS_VFPU|OUT_EAT_PREFIX), -//8 - {-2},{-2},{-2},{-2},{-2},{-2},{-2},{-2}, -//16 - INSTR("vrcp", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vrsq", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vsin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vcos", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vexp2", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vlog2", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vsqrt", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vasin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), -//24 - INSTR("vnrcp", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX), - {-2}, - INSTR("vnsin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX), - {-2}, - INSTR("vrexp2",&Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX), - {-2},{-2},{-2}, -//32 -}; - -MIPSInstruction tableVFPU5[8] = //110111 xxx -{ - INSTR("vpfxs",&Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IS_VFPU), - INSTR("vpfxs",&Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IS_VFPU), - INSTR("vpfxt",&Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IS_VFPU), - INSTR("vpfxt",&Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IS_VFPU), - INSTR("vpfxd", &Jit::Comp_VPFX, Dis_VPFXD, Int_VPFX, IS_VFPU), - INSTR("vpfxd", &Jit::Comp_VPFX, Dis_VPFXD, Int_VPFX, IS_VFPU), - INSTR("viim.s",&Jit::Comp_Viim, Dis_Viim,Int_Viim, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vfim.s",&Jit::Comp_Vfim, Dis_Viim,Int_Viim, IS_VFPU|OUT_EAT_PREFIX), -}; - -const MIPSInstruction tableVFPU6[32] = //111100 xxx -{ -//0 - INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmmul",&Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IS_VFPU|OUT_EAT_PREFIX), - - INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm2",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), -//8 - INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm3",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - - INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - INSTR("v(h)tfm4",&Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IS_VFPU|OUT_EAT_PREFIX), - //16 - INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmscl",&Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IS_VFPU|OUT_EAT_PREFIX), - - INSTR("vcrsp.t/vqmul.q",&Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vcrsp.t/vqmul.q",&Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vcrsp.t/vqmul.q",&Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vcrsp.t/vqmul.q",&Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IS_VFPU|OUT_EAT_PREFIX), -//24 - {-2}, - {-2}, - {-2}, - {-2}, - - {VFPUMatrix1}, - INSTR("vrot",&Jit::Comp_VRot, Dis_VRot, Int_Vrot, IS_VFPU|OUT_EAT_PREFIX), - {-2}, - {-2}, -}; - -const MIPSInstruction tableVFPUMatrixSet1[16] = //111100 11100 0xxxx (rm x is 16) -{ - INSTR("vmmov",&Jit::Comp_Vmmov, Dis_MatrixSet2, Int_Vmmov, IS_VFPU|OUT_EAT_PREFIX), - {-2}, - {-2}, - INSTR("vmidt",&Jit::Comp_VMatrixInit, Dis_MatrixSet1, Int_VMatrixInit, IS_VFPU|OUT_EAT_PREFIX), - - {-2}, - {-2}, - INSTR("vmzero", &Jit::Comp_VMatrixInit, Dis_MatrixSet1, Int_VMatrixInit, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vmone", &Jit::Comp_VMatrixInit, Dis_MatrixSet1, Int_VMatrixInit, IS_VFPU|OUT_EAT_PREFIX), - - {-2},{-2},{-2},{-2}, - {-2},{-2},{-2},{-2}, -}; - -const MIPSInstruction tableVFPU9[32] = //110100 00010 xxxxx -{ - INSTR("vsrt1", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt1, IS_VFPU), - INSTR("vsrt2", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt2, IS_VFPU), - INSTR("vbfy1", &Jit::Comp_Generic, Dis_Vbfy, Int_Vbfy, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vbfy2", &Jit::Comp_Generic, Dis_Vbfy, Int_Vbfy, IS_VFPU|OUT_EAT_PREFIX), - //4 - INSTR("vocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vocp, IS_VFPU|OUT_EAT_PREFIX), // one's complement - INSTR("vsocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsocp, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vfad", &Jit::Comp_Vhoriz, Dis_Vfad, Int_Vfad, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vavg", &Jit::Comp_Vhoriz, Dis_Vfad, Int_Vavg, IS_VFPU), + INSTR("vmov", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vabs", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vneg", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vidt", &Jit::Comp_VIdt, Dis_VectorSet1, Int_Vidt, OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vsat0", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vsat1", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vzero", &Jit::Comp_VVectorInit, Dis_VectorSet1, Int_VVectorInit, OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vone", &Jit::Comp_VVectorInit, Dis_VectorSet1, Int_VVectorInit, OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), //8 - INSTR("vsrt3", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt3, IS_VFPU), - INSTR("vsrt4", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt4, IS_VFPU), - INSTR("vsgn", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsgn, IS_VFPU|OUT_EAT_PREFIX), - {-2}, + INVALID_X_8, + //16 + INSTR("vrcp", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vrsq", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vsin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vcos", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vexp2", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vlog2", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vsqrt", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vasin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + //24 + INSTR("vnrcp", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INSTR("vnsin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INSTR("vrexp2", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, INVALID, INVALID, +}; + +MIPSInstruction tableVFPU5[8] = // 110111 xxx ....... ................ +{ + INSTR("vpfxs", &Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IN_IMM16|OUT_OTHER|IS_VFPU), + INSTR("vpfxs", &Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IN_IMM16|OUT_OTHER|IS_VFPU), + INSTR("vpfxt", &Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IN_IMM16|OUT_OTHER|IS_VFPU), + INSTR("vpfxt", &Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IN_IMM16|OUT_OTHER|IS_VFPU), + INSTR("vpfxd", &Jit::Comp_VPFX, Dis_VPFXD, Int_VPFX, IN_IMM16|OUT_OTHER|IS_VFPU), + INSTR("vpfxd", &Jit::Comp_VPFX, Dis_VPFXD, Int_VPFX, IN_IMM16|OUT_OTHER|IS_VFPU), + INSTR("viim.s", &Jit::Comp_Viim, Dis_Viim, Int_Viim, IN_IMM16|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vfim.s", &Jit::Comp_Vfim, Dis_Viim, Int_Viim, IN_IMM16|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), +}; + +const MIPSInstruction tableVFPU6[32] = // 111100 xxxxx ..... . ....... . ....... +{ + //0 + INSTR("vmmul", &Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmmul", &Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmmul", &Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmmul", &Jit::Comp_Vmmul, Dis_MatrixMult, Int_Vmmul, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INSTR("v(h)tfm2", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm2", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm2", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm2", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + //8 + INSTR("v(h)tfm3", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm3", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm3", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm3", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INSTR("v(h)tfm4", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm4", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm4", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("v(h)tfm4", &Jit::Comp_Vtfm, Dis_Vtfm, Int_Vtfm, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + //16 + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmscl", &Jit::Comp_Vmscl, Dis_Generic, Int_Vmscl, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INSTR("vcrsp.t/vqmul.q", &Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vcrsp.t/vqmul.q", &Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vcrsp.t/vqmul.q", &Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vcrsp.t/vqmul.q", &Jit::Comp_VCrossQuat, Dis_CrossQuat, Int_CrossQuat, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + //24 + INVALID, + INVALID, + INVALID, + INVALID, + //28 + ENCODING(VFPUMatrix1), + INSTR("vrot", &Jit::Comp_VRot, Dis_VRot, Int_Vrot, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INVALID, +}; + +// TODO: Should this only be when bit 20 is 0? +const MIPSInstruction tableVFPUMatrixSet1[16] = // 111100 11100 .xxxx . ....... . ....... (rm x is 16) +{ + INSTR("vmmov", &Jit::Comp_Vmmov, Dis_MatrixSet2, Int_Vmmov, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, + INVALID, + INSTR("vmidt", &Jit::Comp_VMatrixInit, Dis_MatrixSet1, Int_VMatrixInit, OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INVALID, + INVALID, + INSTR("vmzero", &Jit::Comp_VMatrixInit, Dis_MatrixSet1, Int_VMatrixInit, OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vmone", &Jit::Comp_VMatrixInit, Dis_MatrixSet1, Int_VMatrixInit, OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + + INVALID_X_8, +}; + +const MIPSInstruction tableVFPU9[32] = // 110100 00010 xxxxx . ....... . ....... +{ + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vsrt1", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt1, IN_OTHER|OUT_OTHER|IS_VFPU), + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vsrt2", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt2, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vbfy1", &Jit::Comp_Generic, Dis_Vbfy, Int_Vbfy, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vbfy2", &Jit::Comp_Generic, Dis_Vbfy, Int_Vbfy, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + //4 + INSTR("vocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vocp, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), // one's complement + INSTR("vsocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsocp, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vfad", &Jit::Comp_Vhoriz, Dis_Vfad, Int_Vfad, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vavg", &Jit::Comp_Vhoriz, Dis_Vfad, Int_Vavg, IN_OTHER|OUT_OTHER|IS_VFPU), + //8 + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vsrt3", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt3, IN_OTHER|OUT_OTHER|IS_VFPU), + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vsrt4", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt4, IN_OTHER|OUT_OTHER|IS_VFPU), + INSTR("vsgn", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsgn, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INVALID, //12 - {-2}, - {-2}, - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, + INVALID, //16 - INSTR("vmfvc", &Jit::Comp_Generic, Dis_Generic, Int_Vmfvc, IS_VFPU), - INSTR("vmtvc", &Jit::Comp_Generic, Dis_Generic, Int_Vmtvc, IS_VFPU), - {-2}, - {-2}, + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vmfvc", &Jit::Comp_Generic, Dis_Generic, Int_Vmfvc, IN_OTHER|OUT_OTHER|IS_VFPU), + // TODO: Flags may not be correct (prefixes, etc.) + INSTR("vmtvc", &Jit::Comp_Generic, Dis_Generic, Int_Vmtvc, IN_OTHER|OUT_OTHER|IS_VFPU), + INVALID, + INVALID, //20 - {-2},{-2},{-2},{-2}, + INVALID, INVALID, INVALID, INVALID, //24 - {-2}, - INSTR("vt4444", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vt5551", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU|OUT_EAT_PREFIX), - INSTR("vt5650", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU|OUT_EAT_PREFIX), - + INVALID, + INSTR("vt4444", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vt5551", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + INSTR("vt5650", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IN_OTHER|OUT_OTHER|IS_VFPU|OUT_EAT_PREFIX), + //28 - {-2},{-2},{-2},{-2}, + INVALID, INVALID, INVALID, INVALID, }; -const MIPSInstruction tableALLEGREX0[32] = //111111 +const MIPSInstruction tableALLEGREX0[32] = // 011111 ..... ..... ..... xxxxx 100000 - or ending with 011000? { - {-2}, - {-2}, - INSTR("wsbh",&Jit::Comp_Allegrex2, Dis_Allegrex2,Int_Allegrex2,0), - INSTR("wsbw",&Jit::Comp_Allegrex2, Dis_Allegrex2,Int_Allegrex2,0), - {-2}, {-2}, {-2}, {-2}, + INVALID, + INVALID, + INSTR("wsbh", &Jit::Comp_Allegrex2, Dis_Allegrex2, Int_Allegrex2, IN_RT|OUT_RD), + INSTR("wsbw", &Jit::Comp_Allegrex2, Dis_Allegrex2, Int_Allegrex2, IN_RT|OUT_RD), + INVALID, INVALID, INVALID, INVALID, //8 - {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, {-2}, + INVALID_X_8, //16 INSTR("seb", &Jit::Comp_Allegrex, Dis_Allegrex,Int_Allegrex, IN_RT|OUT_RD), - {-2}, - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, //20 - INSTR("bitrev",&Jit::Comp_Allegrex, Dis_Allegrex,Int_Allegrex, IN_RT|OUT_RD), - {-2}, - {-2}, - {-2}, + INSTR("bitrev", &Jit::Comp_Allegrex, Dis_Allegrex,Int_Allegrex, IN_RT|OUT_RD), + INVALID, + INVALID, + INVALID, //24 INSTR("seh", &Jit::Comp_Allegrex, Dis_Allegrex,Int_Allegrex, IN_RT|OUT_RD), - {-2}, - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, //28 - {-2}, - {-2}, - {-2}, - {-2}, + INVALID, + INVALID, + INVALID, + INVALID, }; const MIPSInstruction tableEMU[4] = { - INSTR("RUNBLOCK",&Jit::Comp_RunBlock,Dis_Emuhack,Int_Emuhack, 0xFFFFFFFF), - INSTR("RetKrnl", 0,Dis_Emuhack,Int_Emuhack, 0), - {-2}, - {-2}, + INSTR("RUNBLOCK", &Jit::Comp_RunBlock, Dis_Emuhack, Int_Emuhack, 0xFFFFFFFF), + INSTR("RetKrnl", 0, Dis_Emuhack, Int_Emuhack, 0), + INVALID, + INVALID, }; const int encodingBits[NumEncodings][2] = { - {26, 6}, //IMME - {0, 6}, //Special - {0, 6}, //special2 + {26, 6}, //IMME + {0, 6}, //Special + {0, 6}, //special2 {0, 6}, //special3 {16, 5}, //RegImm {21, 5}, //Cop0 {0, 6}, //Cop0CO {21, 5}, //Cop1 {16, 5}, //Cop1BC + {0, 6}, //Cop1S + {0, 6}, //Cop1W {21, 5}, //Cop2 {16, 2}, //Cop2BC2 {0, 0}, //Cop2Rese @@ -788,7 +843,7 @@ const int encodingBits[NumEncodings][2] = {16, 5}, //VFPU9 {6, 5}, //ALLEGREX0 {24, 2}, //EMUHACK -}; +}; const MIPSInstruction *mipsTables[NumEncodings] = @@ -802,6 +857,8 @@ const MIPSInstruction *mipsTables[NumEncodings] = tableCop0CO, tableCop1, tableCop1BC, + tableCop1S, + tableCop1W, tableCop2, tableCop2BC2, 0, @@ -838,7 +895,7 @@ const MIPSInstruction *MIPSGetInstruction(u32 op) { MipsEncoding encoding = Imme; const MIPSInstruction *instr = &tableImmediate[op>>26]; - while (instr->altEncoding != -1) + while (instr->altEncoding != -1) { const MIPSInstruction *table = mipsTables[encoding]; int mask = ((1<altEncoding; - } + } //alright, we have a valid MIPS instruction! return instr; } @@ -872,9 +929,9 @@ void MIPSCompileOp(u32 op) { if (instr->compile) (MIPSComp::jit->*(instr->compile))(op); // woohoo, member functions pointers! - else + else { - ERROR_LOG(CPU,"MIPSCompileOp %08x failed",op); + ERROR_LOG_REPORT(CPU,"MIPSCompileOp %08x failed",op); //MessageBox(0,"ARGH2",0,0);//compile an interpreter call } @@ -883,7 +940,7 @@ void MIPSCompileOp(u32 op) } else { - ERROR_LOG(CPU, "MIPSCompileOp: Invalid instruction %08x", op); + ERROR_LOG_REPORT(CPU, "MIPSCompileOp: Invalid instruction %08x", op); } } @@ -928,14 +985,14 @@ void MIPSInterpret(u32 op) //only for those rare ones if (instr && instr->interpret) instr->interpret(op); else - { - ERROR_LOG(CPU,"Unknown instruction %08x at %08x", op, currentMIPS->pc); - // Try to disassemble it - char disasm[256]; - MIPSDisAsm(op, currentMIPS->pc, disasm); + { + ERROR_LOG_REPORT(CPU, "Unknown instruction %08x at %08x", op, currentMIPS->pc); + // Try to disassemble it + char disasm[256]; + MIPSDisAsm(op, currentMIPS->pc, disasm); _dbg_assert_msg_(CPU, 0, "%s", disasm); - currentMIPS->pc += 4; - } + currentMIPS->pc += 4; + } } #define _RS ((op>>21) & 0x1F) @@ -1050,9 +1107,9 @@ MIPSInterpretFunc MIPSGetInterpretFunc(u32 op) // TODO: Do something that makes sense here. int MIPSGetInstructionCycleEstimate(u32 op) { - u32 info = MIPSGetInfo(op); - if (info & DELAYSLOT) - return 2; - else - return 1; + u32 info = MIPSGetInfo(op); + if (info & DELAYSLOT) + return 2; + else + return 1; } diff --git a/Core/MIPS/MIPSTables.h b/Core/MIPS/MIPSTables.h index c15e56a202..439e9c9fc2 100644 --- a/Core/MIPS/MIPSTables.h +++ b/Core/MIPS/MIPSTables.h @@ -30,10 +30,12 @@ // as long as the other flags are checked, // there is no way to misinterprete these // as CONDTYPE_X -#define MEMTYPE_MASK 0x00000003 +#define MEMTYPE_MASK 0x00000007 #define MEMTYPE_BYTE 0x00000001 #define MEMTYPE_HWORD 0x00000002 #define MEMTYPE_WORD 0x00000003 +#define MEMTYPE_FLOAT 0x00000004 +#define MEMTYPE_VQUAD 0x00000005 #define IS_CONDMOVE 0x00000008 #define DELAYSLOT 0x00000010 @@ -43,9 +45,9 @@ #define IS_CONDBRANCH 0x00000100 #define IS_JUMP 0x00000200 -#define IN_RS_SHIFT 0x00000400 -#define IN_RS_ADDR 0x00000800 -#define IN_RS 0x00001000 +#define IN_RS 0x00000400 +#define IN_RS_ADDR (0x00000800 | IN_RS) +#define IN_RS_SHIFT (0x00001000 | IN_RS) #define IN_RT 0x00002000 #define IN_SA 0x00004000 #define IN_IMM16 0x00008000 diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index 93201d1fe6..dc598ddec4 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -272,6 +272,73 @@ void Jit::Comp_SVQ(u32 op) switch (op >> 26) { + case 53: //lvl.q/lvr.q + { + if (!g_Config.bFastMemory) { + DISABLE; + } + DISABLE; + + gpr.BindToRegister(rs, true, true); + gpr.FlushLockX(ECX); + u8 vregs[4]; + GetVectorRegs(vregs, V_Quad, vt); + MOV(32, R(EAX), gpr.R(rs)); + ADD(32, R(EAX), Imm32(imm)); +#ifdef _M_IX86 + AND(32, R(EAX), Imm32(Memory::MEMVIEW32_MASK)); +#endif + MOV(32, R(ECX), R(EAX)); + SHR(32, R(EAX), Imm8(2)); + AND(32, R(EAX), Imm32(0x3)); + CMP(32, R(EAX), Imm32(0)); + FixupBranch next = J_CC(CC_NE); + + fpr.MapRegsV(vregs, V_Quad, MAP_DIRTY); + + // Offset = 0 + MOVSS(fpr.RX(vregs[3]), MRegSum(RBX, RAX)); + + FixupBranch skip0 = J(); + SetJumpTarget(next); + CMP(32, R(EAX), Imm32(1)); + next = J_CC(CC_NE); + + // Offset = 1 + MOVSS(fpr.RX(vregs[3]), MComplex(RBX, RAX, 1, 4)); + MOVSS(fpr.RX(vregs[2]), MComplex(RBX, RAX, 1, 0)); + + FixupBranch skip1 = J(); + SetJumpTarget(next); + CMP(32, R(EAX), Imm32(2)); + next = J_CC(CC_NE); + + // Offset = 2 + MOVSS(fpr.RX(vregs[3]), MComplex(RBX, RAX, 1, 8)); + MOVSS(fpr.RX(vregs[2]), MComplex(RBX, RAX, 1, 4)); + MOVSS(fpr.RX(vregs[1]), MComplex(RBX, RAX, 1, 0)); + + FixupBranch skip2 = J(); + SetJumpTarget(next); + CMP(32, R(EAX), Imm32(3)); + next = J_CC(CC_NE); + + // Offset = 3 + MOVSS(fpr.RX(vregs[3]), MComplex(RBX, RAX, 1, 12)); + MOVSS(fpr.RX(vregs[2]), MComplex(RBX, RAX, 1, 8)); + MOVSS(fpr.RX(vregs[1]), MComplex(RBX, RAX, 1, 4)); + MOVSS(fpr.RX(vregs[0]), MComplex(RBX, RAX, 1, 0)); + + SetJumpTarget(next); + SetJumpTarget(skip0); + SetJumpTarget(skip1); + SetJumpTarget(skip2); + + gpr.UnlockAll(); + fpr.ReleaseSpillLocks(); + } + break; + case 54: //lv.q { gpr.BindToRegister(rs, true, true); @@ -337,6 +404,8 @@ void Jit::Comp_SVQ(u32 op) } break; + + default: DISABLE; break; diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index a57d84921f..94dc089670 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -22,6 +22,7 @@ #include "Core/System.h" #include "Core/CoreTiming.h" #include "Core/Config.h" +#include "Core/Reporting.h" #include "Core/MIPS/MIPS.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/MIPSInt.h" @@ -338,7 +339,7 @@ void Jit::Comp_Generic(u32 op) ABI_CallFunctionC((void *)func, op); } else - _dbg_assert_msg_(JIT, 0, "Trying to compile instruction that can't be interpreted"); + ERROR_LOG_REPORT(JIT, "Trying to compile instruction that can't be interpreted"); const int info = MIPSGetInfo(op); if ((info & IS_VFPU) != 0 && (info & VFPU_NO_PREFIX) == 0) @@ -352,7 +353,7 @@ void Jit::Comp_Generic(u32 op) void Jit::WriteExit(u32 destination, int exit_num) { if (!Memory::IsValidAddress(destination)) { - ERROR_LOG(JIT, "Trying to write block exit to illegal destination %08x: pc = %08x", destination, currentMIPS->pc); + ERROR_LOG_REPORT(JIT, "Trying to write block exit to illegal destination %08x: pc = %08x", destination, currentMIPS->pc); } // If we need to verify coreState and rewind, we may not jump yet. if (js.afterOp & (JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE)) diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index f769497592..02aa55fef6 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -165,16 +165,6 @@ void Memset(const u32 _Address, const u8 _iValue, const u32 _iLength) } } -void Memcpy(const u32 to_address, const void *from_data, const u32 len) -{ - memcpy(GetPointer(to_address), from_data, len); -} - -void Memcpy(void *to_data, const u32 from_address, const u32 len) -{ - memcpy(to_data,GetPointer(from_address),len); -} - void GetString(std::string& _string, const u32 em_address) { char stringBuffer[2048]; diff --git a/Core/MemMap.h b/Core/MemMap.h index 1f10a6018a..71a2a2197a 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -117,6 +117,13 @@ u64 Read_U64(const u32 _Address); #define _M_ARM #endif +inline u8* GetPointerUnchecked(const u32 address) { +#if defined(_M_IX86) || defined(_M_ARM32) + return (u8 *)(base + (address & MEMVIEW32_MASK)); +#else + return (u8 *)(base + address); +#endif +} #ifdef SAFE_MEMORY u32 ReadUnchecked_U32(const u32 _Address); @@ -212,8 +219,30 @@ inline const char* GetCharPointer(const u32 address) { } void Memset(const u32 _Address, const u8 _Data, const u32 _iLength); -void Memcpy(const u32 to_address, const void *from_data, const u32 len); -void Memcpy(void *to_data, const u32 from_address, const u32 len); + +inline void Memcpy(const u32 to_address, const void *from_data, const u32 len) +{ + u8 *to = GetPointer(to_address); + if (to) { + memcpy(to, from_data, len); + } + // if not, GetPointer will log. +} + +inline void Memcpy(void *to_data, const u32 from_address, const u32 len) +{ + const u8 *from = GetPointer(from_address); + if (from) { + memcpy(to_data, from, len); + } + // if not, GetPointer will log. +} + +inline void MemcpyUnchecked(void *to_data, const u32 from_address, const u32 len) +{ + memcpy(to_data, GetPointerUnchecked(from_address), len); +} + template void ReadStruct(u32 address, T *ptr) diff --git a/Core/System.cpp b/Core/System.cpp index 13a6a2d459..2355f62585 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -20,6 +20,7 @@ #endif #include "native/thread/thread.h" +#include "native/thread/threadutil.h" #include "native/base/mutex.h" #include "Core/MemMap.h" @@ -42,7 +43,6 @@ #include "Core/PSPLoaders.h" #include "Core/ELF/ParamSFO.h" #include "Core/SaveState.h" -#include "Common/Thread.h" #include "Common/LogManager.h" #include "GPU/GPUState.h" @@ -196,7 +196,7 @@ void CPU_Shutdown() { } void CPU_RunLoop() { - Common::SetCurrentThreadName("CPUThread"); + setCurrentThreadName("CPUThread"); if (!CPU_NextState(CPU_THREAD_PENDING, CPU_THREAD_STARTING)) { ERROR_LOG(CPU, "CPU thread in unexpected state: %d", cpuThreadState); return; diff --git a/Core/ThreadEventQueue.h b/Core/ThreadEventQueue.h index 11231ea6ac..5d0b6d9d51 100644 --- a/Core/ThreadEventQueue.h +++ b/Core/ThreadEventQueue.h @@ -18,6 +18,7 @@ #pragma once #include "native/base/mutex.h" +#include "Core/System.h" #include "Core/CoreTiming.h" #include @@ -74,7 +75,7 @@ struct ThreadEventQueue : public B { } // Quit the loop if the queue is drained and coreState has tripped, or threading is disabled. - if (coreState != CORE_RUNNING || !threadEnabled_) { + if (ShouldExitEventLoop() || !threadEnabled_) { return; } @@ -104,6 +105,7 @@ struct ThreadEventQueue : public B { protected: virtual void ProcessEvent(Event ev) = 0; + virtual bool ShouldExitEventLoop() = 0; private: bool threadEnabled_; diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index cea3838d5b..d9f10db376 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -921,7 +921,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { shaderManager_->DirtyUniform(DIRTY_WORLDMATRIX); } num++; - gstate.worldmtxnum = (gstate.worldmtxnum & 0xFF000000) | (num & 0xF); + gstate.worldmtxnum = (GE_CMD_WORLDMATRIXNUMBER << 24) | (num & 0xF); } break; @@ -939,7 +939,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { shaderManager_->DirtyUniform(DIRTY_VIEWMATRIX); } num++; - gstate.viewmtxnum = (gstate.viewmtxnum & 0xFF000000) | (num & 0xF); + gstate.viewmtxnum = (GE_CMD_VIEWMATRIXNUMBER << 24) | (num & 0xF); } break; @@ -957,7 +957,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { shaderManager_->DirtyUniform(DIRTY_PROJMATRIX | DIRTY_PROJTHROUGHMATRIX); } num++; - gstate.projmtxnum = (gstate.projmtxnum & 0xFF000000) | (num & 0xF); + gstate.projmtxnum = (GE_CMD_PROJMATRIXNUMBER << 24) | (num & 0xF); } break; @@ -975,7 +975,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { shaderManager_->DirtyUniform(DIRTY_TEXMATRIX); } num++; - gstate.texmtxnum = (gstate.texmtxnum & 0xFF000000) | (num & 0xF); + gstate.texmtxnum = (GE_CMD_TGENMATRIXNUMBER << 24) | (num & 0xF); } break; @@ -993,7 +993,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { shaderManager_->DirtyUniform(DIRTY_BONEMATRIX0 << (num / 12)); } num++; - gstate.boneMatrixNumber = (gstate.boneMatrixNumber & 0xFF000000) | (num & 0x7F); + gstate.boneMatrixNumber = (GE_CMD_BONEMATRIXNUMBER << 24) | (num & 0x7F); } break; @@ -1120,11 +1120,6 @@ void GLES_GPU::ClearCacheNextFrame() { textureCache_.ClearNextFrame(); } - -inline void GLES_GPU::Flush() { - transformDraw_.Flush(); -} - void GLES_GPU::Resized() { framebufferManager_.Resized(); } diff --git a/GPU/GLES/DisplayListInterpreter.h b/GPU/GLES/DisplayListInterpreter.h index aa97f25fd0..76a4969480 100644 --- a/GPU/GLES/DisplayListInterpreter.h +++ b/GPU/GLES/DisplayListInterpreter.h @@ -69,7 +69,9 @@ protected: virtual void ProcessEvent(GPUEvent ev); private: - void Flush(); + void Flush() { + transformDraw_.Flush(); + } void DoBlockTransfer(); void ApplyDrawState(int prim); void CheckFlushOp(int cmd, u32 diff); diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 513835a742..1e55bb3703 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -392,8 +392,9 @@ void GuessDrawingSize(int &drawing_width, int &drawing_height) { int fb_stride = gstate.fbwidth & 0x3C0; GetViewportDimensions(viewport_width, viewport_height); - // Generated FBO shouldn't greate than 512x512 - if ( viewport_width > 512 && viewport_height > 512 ) { + // Generated FBO shouldn't greate than 512x512 + // Some games like FF Type-0 inits viewport as 0x0 + if ( viewport_width > 512 && viewport_height > 512 || viewport_width <= 1 && viewport_height <= 1 ) { viewport_width = default_width; viewport_height = default_height; } diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index a70bddbdf7..5234176d92 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -253,10 +253,6 @@ void TextureCache::NotifyFramebuffer(u32 address, VirtualFramebuffer *framebuffe } } -static u32 GetClutAddr() { - return ((gstate.clutaddr & 0xFFFFFF) | ((gstate.clutaddrupper << 8) & 0x0F000000)); -} - static u32 GetClutIndex(u32 index) { const u32 clutBase = gstate.getClutIndexStartPos(); const u32 clutMask = gstate.getClutIndexMask(); @@ -876,10 +872,10 @@ inline bool TextureCache::TexCacheEntry::Matches(u16 dim2, u8 format2, int maxLe } void TextureCache::LoadClut() { - u32 clutAddr = GetClutAddr(); + u32 clutAddr = ((gstate.clutaddr & 0xFFFFFF) | ((gstate.clutaddrupper << 8) & 0x0F000000)); clutTotalBytes_ = (gstate.loadclut & 0x3f) * 32; if (Memory::IsValidAddress(clutAddr)) { - Memory::Memcpy(clutBufRaw_, clutAddr, clutTotalBytes_); + Memory::MemcpyUnchecked(clutBufRaw_, clutAddr, clutTotalBytes_); } else { memset(clutBufRaw_, 0xFF, clutTotalBytes_); } diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index c087af9f74..a5a5e1cd0a 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -1109,10 +1109,7 @@ VertexArrayInfo::~VertexArrayInfo() { glDeleteBuffers(1, &ebo); } -void TransformDrawEngine::Flush() { - if (!numDrawCalls) - return; - +void TransformDrawEngine::DoFlush() { gpuStats.numFlushes++; gpuStats.numTrackedVertexArrays = (int)vai_.size(); diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index 20391c2163..98474748e1 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -100,7 +100,6 @@ public: void DrawBezier(int ucount, int vcount); void DrawSpline(int ucount, int vcount, int utype, int vtype); void DecodeVerts(); - void Flush(); void SetShaderManager(ShaderManager *shaderManager) { shaderManager_ = shaderManager; } @@ -122,7 +121,15 @@ public: // This requires a SetupVertexDecoder call first. int EstimatePerVertexCost(); + // So that this can be inlined + void Flush() { + if (!numDrawCalls) + return; + DoFlush(); + } + private: + void DoFlush(); void SoftwareTransformAndDraw(int prim, u8 *decoded, LinkedShader *program, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex); void ApplyDrawState(int prim); bool IsReallyAClear(int numVerts) const; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 6d610b5764..b4001a338f 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -20,7 +20,8 @@ GPUCommon::GPUCommon() : busyTicks(0), dumpNextFrame_(false), dumpThisFrame_(false), - interruptsEnabled_(true) + interruptsEnabled_(true), + curTickEst_(0) { memset(dls, 0, sizeof(dls)); for (int i = 0; i < DisplayListMaxCount; ++i) { @@ -579,6 +580,7 @@ bool GPUCommon::ProcessDLQueue() { void GPUCommon::ProcessDLQueueInternal() { startingTicks = CoreTiming::GetTicks(); cyclesExecuted = 0; + UpdateTickEstimate(std::max(busyTicks, startingTicks + cyclesExecuted)); if (startingTicks < busyTicks) { DEBUG_LOG(HLE, "Can't execute a list yet, still busy for %lld ticks", busyTicks - startingTicks); @@ -594,6 +596,7 @@ void GPUCommon::ProcessDLQueueInternal() { easy_guard guard(listLock); // At the end, we can remove it from the queue and continue. dlQueue.erase(std::remove(dlQueue.begin(), dlQueue.end(), listIndex), dlQueue.end()); + UpdateTickEstimate(std::max(busyTicks, startingTicks + cyclesExecuted)); } } @@ -603,6 +606,8 @@ void GPUCommon::ProcessDLQueueInternal() { drawCompleteTicks = startingTicks + cyclesExecuted; busyTicks = std::max(busyTicks, drawCompleteTicks); __GeTriggerSync(WAITTYPE_GEDRAWSYNC, 1, drawCompleteTicks); + // Since the event is in CoreTiming, we're in sync. Just set 0 now. + UpdateTickEstimate(0); } void GPUCommon::PreExecuteOp(u32 op, u32 diff) { diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 411021ea1f..4b4692271f 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -36,6 +36,11 @@ public: virtual u32 Break(int mode); virtual void ReapplyGfxState(); + virtual u64 GetTickEstimate() { + lock_guard guard(curTickEstLock_); + return curTickEst_; + } + protected: // To avoid virtual calls to PreExecuteOp(). virtual void FastRunLoop(DisplayList &list) = 0; @@ -48,6 +53,9 @@ protected: void ProcessDLQueueInternal(); void ReapplyGfxStateInternal(); virtual void ProcessEvent(GPUEvent ev); + virtual bool ShouldExitEventLoop() { + return coreState != CORE_RUNNING; + } // Allows early unlocking with a guard. Do not double unlock. class easy_guard { @@ -83,6 +91,15 @@ protected: bool dumpThisFrame_; bool interruptsEnabled_; + // For CPU/GPU sync. + volatile u64 curTickEst_; + recursive_mutex curTickEstLock_; + + virtual void UpdateTickEstimate(u64 value) { + lock_guard guard(curTickEstLock_); + curTickEst_ = value; + } + public: virtual DisplayList* getList(int listid) { diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index f98a16a923..9da055b53a 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -224,6 +224,7 @@ public: virtual void DeviceLost() = 0; virtual void ReapplyGfxState() = 0; virtual void SyncThread() = 0; + virtual u64 GetTickEstimate() = 0; virtual void DoState(PointerWrap &p) = 0; // Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*. diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 00928333b7..d990515908 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -100,6 +100,7 @@ void GameScreen::DrawBackground(UIContext &dc) { void GameScreen::update(InputState &input) { UIScreen::update(input); + I18NCategory *g = GetI18NCategory("General"); GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); if (tvTitle_) @@ -112,9 +113,9 @@ void GameScreen::update(InputState &input) { if (info->gameSize) { char temp[256]; - sprintf(temp, "Game: %1.1f MB", (float)(info->gameSize) / 1024.f / 1024.f); + sprintf(temp, "%s: %1.1f %s", g->T("Game"), (float) (info->gameSize) / 1024.f / 1024.f, g->T("MB")); tvGameSize_->SetText(temp); - sprintf(temp, "SaveData: %1.2f MB", (float)(info->saveDataSize) / 1024.f / 1024.f); + sprintf(temp, "%s: %1.2f %s", g->T("SaveData"), (float) (info->saveDataSize) / 1024.f / 1024.f, g->T("MB")); tvSaveDataSize_->SetText(temp); } } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 83baf7b788..c622886c7b 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -179,6 +179,7 @@ void GameSettingsScreen::CreateViews() { I18NCategory *c = GetI18NCategory("Controls"); I18NCategory *a = GetI18NCategory("Audio"); I18NCategory *s = GetI18NCategory("System"); + I18NCategory *ms = GetI18NCategory("MainSettings"); Margins actionMenuMargins(0, 0, 15, 0); @@ -200,7 +201,7 @@ void GameSettingsScreen::CreateViews() { ViewGroup *graphicsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); ViewGroup *graphicsSettings = new LinearLayout(ORIENT_VERTICAL); graphicsSettingsScroll->Add(graphicsSettings); - tabHolder->AddTab("Graphics", graphicsSettingsScroll); + tabHolder->AddTab(ms->T("Graphics"), graphicsSettingsScroll); graphicsSettings->Add(new ItemHeader(gs->T("Rendering Mode"))); #ifndef USING_GLES2 @@ -250,7 +251,7 @@ void GameSettingsScreen::CreateViews() { ViewGroup *audioSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); ViewGroup *audioSettings = new LinearLayout(ORIENT_VERTICAL); audioSettingsScroll->Add(audioSettings); - tabHolder->AddTab("Audio", audioSettingsScroll); + tabHolder->AddTab(ms->T("Audio"), audioSettingsScroll); std::string atracString; atracString.assign(Atrac3plus_Decoder::IsInstalled() ? "Redownload Atrac3+ plugin" : "Download Atrac3+ plugin"); @@ -265,7 +266,7 @@ void GameSettingsScreen::CreateViews() { ViewGroup *controlsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); ViewGroup *controlsSettings = new LinearLayout(ORIENT_VERTICAL); controlsSettingsScroll->Add(controlsSettings); - tabHolder->AddTab("Controls", controlsSettingsScroll); + tabHolder->AddTab(ms->T("Controls"), controlsSettingsScroll); controlsSettings->Add(new CheckBox(&g_Config.bShowTouchControls, c->T("OnScreen", "On-Screen Touch Controls"))); controlsSettings->Add(new CheckBox(&g_Config.bShowAnalogStick, c->T("Show Left Analog Stick"))); controlsSettings->Add(new CheckBox(&g_Config.bAccelerometerToAnalogHoriz, c->T("Tilt", "Tilt to Analog (horizontal)"))); @@ -276,7 +277,7 @@ void GameSettingsScreen::CreateViews() { ViewGroup *systemSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); ViewGroup *systemSettings = new LinearLayout(ORIENT_VERTICAL); systemSettingsScroll->Add(systemSettings); - tabHolder->AddTab("System", systemSettingsScroll); + tabHolder->AddTab(ms->T("System"), systemSettingsScroll); systemSettings->Add(new CheckBox(&g_Config.bJit, s->T("Dynarec", "Dynarec (JIT)"))); systemSettings->Add(new CheckBox(&g_Config.bSeparateCPUThread, s->T("Multithreaded (experimental)"))); systemSettings->Add(new CheckBox(&g_Config.bFastMemory, s->T("Fast Memory", "Fast Memory (Unstable)"))); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 261cc619a1..c6b0aba134 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -35,6 +35,7 @@ #include "UI/ui_atlas.h" #include "Core/Config.h" #include "GPU/GPUInterface.h" +#include "i18n/i18n.h" #ifdef _WIN32 namespace MainWindow { @@ -338,6 +339,8 @@ void MainScreen::CreateViews() { // Scrolling action menu to the right. using namespace UI; + I18NCategory *m = GetI18NCategory("MainMenu"); + Margins actionMenuMargins(0, 100, 15, 0); root_ = new LinearLayout(ORIENT_HORIZONTAL); @@ -357,9 +360,9 @@ void MainScreen::CreateViews() { scrollAllGames->Add(tabAllGames); scrollHomebrew->Add(tabHomebrew); - leftColumn->AddTab("Recent", scrollRecentGames); - leftColumn->AddTab("Games", scrollAllGames); - leftColumn->AddTab("Homebrew & Demos", scrollHomebrew); + leftColumn->AddTab(m->T("Recent"), scrollRecentGames); + leftColumn->AddTab(m->T("Games"), scrollAllGames); + leftColumn->AddTab(m->T("Homebrew & Demos"), scrollHomebrew); tabRecentGames->OnChoice.Handle(this, &MainScreen::OnGameSelected); tabAllGames->OnChoice.Handle(this, &MainScreen::OnGameSelected); @@ -384,12 +387,12 @@ void MainScreen::CreateViews() { rightColumn->Add(rightColumnItems); #ifdef _WIN32 - rightColumnItems->Add(new Choice("Load..."))->OnClick.Handle(this, &MainScreen::OnLoadFile); + rightColumnItems->Add(new Choice(m->T("Load","Load...")))->OnClick.Handle(this, &MainScreen::OnLoadFile); #endif - rightColumnItems->Add(new Choice("Settings"))->OnClick.Handle(this, &MainScreen::OnSettings); - rightColumnItems->Add(new Choice("Exit"))->OnClick.Handle(this, &MainScreen::OnExit); - rightColumnItems->Add(new Choice("Credits"))->OnClick.Handle(this, &MainScreen::OnCredits); - rightColumnItems->Add(new Choice("Support PPSSPP"))->OnClick.Handle(this, &MainScreen::OnSupport); + rightColumnItems->Add(new Choice(m->T("Settings")))->OnClick.Handle(this, &MainScreen::OnSettings); + rightColumnItems->Add(new Choice(m->T("Exit")))->OnClick.Handle(this, &MainScreen::OnExit); + rightColumnItems->Add(new Choice(m->T("Credits")))->OnClick.Handle(this, &MainScreen::OnCredits); + rightColumnItems->Add(new Choice(m->T("Support PPSSPP")))->OnClick.Handle(this, &MainScreen::OnSupport); } void MainScreen::sendMessage(const char *message, const char *value) { @@ -479,6 +482,8 @@ GamePauseScreen::~GamePauseScreen() { void GamePauseScreen::CreateViews() { using namespace UI; Margins actionMenuMargins(0, 100, 15, 0); + I18NCategory *gs = GetI18NCategory("Graphics"); + I18NCategory *i = GetI18NCategory("Pause"); root_ = new LinearLayout(ORIENT_HORIZONTAL); @@ -497,8 +502,8 @@ void GamePauseScreen::CreateViews() { saveSlots_->AddChoice("4"); saveSlots_->SetSelection(g_Config.iCurrentStateSlot); - leftColumnItems->Add(new Choice("Save State"))->OnClick.Handle(this, &GamePauseScreen::OnSaveState); - leftColumnItems->Add(new Choice("Load State"))->OnClick.Handle(this, &GamePauseScreen::OnLoadState); + leftColumnItems->Add(new Choice(gs->T("Save State")))->OnClick.Handle(this, &GamePauseScreen::OnSaveState); + leftColumnItems->Add(new Choice(gs->T("Load State")))->OnClick.Handle(this, &GamePauseScreen::OnLoadState); ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); root_->Add(rightColumn); @@ -506,10 +511,10 @@ void GamePauseScreen::CreateViews() { ViewGroup *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); rightColumn->Add(rightColumnItems); - rightColumnItems->Add(new Choice("Continue"))->OnClick.Handle(this, &GamePauseScreen::OnContinue); - rightColumnItems->Add(new Choice("Game Settings"))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); - rightColumnItems->Add(new Choice("Main Settings"))->OnClick.Handle(this, &GamePauseScreen::OnMainSettings); - rightColumnItems->Add(new Choice("Exit to menu"))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); + rightColumnItems->Add(new Choice(i->T("Continue")))->OnClick.Handle(this, &GamePauseScreen::OnContinue); + rightColumnItems->Add(new Choice(i->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); + rightColumnItems->Add(new Choice(i->T("Main Settings")))->OnClick.Handle(this, &GamePauseScreen::OnMainSettings); + rightColumnItems->Add(new Choice(i->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); } UI::EventReturn GamePauseScreen::OnMainSettings(UI::EventParams &e) { diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 6cc89ff506..28843df509 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -253,6 +253,7 @@ void MenuScreen::render() { VLinear vlinear(dp_xres + xoff, 100, 20); I18NCategory *m = GetI18NCategory("MainMenu"); + I18NCategory *p = GetI18NCategory("Plugin"); if (UIButton(GEN_ID, vlinear, w, 0, m->T("Load", "Load..."), ALIGN_RIGHT)) { #if defined(USING_QT_UI) && !defined(MEEGO_EDITION_HARMATTAN) @@ -312,7 +313,7 @@ void MenuScreen::render() { } if (showAtracShortcut_) { - if (UIButton(GEN_ID, Pos(10,dp_yres - 10), 500, 50, "Download audio plugin", ALIGN_BOTTOMLEFT)) { + if (UIButton(GEN_ID, Pos(10, dp_yres - 10), 500, 50, p->T("Download audio plugin"), ALIGN_BOTTOMLEFT)) { screenManager()->push(new PluginScreen()); } } @@ -844,6 +845,7 @@ void AudioScreen::render() { I18NCategory *g = GetI18NCategory("General"); I18NCategory *a = GetI18NCategory("Audio"); + I18NCategory *p = GetI18NCategory("Plugin"); ui_draw2d.SetFontScale(1.5f, 1.5f); ui_draw2d.DrawTextShadow(UBUNTU24, a->T("Audio Settings"), dp_xres / 2, 10, 0xFFFFFFFF, ALIGN_HCENTER); @@ -866,7 +868,7 @@ void AudioScreen::render() { // Show the download button even if not installed - might want to upgrade. VLinear vlinear(30, 400, 20); std::string atracString; - atracString.assign(Atrac3plus_Decoder::IsInstalled() ? "Redownload Atrac3+ plugin" : "Download Atrac3+ plugin"); + atracString.assign(Atrac3plus_Decoder::IsInstalled() ? p->T("Redownload Atrac3+ plugin") : p->T("Download Atrac3+ plugin")); if (UIButton(GEN_ID, vlinear, 400, 0, a->T(atracString.c_str()), ALIGN_LEFT)) { screenManager()->push(new PluginScreen()); } @@ -1544,7 +1546,7 @@ void SystemScreen::render() { char nickname[512]; memset(nickname, 0, sizeof(nickname)); - sprintf(nickname, "%s %s", s->T("System Nickname: "), g_Config.sNickName.c_str()); + sprintf(nickname, "%s %s", s->T("System Nickname:"), g_Config.sNickName.c_str()); ui_draw2d.DrawTextShadow(UBUNTU24, nickname, x, y += stride, 0xFFFFFFFF, ALIGN_LEFT); HLinear hlinearNick(x + 400, y, 10); diff --git a/UI/PluginScreen.cpp b/UI/PluginScreen.cpp index 185e2092f9..72466a1cf1 100644 --- a/UI/PluginScreen.cpp +++ b/UI/PluginScreen.cpp @@ -48,7 +48,7 @@ void PluginScreen::CreateViews() { Margins textMargins(20,17); Margins buttonMargins(10,10); - root_->Add(new TextView(UBUNTU24, "Atrac3+ Audio Support", ALIGN_HCENTER, 1.5f, new LinearLayoutParams(textMargins))); + root_->Add(new TextView(UBUNTU24, p->T("Atrac3+ Audio Support"), ALIGN_HCENTER, 1.5f, new LinearLayoutParams(textMargins))); ViewGroup *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0)); LinearLayout *scrollContents = new LinearLayout(ORIENT_VERTICAL); diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 45539ef2ef..8416b4f3a2 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -847,6 +847,7 @@ void CtrlDisAsmView::updateStatusBarText() sprintf(text,"[%08X] = %04X",info.dataAddress,Memory::Read_U16(info.dataAddress)); break; case 4: + // TODO: Could also be a float... { u32 data = Memory::Read_U32(info.dataAddress); const char* addressSymbol = debugger->findSymbolForAddress(data); @@ -858,6 +859,9 @@ void CtrlDisAsmView::updateStatusBarText() } break; } + case 16: + // TODO: vector + break; } } } diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 838d6be0e3..9f99b804fb 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -186,6 +186,7 @@ LOCAL_SRC_FILES := \ $(SRC)/Core/ELF/PrxDecrypter.cpp \ $(SRC)/Core/ELF/ParamSFO.cpp \ $(SRC)/Core/HW/atrac3plus.cpp \ + $(SRC)/Core/HW/AsyncIOManager.cpp \ $(SRC)/Core/HW/MemoryStick.cpp \ $(SRC)/Core/HW/MpegDemux.cpp.arm \ $(SRC)/Core/HW/OMAConvert.cpp.arm \ diff --git a/lang b/lang index 7c2893ed0c..12a1a4ed1d 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 7c2893ed0ca87ae096b45b5d4f88d60ccae2cd3b +Subproject commit 12a1a4ed1d2f030dfe16168b7ddbd323a7b265a3 diff --git a/native b/native index 0c8692bc44..549ef026fe 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 0c8692bc44715aa64b0e592c0001413fe0b80b1c +Subproject commit 549ef026fe9ea9d35495791e5c5c7de43e684105