From 087cb8b5e03714b6821bd8ffbd6fb54b07a7905e Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 27 Jul 2013 06:24:59 +0800 Subject: [PATCH 01/25] Clamp vpX0/vpY0 to zero when negative value retured --- GPU/GLES/StateMapping.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 6b7a53cc93..501c31bd33 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -364,6 +364,11 @@ void TransformDrawEngine::ApplyDrawState(int prim) { // Flip vpY0 to match the OpenGL coordinate system. vpY0 = renderHeight - (vpY0 + vpHeight); + + // Clamp vpX0/vpY0 to zero when negative value retured. + vpY0 = vpY0 < 0 ? 0 : vpY0; + vpX0 = vpX0 < 0 ? 0 : vpX0; + glstate.viewport.set(vpX0 + renderX, vpY0 + renderY, vpWidth, vpHeight); // Sadly, as glViewport takes integers, we will not be able to support sub pixel offsets this way. But meh. // shaderManager_->DirtyUniform(DIRTY_PROJMATRIX); From 116d238d2e4f7d93ff85019264665f37e5103316 Mon Sep 17 00:00:00 2001 From: The Dax Date: Fri, 26 Jul 2013 19:06:29 -0400 Subject: [PATCH 02/25] Win32 UI: Remove secondary loop for unchecking/checking Window Zoom options. It was not needed, and caused a bug.. --- Windows/WndMainWindow.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index a6aa1d02f1..0ef2f916e4 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -1210,7 +1210,7 @@ namespace MainWindow ID_OPTIONS_SCREEN4X, }; for (int i = 0; i < 4; i++) { - CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom - 1) ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom-1) ? MF_CHECKED : MF_UNCHECKED)); } static const int texscalingitems[] = { @@ -1270,16 +1270,6 @@ namespace MainWindow CheckMenuItem(menu, frameskipping[i], MF_BYCOMMAND | ( i == g_Config.iFrameSkip )? MF_CHECKED : MF_UNCHECKED); } - static const int zoommode[] = { - ID_OPTIONS_SCREEN1X, - ID_OPTIONS_SCREEN2X, - ID_OPTIONS_SCREEN3X, - ID_OPTIONS_SCREEN4X, - }; - for (int i = 0; i < 4; i++) { - CheckMenuItem(menu, zoommode[i], MF_BYCOMMAND | ( i == g_Config.iWindowZoom )? MF_CHECKED : MF_UNCHECKED); - } - UpdateCommands(); } From 738338f8beddb7115ddb9112c3a6379f54ff792d Mon Sep 17 00:00:00 2001 From: The Dax Date: Fri, 26 Jul 2013 19:08:24 -0400 Subject: [PATCH 03/25] Fix typo. --- Windows/WndMainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 0ef2f916e4..040f6b7425 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -1210,7 +1210,7 @@ namespace MainWindow ID_OPTIONS_SCREEN4X, }; for (int i = 0; i < 4; i++) { - CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom-1) ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom - 1) ? MF_CHECKED : MF_UNCHECKED)); } static const int texscalingitems[] = { From 883db82255ebb11b89f04c35181f69e441317869 Mon Sep 17 00:00:00 2001 From: The Dax Date: Fri, 26 Jul 2013 19:29:47 -0400 Subject: [PATCH 04/25] Win32 UI: Fix frameskipping menu. Picking 9 would never be checked or work. --- Windows/WndMainWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 040f6b7425..0e1afe63bc 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -1221,7 +1221,7 @@ namespace MainWindow ID_TEXTURESCALING_5X, }; for (int i = 0; i < 5; i++) { - CheckMenuItem(menu, texscalingitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingLevel-1) ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(menu, texscalingitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingLevel - 1) ? MF_CHECKED : MF_UNCHECKED)); } static const int texscalingtypeitems[] = { @@ -1266,7 +1266,7 @@ namespace MainWindow ID_OPTIONS_FRAMESKIP_8, ID_OPTIONS_FRAMESKIP_9, }; - for (int i = 0; i < 9; i++) { + for (int i = 0; i < 10; i++) { CheckMenuItem(menu, frameskipping[i], MF_BYCOMMAND | ( i == g_Config.iFrameSkip )? MF_CHECKED : MF_UNCHECKED); } From c7a82b59e9fa593e51959d6e06f2e7bc221ae76e Mon Sep 17 00:00:00 2001 From: The Dax Date: Fri, 26 Jul 2013 19:36:16 -0400 Subject: [PATCH 05/25] Convert all of the checkbox loops to use ARRAY_SIZE instead of magic numbers. --- Windows/WndMainWindow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 0e1afe63bc..6ee22231fd 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -1209,7 +1209,7 @@ namespace MainWindow ID_OPTIONS_SCREEN3X, ID_OPTIONS_SCREEN4X, }; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < ARRAY_SIZE(zoomitems); i++) { CheckMenuItem(menu, zoomitems[i], MF_BYCOMMAND | ((i == g_Config.iWindowZoom - 1) ? MF_CHECKED : MF_UNCHECKED)); } @@ -1220,7 +1220,7 @@ namespace MainWindow ID_TEXTURESCALING_4X, ID_TEXTURESCALING_5X, }; - for (int i = 0; i < 5; i++) { + for (int i = 0; i < ARRAY_SIZE(texscalingitems); i++) { CheckMenuItem(menu, texscalingitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingLevel - 1) ? MF_CHECKED : MF_UNCHECKED)); } @@ -1230,7 +1230,7 @@ namespace MainWindow ID_TEXTURESCALING_BICUBIC, ID_TEXTURESCALING_HYBRID_BICUBIC, }; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < ARRAY_SIZE(texscalingtypeitems); i++) { CheckMenuItem(menu, texscalingtypeitems[i], MF_BYCOMMAND | ((i == g_Config.iTexScalingType) ? MF_CHECKED : MF_UNCHECKED)); } @@ -1240,7 +1240,7 @@ namespace MainWindow ID_OPTIONS_LINEARFILTERING, ID_OPTIONS_LINEARFILTERING_CG, }; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < ARRAY_SIZE(texfilteringitems); i++) { CheckMenuItem(menu, texfilteringitems[i], MF_BYCOMMAND | ( (i + 1) == g_Config.iTexFiltering )? MF_CHECKED : MF_UNCHECKED); } @@ -1250,7 +1250,7 @@ namespace MainWindow ID_OPTIONS_READFBOTOMEMORYCPU, ID_OPTIONS_READFBOTOMEMORYGPU, }; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < ARRAY_SIZE(renderingmode); i++) { CheckMenuItem(menu, renderingmode[i], MF_BYCOMMAND | ( i == g_Config.iRenderingMode )? MF_CHECKED : MF_UNCHECKED); } @@ -1266,7 +1266,7 @@ namespace MainWindow ID_OPTIONS_FRAMESKIP_8, ID_OPTIONS_FRAMESKIP_9, }; - for (int i = 0; i < 10; i++) { + for (int i = 0; i < ARRAY_SIZE(frameskipping); i++) { CheckMenuItem(menu, frameskipping[i], MF_BYCOMMAND | ( i == g_Config.iFrameSkip )? MF_CHECKED : MF_UNCHECKED); } From 349d4eba2b0da397fb5b47452615318f6fc6925a Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 27 Jul 2013 00:38:42 -0400 Subject: [PATCH 06/25] 64-bit PPSSPP(Windows): Attempt to fix games that crash with Atrac3plusdecoder64.dll. It seems to be caused by m_audiocontext being null.. --- Core/HW/MediaEngine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index 17c3f542f3..6de39474cc 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -589,7 +589,10 @@ int MediaEngine::getAudioSamples(u8* buffer) { return 0; } int outbytes = 0; - Atrac3plus_Decoder::Decode(m_audioContext, audioFrame, frameSize, &outbytes, buffer); + + if(m_audioContext != nullptr) + Atrac3plus_Decoder::Decode(m_audioContext, audioFrame, frameSize, &outbytes, buffer); + if (headerCode1 == 0x24) { // it a mono atrac3plus, convert it to stereo s16 *outbuf = (s16*)buffer; From ddc2c15ce8eabefd80bd65c1bc9459b514378023 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:12:12 -0700 Subject: [PATCH 07/25] Remove some unsigned < 0 comparisons. --- Core/HLE/sceAtrac.cpp | 5 ----- Core/HLE/sceAudio.cpp | 4 ++-- Core/HLE/sceKernelMemory.cpp | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index effd72f489..32600ca637 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1734,11 +1734,6 @@ int sceAtracSetAA3HalfwayBufferAndGetID(u32 halfBuffer, u32 readSize, u32 halfBu return ATRAC_ERROR_INCORRECT_READ_SIZE; } - 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; diff --git a/Core/HLE/sceAudio.cpp b/Core/HLE/sceAudio.cpp index 8afcf6f1fc..3f0738dc4f 100644 --- a/Core/HLE/sceAudio.cpp +++ b/Core/HLE/sceAudio.cpp @@ -313,7 +313,7 @@ u32 sceAudioOutput2Reserve(u32 sampleCount) { u32 sceAudioOutput2OutputBlocking(u32 vol, u32 dataPtr){ // Note: 0xFFFFF, not 0xFFFF! - if (vol < 0 || vol > 0xFFFFF) { + if (vol > 0xFFFFF) { ERROR_LOG(HLE,"sceAudioOutput2OutputBlocking(%08x, %08x) - invalid volume", vol, dataPtr); return SCE_ERROR_AUDIO_INVALID_VOLUME; } @@ -401,7 +401,7 @@ u32 sceAudioSRCChRelease() { } u32 sceAudioSRCOutputBlocking(u32 vol, u32 buf) { - if (vol < 0 || vol > 0xFFFFF) { + if (vol > 0xFFFFF) { ERROR_LOG(HLE,"sceAudioSRCOutputBlocking(%08x, %08x) - invalid volume", vol, buf); return SCE_ERROR_AUDIO_INVALID_VOLUME; } diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 764b9bae8c..ab65d02389 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -1261,7 +1261,7 @@ u32 AllocMemoryBlock(const char *pname, u32 type, u32 size, u32 paramsAddr) { WARN_LOG(HLE, "AllockMemoryBlock(SysMemUserForUser_FE707FDF) : unknown parameters with length %d", length); } } - if (type < 0 || type > 1) { + if (type > 1) { return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE; } From 04b636e889cd5a47da1bd93eab75936686077168 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:12:47 -0700 Subject: [PATCH 08/25] Simplify and avoid a shift size warning. --- Core/HW/OMAConvert.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/HW/OMAConvert.cpp b/Core/HW/OMAConvert.cpp index 4064eb3203..c719e6e1ac 100644 --- a/Core/HW/OMAConvert.cpp +++ b/Core/HW/OMAConvert.cpp @@ -23,6 +23,11 @@ template void BigEndianWriteBuf(u8* buf, T x, int &pos) pos += k; } +template <> void BigEndianWriteBuf(u8* buf, u8 x, int &pos) +{ + buf[pos++] = x; +} + template inline T getBufValue(T* buf, int offsetbytes) { return *(T*)(((u8*)buf) + offsetbytes); From fa3b608b362567b0d17de20e838ea9514368f313 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:13:09 -0700 Subject: [PATCH 09/25] Fix a missing log argument. --- Core/FileSystems/DirectoryFileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index 38eae20467..2e0324195f 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -988,7 +988,7 @@ size_t VirtualDiscFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size) { int fileIndex = getFileListIndex(iter->second.curOffset,size*2048); if (fileIndex == -1) { - ERROR_LOG(HLE,"VirtualDiscFileSystem: Reading from unknown address", handle); + ERROR_LOG(HLE,"VirtualDiscFileSystem: Reading from unknown address %08x", handle); return 0; } From efb1eddbc84c1d19aa7275f5fe0cba0449f9c83a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:13:43 -0700 Subject: [PATCH 10/25] Remove an unused private var. --- GPU/GLES/TransformPipeline.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index 7bc2c33912..93051632d8 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -219,7 +219,6 @@ public: void Light(float colorOut0[4], float colorOut1[4], const float colorIn[4], Vec3 pos, Vec3 normal); private: - bool disabled_; Color4 globalAmbient; Color4 materialEmissive; Color4 materialAmbient; From 0cd5766f501fe962947447b5e472fb82c5214f42 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:13:57 -0700 Subject: [PATCH 11/25] Support clang as well as gcc for Android/Linux. --- Common/ArmEmitter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Common/ArmEmitter.cpp b/Common/ArmEmitter.cpp index c66c1b3a88..4c98f063b0 100644 --- a/Common/ArmEmitter.cpp +++ b/Common/ArmEmitter.cpp @@ -320,8 +320,12 @@ void ARMXEmitter::FlushIcacheSection(u8 *start, u8 *end) // Header file says this is equivalent to: sys_icache_invalidate(start, end - start); sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start); #elif !defined(_WIN32) +#ifdef __clang__ + __clear_cache(start, end); +#else __builtin___clear_cache(start, end); #endif +#endif } void ARMXEmitter::SetCC(CCFlags cond) From e3555185498aab2c6f006bebb8713cfcb013fe9c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:30:05 -0700 Subject: [PATCH 12/25] Fix a bad enum compare. --- Core/MIPS/ARM/ArmRegCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/MIPS/ARM/ArmRegCache.cpp b/Core/MIPS/ARM/ArmRegCache.cpp index ce2fcaf6b5..a153137254 100644 --- a/Core/MIPS/ARM/ArmRegCache.cpp +++ b/Core/MIPS/ARM/ArmRegCache.cpp @@ -193,7 +193,7 @@ void ArmRegCache::FlushR(MIPSReg r) { break; case ML_ARMREG: - if (mr[r].reg == (int)INVALID_REG) { + if (mr[r].reg == INVALID_REG) { ERROR_LOG(HLE, "FlushMipsReg: MipsReg had bad ArmReg"); } if (ar[mr[r].reg].isDirty) { From 7c238f4567fcf0b14b84221956f4ec02f1659ace Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:30:17 -0700 Subject: [PATCH 13/25] Avoid a signed/unsigned compare. This one is pretty pedantic. --- Core/MIPS/ARM/ArmCompFPU.cpp | 4 ++-- Core/MIPS/JitCommon/JitBlockCache.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/MIPS/ARM/ArmCompFPU.cpp b/Core/MIPS/ARM/ArmCompFPU.cpp index a116c715d6..3b7b8cef84 100644 --- a/Core/MIPS/ARM/ArmCompFPU.cpp +++ b/Core/MIPS/ARM/ArmCompFPU.cpp @@ -56,10 +56,10 @@ void Jit::Comp_FPU3op(u32 op) case 2: { //F(fd) = F(fs) * F(ft); //mul u32 nextOp = Memory::Read_Instruction(js.compilerPC + 4); // Optimise possible if destination is the same - if (fd == ((nextOp>>6) & 0x1F)) { + if (fd == (int)((nextOp>>6) & 0x1F)) { // VMUL + VNEG -> VNMUL if (!strcmp(MIPSGetName(nextOp), "neg.s")) { - if (fd == ((nextOp>>11) & 0x1F)) { + if (fd == (int)((nextOp>>11) & 0x1F)) { VNMUL(fpr.R(fd), fpr.R(fs), fpr.R(ft)); EatInstruction(nextOp); } diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index d626ad5538..6c28292462 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -329,7 +329,7 @@ void JitBlockCache::DestroyBlock(int block_num, bool invalidate) return; } b.invalid = true; - if ((int)Memory::ReadUnchecked_U32(b.originalAddress) == GetEmuHackOpForBlock(block_num)) + if (Memory::ReadUnchecked_U32(b.originalAddress) == GetEmuHackOpForBlock(block_num)) Memory::WriteUnchecked_U32(b.originalFirstOpcode, b.originalAddress); b.normalEntry = 0; From 6ffaf98d7f0772a5ebaeb5d051e4b09f59c8ce2d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:37:47 -0700 Subject: [PATCH 14/25] Try to force gcc to notice hasNormal(). --- GPU/GLES/VertexDecoder.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GPU/GLES/VertexDecoder.h b/GPU/GLES/VertexDecoder.h index 22278e249c..8677a89da8 100644 --- a/GPU/GLES/VertexDecoder.h +++ b/GPU/GLES/VertexDecoder.h @@ -210,7 +210,7 @@ class VertexReader public: VertexReader(u8 *base, const DecVtxFormat &decFmt, int vtype) : base_(base), data_(base), decFmt_(decFmt), vtype_(vtype) {} - void ReadPos(float pos[3]) { + void ReadPos(float pos[3]) const { switch (decFmt_.posfmt) { case DEC_FLOAT_3: { @@ -259,7 +259,7 @@ public: } } - void ReadNrm(float nrm[3]) { + void ReadNrm(float nrm[3]) const { switch (decFmt_.nrmfmt) { case DEC_FLOAT_3: //memcpy(nrm, data_ + decFmt_.nrmoff, 12); @@ -290,7 +290,7 @@ public: } } - void ReadUV(float uv[2]) { + void ReadUV(float uv[2]) const { switch (decFmt_.uvfmt) { case DEC_U8_2: { @@ -330,7 +330,7 @@ public: } } - void ReadColor0(float color[4]) { + void ReadColor0(float color[4]) const { switch (decFmt_.c0fmt) { case DEC_U8_4: { @@ -349,7 +349,7 @@ public: } } - void ReadColor1(float color[3]) { + void ReadColor1(float color[3]) const { switch (decFmt_.c1fmt) { case DEC_U8_4: { @@ -368,7 +368,7 @@ public: } } - void ReadWeights(float weights[8]) { + void ReadWeights(float weights[8]) const { const float *f = (const float *)(data_ + decFmt_.w0off); const u8 *b = (const u8 *)(data_ + decFmt_.w0off); const u16 *s = (const u16 *)(data_ + decFmt_.w0off); From d9d66c46e96aed39941b753de2a46803a40f69af Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:39:35 -0700 Subject: [PATCH 15/25] Avoid a possibly uninitialized var. --- Core/ELF/ElfReader.cpp | 2 +- Core/FileSystems/ISOFileSystem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index b900b5dd3a..276b1a16d2 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -175,7 +175,7 @@ void ElfReader::LoadRelocations2(int rel_seg) int flag_bits, seg_bits, type_bits; int cmd, flag, seg, type; int off_seg = 0, addr_seg, rel_base, rel_offset; - int relocate_to, last_type, lo16; + int relocate_to, last_type, lo16 = 0; u32 op, addr; int rcount = 0; diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index 2d3d8ea94b..c5236596db 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -641,7 +641,7 @@ void ISOFileSystem::DoState(PointerWrap &p) p.Do(of.sectorStart); p.Do(of.openSize); - bool hasFile; + bool hasFile = false; p.Do(hasFile); if (hasFile) { std::string path; From abec782420cfc2ffe4650df9d398d8fd4f9a993f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:41:07 -0700 Subject: [PATCH 16/25] Return unsigned vars in sceCccDecode*(). Semantics only, but clearer. --- Core/HLE/sceCcc.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Core/HLE/sceCcc.cpp b/Core/HLE/sceCcc.cpp index 61cbc17e18..b8570f2057 100644 --- a/Core/HLE/sceCcc.cpp +++ b/Core/HLE/sceCcc.cpp @@ -336,7 +336,7 @@ u32 sceCccEncodeSJIS(u32 dstAddrAddr, u32 jis) return dstp->ptr; } -int sceCccDecodeUTF8(u32 dstAddrAddr) +u32 sceCccDecodeUTF8(u32 dstAddrAddr) { PSPPointer dstp; dstp = dstAddrAddr; @@ -349,7 +349,7 @@ int sceCccDecodeUTF8(u32 dstAddrAddr) DEBUG_LOG(HLE, "sceCccDecodeUTF8(%08x)", dstAddrAddr); UTF8 utf(*dstp); - int result = utf.next(); + u32 result = utf.next(); *dstp += utf.byteIndex(); if (result == UTF8::INVALID) @@ -357,7 +357,7 @@ int sceCccDecodeUTF8(u32 dstAddrAddr) return result; } -int sceCccDecodeUTF16(u32 dstAddrAddr) +u32 sceCccDecodeUTF16(u32 dstAddrAddr) { PSPPointer dstp; dstp = dstAddrAddr; @@ -371,7 +371,7 @@ int sceCccDecodeUTF16(u32 dstAddrAddr) DEBUG_LOG(HLE, "sceCccDecodeUTF16(%08x)", dstAddrAddr); // TODO: Does it do any detection of BOM? UTF16LE utf(*dstp); - int result = utf.next(); + u32 result = utf.next(); *dstp += utf.byteIndex(); if (result == UTF16LE::INVALID) @@ -379,7 +379,7 @@ int sceCccDecodeUTF16(u32 dstAddrAddr) return result; } -int sceCccDecodeSJIS(u32 dstAddrAddr) +u32 sceCccDecodeSJIS(u32 dstAddrAddr) { PSPPointer dstp; dstp = dstAddrAddr; @@ -392,7 +392,7 @@ int sceCccDecodeSJIS(u32 dstAddrAddr) DEBUG_LOG(HLE, "sceCccDecodeSJIS(%08x)", dstAddrAddr); ShiftJIS sjis(*dstp); - int result = sjis.next(); + u32 result = sjis.next(); *dstp += sjis.byteIndex(); if (result == ShiftJIS::INVALID) @@ -503,9 +503,9 @@ const HLEFunction sceCcc[] = {0x92C05851, WrapU_UU, "sceCccEncodeUTF8"}, {0x8406F469, WrapV_UU, "sceCccEncodeUTF16"}, {0x068c4320, WrapU_UU, "sceCccEncodeSJIS"}, - {0xc6a8bee2, WrapI_U, "sceCccDecodeUTF8"}, - {0xe0cf8091, WrapI_U, "sceCccDecodeUTF16"}, - {0x953e6c10, WrapI_U, "sceCccDecodeSJIS"}, + {0xc6a8bee2, WrapU_U, "sceCccDecodeUTF8"}, + {0xe0cf8091, WrapU_U, "sceCccDecodeUTF16"}, + {0x953e6c10, WrapU_U, "sceCccDecodeSJIS"}, {0x90521ac5, WrapI_U, "sceCccIsValidUTF8"}, {0xcc0a8bda, WrapI_U, "sceCccIsValidUTF16"}, {0x67bf0d19, WrapI_U, "sceCccIsValidSJIS"}, From b5e46b46cd3968c28b4aa313d159928132f2aff7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 26 Jul 2013 22:46:03 -0700 Subject: [PATCH 17/25] Fix some minor virtual disc warnings. --- Core/FileSystems/DirectoryFileSystem.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index 2e0324195f..a9aed142d3 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -803,10 +803,10 @@ std::string VirtualDiscFileSystem::GetLocalPath(std::string localpath) { int VirtualDiscFileSystem::getFileListIndex(std::string& fileName) { - for (int i = 0; i < fileList.size(); i++) + for (size_t i = 0; i < fileList.size(); i++) { if (fileList[i].fileName == fileName) - return i; + return (int)i; } // unknown file - add it @@ -841,7 +841,7 @@ int VirtualDiscFileSystem::getFileListIndex(std::string& fileName) int VirtualDiscFileSystem::getFileListIndex(u32 accessBlock, u32 accessSize) { - for (int i = 0; i < fileList.size(); i++) + for (size_t i = 0; i < fileList.size(); i++) { if (fileList[i].firstBlock <= accessBlock) { @@ -849,7 +849,7 @@ int VirtualDiscFileSystem::getFileListIndex(u32 accessBlock, u32 accessSize) u32 endOffset = sectorOffset+accessSize; if (endOffset <= fileList[i].totalSize) { - return i; + return (int)i; } } } @@ -883,12 +883,13 @@ u32 VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, con entry.type = VFILETYPE_LBN; entry.size = readSize; - entry.fileIndex = getFileListIndex(sectorStart,readSize); - if (entry.fileIndex == -1) + int fileIndex = getFileListIndex(sectorStart,readSize); + if (fileIndex == -1) { ERROR_LOG(FILESYS, "VirtualDiscFileSystem: sce_lbn used without calling fileinfo."); return 0; } + entry.fileIndex = (u32)fileIndex; entry.startOffset = (sectorStart-fileList[entry.fileIndex].firstBlock)*2048; @@ -969,6 +970,7 @@ size_t VirtualDiscFileSystem::SeekFile(u32 handle, s32 position, FileMove type) return iter->second.curOffset; } } + return 0; } else { //This shouldn't happen... ERROR_LOG(HLE,"VirtualDiscFileSystem: Cannot seek in file that hasn't been opened: %08x", handle); From 489748ffc08ac86dfd8683a3ef6c0c3f8ea73904 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 27 Jul 2013 02:16:06 -0400 Subject: [PATCH 18/25] Change nullptr to NULL to avoid possible issues with platforms that don't support C++11. --- Core/HW/MediaEngine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index 6de39474cc..4dd07f146e 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -590,7 +590,7 @@ int MediaEngine::getAudioSamples(u8* buffer) { } int outbytes = 0; - if(m_audioContext != nullptr) + if(m_audioContext != NULL) Atrac3plus_Decoder::Decode(m_audioContext, audioFrame, frameSize, &outbytes, buffer); if (headerCode1 == 0x24) { From 7d6538bd0b90b7da62322c3bb2b19bb14999b94f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 27 Jul 2013 01:05:00 -0700 Subject: [PATCH 19/25] Don't crash in DeviceLost before game init. --- UI/EmuScreen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index e359fe5f43..f69e86f7ad 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -548,5 +548,6 @@ void EmuScreen::render() { void EmuScreen::deviceLost() { ILOG("EmuScreen::deviceLost()"); - gpu->DeviceLost(); + if (gpu) + gpu->DeviceLost(); } From ab3b7041d2a572e8fc6673f2ce96359cf7730fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 27 Jul 2013 10:14:00 +0200 Subject: [PATCH 20/25] Restore accidentally deleted config saving line --- Core/Config.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/Config.cpp b/Core/Config.cpp index eed466be5a..520002dd73 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -227,6 +227,7 @@ void Config::Save() graphics->Set("HardwareTransform", bHardwareTransform); graphics->Set("TextureFiltering", iTexFiltering); graphics->Set("SSAA", SSAntiAliasing); + graphics->Set("VBO", bUseVBO); graphics->Set("FrameSkip", iFrameSkip); graphics->Set("FrameRate", iFpsLimit); graphics->Set("ForceMaxEmulatedFPS", iForceMaxEmulatedFPS); From 4b3312c3230c7dfceda96bb0d5fb49af620ee997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 27 Jul 2013 10:16:19 +0200 Subject: [PATCH 21/25] Update native with mac buildfix --- native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native b/native index f72b981395..24aed40031 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit f72b981395c31b566270d7c3125c981e3263adb7 +Subproject commit 24aed4003130a7618c060f21dc4fabbe1d97abef From 3988a12801e018ba22045af19161cf3f81173abd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 27 Jul 2013 01:16:01 -0700 Subject: [PATCH 22/25] Allow filenames like e.g. F:\ as dirs. --- Core/Loaders.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index ec32f612d4..464100026a 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -29,12 +29,12 @@ // TODO : improve, look in the file more EmuFileType Identify_File(std::string &filename) { - if (filename.size() < 5) { + if (filename.size() == 0) { ERROR_LOG(LOADER, "invalid filename %s", filename.c_str()); return FILETYPE_ERROR; } - std::string extension = filename.substr(filename.size() - 4); + std::string extension = filename.size() >= 5 ? filename.substr(filename.size() - 4) : ""; if (!strcasecmp(extension.c_str(),".iso")) { return FILETYPE_PSP_ISO; From 67adad6cf016fe39432f0b62bccc535a1f937ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 27 Jul 2013 11:45:40 +0200 Subject: [PATCH 23/25] Move CheckGLExtensions to InitGraphics from EmuScreen, trying to fix #2900 --- UI/EmuScreen.cpp | 1 - UI/NativeApp.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f69e86f7ad..0862803cb2 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -60,7 +60,6 @@ EmuScreen::EmuScreen(const std::string &filename) } void EmuScreen::bootGame(const std::string &filename) { - CheckGLExtensions(); std::string fileToStart = filename; // This is probably where we should start up the emulated PSP. INFO_LOG(BOOT, "Starting up hardware."); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index c4948b8c7a..459ae3ce64 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -379,11 +379,12 @@ void NativeInit(int argc, const char *argv[], } #endif } - + screenManager->switchScreen(new LogoScreen(boot_filename)); } void NativeInitGraphics() { + CheckGLExtensions(); gl_lost_manager_init(); ui_draw2d.SetAtlas(&ui_atlas); From 380b51dc6d0ec1204a0b3c24f29f3720d385b319 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 27 Jul 2013 18:20:07 +0800 Subject: [PATCH 24/25] Revert clamp to zero and use another attempt fix --- GPU/GLES/StateMapping.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 501c31bd33..6b9683be58 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -363,11 +363,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { vpHeight *= renderHeightFactor; // Flip vpY0 to match the OpenGL coordinate system. - vpY0 = renderHeight - (vpY0 + vpHeight); - - // Clamp vpX0/vpY0 to zero when negative value retured. - vpY0 = vpY0 < 0 ? 0 : vpY0; - vpX0 = vpX0 < 0 ? 0 : vpX0; + vpY0 = renderHeight - (vpYb - offsetY + fabsf(vpYa)) * renderHeightFactor; glstate.viewport.set(vpX0 + renderX, vpY0 + renderY, vpWidth, vpHeight); // Sadly, as glViewport takes integers, we will not be able to support sub pixel offsets this way. But meh. From b35e89f6467d31830c11cf0a69931e63b5a18fe5 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 27 Jul 2013 18:45:48 +0800 Subject: [PATCH 25/25] Fix rear mirror in Ridge Racer 2 --- GPU/GLES/StateMapping.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 6b9683be58..46c7f3da59 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -362,8 +362,9 @@ void TransformDrawEngine::ApplyDrawState(int prim) { vpWidth *= renderWidthFactor; vpHeight *= renderHeightFactor; + vpX0 = (vpXb - offsetX - fabsf(vpXa)) * renderWidthFactor; // Flip vpY0 to match the OpenGL coordinate system. - vpY0 = renderHeight - (vpYb - offsetY + fabsf(vpYa)) * renderHeightFactor; + vpY0 = renderHeight - (vpYb - offsetY + fabsf(vpYa)) * renderHeightFactor; glstate.viewport.set(vpX0 + renderX, vpY0 + renderY, vpWidth, vpHeight); // Sadly, as glViewport takes integers, we will not be able to support sub pixel offsets this way. But meh.