From 5dd9ece98b13286eb16c36f6c48d1ed21040e3dc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Jun 2013 17:32:35 -0700 Subject: [PATCH 01/37] Ignore alpha when writing to display. --- GPU/GLES/Framebuffer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 860b2e29fd..2f83bb05fa 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -40,6 +40,7 @@ static const char tex_fs[] = "varying vec2 v_texcoord0;\n" "void main() {\n" " gl_FragColor = texture2D(sampler0, v_texcoord0);\n" + " gl_FragColor.a = 1.0;\n" "}\n"; static const char basic_vs[] = From 2ab16f13b10e62d8312c5ad6bf5bb9b33a11d63e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Jun 2013 21:22:28 -0700 Subject: [PATCH 02/37] If __KernelLoadExec() fails, halt emulation. Otherwise, we have no current thread, nothing can work. --- Core/HLE/sceKernelModule.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index ced7575ad1..a97d6808c5 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -995,6 +995,7 @@ int sceKernelLoadExec(const char *filename, u32 paramPtr) std::string error_string; if (!__KernelLoadExec(filename, param, &error_string)) { ERROR_LOG(HLE, "sceKernelLoadExec failed: %s", error_string.c_str()); + Core_UpdateState(CORE_ERROR); return -1; } return 0; From 2d769384e480594aba7800e0ac08fd97e4e5564c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Jun 2013 21:30:48 -0700 Subject: [PATCH 03/37] sceKernelLoadExec(.../BOOT.BIN) loads EBOOT.BIN. Fixes #2289, crash when pressing R+L+Start+Select in Final Fantasy 3. --- Core/HLE/sceKernelModule.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index a97d6808c5..c4e14f637c 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -18,6 +18,7 @@ #include #include +#include "native/base/stringutil.h" #include "Core/HLE/HLE.h" #include "Core/HLE/HLETables.h" #include "Core/Reporting.h" @@ -971,29 +972,39 @@ bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param, std:: //TODO: second param int sceKernelLoadExec(const char *filename, u32 paramPtr) { + std::string exec_filename = filename; SceKernelLoadExecParam *param = 0; - if (paramPtr) - { - param = (SceKernelLoadExecParam*)Memory::GetPointer(paramPtr); + if (paramPtr) { + param = (SceKernelLoadExecParam *)Memory::GetPointer(paramPtr); + } + + PSPFileInfo info = pspFileSystem.GetFileInfo(exec_filename); + + // If there's an EBOOT.BIN, redirect to that instead. + if (info.exists && endsWith(exec_filename, "/BOOT.BIN")) { + std::string eboot_filename = exec_filename.substr(0, exec_filename.length() - strlen("BOOT.BIN")) + "EBOOT.BIN"; + + PSPFileInfo eboot_info = pspFileSystem.GetFileInfo(eboot_filename); + if (eboot_info.exists) { + exec_filename = eboot_filename; + info = eboot_info; + } } - PSPFileInfo info = pspFileSystem.GetFileInfo(filename); - if (!info.exists) { ERROR_LOG(LOADER, "sceKernelLoadExec(%s, ...): File does not exist", filename); return SCE_KERNEL_ERROR_NOFILE; } s64 size = (s64)info.size; - if (!size) - { + if (!size) { ERROR_LOG(LOADER, "sceKernelLoadExec(%s, ...): File is size 0", filename); return SCE_KERNEL_ERROR_ILLEGAL_OBJECT; } - DEBUG_LOG(HLE,"sceKernelLoadExec(name=%s,...)", filename); + DEBUG_LOG(HLE, "sceKernelLoadExec(name=%s,...): loading %s", filename, exec_filename.c_str()); std::string error_string; - if (!__KernelLoadExec(filename, param, &error_string)) { + if (!__KernelLoadExec(exec_filename.c_str(), param, &error_string)) { ERROR_LOG(HLE, "sceKernelLoadExec failed: %s", error_string.c_str()); Core_UpdateState(CORE_ERROR); return -1; From 5c14ec134c967e601daa8c17675e16344ecc1087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 16 Jun 2013 12:41:41 +0200 Subject: [PATCH 04/37] Add support for external at3plus decoders on MacOSX 64bit. --- .gitignore | 5 +++++ Core/HW/atrac3plus.cpp | 31 +++++++++++++++++++++++-------- Core/HW/atrac3plus.h | 4 ++-- UI/MenuScreens.cpp | 12 +++++------- UI/NativeApp.cpp | 2 +- UI/PluginScreen.cpp | 17 +++++++++++++++-- 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index ce94486f63..51767a038d 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,8 @@ local.properties # For vim *.swp tags + +libat3plusdecoder.dylib +libat3plusdecoder.so +at3plusdecoder.dll +at3plusdecoder64.dll diff --git a/Core/HW/atrac3plus.cpp b/Core/HW/atrac3plus.cpp index 18407df95c..edb94585e0 100644 --- a/Core/HW/atrac3plus.cpp +++ b/Core/HW/atrac3plus.cpp @@ -1,4 +1,4 @@ -#ifdef _WIN32 +#ifdef _WIN32 #include #else #include @@ -11,17 +11,31 @@ #include #include - #include "base/logging.h" #include "Core/Config.h" #include "Common/FileUtil.h" #include "Core/HW/atrac3plus.h" +#ifdef __APPLE__ +#include "TargetConditionals.h" +#if TARGET_OS_MAC +#define MACOSX +#endif +#endif + extern std::string externalDirectory; namespace Atrac3plus_Decoder { -#ifdef _WIN32 + bool IsSupported() { +#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A) || defined(MACOSX) + return true; +#else + return false; +#endif + } + +#ifdef _WIN32 HMODULE hlib = 0; #else static void *so; @@ -43,6 +57,8 @@ namespace Atrac3plus_Decoder { #else return "at3plusdecoder.dll"; #endif +#elif defined(__APPLE__) + return "libat3plusdecoder.dylib"; #else return "libat3plusdecoder.so"; #endif @@ -67,7 +83,7 @@ namespace Atrac3plus_Decoder { // Other platforms can't. return false; } - + bool IsInstalled() { return File::Exists(GetInstalledFilename()); } @@ -105,8 +121,8 @@ namespace Atrac3plus_Decoder { // Okay, we're screwed. Let's bail. return -1; } - -#ifdef _WIN32 + +#ifdef _WIN32 #ifdef _M_X64 hlib = LoadLibraryA(GetInstalledFilename().c_str()); @@ -121,7 +137,6 @@ namespace Atrac3plus_Decoder { return -1; } #else - std::string filename = GetInstalledFilename(); ILOG("Attempting to load atrac3plus decoder from %s", filename.c_str()); @@ -149,7 +164,7 @@ namespace Atrac3plus_Decoder { } int Shutdown() { -#ifdef _WIN32 +#ifdef _WIN32 if (hlib) { FreeLibrary(hlib); hlib = 0; diff --git a/Core/HW/atrac3plus.h b/Core/HW/atrac3plus.h index 9d2c7cf41f..480733b4c4 100644 --- a/Core/HW/atrac3plus.h +++ b/Core/HW/atrac3plus.h @@ -2,7 +2,7 @@ #define _ATRAC3PLUS_DECODER_ namespace Atrac3plus_Decoder { - + bool IsSupported(); bool IsInstalled(); bool CanAutoInstall(); bool DoAutoInstall(); @@ -88,4 +88,4 @@ namespace Atrac3plus_Decoder { }; } -#endif // _ATRAC3PLUS_DECODER_ \ No newline at end of file +#endif // _ATRAC3PLUS_DECODER_ diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index fa501091c9..63142223a6 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -700,15 +700,13 @@ void AudioScreen::render() { } -#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A) - - VLinear vlinear(30, 300, 20); - if (!Atrac3plus_Decoder::IsInstalled() && UIButton(GEN_ID, vlinear, 400, 0, a->T("Download Atrac3+ plugin"), ALIGN_LEFT)) { - screenManager()->push(new PluginScreen()); + if (Atrac3plus_Decoder::IsSupported()) { + VLinear vlinear(30, 300, 20); + if (!Atrac3plus_Decoder::IsInstalled() && UIButton(GEN_ID, vlinear, 400, 0, a->T("Download Atrac3+ plugin"), ALIGN_LEFT)) { + screenManager()->push(new PluginScreen()); + } } -#endif - UIEnd(); } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 7a6a52dd61..8b226997e2 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -356,7 +356,7 @@ void NativeInitGraphics() { screenManager = new ScreenManager(); if (boot_filename.empty()) { -#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A) +#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A) || (defined(MACOSX) && defined(_M_IX64)) if (Atrac3plus_Decoder::CanAutoInstall()) { Atrac3plus_Decoder::DoAutoInstall(); screenManager->switchScreen(new LogoScreen(boot_filename)); diff --git a/UI/PluginScreen.cpp b/UI/PluginScreen.cpp index 171a950482..bbc37c8b2c 100644 --- a/UI/PluginScreen.cpp +++ b/UI/PluginScreen.cpp @@ -25,6 +25,13 @@ #include "UI/ui_atlas.h" #include "Core/HW/atrac3plus.h" +#ifdef __APPLE__ +#include "TargetConditionals.h" +#if TARGET_OS_MAC +#define MACOSX +#endif +#endif + void DrawBackground(float alpha); void PluginScreen::DrawBackground(UIContext &dc) @@ -108,17 +115,23 @@ void PluginScreen::update(InputState &input) { abi = "armeabi"; #elif defined(ARMEABI_V7A) abi = "armeabi-v7a"; +#elif defined(MACOSX) + abi = "MacOSX64"; #endif + const char *notSupportedText = p->T("SorryNoDownload", "Sorry, there is no automatic download of the decoder\navailable for this platform."); if (!abi.empty()) { at3plusdecoderUrl_ = root->getString(abi.c_str(), ""); if (at3plusdecoderUrl_.empty()) { buttonDownload_->SetEnabled(false); + tvDescription_->SetText(notSupportedText); } else { buttonDownload_->SetEnabled(true); - const char *notInstalledText = p->T("To download and install", "To download and install Mai's Atrac3+ decoding support, click Download.\n"); - const char *reInstallText = p->T("Already installed", "Mai's Atrac3+ decoder already installed.\nWould you like to redownload and reinstall it?\n"); + const char *notInstalledText = p->T("To download and install", "To download and install Mai's Atrac3+ decoding\n support, click Download."); + const char *reInstallText = p->T("Already installed", "Mai's Atrac3+ decoder already installed.\nWould you like to redownload and reinstall it?"); tvDescription_->SetText(Atrac3plus_Decoder::IsInstalled() ? reInstallText : notInstalledText); } + } else { + tvDescription_->SetText(notSupportedText); } } From 503b9d9e2bfbd200f230042e638b75179ebb6a61 Mon Sep 17 00:00:00 2001 From: Sacha Date: Sun, 16 Jun 2013 21:08:16 +1000 Subject: [PATCH 05/37] Fix Blackberry10 building on non-Windows systems. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa5e2b0fac..0f239355e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,7 @@ endif() include_directories("${CMAKE_SOURCE_DIR}") if(BLACKBERRY) + set(CMAKE_SYSTEM_NAME "QNX") add_definitions(-DBLACKBERRY) if(BLACKBERRY VERSION_GREATER 10) add_definitions(-DBLACKBERRY10) From 00540ea44c7d4738037d96f5ddbb78b2c554fd26 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Jun 2013 23:04:43 -0700 Subject: [PATCH 06/37] Hash/convert more when a CLUT base is used. This seems a bit strange, but the games that use these bases seem to read outside the loaded CLUT to a previously loaded CLUT. May cause a performance issue on games that use a base but don't do this. --- GPU/GLES/TextureCache.cpp | 28 +++++++++++++++------------- GPU/GLES/TextureCache.h | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 180c2530bc..8506ff03de 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -809,27 +809,29 @@ void TextureCache::LoadClut() { u32 clutAddr = GetClutAddr(); clutTotalBytes_ = (gstate.loadclut & 0x3f) * 32; if (Memory::IsValidAddress(clutAddr)) { - Memory::Memcpy((u8 *)clutBufRaw_, clutAddr, clutTotalBytes_); + Memory::Memcpy(clutBufRaw_, clutAddr, clutTotalBytes_); } else { memset(clutBufRaw_, 0xFF, clutTotalBytes_); - clutHash_ = 0; } // Reload the clut next time. - clutLastFormat_ = 0xFF; + clutLastFormat_ = 0xFFFFFFFF; } void TextureCache::UpdateCurrentClut() { - // 0xFF is an invalid format, it means not yet hashed or updated. - if (clutLastFormat_ == 0xFF) { - // QuickClutHash is not quite good enough apparently. - // clutHash_ = QuickClutHash((const u8 *)clutBufRaw_, clutTotalBytes_); - clutHash_ = CityHash32((const char *)clutBufRaw_, clutTotalBytes_); - } + const GEPaletteFormat clutFormat = (GEPaletteFormat)(gstate.clutformat & 3); + const u32 clutBase = (gstate.clutformat & 0x1f0000) >> 12; + const u32 clutBaseBytes = clutBase * (clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16)); + // Technically, these extra bytes weren't loaded, but hopefully it was loaded earlier. + // If not, we're going to hash random data, which hopefully doesn't cause a performance issue. + const u32 clutExtendedBytes = clutTotalBytes_ + clutBaseBytes; + + // QuickClutHash is not quite good enough apparently. + // clutHash_ = QuickClutHash((const u8 *)clutBufRaw_, clutExtendedBytes); + clutHash_ = CityHash32((const char *)clutBufRaw_, clutExtendedBytes); - GEPaletteFormat clutFormat = (GEPaletteFormat)(gstate.clutformat & 3); // Avoid a copy when we don't need to convert colors. if (clutFormat != GE_CMODE_32BIT_ABGR8888) { - ConvertColors(clutBufConverted_, clutBufRaw_, getClutDestFormat(clutFormat), clutTotalBytes_ / sizeof(u16)); + ConvertColors(clutBufConverted_, clutBufRaw_, getClutDestFormat(clutFormat), clutExtendedBytes / sizeof(u16)); clutBuf_ = clutBufConverted_; } else { clutBuf_ = clutBufRaw_; @@ -855,7 +857,7 @@ void TextureCache::UpdateCurrentClut() { } } - clutLastFormat_ = clutFormat; + clutLastFormat_ = gstate.clutformat; } template @@ -888,7 +890,7 @@ void TextureCache::SetTexture() { u32 clutformat, cluthash; if (hasClut) { clutformat = gstate.clutformat & 3; - if (clutLastFormat_ != clutformat) { + if (clutLastFormat_ != gstate.clutformat) { // We update here because the clut format can be specified after the load. UpdateCurrentClut(); } diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index 92b76e2cf1..361885f41c 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -127,7 +127,7 @@ private: SimpleBuf tmpTexBufRearrange; - u8 clutLastFormat_; + u32 clutLastFormat_; u32 *clutBufRaw_; u32 *clutBufConverted_; u32 *clutBuf_; From c1ed09949d31df085edf670e2b8dca1ca6c5c60d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 09:11:19 -0700 Subject: [PATCH 07/37] Initial impl of sceIoGetFdList(). --- Core/HLE/sceIo.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index c880dd69d7..8e23491cd4 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -1372,7 +1372,7 @@ u32 sceIoPollAsync(int id, u32 address) { } return 0; //completed } else { - WARN_LOG(HLE, "SCE_KERNEL_ERROR_NOASYNC = sceIoWaitAsyncCB(%i, %08x)", id, address); + WARN_LOG(HLE, "SCE_KERNEL_ERROR_NOASYNC = sceIoPollAsync(%i, %08x)", id, address); return SCE_KERNEL_ERROR_NOASYNC; } } else { @@ -1608,9 +1608,33 @@ u32 sceIoIoctlAsync(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u } } +struct GetFdListArg { + u32 outAddr; + int outLeft; + int total; +}; + +bool __GetFdListIterator(FileNode *f, GetFdListArg *state) { + ++state->total; + if (Memory::IsValidAddress(state->outAddr) && state->outLeft > 0) { + Memory::Write_U32(f->GetUID(), state->outAddr); + state->outAddr += 4; + --state->outLeft; + } + return true; +} + u32 sceIoGetFdList(u32 outAddr, int outSize, u32 fdNumAddr) { - ERROR_LOG_REPORT(HLE, "UNIMPL sceIoGetFdList(%08x, %i, %08x)", outAddr, outSize, fdNumAddr); - return 0; + WARN_LOG(HLE, "sceIoGetFdList(%08x, %i, %08x)", outAddr, outSize, fdNumAddr); + GetFdListArg arg; + arg.outAddr = outAddr; + arg.outLeft = outSize; + arg.total = 0; + + kernelObjects.Iterate(&__GetFdListIterator, &arg, PPSSPP_KERNEL_TMID_File); + if (Memory::IsValidAddress(fdNumAddr)) + Memory::Write_U32(arg.total, fdNumAddr); + return outSize - arg.outLeft; } // Presumably lets you hook up stderr to a MsgPipe. From 2bc3da5b94ff01680854b6ed6e3c1ff87fa5b2fc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 10:05:30 -0700 Subject: [PATCH 08/37] Return fds in the range 0 - 64 like the PSP. Some games appear to check ids are valid specifically by checking this range. Reproduced on a PSP. --- Core/HLE/sceIo.cpp | 191 ++++++++++++++++++++++++++++++--------------- 1 file changed, 126 insertions(+), 65 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 8e23491cd4..3a4204acc5 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -97,7 +97,12 @@ typedef s32 SceMode; typedef s64 SceOff; typedef u64 SceIores; -int asyncNotifyEvent = -1; +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 SceUID fds[PSP_COUNT_FDS]; + u32 ioErrorCode = 0; #define SCE_STM_FDIR 0x1000 @@ -213,12 +218,43 @@ public: /******************************************************************************/ -void __IoCompleteAsyncIO(SceUID id); +void __IoCompleteAsyncIO(int fd); static void TellFsThreadEnded (SceUID threadID) { pspFileSystem.ThreadEnded(threadID); } +FileNode *__IoGetFd(int fd, u32 &error) { + if (fd < 0 || fd >= PSP_COUNT_FDS) { + error = ERROR_KERNEL_BAD_FILE_DESCRIPTOR; + return NULL; + } + + return kernelObjects.Get(fds[fd], error); +} + +int __IoAllocFd(FileNode *f) { + // The PSP takes the lowest available id after stderr/etc. + for (int possible = PSP_MIN_FD; possible < PSP_COUNT_FDS; ++possible) { + if (fds[possible] == 0) { + fds[possible] = f->GetUID(); + return possible; + } + } + + // Bugger, out of fds... + return SCE_KERNEL_ERROR_MFILE; +} + +void __IoFreeFd(int fd, u32 &error) { + if (fd < PSP_MIN_FD || fd >= PSP_COUNT_FDS) { + error = ERROR_KERNEL_BAD_FILE_DESCRIPTOR; + } else { + error = kernelObjects.Destroy(fds[fd]); + fds[fd] = 0; + } +} + // Async IO seems to work roughly like this: // 1. Game calls SceIo*Async() to start the process. // 2. This runs a thread with a customizable priority. @@ -236,7 +272,7 @@ static void TellFsThreadEnded (SceUID threadID) { // For now, let's at least delay the callback mnotification. void __IoAsyncNotify(u64 userdata, int cyclesLate) { SceUID threadID = userdata >> 32; - SceUID fd = (SceUID) (userdata & 0xFFFFFFFF); + int fd = (int) (userdata & 0xFFFFFFFF); __IoCompleteAsyncIO(fd); u32 error; @@ -245,14 +281,14 @@ void __IoAsyncNotify(u64 userdata, int cyclesLate) { if (waitID == fd && error == 0) { __KernelResumeThreadFromWait(threadID, 0); - FileNode *f = kernelObjects.Get(fd, error); + FileNode *f = __IoGetFd(fd, error); if (Memory::IsValidAddress(address) && f) { Memory::Write_U64((u64) f->asyncResult, address); } // If this was a sceIoCloseAsync, we should close it at this point. if (f->closePending) { - kernelObjects.Destroy(fd); + __IoFreeFd(fd, error); } } } @@ -280,9 +316,12 @@ void __IoInit() { pspFileSystem.Mount("flash0:", flash0); __KernelListenThreadEnd(&TellFsThreadEnded); + + memset(fds, 0, sizeof(fds)); } void __IoDoState(PointerWrap &p) { + p.DoArray(fds, ARRAY_SIZE(fds)); p.Do(asyncNotifyEvent); CoreTiming::RestoreRegisterEvent(asyncNotifyEvent, "IoAsyncNotify", __IoAsyncNotify); } @@ -292,9 +331,9 @@ void __IoShutdown() { u32 __IoGetFileHandleFromId(u32 id, u32 &outError) { - FileNode *f = kernelObjects.Get < FileNode > (id, outError); + FileNode *f = __IoGetFd(id, outError); if (!f) { - return -1; + return (u32)-1; } return f->handle; } @@ -342,9 +381,9 @@ u32 sceKernelStderr() { return 2; } -void __IoCompleteAsyncIO(SceUID id) { +void __IoCompleteAsyncIO(int fd) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(fd, error); if (f) { if (f->callbackID) { __KernelNotifyCallback(THREAD_CALLBACK_IO, f->callbackID, f->callbackArg); @@ -384,7 +423,7 @@ void __IoGetStat(SceIoStat *stat, PSPFileInfo &info) { stat->st_private[0] = info.startSector; } -void __IoSchedAsync(FileNode *f, SceUID fd, int usec) { +void __IoSchedAsync(FileNode *f, int fd, int usec) { u64 param = ((u64)__KernelGetCurThread()) << 32 | fd; CoreTiming::ScheduleEvent(usToCycles(usec), asyncNotifyEvent, param); @@ -478,7 +517,7 @@ int __IoRead(int id, u32 data_addr, int size) { } u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { if(!(f->openMode & FILEACCESS_READ)) { @@ -520,7 +559,7 @@ u32 sceIoRead(int id, u32 data_addr, int size) { u32 sceIoReadAsync(int id, u32 data_addr, int size) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, 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...) @@ -542,7 +581,7 @@ int __IoWrite(int id, void *data_ptr, int size) { return size; } u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { if(!(f->openMode & FILEACCESS_WRITE)) { return ERROR_KERNEL_BAD_FILE_DESCRIPTOR; @@ -574,7 +613,7 @@ u32 sceIoWrite(int id, u32 data_addr, int size) { u32 sceIoWriteAsync(int id, u32 data_addr, int size) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, 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...) @@ -591,7 +630,7 @@ u32 sceIoGetDevType(int id) { ERROR_LOG_REPORT(HLE, "UNIMPL sceIoGetDevType(%d)", id); u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); int result; if (f) result = PSP_DEV_TYPE_ALIAS; @@ -607,7 +646,7 @@ u32 sceIoCancel(int id) { ERROR_LOG_REPORT(HLE, "UNIMPL sceIoCancel(%d)", id); u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { // TODO: Cancel the async operation if possible? } else { @@ -643,7 +682,7 @@ u32 npdrmLseek(FileNode *f, s32 where, FileMove whence) s64 __IoLseek(SceUID id, s64 offset, int whence) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { FileMove seek = FILEMOVE_BEGIN; @@ -700,7 +739,7 @@ u32 sceIoLseek32(int id, int offset, int whence) { u32 sceIoLseekAsync(int id, s64 offset, int whence) { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = __IoGetFd(id, error); if (f) { f->asyncResult = __IoLseek(id, offset, whence); // Educated guess at timing. @@ -716,7 +755,7 @@ u32 sceIoLseekAsync(int id, s64 offset, int whence) { u32 sceIoLseek32Async(int id, int offset, int whence) { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = __IoGetFd(id, error); if (f) { f->asyncResult = __IoLseek(id, offset, whence); // Educated guess at timing. @@ -785,18 +824,24 @@ u32 sceIoOpen(const char* filename, int flags, int mode) { } } - SceUID id = f->GetUID(); - DEBUG_LOG(HLE, "%i=sceIoOpen(%s, %08x, %08x)", id, filename, flags, mode); - // Timing is not accurate, aiming low for now. - return hleDelayResult(id, "file opened", 100); + int id = __IoAllocFd(f); + if (id < 0) { + ERROR_LOG(HLE, "%08x=sceIoOpen(%s, %08x, %08x): out of fds", id, filename, flags, mode); + kernelObjects.Destroy(f->GetUID()); + return id; + } else { + DEBUG_LOG(HLE, "%i=sceIoOpen(%s, %08x, %08x)", id, filename, flags, mode); + // Timing is not accurate, aiming low for now. + return hleDelayResult(id, "file opened", 100); + } } u32 sceIoClose(int id) { u32 error; DEBUG_LOG(HLE, "sceIoClose(%d)", id); - FileNode *f = kernelObjects.Get(id, error); + __IoFreeFd(id, error); // Timing is not accurate, aiming low for now. - return hleDelayResult(kernelObjects.Destroy(id), "file closed", 100); + return hleDelayResult(error, "file closed", 100); } u32 sceIoRemove(const char *filename) { @@ -1197,7 +1242,7 @@ int sceIoCloseAsync(int id) { DEBUG_LOG(HLE, "sceIoCloseAsync(%d)", id); u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = __IoGetFd(id, error); if (f) { f->closePending = true; @@ -1215,7 +1260,7 @@ u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg) DEBUG_LOG(HLE, "sceIoSetAsyncCallback(%d, %i, %08x)", id, clbckId, clbckArg); u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { f->callbackID = clbckId; @@ -1236,7 +1281,7 @@ u32 sceIoOpenAsync(const char *filename, int flags, int mode) sceKernelResumeDispatchThread(1); FileNode *f = __IoOpen(filename, flags, mode); - SceUID fd; + int fd; // We have to return an fd here, which may have been destroyed when we reach Wait if it failed. if (f == NULL) @@ -1244,16 +1289,26 @@ u32 sceIoOpenAsync(const char *filename, int flags, int mode) ERROR_LOG(HLE, "ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpenAsync(%s, %08x, %08x) - file not found", filename, flags, mode); f = new FileNode(); - fd = kernelObjects.Create(f); - f->handle = fd; + f->handle = kernelObjects.Create(f); f->fullpath = filename; f->asyncResult = ERROR_ERRNO_FILE_NOT_FOUND; f->closePending = true; + + fd = __IoAllocFd(f); } else { - fd = f->GetUID(); - DEBUG_LOG(HLE, "%x=sceIoOpenAsync(%s, %08x, %08x)", fd, filename, flags, mode); + fd = __IoAllocFd(f); + if (fd >= 0) { + DEBUG_LOG(HLE, "%x=sceIoOpenAsync(%s, %08x, %08x)", fd, filename, flags, mode); + f->asyncResult = fd; + } + } + + if (fd < 0) { + ERROR_LOG(HLE, "%08x=sceIoOpenAsync(%s, %08x, %08x): out of fds", fd, filename, flags, mode); + kernelObjects.Destroy(f->GetUID()); + return fd; } // TODO: Timing is very inconsistent. From ms0, 10ms - 20ms depending on filesize/dir depth? From umd, can take > 1s. @@ -1266,7 +1321,7 @@ u32 sceIoOpenAsync(const char *filename, int flags, int mode) u32 sceIoGetAsyncStat(int id, u32 poll, u32 address) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { if (f->pendingAsyncResult) { @@ -1286,7 +1341,7 @@ u32 sceIoGetAsyncStat(int id, u32 poll, u32 address) f->hasAsyncResult = false; if (f->closePending) { - kernelObjects.Destroy(id); + __IoFreeFd(id, error); } } else { WARN_LOG(HLE, "SCE_KERNEL_ERROR_NOASYNC = sceIoGetAsyncStat(%i, %i, %08x)", id, poll, address); @@ -1303,7 +1358,7 @@ u32 sceIoGetAsyncStat(int id, u32 poll, u32 address) int sceIoWaitAsync(int id, u32 address) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { if (f->pendingAsyncResult) { DEBUG_LOG(HLE, "%lli = sceIoWaitAsync(%i, %08x): waiting", f->asyncResult, id, address); @@ -1314,7 +1369,7 @@ int sceIoWaitAsync(int id, u32 address) { f->hasAsyncResult = false; if (f->closePending) { - kernelObjects.Destroy(id); + __IoFreeFd(id, error); } } else { WARN_LOG(HLE, "SCE_KERNEL_ERROR_NOASYNC = sceIoWaitAsync(%i, %08x)", id, address); @@ -1330,7 +1385,7 @@ int sceIoWaitAsync(int id, u32 address) { int sceIoWaitAsyncCB(int id, u32 address) { // Should process callbacks here u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { hleCheckCurrentCallbacks(); if (f->pendingAsyncResult) { @@ -1342,7 +1397,7 @@ int sceIoWaitAsyncCB(int id, u32 address) { f->hasAsyncResult = false; if (f->closePending) { - kernelObjects.Destroy(id); + __IoFreeFd(id, error); } } else { WARN_LOG(HLE, "SCE_KERNEL_ERROR_NOASYNC = sceIoWaitAsyncCB(%i, %08x)", id, address); @@ -1357,7 +1412,7 @@ int sceIoWaitAsyncCB(int id, u32 address) { u32 sceIoPollAsync(int id, u32 address) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { if (f->pendingAsyncResult) { DEBUG_LOG(HLE, "%lli = sceIoPollAsync(%i, %08x): not ready", f->asyncResult, id, address); @@ -1368,7 +1423,7 @@ u32 sceIoPollAsync(int id, u32 address) { f->hasAsyncResult = false; if (f->closePending) { - kernelObjects.Destroy(id); + __IoFreeFd(id, error); } return 0; //completed } else { @@ -1465,7 +1520,7 @@ u32 sceIoDclose(int id) { int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen) { u32 error; - FileNode *f = kernelObjects.Get(id, error); + FileNode *f = __IoGetFd(id, error); if (error) { ERROR_LOG(HLE, "UNIMPL %08x=sceIoIoctl id: %08x, cmd %08x, bad file", error, id, cmd); return error; @@ -1596,7 +1651,7 @@ u32 sceIoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 ou u32 sceIoIoctlAsync(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen) { u32 error; - FileNode *f = kernelObjects.Get < FileNode > (id, error); + FileNode *f = __IoGetFd(id, error); if (f) { DEBUG_LOG(HLE, "sceIoIoctlAsync(%08x, %08x, %08x, %08x, %08x, %08x)", id, cmd, indataPtr, inlen, outdataPtr, outlen); f->asyncResult = __IoIoctl(id, cmd, indataPtr, inlen, outdataPtr, outlen); @@ -1608,33 +1663,39 @@ u32 sceIoIoctlAsync(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u } } -struct GetFdListArg { - u32 outAddr; - int outLeft; - int total; -}; - -bool __GetFdListIterator(FileNode *f, GetFdListArg *state) { - ++state->total; - if (Memory::IsValidAddress(state->outAddr) && state->outLeft > 0) { - Memory::Write_U32(f->GetUID(), state->outAddr); - state->outAddr += 4; - --state->outLeft; - } - return true; -} - u32 sceIoGetFdList(u32 outAddr, int outSize, u32 fdNumAddr) { WARN_LOG(HLE, "sceIoGetFdList(%08x, %i, %08x)", outAddr, outSize, fdNumAddr); - GetFdListArg arg; - arg.outAddr = outAddr; - arg.outLeft = outSize; - arg.total = 0; - kernelObjects.Iterate(&__GetFdListIterator, &arg, PPSSPP_KERNEL_TMID_File); + PSPPointer out; + out = outAddr; + int count = 0; + + // Always have the first three. + for (int i = 0; i < PSP_MIN_FD; ++i) { + // TODO: Technically it seems like these are fixed ids > PSP_COUNT_FDS. + if (count < outSize && out.Valid()) { + out[count] = i; + } + ++count; + } + + for (int i = PSP_MIN_FD; i < PSP_COUNT_FDS; ++i) { + if (fds[i] == 0) { + continue; + } + if (count < outSize && out.Valid()) { + out[count] = i; + } + ++count; + } + if (Memory::IsValidAddress(fdNumAddr)) - Memory::Write_U32(arg.total, fdNumAddr); - return outSize - arg.outLeft; + Memory::Write_U32(count, fdNumAddr); + if (count >= outSize) { + return outSize; + } else { + return count; + } } // Presumably lets you hook up stderr to a MsgPipe. From a1f6a239740429f16eefeb08b6874c0582cb5d11 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 16 Jun 2013 08:55:07 +0800 Subject: [PATCH 09/37] Use bit longer horizontal lines --- Core/Dialog/PSPMsgDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Dialog/PSPMsgDialog.cpp b/Core/Dialog/PSPMsgDialog.cpp index ce13c922d1..8191389202 100755 --- a/Core/Dialog/PSPMsgDialog.cpp +++ b/Core/Dialog/PSPMsgDialog.cpp @@ -174,8 +174,8 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo) } PPGeDrawTextWrapped(text.c_str(), 240.0f, y, WRAP_WIDTH, PPGE_ALIGN_CENTER, FONT_SCALE, CalcFadedColor(0xFFFFFFFF)); float sy = 122.0f - h2, ey = 150.0f + h2; - PPGeDrawRect(30.0f, sy, 450.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF)); - PPGeDrawRect(30.0f, ey, 450.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawRect(15.0f, sy, 465.0f, sy + 1.0f, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawRect(15.0f, ey, 465.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF)); } int PSPMsgDialog::Update() From c35b206398ad8d1a4dff193298c224b00dfc065e Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 16 Jun 2013 22:49:26 +0200 Subject: [PATCH 10/37] Update native to fix excessive logging on android, minor ui tweaks --- UI/MenuScreens.cpp | 15 +++++++-------- native | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 63142223a6..91967ea573 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -208,7 +208,7 @@ void MenuScreen::render() { if (frames_ > 200) // seems the above goes nuts after a while... xoff = -20; - int w = LARGE_BUTTON_WIDTH + 60; + int w = LARGE_BUTTON_WIDTH + 70; ui_draw2d.DrawTextShadow(UBUNTU48, "PPSSPP", dp_xres + xoff - w/2, 75, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_BOTTOM); ui_draw2d.SetFontScale(0.7f, 0.7f); @@ -695,14 +695,13 @@ void AudioScreen::render() { int stride = 40; int columnw = 400; UICheckBox(GEN_ID, x, y += stride, a->T("Enable Sound"), ALIGN_TOPLEFT, &g_Config.bEnableSound); - if (Atrac3plus_Decoder::IsInstalled() && g_Config.bEnableSound) { - UICheckBox(GEN_ID, x + 60, y += stride, a->T("Enable Atrac3+"), ALIGN_TOPLEFT, &g_Config.bEnableAtrac3plus); - } - - if (Atrac3plus_Decoder::IsSupported()) { - VLinear vlinear(30, 300, 20); - if (!Atrac3plus_Decoder::IsInstalled() && UIButton(GEN_ID, vlinear, 400, 0, a->T("Download Atrac3+ plugin"), ALIGN_LEFT)) { + if (Atrac3plus_Decoder::IsInstalled() && g_Config.bEnableSound) { + UICheckBox(GEN_ID, x + 60, y += stride, a->T("Enable Atrac3+"), ALIGN_TOPLEFT, &g_Config.bEnableAtrac3plus); + } + + VLinear vlinear(30, 200, 20); + if (UIButton(GEN_ID, vlinear, 400, 0, a->T("Download Atrac3+ plugin"), ALIGN_LEFT)) { screenManager()->push(new PluginScreen()); } } diff --git a/native b/native index 5d098ca88b..bebb3ae397 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 5d098ca88bd11f0af09c95c9e91166fb82faa07b +Subproject commit bebb3ae397212883cf3c51a93ef803b72aca1860 From e782b6f20e2ba87f062ea20d73fa6e13991ccefb Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 16 Jun 2013 23:45:06 +0200 Subject: [PATCH 11/37] Add VSync option in Windows. Turns itself off when unthrottled. --- Core/Config.cpp | 2 ++ Core/Config.h | 1 + GPU/GLES/DisplayListInterpreter.cpp | 15 +++++++++++++-- GPU/GLES/DisplayListInterpreter.h | 1 + Windows/OpenGLBase.cpp | 21 +++++---------------- Windows/OpenGLBase.h | 1 + Windows/WndMainWindow.cpp | 5 +++++ Windows/ppsspp.rc | Bin 39448 -> 39580 bytes Windows/resource.h | Bin 22786 -> 22882 bytes native | 2 +- 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index f9c793b871..6db53a4567 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -123,6 +123,7 @@ void Config::Load(const char *iniFileName) graphics->Get("TexScalingLevel", &iTexScalingLevel, 1); graphics->Get("TexScalingType", &iTexScalingType, 0); graphics->Get("TexDeposterize", &bTexDeposterize, false); + graphics->Get("VSyncInterval", &iVSyncInterval, 0); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); sound->Get("Enable", &bEnableSound, true); @@ -221,6 +222,7 @@ void Config::Save() graphics->Set("TexScalingLevel", iTexScalingLevel); graphics->Set("TexScalingType", iTexScalingType); graphics->Set("TexDeposterize", bTexDeposterize); + graphics->Set("VSyncInterval", iVSyncInterval); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); sound->Set("Enable", bEnableSound); diff --git a/Core/Config.h b/Core/Config.h index 43a9f61239..1b2347e05d 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -67,6 +67,7 @@ public: bool bPartialStretch; #endif bool bStretchToDisplay; + int iVSyncInterval; int iFrameSkip; int iWindowX; diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 59434680b5..118575425e 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -172,8 +172,10 @@ static const u8 flushBeforeCommandList[] = { }; GLES_GPU::GLES_GPU() -: resized_(false) -{ +: resized_(false) { + lastVsync_ = g_Config.iVSyncInterval; + glstate.SetVSyncInterval(g_Config.iVSyncInterval); + shaderManager_ = new ShaderManager(); transformDraw_.SetShaderManager(shaderManager_); transformDraw_.SetTextureCache(&textureCache_); @@ -251,6 +253,15 @@ void GLES_GPU::DumpNextFrame() { } void GLES_GPU::BeginFrame() { + // Turn off vsync when unthrottled + int desiredVSyncInterval = g_Config.iVSyncInterval; + if (PSP_CoreParameter().unthrottle) + desiredVSyncInterval = 0; + if (desiredVSyncInterval != lastVsync_) { + glstate.SetVSyncInterval(desiredVSyncInterval); + lastVsync_ = desiredVSyncInterval; + } + textureCache_.StartFrame(); transformDraw_.DecimateTrackedVertexArrays(); diff --git a/GPU/GLES/DisplayListInterpreter.h b/GPU/GLES/DisplayListInterpreter.h index d8340abc60..f1da2ea9c0 100644 --- a/GPU/GLES/DisplayListInterpreter.h +++ b/GPU/GLES/DisplayListInterpreter.h @@ -83,6 +83,7 @@ private: u8 *flushBeforeCommand_; bool resized_; + int lastVsync_; std::string reportingPrimaryInfo_; std::string reportingFullInfo_; diff --git a/Windows/OpenGLBase.cpp b/Windows/OpenGLBase.cpp index ee271bfc00..34092506a6 100644 --- a/Windows/OpenGLBase.cpp +++ b/Windows/OpenGLBase.cpp @@ -8,29 +8,21 @@ #include "OpenGLBase.h" -static HDC hDC=NULL; // Private GDI Device Context -static HGLRC hRC=NULL; // Permanent Rendering Context -static HWND hWnd=NULL; // Holds Our Window Handle -static HINSTANCE hInstance; // Holds The Instance Of The Application +static HDC hDC; // Private GDI Device Context +static HGLRC hRC; // Permanent Rendering Context +static HWND hWnd; // Holds Our Window Handle static int xres, yres; // TODO: Make config? static bool enableGLDebug = false; - -//typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int ); -//static PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0; - -void setVSync(int interval=1) +void GL_SetVSyncInterval(int interval=1) { - const char *extensions = (const char *)glGetString( GL_EXTENSIONS ); - if( wglSwapIntervalEXT ) wglSwapIntervalEXT(interval); } -// Resize And Initialize The GL Window void GL_Resized() { if (!hWnd) return; @@ -39,8 +31,6 @@ void GL_Resized() { xres = rc.right - rc.left; //account for border :P yres = rc.bottom - rc.top; - //swidth=width; // Set Scissor Width To Window Width - //sheight=height; // Set Scissor Height To Window Height if (yres == 0) yres = 1; glstate.viewport.set(0, 0, xres, yres); @@ -105,7 +95,6 @@ bool GL_Init(HWND window, std::string *error_message) { hWnd = window; GLuint PixelFormat; - hInstance = GetModuleHandle(NULL); static const PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number @@ -205,7 +194,7 @@ bool GL_Init(HWND window, std::string *error_message) { glGetIntegerv(GL_MINOR_VERSION, &OpenGLVersion[1]); glstate.Initialize(); - setVSync(0); + GL_SetVSyncInterval(0); if (enableGLDebug && glewIsSupported("GL_ARB_debug_output")) { glDebugMessageCallbackARB((GLDEBUGPROCARB)&DebugCallbackARB, 0); // print debug output to stderr glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); diff --git a/Windows/OpenGLBase.h b/Windows/OpenGLBase.h index bf19199b49..a946a16039 100644 --- a/Windows/OpenGLBase.h +++ b/Windows/OpenGLBase.h @@ -6,6 +6,7 @@ #include bool GL_Init(HWND window, std::string *error_message); + void GL_Shutdown(); void GL_Resized(); void GL_SwapBuffers(); diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 23cbe0b860..34a0176c77 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -586,6 +586,10 @@ namespace MainWindow g_Config.bMipMap = !g_Config.bMipMap; break; + case ID_OPTIONS_VSYNC: + g_Config.iVSyncInterval = !g_Config.iVSyncInterval; + break; + case ID_TEXTURESCALING_OFF: setTexScalingLevel(1); break; @@ -897,6 +901,7 @@ namespace MainWindow CHECKITEM(ID_OPTIONS_SHOWFPS, g_Config.bShowFPSCounter); CHECKITEM(ID_OPTIONS_FRAMESKIP, g_Config.iFrameSkip != 0); CHECKITEM(ID_OPTIONS_MIPMAP, g_Config.bMipMap); + CHECKITEM(ID_OPTIONS_VSYNC, g_Config.iVSyncInterval != 0); CHECKITEM(ID_OPTIONS_TOPMOST, g_Config.bTopMost); CHECKITEM(ID_EMULATION_SOUND, g_Config.bEnableSound); CHECKITEM(ID_TEXTURESCALING_DEPOSTERIZE, g_Config.bTexDeposterize); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index e7bb609c133761baabf39f55a4cd29e7fb811450..8520b2b3e522bb9b8a93f16b2c9aa0cdf646d18d 100644 GIT binary patch delta 52 zcmbQSg=x-KrVU-ylLJyjxWgEN8Ppgm8S)sCCpTuAPZlT=-~@?9GWan#Po5|yy1A>m GPYwXS%R9Qd1U_ K;8z%vR9LRWjS+$X delta 33 pcmaE~iLq%Dj3P$4Nw38 diff --git a/native b/native index bebb3ae397..4c2f26ff35 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit bebb3ae397212883cf3c51a93ef803b72aca1860 +Subproject commit 4c2f26ff35b9833752d956a97265261f1e149e58 From d220e55d4f2e8e044e2411f5b46dcf23db813b29 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 16 Jun 2013 23:48:24 +0200 Subject: [PATCH 12/37] Android: Declare support for large screens. --- android/AndroidManifest.xml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index e21d332ce8..68875a411c 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -5,19 +5,25 @@ android:versionName="0.7.6" android:installLocation="auto" > - + - - - - - - - - + + + + + + + + + + Date: Sun, 16 Jun 2013 17:59:59 -0500 Subject: [PATCH 13/37] Rewrite .ini files to match cheat.db Rewrite .ini titles for better identification --- Core/CwCheat.cpp | 109 +++++++++++++++++++++++++---------------------- Core/CwCheat.h | 14 +++--- 2 files changed, 64 insertions(+), 59 deletions(-) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 6279f24802..554985c6c7 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -19,7 +19,11 @@ void trim2(std::string& str); void __CheatInit() { //Moved createFullPath to CheatInit from the constructor because it spams the log and constantly checks if exists. In here, only checks once. - activeCheatFile = CHEATS_DIR + "/" + g_paramSFO.GetValueString("DISC_ID").c_str() + ".ini"; + std::string gameTitle = g_paramSFO.GetValueString("DISC_ID") + " - " + g_paramSFO.GetValueString("TITLE"); + if (gameTitle.find("™")!= std::string::npos) { + gameTitle.erase (gameTitle.find("™"), std::string::npos); + } + activeCheatFile = CHEATS_DIR + "/" + gameTitle +".ini"; File::CreateFullPath(CHEATS_DIR); if (g_Config.bEnableCheats) { @@ -64,12 +68,61 @@ void CWCheatEngine::Exit() { exit2 = true; } void CWCheatEngine::CreateCodeList() { - parts = makeCodeParts(); + initialCodesList = GetCodesList(); + std::string currentcode, codename; + std::vector codelist; + + for (size_t i = 0; i < initialCodesList.size(); i ++) { + + if (initialCodesList[i].substr(0,3) == "_C1") { + cheatEnabled = true; + codename = initialCodesList[i]; + codename.erase (codename.begin(), codename.begin()+4); + codeNameList.push_back(codename); //Import names for GUI + continue; + } + if (initialCodesList[i].substr(0,2) == "_L") { + if (cheatEnabled == true) { + currentcode = initialCodesList[i]; + currentcode.erase(currentcode.begin(), currentcode.begin() + 3); + codelist.push_back(currentcode); + } + continue; + } + if (initialCodesList[i].substr(0,3) == "_C0") { + cheatEnabled = false; + codename = initialCodesList[i]; + codename.erase (codename.begin(), codename.begin()+4); + codeNameList.push_back(codename); //Import names for GUI + continue; + } + } + parts = makeCodeParts(codelist); +} +inline std::vector makeCodeParts(std::vector CodesList) { + std::string currentcode; + std::vector finalList; + char split_char = '\n'; + char empty = ' '; + for (size_t i = 0; i < CodesList.size(); i++) { + currentcode = CodesList[i]; + for (size_t j=0; j < currentcode.length(); j++) { + if (currentcode[j] == empty) { + currentcode[j] = '\n'; + } + } + trim2(currentcode); + std::istringstream iss(currentcode); + std::string each; + while (std::getline(iss, each, split_char)) { + finalList.push_back(each); + } + } + return finalList; } std::vector CWCheatEngine::GetNextCode() { std::string code1; std::string code2; - std::string modifier = "_L"; std::vector splitCode; std::vector finalCode; std::string modifier2 = "0"; @@ -90,11 +143,7 @@ std::vector CWCheatEngine::GetNextCode() { int var2 = (int) parseHexLong(splitCode[1]); finalCode.push_back(var1); finalCode.push_back(var2); - if (splitCode[0].substr(0,2) == modifier) { - splitCode[0] = splitCode[0].substr(3); - break; - } - else if (splitCode[0].substr(0,1) == modifier2) { + if (splitCode[0].substr(0,1) == modifier2) { break; } } @@ -118,14 +167,6 @@ int CWCheatEngine::GetAddress(int value) { return (value + 0x08800000) & 0x3FFFFFFF; } -void CWCheatEngine::AddCheatLine(std::string& line) { - std::string cheatCodes; - if (cheatCodes.length() <= 0) { - cheatCodes = line; - } else { - cheatCodes += "\n" + line; - } -} inline void trim2(std::string& str) { size_t pos = str.find_last_not_of(' '); @@ -137,43 +178,13 @@ inline void trim2(std::string& str) { else str.erase(str.begin(), str.end()); } -inline std::vector makeCodeParts() { - CWCheatEngine cheats; - std::string currentcode; - std::vector finalList; - std::vector CodesList = cheats.GetCodesList(); - char split_char = '\n'; - char empty = ' '; - for (size_t i = 0; i < CodesList.size(); i++) { - currentcode = CodesList[i]; - for (size_t j=0; j < currentcode.length(); j++) { - if (currentcode[j] == empty) { - currentcode[j] = '\n'; - } - } - trim2(currentcode); - std::istringstream iss(currentcode); - std::string each; - while (std::getline(iss, each, split_char)) { - finalList.push_back(each); - } - } - return finalList; -} - std::vector CWCheatEngine::GetCodesList() { std::string line; - - std::string skip = "//"; std::vector codesList; // Read from INI here std::ifstream list(activeCheatFile.c_str()); for (int i = 0; !list.eof(); i ++) { getline(list, line, '\n'); - if (line.substr(0,2) == skip) { - line.clear(); - } else { - codesList.push_back(line); - } + codesList.push_back(line); } for(size_t i = 0; i < codesList.size(); i++) { trim2(codesList[i]); @@ -182,10 +193,8 @@ std::vector CWCheatEngine::GetCodesList() { } void CWCheatEngine::Run() { - CWCheatEngine cheats; exit2 = false; while (!exit2) { - codes = cheats.GetCodesList(); // UI Member currentCode = 0; while (true) { @@ -274,7 +283,7 @@ void CWCheatEngine::Run() { } case 0x4: // 32-bit patch code code = GetNextCode(); - if (code[0] != NULL) { + if (code[0] != 0) { int data = code[0]; int dataAdd = code[1]; diff --git a/Core/CwCheat.h b/Core/CwCheat.h index bd6a4b951e..69d40f0527 100644 --- a/Core/CwCheat.h +++ b/Core/CwCheat.h @@ -12,7 +12,7 @@ void __CheatInit(); void __CheatShutdown(); -std::vector makeCodeParts(); +std::vector makeCodeParts(std::vector CodesList); class CWCheatEngine { public: @@ -24,19 +24,15 @@ public: void Exit(); void Run(); std::vector GetNextCode(); + private: void SkipCodes(int count); void SkipAllCodes(); - + bool cheatsOn, exit2, cheatEnabled; int GetAddress(int value); + std::vector codeNameList; - static uint64_t const serialVersionUID = 6791588139795694296ULL; - static const int cheatsThreadSleepMillis = 5; - - bool cheatsOn; - std::vector codes; + std::vector codes, initialCodesList, parts; size_t currentCode; - bool exit2; - std::vector parts; }; From 25bba708e1313b6e8af9dad47b57a12b9fe189d8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 18:42:41 -0700 Subject: [PATCH 14/37] Make it so createAtrac() can return an error. It doesn't yet, but if it's out of IDs, it should. --- Core/HLE/sceAtrac.cpp | 104 ++++++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 29 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 96c36aa9ad..90baa07c40 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -19,10 +19,11 @@ // to keep games happy anyway. So, no ATRAC3 music until someone has reverse engineered Atrac3+. -#include "HLE.h" -#include "../MIPS/MIPS.h" -#include "../CoreTiming.h" -#include "ChunkFile.h" +#include "Core/HLE/HLE.h" +#include "Core/MIPS/MIPS.h" +#include "Core/CoreTiming.h" +#include "Core/Reporting.h" +#include "Common/ChunkFile.h" #include "sceKernel.h" #include "sceUtility.h" @@ -312,7 +313,7 @@ Atrac *getAtrac(int atracID) { return atracMap[atracID]; } -int createAtrac(Atrac *atrac) { +int createAtrac(Atrac *atrac, int codecType) { int id; do { id= nextAtracID; @@ -453,17 +454,22 @@ void Atrac::Analyze() } } -u32 sceAtracGetAtracID(int codecType) -{ - INFO_LOG(HLE, "sceAtracGetAtracID(%i)", codecType); - if (codecType < 0x1000 || codecType > 0x1001) +u32 sceAtracGetAtracID(int codecType) { + if (codecType != PSP_MODE_AT_3 && codecType > PSP_MODE_AT_3_PLUS) { + ERROR_LOG_REPORT(HLE, "sceAtracGetAtracID(%i): invalid codecType", codecType); return ATRAC_ERROR_INVALID_CODECTYPE; + } - int atracID = createAtrac(new Atrac); - Atrac *atrac = getAtrac(atracID); - if (!atrac) - return ATRAC_ERROR_NO_ATRACID; + Atrac *atrac = new Atrac(); atrac->codeType = codecType; + int atracID = createAtrac(new Atrac, codecType); + if (atracID < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracGetAtracID(%i): no free ID", codecType); + delete atrac; + return atracID; + } + + INFO_LOG(HLE, "%d=sceAtracGetAtracID(%i)", atracID, codecType); return atracID; } @@ -1133,7 +1139,6 @@ u32 sceAtracSetData(int atracID, u32 buffer, u32 bufferSize) int sceAtracSetDataAndGetID(u32 buffer, u32 bufferSize) { - INFO_LOG(HLE, "sceAtracSetDataAndGetID(%08x, %08x)", buffer, bufferSize); int codecType = getCodecType(buffer); Atrac *atrac = new Atrac(); @@ -1141,7 +1146,13 @@ int sceAtracSetDataAndGetID(u32 buffer, u32 bufferSize) atrac->first.size = bufferSize; atrac->Analyze(); atrac->atracOutputChannels = 2; - int atracID = createAtrac(atrac); + int atracID = createAtrac(atrac, codecType); + if (atracID < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracSetDataAndGetID(%08x, %08x): no free ID", buffer, bufferSize); + delete atrac; + return atracID; + } + INFO_LOG(HLE, "%d=sceAtracSetDataAndGetID(%08x, %08x)", atracID, buffer, bufferSize); int ret = _AtracSetData(atracID, buffer, bufferSize, true); if (ret < 0) return ret; @@ -1150,9 +1161,10 @@ int sceAtracSetDataAndGetID(u32 buffer, u32 bufferSize) int sceAtracSetHalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfBufferSize) { - INFO_LOG(HLE, "sceAtracSetHalfwayBufferAndGetID(%08x, %08x, %08x)", halfBuffer, readSize, halfBufferSize); - if (readSize > halfBufferSize) + if (readSize > halfBufferSize) { + ERROR_LOG(HLE, "sceAtracSetHalfwayBufferAndGetID(%08x, %08x, %08x): incorrect read size", halfBuffer, readSize, halfBufferSize); return ATRAC_ERROR_INCORRECT_READ_SIZE; + } int codecType = getCodecType(halfBuffer); Atrac *atrac = new Atrac(); @@ -1160,7 +1172,13 @@ int sceAtracSetHalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfBuffe atrac->first.size = readSize; atrac->Analyze(); atrac->atracOutputChannels = 2; - int atracID = createAtrac(atrac); + int atracID = createAtrac(atrac, codecType); + if (atracID < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracSetHalfwayBufferAndGetID(%08x, %08x, %08x): no free ID", halfBuffer, readSize, halfBufferSize); + delete atrac; + return atracID; + } + INFO_LOG(HLE, "%d=sceAtracSetHalfwayBufferAndGetID(%08x, %08x, %08x)", atracID, halfBuffer, readSize, halfBufferSize); int ret = _AtracSetData(atracID, halfBuffer, halfBufferSize, true); if (ret < 0) return ret; @@ -1250,7 +1268,6 @@ u32 sceAtracSetMOutData(int atracID, u32 buffer, u32 bufferSize) int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) { - INFO_LOG(HLE, "sceAtracSetMOutDataAndGetID(%08x, %08x)", buffer, bufferSize); int codecType = getCodecType(buffer); Atrac *atrac = new Atrac(); @@ -1258,7 +1275,13 @@ int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) atrac->first.size = bufferSize; atrac->Analyze(); atrac->atracOutputChannels = 1; - int atracID = createAtrac(atrac); + int atracID = createAtrac(atrac, codecType); + if (atracID < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracSetMOutDataAndGetID(%08x, %08x): no free ID", buffer, bufferSize); + delete atrac; + return atracID; + } + INFO_LOG(HLE, "%d=sceAtracSetMOutDataAndGetID(%08x, %08x)", atracID, buffer, bufferSize); int ret = _AtracSetData(atracID, buffer, bufferSize, true); if (ret < 0) return ret; @@ -1267,9 +1290,10 @@ int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) int sceAtracSetMOutHalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfBufferSize) { - INFO_LOG(HLE, "sceAtracSetMOutHalfwayBufferAndGetID(%08x, %08x, %08x)", halfBuffer, readSize, halfBufferSize); - if (readSize > halfBufferSize) + if (readSize > halfBufferSize) { + ERROR_LOG(HLE, "sceAtracSetMOutDataAndGetID(%08x, %08x, %08x): incorrect read size", halfBuffer, readSize, halfBufferSize); return ATRAC_ERROR_INCORRECT_READ_SIZE; + } int codecType = getCodecType(halfBuffer); Atrac *atrac = new Atrac(); @@ -1277,7 +1301,13 @@ int sceAtracSetMOutHalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfB atrac->first.size = readSize; atrac->Analyze(); atrac->atracOutputChannels = 1; - int atracID = createAtrac(atrac); + int atracID = createAtrac(atrac, codecType); + if (atracID < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracSetMOutDataAndGetID(%08x, %08x, %08x): no free ID", halfBuffer, readSize, halfBufferSize); + delete atrac; + return atracID; + } + INFO_LOG(HLE, "sceAtracSetMOutHalfwayBufferAndGetID(%08x, %08x, %08x)", atracID, halfBuffer, readSize, halfBufferSize); int ret = _AtracSetData(atracID, halfBuffer, halfBufferSize, true); if (ret < 0) return ret; @@ -1286,14 +1316,20 @@ int sceAtracSetMOutHalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfB int sceAtracSetAA3DataAndGetID(u32 buffer, int bufferSize, int fileSize, u32 metadataSizeAddr) { - ERROR_LOG(HLE, "UNIMPL sceAtracSetAA3DataAndGetID(%08x, %i, %i, %08x)", buffer, bufferSize, fileSize, metadataSizeAddr); int codecType = getCodecType(buffer); Atrac *atrac = new Atrac(); atrac->first.addr = buffer; atrac->first.size = bufferSize; atrac->Analyze(); - return createAtrac(atrac); + int atracID = createAtrac(atrac, codecType); + if (atracID < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracSetAA3DataAndGetID(%08x, %i, %i, %08x): no free ID", buffer, bufferSize, fileSize, metadataSizeAddr); + delete atrac; + return atracID; + } + ERROR_LOG(HLE, "UNIMPL %d=sceAtracSetAA3DataAndGetID(%08x, %i, %i, %08x)", atracID, buffer, bufferSize, fileSize, metadataSizeAddr); + return atracID; } int _AtracGetIDByContext(u32 contextAddr) { @@ -1596,19 +1632,29 @@ int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesConsumedA int sceAtracSetAA3HalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfBufferSize) { - ERROR_LOG(HLE, "UNIMPL sceAtracSetAA3HalfwayBufferAndGetID(%08x, %08x, %08x)", halfBuffer, readSize, halfBufferSize); - if (readSize > halfBufferSize) + if (readSize > halfBufferSize) { + ERROR_LOG(HLE, "sceAtracSetAA3HalfwayBufferAndGetID(%08x, %08x, %08x): invalid read size", halfBuffer, readSize, halfBufferSize); return ATRAC_ERROR_INCORRECT_READ_SIZE; + } - if (readSize < 0 || halfBufferSize < 0) + if (readSize < 0 || halfBufferSize < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracSetAA3HalfwayBufferAndGetID(%08x, %08x, %08x): invalid buffer size", halfBuffer, readSize, halfBufferSize); return -1; + } int codecType = getCodecType(halfBuffer); Atrac *atrac = new Atrac(); atrac->first.addr = halfBuffer; atrac->first.size = halfBufferSize; atrac->Analyze(); - return createAtrac(atrac); + int atracID = createAtrac(atrac, codecType); + if (atracID < 0) { + ERROR_LOG_REPORT(HLE, "sceAtracSetAA3HalfwayBufferAndGetID(%08x, %08x, %08x): no free ID", halfBuffer, readSize, halfBufferSize); + delete atrac; + return atracID; + } + ERROR_LOG(HLE, "UNIMPL %d=sceAtracSetAA3HalfwayBufferAndGetID(%08x, %08x, %08x)", atracID, halfBuffer, readSize, halfBufferSize); + return createAtrac(atrac, codecType); } const HLEFunction sceAtrac3plus[] = From b4269bce536494e055f6ff33f563e83c511d4455 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 19:05:10 -0700 Subject: [PATCH 15/37] Implement sceAtracReinit(), reuse atracIDs. The same way tests show the PSP does. Fixes Ridge Racer mini loading game when you try to play too long. --- Core/HLE/sceAtrac.cpp | 110 +++++++++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 29 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 90baa07c40..45d0be37ec 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -277,11 +277,23 @@ struct Atrac { }; -std::map atracMap; -u8 nextAtracID; +const int PSP_NUM_ATRAC_IDS = 6; +static bool atracInited = true; +static Atrac *atracIDs[PSP_NUM_ATRAC_IDS]; +static int atracIDTypes[PSP_NUM_ATRAC_IDS]; void __AtracInit() { - nextAtracID = 0; + atracInited = true; + memset(atracIDs, 0, sizeof(atracIDs)); + + // Start with 2 of each in this order. + atracIDTypes[0] = PSP_MODE_AT_3_PLUS; + atracIDTypes[1] = PSP_MODE_AT_3_PLUS; + atracIDTypes[2] = PSP_MODE_AT_3; + atracIDTypes[3] = PSP_MODE_AT_3; + atracIDTypes[4] = 0; + atracIDTypes[5] = 0; + #ifdef USE_FFMPEG avcodec_register_all(); av_register_all(); @@ -291,44 +303,45 @@ void __AtracInit() { } void __AtracDoState(PointerWrap &p) { - p.Do(atracMap); - p.Do(nextAtracID); + p.Do(atracInited); + p.DoArray(atracIDs, PSP_NUM_ATRAC_IDS); + p.DoArray(atracIDTypes, PSP_NUM_ATRAC_IDS); p.DoMarker("sceAtrac"); } void __AtracShutdown() { - for (auto it = atracMap.begin(), end = atracMap.end(); it != end; ++it) { - delete it->second; + for (size_t i = 0; i < ARRAY_SIZE(atracIDs); ++i) { + delete atracIDs[i]; + atracIDs[i] = NULL; } - atracMap.clear(); Atrac3plus_Decoder::Shutdown(); } Atrac *getAtrac(int atracID) { - if (atracMap.find(atracID) == atracMap.end()) { + if (atracID < 0 || atracID >= PSP_NUM_ATRAC_IDS) { return NULL; } - return atracMap[atracID]; + return atracIDs[atracID]; } int createAtrac(Atrac *atrac, int codecType) { - int id; - do { - id= nextAtracID; - nextAtracID = (nextAtracID + 1) & 0x3f; - } while (atracMap.find(id) != atracMap.end()); - atracMap[id] = atrac; - atrac->atracID = id; - return id; + for (int i = 0; i < (int)ARRAY_SIZE(atracIDs); ++i) { + if (atracIDTypes[i] == codecType && atracIDs[i] == 0) { + atracIDs[i] = atrac; + return i; + } + } + + return ATRAC_ERROR_NO_ATRACID; } -void deleteAtrac(int atracID) { - if (atracMap.find(atracID) != atracMap.end()) { - delete atracMap[atracID]; - atracMap.erase(atracID); - } +int deleteAtrac(int atracID) { + delete atracIDs[atracID]; + atracIDs[atracID] = NULL; + + return ATRAC_ERROR_BAD_ATRACID; } int getCodecType(int addr) { @@ -890,8 +903,7 @@ u32 sceAtracGetStreamDataInfo(int atracID, u32 writeAddr, u32 writableBytesAddr, u32 sceAtracReleaseAtracID(int atracID) { INFO_LOG(HLE, "sceAtracReleaseAtracID(%i)", atracID); - deleteAtrac(atracID); - return 0; + return deleteAtrac(atracID); } u32 sceAtracResetPlayPosition(int atracID, int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf) @@ -1208,10 +1220,50 @@ u32 sceAtracSetLoopNum(int atracID, int loopNum) return 0; } -int sceAtracReinit() +int sceAtracReinit(int at3Count, int at3plusCount) { - ERROR_LOG(HLE, "UNIMPL sceAtracReinit(..)"); - return 0; + for (int i = 0; i < PSP_NUM_ATRAC_IDS; ++i) { + if (atracIDs[i] != NULL) { + ERROR_LOG_REPORT(HLE, "sceAtracReinit(%d, %d): cannot reinit while IDs in use", at3Count, at3plusCount); + return SCE_KERNEL_ERROR_BUSY; + } + } + + memset(atracIDTypes, 0, sizeof(atracIDTypes)); + int next = 0; + int space = PSP_NUM_ATRAC_IDS; + + // This seems to deinit things. Mostly, it cause a reschedule on next deinit (but -1, -1 does not.) + if (at3Count == 0 && at3plusCount == 0) { + INFO_LOG(HLE, "sceAtracReinit(%d, %d): deinit", at3Count, at3plusCount); + atracInited = false; + return hleDelayResult(0, "atrac reinit", 200); + } + + // First, ATRAC3+. These IDs seem to cost double (probably memory.) + // Intentionally signed. 9999 tries to allocate, -1 does not. + for (int i = 0; i < at3plusCount; ++i) { + space -= 2; + if (space >= 0) { + atracIDTypes[next++] = PSP_MODE_AT_3_PLUS; + } + } + for (int i = 0; i < at3Count; ++i) { + space -= 1; + if (space >= 0) { + atracIDTypes[next++] = PSP_MODE_AT_3; + } + } + + // If we ran out of space, we still initialize some, but return an error. + int result = space >= 0 ? 0 : SCE_KERNEL_ERROR_OUT_OF_MEMORY; + if (atracInited) { + INFO_LOG(HLE, "sceAtracReinit(%d, %d)", at3Count, at3plusCount); + return result; + } else { + INFO_LOG(HLE, "sceAtracReinit(%d, %d): init", at3Count, at3plusCount); + return hleDelayResult(result, "atrac reinit", 400); + } } int sceAtracGetOutputChannel(int atracID, u32 outputChanPtr) @@ -1683,7 +1735,7 @@ const HLEFunction sceAtrac3plus[] = {0x7a20e7af,WrapI_UU,"sceAtracSetDataAndGetID"}, {0xd1f59fdb,WrapU_V,"sceAtracStartEntry"}, {0x868120b5,WrapU_II,"sceAtracSetLoopNum"}, - {0x132f1eca,WrapI_V,"sceAtracReinit"}, + {0x132f1eca,WrapI_II,"sceAtracReinit"}, {0xeca32a99,WrapI_I,"sceAtracIsSecondBufferNeeded"}, {0x0fae370e,WrapI_UUU,"sceAtracSetHalfwayBufferAndGetID"}, {0x2DD3E298,WrapU_IIU,"sceAtracGetBufferInfoForResetting"}, From d6de868108258facf99620d1f3232e933a347e64 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 20:00:27 -0700 Subject: [PATCH 16/37] Correctly savestate the atrac ids. --- Core/HLE/sceAtrac.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 45d0be37ec..a8734bcc58 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -304,7 +304,16 @@ void __AtracInit() { void __AtracDoState(PointerWrap &p) { p.Do(atracInited); - p.DoArray(atracIDs, PSP_NUM_ATRAC_IDS); + for (int i = 0; i < PSP_NUM_ATRAC_IDS; ++i) { + bool valid = atracIDs[i] != NULL; + p.Do(valid); + if (valid) { + p.Do(atracIDs[i]); + } else { + delete atracIDs[i]; + atracIDs[i] = NULL; + } + } p.DoArray(atracIDTypes, PSP_NUM_ATRAC_IDS); p.DoMarker("sceAtrac"); From ea299e358d88fd4bf704c834cf7bdef2715dc266 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 22:18:17 -0700 Subject: [PATCH 17/37] Oops, dumb typo. --- Core/HLE/sceAtrac.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index a8734bcc58..d3fbf8972c 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -484,7 +484,7 @@ u32 sceAtracGetAtracID(int codecType) { Atrac *atrac = new Atrac(); atrac->codeType = codecType; - int atracID = createAtrac(new Atrac, codecType); + int atracID = createAtrac(atrac, codecType); if (atracID < 0) { ERROR_LOG_REPORT(HLE, "sceAtracGetAtracID(%i): no free ID", codecType); delete atrac; From 9683e021eaa27e36e84133b0a58e34b45cec161a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 22:26:19 -0700 Subject: [PATCH 18/37] Fix return on atrac release, fix deinit/reinit. --- Core/HLE/sceAtrac.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index d3fbf8972c..ba320148bc 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -347,8 +347,14 @@ int createAtrac(Atrac *atrac, int codecType) { } int deleteAtrac(int atracID) { - delete atracIDs[atracID]; - atracIDs[atracID] = NULL; + if (atracID >= 0 && atracID < PSP_NUM_ATRAC_IDS) { + if (atracIDs[atracID] != NULL) { + delete atracIDs[atracID]; + atracIDs[atracID] = NULL; + + return 0; + } + } return ATRAC_ERROR_BAD_ATRACID; } @@ -1266,11 +1272,13 @@ int sceAtracReinit(int at3Count, int at3plusCount) // If we ran out of space, we still initialize some, but return an error. int result = space >= 0 ? 0 : SCE_KERNEL_ERROR_OUT_OF_MEMORY; - if (atracInited) { + if (atracInited || next == 0) { INFO_LOG(HLE, "sceAtracReinit(%d, %d)", at3Count, at3plusCount); + atracInited = true; return result; } else { INFO_LOG(HLE, "sceAtracReinit(%d, %d): init", at3Count, at3plusCount); + atracInited = true; return hleDelayResult(result, "atrac reinit", 400); } } From 6ff9cf64cac49f7a275cdd04c24312e44ac0f62a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Jun 2013 23:44:11 -0700 Subject: [PATCH 19/37] Measure flips per second. --- Core/HLE/sceDisplay.cpp | 17 ++++++++++++++--- UI/EmuScreen.cpp | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index b5c28b85f8..7f7688deff 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -121,6 +121,9 @@ static double fps = 0.0; static double fpsHistory[120]; static size_t fpsHistoryPos = 0; static size_t fpsHistoryValid = 0; +static int lastNumFlips = 0; +static int numFlips = 0; +static float flips = 0.0f; void hleEnterVblank(u64 userdata, int cyclesLate); void hleLeaveVblank(u64 userdata, int cyclesLate); @@ -214,7 +217,8 @@ void __DisplayFireVblank() { } void __DisplayGetFPS(float *out_vps, float *out_fps) { - *out_vps = *out_fps = fps; + *out_vps = fps; + *out_fps = flips; } void __DisplayGetAveragedFPS(float *out_vps, float *out_fps) { @@ -239,9 +243,12 @@ void CalculateFPS() if (now >= lastFpsTime + 1.0) { - fps = (gpuStats.numFrames - lastFpsFrame) / (now - lastFpsTime); + double frames = (gpuStats.numFrames - lastFpsFrame); + fps = frames / (now - lastFpsTime); + flips = 60.0 * (double) (numFlips - lastNumFlips) / frames; - lastFpsFrame = gpuStats.numFrames; + lastFpsFrame = gpuStats.numFrames; + lastNumFlips = numFlips; lastFpsTime = now; fpsHistory[fpsHistoryPos++] = fps; @@ -503,6 +510,10 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync) fbstate.pspFramebufLinesize = linesize; } + if (topaddr != framebuf.topaddr) { + ++numFlips; + } + if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) { // Write immediately to the current framebuffer parameters if (topaddr != 0) { diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 95935d1242..95221d819d 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -337,7 +337,7 @@ void EmuScreen::render() { float vps, fps; __DisplayGetFPS(&vps, &fps); char fpsbuf[256]; - sprintf(fpsbuf, "VPS: %0.1f", vps); + sprintf(fpsbuf, "VPS: %0.1f\nFPS: %0.1f", vps, fps); ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT); ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT); } From 9bb96a63f58f845c98d827ee1df3302a40345ab0 Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 08:04:31 -0400 Subject: [PATCH 20/37] Implement more sceNetStubs. Should fix most games that hang when messing with WLAN/Adhoc(not infrastructure) stuff. Also make the code style closer to the Dolphin/PPSSPP guidelines. --- Core/HLE/sceNet.cpp | 223 +++++++++++++++++++++++++++++++++----------- 1 file changed, 166 insertions(+), 57 deletions(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index bb32fc8e6a..7d64e673d5 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -20,12 +20,16 @@ #include "../MIPS/MIPS.h" #include "sceKernel.h" +#include "sceKernelThread.h" #include "sceUtility.h" static bool netInited; static bool netAdhocInited; -enum { +static u32 adhocctlHandlerPtr; + +enum +{ ERROR_NET_BUFFER_TOO_SMALL = 0x80400706, ERROR_NET_RESOLVER_BAD_ID = 0x80410408, @@ -42,13 +46,14 @@ enum { ERROR_NET_ADHOC_TIMEOUT = 0x80410715, ERROR_NET_ADHOC_NO_ENTRY = 0x80410716, ERROR_NET_ADHOC_CONNECTION_REFUSED = 0x80410718, - ERROR_NET_ADHOC_INVALID_MATCHING_ID = 0x80410807, ERROR_NET_ADHOC_MATCHING_ALREADY_INITIALIZED = 0x80410812, ERROR_NET_ADHOC_MATCHING_NOT_INITIALIZED = 0x80410813, + ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF = 0x80410b03, ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED = 0x80410b07, ERROR_NET_ADHOCCTL_NOT_INITIALIZED = 0x80410b08, + ERROR_NET_ADHOCCTL_DISCONNECTED = 0x80410b09, ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12, }; @@ -67,26 +72,45 @@ struct ProductStruct char product[9]; //Product name? }; -void __NetInit() { +struct SceNetMallocStat +{ + int pool; // Pointer to the pool? + int maximum; // Maximum size of the pool? + int free; // How much memory is free +}; + +static struct SceNetMallocStat netMallocStat; + +void __NetInit() +{ netInited = false; netAdhocInited = false; + adhocctlHandlerPtr = 0; } -void __NetShutdown() { +void __NetShutdown() +{ } // This feels like a dubious proposition, mostly... -void __NetDoState(PointerWrap &p) { +void __NetDoState(PointerWrap &p) +{ p.Do(netInited); p.Do(netAdhocInited); + p.Do(adhocctlHandlerPtr); p.DoMarker("net"); } -void sceNetInit() { +// TODO: should that struct actually be initialized here? +void sceNetInit() +{ ERROR_LOG(HLE,"UNIMPL sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d)", PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); netInited = true; + netMallocStat.maximum = PARAM(0); + netMallocStat.free = PARAM(0); + netMallocStat.pool = 0; RETURN(0); //ERROR } @@ -96,15 +120,18 @@ u32 sceNetTerm() { return 0; } -u32 sceNetAdhocInit() { +u32 sceNetAdhocInit() +{ ERROR_LOG(HLE,"UNIMPL sceNetAdhocInit()"); if (netAdhocInited) return ERROR_NET_ADHOC_ALREADY_INITIALIZED; netAdhocInited = true; + return 0; } -u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) { +u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) +{ ERROR_LOG(HLE,"UNIMPL sceNetAdhocctlInit(%i, %i, %08x)", stackSize, prio, productAddr); return 0; } @@ -115,6 +142,7 @@ u32 sceWlanGetEtherAddr(u32 addrAddr) DEBUG_LOG(HLE, "sceWlanGetEtherAddr(%08x)", addrAddr); for (int i = 0; i < 6; i++) Memory::Write_U8(fakeEtherAddr[i], addrAddr + i); + return 0; } @@ -124,44 +152,74 @@ u32 sceWlanDevIsPowerOn() return 0; } -u32 sceWlanGetSwitchState() { +u32 sceWlanGetSwitchState() +{ DEBUG_LOG(HLE, "UNTESTED sceWlanGetSwitchState()"); return 0; } -//handler probably shouldn't be an int... -u32 sceNetAdhocctlAddHandler(int handler, void *unknown) { - ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlAddHandler(%x, %x)", handler, unknown); +// TODO: How many handlers can the PSP actually have for Adhocctl? +u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 unknown) +{ + WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x)", handlerPtr, unknown); + if(adhocctlHandlerPtr == 0) + { + adhocctlHandlerPtr = handlerPtr; + DEBUG_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler", handlerPtr, unknown); + } + else + { + WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Too many handlers already!", handlerPtr, unknown); + return ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS; + } + return 0; } -u32 sceNetAdhocctlDisconnect() { - DEBUG_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()"); +u32 sceNetAdhocctlDisconnect() +{ + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()"); return 0; } -u32 sceNetAdhocctlDelHandler(int handler) { - ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDelHandler(%x)", handler); +u32 sceNetAdhocctlDelHandler(u32 handlerPtr) +{ + WARN_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%x)", handlerPtr); + + if(adhocctlHandlerPtr > 0) + { + adhocctlHandlerPtr = 0; + DEBUG_LOG(HLE, "sceNetAdhocctlDelHandler(%x): deleted handler", handlerPtr); + } + else + { + WARN_LOG(HLE, "sceNetAdhocctlDelHandler(%x): asked to delete invalid handler", handlerPtr); + } + return 0; } -int sceNetAdhocMatchingTerm() { +int sceNetAdhocMatchingTerm() +{ ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingTerm()"); return 0; } -int sceNetAdhocctlTerm() { +int sceNetAdhocctlTerm() +{ ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlTerm()"); return 0; } -int sceNetAdhocTerm() { +int sceNetAdhocTerm() +{ ERROR_LOG(HLE, "UNIMPL sceNetAdhocTerm()"); return 0; } -//homebrew SDK claims it's a void function, but tests seem to indicate otherwise -int sceNetEtherNtostr(const char *mac, u32 bufferPtr) { +// Homebrew SDK claims it's a void function, but tests seem to indicate otherwise +int sceNetEtherNtostr(const char *mac, u32 bufferPtr) +{ DEBUG_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x)", mac, bufferPtr); int len = strlen(mac); for (int i = 0; i < len; i++) @@ -170,50 +228,106 @@ int sceNetEtherNtostr(const char *mac, u32 bufferPtr) { return 0; } -//write SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED to attempt to stop games from spamming wifi syscalls... -int sceNetAdhocctlGetState(u32 ptrToStatus) { - DEBUG_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus); - Memory::Write_U32(SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED, ptrToStatus); +// Seems to always return 0, and write 0 to the pointer.. +// TODO: Eventually research what possible states there are +int sceNetAdhocctlGetState(u32 ptrToStatus) +{ + WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus); + if(Memory::IsValidAddress(ptrToStatus)) + Memory::Write_U32(0, ptrToStatus); + else + ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x): Tried to write invalid location!", ptrToStatus); + return 0; } -//always return -1 since we don't have any real networking... -int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) { +// Always return -1 since we don't have any real networking... +int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) +{ ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpCreate(%s, %x, %x, %x)", mac, port, bufferSize, unknown); return -1; } -//SHOULD be int sceNetAdhocctlGetParameter(struct SceNetAdhocctlParams *params), but I don't want -//to mess up the function wrappers.. -int sceNetAdhocctlGetParameter() { - ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetParameter()"); - return -1; -} - -//SHOULD be int sceNetAdhocctlGetAdhocId(struct productStruct * product), but I don't want -//to mess up the function wrappers.. -int sceNetAdhocctlGetAdhocId() { - ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetAdhocId()"); - return -1; +int sceNetAdhocctlGetParameter(u32 paramAddr) +{ + ERROR_LOG(HLE, "UNIMPL %x=sceNetAdhocctlGetParameter(%x)", 0, paramAddr); + struct SceNetAdhocctlParams params; + params.channel = 0; + for(int i = 0; i < 6; i++) + params.bssid[i] = i + 1; + strcpy(params.name, ""); + strcpy(params.nickname, ""); + + Memory::WriteStruct(paramAddr, ¶ms); + + return ERROR_NET_ADHOCCTL_DISCONNECTED; } -//return -1 packets since we don't have networking yet -int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) { +// Return -1 packets since we don't have networking yet.. +int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) +{ ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpRecv(%d, %d, %d, %x, %x, %d, %d)", id, mac, port, data, dataLength, timeout, nonBlock); return -1; } -//Assuming < 0 for failure, homebrew SDK doesn't have much to say about this one -int sceNetAdhocSetSocketAlert(int id, int flag) { +// Assuming < 0 for failure, homebrew SDK doesn't have much to say about this one.. +int sceNetAdhocSetSocketAlert(int id, int flag) +{ ERROR_LOG(HLE, "UNIMPL sceNetAdhocSetSocketAlert(%d, %d)", id, flag); return -1; } -int sceNetAdhocPdpDelete(int id, int unknown) { +int sceNetAdhocPdpDelete(int id, int unknown) +{ ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpDelete(%d, %d)", id, unknown); return 0; } +int sceNetAdhocctlGetAdhocId(u32 productStructAddr) +{ + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetAdhocId(%x)", productStructAddr); + return 0; +} + +int sceNetAdhocctlScan() +{ + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlScan()"); + u32 args[3] = {0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF, adhocctlHandlerPtr }; + __KernelDirectMipsCall(adhocctlHandlerPtr, NULL, args, 3, true); + + return 0; +} + +int sceNetAdhocctlGetScanInfo() +{ + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetScanInfo()"); + return 0; +} + +int sceNetAdhocctlConnect(u32 ptrToGroupName) +{ + ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName); + return 0; +} + +// Write static data since we don't actually manage any memory for sceNet* yet. +int sceNetGetMallocStat(u32 statPtr) +{ + ERROR_LOG(HLE, "UNTESTED sceNetGetMallocStat(%x)", statPtr); + if(Memory::IsValidAddress(statPtr)) + Memory::WriteStruct(statPtr, &netMallocStat); + else + ERROR_LOG(HLE, "UNTESTED sceNetGetMallocStat(%x): tried to request invalid address!", statPtr); + + return 0; +} + +int sceNetAdhocMatchingInit(u32 memsize) +{ + ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingInit(%08x)", memsize); + return 0; +} + const HLEFunction sceNet[] = { {0x39AF39A6, sceNetInit, "sceNetInit"}, @@ -222,7 +336,7 @@ const HLEFunction sceNet[] = {0x0bf0a3ae, 0, "sceNetGetLocalEtherAddr"}, {0xd27961c9, 0, "sceNetEtherStrton"}, {0x50647530, 0, "sceNetFreeThreadinfo"}, - {0xcc393e48, 0, "sceNetGetMallocStat"}, + {0xcc393e48, WrapI_U, "sceNetGetMallocStat"}, {0xad6844c6, 0, "sceNetThreadAbort"}, }; @@ -256,11 +370,6 @@ const HLEFunction sceNetAdhoc[] = {0x4d2ce199, 0, "sceNetAdhocGetSocketAlert"}, }; -int sceNetAdhocMatchingInit(u32 memsize) { - ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingInit(%08x)", memsize); - return 0; -} - const HLEFunction sceNetAdhocMatching[] = { {0x2a2a1e07, WrapI_U, "sceNetAdhocMatchingInit"}, @@ -285,15 +394,15 @@ const HLEFunction sceNetAdhocctl[] = { {0xE26F226E, WrapU_IIU, "sceNetAdhocctlInit"}, {0x9D689E13, WrapI_V, "sceNetAdhocctlTerm"}, - {0x20B317A0, WrapU_IV, "sceNetAdhocctlAddHandler"}, - {0x6402490B, WrapU_I, "sceNetAdhocctlDelHandler"}, + {0x20B317A0, WrapU_UU, "sceNetAdhocctlAddHandler"}, + {0x6402490B, WrapU_U, "sceNetAdhocctlDelHandler"}, {0x34401D65, WrapU_V, "sceNetAdhocctlDisconnect"}, - {0x0ad043ed, 0, "sceNetAdhocctlConnect"}, - {0x08fff7a0, 0, "sceNetAdhocctlScan"}, + {0x0ad043ed, WrapI_U, "sceNetAdhocctlConnect"}, + {0x08fff7a0, WrapI_V, "sceNetAdhocctlScan"}, {0x75ecd386, WrapI_U, "sceNetAdhocctlGetState"}, {0x8916c003, 0, "sceNetAdhocctlGetNameByAddr"}, - {0xded9d28e, WrapI_V, "sceNetAdhocctlGetParameter"}, - {0x81aee1be, 0, "sceNetAdhocctlGetScanInfo"}, + {0xded9d28e, WrapI_U, "sceNetAdhocctlGetParameter"}, + {0x81aee1be, WrapI_V, "sceNetAdhocctlGetScanInfo"}, {0x5e7f79c9, 0, "sceNetAdhocctlJoin"}, {0x8db83fdc, 0, "sceNetAdhocctlGetPeerInfo"}, {0xec0635c1, 0, "sceNetAdhocctlCreate"}, @@ -301,7 +410,7 @@ const HLEFunction sceNetAdhocctl[] = {0x1ff89745, 0, "sceNetAdhocctlJoinEnterGameMode"}, {0xcf8e084d, 0, "sceNetAdhocctlExitGameMode"}, {0xe162cb14, 0, "sceNetAdhocctlGetPeerList"}, - {0x362cbe8f, WrapI_V, "sceNetAdhocctlGetAdhocId"}, + {0x362cbe8f, WrapI_U, "sceNetAdhocctlGetAdhocId"}, {0x5a014ce0, 0, "sceNetAdhocctlGetGameModeInfo"}, {0x99560abe, 0, "sceNetAdhocctlGetAddrByName"}, {0xb0b80e80, 0, "sceNetAdhocctlCreateEnterGameModeMin"}, From 113ed42500eff6faeefad54a36c50b21b4ae3471 Mon Sep 17 00:00:00 2001 From: raven02 Date: Mon, 17 Jun 2013 20:06:17 +0800 Subject: [PATCH 21/37] Add VSync to UI Graphics (WIN only) --- UI/MenuScreens.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 91967ea573..729ce667c7 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -746,6 +746,11 @@ void GraphicsScreenP1::render() { UICheckBox(GEN_ID, x, y += stride, gs->T("Stream VBO"), ALIGN_TOPLEFT, &g_Config.bUseVBO); #endif UICheckBox(GEN_ID, x, y += stride, gs->T("Mipmapping"), ALIGN_TOPLEFT, &g_Config.bMipMap); +#ifdef _WIN32 + bool Vsync = g_Config.iVSyncInterval != 0; + UICheckBox(GEN_ID, x, y += stride, gs->T("VSync"), ALIGN_TOPLEFT, &Vsync); + g_Config.iVSyncInterval = Vsync ? 1 : 0; +#endif UICheckBox(GEN_ID, x, y += stride, gs->T("Display Raw Framebuffer"), ALIGN_TOPLEFT, &g_Config.bDisplayFramebuffer); if (UICheckBox(GEN_ID, x, y += stride, gs->T("Buffered Rendering"), ALIGN_TOPLEFT, &g_Config.bBufferedRendering)) { if (gpu) From 2c2d3e53624e95901ac4bf42f41e6fcbafbeee7b Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 08:15:43 -0400 Subject: [PATCH 22/37] Fix possible crashes and some spacing errors. --- Core/HLE/sceNet.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 7d64e673d5..b8ecabfb62 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -57,7 +57,7 @@ enum ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12, }; -//these might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc +// These might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc.. struct SceNetAdhocctlParams { int channel; //which ad-hoc channel to connect to @@ -68,8 +68,8 @@ struct SceNetAdhocctlParams struct ProductStruct { - int unknown; //unknown, set to 0 - char product[9]; //Product name? + int unknown; // Unknown, set to 0 + char product[9]; // Game ID (Example: ULUS10000) }; struct SceNetMallocStat @@ -88,7 +88,6 @@ void __NetInit() adhocctlHandlerPtr = 0; } - void __NetShutdown() { @@ -114,7 +113,8 @@ void sceNetInit() RETURN(0); //ERROR } -u32 sceNetTerm() { +u32 sceNetTerm() +{ ERROR_LOG(HLE,"UNIMPL sceNetTerm()"); netInited = false; return 0; @@ -221,10 +221,14 @@ int sceNetAdhocTerm() int sceNetEtherNtostr(const char *mac, u32 bufferPtr) { DEBUG_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x)", mac, bufferPtr); - int len = strlen(mac); - for (int i = 0; i < len; i++) - Memory::Write_U8(mac[i], bufferPtr + i); - + if(Memory::IsValidAddress(bufferPtr) + { + int len = strlen(mac); + for (int i = 0; i < len; i++) + Memory::Write_U8(mac[i], bufferPtr + i); + } + else + ERROR_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x): Tried to write to an invalid pointer", mac, bufferPtr); return 0; } @@ -236,7 +240,7 @@ int sceNetAdhocctlGetState(u32 ptrToStatus) if(Memory::IsValidAddress(ptrToStatus)) Memory::Write_U32(0, ptrToStatus); else - ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x): Tried to write invalid location!", ptrToStatus); + ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x): Tried to write invalid location", ptrToStatus); return 0; } @@ -248,6 +252,7 @@ int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) return -1; } +// TODO: Should we really write the struct if we're disconnected? int sceNetAdhocctlGetParameter(u32 paramAddr) { ERROR_LOG(HLE, "UNIMPL %x=sceNetAdhocctlGetParameter(%x)", 0, paramAddr); @@ -258,7 +263,8 @@ int sceNetAdhocctlGetParameter(u32 paramAddr) strcpy(params.name, ""); strcpy(params.nickname, ""); - Memory::WriteStruct(paramAddr, ¶ms); + if(Memory::IsValidAddress(paramAddr)) + Memory::WriteStruct(paramAddr, ¶ms); return ERROR_NET_ADHOCCTL_DISCONNECTED; } @@ -292,8 +298,11 @@ int sceNetAdhocctlGetAdhocId(u32 productStructAddr) int sceNetAdhocctlScan() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlScan()"); - u32 args[3] = {0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF, adhocctlHandlerPtr }; - __KernelDirectMipsCall(adhocctlHandlerPtr, NULL, args, 3, true); + if(adhocctlHandlerPtr != 0) + { + u32 args[3] = {0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF, adhocctlHandlerPtr }; + __KernelDirectMipsCall(adhocctlHandlerPtr, NULL, args, 3, true); + } return 0; } From 35f11151910a1fa144a992f344aa1619c45957ed Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 08:32:13 -0400 Subject: [PATCH 23/37] Fix compilation error. --- Core/HLE/sceNet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index b8ecabfb62..40a451eb9a 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -221,7 +221,7 @@ int sceNetAdhocTerm() int sceNetEtherNtostr(const char *mac, u32 bufferPtr) { DEBUG_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x)", mac, bufferPtr); - if(Memory::IsValidAddress(bufferPtr) + if(Memory::IsValidAddress(bufferPtr)) { int len = strlen(mac); for (int i = 0; i < len; i++) From 8621b0e637550e9bbb96f69ae047ab21477ed5be Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 08:43:29 -0400 Subject: [PATCH 24/37] Fix some more styling issues. --- Core/HLE/sceNet.cpp | 148 +++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 99 deletions(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 40a451eb9a..148d3ff11d 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -28,8 +28,7 @@ static bool netAdhocInited; static u32 adhocctlHandlerPtr; -enum -{ +enum { ERROR_NET_BUFFER_TOO_SMALL = 0x80400706, ERROR_NET_RESOLVER_BAD_ID = 0x80410408, @@ -58,22 +57,19 @@ enum }; // These might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc.. -struct SceNetAdhocctlParams -{ +struct SceNetAdhocctlParams { int channel; //which ad-hoc channel to connect to char name[8]; //connection name u8 bssid[6]; //BSSID of the connection? char nickname[128]; //PSP's nickname? }; -struct ProductStruct -{ +struct ProductStruct { int unknown; // Unknown, set to 0 char product[9]; // Game ID (Example: ULUS10000) }; -struct SceNetMallocStat -{ +struct SceNetMallocStat { int pool; // Pointer to the pool? int maximum; // Maximum size of the pool? int free; // How much memory is free @@ -81,21 +77,18 @@ struct SceNetMallocStat static struct SceNetMallocStat netMallocStat; -void __NetInit() -{ +void __NetInit() { netInited = false; netAdhocInited = false; adhocctlHandlerPtr = 0; } -void __NetShutdown() -{ +void __NetShutdown() { } // This feels like a dubious proposition, mostly... -void __NetDoState(PointerWrap &p) -{ +void __NetDoState(PointerWrap &p) { p.Do(netInited); p.Do(netAdhocInited); p.Do(adhocctlHandlerPtr); @@ -103,8 +96,7 @@ void __NetDoState(PointerWrap &p) } // TODO: should that struct actually be initialized here? -void sceNetInit() -{ +void sceNetInit() { ERROR_LOG(HLE,"UNIMPL sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d)", PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); netInited = true; netMallocStat.maximum = PARAM(0); @@ -113,15 +105,13 @@ void sceNetInit() RETURN(0); //ERROR } -u32 sceNetTerm() -{ +u32 sceNetTerm() { ERROR_LOG(HLE,"UNIMPL sceNetTerm()"); netInited = false; return 0; } -u32 sceNetAdhocInit() -{ +u32 sceNetAdhocInit() { ERROR_LOG(HLE,"UNIMPL sceNetAdhocInit()"); if (netAdhocInited) return ERROR_NET_ADHOC_ALREADY_INITIALIZED; @@ -130,14 +120,12 @@ u32 sceNetAdhocInit() return 0; } -u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) -{ +u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) { ERROR_LOG(HLE,"UNIMPL sceNetAdhocctlInit(%i, %i, %08x)", stackSize, prio, productAddr); return 0; } -u32 sceWlanGetEtherAddr(u32 addrAddr) -{ +u32 sceWlanGetEtherAddr(u32 addrAddr) { static const u8 fakeEtherAddr[6] = { 1, 2, 3, 4, 5, 6 }; DEBUG_LOG(HLE, "sceWlanGetEtherAddr(%08x)", addrAddr); for (int i = 0; i < 6; i++) @@ -146,29 +134,24 @@ u32 sceWlanGetEtherAddr(u32 addrAddr) return 0; } -u32 sceWlanDevIsPowerOn() -{ +u32 sceWlanDevIsPowerOn() { DEBUG_LOG(HLE, "UNTESTED 0=sceWlanDevIsPowerOn()"); return 0; } -u32 sceWlanGetSwitchState() -{ +u32 sceWlanGetSwitchState() { DEBUG_LOG(HLE, "UNTESTED sceWlanGetSwitchState()"); return 0; } // TODO: How many handlers can the PSP actually have for Adhocctl? -u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 unknown) -{ +u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 unknown) { WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x)", handlerPtr, unknown); - if(adhocctlHandlerPtr == 0) - { + if(adhocctlHandlerPtr == 0) { adhocctlHandlerPtr = handlerPtr; DEBUG_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler", handlerPtr, unknown); } - else - { + else { WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Too many handlers already!", handlerPtr, unknown); return ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS; } @@ -176,53 +159,43 @@ u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 unknown) return 0; } -u32 sceNetAdhocctlDisconnect() -{ +u32 sceNetAdhocctlDisconnect() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()"); return 0; } -u32 sceNetAdhocctlDelHandler(u32 handlerPtr) -{ +u32 sceNetAdhocctlDelHandler(u32 handlerPtr) { WARN_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%x)", handlerPtr); - if(adhocctlHandlerPtr > 0) - { + if(adhocctlHandlerPtr > 0) { adhocctlHandlerPtr = 0; DEBUG_LOG(HLE, "sceNetAdhocctlDelHandler(%x): deleted handler", handlerPtr); } - else - { + else WARN_LOG(HLE, "sceNetAdhocctlDelHandler(%x): asked to delete invalid handler", handlerPtr); - } return 0; } -int sceNetAdhocMatchingTerm() -{ +int sceNetAdhocMatchingTerm() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingTerm()"); return 0; } -int sceNetAdhocctlTerm() -{ +int sceNetAdhocctlTerm() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlTerm()"); return 0; } -int sceNetAdhocTerm() -{ +int sceNetAdhocTerm() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocTerm()"); return 0; } // Homebrew SDK claims it's a void function, but tests seem to indicate otherwise -int sceNetEtherNtostr(const char *mac, u32 bufferPtr) -{ +int sceNetEtherNtostr(const char *mac, u32 bufferPtr) { DEBUG_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x)", mac, bufferPtr); - if(Memory::IsValidAddress(bufferPtr)) - { + if(Memory::IsValidAddress(bufferPtr)) { int len = strlen(mac); for (int i = 0; i < len; i++) Memory::Write_U8(mac[i], bufferPtr + i); @@ -234,8 +207,7 @@ int sceNetEtherNtostr(const char *mac, u32 bufferPtr) // Seems to always return 0, and write 0 to the pointer.. // TODO: Eventually research what possible states there are -int sceNetAdhocctlGetState(u32 ptrToStatus) -{ +int sceNetAdhocctlGetState(u32 ptrToStatus) { WARN_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus); if(Memory::IsValidAddress(ptrToStatus)) Memory::Write_U32(0, ptrToStatus); @@ -246,15 +218,13 @@ int sceNetAdhocctlGetState(u32 ptrToStatus) } // Always return -1 since we don't have any real networking... -int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) -{ +int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpCreate(%s, %x, %x, %x)", mac, port, bufferSize, unknown); return -1; } // TODO: Should we really write the struct if we're disconnected? -int sceNetAdhocctlGetParameter(u32 paramAddr) -{ +int sceNetAdhocctlGetParameter(u32 paramAddr) { ERROR_LOG(HLE, "UNIMPL %x=sceNetAdhocctlGetParameter(%x)", 0, paramAddr); struct SceNetAdhocctlParams params; params.channel = 0; @@ -270,36 +240,30 @@ int sceNetAdhocctlGetParameter(u32 paramAddr) } // Return -1 packets since we don't have networking yet.. -int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) -{ +int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpRecv(%d, %d, %d, %x, %x, %d, %d)", id, mac, port, data, dataLength, timeout, nonBlock); return -1; } // Assuming < 0 for failure, homebrew SDK doesn't have much to say about this one.. -int sceNetAdhocSetSocketAlert(int id, int flag) -{ +int sceNetAdhocSetSocketAlert(int id, int flag) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocSetSocketAlert(%d, %d)", id, flag); return -1; } -int sceNetAdhocPdpDelete(int id, int unknown) -{ +int sceNetAdhocPdpDelete(int id, int unknown) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpDelete(%d, %d)", id, unknown); return 0; } -int sceNetAdhocctlGetAdhocId(u32 productStructAddr) -{ +int sceNetAdhocctlGetAdhocId(u32 productStructAddr) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetAdhocId(%x)", productStructAddr); return 0; } -int sceNetAdhocctlScan() -{ +int sceNetAdhocctlScan() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlScan()"); - if(adhocctlHandlerPtr != 0) - { + if(adhocctlHandlerPtr != 0) { u32 args[3] = {0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF, adhocctlHandlerPtr }; __KernelDirectMipsCall(adhocctlHandlerPtr, NULL, args, 3, true); } @@ -307,21 +271,18 @@ int sceNetAdhocctlScan() return 0; } -int sceNetAdhocctlGetScanInfo() -{ +int sceNetAdhocctlGetScanInfo() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetScanInfo()"); return 0; } -int sceNetAdhocctlConnect(u32 ptrToGroupName) -{ +int sceNetAdhocctlConnect(u32 ptrToGroupName) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName); return 0; } // Write static data since we don't actually manage any memory for sceNet* yet. -int sceNetGetMallocStat(u32 statPtr) -{ +int sceNetGetMallocStat(u32 statPtr) { ERROR_LOG(HLE, "UNTESTED sceNetGetMallocStat(%x)", statPtr); if(Memory::IsValidAddress(statPtr)) Memory::WriteStruct(statPtr, &netMallocStat); @@ -331,14 +292,12 @@ int sceNetGetMallocStat(u32 statPtr) return 0; } -int sceNetAdhocMatchingInit(u32 memsize) -{ +int sceNetAdhocMatchingInit(u32 memsize) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingInit(%08x)", memsize); return 0; } -const HLEFunction sceNet[] = -{ +const HLEFunction sceNet[] = { {0x39AF39A6, sceNetInit, "sceNetInit"}, {0x281928A9, WrapU_V, "sceNetTerm"}, {0x89360950, WrapI_CU, "sceNetEtherNtostr"}, @@ -349,8 +308,7 @@ const HLEFunction sceNet[] = {0xad6844c6, 0, "sceNetThreadAbort"}, }; -const HLEFunction sceNetAdhoc[] = -{ +const HLEFunction sceNetAdhoc[] = { {0xE1D621D7, WrapU_V, "sceNetAdhocInit"}, {0xA62C6F57, WrapI_V, "sceNetAdhocTerm"}, {0x0AD043ED, 0, "sceNetAdhocctlConnect"}, @@ -379,8 +337,7 @@ const HLEFunction sceNetAdhoc[] = {0x4d2ce199, 0, "sceNetAdhocGetSocketAlert"}, }; -const HLEFunction sceNetAdhocMatching[] = -{ +const HLEFunction sceNetAdhocMatching[] = { {0x2a2a1e07, WrapI_U, "sceNetAdhocMatchingInit"}, {0x7945ecda, WrapI_V, "sceNetAdhocMatchingTerm"}, {0xca5eda6f, 0, "sceNetAdhocMatchingCreate"}, @@ -399,8 +356,7 @@ const HLEFunction sceNetAdhocMatching[] = {0x9c5cfb7d, 0, "sceNetAdhocMatchingGetPoolStat"}, }; -const HLEFunction sceNetAdhocctl[] = -{ +const HLEFunction sceNetAdhocctl[] = { {0xE26F226E, WrapU_IIU, "sceNetAdhocctlInit"}, {0x9D689E13, WrapI_V, "sceNetAdhocctlTerm"}, {0x20B317A0, WrapU_UU, "sceNetAdhocctlAddHandler"}, @@ -425,8 +381,7 @@ const HLEFunction sceNetAdhocctl[] = {0xb0b80e80, 0, "sceNetAdhocctlCreateEnterGameModeMin"}, }; -const HLEFunction sceNetResolver[] = -{ +const HLEFunction sceNetResolver[] = { {0x224c5f44, 0, "sceNetResolverStartNtoA"}, {0x244172af, 0, "sceNetResolverCreate"}, {0x94523e09, 0, "sceNetResolverDelete"}, @@ -440,8 +395,7 @@ const HLEFunction sceNetResolver[] = {0x4ee99358, 0, "sceNetResolverPollAsync"}, }; -const HLEFunction sceNetInet[] = -{ +const HLEFunction sceNetInet[] = { {0x17943399, 0, "sceNetInetInit"}, {0x2fe71fe7, 0, "sceNetInetSetsockopt"}, {0x410b34aa, 0, "sceNetInetConnect"}, @@ -475,8 +429,7 @@ const HLEFunction sceNetInet[] = {0x39b0c7d3, 0, "sceNetInetGetUdpcbstat"}, }; -const HLEFunction sceNetApctl[] = -{ +const HLEFunction sceNetApctl[] = { {0xCFB957C6, 0, "sceNetApctlConnect"}, {0x24fe91a1, 0, "sceNetApctlDisconnect"}, {0x5deac81b, 0, "sceNetApctlGetState"}, @@ -490,15 +443,13 @@ const HLEFunction sceNetApctl[] = {0x2935c45b, 0, "sceNetApctlGetBSSDescEntry2"}, }; -const HLEFunction sceWlanDrv[] = -{ +const HLEFunction sceWlanDrv[] = { {0xd7763699, WrapU_V, "sceWlanGetSwitchState"}, {0x0c622081, WrapU_U, "sceWlanGetEtherAddr"}, {0x93440B11, WrapU_V, "sceWlanDevIsPowerOn"}, }; -void Register_sceNet() -{ +void Register_sceNet() { RegisterModule("sceNet", ARRAY_SIZE(sceNet), sceNet); RegisterModule("sceNetAdhoc", ARRAY_SIZE(sceNetAdhoc), sceNetAdhoc); RegisterModule("sceNetAdhocMatching", ARRAY_SIZE(sceNetAdhocMatching), sceNetAdhocMatching); @@ -508,7 +459,6 @@ void Register_sceNet() RegisterModule("sceNetApctl", ARRAY_SIZE(sceNetApctl), sceNetApctl); } -void Register_sceWlanDrv() -{ +void Register_sceWlanDrv() { RegisterModule("sceWlanDrv", ARRAY_SIZE(sceWlanDrv), sceWlanDrv); } From f5af0bbc5429fdefa0c79ac614b9f3ef3db69e73 Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 08:52:38 -0400 Subject: [PATCH 25/37] Fix hang in Pangya, again. --- Core/HLE/sceNet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 148d3ff11d..077aa740d4 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -53,6 +53,7 @@ enum { ERROR_NET_ADHOCCTL_ALREADY_INITIALIZED = 0x80410b07, ERROR_NET_ADHOCCTL_NOT_INITIALIZED = 0x80410b08, ERROR_NET_ADHOCCTL_DISCONNECTED = 0x80410b09, + ERROR_NET_ADHOCCTL_BUSY = 0x80410b10, ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12, }; @@ -278,7 +279,7 @@ int sceNetAdhocctlGetScanInfo() { int sceNetAdhocctlConnect(u32 ptrToGroupName) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName); - return 0; + return ERROR_NET_ADHOCCTL_BUSY; } // Write static data since we don't actually manage any memory for sceNet* yet. From 490f8410935c21a3730e54a67c0e3d72075d3bab Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 18 Jun 2013 01:42:36 +1000 Subject: [PATCH 26/37] Integer division is not guaranteed for VFPv4 devices. Example: Cortex-A5. --- Common/ArmCPUDetect.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Common/ArmCPUDetect.cpp b/Common/ArmCPUDetect.cpp index 1818357de8..5d3a69669d 100644 --- a/Common/ArmCPUDetect.cpp +++ b/Common/ArmCPUDetect.cpp @@ -182,10 +182,8 @@ bool isVFP4 = false; bVFPv3 = CheckCPUFeature("vfpv3"); bTLS = CheckCPUFeature("tls"); bVFPv4 = CheckCPUFeature("vfpv4"); - // On some buggy kernels(Qualcomm) they show that they support VFPv4 but not IDIVa - // All VFPv4 CPUs will support IDIVa - bIDIVa = bVFPv4 || CheckCPUFeature("idiva"); - bIDIVt = bVFPv4 || CheckCPUFeature("idivt"); + bIDIVa = CheckCPUFeature("idiva"); + bIDIVt = CheckCPUFeature("idivt"); // These two require ARMv8 or higher bFP = CheckCPUFeature("fp"); bASIMD = CheckCPUFeature("asimd"); From c4abec356018dd8e2baa988af68517ad9d8e01c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Jun 2013 20:28:22 +0200 Subject: [PATCH 27/37] Add option for very transparent touch buttons --- Core/Config.cpp | 12 ++++-------- Core/Config.h | 3 ++- Core/Dialog/PSPOskDialog.cpp | 4 ++-- UI/EmuScreen.cpp | 14 +++++++++----- UI/GamepadEmu.cpp | 10 ++++++---- UI/GamepadEmu.h | 2 +- UI/MenuScreens.cpp | 10 ++++++++-- 7 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 6db53a4567..8ecbb5ff8b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -25,18 +25,12 @@ Config g_Config; - #ifdef IOS extern bool isJailed; #endif -Config::Config() -{ -} - -Config::~Config() -{ -} +Config::Config() { } +Config::~Config() { } void Config::Load(const char *iniFileName) { @@ -143,6 +137,7 @@ void Config::Load(const char *iniFileName) control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false); control->Get("ForceInputDevice", &iForceInputDevice, -1); control->Get("RightStickBind", &iRightStickBind, 0); + control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); pspConfig->Get("NickName", &sNickName, "shadow"); @@ -236,6 +231,7 @@ void Config::Save() control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz); control->Set("ForceInputDevice", iForceInputDevice); control->Set("RightStickBind", iRightStickBind); + control->Set("TouchButtonOpacity", iTouchButtonOpacity); IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); diff --git a/Core/Config.h b/Core/Config.h index 1b2347e05d..c0a991525e 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -90,7 +90,7 @@ public: // Sound bool bEnableSound; bool bEnableAtrac3plus; - + // UI bool bShowTouchControls; bool bShowDebuggerOnLoad; @@ -109,6 +109,7 @@ public: // Control std::map iMappingMap; // Can be used differently depending on systems int iForceInputDevice; + int iTouchButtonOpacity; // SystemParam std::string sNickName; diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 476b90d1a2..823683b835 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -795,7 +795,7 @@ int PSPOskDialog::Update() selectedChar = (selectedChar + (numKeyCols[currentKeyboard] * numKeyRows[currentKeyboard])) % (numKeyCols[currentKeyboard] * numKeyRows[currentKeyboard]); - if (IsButtonPressed(CTRL_CROSS) && g_Config.bButtonPreference || IsButtonPressed(CTRL_CIRCLE) && !g_Config.bButtonPreference) + if ((IsButtonPressed(CTRL_CROSS) && g_Config.bButtonPreference) || (IsButtonPressed(CTRL_CIRCLE) && !g_Config.bButtonPreference)) { inputChars = CombinationString(true); } @@ -816,7 +816,7 @@ int PSPOskDialog::Update() selectedChar = selectedRow * numKeyCols[currentKeyboard] + selectedExtra; } - else if (IsButtonPressed(CTRL_CIRCLE) && g_Config.bButtonPreference || IsButtonPressed(CTRL_CROSS) && !g_Config.bButtonPreference) + else if ((IsButtonPressed(CTRL_CIRCLE) && g_Config.bButtonPreference) || (IsButtonPressed(CTRL_CROSS) && !g_Config.bButtonPreference)) { if (inputChars.size() > 0) { diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 95221d819d..5ce338c37d 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -233,12 +233,15 @@ void EmuScreen::update(InputState &input) { __CtrlSetAnalog(rightstick_x, rightstick_x, 1); if (PSP_CoreParameter().fpsLimit != 2) { + // Don't really need to show these, it's pretty obvious what unthrottle does, + // in contrast to the three state toggle + /* if (input.pad_buttons_down & PAD_BUTTON_UNTHROTTLE) { osm.Show(s->T("unlimited", "Speed: unlimited!"), 1.0, 0x50E0FF); } if (input.pad_buttons_up & PAD_BUTTON_UNTHROTTLE) { osm.Show(s->T("standard", "Speed: standard"), 1.0); - } + }*/ } if (input.pad_buttons & PAD_BUTTON_UNTHROTTLE) { PSP_CoreParameter().unthrottle = true; @@ -249,22 +252,22 @@ void EmuScreen::update(InputState &input) { if (PSP_CoreParameter().fpsLimit != 0 && PSP_CoreParameter().fpsLimit != 1 && PSP_CoreParameter().fpsLimit != 2) { PSP_CoreParameter().fpsLimit = 0; } + //Toggle between 3 different states of fpsLimit if (input.pad_buttons_down & PAD_BUTTON_LEFT_THUMB) { if (PSP_CoreParameter().fpsLimit == 0) { PSP_CoreParameter().fpsLimit = 1; osm.Show(s->T("fixed", "Speed: fixed"), 1.0); } - else if (PSP_CoreParameter().fpsLimit == 1){ + else if (PSP_CoreParameter().fpsLimit == 1) { PSP_CoreParameter().fpsLimit = 2; osm.Show(s->T("unlimited", "Speed: unlimited!"), 1.0, 0x50E0FF); } - else if (PSP_CoreParameter().fpsLimit == 2){ + else if (PSP_CoreParameter().fpsLimit == 2) { PSP_CoreParameter().fpsLimit = 0; osm.Show(s->T("standard", "Speed: standard"), 1.0); } } - if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB)) { if (g_Config.bBufferedRendering) @@ -313,8 +316,9 @@ void EmuScreen::render() { ui_draw2d.Begin(UIShader_Get(), DBMODE_NORMAL); + float touchOpacity = g_Config.iTouchButtonOpacity / 100.0f; if (g_Config.bShowTouchControls) - DrawGamepad(ui_draw2d); + DrawGamepad(ui_draw2d, touchOpacity); DrawWatermark(); diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index cdcb5a7f4e..eab63aebd5 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -16,8 +16,9 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "GamepadEmu.h" +#include "base/colorutil.h" #include "ui/virtual_input.h" -#include "../../Core/Config.h" +#include "Core/Config.h" #include "ui_atlas.h" TouchButton buttonX(&ui_atlas, I_ROUND, I_CROSS, PAD_BUTTON_A); @@ -112,10 +113,11 @@ void UpdateGamepad(InputState &input_state) leftStick.update(input_state); } -void DrawGamepad(DrawBuffer &db) +void DrawGamepad(DrawBuffer &db, float opacity) { - uint32_t color = 0xa0c0b080; - uint32_t colorOverlay = 0xa0FFFFFF; + uint32_t color = colorAlpha(0xc0b080, opacity); + uint32_t colorOverlay = colorAlpha(0xFFFFFF, opacity); + buttonO.draw(db, color, colorOverlay); buttonX.draw(db, color, colorOverlay); buttonTri.draw(db, color, colorOverlay); diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index 85a79b7266..3f6d8b964d 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -22,4 +22,4 @@ void LayoutGamepad(int w, int h); void UpdateGamepad(InputState &input_state); -void DrawGamepad(DrawBuffer &db); \ No newline at end of file +void DrawGamepad(DrawBuffer &db, float opacity); diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 729ce667c7..21bcad9412 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -658,7 +658,7 @@ void DeveloperScreen::render() { } if (UIButton(GEN_ID, vlinear, w, 0, d->T("Save language ini"), ALIGN_LEFT)) { - i18nrepo.SaveIni(g_Config.languageIni); + i18nrepo.SaveIni(g_Config.languageIni); } if (UIButton(GEN_ID, vlinear, w, 0, d->T("Run CPU tests"), ALIGN_LEFT)) { @@ -1119,7 +1119,13 @@ void ControlsScreen::render() { if (g_Config.bShowTouchControls) { UICheckBox(GEN_ID, x, y += stride, c->T("Large Controls"), ALIGN_TOPLEFT, &g_Config.bLargeControls); UICheckBox(GEN_ID, x, y += stride, c->T("Show Analog Stick"), ALIGN_TOPLEFT, &g_Config.bShowAnalogStick); - } + // This will be a slider in the new UI later + bool bTransparent = g_Config.iTouchButtonOpacity < 30; + bool prev = bTransparent; + UICheckBox(GEN_ID, x, y += stride, c->T("Transparent Buttons"), ALIGN_TOPLEFT, &bTransparent); + if (bTransparent != prev) + g_Config.iTouchButtonOpacity = bTransparent ? 15 : 65; + } UICheckBox(GEN_ID, x, y += stride, c->T("Tilt", "Tilt to Analog (horizontal)"), ALIGN_TOPLEFT, &g_Config.bAccelerometerToAnalogHoriz); UIEnd(); From 5fc11fa99c006aaf3713e90c0a9a455776f4097c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Jun 2013 20:45:08 +0200 Subject: [PATCH 28/37] Turn off forced linear filtering if colortest enabled --- GPU/GLES/TextureCache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 8506ff03de..7fd6468fe1 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -514,7 +514,7 @@ void TextureCache::UpdateSamplingParams(TexCacheEntry &entry, bool force) { } } - if (g_Config.bLinearFiltering) { + if (g_Config.bLinearFiltering && !gstate.isColorTestEnabled()) { magFilt |= 1; minFilt |= 1; } @@ -523,7 +523,7 @@ void TextureCache::UpdateSamplingParams(TexCacheEntry &entry, bool force) { magFilt &= 1; minFilt &= 1; } - + if (force || entry.minFilt != minFilt) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFiltGL[minFilt]); entry.minFilt = minFilt; From e00c345b1d1ea2e21be1bd8d6afcd47ba0c9470d Mon Sep 17 00:00:00 2001 From: jtraynham Date: Mon, 17 Jun 2013 14:06:00 -0500 Subject: [PATCH 29/37] Make the iOS build only compile for the armv7 architecture --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c2800ec37..9791a44f66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,6 +156,7 @@ if(NOT MSVC) if(IOS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") + set(CMAKE_OSX_ARCHITECTURES "armv7") elseif(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -U__STRICT_ANSI__") # Karen/angelXwind: --macosx-version-min=10.7 is needed in order to produce binaries that OS X 10.7 Lion can execute. However, it seems that PPSSPP won't support 10.6 or lower without getting rid of -stdlib=libc++ ...which probably won't end well. So I guess PPSSPP will strictly be a 10.7+ app. From 806fadb1c042ccf10de3d851e221c72fe31dec60 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 17 Jun 2013 00:24:39 +0200 Subject: [PATCH 30/37] logging tweak --- Core/HLE/sceSas.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index bd6554d6d4..7f4f25375f 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -148,7 +148,11 @@ u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop) { } if (size <= 0 || (size & 0xF) != 0) { - WARN_LOG(HLE, "%s: invalid size %d", __FUNCTION__, size); + if (size == 0) { + DEBUG_LOG(HLE, "%s: invalid size %d", __FUNCTION__, size); + } else { + WARN_LOG(HLE, "%s: invalid size %d", __FUNCTION__, size); + } return ERROR_SAS_INVALID_SIZE; } From fc1a8fc1f3f6cf8d629fd5dfadf5fe75ac334dee Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Mon, 17 Jun 2013 17:44:41 -0500 Subject: [PATCH 31/37] Fix bug with titles containing "/" Also, add comments to help those reading the code. --- Core/CwCheat.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 554985c6c7..9d2bf42861 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -23,6 +23,9 @@ void __CheatInit() { if (gameTitle.find("™")!= std::string::npos) { gameTitle.erase (gameTitle.find("™"), std::string::npos); } + while (gameTitle.find("/")!= std::string::npos) { + gameTitle.replace (gameTitle.find("/"),1," "); + } activeCheatFile = CHEATS_DIR + "/" + gameTitle +".ini"; File::CreateFullPath(CHEATS_DIR); @@ -51,7 +54,7 @@ void __CheatShutdown() { void hleCheat(u64 userdata, int cyclesLate) { CoreTiming::ScheduleEvent(msToCycles(77), CheatEvent, 0); - if (g_Config.bReloadCheats == true) { + if (g_Config.bReloadCheats == true) { //Checks if the "reload cheats" button has been pressed. cheatEngine->CreateCodeList(); g_Config.bReloadCheats = false; } @@ -67,7 +70,7 @@ CWCheatEngine::CWCheatEngine() { void CWCheatEngine::Exit() { exit2 = true; } -void CWCheatEngine::CreateCodeList() { +void CWCheatEngine::CreateCodeList() { //Creates code list to be used in function GetNextCode initialCodesList = GetCodesList(); std::string currentcode, codename; std::vector codelist; @@ -99,7 +102,7 @@ void CWCheatEngine::CreateCodeList() { } parts = makeCodeParts(codelist); } -inline std::vector makeCodeParts(std::vector CodesList) { +inline std::vector makeCodeParts(std::vector CodesList) { //Takes a single code line and creates a two-part vector for all codes. Feeds to CreateCodeList std::string currentcode; std::vector finalList; char split_char = '\n'; @@ -120,7 +123,7 @@ inline std::vector makeCodeParts(std::vector CodesList } return finalList; } -std::vector CWCheatEngine::GetNextCode() { +std::vector CWCheatEngine::GetNextCode() { // Feeds a size-2 vector of ints to Run() which contains the address and value of one cheat. std::string code1; std::string code2; std::vector splitCode; @@ -162,8 +165,7 @@ void CWCheatEngine::SkipAllCodes() { currentCode = codes.size(); } -int CWCheatEngine::GetAddress(int value) { - // The User space base address has to be added to given value +int CWCheatEngine::GetAddress(int value) { //Returns static address used by ppsspp. Some games may not like this, and causes cheats to not work without offset return (value + 0x08800000) & 0x3FFFFFFF; } @@ -178,7 +180,7 @@ inline void trim2(std::string& str) { else str.erase(str.begin(), str.end()); } -std::vector CWCheatEngine::GetCodesList() { +std::vector CWCheatEngine::GetCodesList() { //Reads the entire cheat list from the appropriate .ini. std::string line; std::vector codesList; // Read from INI here std::ifstream list(activeCheatFile.c_str()); From 4d3cd4d23522caf1f5cc440d1edc4c1c6055c755 Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 18:50:38 -0400 Subject: [PATCH 32/37] Add support for multiple adhocctl handlers, and clean up how we call them slightly. --- Core/HLE/sceNet.cpp | 94 ++++++++++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 30 deletions(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 077aa740d4..c3c21075a0 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -23,10 +23,12 @@ #include "sceKernelThread.h" #include "sceUtility.h" +#include + static bool netInited; static bool netAdhocInited; -static u32 adhocctlHandlerPtr; +static u32 adhocctlHandlerCount; enum { ERROR_NET_BUFFER_TOO_SMALL = 0x80400706, @@ -74,25 +76,44 @@ struct SceNetMallocStat { int pool; // Pointer to the pool? int maximum; // Maximum size of the pool? int free; // How much memory is free +} static netMallocStat; + +struct AdhocctlHandler +{ + u32 entryPoint; + u32 argument; + u32 id; }; -static struct SceNetMallocStat netMallocStat; +static std::vector adhocctlHandlers; void __NetInit() { netInited = false; netAdhocInited = false; - adhocctlHandlerPtr = 0; } void __NetShutdown() { } +void __UpdateAdhocctlHandlers(int flag, int error) { + u32 args[3] = { 0, 0, 0 }; + for(std::vector::iterator it = adhocctlHandlers.begin(); it < adhocctlHandlers.end(); it++) { + args[0] = flag; + args[1] = error; + args[2] = it->argument; + + __KernelDirectMipsCall(it->entryPoint, NULL, args, 3, false); + } +} + // This feels like a dubious proposition, mostly... void __NetDoState(PointerWrap &p) { p.Do(netInited); p.Do(netAdhocInited); - p.Do(adhocctlHandlerPtr); + p.Do(adhocctlHandlers); + p.Do(adhocctlHandlerCount); + p.Do(netMallocStat); p.DoMarker("net"); } @@ -100,10 +121,12 @@ void __NetDoState(PointerWrap &p) { void sceNetInit() { ERROR_LOG(HLE,"UNIMPL sceNetInit(poolsize=%d, calloutpri=%i, calloutstack=%d, netintrpri=%i, netintrstack=%d)", PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); netInited = true; + memset(&netMallocStat, 0, sizeof(netMallocStat)); netMallocStat.maximum = PARAM(0); netMallocStat.free = PARAM(0); netMallocStat.pool = 0; - RETURN(0); //ERROR + + RETURN(0); //ERROR <- The Dax: Why is it an error when it returns 0 on success? } u32 sceNetTerm() { @@ -146,34 +169,45 @@ u32 sceWlanGetSwitchState() { } // TODO: How many handlers can the PSP actually have for Adhocctl? -u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 unknown) { - WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x)", handlerPtr, unknown); - if(adhocctlHandlerPtr == 0) { - adhocctlHandlerPtr = handlerPtr; - DEBUG_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler", handlerPtr, unknown); - } - else { - WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Too many handlers already!", handlerPtr, unknown); - return ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS; +// TODO: Should we allow the same handler to be added more than once? +u32 sceNetAdhocctlAddHandler(u32 handlerPtr, u32 handlerArg) { + bool foundHandler = false; + struct AdhocctlHandler handler; + memset(&handler, 0, sizeof(handler)); + handler.entryPoint = handlerPtr; + handler.argument = handlerArg; + handler.id = -1; + + for(std::vector::iterator it = adhocctlHandlers.begin(); it < adhocctlHandlers.end(); it++) { + if(it->entryPoint == handlerPtr) { + foundHandler = true; + break; + } } - return 0; + if(!foundHandler && Memory::IsValidAddress(handlerPtr)) { + handler.id = adhocctlHandlerCount > 0? ++adhocctlHandlerCount : 0; + adhocctlHandlers.push_back(handler); + WARN_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): added handler %d", handlerPtr, handlerArg, handler.id); + } + else + ERROR_LOG(HLE, "UNTESTED sceNetAdhocctlAddHandler(%x, %x): Same handler already exists", handlerPtr, handlerArg); + + + return handler.id; } u32 sceNetAdhocctlDisconnect() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()"); + __UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF); + return 0; } -u32 sceNetAdhocctlDelHandler(u32 handlerPtr) { - WARN_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%x)", handlerPtr); - - if(adhocctlHandlerPtr > 0) { - adhocctlHandlerPtr = 0; - DEBUG_LOG(HLE, "sceNetAdhocctlDelHandler(%x): deleted handler", handlerPtr); - } - else - WARN_LOG(HLE, "sceNetAdhocctlDelHandler(%x): asked to delete invalid handler", handlerPtr); +u32 sceNetAdhocctlDelHandler(u32 handlerID) { + WARN_LOG(HLE, "UNTESTED sceNetAdhocctlDelHandler(%x)", handlerID); + adhocctlHandlers.erase(adhocctlHandlers.begin() + handlerID); + adhocctlHandlerCount = adhocctlHandlerCount > 0? --adhocctlHandlerCount : adhocctlHandlerCount; return 0; } @@ -203,6 +237,7 @@ int sceNetEtherNtostr(const char *mac, u32 bufferPtr) { } else ERROR_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x): Tried to write to an invalid pointer", mac, bufferPtr); + return 0; } @@ -226,7 +261,7 @@ int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) // TODO: Should we really write the struct if we're disconnected? int sceNetAdhocctlGetParameter(u32 paramAddr) { - ERROR_LOG(HLE, "UNIMPL %x=sceNetAdhocctlGetParameter(%x)", 0, paramAddr); + ERROR_LOG(HLE, "UNTESTED %x=sceNetAdhocctlGetParameter(%x)", 0, paramAddr); struct SceNetAdhocctlParams params; params.channel = 0; for(int i = 0; i < 6; i++) @@ -264,10 +299,7 @@ int sceNetAdhocctlGetAdhocId(u32 productStructAddr) { int sceNetAdhocctlScan() { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlScan()"); - if(adhocctlHandlerPtr != 0) { - u32 args[3] = {0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF, adhocctlHandlerPtr }; - __KernelDirectMipsCall(adhocctlHandlerPtr, NULL, args, 3, true); - } + __UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF); return 0; } @@ -279,7 +311,9 @@ int sceNetAdhocctlGetScanInfo() { int sceNetAdhocctlConnect(u32 ptrToGroupName) { ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlConnect(%x)", ptrToGroupName); - return ERROR_NET_ADHOCCTL_BUSY; + __UpdateAdhocctlHandlers(0, ERROR_NET_ADHOCCTL_WLAN_SWITCH_OFF); + + return 0; } // Write static data since we don't actually manage any memory for sceNet* yet. From f0072380aa473c697b3936e987fc28118c8704f3 Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 18:56:52 -0400 Subject: [PATCH 33/37] Fix handler reschedule. Pretty sure these should reschedule after being executed. --- Core/HLE/sceNet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index c3c21075a0..6df5a58c30 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -103,7 +103,7 @@ void __UpdateAdhocctlHandlers(int flag, int error) { args[1] = error; args[2] = it->argument; - __KernelDirectMipsCall(it->entryPoint, NULL, args, 3, false); + __KernelDirectMipsCall(it->entryPoint, NULL, args, 3, true); } } From 83549aa43eab7619b263041a7ddc09129453a605 Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Mon, 17 Jun 2013 17:58:29 -0500 Subject: [PATCH 34/37] Another small fix for ":" character --- Core/CwCheat.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 9d2bf42861..2c0d93934f 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -20,12 +20,16 @@ void trim2(std::string& str); void __CheatInit() { //Moved createFullPath to CheatInit from the constructor because it spams the log and constantly checks if exists. In here, only checks once. std::string gameTitle = g_paramSFO.GetValueString("DISC_ID") + " - " + g_paramSFO.GetValueString("TITLE"); + //These 3 statements clean up the title, which sometimes contain characters that will cause problems when creating the .ini if (gameTitle.find("™")!= std::string::npos) { gameTitle.erase (gameTitle.find("™"), std::string::npos); } while (gameTitle.find("/")!= std::string::npos) { gameTitle.replace (gameTitle.find("/"),1," "); } + if (gameTitle.find(":")!= std::string::npos) { + gameTitle.replace (gameTitle.find(":"),1," "); + } activeCheatFile = CHEATS_DIR + "/" + gameTitle +".ini"; File::CreateFullPath(CHEATS_DIR); From 196d1dbf463c8b74c8c8332af44ab098c4e043b4 Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 19:03:56 -0400 Subject: [PATCH 35/37] Remove unnecessary include. --- Core/HLE/sceNet.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 6df5a58c30..6994fe498b 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -23,8 +23,6 @@ #include "sceKernelThread.h" #include "sceUtility.h" -#include - static bool netInited; static bool netAdhocInited; From c1fc92c29b6af6507d44a8acaf5297b1aafb95e9 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 18 Jun 2013 01:21:20 +0200 Subject: [PATCH 36/37] Fit more languages on the language screen, trying to fix #731 temporarily. Also add home button to file selector. --- UI/MenuScreens.cpp | 27 +++++++++++++++++++++------ UI/NativeApp.cpp | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 21bcad9412..ba70798f84 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -960,17 +960,28 @@ void LanguageScreen::render() { I18NCategory *g = GetI18NCategory("General"); I18NCategory *l = GetI18NCategory("Language"); - ui_draw2d.SetFontScale(1.5f, 1.5f); - ui_draw2d.DrawText(UBUNTU24, s->T("Language"), dp_xres / 2, 10, 0xFFFFFFFF, ALIGN_HCENTER); - ui_draw2d.SetFontScale(1.0f, 1.0f); + bool small = dp_xres < 720; + + if (!small) { + ui_draw2d.SetFontScale(1.5f, 1.5f); + ui_draw2d.DrawText(UBUNTU24, s->T("Language"), dp_xres / 2, 10, 0xFFFFFFFF, ALIGN_HCENTER); + ui_draw2d.SetFontScale(1.0f, 1.0f); + } if (UIButton(GEN_ID, Pos(dp_xres - 10, dp_yres-10), LARGE_BUTTON_WIDTH, 0, g->T("Back"), ALIGN_RIGHT | ALIGN_BOTTOM)) { screenManager()->finishDialog(this, DR_OK); } - VGrid vlang(50, 100, dp_yres - 50, 10, 10); + int buttonW = LARGE_BUTTON_WIDTH - 50; + + if (small) { + buttonW = LARGE_BUTTON_WIDTH - 70; + } + + VGrid vlang(20, small ? 20 : 100, dp_yres - 50, 10, 10); std::string text; + for (size_t i = 0; i < langs_.size(); i++) { std::string code; size_t dot = langs_[i].name.find('.'); @@ -1015,7 +1026,7 @@ void LanguageScreen::render() { } } - if (UIButton(GEN_ID_LOOP(i), vlang, LARGE_BUTTON_WIDTH - 30, 0, buttonTitle.c_str(), ALIGN_TOPLEFT)) { + if (UIButton(GEN_ID_LOOP(i), vlang, buttonW, 0, buttonTitle.c_str(), ALIGN_TOPLEFT)) { std::string oldLang = g_Config.languageIni; g_Config.languageIni = code; @@ -1242,7 +1253,11 @@ void FileSelectScreen::render() { currentDirectory_ = getDir(currentDirectory_); updateListing(); } - ui_draw2d.DrawTextShadow(UBUNTU24, currentDirectory_.c_str(), 20 + SMALL_BUTTON_WIDTH, 10 + 25, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER); + if (UIButton(GEN_ID, Pos(SMALL_BUTTON_WIDTH + 20,10), SMALL_BUTTON_WIDTH, 0, g->T("Home"), ALIGN_TOPLEFT)) { + currentDirectory_ = g_Config.externalDirectory; + updateListing(); + } + ui_draw2d.DrawTextShadow(UBUNTU24, currentDirectory_.c_str(), 30 + SMALL_BUTTON_WIDTH*2, 10 + 25, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER); if (UIButton(GEN_ID, Pos(dp_xres - 10, 10), SMALL_BUTTON_WIDTH, 0, g->T("Back"), ALIGN_RIGHT)) { g_Config.Save(); screenManager()->switchScreen(new MenuScreen()); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 8b226997e2..37af83f56f 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -234,6 +234,7 @@ void NativeInit(int argc, const char *argv[], config_filename = user_data_path + "/ppsspp.ini"; g_Config.Load(config_filename.c_str()); + g_Config.externalDirectory = external_directory; #endif const char *fileToLog = 0; From b5a2c0d8c199a8b312d625967e00e5c4a249c921 Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 17 Jun 2013 19:27:59 -0400 Subject: [PATCH 37/37] Fix style error. --- Core/HLE/sceNet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 6994fe498b..bca7fac1df 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -74,7 +74,9 @@ struct SceNetMallocStat { int pool; // Pointer to the pool? int maximum; // Maximum size of the pool? int free; // How much memory is free -} static netMallocStat; +}; + +static struct SceNetMallocStat netMallocStat; struct AdhocctlHandler {