mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 09:43:45 +01:00
Merge branch 'master' into armjit-fpu
Conflicts: Core/MIPS/ARM/ArmJit.h Core/MIPS/x86/CompVFPU.cpp GPU/GLES/Framebuffer.cpp
This commit is contained in:
commit
516ca8a0c4
159 files changed
+6167
-3045
No files matched your search
@@ -42,8 +42,10 @@ build*/
|
||||
__testoutput.txt
|
||||
__testerror.txt
|
||||
__testfinish.txt
|
||||
__testfailure.bmp
|
||||
GameLogNotes.txt
|
||||
|
||||
android/ui_atlas.zim
|
||||
android/assets/flash0
|
||||
ppge_atlas.zim.png
|
||||
local.properties
|
||||
+32
-13
@@ -63,12 +63,12 @@ else()
|
||||
endif()
|
||||
|
||||
#find_package(Qt5Widgets)
|
||||
if(USING_GLES2)
|
||||
if(USING_GLES2 AND NOT IOS)
|
||||
set(OPENGL_LIBRARIES GLESv2)
|
||||
else()
|
||||
elseif(NOT IOS)
|
||||
include(FindOpenGL REQUIRED)
|
||||
endif()
|
||||
if (NOT BLACKBERRY AND NOT ANDROID)
|
||||
if (NOT BLACKBERRY AND NOT ANDROID AND NOT IOS)
|
||||
include(FindSDL)
|
||||
endif()
|
||||
include(FindThreads)
|
||||
@@ -119,9 +119,8 @@ if(NOT MSVC)
|
||||
add_definitions(-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
if(IOS)
|
||||
add_definitions(-DGL_ETC1_RGB8_OES=0)
|
||||
endif()
|
||||
|
||||
if(BLACKBERRY)
|
||||
@@ -133,6 +132,11 @@ if(NOT MSVC)
|
||||
add_definitions(-msse2)
|
||||
endif()
|
||||
|
||||
if(IOS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
|
||||
elseif(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.0)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
else()
|
||||
@@ -415,9 +419,8 @@ elseif(IOS)
|
||||
ios/AppDelegate.h
|
||||
ios/ViewController.mm
|
||||
ios/ViewController.h)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework UIKit")
|
||||
# No target
|
||||
# set(TargetBin PPSSPP)
|
||||
set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework UIKit -framework GLKit")
|
||||
set(TargetBin PPSSPP)
|
||||
elseif(USING_QT_UI)
|
||||
# Currently unused
|
||||
find_package(Qt4 COMPONENTS QtMultimedia QtOpenGL QtGui QtCore)
|
||||
@@ -589,6 +592,8 @@ endif()
|
||||
add_library(kirk STATIC
|
||||
ext/libkirk/AES.c
|
||||
ext/libkirk/AES.h
|
||||
ext/libkirk/amctrl.c
|
||||
ext/libkirk/amctrl.h
|
||||
ext/libkirk/SHA1.c
|
||||
ext/libkirk/SHA1.h
|
||||
ext/libkirk/bn.c
|
||||
@@ -679,6 +684,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
||||
Core/FileSystems/ISOFileSystem.h
|
||||
Core/FileSystems/MetaFileSystem.cpp
|
||||
Core/FileSystems/MetaFileSystem.h
|
||||
Core/Font/PGF.cpp
|
||||
Core/Font/PGF.h
|
||||
Core/HLE/FunctionWrappers.h
|
||||
Core/HLE/HLE.cpp
|
||||
Core/HLE/HLE.h
|
||||
@@ -764,6 +771,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
||||
Core/HLE/sceUtility.h
|
||||
Core/HLE/sceVaudio.cpp
|
||||
Core/HLE/sceVaudio.h
|
||||
Core/HLE/scePspNpDrm_user.cpp
|
||||
Core/HLE/scePspNpDrm_user.h
|
||||
Core/HW/MediaEngine.cpp
|
||||
Core/HW/MediaEngine.h
|
||||
Core/HW/MemoryStick.cpp
|
||||
@@ -811,7 +820,6 @@ add_library(${CoreLibName} ${CoreLinkType}
|
||||
Core/Util/BlockAllocator.h
|
||||
Core/Util/PPGeDraw.cpp
|
||||
Core/Util/PPGeDraw.h
|
||||
Core/Util/Pool.h
|
||||
Core/Util/ppge_atlas.cpp
|
||||
Core/Util/ppge_atlas.h
|
||||
$<TARGET_OBJECTS:GPU>
|
||||
@@ -950,15 +958,26 @@ set(NativeAssets
|
||||
set(LinkCommon ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT} ${nativeExtraLibs})
|
||||
|
||||
if (TargetBin)
|
||||
add_executable(${TargetBin} ${NativeAppSource})
|
||||
if (IOS)
|
||||
add_executable(${TargetBin} MACOSX_BUNDLE ${NativeAppSource})
|
||||
else()
|
||||
add_executable(${TargetBin} ${NativeAppSource})
|
||||
endif()
|
||||
target_link_libraries(${TargetBin} ${LinkCommon})
|
||||
endif()
|
||||
|
||||
# installs
|
||||
file(INSTALL ${NativeAssets} DESTINATION assets)
|
||||
|
||||
# code signing
|
||||
# packaging and code signing
|
||||
if (IOS)
|
||||
set_target_properties(${NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST PPSSPP-Info.plist XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: My Name")
|
||||
set(RSRC_XIB_FILES assets/Icon@2x.png)
|
||||
SET_SOURCE_FILES_PROPERTIES(${RSRC_XIB_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
set(APP_DIR_NAME \${TARGET_BUILD_DIR}/\${FULL_PRODUCT_NAME})
|
||||
add_custom_command(TARGET PPSSPP POST_BUILD
|
||||
COMMAND tar -c -C . --exclude .DS_Store --exclude .git -H `find assets` | tar -x -C ${APP_DIR_NAME}
|
||||
)
|
||||
set_target_properties(${TargetBin} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "../ios/PPSSPP-Info.plist" XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: My Name")
|
||||
endif()
|
||||
|
||||
#include(CPack)
|
||||
+58
-5
@@ -151,6 +151,9 @@ void ARMXEmitter::SetCodePtr(u8 *ptr)
|
||||
{
|
||||
code = ptr;
|
||||
startcode = code;
|
||||
#ifdef IOS
|
||||
lastCacheFlushEnd = ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
const u8 *ARMXEmitter::GetCodePtr() const
|
||||
@@ -194,7 +197,8 @@ void ARMXEmitter::FlushIcacheSection(u8 *start, u8 *end)
|
||||
#elif defined(BLACKBERRY)
|
||||
msync(start, end - start, MS_SYNC | MS_INVALIDATE_ICACHE);
|
||||
#elif defined(IOS)
|
||||
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
||||
if (start != NULL)
|
||||
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
||||
#elif !defined(_WIN32)
|
||||
__builtin___clear_cache(start, end);
|
||||
#endif
|
||||
@@ -494,6 +498,16 @@ void ARMXEmitter::SMULL(ARMReg destLo, ARMReg destHi, ARMReg rm, ARMReg rn)
|
||||
Write4OpMultiply(0xC, destLo, destHi, rn, rm);
|
||||
}
|
||||
|
||||
void ARMXEmitter::UMLAL(ARMReg destLo, ARMReg destHi, ARMReg rm, ARMReg rn)
|
||||
{
|
||||
Write4OpMultiply(0xA, destLo, destHi, rn, rm);
|
||||
}
|
||||
|
||||
void ARMXEmitter::SMLAL(ARMReg destLo, ARMReg destHi, ARMReg rm, ARMReg rn)
|
||||
{
|
||||
Write4OpMultiply(0xE, destLo, destHi, rn, rm);
|
||||
}
|
||||
|
||||
void ARMXEmitter::SXTB (ARMReg dest, ARMReg op2)
|
||||
{
|
||||
Write32(condition | (0x6AF << 16) | (dest << 12) | (7 << 4) | op2);
|
||||
@@ -537,12 +551,25 @@ void ARMXEmitter::WriteStoreOp(u32 op, ARMReg dest, ARMReg src, Operand2 op2)
|
||||
else
|
||||
Write32(condition | (op << 20) | (3 << 23) | (dest << 16) | (src << 12) | op2.Imm12());
|
||||
}
|
||||
void ARMXEmitter::STR (ARMReg dest, ARMReg src, Operand2 op) { WriteStoreOp(0x40, dest, src, op);}
|
||||
void ARMXEmitter::STRB(ARMReg dest, ARMReg src, Operand2 op) { WriteStoreOp(0x44, dest, src, op);}
|
||||
void ARMXEmitter::STR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
void ARMXEmitter::STR (ARMReg dest, ARMReg src, Operand2 op) { WriteStoreOp(0x40, dest, src, op);}
|
||||
void ARMXEmitter::STRH (ARMReg dest, ARMReg src, Operand2 op)
|
||||
{
|
||||
u8 Imm = op.Imm8();
|
||||
Write32(condition | (0x04 << 20) | (src << 16) | (dest << 12) | ((Imm >> 4) << 8) | (0xB << 4) | (Imm & 0x0F));
|
||||
}
|
||||
void ARMXEmitter::STRB (ARMReg dest, ARMReg src, Operand2 op) { WriteStoreOp(0x44, dest, src, op);}
|
||||
void ARMXEmitter::STR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x60 << 20) | (Index << 24) | (Add << 23) | (dest << 16) | (base << 12) | offset);
|
||||
}
|
||||
void ARMXEmitter::STRH (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x00 << 20) | (Index << 24) | (Add << 23) | (dest << 16) | (base << 12) | (0xB << 4) | offset);
|
||||
}
|
||||
void ARMXEmitter::STRB (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x64 << 20) | (Index << 24) | (Add << 23) | (dest << 16) | (base << 12) | offset);
|
||||
}
|
||||
void ARMXEmitter::LDREX(ARMReg dest, ARMReg base)
|
||||
{
|
||||
Write32(condition | (25 << 20) | (base << 16) | (dest << 12) | 0xF9F);
|
||||
@@ -567,12 +594,38 @@ void ARMXEmitter::LDRH(ARMReg dest, ARMReg src, Operand2 op)
|
||||
u8 Imm = op.Imm8();
|
||||
Write32(condition | (0x05 << 20) | (src << 16) | (dest << 12) | ((Imm >> 4) << 8) | (0xB << 4) | (Imm & 0x0F));
|
||||
}
|
||||
void ARMXEmitter::LDRSH(ARMReg dest, ARMReg src, Operand2 op)
|
||||
{
|
||||
u8 Imm = op.Imm8();
|
||||
Write32(condition | (0x05 << 20) | (src << 16) | (dest << 12) | ((Imm >> 4) << 8) | (0xF << 4) | (Imm & 0x0F));
|
||||
}
|
||||
void ARMXEmitter::LDRB(ARMReg dest, ARMReg src, Operand2 op) { WriteStoreOp(0x45, src, dest, op);}
|
||||
void ARMXEmitter::LDRSB(ARMReg dest, ARMReg src, Operand2 op)
|
||||
{
|
||||
u8 Imm = op.Imm8();
|
||||
Write32(condition | (0x05 << 20) | (src << 16) | (dest << 12) | ((Imm >> 4) << 8) | (0xD << 4) | (Imm & 0x0F));
|
||||
}
|
||||
|
||||
void ARMXEmitter::LDR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
void ARMXEmitter::LDR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x61 << 20) | (Index << 24) | (Add << 23) | (base << 16) | (dest << 12) | offset);
|
||||
}
|
||||
void ARMXEmitter::LDRH (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x01 << 20) | (Index << 24) | (Add << 23) | (base << 16) | (dest << 12) | (0xB << 4) | offset);
|
||||
}
|
||||
void ARMXEmitter::LDRSH(ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x01 << 20) | (Index << 24) | (Add << 23) | (base << 16) | (dest << 12) | (0xF << 4) | offset);
|
||||
}
|
||||
void ARMXEmitter::LDRB (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x65 << 20) | (Index << 24) | (Add << 23) | (base << 16) | (dest << 12) | offset);
|
||||
}
|
||||
void ARMXEmitter::LDRSB(ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add)
|
||||
{
|
||||
Write32(condition | (0x01 << 20) | (Index << 24) | (Add << 23) | (base << 16) | (dest << 12) | (0xD << 4) | offset);
|
||||
}
|
||||
void ARMXEmitter::WriteRegStoreOp(u32 op, ARMReg dest, bool WriteBack, u16 RegList)
|
||||
{
|
||||
Write32(condition | (op << 20) | (WriteBack << 21) | (dest << 16) | RegList);
|
||||
|
||||
+22
-7
@@ -457,6 +457,9 @@ public:
|
||||
void UMULL(ARMReg destLo, ARMReg destHi, ARMReg rn, ARMReg rm);
|
||||
void SMULL(ARMReg destLo, ARMReg destHi, ARMReg rn, ARMReg rm);
|
||||
|
||||
void UMLAL(ARMReg destLo, ARMReg destHi, ARMReg rn, ARMReg rm);
|
||||
void SMLAL(ARMReg destLo, ARMReg destHi, ARMReg rn, ARMReg rm);
|
||||
|
||||
void SXTB(ARMReg dest, ARMReg op2);
|
||||
void SXTH(ARMReg dest, ARMReg op2, u8 rotation = 0);
|
||||
void SXTAH(ARMReg dest, ARMReg src, ARMReg op2, u8 rotation = 0);
|
||||
@@ -467,16 +470,26 @@ public:
|
||||
void MRS (ARMReg dest);
|
||||
|
||||
// Memory load/store operations
|
||||
void LDR (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void LDR (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void LDRH (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void LDRSH(ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void LDRB (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void LDRSB(ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
// Offset adds to the base register in LDR
|
||||
void LDR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void LDRH(ARMReg dest, ARMReg src, Operand2 op = 0);
|
||||
void LDRB(ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void STR (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void LDR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void LDRH (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void LDRSH(ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void LDRB (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void LDRSB(ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
|
||||
void STR (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void STRH (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void STRB (ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
// Offset adds on to the destination register in STR
|
||||
void STR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void STR (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void STRH (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
void STRB (ARMReg dest, ARMReg base, ARMReg offset, bool Index, bool Add);
|
||||
|
||||
void STRB(ARMReg dest, ARMReg src, Operand2 op2 = 0);
|
||||
void STMFD(ARMReg dest, bool WriteBack, const int Regnum, ...);
|
||||
void LDMFD(ARMReg dest, bool WriteBack, const int Regnum, ...);
|
||||
|
||||
@@ -556,7 +569,9 @@ public:
|
||||
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
|
||||
void FreeCodeSpace()
|
||||
{
|
||||
#ifndef __SYMBIAN32__
|
||||
FreeMemoryPages(region, region_size);
|
||||
#endif
|
||||
region = NULL;
|
||||
region_size = 0;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,12 @@
|
||||
#include <list>
|
||||
#include <set>
|
||||
#ifndef __SYMBIAN32__
|
||||
#ifdef IOS
|
||||
#include <tr1/type_traits>
|
||||
#else
|
||||
#include <type_traits>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "Common.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
@@ -313,19 +313,19 @@ void ConsoleListener::SendToThread(LogTypes::LOG_LEVELS Level, const char *Text)
|
||||
if (logPendingWritePos == (u32) -1)
|
||||
return;
|
||||
|
||||
size_t Len = strlen(Text);
|
||||
int Len = (int)strlen(Text);
|
||||
if (Len > LOG_PENDING_MAX)
|
||||
Len = LOG_PENDING_MAX - 16;
|
||||
|
||||
char ColorAttr[16] = "";
|
||||
size_t ColorLen = 0;
|
||||
int ColorLen = 0;
|
||||
if (bUseColor)
|
||||
{
|
||||
// Not ANSI, since the console doesn't support it, but ANSI-like.
|
||||
snprintf(ColorAttr, 16, "\033%d", Level);
|
||||
// For now, rather than properly support it.
|
||||
_dbg_assert_msg_(COMMON, strlen(ColorAttr) == 2, "Console logging doesn't support > 9 levels.");
|
||||
ColorLen = strlen(ColorAttr);
|
||||
ColorLen = (int)strlen(ColorAttr);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&criticalSection);
|
||||
@@ -333,7 +333,7 @@ void ConsoleListener::SendToThread(LogTypes::LOG_LEVELS Level, const char *Text)
|
||||
u32 prevLogWritePos = logWritePos;
|
||||
if (logWritePos + ColorLen + Len >= LOG_PENDING_MAX)
|
||||
{
|
||||
for (size_t i = 0; i < ColorLen; ++i)
|
||||
for (int i = 0; i < ColorLen; ++i)
|
||||
logPending[(logWritePos + i) % LOG_PENDING_MAX] = ColorAttr[i];
|
||||
logWritePos += ColorLen;
|
||||
if (logWritePos >= LOG_PENDING_MAX)
|
||||
@@ -370,7 +370,7 @@ void ConsoleListener::SendToThread(LogTypes::LOG_LEVELS Level, const char *Text)
|
||||
|
||||
// Okay, have it go right after the next newline.
|
||||
if (nextNewline != NULL)
|
||||
logPendingReadPos = nextNewline - logPending + 1;
|
||||
logPendingReadPos = (u32)(nextNewline - logPending + 1);
|
||||
}
|
||||
|
||||
// Double check we didn't start quitting.
|
||||
|
||||
+2
-2
@@ -89,9 +89,9 @@ int AES_set_encrypt_key(const unsigned char* userKey, const int bits,
|
||||
int AES_set_decrypt_key(const unsigned char* userKey, const int bits,
|
||||
AES_KEY* key);
|
||||
|
||||
void AES_encrypt(const unsigned char* in, unsigned char* out,
|
||||
void AES_encrypt1(const unsigned char* in, unsigned char* out,
|
||||
const AES_KEY* key);
|
||||
void AES_decrypt(const unsigned char* in, unsigned char* out,
|
||||
void AES_decrypt1(const unsigned char* in, unsigned char* out,
|
||||
const AES_KEY* key);
|
||||
|
||||
void AES_ecb_encrypt(const unsigned char* in, unsigned char* out,
|
||||
|
||||
@@ -75,7 +75,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
while (len >= AES_BLOCK_SIZE) {
|
||||
for(n=0; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] = in[n] ^ iv[n];
|
||||
AES_encrypt(out, out, key);
|
||||
AES_encrypt1(out, out, key);
|
||||
iv = out;
|
||||
len -= AES_BLOCK_SIZE;
|
||||
in += AES_BLOCK_SIZE;
|
||||
@@ -86,13 +86,13 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
out[n] = in[n] ^ iv[n];
|
||||
for(n=len; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] = iv[n];
|
||||
AES_encrypt(out, out, key);
|
||||
AES_encrypt1(out, out, key);
|
||||
iv = out;
|
||||
}
|
||||
memcpy(ivec,iv,AES_BLOCK_SIZE);
|
||||
} else if (in != out) {
|
||||
while (len >= AES_BLOCK_SIZE) {
|
||||
AES_decrypt(in, out, key);
|
||||
AES_decrypt1(in, out, key);
|
||||
for(n=0; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] ^= iv[n];
|
||||
iv = in;
|
||||
@@ -101,7 +101,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
out += AES_BLOCK_SIZE;
|
||||
}
|
||||
if (len) {
|
||||
AES_decrypt(in,tmp,key);
|
||||
AES_decrypt1(in,tmp,key);
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] = tmp[n] ^ iv[n];
|
||||
iv = in;
|
||||
@@ -110,7 +110,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
} else {
|
||||
while (len >= AES_BLOCK_SIZE) {
|
||||
memcpy(tmp, in, AES_BLOCK_SIZE);
|
||||
AES_decrypt(in, out, key);
|
||||
AES_decrypt1(in, out, key);
|
||||
for(n=0; n < AES_BLOCK_SIZE; ++n)
|
||||
out[n] ^= ivec[n];
|
||||
memcpy(ivec, tmp, AES_BLOCK_SIZE);
|
||||
@@ -120,7 +120,7 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
|
||||
}
|
||||
if (len) {
|
||||
memcpy(tmp, in, AES_BLOCK_SIZE);
|
||||
AES_decrypt(tmp, out, key);
|
||||
AES_decrypt1(tmp, out, key);
|
||||
for(n=0; n < len; ++n)
|
||||
out[n] ^= ivec[n];
|
||||
for(n=len; n < AES_BLOCK_SIZE; ++n)
|
||||
|
||||
@@ -778,7 +778,7 @@ int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
|
||||
* Encrypt a single block
|
||||
* in and out can overlap
|
||||
*/
|
||||
void AES_encrypt(const unsigned char *in, unsigned char *out,
|
||||
void AES_encrypt1(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key) {
|
||||
|
||||
const u32 *rk;
|
||||
@@ -969,7 +969,7 @@ void AES_encrypt(const unsigned char *in, unsigned char *out,
|
||||
* Decrypt a single block
|
||||
* in and out can overlap
|
||||
*/
|
||||
void AES_decrypt(const unsigned char *in, unsigned char *out,
|
||||
void AES_decrypt1(const unsigned char *in, unsigned char *out,
|
||||
const AES_KEY *key) {
|
||||
|
||||
const u32 *rk;
|
||||
|
||||
+32
-30
@@ -27,8 +27,8 @@
|
||||
#endif
|
||||
|
||||
// Unfortunately this is quite slow.
|
||||
// #define LOG_MSC_OUTPUTDEBUG true
|
||||
#define LOG_MSC_OUTPUTDEBUG false
|
||||
// #define LOG_MSC_OUTPUTDEBUG true
|
||||
|
||||
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
||||
const char *file, int line, const char* fmt, ...)
|
||||
@@ -46,30 +46,30 @@ LogManager *LogManager::m_logManager = NULL;
|
||||
LogManager::LogManager()
|
||||
{
|
||||
// create log files
|
||||
m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log");
|
||||
m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot");
|
||||
m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common");
|
||||
m_Log[LogTypes::CPU] = new LogContainer("CPU", "CPU");
|
||||
m_Log[LogTypes::LOADER] = new LogContainer("LOAD", "Loader");
|
||||
m_Log[LogTypes::IO] = new LogContainer("IO", "IO");
|
||||
m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "DiscIO");
|
||||
m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad");
|
||||
m_Log[LogTypes::FILESYS] = new LogContainer("FileSys", "File System");
|
||||
m_Log[LogTypes::G3D] = new LogContainer("G3D", "3D Graphics");
|
||||
m_Log[LogTypes::DMA] = new LogContainer("DMA", "DMA");
|
||||
m_Log[LogTypes::INTC] = new LogContainer("INTC", "Interrupts");
|
||||
m_Log[LogTypes::MEMMAP] = new LogContainer("MM", "Memory Map");
|
||||
m_Log[LogTypes::SOUND] = new LogContainer("SND", "Sound");
|
||||
m_Log[LogTypes::SAS] = new LogContainer("SAS", "Sound Mixer (Sas)");
|
||||
m_Log[LogTypes::HLE] = new LogContainer("HLE", "HLE");
|
||||
m_Log[LogTypes::TIMER] = new LogContainer("TMR", "Timer");
|
||||
m_Log[LogTypes::VIDEO] = new LogContainer("VID", "Video");
|
||||
m_Log[LogTypes::DYNA_REC] = new LogContainer("Jit", "JIT compiler");
|
||||
m_Log[LogTypes::NETPLAY] = new LogContainer("NET", "Net play");
|
||||
m_Log[LogTypes::ME] = new LogContainer("ME", "Media Engine");
|
||||
m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log");
|
||||
m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot");
|
||||
m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common");
|
||||
m_Log[LogTypes::CPU] = new LogContainer("CPU", "CPU");
|
||||
m_Log[LogTypes::LOADER] = new LogContainer("LOAD", "Loader");
|
||||
m_Log[LogTypes::IO] = new LogContainer("IO", "IO");
|
||||
m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "DiscIO");
|
||||
m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad");
|
||||
m_Log[LogTypes::FILESYS] = new LogContainer("FileSys", "File System");
|
||||
m_Log[LogTypes::G3D] = new LogContainer("G3D", "3D Graphics");
|
||||
m_Log[LogTypes::DMA] = new LogContainer("DMA", "DMA");
|
||||
m_Log[LogTypes::INTC] = new LogContainer("INTC", "Interrupts");
|
||||
m_Log[LogTypes::MEMMAP] = new LogContainer("MM", "Memory Map");
|
||||
m_Log[LogTypes::SOUND] = new LogContainer("SND", "Sound");
|
||||
m_Log[LogTypes::SAS] = new LogContainer("SAS", "Sound Mixer (Sas)");
|
||||
m_Log[LogTypes::HLE] = new LogContainer("HLE", "HLE");
|
||||
m_Log[LogTypes::TIMER] = new LogContainer("TMR", "Timer");
|
||||
m_Log[LogTypes::VIDEO] = new LogContainer("VID", "Video");
|
||||
m_Log[LogTypes::DYNA_REC] = new LogContainer("Jit", "JIT compiler");
|
||||
m_Log[LogTypes::NETPLAY] = new LogContainer("NET", "Net play");
|
||||
m_Log[LogTypes::ME] = new LogContainer("ME", "Media Engine");
|
||||
|
||||
// Remove file logging on small devices
|
||||
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
|
||||
#ifndef USING_GLES2
|
||||
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str());
|
||||
m_consoleLog = new ConsoleListener();
|
||||
m_debuggerLog = new DebuggerLogListener();
|
||||
@@ -82,7 +82,7 @@ LogManager::LogManager()
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
m_Log[i]->SetEnable(true);
|
||||
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
|
||||
#ifndef USING_GLES2
|
||||
m_Log[i]->AddListener(m_fileLog);
|
||||
m_Log[i]->AddListener(m_consoleLog);
|
||||
#ifdef _MSC_VER
|
||||
@@ -97,11 +97,13 @@ LogManager::~LogManager()
|
||||
{
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
#ifndef USING_GLES2
|
||||
if (m_fileLog != NULL)
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
||||
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog);
|
||||
#ifdef _MSC_VER
|
||||
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ LogManager::~LogManager()
|
||||
delete m_Log[i];
|
||||
if (m_fileLog != NULL)
|
||||
delete m_fileLog;
|
||||
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
|
||||
#ifndef USING_GLES2
|
||||
delete m_consoleLog;
|
||||
delete m_debuggerLog;
|
||||
#endif
|
||||
@@ -214,6 +216,9 @@ void LogContainer::RemoveListener(LogListener *listener)
|
||||
|
||||
void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg)
|
||||
{
|
||||
#ifdef __SYMBIAN32__
|
||||
RDebug::Printf("%s",msg);
|
||||
#else
|
||||
std::lock_guard<std::mutex> lk(m_listeners_lock);
|
||||
|
||||
std::set<LogListener*>::const_iterator i;
|
||||
@@ -221,6 +226,7 @@ void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg)
|
||||
{
|
||||
(*i)->Log(level, msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FileLogListener::FileLogListener(const char *filename)
|
||||
@@ -235,11 +241,7 @@ void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lk(m_log_lock);
|
||||
#ifdef __SYMBIAN32__
|
||||
RDebug::Printf("%s",msg);
|
||||
#else
|
||||
m_logfile << msg << std::flush;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DebuggerLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
|
||||
|
||||
@@ -62,6 +62,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
||||
#elif defined(__SYMBIAN32__)
|
||||
//This function may be called more than once, and we want to create only one big
|
||||
//memory chunk for all the executable code for the JIT
|
||||
void* ptr;
|
||||
if( g_code_chunk == NULL && g_code_heap == NULL)
|
||||
{
|
||||
TInt minsize = SYMBIAN_CODECHUNK_SIZE;
|
||||
@@ -69,8 +70,10 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
||||
g_code_chunk = new RChunk();
|
||||
g_code_chunk->CreateLocalCode(minsize, maxsize);
|
||||
g_code_heap = UserHeap::ChunkHeap(*g_code_chunk, minsize, 1, maxsize);
|
||||
ptr = (void*) g_code_heap->Alloc( size );
|
||||
}
|
||||
void* ptr = (void*) g_code_heap->Alloc( size );
|
||||
else
|
||||
ptr = g_code_heap->Base();
|
||||
#else
|
||||
static char *map_hint = 0;
|
||||
#if defined(__x86_64__) && !defined(MAP_32BIT)
|
||||
@@ -116,11 +119,6 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64)
|
||||
if ((u64)ptr >= 0x80000000 && low == true)
|
||||
PanicAlert("Executable memory ended up above 2GB!");
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -112,9 +112,9 @@ void *ThunkManager::ProtectFunction(void *function, int num_params)
|
||||
#else
|
||||
SUB(64, R(ESP), Imm8(0x8));
|
||||
#endif
|
||||
CALL((void*)save_regs);
|
||||
CALL((void*)function);
|
||||
CALL((void*)load_regs);
|
||||
ABI_CallFunction((void*)save_regs);
|
||||
ABI_CallFunction((void*)function);
|
||||
ABI_CallFunction((void*)load_regs);
|
||||
#ifdef _WIN32
|
||||
ADD(64, R(ESP), Imm8(0x28));
|
||||
#else
|
||||
|
||||
@@ -21,6 +21,7 @@ set(SRCS
|
||||
ELF/ElfReader.cpp
|
||||
ELF/ParamSFO.cpp
|
||||
ELF/PrxDecrypter.cpp
|
||||
Font/PGF.cpp
|
||||
HLE/HLE.cpp
|
||||
HLE/HLETables.cpp
|
||||
HLE/sceAtrac.cpp
|
||||
|
||||
+4
-3
@@ -57,7 +57,8 @@ void CConfig::Load(const char *iniFileName)
|
||||
|
||||
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
||||
cpu->Get("Jit", &bJit, true);
|
||||
cpu->Get("FastMemory", &bFastMemory, true);
|
||||
//FastMemory Default set back to True when solve UNIMPL _sceAtracGetContextAddress making game crash
|
||||
cpu->Get("FastMemory", &bFastMemory, false);
|
||||
|
||||
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
||||
graphics->Get("ShowFPSCounter", &bShowFPSCounter, false);
|
||||
@@ -74,10 +75,10 @@ void CConfig::Load(const char *iniFileName)
|
||||
#else
|
||||
graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
|
||||
#endif
|
||||
graphics->Get("DisableG3DLog", &bDisableG3DLog, false);
|
||||
graphics->Get("VertexCache", &bVertexCache, true);
|
||||
graphics->Get("FullScreen", &bFullScreen, false);
|
||||
graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
|
||||
graphics->Get("TrueColor", &bTrueColor, true);
|
||||
|
||||
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
||||
sound->Get("Enable", &bEnableSound, true);
|
||||
@@ -134,10 +135,10 @@ void CConfig::Save()
|
||||
graphics->Set("VBO", bUseVBO);
|
||||
graphics->Set("FrameSkip", iFrameSkip);
|
||||
graphics->Set("AnisotropyLevel", iAnisotropyLevel);
|
||||
graphics->Set("DisableG3DLog", bDisableG3DLog);
|
||||
graphics->Set("VertexCache", bVertexCache);
|
||||
graphics->Set("FullScreen", bFullScreen);
|
||||
graphics->Set("StretchToDisplay", bStretchToDisplay);
|
||||
graphics->Set("TrueColor", bTrueColor);
|
||||
|
||||
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
||||
sound->Set("Enable", bEnableSound);
|
||||
|
||||
+1
-1
@@ -63,10 +63,10 @@ public:
|
||||
|
||||
int iWindowZoom; // for Windows
|
||||
bool SSAntiAliasing; //for Windows, too
|
||||
bool bDisableG3DLog;
|
||||
bool bVertexCache;
|
||||
bool bFullScreen;
|
||||
int iAnisotropyLevel;
|
||||
bool bTrueColor;
|
||||
|
||||
// Sound
|
||||
bool bEnableSound;
|
||||
|
||||
+43
-5
@@ -33,13 +33,24 @@
|
||||
// HANDLE m_hStepEvent;
|
||||
event m_hStepEvent;
|
||||
recursive_mutex m_hStepMutex;
|
||||
event m_hInactiveEvent;
|
||||
recursive_mutex m_hInactiveMutex;
|
||||
|
||||
// This can be read and written from ANYWHERE.
|
||||
volatile CoreState coreState = CORE_STEPPING;
|
||||
// Note: intentionally not used for CORE_NEXTFRAME.
|
||||
volatile bool coreStatePending = false;
|
||||
|
||||
void Core_UpdateState(CoreState newState)
|
||||
{
|
||||
if ((coreState == CORE_RUNNING || coreState == CORE_NEXTFRAME) && newState != CORE_RUNNING)
|
||||
coreStatePending = true;
|
||||
coreState = newState;
|
||||
}
|
||||
|
||||
void Core_ErrorPause()
|
||||
{
|
||||
coreState = CORE_ERROR;
|
||||
Core_UpdateState(CORE_ERROR);
|
||||
}
|
||||
|
||||
void Core_Pause()
|
||||
@@ -56,7 +67,7 @@ void Core_Halt(const char *msg)
|
||||
|
||||
void Core_Stop()
|
||||
{
|
||||
coreState = CORE_POWERDOWN;
|
||||
Core_UpdateState(CORE_POWERDOWN);
|
||||
m_hStepEvent.notify_one();
|
||||
}
|
||||
|
||||
@@ -65,6 +76,23 @@ bool Core_IsStepping()
|
||||
return coreState == CORE_STEPPING || coreState == CORE_POWERDOWN;
|
||||
}
|
||||
|
||||
bool Core_IsInactive()
|
||||
{
|
||||
return coreState != CORE_RUNNING && coreState != CORE_NEXTFRAME && !coreStatePending;
|
||||
}
|
||||
|
||||
void Core_WaitInactive()
|
||||
{
|
||||
while (!Core_IsInactive())
|
||||
m_hInactiveEvent.wait(m_hInactiveMutex);
|
||||
}
|
||||
|
||||
void Core_WaitInactive(int milliseconds)
|
||||
{
|
||||
while (!Core_IsInactive())
|
||||
m_hInactiveEvent.wait_for(m_hInactiveMutex, milliseconds);
|
||||
}
|
||||
|
||||
void Core_RunLoop()
|
||||
{
|
||||
while (!coreState) {
|
||||
@@ -72,9 +100,9 @@ void Core_RunLoop()
|
||||
if (coreState == CORE_NEXTFRAME)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
coreState = CORE_RUNNING;
|
||||
GL_SwapBuffers();
|
||||
#endif
|
||||
coreState = CORE_RUNNING;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +138,10 @@ reswitch:
|
||||
|
||||
// We should never get here on Android.
|
||||
case CORE_STEPPING:
|
||||
if (coreStatePending)
|
||||
m_hInactiveEvent.notify_one();
|
||||
coreStatePending = false;
|
||||
|
||||
//1: wait for step command..
|
||||
#if defined(USING_QT_UI) || defined(_DEBUG)
|
||||
host->UpdateDisassembly();
|
||||
@@ -142,8 +174,13 @@ reswitch:
|
||||
|
||||
case CORE_POWERDOWN:
|
||||
case CORE_ERROR:
|
||||
case CORE_NEXTFRAME:
|
||||
//1: Exit loop!!
|
||||
if (coreStatePending)
|
||||
m_hInactiveEvent.notify_one();
|
||||
coreStatePending = false;
|
||||
return;
|
||||
|
||||
case CORE_NEXTFRAME:
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -158,7 +195,7 @@ void Core_EnableStepping(bool step)
|
||||
#if defined(_DEBUG)
|
||||
host->SetDebugMode(true);
|
||||
#endif
|
||||
coreState = CORE_STEPPING;
|
||||
Core_UpdateState(CORE_STEPPING);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,6 +203,7 @@ void Core_EnableStepping(bool step)
|
||||
host->SetDebugMode(false);
|
||||
#endif
|
||||
coreState = CORE_RUNNING;
|
||||
coreStatePending = false;
|
||||
m_hStepEvent.notify_one();
|
||||
}
|
||||
}
|
||||
@@ -43,5 +43,10 @@ enum CoreState
|
||||
CORE_NEXTFRAME,
|
||||
};
|
||||
|
||||
void Core_UpdateState(CoreState newState);
|
||||
bool Core_IsInactive();
|
||||
void Core_WaitInactive();
|
||||
void Core_WaitInactive(int milliseconds);
|
||||
|
||||
|
||||
extern volatile CoreState coreState;
|
||||
+2
-1
@@ -144,6 +144,7 @@
|
||||
<ClCompile Include="FileSystems\DirectoryFileSystem.cpp" />
|
||||
<ClCompile Include="FileSystems\ISOFileSystem.cpp" />
|
||||
<ClCompile Include="FileSystems\MetaFileSystem.cpp" />
|
||||
<ClCompile Include="Font\PGF.cpp" />
|
||||
<ClCompile Include="HLE\HLE.cpp" />
|
||||
<ClCompile Include="HLE\HLETables.cpp" />
|
||||
<ClCompile Include="HLE\sceAtrac.cpp" />
|
||||
@@ -312,6 +313,7 @@
|
||||
<ClInclude Include="FileSystems\FileSystem.h" />
|
||||
<ClInclude Include="FileSystems\ISOFileSystem.h" />
|
||||
<ClInclude Include="FileSystems\MetaFileSystem.h" />
|
||||
<ClInclude Include="Font\PGF.h" />
|
||||
<ClInclude Include="HLE\FunctionWrappers.h" />
|
||||
<ClInclude Include="HLE\HLE.h" />
|
||||
<ClInclude Include="HLE\HLETables.h" />
|
||||
@@ -412,7 +414,6 @@
|
||||
<ClInclude Include="SaveState.h" />
|
||||
<ClInclude Include="System.h" />
|
||||
<ClInclude Include="Util\BlockAllocator.h" />
|
||||
<ClInclude Include="Util\Pool.h" />
|
||||
<ClInclude Include="Util\PPGeDraw.h" />
|
||||
<ClInclude Include="Util\ppge_atlas.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
<Filter Include="Ext\Snappy">
|
||||
<UniqueIdentifier>{0b77054f-7fc7-4c33-ada3-762aecde69e5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Font">
|
||||
<UniqueIdentifier>{1c79e88d-1c48-450b-8af6-f22ce7d40c66}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ELF\ElfReader.cpp">
|
||||
@@ -375,6 +378,10 @@
|
||||
<ClCompile Include="MIPS\ARM\ArmRegCacheFPU.cpp">
|
||||
<Filter>MIPS\ARM</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HLE\sceChnnlsv.cpp" />
|
||||
<ClCompile Include="Font\PGF.cpp">
|
||||
<Filter>Font</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
@@ -533,9 +540,6 @@
|
||||
<ClInclude Include="Util\BlockAllocator.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Util\Pool.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Debugger\Breakpoints.h">
|
||||
<Filter>Debugger</Filter>
|
||||
</ClInclude>
|
||||
@@ -695,6 +699,10 @@
|
||||
<ClInclude Include="MIPS\ARM\ArmRegCacheFPU.h">
|
||||
<Filter>MIPS\ARM</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HLE\sceChnnlsv.h" />
|
||||
<ClInclude Include="Font\PGF.h">
|
||||
<Filter>Font</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
||||
+9
-7
@@ -422,12 +422,6 @@ void RemoveAllEvents(int event_type)
|
||||
//This raise only the events required while the fifo is processing data
|
||||
void ProcessFifoWaitEvents()
|
||||
{
|
||||
if (Common::AtomicLoadAcquire(hasTsEvents))
|
||||
MoveEvents();
|
||||
|
||||
if (!first)
|
||||
return;
|
||||
|
||||
while (first)
|
||||
{
|
||||
if (first->time <= globalTimer)
|
||||
@@ -471,7 +465,7 @@ void MoveEvents()
|
||||
}
|
||||
}
|
||||
|
||||
void Advance()
|
||||
void AdvanceQuick()
|
||||
{
|
||||
int cyclesExecuted = slicelength - currentMIPS->downcount;
|
||||
globalTimer += cyclesExecuted;
|
||||
@@ -495,6 +489,14 @@ void Advance()
|
||||
advanceCallback(cyclesExecuted);
|
||||
}
|
||||
|
||||
void Advance()
|
||||
{
|
||||
if (Common::AtomicLoadAcquire(hasTsEvents))
|
||||
MoveEvents();
|
||||
|
||||
AdvanceQuick();
|
||||
}
|
||||
|
||||
void LogPendingEvents()
|
||||
{
|
||||
Event *ptr = first;
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace CoreTiming
|
||||
void RemoveAllEvents(int event_type);
|
||||
bool IsScheduled(int event_type);
|
||||
void Advance();
|
||||
void AdvanceQuick();
|
||||
void MoveEvents();
|
||||
void ProcessFifoWaitEvents();
|
||||
|
||||
|
||||
@@ -133,20 +133,20 @@ void CBreakPoints::AddBreakPoint(u32 _iAddress, bool temp)
|
||||
void CBreakPoints::InvalidateJit(u32 _iAddress)
|
||||
{
|
||||
// Don't want to clear cache while running, I think?
|
||||
if (MIPSComp::jit && coreState == CORE_STEPPING)
|
||||
if (MIPSComp::jit && Core_IsInactive())
|
||||
MIPSComp::jit->ClearCacheAt(_iAddress);
|
||||
}
|
||||
|
||||
void CBreakPoints::InvalidateJit()
|
||||
{
|
||||
// Don't want to clear cache while running, I think?
|
||||
if (MIPSComp::jit && coreState == CORE_STEPPING)
|
||||
if (MIPSComp::jit && Core_IsInactive())
|
||||
MIPSComp::jit->ClearCache();
|
||||
}
|
||||
|
||||
int CBreakPoints::GetNumBreakpoints()
|
||||
{
|
||||
return m_iBreakPoints.size();
|
||||
return (int)m_iBreakPoints.size();
|
||||
}
|
||||
|
||||
int CBreakPoints::GetBreakpointAddress(int i)
|
||||
|
||||
@@ -149,14 +149,9 @@ void PSPMsgDialog::DisplayYesNo()
|
||||
}
|
||||
|
||||
void PSPMsgDialog::DisplayOk()
|
||||
{
|
||||
PPGeDrawText("OK", 250, 150, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFF0000FF));
|
||||
}
|
||||
|
||||
void PSPMsgDialog::DisplayEnter()
|
||||
{
|
||||
PPGeDrawImage(okButtonImg, 200, 220, 20, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Enter", 230, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Ok", 230, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
int PSPMsgDialog::Update()
|
||||
@@ -196,11 +191,9 @@ int PSPMsgDialog::Update()
|
||||
|
||||
if(flag & DS_YESNO)
|
||||
DisplayYesNo();
|
||||
if(flag & DS_OK)
|
||||
if (flag & (DS_OK | DS_VALIDBUTTON))
|
||||
DisplayOk();
|
||||
|
||||
if(flag & DS_VALIDBUTTON)
|
||||
DisplayEnter();
|
||||
if(flag & DS_CANCELBUTTON)
|
||||
DisplayBack();
|
||||
|
||||
|
||||
@@ -20,15 +20,19 @@
|
||||
#include "../HLE/sceCtrl.h"
|
||||
#include "ChunkFile.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#define NUMKEYROWS 4
|
||||
#define KEYSPERROW 12
|
||||
#define NUMBEROFVALIDCHARS (KEYSPERROW * NUMKEYROWS)
|
||||
const char oskKeys[NUMKEYROWS][KEYSPERROW + 1] =
|
||||
{
|
||||
{'1','2','3','4','5','6','7','8','9','0','-','+','\0'},
|
||||
{'Q','W','E','R','T','Y','U','I','O','P','[',']','\0'},
|
||||
{'A','S','D','F','G','H','J','K','L',';','@','~','\0'},
|
||||
{'Z','X','C','V','B','N','M',',','.','/','?','\\','\0'},
|
||||
{'q','w','e','r','t','t','u','i','o','p','[',']','\0'},
|
||||
{'a','s','d','f','g','h','j','k','l',';','@','~','\0'},
|
||||
{'z','x','c','v','b','n','m',',','.','/','?','\\','\0'},
|
||||
};
|
||||
|
||||
|
||||
@@ -108,9 +112,9 @@ void PSPOskDialog::RenderKeyboard()
|
||||
if (limit <= 0)
|
||||
limit = 16;
|
||||
|
||||
const float keyboardLeftSide = (480.0f - (23.0f * KEYSPERROW)) / 2.0f;
|
||||
float previewLeftSide = (480.0f - (15.0f * limit)) / 2.0f;
|
||||
float title = (480.0f - (7.0f * limit)) / 2.0f;
|
||||
const float keyboardLeftSide = (480.0f - (24.0f * KEYSPERROW)) / 2.0f;
|
||||
float previewLeftSide = (480.0f - (16.0f * limit)) / 2.0f;
|
||||
float title = (480.0f - limit) / 2.0f;
|
||||
|
||||
PPGeDrawText(oskDesc.c_str(), title , 20, PPGE_ALIGN_CENTER, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
for (u32 i = 0; i < limit; ++i)
|
||||
@@ -167,15 +171,19 @@ int PSPOskDialog::Update()
|
||||
|
||||
StartDraw();
|
||||
RenderKeyboard();
|
||||
PPGeDrawImage(I_CROSS, 100, 220, 20, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Select", 130, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawImage(I_CROSS, 30, 220, 20, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Select", 60, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
PPGeDrawImage(I_CIRCLE, 200, 220, 20, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Delete", 230, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawImage(I_CIRCLE, 130, 220, 20, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Delete", 160, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
PPGeDrawImage(I_BUTTON, 290, 220, 50, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Start", 305, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Finish", 350, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawImage(I_BUTTON, 230, 220, 50, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Start", 245, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Finish", 290, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
PPGeDrawImage(I_BUTTON, 350, 220, 55, 20, 0, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Select", 365, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
PPGeDrawText("Caps", 410, 220, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF));
|
||||
|
||||
if (IsButtonPressed(CTRL_UP))
|
||||
{
|
||||
@@ -203,7 +211,12 @@ int PSPOskDialog::Update()
|
||||
if (IsButtonPressed(CTRL_CROSS))
|
||||
{
|
||||
if (inputChars.size() < limit)
|
||||
inputChars += oskKeys[selectedRow][selectedExtra];
|
||||
inputChars += (oskKeys[selectedRow][selectedExtra]);
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_SELECT))
|
||||
{
|
||||
if (inputChars.size() < limit)
|
||||
inputChars += toupper(oskKeys[selectedRow][selectedExtra]);
|
||||
}
|
||||
else if (IsButtonPressed(CTRL_CIRCLE))
|
||||
{
|
||||
@@ -229,7 +242,7 @@ int PSPOskDialog::Update()
|
||||
Memory::Write_U16(value, oskData.outtextPtr + (2 * i));
|
||||
}
|
||||
|
||||
oskData.outtextlength = inputChars.size();
|
||||
oskData.outtextlength = (u32)inputChars.size();
|
||||
oskParams.base.result= 0;
|
||||
oskData.result = PSP_UTILITY_OSK_RESULT_CHANGED;
|
||||
Memory::WriteStruct(oskParams.SceUtilityOskDataPtr, &oskData);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "ChunkFile.h"
|
||||
#include "FileUtil.h"
|
||||
#include "DirectoryFileSystem.h"
|
||||
|
||||
#include "file/zip_read.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -595,3 +595,153 @@ void DirectoryFileSystem::DoState(PointerWrap &p) {
|
||||
ERROR_LOG(FILESYS, "FIXME: Open files during savestate, could go badly.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VFSFileSystem::VFSFileSystem(IHandleAllocator *_hAlloc, std::string _basePath) : basePath(_basePath) {
|
||||
INFO_LOG(HLE, "Creating VFS file system");
|
||||
hAlloc = _hAlloc;
|
||||
}
|
||||
|
||||
VFSFileSystem::~VFSFileSystem() {
|
||||
for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
|
||||
delete [] iter->second.fileData;
|
||||
}
|
||||
entries.clear();
|
||||
}
|
||||
|
||||
std::string VFSFileSystem::GetLocalPath(std::string localPath) {
|
||||
return basePath + localPath;
|
||||
}
|
||||
|
||||
bool VFSFileSystem::MkDir(const std::string &dirname) {
|
||||
// NOT SUPPORTED - READ ONLY
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VFSFileSystem::RmDir(const std::string &dirname) {
|
||||
// NOT SUPPORTED - READ ONLY
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VFSFileSystem::RenameFile(const std::string &from, const std::string &to) {
|
||||
// NOT SUPPORTED - READ ONLY
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VFSFileSystem::RemoveFile(const std::string &filename) {
|
||||
// NOT SUPPORTED - READ ONLY
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 VFSFileSystem::OpenFile(std::string filename, FileAccess access) {
|
||||
if (access != FILEACCESS_READ) {
|
||||
ERROR_LOG(HLE, "VFSFileSystem only supports plain reading");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
const char *fullNameC = fullName.c_str();
|
||||
INFO_LOG(HLE,"VFSFileSystem actually opening %s (%s)", fullNameC, filename.c_str());
|
||||
|
||||
size_t size;
|
||||
u8 *data = VFSReadFile(fullNameC, &size);
|
||||
if (!data) {
|
||||
ERROR_LOG(HLE, "VFSFileSystem failed to open %s", filename.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
OpenFileEntry entry;
|
||||
entry.fileData = data;
|
||||
entry.size = size;
|
||||
entry.seekPos = 0;
|
||||
u32 newHandle = hAlloc->GetNewHandle();
|
||||
entries[newHandle] = entry;
|
||||
return newHandle;
|
||||
}
|
||||
|
||||
PSPFileInfo VFSFileSystem::GetFileInfo(std::string filename) {
|
||||
PSPFileInfo x;
|
||||
x.name = filename;
|
||||
|
||||
std::string fullName = GetLocalPath(filename);
|
||||
INFO_LOG(HLE,"Getting VFS file info %s (%s)", fullName.c_str(), filename.c_str());
|
||||
FileInfo fo;
|
||||
VFSGetFileInfo(fullName.c_str(), &fo);
|
||||
x.exists = fo.exists;
|
||||
if (x.exists) {
|
||||
x.size = fo.size;
|
||||
x.type = fo.isDirectory ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
|
||||
}
|
||||
INFO_LOG(HLE,"Got VFS file info: size = %i", (int)x.size);
|
||||
return x;
|
||||
}
|
||||
|
||||
void VFSFileSystem::CloseFile(u32 handle) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end()) {
|
||||
delete [] iter->second.fileData;
|
||||
entries.erase(iter);
|
||||
} else {
|
||||
//This shouldn't happen...
|
||||
ERROR_LOG(HLE,"Cannot close file that hasn't been opened: %08x", handle);
|
||||
}
|
||||
}
|
||||
|
||||
bool VFSFileSystem::OwnsHandle(u32 handle) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
return (iter != entries.end());
|
||||
}
|
||||
|
||||
size_t VFSFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size) {
|
||||
INFO_LOG(HLE,"VFSFileSystem::ReadFile %08x %p %i", handle, pointer, (u32)size);
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end())
|
||||
{
|
||||
size_t bytesRead = size;
|
||||
memcpy(pointer, iter->second.fileData + iter->second.seekPos, size);
|
||||
iter->second.seekPos += size;
|
||||
return bytesRead;
|
||||
} else {
|
||||
ERROR_LOG(HLE,"Cannot read file that hasn't been opened: %08x", handle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t VFSFileSystem::WriteFile(u32 handle, const u8 *pointer, s64 size) {
|
||||
// NOT SUPPORTED - READ ONLY
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t VFSFileSystem::SeekFile(u32 handle, s32 position, FileMove type) {
|
||||
EntryMap::iterator iter = entries.find(handle);
|
||||
if (iter != entries.end()) {
|
||||
switch (type) {
|
||||
case FILEMOVE_BEGIN: iter->second.seekPos = position; break;
|
||||
case FILEMOVE_CURRENT: iter->second.seekPos += position; break;
|
||||
case FILEMOVE_END: iter->second.seekPos = iter->second.size + position; break;
|
||||
}
|
||||
return iter->second.seekPos;
|
||||
} else {
|
||||
//This shouldn't happen...
|
||||
ERROR_LOG(HLE,"Cannot seek in file that hasn't been opened: %08x", handle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool VFSFileSystem::GetHostPath(const std::string &inpath, std::string &outpath) {
|
||||
// NOT SUPPORTED
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<PSPFileInfo> VFSFileSystem::GetDirListing(std::string path) {
|
||||
std::vector<PSPFileInfo> myVector;
|
||||
// TODO
|
||||
return myVector;
|
||||
}
|
||||
|
||||
void VFSFileSystem::DoState(PointerWrap &p) {
|
||||
if (!entries.empty()) {
|
||||
ERROR_LOG(FILESYS, "FIXME: Open files during savestate, could go badly.");
|
||||
}
|
||||
}
|
||||
@@ -95,3 +95,41 @@ private:
|
||||
bool FixPathCase(std::string &path, FixPathCaseBehavior behavior);
|
||||
#endif
|
||||
};
|
||||
|
||||
// VFSFileSystem: Ability to map in Android APK paths as well! Does not support all features, only meant for fonts.
|
||||
// Very inefficient - always load the whole file on open.
|
||||
class VFSFileSystem : public IFileSystem {
|
||||
public:
|
||||
VFSFileSystem(IHandleAllocator *_hAlloc, std::string _basePath);
|
||||
~VFSFileSystem();
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
std::vector<PSPFileInfo> GetDirListing(std::string path);
|
||||
u32 OpenFile(std::string filename, FileAccess access);
|
||||
void CloseFile(u32 handle);
|
||||
size_t ReadFile(u32 handle, u8 *pointer, s64 size);
|
||||
size_t WriteFile(u32 handle, const u8 *pointer, s64 size);
|
||||
size_t SeekFile(u32 handle, s32 position, FileMove type);
|
||||
PSPFileInfo GetFileInfo(std::string filename);
|
||||
bool OwnsHandle(u32 handle);
|
||||
|
||||
bool MkDir(const std::string &dirname);
|
||||
bool RmDir(const std::string &dirname);
|
||||
bool RenameFile(const std::string &from, const std::string &to);
|
||||
bool RemoveFile(const std::string &filename);
|
||||
bool GetHostPath(const std::string &inpath, std::string &outpath);
|
||||
|
||||
private:
|
||||
struct OpenFileEntry {
|
||||
u8 *fileData;
|
||||
size_t size;
|
||||
size_t seekPos;
|
||||
};
|
||||
|
||||
typedef std::map<u32, OpenFileEntry> EntryMap;
|
||||
EntryMap entries;
|
||||
std::string basePath;
|
||||
IHandleAllocator *hAlloc;
|
||||
|
||||
std::string GetLocalPath(std::string localpath);
|
||||
};
|
||||
@@ -203,7 +203,6 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
||||
|
||||
bool isFile = (dir.flags & 2) ? false : true;
|
||||
bool relative;
|
||||
int fnLength = dir.identifierLength;
|
||||
|
||||
TreeEntry *e = new TreeEntry();
|
||||
if (dir.identifierLength == 1 && (dir.firstIdChar == '\x00' || dir.firstIdChar == '.'))
|
||||
|
||||
@@ -0,0 +1,531 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
// ============== NOTE!!!!
|
||||
|
||||
// Thanks to the JPCSP project! This sceFont implementation is basically a C++ take on JPCSP's font code.
|
||||
// Some parts, especially in this file, were simply copied, so I guess this really makes this file GPL3.
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/Font/PGF.h"
|
||||
|
||||
// These fonts, created by ttf2pgf, don't have complete glyph info and need to be identified.
|
||||
static bool isJPCSPFont(const char *fontName) {
|
||||
return !strcmp(fontName, "Liberation") || !strcmp(fontName, "Sazanami") || !strcmp(fontName, "UnDotum");
|
||||
}
|
||||
|
||||
// Gets a number of bits from an offset.
|
||||
// TODO: Make more efficient.
|
||||
static int getBits(int numBits, const u8 *buf, size_t pos) {
|
||||
int v = 0;
|
||||
for (int i = 0; i < numBits; i++) {
|
||||
v = v | (((buf[pos >> 3] >> (pos & 7)) & 1) << i);
|
||||
pos++;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
static std::vector<int> getTable(const u8 *buf, int bpe, int length) {
|
||||
std::vector<int> vec;
|
||||
vec.resize(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
vec[i] = getBits(bpe, buf, bpe * i);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
PGF::PGF()
|
||||
: fontData(0), charMap(0), shadowCharMap(0), charPointerTable(0) {
|
||||
|
||||
}
|
||||
|
||||
PGF::~PGF() {
|
||||
delete [] fontData;
|
||||
delete [] charMap;
|
||||
delete [] shadowCharMap;
|
||||
delete [] charPointerTable;
|
||||
}
|
||||
|
||||
void PGF::DoState(PointerWrap &p) {
|
||||
// TODO!
|
||||
}
|
||||
|
||||
void PGF::ReadPtr(const u8 *ptr, size_t dataSize) {
|
||||
const u8 *const startPtr = ptr;
|
||||
|
||||
INFO_LOG(HLE, "Reading %i bytes of PGF header", sizeof(header));
|
||||
memcpy(&header, ptr, sizeof(header));
|
||||
ptr += sizeof(header);
|
||||
|
||||
if (header.revision == 3) {
|
||||
memcpy(&rev3extra, ptr, sizeof(rev3extra));
|
||||
rev3extra.compCharMapLength1 &= 0xFFFF;
|
||||
rev3extra.compCharMapLength2 &= 0xFFFF;
|
||||
ptr += sizeof(rev3extra);
|
||||
}
|
||||
|
||||
const u32 *wptr = (const u32 *)ptr;
|
||||
dimensionTable[0].resize(header.dimTableLength);
|
||||
dimensionTable[1].resize(header.dimTableLength);
|
||||
for (int i = 0; i < header.dimTableLength; i++) {
|
||||
dimensionTable[0][i] = *wptr++;
|
||||
dimensionTable[1][i] = *wptr++;
|
||||
}
|
||||
|
||||
xAdjustTable[0].resize(header.xAdjustTableLength);
|
||||
xAdjustTable[1].resize(header.xAdjustTableLength);
|
||||
for (int i = 0; i < header.xAdjustTableLength; i++) {
|
||||
xAdjustTable[0][i] = *wptr++;
|
||||
xAdjustTable[1][i] = *wptr++;
|
||||
}
|
||||
|
||||
yAdjustTable[0].resize(header.yAdjustTableLength);
|
||||
yAdjustTable[1].resize(header.yAdjustTableLength);
|
||||
for (int i = 0; i < header.yAdjustTableLength; i++) {
|
||||
yAdjustTable[0][i] = *wptr++;
|
||||
yAdjustTable[1][i] = *wptr++;
|
||||
}
|
||||
|
||||
advanceTable[0].resize(header.advanceTableLength);
|
||||
advanceTable[1].resize(header.advanceTableLength);
|
||||
for (int i = 0; i < header.advanceTableLength; i++) {
|
||||
advanceTable[0][i] = *wptr++;
|
||||
advanceTable[1][i] = *wptr++;
|
||||
}
|
||||
|
||||
const u8 *uptr = (const u8 *)wptr;
|
||||
|
||||
int shadowCharMapSize = ((header.shadowMapLength * header.shadowMapBpe + 31) & ~31) / 8;
|
||||
shadowCharMap = new u8[shadowCharMapSize];
|
||||
for (int i = 0; i < shadowCharMapSize; i++) {
|
||||
shadowCharMap[i] = *uptr++;
|
||||
}
|
||||
|
||||
const u16 *sptr = (const u16 *)uptr;
|
||||
if (header.revision == 3) {
|
||||
charmapCompressionTable1[0].resize(rev3extra.compCharMapLength1);
|
||||
charmapCompressionTable1[1].resize(rev3extra.compCharMapLength1);
|
||||
for (int i = 0; i < rev3extra.compCharMapLength1; i++) {
|
||||
charmapCompressionTable1[0][i] = *sptr++;
|
||||
charmapCompressionTable1[1][i] = *sptr++;
|
||||
}
|
||||
|
||||
charmapCompressionTable2[0].resize(rev3extra.compCharMapLength2);
|
||||
charmapCompressionTable2[1].resize(rev3extra.compCharMapLength2);
|
||||
for (int i = 0; i < rev3extra.compCharMapLength2; i++) {
|
||||
charmapCompressionTable2[0][i] = *sptr++;
|
||||
charmapCompressionTable2[1][i] = *sptr++;
|
||||
}
|
||||
}
|
||||
|
||||
uptr = (const u8 *)sptr;
|
||||
|
||||
int charMapSize = ((header.charMapLength * header.charMapBpe + 31) & ~31) / 8;
|
||||
|
||||
charMap = new u8[charMapSize];
|
||||
for (int i = 0; i < charMapSize; i++) {
|
||||
charMap[i] = *uptr++;
|
||||
}
|
||||
|
||||
int charPointerSize = (((header.charPointerLength * header.charPointerBpe + 31) & ~31) / 8);
|
||||
charPointerTable = new u8[charPointerSize];
|
||||
for (int i = 0; i < charPointerSize; i++) {
|
||||
charPointerTable[i] = *uptr++;
|
||||
}
|
||||
|
||||
// PGF Fontdata.
|
||||
u32 fontDataOffset = uptr - startPtr;
|
||||
|
||||
fontDataSize = dataSize - fontDataOffset;
|
||||
fontData = new u8[fontDataSize];
|
||||
memcpy(fontData, uptr, fontDataSize);
|
||||
|
||||
// charmap.resize();
|
||||
charmap.resize(header.charMapLength);
|
||||
int charmap_compr_len = header.revision == 3 ? 7 : 1;
|
||||
charmap_compr.resize(charmap_compr_len * 4);
|
||||
glyphs.resize(header.charPointerLength);
|
||||
shadowGlyphs.resize(header.shadowMapLength);
|
||||
firstGlyph = header.firstGlyph;
|
||||
|
||||
// Parse out the char map (array where each entry is an irregular number of bits)
|
||||
// BPE = bits per entry, I think.
|
||||
for (int i = 0; i < header.charMapLength; i++) {
|
||||
charmap[i] = getBits(header.charMapBpe, charMap, i * header.charMapBpe);
|
||||
// This check seems a little odd.
|
||||
if ((size_t)charmap[i] >= glyphs.size())
|
||||
charmap[i] = 65535;
|
||||
}
|
||||
|
||||
std::vector<int> charPointers = getTable(charPointerTable, header.charPointerBpe, glyphs.size());
|
||||
std::vector<int> shadowMap = getTable(shadowCharMap, header.shadowMapBpe, shadowGlyphs.size());
|
||||
|
||||
// Pregenerate glyphs.
|
||||
for (size_t i = 0; i < glyphs.size(); i++) {
|
||||
GetGlyph(fontData, charPointers[i] * 4 * 8 /* ??? */, FONT_PGF_CHARGLYPH, glyphs[i]);
|
||||
}
|
||||
|
||||
// And shadow glyphs.
|
||||
for (size_t i = 0; i < shadowGlyphs.size(); i++) {
|
||||
size_t shadowId = glyphs[i].shadowID;
|
||||
if (shadowId >= 0 && shadowId < shadowMap.size()) {
|
||||
size_t charId = shadowMap[shadowId];
|
||||
if (charId >= 0 && charId < glyphs.size()) {
|
||||
// TODO: check for pre existing shadow glyph
|
||||
GetGlyph(fontData, charPointers[charId] * 4 * 8 /* ??? */, FONT_PGF_SHADOWGLYPH, shadowGlyphs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int PGF::GetCharIndex(int charCode, const std::vector<int> &charmapCompressed) {
|
||||
int charIndex = 0;
|
||||
for (size_t i = 0; i < charmapCompressed.size(); i += 2) {
|
||||
if (charCode >= charmapCompressed[i] && charCode < charmapCompressed[i] + charmapCompressed[i + 1]) {
|
||||
charIndex += charCode - charmapCompressed[i];
|
||||
return charIndex;
|
||||
}
|
||||
charIndex += charmapCompressed[i + 1];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool PGF::GetCharInfo(int charCode, PGFCharInfo *charInfo) {
|
||||
Glyph glyph;
|
||||
if (!GetCharGlyph(charCode, FONT_PGF_CHARGLYPH, glyph)) {
|
||||
// Character not in font, return zeroed charInfo as on real PSP.
|
||||
return false;
|
||||
}
|
||||
memset(charInfo, 0, sizeof(charInfo));
|
||||
|
||||
charInfo->bitmapWidth = glyph.w;
|
||||
charInfo->bitmapHeight = glyph.h;
|
||||
charInfo->bitmapLeft = glyph.left;
|
||||
charInfo->bitmapTop = glyph.top;
|
||||
charInfo->sfp26Width = glyph.dimensionWidth;
|
||||
charInfo->sfp26Height = glyph.dimensionHeight;
|
||||
charInfo->sfp26Ascender = glyph.top << 6;
|
||||
charInfo->sfp26Descender = (glyph.h - glyph.top) << 6;
|
||||
charInfo->sfp26BearingHX = glyph.xAdjustH;
|
||||
charInfo->sfp26BearingHY = glyph.yAdjustH;
|
||||
charInfo->sfp26BearingVX = glyph.xAdjustV;
|
||||
charInfo->sfp26BearingVY = glyph.yAdjustV;
|
||||
charInfo->sfp26AdvanceH = glyph.advanceH;
|
||||
charInfo->sfp26AdvanceV = glyph.advanceV;
|
||||
return true;
|
||||
}
|
||||
|
||||
void PGF::GetFontInfo(PGFFontInfo *fi) {
|
||||
fi->maxGlyphWidthI = header.maxSize[0];
|
||||
fi->maxGlyphHeightI = header.maxSize[1];
|
||||
fi->maxGlyphAscenderI = header.maxAscender;
|
||||
fi->maxGlyphDescenderI = header.maxDescender;
|
||||
fi->maxGlyphLeftXI = header.maxLeftXAdjust;
|
||||
fi->maxGlyphBaseYI = header.maxBaseYAdjust;
|
||||
fi->minGlyphCenterXI = header.minCenterXAdjust;
|
||||
fi->maxGlyphTopYI = header.maxTopYAdjust;
|
||||
fi->maxGlyphAdvanceXI = header.maxAdvance[0];
|
||||
fi->maxGlyphAdvanceYI = header.maxAdvance[1];
|
||||
fi->maxGlyphWidthF = header.maxSize[0] / 64.0f;
|
||||
fi->maxGlyphHeightF = header.maxSize[1] / 64.0f;
|
||||
fi->maxGlyphAscenderF = header.maxAscender / 64.0f;
|
||||
fi->maxGlyphDescenderF = header.maxDescender / 64.0f;
|
||||
fi->maxGlyphLeftXF = header.maxLeftXAdjust / 64.0f;
|
||||
fi->maxGlyphBaseYF = header.maxBaseYAdjust / 64.0f;
|
||||
fi->minGlyphCenterXF = header.minCenterXAdjust / 64.0f;
|
||||
fi->maxGlyphTopYF = header.maxTopYAdjust / 64.0f;
|
||||
fi->maxGlyphAdvanceXF = header.maxAdvance[0] / 64.0f;
|
||||
fi->maxGlyphAdvanceYF = header.maxAdvance[1] / 64.0f;
|
||||
|
||||
fi->maxGlyphWidth = header.maxGlyphWidth;
|
||||
fi->maxGlyphHeight = header.maxGlyphHeight;
|
||||
fi->charMapLength = header.charMapLength;
|
||||
fi->shadowMapLength = 0; // header.shadowMapLength; TODO
|
||||
|
||||
fi->BPP = header.bpp;
|
||||
}
|
||||
|
||||
bool PGF::GetGlyph(const u8 *fontdata, size_t charPtr, int glyphType, Glyph &glyph) {
|
||||
if (glyphType == FONT_PGF_SHADOWGLYPH) {
|
||||
if (charPtr + 96 > fontDataSize * 8)
|
||||
return false;
|
||||
charPtr += getBits(14, fontdata, charPtr) * 8;
|
||||
if (charPtr + 96 > fontDataSize * 8)
|
||||
return false;
|
||||
}
|
||||
charPtr += 14;
|
||||
|
||||
glyph.w = getBits(7, fontdata, charPtr);
|
||||
charPtr += 7;
|
||||
|
||||
glyph.h = getBits(7, fontdata, charPtr);
|
||||
charPtr += 7;
|
||||
|
||||
glyph.left = getBits(7, fontdata, charPtr);
|
||||
charPtr += 7;
|
||||
if (glyph.left >= 64) {
|
||||
glyph.left -= 128;
|
||||
}
|
||||
|
||||
glyph.top = getBits(7, fontdata, charPtr);
|
||||
charPtr += 7;
|
||||
if (glyph.top >= 64) {
|
||||
glyph.top -= 128;
|
||||
}
|
||||
|
||||
glyph.flags = getBits(6, fontdata, charPtr);
|
||||
charPtr += 6;
|
||||
|
||||
if (glyph.flags & FONT_PGF_CHARGLYPH) {
|
||||
// Skip magic number
|
||||
charPtr += 7;
|
||||
|
||||
glyph.shadowID = getBits(9, fontdata, charPtr);
|
||||
charPtr += 9;
|
||||
|
||||
int dimensionIndex = getBits(8, fontdata, charPtr);
|
||||
charPtr += 8;
|
||||
|
||||
int xAdjustIndex = getBits(8, fontdata, charPtr);
|
||||
charPtr += 8;
|
||||
|
||||
int yAdjustIndex = getBits(8, fontdata, charPtr);
|
||||
charPtr += 8;
|
||||
|
||||
charPtr +=
|
||||
((glyph.flags & FONT_PGF_METRIC_FLAG1) ? 0 : 56) +
|
||||
((glyph.flags & FONT_PGF_METRIC_FLAG2) ? 0 : 56) +
|
||||
((glyph.flags & FONT_PGF_METRIC_FLAG3) ? 0 : 56);
|
||||
|
||||
int advanceIndex = getBits(8, fontdata, charPtr);
|
||||
charPtr += 8;
|
||||
|
||||
if (dimensionIndex < header.dimTableLength) {
|
||||
glyph.dimensionWidth = dimensionTable[0][dimensionIndex];
|
||||
glyph.dimensionHeight = dimensionTable[1][dimensionIndex];
|
||||
}
|
||||
|
||||
if (xAdjustIndex < header.xAdjustTableLength) {
|
||||
glyph.xAdjustH = xAdjustTable[0][xAdjustIndex];
|
||||
glyph.xAdjustV = xAdjustTable[1][xAdjustIndex];
|
||||
}
|
||||
|
||||
if (yAdjustIndex < header.xAdjustTableLength) {
|
||||
glyph.yAdjustH = yAdjustTable[0][yAdjustIndex];
|
||||
glyph.yAdjustV = yAdjustTable[1][yAdjustIndex];
|
||||
}
|
||||
|
||||
if (dimensionIndex == 0 && xAdjustIndex == 0 && yAdjustIndex == 0 && isJPCSPFont(fileName.c_str())) {
|
||||
// Fonts created by ttf2pgf do not contain complete Glyph information.
|
||||
// Provide default values.
|
||||
glyph.dimensionWidth = glyph.w << 6;
|
||||
glyph.dimensionHeight = glyph.h << 6;
|
||||
// This stuff doesn't exactly look right.
|
||||
glyph.xAdjustH = glyph.left << 6;
|
||||
glyph.xAdjustV = glyph.left << 6;
|
||||
glyph.yAdjustH = glyph.top << 6;
|
||||
glyph.yAdjustV = glyph.top << 6;
|
||||
}
|
||||
|
||||
if (advanceIndex < header.advanceTableLength) {
|
||||
glyph.advanceH = advanceTable[0][advanceIndex];
|
||||
glyph.advanceV = advanceTable[1][advanceIndex];
|
||||
}
|
||||
} else {
|
||||
glyph.shadowID = 65535;
|
||||
glyph.advanceH = 0;
|
||||
}
|
||||
|
||||
glyph.ptr = (u32)(charPtr / 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PGF::GetCharGlyph(int charCode, int glyphType, Glyph &glyph) {
|
||||
if (charCode < firstGlyph)
|
||||
return false;
|
||||
charCode -= firstGlyph;
|
||||
if (charCode < (int)charmap.size()) {
|
||||
charCode = charmap[charCode];
|
||||
}
|
||||
if (glyphType == FONT_PGF_CHARGLYPH) {
|
||||
if (charCode >= (int)glyphs.size())
|
||||
return false;
|
||||
glyph = glyphs[charCode];
|
||||
} else {
|
||||
if (charCode >= (int)shadowGlyphs.size())
|
||||
return false;
|
||||
glyph = shadowGlyphs[charCode];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PGF::DrawCharacter(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight, int pixelformat, int charCode, int altCharCode, int glyphType) {
|
||||
Glyph glyph;
|
||||
if (!GetCharGlyph(charCode, glyphType, glyph)) {
|
||||
// No Glyph available for this charCode, try to use the alternate char.
|
||||
charCode = altCharCode;
|
||||
if (!GetCharGlyph(charCode, glyphType, glyph)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (glyph.w <= 0 || glyph.h <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((glyph.flags & FONT_PGF_BMP_OVERLAY) != FONT_PGF_BMP_H_ROWS) &&
|
||||
((glyph.flags & FONT_PGF_BMP_OVERLAY) != FONT_PGF_BMP_V_ROWS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
u32 bitPtr = glyph.ptr * 8;
|
||||
int numberPixels = glyph.w * glyph.h;
|
||||
int pixelIndex = 0;
|
||||
|
||||
while (pixelIndex < numberPixels && bitPtr + 8 < fontDataSize * 8) {
|
||||
// This is some kind of nibble based RLE compression.
|
||||
int nibble = getBits(4, fontData, bitPtr);
|
||||
bitPtr += 4;
|
||||
|
||||
int count;
|
||||
int value;
|
||||
if (nibble < 8) {
|
||||
value = getBits(4, fontData, bitPtr);
|
||||
bitPtr += 4;
|
||||
count = nibble + 1;
|
||||
} else {
|
||||
count = 16 - nibble;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count && pixelIndex < numberPixels; i++) {
|
||||
if (nibble >= 8) {
|
||||
value = getBits(4, fontData, bitPtr);
|
||||
bitPtr += 4;
|
||||
}
|
||||
|
||||
int xx, yy;
|
||||
if ((glyph.flags & FONT_PGF_BMP_OVERLAY) == FONT_PGF_BMP_H_ROWS) {
|
||||
xx = pixelIndex % glyph.w;
|
||||
yy = pixelIndex / glyph.w;
|
||||
} else {
|
||||
xx = pixelIndex / glyph.h;
|
||||
yy = pixelIndex % glyph.h;
|
||||
}
|
||||
|
||||
int pixelX = x + xx;
|
||||
int pixelY = y + yy;
|
||||
if (pixelX >= clipX && pixelX < clipX + clipWidth && pixelY >= clipY && pixelY < clipY + clipHeight) {
|
||||
// 4-bit color value
|
||||
int pixelColor = value;
|
||||
switch (pixelformat) {
|
||||
case PSP_FONT_PIXELFORMAT_8:
|
||||
// 8-bit color value
|
||||
pixelColor |= pixelColor << 4;
|
||||
break;
|
||||
case PSP_FONT_PIXELFORMAT_24:
|
||||
// 24-bit color value
|
||||
pixelColor |= pixelColor << 4;
|
||||
pixelColor |= pixelColor << 8;
|
||||
pixelColor |= pixelColor << 8;
|
||||
break;
|
||||
case PSP_FONT_PIXELFORMAT_32:
|
||||
// 32-bit color value
|
||||
pixelColor |= pixelColor << 4;
|
||||
pixelColor |= pixelColor << 8;
|
||||
pixelColor |= pixelColor << 16;
|
||||
break;
|
||||
}
|
||||
|
||||
SetFontPixel(base, bpl, bufWidth, bufHeight, pixelX, pixelY, pixelColor, pixelformat);
|
||||
}
|
||||
|
||||
pixelIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PGF::SetFontPixel(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int pixelColor, int pixelformat) {
|
||||
if (x < 0 || x >= bufWidth || y < 0 || y >= bufHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
static const u8 fontPixelSizeInBytes[] = { 0, 0, 1, 3, 4 }; // 0 means 2 pixels per byte
|
||||
int pixelBytes = fontPixelSizeInBytes[pixelformat];
|
||||
int bufMaxWidth = (pixelBytes == 0 ? bpl * 2 : bpl / pixelBytes);
|
||||
if (x >= bufMaxWidth) {
|
||||
return;
|
||||
}
|
||||
|
||||
int framebufferAddr = base + (y * bpl) + (pixelBytes == 0 ? x / 2 : x * pixelBytes);
|
||||
|
||||
switch (pixelformat) {
|
||||
case PSP_FONT_PIXELFORMAT_4:
|
||||
case PSP_FONT_PIXELFORMAT_4_REV:
|
||||
{
|
||||
int oldColor = Memory::Read_U8(framebufferAddr);
|
||||
int newColor;
|
||||
if ((x & 1) != pixelformat) {
|
||||
newColor = (pixelColor << 4) | (oldColor & 0xF);
|
||||
} else {
|
||||
newColor = (oldColor & 0xF0) | pixelColor;
|
||||
}
|
||||
Memory::Write_U8(newColor, framebufferAddr);
|
||||
break;
|
||||
}
|
||||
case PSP_FONT_PIXELFORMAT_8:
|
||||
{
|
||||
Memory::Write_U8((u8)pixelColor, framebufferAddr);
|
||||
break;
|
||||
}
|
||||
case PSP_FONT_PIXELFORMAT_24:
|
||||
{
|
||||
Memory::Write_U8(pixelColor & 0xFF, framebufferAddr + 0);
|
||||
Memory::Write_U8(pixelColor >> 8, framebufferAddr + 1);
|
||||
Memory::Write_U8(pixelColor >> 16, framebufferAddr + 2);
|
||||
break;
|
||||
}
|
||||
case PSP_FONT_PIXELFORMAT_32:
|
||||
{
|
||||
Memory::Write_U32(pixelColor, framebufferAddr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetFontPixelColor(int color, int pixelformat) {
|
||||
switch (pixelformat) {
|
||||
case PSP_FONT_PIXELFORMAT_4:
|
||||
case PSP_FONT_PIXELFORMAT_4_REV:
|
||||
// Use only 4-bit alpha
|
||||
color = (color >> 28) & 0xF;
|
||||
break;
|
||||
case PSP_FONT_PIXELFORMAT_8:
|
||||
// Use only 8-bit alpha
|
||||
color = (color >> 24) & 0xFF;
|
||||
break;
|
||||
case PSP_FONT_PIXELFORMAT_24:
|
||||
// Use RGB with 8-bit values
|
||||
color = color & 0x00FFFFFF;
|
||||
break;
|
||||
case PSP_FONT_PIXELFORMAT_32:
|
||||
// Use RGBA with 8-bit values
|
||||
break;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
// Thanks to the JPCSP project! This sceFont implementation is basically a C++ take on JPCSP's font code.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
enum {
|
||||
FONT_FILETYPE_PGF = 0x00,
|
||||
FONT_FILETYPE_BWFON = 0x01,
|
||||
};
|
||||
|
||||
enum {
|
||||
FONT_PGF_BMP_H_ROWS = 0x01,
|
||||
FONT_PGF_BMP_V_ROWS = 0x02,
|
||||
FONT_PGF_BMP_OVERLAY = 0x03,
|
||||
FONT_PGF_METRIC_FLAG1 = 0x04,
|
||||
FONT_PGF_METRIC_FLAG2 = 0x08,
|
||||
FONT_PGF_METRIC_FLAG3 = 0x10,
|
||||
FONT_PGF_CHARGLYPH = 0x20,
|
||||
FONT_PGF_SHADOWGLYPH = 0x40,
|
||||
};
|
||||
|
||||
enum Family {
|
||||
FONT_FAMILY_SANS_SERIF = 1,
|
||||
FONT_FAMILY_SERIF = 2,
|
||||
};
|
||||
|
||||
enum Style {
|
||||
FONT_STYLE_REGULAR = 1,
|
||||
FONT_STYLE_ITALIC = 2,
|
||||
FONT_STYLE_BOLD = 5,
|
||||
FONT_STYLE_BOLD_ITALIC = 6,
|
||||
FONT_STYLE_DB = 103, // Demi-Bold / semi-bold
|
||||
};
|
||||
|
||||
enum Language {
|
||||
FONT_LANGUAGE_JAPANESE = 1,
|
||||
FONT_LANGUAGE_LATIN = 2,
|
||||
FONT_LANGUAGE_KOREAN = 3,
|
||||
FONT_LANGUAGE_CHINESE = 4,
|
||||
};
|
||||
|
||||
enum FontPixelFormat {
|
||||
PSP_FONT_PIXELFORMAT_4 = 0, // 2 pixels packed in 1 byte (natural order)
|
||||
PSP_FONT_PIXELFORMAT_4_REV = 1, // 2 pixels packed in 1 byte (reversed order)
|
||||
PSP_FONT_PIXELFORMAT_8 = 2, // 1 pixel in 1 byte
|
||||
PSP_FONT_PIXELFORMAT_24 = 3, // 1 pixel in 3 bytes (RGB)
|
||||
PSP_FONT_PIXELFORMAT_32 = 4, // 1 pixel in 4 bytes (RGBA)
|
||||
};
|
||||
|
||||
|
||||
struct PGFFontStyle {
|
||||
float fontH;
|
||||
float fontV;
|
||||
float fontHRes;
|
||||
float fontVRes;
|
||||
float fontWeight;
|
||||
u16 fontFamily;
|
||||
u16 fontStyle;
|
||||
// Check.
|
||||
u16 fontStyleSub;
|
||||
u16 fontLanguage;
|
||||
u16 fontRegion;
|
||||
u16 fontCountry;
|
||||
char fontName[64];
|
||||
char fontFileName[64];
|
||||
u32 fontAttributes;
|
||||
u32 fontExpire;
|
||||
};
|
||||
|
||||
|
||||
class Glyph {
|
||||
public:
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
int left;
|
||||
int top;
|
||||
int flags;
|
||||
int shadowID;
|
||||
int advanceH;
|
||||
int advanceV;
|
||||
int dimensionWidth, dimensionHeight;
|
||||
int xAdjustH, xAdjustV;
|
||||
int yAdjustH, yAdjustV;
|
||||
u32 ptr;
|
||||
};
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct PGFHeader
|
||||
{
|
||||
u16 headerOffset;
|
||||
u16 headerSize;
|
||||
|
||||
char PGFMagic[4];
|
||||
int revision;
|
||||
int version;
|
||||
|
||||
int charMapLength;
|
||||
int charPointerLength;
|
||||
int charMapBpe;
|
||||
int charPointerBpe;
|
||||
|
||||
u8 pad1[2];
|
||||
u8 bpp;
|
||||
u8 pad2[1];
|
||||
|
||||
int hSize;
|
||||
int vSize;
|
||||
int hResolution;
|
||||
int vResolution;
|
||||
|
||||
u8 pad3[1];
|
||||
char fontName[64];
|
||||
char fontType[64];
|
||||
u8 pad4[1];
|
||||
|
||||
u16 firstGlyph;
|
||||
u16 lastGlyph;
|
||||
|
||||
u8 pad5[26];
|
||||
|
||||
int maxAscender;
|
||||
int maxDescender;
|
||||
int maxLeftXAdjust;
|
||||
int maxBaseYAdjust;
|
||||
int minCenterXAdjust;
|
||||
int maxTopYAdjust;
|
||||
|
||||
int maxAdvance[2];
|
||||
int maxSize[2];
|
||||
u16 maxGlyphWidth;
|
||||
u16 maxGlyphHeight;
|
||||
u8 pad6[2];
|
||||
|
||||
u8 dimTableLength;
|
||||
u8 xAdjustTableLength;
|
||||
u8 yAdjustTableLength;
|
||||
u8 advanceTableLength;
|
||||
u8 pad7[102];
|
||||
|
||||
int shadowMapLength;
|
||||
int shadowMapBpe;
|
||||
float unknown1;
|
||||
int shadowScale[2];
|
||||
u8 pad8[8];
|
||||
};
|
||||
|
||||
struct PGFHeaderRev3Extra {
|
||||
int compCharMapBpe1;
|
||||
int compCharMapLength1;
|
||||
int compCharMapBpe2;
|
||||
int compCharMapLength2;
|
||||
u32 unknown;
|
||||
};
|
||||
|
||||
struct PGFCharInfo {
|
||||
u32 bitmapWidth;
|
||||
u32 bitmapHeight;
|
||||
u32 bitmapLeft;
|
||||
u32 bitmapTop;
|
||||
// Glyph metrics (in 26.6 signed fixed-point).
|
||||
u32 sfp26Width;
|
||||
u32 sfp26Height;
|
||||
s32 sfp26Ascender;
|
||||
s32 sfp26Descender;
|
||||
s32 sfp26BearingHX;
|
||||
s32 sfp26BearingHY;
|
||||
s32 sfp26BearingVX;
|
||||
s32 sfp26BearingVY;
|
||||
s32 sfp26AdvanceH;
|
||||
s32 sfp26AdvanceV;
|
||||
u8 pad[4];
|
||||
};
|
||||
|
||||
struct PGFFontInfo {
|
||||
// Glyph metrics (in 26.6 signed fixed-point).
|
||||
int maxGlyphWidthI;
|
||||
int maxGlyphHeightI;
|
||||
int maxGlyphAscenderI;
|
||||
int maxGlyphDescenderI;
|
||||
int maxGlyphLeftXI;
|
||||
int maxGlyphBaseYI;
|
||||
int minGlyphCenterXI;
|
||||
int maxGlyphTopYI;
|
||||
int maxGlyphAdvanceXI;
|
||||
int maxGlyphAdvanceYI;
|
||||
|
||||
// Glyph metrics (replicated as float).
|
||||
float maxGlyphWidthF;
|
||||
float maxGlyphHeightF;
|
||||
float maxGlyphAscenderF;
|
||||
float maxGlyphDescenderF;
|
||||
float maxGlyphLeftXF;
|
||||
float maxGlyphBaseYF;
|
||||
float minGlyphCenterXF;
|
||||
float maxGlyphTopYF;
|
||||
float maxGlyphAdvanceXF;
|
||||
float maxGlyphAdvanceYF;
|
||||
|
||||
// Bitmap dimensions.
|
||||
short maxGlyphWidth;
|
||||
short maxGlyphHeight;
|
||||
int charMapLength; // Number of elements in the font's charmap.
|
||||
int shadowMapLength; // Number of elements in the font's shadow charmap.
|
||||
|
||||
// Font style (used by font comparison functions).
|
||||
PGFFontStyle fontStyle;
|
||||
|
||||
int BPP; // Font's BPP.
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
class PGF {
|
||||
public:
|
||||
PGF();
|
||||
~PGF();
|
||||
|
||||
void ReadPtr(const u8 *ptr, size_t dataSize);
|
||||
|
||||
bool GetCharInfo(int charCode, PGFCharInfo *ci);
|
||||
void GetFontInfo(PGFFontInfo *fi);
|
||||
void DrawCharacter(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight, int pixelformat, int charCode, int altCharCode, int glyphType);
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
PGFHeader header;
|
||||
|
||||
private:
|
||||
bool GetGlyph(const u8 *fontdata, size_t charPtr, int glyphType, Glyph &glyph);
|
||||
bool GetCharGlyph(int charCode, int glyphType, Glyph &glyph);
|
||||
|
||||
// Unused
|
||||
int GetCharIndex(int charCode, const std::vector<int> &charmapCompressed);
|
||||
|
||||
void SetFontPixel(u32 base, int bpl, int bufWidth, int bufHeight, int x, int y, int pixelColor, int pixelformat);
|
||||
|
||||
PGFHeaderRev3Extra rev3extra;
|
||||
|
||||
// Font character image data
|
||||
u8 *fontData;
|
||||
size_t fontDataSize;
|
||||
|
||||
std::string fileName;
|
||||
|
||||
std::vector<int> dimensionTable[2];
|
||||
std::vector<int> xAdjustTable[2];
|
||||
std::vector<int> yAdjustTable[2];
|
||||
std::vector<int> advanceTable[2];
|
||||
|
||||
// Unused
|
||||
std::vector<int> charmapCompressionTable1[2];
|
||||
std::vector<int> charmapCompressionTable2[2];
|
||||
|
||||
u8 *charMap;
|
||||
u8 *shadowCharMap;
|
||||
u8 *charPointerTable;
|
||||
|
||||
std::vector<int> charmap_compr;
|
||||
std::vector<int> charmap;
|
||||
|
||||
std::vector<Glyph> glyphs;
|
||||
std::vector<Glyph> shadowGlyphs;
|
||||
int firstGlyph;
|
||||
};
|
||||
@@ -96,6 +96,11 @@ template<float func()> void WrapF_V() {
|
||||
RETURNF(func());
|
||||
}
|
||||
|
||||
// TODO: Not sure about the floating point parameter passing
|
||||
template<float func(int, float, u32)> void WrapF_IFU() {
|
||||
RETURNF(func(PARAM(0), PARAMF(0), PARAM(1)));
|
||||
}
|
||||
|
||||
template<u32 func(u32)> void WrapU_U() {
|
||||
u32 retval = func(PARAM(0));
|
||||
RETURN(retval);
|
||||
@@ -133,7 +138,7 @@ template<int func(u32, u32)> void WrapI_UU() {
|
||||
|
||||
template<int func(u32, float, float)> void WrapI_UFF() {
|
||||
// Not sure about the float arguments.
|
||||
int retval = func(PARAM(0), currentMIPS->f[0], currentMIPS->f[1]);
|
||||
int retval = func(PARAM(0), currentMIPS->f[12], currentMIPS->f[13]);
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
@@ -313,6 +318,11 @@ template<int func(int, int, int, int)> void WrapI_IIII() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, const char *, int, u32, u32)> void WrapI_ICIUU() {
|
||||
int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<int func(int, int, u32)> void WrapI_IIU() {
|
||||
int retval = func(PARAM(0), PARAM(1), PARAM(2));
|
||||
RETURN(retval);
|
||||
@@ -481,6 +491,11 @@ template<u32 func(u32, u32, u32, u32)> void WrapU_UUUU() {
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(u32, const char *, u32, u32)> void WrapU_UCUU() {
|
||||
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(u32, u32, u32, int)> void WrapU_UUUI() {
|
||||
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
|
||||
RETURN(retval);
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ void HLEInit()
|
||||
|
||||
void HLEDoState(PointerWrap &p)
|
||||
{
|
||||
Syscall sc = {0};
|
||||
Syscall sc = {""};
|
||||
p.Do(unresolvedSyscalls, sc);
|
||||
p.Do(exportedCalls, sc);
|
||||
p.DoMarker("HLE");
|
||||
|
||||
+2
-1
@@ -53,11 +53,12 @@ struct Syscall
|
||||
};
|
||||
|
||||
#define PARAM(n) currentMIPS->r[4+n]
|
||||
#define PARAMF(n) currentMIPS->f[12+n]
|
||||
#define RETURN(n) currentMIPS->r[2]=n
|
||||
#define RETURNF(fl) currentMIPS->f[0]=fl
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
#include "FunctionWrappers.h"
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "sceVaudio.h"
|
||||
#include "sceUsb.h"
|
||||
#include "sceChnnlsv.h"
|
||||
#include "scePspNpDrm_user.h"
|
||||
|
||||
#define N(s) s
|
||||
|
||||
|
||||
@@ -395,10 +395,11 @@ u32 sceAtracGetStreamDataInfo(int atracID, u32 writeAddr, u32 writableBytesAddr,
|
||||
Atrac *atrac = getAtrac(atracID);
|
||||
if (!atrac) {
|
||||
//return -1;
|
||||
} else {
|
||||
Memory::Write_U32(atrac->first.addr, writeAddr);
|
||||
Memory::Write_U32(atrac->first.writableBytes, writableBytesAddr);
|
||||
Memory::Write_U32(atrac->first.fileoffset, readOffsetAddr);
|
||||
}
|
||||
Memory::Write_U32(atrac->first.addr, writeAddr);
|
||||
Memory::Write_U32(atrac->first.writableBytes, writableBytesAddr);
|
||||
Memory::Write_U32(atrac->first.fileoffset, readOffsetAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -403,12 +403,15 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
|
||||
if (skipFrame) {
|
||||
gstate_c.skipDrawReason |= SKIPDRAW_SKIPFRAME;
|
||||
numSkippedFrames++;
|
||||
} else {
|
||||
} else {
|
||||
numSkippedFrames = 0;
|
||||
}
|
||||
|
||||
if (!skipFlip) {
|
||||
coreState = CORE_NEXTFRAME;
|
||||
// Might've just quit / been paused.
|
||||
if (coreState == CORE_RUNNING) {
|
||||
coreState = CORE_NEXTFRAME;
|
||||
}
|
||||
CoreTiming::ScheduleEvent(0 - cyclesLate, afterFlipEvent, 0);
|
||||
|
||||
gpu->CopyDisplayToOutput();
|
||||
|
||||
+740
-290
File diff suppressed because it is too large.
Load diff
@@ -5,4 +5,5 @@ class PointerWrap;
|
||||
void Register_sceFont();
|
||||
|
||||
void __FontInit();
|
||||
void __FontShutdown();
|
||||
void __FontDoState(PointerWrap &p);
|
||||
+116
-14
@@ -31,6 +31,10 @@
|
||||
#include "../FileSystems/ISOFileSystem.h"
|
||||
#include "../FileSystems/DirectoryFileSystem.h"
|
||||
|
||||
extern "C" {
|
||||
#include "ext/libkirk/amctrl.h"
|
||||
};
|
||||
|
||||
#include "sceIo.h"
|
||||
#include "sceRtc.h"
|
||||
#include "sceKernel.h"
|
||||
@@ -76,6 +80,7 @@ umd01: block access - umd
|
||||
#define O_CREAT 0x0200
|
||||
#define O_TRUNC 0x0400
|
||||
#define O_NOWAIT 0x8000
|
||||
#define O_NPDRM 0x40000000
|
||||
|
||||
|
||||
typedef s32 SceMode;
|
||||
@@ -168,8 +173,17 @@ public:
|
||||
|
||||
PSPFileInfo info;
|
||||
u32 openMode;
|
||||
|
||||
u32 npdrm;
|
||||
PGD_DESC *pgdInfo;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
static void TellFsThreadEnded (SceUID threadID) {
|
||||
pspFileSystem.ThreadEnded(threadID);
|
||||
}
|
||||
@@ -183,7 +197,7 @@ void __IoInit() {
|
||||
|
||||
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT];
|
||||
char memstickpath[_MAX_PATH];
|
||||
char flashpath[_MAX_PATH];
|
||||
char flash0path[_MAX_PATH];
|
||||
|
||||
GetModuleFileName(NULL,path_buffer,sizeof(path_buffer));
|
||||
|
||||
@@ -196,24 +210,25 @@ void __IoInit() {
|
||||
|
||||
// Mount a couple of filesystems
|
||||
sprintf(memstickpath, "%s%sMemStick\\", drive, dir);
|
||||
sprintf(flashpath, "%s%sFlash\\", drive, dir);
|
||||
sprintf(flash0path, "%s%sflash0\\", drive, dir);
|
||||
|
||||
#else
|
||||
// TODO
|
||||
std::string memstickpath = g_Config.memCardDirectory;
|
||||
std::string flashpath = g_Config.flashDirectory;
|
||||
std::string flash0path = g_Config.flashDirectory;
|
||||
#endif
|
||||
|
||||
DirectoryFileSystem *memstick;
|
||||
DirectoryFileSystem *flash;
|
||||
|
||||
memstick = new DirectoryFileSystem(&pspFileSystem, memstickpath);
|
||||
flash = new DirectoryFileSystem(&pspFileSystem, flashpath);
|
||||
DirectoryFileSystem *memstick = new DirectoryFileSystem(&pspFileSystem, memstickpath);
|
||||
#ifdef ANDROID
|
||||
VFSFileSystem *flash0 = new VFSFileSystem(&pspFileSystem, "flash0");
|
||||
#else
|
||||
DirectoryFileSystem *flash0 = new DirectoryFileSystem(&pspFileSystem, flash0path);
|
||||
#endif
|
||||
pspFileSystem.Mount("ms0:", memstick);
|
||||
pspFileSystem.Mount("fatms0:", memstick);
|
||||
pspFileSystem.Mount("fatms:", memstick);
|
||||
pspFileSystem.Mount("flash0:", flash);
|
||||
pspFileSystem.Mount("flash1:", flash);
|
||||
pspFileSystem.Mount("flash0:", flash0);
|
||||
|
||||
__KernelListenThreadEnd(&TellFsThreadEnded);
|
||||
}
|
||||
@@ -342,6 +357,42 @@ u32 sceIoGetstat(const char *filename, u32 addr) {
|
||||
}
|
||||
}
|
||||
|
||||
u32 npdrmRead(FileNode *f, u8 *data, int size) {
|
||||
PGD_DESC *pgd = f->pgdInfo;
|
||||
u32 block, offset;
|
||||
u32 remain_size, copy_size;
|
||||
|
||||
block = pgd->file_offset/pgd->block_size;
|
||||
offset = pgd->file_offset%pgd->block_size;
|
||||
|
||||
remain_size = size;
|
||||
|
||||
while(remain_size){
|
||||
|
||||
if(pgd->current_block!=block){
|
||||
pspFileSystem.ReadFile(f->handle, pgd->block_buf, pgd->block_size);
|
||||
pgd_decrypt_block(pgd, block);
|
||||
pgd->current_block = block;
|
||||
}
|
||||
|
||||
if(offset+remain_size>pgd->block_size){
|
||||
copy_size = pgd->block_size-offset;
|
||||
block += 1;
|
||||
offset = 0;
|
||||
}else{
|
||||
copy_size = remain_size;
|
||||
}
|
||||
|
||||
memcpy(data, pgd->block_buf+offset, copy_size);
|
||||
|
||||
data += copy_size;
|
||||
remain_size -= copy_size;
|
||||
pgd->file_offset += copy_size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
//Not sure about wrapping it or not, since the log seems to take the address of the data var
|
||||
u32 sceIoRead(int id, u32 data_addr, int size) {
|
||||
if (id == 3) {
|
||||
@@ -358,7 +409,11 @@ u32 sceIoRead(int id, u32 data_addr, int size) {
|
||||
}
|
||||
else if (Memory::IsValidAddress(data_addr)) {
|
||||
u8 *data = (u8*) Memory::GetPointer(data_addr);
|
||||
f->asyncResult = (u32) pspFileSystem.ReadFile(f->handle, data, size);
|
||||
if(f->npdrm){
|
||||
f->asyncResult = (u32) npdrmRead(f, data, size);
|
||||
}else{
|
||||
f->asyncResult = (u32) pspFileSystem.ReadFile(f->handle, data, size);
|
||||
}
|
||||
DEBUG_LOG(HLE, "%i=sceIoRead(%d, %08x , %i)", f->asyncResult, id, data_addr, size);
|
||||
return f->asyncResult;
|
||||
} else {
|
||||
@@ -445,6 +500,26 @@ u32 sceIoCancel(int id)
|
||||
return error;
|
||||
}
|
||||
|
||||
u32 npdrmLseek(FileNode *f, s32 where, FileMove whence)
|
||||
{
|
||||
u32 newPos;
|
||||
|
||||
if(whence==FILEMOVE_BEGIN){
|
||||
newPos = where;
|
||||
}else if(whence==FILEMOVE_CURRENT){
|
||||
newPos = f->pgdInfo->file_offset+where;
|
||||
}else{
|
||||
newPos = f->pgdInfo->data_size+where;
|
||||
}
|
||||
|
||||
if(newPos<0 || newPos>f->pgdInfo->data_size){
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
f->pgdInfo->file_offset = newPos;
|
||||
return newPos;
|
||||
}
|
||||
|
||||
s64 sceIoLseek(int id, s64 offset, int whence) {
|
||||
u32 error;
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
@@ -468,7 +543,11 @@ s64 sceIoLseek(int id, s64 offset, int whence) {
|
||||
if(newPos < 0)
|
||||
return -1;
|
||||
|
||||
f->asyncResult = (u32) pspFileSystem.SeekFile(f->handle, (s32) offset, seek);
|
||||
if(f->npdrm){
|
||||
f->asyncResult = npdrmLseek(f, (s32)offset, seek);
|
||||
}else{
|
||||
f->asyncResult = (u32) pspFileSystem.SeekFile(f->handle, (s32) offset, seek);
|
||||
}
|
||||
DEBUG_LOG(HLE, "%i = sceIoLseek(%d,%i,%i)", f->asyncResult, id, (int) offset, whence);
|
||||
return f->asyncResult;
|
||||
} else {
|
||||
@@ -500,7 +579,11 @@ u32 sceIoLseek32(int id, int offset, int whence) {
|
||||
if(newPos < 0)
|
||||
return -1;
|
||||
|
||||
f->asyncResult = (u32) pspFileSystem.SeekFile(f->handle, (s32) offset, seek);
|
||||
if(f->npdrm){
|
||||
f->asyncResult = npdrmLseek(f, (s32)offset, seek);
|
||||
}else{
|
||||
f->asyncResult = (u32) pspFileSystem.SeekFile(f->handle, (s32) offset, seek);
|
||||
}
|
||||
DEBUG_LOG(HLE, "%i = sceIoLseek32(%d,%i,%i)", f->asyncResult, id, (int) offset, whence);
|
||||
return f->asyncResult;
|
||||
} else {
|
||||
@@ -520,6 +603,8 @@ u32 sceIoOpen(const char* filename, int flags, int mode) {
|
||||
access |= FILEACCESS_APPEND;
|
||||
if (flags & O_CREAT)
|
||||
access |= FILEACCESS_CREATE;
|
||||
if (flags & O_NPDRM)
|
||||
|
||||
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
|
||||
u32 h = pspFileSystem.OpenFile(filename, (FileAccess) access);
|
||||
@@ -535,14 +620,22 @@ u32 sceIoOpen(const char* filename, int flags, int mode) {
|
||||
f->handle = h;
|
||||
f->fullpath = filename;
|
||||
f->asyncResult = id;
|
||||
f->info = info;
|
||||
f->info = pspFileSystem.GetFileInfo(filename);
|
||||
f->openMode = access;
|
||||
|
||||
f->npdrm = (flags & O_NPDRM)? true: false;
|
||||
|
||||
DEBUG_LOG(HLE, "%i=sceIoOpen(%s, %08x, %08x)", id, filename, flags, mode);
|
||||
return id;
|
||||
}
|
||||
|
||||
u32 sceIoClose(int id) {
|
||||
u32 error;
|
||||
DEBUG_LOG(HLE, "sceIoClose(%d)", id);
|
||||
FileNode *f = kernelObjects.Get < FileNode > (id, error);
|
||||
if(f && f->npdrm){
|
||||
pgd_close(f->pgdInfo);
|
||||
}
|
||||
return kernelObjects.Destroy < FileNode > (id);
|
||||
}
|
||||
|
||||
@@ -1091,8 +1184,17 @@ u32 sceIoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 ou
|
||||
case 0x04100001:
|
||||
if (Memory::IsValidAddress(indataPtr) && inlen == 16) {
|
||||
u8 keybuf[16];
|
||||
u8 pgd_header[0x90];
|
||||
INFO_LOG(HLE, "Decrypting PGD DRM files");
|
||||
memcpy(keybuf, Memory::GetPointer(indataPtr), 16);
|
||||
ERROR_LOG(HLE, "PGD DRM not yet supported, sorry.");
|
||||
pspFileSystem.ReadFile(f->handle, pgd_header, 0x90);
|
||||
f->pgdInfo = pgd_open(pgd_header, 2, keybuf);
|
||||
if(f->pgdInfo==NULL){
|
||||
DEBUG_LOG(HLE, "Not a valid PGD file. Open as normal file.");
|
||||
f->npdrm = false;
|
||||
pspFileSystem.SeekFile(f->handle, (s32)0, FILEMOVE_BEGIN);
|
||||
}
|
||||
f->asyncResult = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+32
-27
@@ -60,6 +60,7 @@
|
||||
#include "scePsmf.h"
|
||||
#include "sceImpose.h"
|
||||
#include "sceUsb.h"
|
||||
#include "scePspNpDrm_user.h"
|
||||
|
||||
#include "../Util/PPGeDraw.h"
|
||||
|
||||
@@ -127,6 +128,8 @@ void __KernelShutdown()
|
||||
INFO_LOG(HLE, "Shutting down kernel - %i kernel objects alive", kernelObjects.GetCount());
|
||||
kernelObjects.Clear();
|
||||
|
||||
__FontShutdown();
|
||||
|
||||
__MpegShutdown();
|
||||
__PsmfShutdown();
|
||||
__PPGeShutdown();
|
||||
@@ -539,35 +542,37 @@ u32 sceKernelReferGlobalProfiler(u32 statusPtr) {
|
||||
|
||||
const HLEFunction ThreadManForUser[] =
|
||||
{
|
||||
{0x55C20A00,&WrapI_CUUU<sceKernelCreateEventFlag>, "sceKernelCreateEventFlag"},
|
||||
{0x812346E4,&WrapU_IU<sceKernelClearEventFlag>, "sceKernelClearEventFlag"},
|
||||
{0xEF9E4C70,&WrapU_I<sceKernelDeleteEventFlag>, "sceKernelDeleteEventFlag"},
|
||||
{0x1fb15a32,&WrapU_IU<sceKernelSetEventFlag>, "sceKernelSetEventFlag"},
|
||||
{0x402FCF22,&WrapI_IUUUU<sceKernelWaitEventFlag>, "sceKernelWaitEventFlag"},
|
||||
{0x328C546A,&WrapI_IUUUU<sceKernelWaitEventFlagCB>, "sceKernelWaitEventFlagCB"},
|
||||
{0x30FD48F0,&WrapI_IUUUU<sceKernelPollEventFlag>, "sceKernelPollEventFlag"},
|
||||
{0xCD203292,&WrapU_IUU<sceKernelCancelEventFlag>, "sceKernelCancelEventFlag"},
|
||||
{0xA66B0120,&WrapU_IU<sceKernelReferEventFlagStatus>, "sceKernelReferEventFlagStatus"},
|
||||
{0x55C20A00,&WrapI_CUUU<sceKernelCreateEventFlag>, "sceKernelCreateEventFlag"},
|
||||
{0x812346E4,&WrapU_IU<sceKernelClearEventFlag>, "sceKernelClearEventFlag"},
|
||||
{0xEF9E4C70,&WrapU_I<sceKernelDeleteEventFlag>, "sceKernelDeleteEventFlag"},
|
||||
{0x1fb15a32,&WrapU_IU<sceKernelSetEventFlag>, "sceKernelSetEventFlag"},
|
||||
{0x402FCF22,&WrapI_IUUUU<sceKernelWaitEventFlag>, "sceKernelWaitEventFlag"},
|
||||
{0x328C546A,&WrapI_IUUUU<sceKernelWaitEventFlagCB>, "sceKernelWaitEventFlagCB"},
|
||||
{0x30FD48F0,&WrapI_IUUUU<sceKernelPollEventFlag>, "sceKernelPollEventFlag"},
|
||||
{0xCD203292,&WrapU_IUU<sceKernelCancelEventFlag>, "sceKernelCancelEventFlag"},
|
||||
{0xA66B0120,&WrapU_IU<sceKernelReferEventFlagStatus>, "sceKernelReferEventFlagStatus"},
|
||||
|
||||
{0x8FFDF9A2,&WrapI_IIU<sceKernelCancelSema>, "sceKernelCancelSema"},
|
||||
{0xD6DA4BA1,&WrapI_CUIIU<sceKernelCreateSema>, "sceKernelCreateSema"},
|
||||
{0x28b6489c,&WrapI_I<sceKernelDeleteSema>, "sceKernelDeleteSema"},
|
||||
{0x58b1f937,&WrapI_II<sceKernelPollSema>, "sceKernelPollSema"},
|
||||
{0xBC6FEBC5,&WrapI_IU<sceKernelReferSemaStatus>, "sceKernelReferSemaStatus"},
|
||||
{0x3F53E640,&WrapI_II<sceKernelSignalSema>, "sceKernelSignalSema"},
|
||||
{0x4E3A1105,&WrapI_IIU<sceKernelWaitSema>, "sceKernelWaitSema"},
|
||||
{0x6d212bac,&WrapI_IIU<sceKernelWaitSemaCB>, "sceKernelWaitSemaCB"},
|
||||
{0x8FFDF9A2,&WrapI_IIU<sceKernelCancelSema>, "sceKernelCancelSema"},
|
||||
{0xD6DA4BA1,&WrapI_CUIIU<sceKernelCreateSema>, "sceKernelCreateSema"},
|
||||
{0x28b6489c,&WrapI_I<sceKernelDeleteSema>, "sceKernelDeleteSema"},
|
||||
{0x58b1f937,&WrapI_II<sceKernelPollSema>, "sceKernelPollSema"},
|
||||
{0xBC6FEBC5,&WrapI_IU<sceKernelReferSemaStatus>, "sceKernelReferSemaStatus"},
|
||||
{0x3F53E640,&WrapI_II<sceKernelSignalSema>, "sceKernelSignalSema"},
|
||||
{0x4E3A1105,&WrapI_IIU<sceKernelWaitSema>, "sceKernelWaitSema"},
|
||||
{0x6d212bac,&WrapI_IIU<sceKernelWaitSemaCB>, "sceKernelWaitSemaCB"},
|
||||
|
||||
{0x60107536,&WrapI_U<sceKernelDeleteLwMutex>, "sceKernelDeleteLwMutex"},
|
||||
{0x19CFF145,&WrapI_UCUIU<sceKernelCreateLwMutex>, "sceKernelCreateLwMutex"},
|
||||
{0xf8170fbe,&WrapI_I<sceKernelDeleteMutex>, "sceKernelDeleteMutex"},
|
||||
{0xB011B11F,&WrapI_IIU<sceKernelLockMutex>, "sceKernelLockMutex"},
|
||||
{0x5bf4dd27,&WrapI_IIU<sceKernelLockMutexCB>, "sceKernelLockMutexCB"},
|
||||
{0x6b30100f,&WrapI_II<sceKernelUnlockMutex>, "sceKernelUnlockMutex"},
|
||||
{0xb7d098c6,&WrapI_CUIU<sceKernelCreateMutex>, "sceKernelCreateMutex"},
|
||||
{0x0DDCD2C9,&WrapI_II<sceKernelTryLockMutex>, "sceKernelTryLockMutex"},
|
||||
{0xA9C2CB9A,&WrapI_IU<sceKernelReferMutexStatus>, "sceKernelReferMutexStatus"},
|
||||
// NOTE: LockLwMutex and UnlockLwMutex are in Kernel_Library, see sceKernelInterrupt.cpp.
|
||||
{0x60107536,&WrapI_U<sceKernelDeleteLwMutex>, "sceKernelDeleteLwMutex"},
|
||||
{0x19CFF145,&WrapI_UCUIU<sceKernelCreateLwMutex>, "sceKernelCreateLwMutex"},
|
||||
{0x4C145944,&WrapI_IU<sceKernelReferLwMutexStatusByID>, "sceKernelReferLwMutexStatusByID"},
|
||||
// NOTE: LockLwMutex, UnlockLwMutex, and ReferLwMutexStatus are in Kernel_Library, see sceKernelInterrupt.cpp.
|
||||
|
||||
{0xf8170fbe,&WrapI_I<sceKernelDeleteMutex>, "sceKernelDeleteMutex"},
|
||||
{0xB011B11F,&WrapI_IIU<sceKernelLockMutex>, "sceKernelLockMutex"},
|
||||
{0x5bf4dd27,&WrapI_IIU<sceKernelLockMutexCB>, "sceKernelLockMutexCB"},
|
||||
{0x6b30100f,&WrapI_II<sceKernelUnlockMutex>, "sceKernelUnlockMutex"},
|
||||
{0xb7d098c6,&WrapI_CUIU<sceKernelCreateMutex>, "sceKernelCreateMutex"},
|
||||
{0x0DDCD2C9,&WrapI_II<sceKernelTryLockMutex>, "sceKernelTryLockMutex"},
|
||||
{0xA9C2CB9A,&WrapI_IU<sceKernelReferMutexStatus>, "sceKernelReferMutexStatus"},
|
||||
|
||||
{0xFCCFAD26,sceKernelCancelWakeupThread,"sceKernelCancelWakeupThread"},
|
||||
{0xea748e31,sceKernelChangeCurrentThreadAttr,"sceKernelChangeCurrentThreadAttr"},
|
||||
|
||||
@@ -87,6 +87,7 @@ enum
|
||||
SCE_KERNEL_ERROR_ILLEGAL_CHUNK_ID = 0x800200de,
|
||||
SCE_KERNEL_ERROR_NOCHUNK = 0x800200df,
|
||||
SCE_KERNEL_ERROR_NO_FREECHUNK = 0x800200e0,
|
||||
SCE_ERROR_KERNEL_ILLEGAL_ALIGNMENT_SIZE = 0x800200e4,
|
||||
SCE_KERNEL_ERROR_LINKERR = 0x8002012c,
|
||||
SCE_KERNEL_ERROR_ILLEGAL_OBJECT = 0x8002012d,
|
||||
SCE_KERNEL_ERROR_UNKNOWN_MODULE = 0x8002012e,
|
||||
|
||||
@@ -213,7 +213,7 @@ void __InterruptsInit()
|
||||
{
|
||||
interruptsEnabled = 1;
|
||||
inInterrupt = false;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(intrHandlers); ++i)
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(intrHandlers); ++i)
|
||||
intrHandlers[i] = new IntrHandler(i);
|
||||
intState.clear();
|
||||
}
|
||||
@@ -553,6 +553,7 @@ const HLEFunction Kernel_Library[] =
|
||||
{0xbea46419,WrapI_UIU<sceKernelLockLwMutex>, "sceKernelLockLwMutex"},
|
||||
{0x1FC64E09,WrapI_UIU<sceKernelLockLwMutexCB>, "sceKernelLockLwMutexCB"},
|
||||
{0x15b6446b,WrapI_UI<sceKernelUnlockLwMutex>, "sceKernelUnlockLwMutex"},
|
||||
{0xc1734599,WrapI_UU<sceKernelReferLwMutexStatus>, "sceKernelReferLwMutexStatus"},
|
||||
{0x293b45b8,sceKernelGetThreadId, "sceKernelGetThreadId"},
|
||||
{0x1839852A,WrapU_UUU<sceKernelMemcpy>,"sce_paf_private_memcpy"},
|
||||
};
|
||||
|
||||
@@ -390,6 +390,14 @@ void sceKernelReferFplStatus()
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//00:49:12 <TyRaNiD> ector, well the partitions are 1 = kernel, 2 = user, 3 = me, 4 = kernel mirror :)
|
||||
|
||||
enum MemblockType
|
||||
{
|
||||
PSP_SMEM_Low = 0,
|
||||
PSP_SMEM_High = 1,
|
||||
PSP_SMEM_Addr = 2,
|
||||
PSP_SMEM_LowAligned = 3,
|
||||
PSP_SMEM_HighAligned = 4,
|
||||
};
|
||||
|
||||
class PartitionMemoryBlock : public KernelObject
|
||||
{
|
||||
@@ -401,23 +409,34 @@ public:
|
||||
int sz = alloc->GetBlockSizeFromAddress(address);
|
||||
sprintf(ptr, "MemPart: %08x - %08x size: %08x", address, address + sz, sz);
|
||||
}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_MPPID; } /// ????
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_UID; }
|
||||
int GetIDType() const { return PPSSPP_KERNEL_TMID_PMB; }
|
||||
|
||||
PartitionMemoryBlock(BlockAllocator *_alloc, u32 size, bool fromEnd)
|
||||
PartitionMemoryBlock(BlockAllocator *_alloc, const char *_name, u32 size, MemblockType type, u32 alignment)
|
||||
{
|
||||
alloc = _alloc;
|
||||
strncpy(name, _name, 32);
|
||||
name[31] = '\0';
|
||||
|
||||
// 0 is used for save states to wake up.
|
||||
if (size != 0)
|
||||
{
|
||||
address = alloc->Alloc(size, fromEnd, "PMB");
|
||||
if (type == PSP_SMEM_Addr)
|
||||
{
|
||||
alignment &= ~0xFF;
|
||||
address = alloc->AllocAt(alignment, size, name);
|
||||
}
|
||||
else if (type == PSP_SMEM_LowAligned || type == PSP_SMEM_HighAligned)
|
||||
address = alloc->AllocAligned(size, alignment, type == PSP_SMEM_HighAligned, name);
|
||||
else
|
||||
address = alloc->Alloc(size, type == PSP_SMEM_High, name);
|
||||
alloc->ListBlocks();
|
||||
}
|
||||
}
|
||||
~PartitionMemoryBlock()
|
||||
{
|
||||
alloc->Free(address);
|
||||
if (address != (u32)-1)
|
||||
alloc->Free(address);
|
||||
}
|
||||
bool IsValid() {return address != (u32)-1;}
|
||||
BlockAllocator *alloc;
|
||||
@@ -449,54 +468,78 @@ void sceKernelTotalFreeMemSize()
|
||||
RETURN(retVal);
|
||||
}
|
||||
|
||||
void sceKernelAllocPartitionMemory()
|
||||
int sceKernelAllocPartitionMemory(int partition, const char *name, int type, u32 size, u32 addr)
|
||||
{
|
||||
int partid = PARAM(0);
|
||||
const char *name = Memory::GetCharPointer(PARAM(1));
|
||||
int type = PARAM(2);
|
||||
u32 size = PARAM(3);
|
||||
int addr = PARAM(4); //only if type includes ADDR
|
||||
if (name == NULL)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelAllocPartitionMemory(): invalid name", SCE_KERNEL_ERROR_ERROR);
|
||||
return SCE_KERNEL_ERROR_ERROR;
|
||||
}
|
||||
if (size == 0)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelAllocPartitionMemory(): invalid size %x", SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED, size);
|
||||
return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED;
|
||||
}
|
||||
if (partition < 1 || partition > 9 || partition == 7)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelAllocPartitionMemory(): invalid partition %x", SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT, partition);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT;
|
||||
}
|
||||
// We only support user right now.
|
||||
if (partition != 2 && partition != 5 && partition != 6)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelAllocPartitionMemory(): invalid partition %x", SCE_KERNEL_ERROR_ILLEGAL_PARTITION, partition);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_PARTITION;
|
||||
}
|
||||
if (type < PSP_SMEM_Low || type > PSP_SMEM_HighAligned)
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelAllocPartitionMemory(): invalid type %x", SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE, type);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE;
|
||||
}
|
||||
// Alignment is only allowed for powers of 2.
|
||||
if ((type == PSP_SMEM_LowAligned || type == PSP_SMEM_HighAligned) && ((addr & (addr - 1)) != 0 || addr == 0))
|
||||
{
|
||||
WARN_LOG(HLE, "%08x=sceKernelAllocPartitionMemory(): invalid alignment %x", SCE_ERROR_KERNEL_ILLEGAL_ALIGNMENT_SIZE, addr);
|
||||
return SCE_ERROR_KERNEL_ILLEGAL_ALIGNMENT_SIZE;
|
||||
}
|
||||
|
||||
PartitionMemoryBlock *block = new PartitionMemoryBlock(&userMemory, size, type==1);
|
||||
PartitionMemoryBlock *block = new PartitionMemoryBlock(&userMemory, name, size, (MemblockType)type, addr);
|
||||
if (!block->IsValid())
|
||||
{
|
||||
delete block;
|
||||
ERROR_LOG(HLE, "ARGH! sceKernelAllocPartitionMemory failed");
|
||||
RETURN(-1);
|
||||
return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED;
|
||||
}
|
||||
SceUID uid = kernelObjects.Create(block);
|
||||
strncpy(block->name, name, 32);
|
||||
|
||||
DEBUG_LOG(HLE,"%i = sceKernelAllocPartitionMemory(partition = %i, %s, type= %i, size= %i, addr= %08x)",
|
||||
uid, partid,name,type,size,addr);
|
||||
uid, partition, name, type, size, addr);
|
||||
if (type == 2)
|
||||
ERROR_LOG(HLE, "ARGH! sceKernelAllocPartitionMemory wants a specific address");
|
||||
|
||||
RETURN(uid); //for now
|
||||
return uid;
|
||||
}
|
||||
|
||||
void sceKernelFreePartitionMemory()
|
||||
int sceKernelFreePartitionMemory(SceUID id)
|
||||
{
|
||||
SceUID id = PARAM(0);
|
||||
DEBUG_LOG(HLE,"sceKernelFreePartitionMemory(%d)",id);
|
||||
|
||||
RETURN(kernelObjects.Destroy<PartitionMemoryBlock>(id));
|
||||
return kernelObjects.Destroy<PartitionMemoryBlock>(id);
|
||||
}
|
||||
|
||||
void sceKernelGetBlockHeadAddr()
|
||||
u32 sceKernelGetBlockHeadAddr(SceUID id)
|
||||
{
|
||||
SceUID id = PARAM(0);
|
||||
|
||||
u32 error;
|
||||
PartitionMemoryBlock *block = kernelObjects.Get<PartitionMemoryBlock>(id, error);
|
||||
if (block)
|
||||
{
|
||||
DEBUG_LOG(HLE,"%08x = sceKernelGetBlockHeadAddr(%i)", block->address, id);
|
||||
RETURN(block->address);
|
||||
return block->address;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE,"sceKernelGetBlockHeadAddr failed(%i)", id);
|
||||
RETURN(error);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +762,7 @@ KernelObject *__KernelMemoryVPLObject()
|
||||
KernelObject *__KernelMemoryPMBObject()
|
||||
{
|
||||
// TODO: We could theoretically handle kernelMemory too, but we don't support that now anyway.
|
||||
return new PartitionMemoryBlock(&userMemory, 0, true);
|
||||
return new PartitionMemoryBlock(&userMemory, "", 0, PSP_SMEM_Low, 0);
|
||||
}
|
||||
|
||||
// VPL = variable length memory pool
|
||||
@@ -1135,9 +1178,9 @@ const HLEFunction SysMemUserForUser[] = {
|
||||
{0xA291F107,sceKernelMaxFreeMemSize,"sceKernelMaxFreeMemSize"},
|
||||
{0xF919F628,sceKernelTotalFreeMemSize,"sceKernelTotalFreeMemSize"},
|
||||
{0x3FC9AE6A,WrapU_V<sceKernelDevkitVersion>,"sceKernelDevkitVersion"},
|
||||
{0x237DBD4F,sceKernelAllocPartitionMemory,"sceKernelAllocPartitionMemory"}, //(int size) ?
|
||||
{0xB6D61D02,sceKernelFreePartitionMemory,"sceKernelFreePartitionMemory"}, //(void *ptr) ?
|
||||
{0x9D9A5BA1,sceKernelGetBlockHeadAddr,"sceKernelGetBlockHeadAddr"}, //(void *ptr) ?
|
||||
{0x237DBD4F,WrapI_ICIUU<sceKernelAllocPartitionMemory>,"sceKernelAllocPartitionMemory"}, //(int size) ?
|
||||
{0xB6D61D02,WrapI_I<sceKernelFreePartitionMemory>,"sceKernelFreePartitionMemory"}, //(void *ptr) ?
|
||||
{0x9D9A5BA1,WrapU_I<sceKernelGetBlockHeadAddr>,"sceKernelGetBlockHeadAddr"}, //(void *ptr) ?
|
||||
{0x13a5abef,sceKernelPrintf,"sceKernelPrintf 0x13a5abef"},
|
||||
{0x7591c7db,&WrapV_I<sceKernelSetCompiledSdkVersion>,"sceKernelSetCompiledSdkVersion"},
|
||||
{0x342061E5,&WrapV_I<sceKernelSetCompiledSdkVersion370>,"sceKernelSetCompiledSdkVersion370"},
|
||||
|
||||
+112
-36
@@ -46,7 +46,6 @@
|
||||
#define PSP_LWMUTEX_ERROR_UNLOCK_UNDERFLOW 0x800201CE
|
||||
#define PSP_LWMUTEX_ERROR_ALREADY_LOCKED 0x800201CF
|
||||
|
||||
// Guesswork - not exposed anyway
|
||||
struct NativeMutex
|
||||
{
|
||||
SceSize size;
|
||||
@@ -54,6 +53,8 @@ struct NativeMutex
|
||||
SceUInt attr;
|
||||
int initialCount;
|
||||
int lockLevel;
|
||||
SceUID lockThread;
|
||||
// Not kept up to date.
|
||||
int numWaitThreads;
|
||||
};
|
||||
|
||||
@@ -69,22 +70,28 @@ struct Mutex : public KernelObject
|
||||
p.Do(nm);
|
||||
SceUID dv = 0;
|
||||
p.Do(waitingThreads, dv);
|
||||
p.Do(lockThread);
|
||||
p.DoMarker("Mutex");
|
||||
}
|
||||
|
||||
NativeMutex nm;
|
||||
std::vector<SceUID> waitingThreads;
|
||||
int lockThread; // The thread holding the lock
|
||||
};
|
||||
|
||||
// Guesswork - not exposed anyway
|
||||
|
||||
struct NativeLwMutex
|
||||
{
|
||||
SceSize size;
|
||||
char name[KERNELOBJECT_MAX_NAME_LENGTH + 1];
|
||||
SceUInt attr;
|
||||
SceUInt workareaPtr;
|
||||
SceUID uid;
|
||||
u32 workareaPtr;
|
||||
int initialCount;
|
||||
// Not kept up to date.
|
||||
int currentCount;
|
||||
// Not kept up to date.
|
||||
SceUID lockThread;
|
||||
// Not kept up to date.
|
||||
int numWaitThreads;
|
||||
};
|
||||
|
||||
struct NativeLwMutexWorkarea
|
||||
@@ -178,7 +185,7 @@ void __KernelMutexAcquireLock(Mutex *mutex, int count, SceUID thread)
|
||||
mutexHeldLocks.insert(std::make_pair(thread, mutex->GetUID()));
|
||||
|
||||
mutex->nm.lockLevel = count;
|
||||
mutex->lockThread = thread;
|
||||
mutex->nm.lockThread = thread;
|
||||
}
|
||||
|
||||
void __KernelMutexAcquireLock(Mutex *mutex, int count)
|
||||
@@ -188,10 +195,10 @@ void __KernelMutexAcquireLock(Mutex *mutex, int count)
|
||||
|
||||
void __KernelMutexEraseLock(Mutex *mutex)
|
||||
{
|
||||
if (mutex->lockThread != -1)
|
||||
if (mutex->nm.lockThread != -1)
|
||||
{
|
||||
SceUID id = mutex->GetUID();
|
||||
std::pair<MutexMap::iterator, MutexMap::iterator> locked = mutexHeldLocks.equal_range(mutex->lockThread);
|
||||
std::pair<MutexMap::iterator, MutexMap::iterator> locked = mutexHeldLocks.equal_range(mutex->nm.lockThread);
|
||||
for (MutexMap::iterator iter = locked.first; iter != locked.second; ++iter)
|
||||
{
|
||||
if ((*iter).second == id)
|
||||
@@ -201,7 +208,7 @@ void __KernelMutexEraseLock(Mutex *mutex)
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex->lockThread = -1;
|
||||
mutex->nm.lockThread = -1;
|
||||
}
|
||||
|
||||
std::vector<SceUID>::iterator __KernelMutexFindPriority(std::vector<SceUID> &waiting)
|
||||
@@ -245,7 +252,7 @@ int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optio
|
||||
Mutex *mutex = new Mutex();
|
||||
SceUID id = kernelObjects.Create(mutex);
|
||||
|
||||
mutex->nm.size = sizeof(mutex);
|
||||
mutex->nm.size = sizeof(mutex->nm);
|
||||
strncpy(mutex->nm.name, name, KERNELOBJECT_MAX_NAME_LENGTH);
|
||||
mutex->nm.name[KERNELOBJECT_MAX_NAME_LENGTH] = 0;
|
||||
mutex->nm.attr = attr;
|
||||
@@ -253,7 +260,7 @@ int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optio
|
||||
if (initialCount == 0)
|
||||
{
|
||||
mutex->nm.lockLevel = 0;
|
||||
mutex->lockThread = -1;
|
||||
mutex->nm.lockThread = -1;
|
||||
}
|
||||
else
|
||||
__KernelMutexAcquireLock(mutex, initialCount);
|
||||
@@ -307,7 +314,7 @@ int sceKernelDeleteMutex(SceUID id)
|
||||
for (iter = mutex->waitingThreads.begin(), end = mutex->waitingThreads.end(); iter != end; ++iter)
|
||||
wokeThreads |= __KernelUnlockMutexForThread(mutex, *iter, error, SCE_KERNEL_ERROR_WAIT_DELETE);
|
||||
|
||||
if (mutex->lockThread != -1)
|
||||
if (mutex->nm.lockThread != -1)
|
||||
__KernelMutexEraseLock(mutex);
|
||||
mutex->waitingThreads.clear();
|
||||
|
||||
@@ -343,7 +350,7 @@ bool __KernelLockMutex(Mutex *mutex, int count, u32 &error)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mutex->lockThread == __KernelGetCurThread())
|
||||
if (mutex->nm.lockThread == __KernelGetCurThread())
|
||||
{
|
||||
// Recursive mutex, let's just increase the lock count and keep going
|
||||
if (mutex->nm.attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE)
|
||||
@@ -379,7 +386,7 @@ bool __KernelUnlockMutex(Mutex *mutex, u32 &error)
|
||||
}
|
||||
|
||||
if (!wokeThreads)
|
||||
mutex->lockThread = -1;
|
||||
mutex->nm.lockThread = -1;
|
||||
|
||||
return wokeThreads;
|
||||
}
|
||||
@@ -528,7 +535,7 @@ int sceKernelUnlockMutex(SceUID id, int count)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
if ((mutex->nm.attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && count > 1)
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_COUNT;
|
||||
if (mutex->nm.lockLevel == 0 || mutex->lockThread != __KernelGetCurThread())
|
||||
if (mutex->nm.lockLevel == 0 || mutex->nm.lockThread != __KernelGetCurThread())
|
||||
return PSP_MUTEX_ERROR_NOT_LOCKED;
|
||||
if (mutex->nm.lockLevel < count)
|
||||
return PSP_MUTEX_ERROR_UNLOCK_UNDERFLOW;
|
||||
@@ -544,6 +551,32 @@ int sceKernelUnlockMutex(SceUID id, int count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelReferMutexStatus(SceUID id, u32 infoAddr)
|
||||
{
|
||||
u32 error;
|
||||
Mutex *m = kernelObjects.Get<Mutex>(id, error);
|
||||
if (!m)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceKernelReferMutexStatus(%i, %08x): invalid mutex id", id, infoAddr);
|
||||
return error;
|
||||
}
|
||||
|
||||
DEBUG_LOG(HLE, "sceKernelReferMutexStatus(%08x, %08x)", id, infoAddr);
|
||||
|
||||
// Should we crash the thread somehow?
|
||||
if (!Memory::IsValidAddress(infoAddr))
|
||||
return -1;
|
||||
|
||||
// Don't write if the size is 0. Anything else is A-OK, though, apparently.
|
||||
if (Memory::Read_U32(infoAddr) != 0)
|
||||
{
|
||||
// Refresh and write
|
||||
m->nm.numWaitThreads = m->waitingThreads.size();
|
||||
Memory::WriteStruct(infoAddr, &m->nm);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int initialCount, u32 optionsPtr)
|
||||
{
|
||||
if (!name)
|
||||
@@ -564,11 +597,13 @@ int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int init
|
||||
|
||||
LwMutex *mutex = new LwMutex();
|
||||
SceUID id = kernelObjects.Create(mutex);
|
||||
mutex->nm.size = sizeof(mutex);
|
||||
mutex->nm.size = sizeof(mutex->nm);
|
||||
strncpy(mutex->nm.name, name, KERNELOBJECT_MAX_NAME_LENGTH);
|
||||
mutex->nm.name[KERNELOBJECT_MAX_NAME_LENGTH] = 0;
|
||||
mutex->nm.attr = attr;
|
||||
mutex->nm.uid = id;
|
||||
mutex->nm.workareaPtr = workareaPtr;
|
||||
mutex->nm.initialCount = initialCount;
|
||||
NativeLwMutexWorkarea workarea;
|
||||
workarea.init();
|
||||
workarea.lockLevel = initialCount;
|
||||
@@ -591,26 +626,6 @@ int sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int init
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelReferMutexStatus(SceUID id, u32 infoAddr)
|
||||
{
|
||||
u32 error;
|
||||
Mutex *m = kernelObjects.Get<Mutex>(id, error);
|
||||
if (!m)
|
||||
{
|
||||
ERROR_LOG(HLE, "sceKernelReferMutexStatus(%i, %08x): invalid mbx id", id, infoAddr);
|
||||
return error;
|
||||
}
|
||||
|
||||
// Should we crash the thread somehow?
|
||||
if (!Memory::IsValidAddress(infoAddr))
|
||||
return -1;
|
||||
|
||||
// Refresh and write
|
||||
m->nm.numWaitThreads = m->waitingThreads.size();
|
||||
Memory::WriteStruct(infoAddr, &m->nm);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __KernelUnlockLwMutexForThread(LwMutex *mutex, NativeLwMutexWorkarea &workarea, SceUID threadID, u32 &error, int result)
|
||||
{
|
||||
SceUID waitID = __KernelGetWaitID(threadID, WAITTYPE_LWMUTEX, error);
|
||||
@@ -925,3 +940,64 @@ int sceKernelUnlockLwMutex(u32 workareaPtr, int count)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __KernelReferLwMutexStatus(SceUID uid, u32 infoPtr)
|
||||
{
|
||||
u32 error;
|
||||
LwMutex *m = kernelObjects.Get<LwMutex>(uid, error);
|
||||
if (!m)
|
||||
return error;
|
||||
|
||||
// Should we crash the thread somehow?
|
||||
if (!Memory::IsValidAddress(infoPtr))
|
||||
return -1;
|
||||
|
||||
if (Memory::Read_U32(infoPtr) != 0)
|
||||
{
|
||||
NativeLwMutexWorkarea workarea;
|
||||
Memory::ReadStruct(m->nm.workareaPtr, &workarea);
|
||||
|
||||
// Refresh and write
|
||||
m->nm.currentCount = workarea.lockLevel;
|
||||
m->nm.lockThread = workarea.lockThread == 0 ? -1 : workarea.lockThread;
|
||||
m->nm.numWaitThreads = m->waitingThreads.size();
|
||||
Memory::WriteStruct(infoPtr, &m->nm);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelReferLwMutexStatusByID(SceUID uid, u32 infoPtr)
|
||||
{
|
||||
int error = __KernelReferLwMutexStatus(uid, infoPtr);
|
||||
if (error >= 0)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelReferLwMutexStatusByID(%08x, %08x)", uid, infoPtr);
|
||||
return error;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE, "%08x=sceKernelReferLwMutexStatusByID(%08x, %08x)", error, uid, infoPtr);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
int sceKernelReferLwMutexStatus(u32 workareaPtr, u32 infoPtr)
|
||||
{
|
||||
if (!Memory::IsValidAddress(workareaPtr))
|
||||
return -1;
|
||||
|
||||
NativeLwMutexWorkarea workarea;
|
||||
Memory::ReadStruct(workareaPtr, &workarea);
|
||||
|
||||
int error = __KernelReferLwMutexStatus(workarea.uid, infoPtr);
|
||||
if (error >= 0)
|
||||
{
|
||||
DEBUG_LOG(HLE, "sceKernelReferLwMutexStatus(%08x, %08x)", workareaPtr, infoPtr);
|
||||
return error;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(HLE, "%08x=sceKernelReferLwMutexStatus(%08x, %08x)", error, workareaPtr, infoPtr);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ int sceKernelTryLockLwMutex_600(u32 workareaPtr, int count);
|
||||
int sceKernelLockLwMutex(u32 workareaPtr, int count, u32 timeoutPtr);
|
||||
int sceKernelLockLwMutexCB(u32 workareaPtr, int count, u32 timeoutPtr);
|
||||
int sceKernelUnlockLwMutex(u32 workareaPtr, int count);
|
||||
int sceKernelReferLwMutexStatusByID(SceUID uid, u32 infoPtr);
|
||||
int sceKernelReferLwMutexStatus(u32 workareaPtr, u32 infoPtr);
|
||||
|
||||
void __KernelMutexTimeout(u64 userdata, int cyclesLate);
|
||||
void __KernelLwMutexTimeout(u64 userdata, int cyclesLate);
|
||||
|
||||
@@ -795,7 +795,7 @@ void __KernelIdle()
|
||||
CoreTiming::Idle();
|
||||
// Advance must happen between Idle and Reschedule, so that threads that were waiting for something
|
||||
// that was triggered at the end of the Idle period must get a chance to be scheduled.
|
||||
CoreTiming::Advance();
|
||||
CoreTiming::AdvanceQuick();
|
||||
|
||||
// We must've exited a callback?
|
||||
if (__KernelInCallback())
|
||||
@@ -1034,6 +1034,9 @@ void __KernelLoadContext(ThreadContext *ctx)
|
||||
currentMIPS->fcr0 = ctx->fcr0;
|
||||
currentMIPS->fcr31 = ctx->fcr31;
|
||||
currentMIPS->fpcond = ctx->fpcond;
|
||||
|
||||
// Reset the llBit, the other thread may have touched memory.
|
||||
currentMIPS->llBit = 0;
|
||||
}
|
||||
|
||||
u32 __KernelResumeThreadFromWait(SceUID threadID)
|
||||
@@ -1213,7 +1216,7 @@ u32 __KernelDeleteThread(SceUID threadID, int exitStatus, const char *reason, bo
|
||||
{
|
||||
// TODO: Unless they should be run before deletion?
|
||||
for (int i = 0; i < THREAD_CALLBACK_NUM_TYPES; i++)
|
||||
readyCallbacksCount -= t->readyCallbacks[i].size();
|
||||
readyCallbacksCount -= (int)t->readyCallbacks[i].size();
|
||||
}
|
||||
|
||||
return kernelObjects.Destroy<Thread>(threadID);
|
||||
@@ -1260,7 +1263,7 @@ void __KernelReSchedule(const char *reason)
|
||||
}
|
||||
|
||||
// Execute any pending events while we're doing scheduling.
|
||||
CoreTiming::Advance();
|
||||
CoreTiming::AdvanceQuick();
|
||||
if (__IsInInterrupt() || __KernelInCallback())
|
||||
{
|
||||
reason = "In Interrupt Or Callback";
|
||||
|
||||
@@ -833,7 +833,7 @@ int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initAddr)
|
||||
{
|
||||
MpegContext *ctx = getMpegCtx(mpeg);
|
||||
if (!ctx) {
|
||||
WARN_LOG(HLE, "sceMpegAvcDecodeYCbCr(%08x, %08x, %d, %08x, %08x): bad mpeg handle", mpeg, auAddr, bufferAddr, initAddr);
|
||||
WARN_LOG(HLE, "sceMpegAvcDecodeYCbCr(%08x, %08x, %08x, %08x): bad mpeg handle", mpeg, auAddr, bufferAddr, initAddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "scePspNpDrm_user.h"
|
||||
|
||||
#include "HLE.h"
|
||||
|
||||
int sceNpDrmSetLicenseeKey()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceNpDrmSetLicenseeKey");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceNpDrmClearLicenseeKey()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceNpDrmClearLicenseeKey");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceNpDrmRenameCheck()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceNpDrmRenameCheck");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceNpDrmEdataSetupKey(u32 edataFd)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceNpDrmEdataSetupKey %x", edataFd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceNpDrmEdataGetDataSize(u32 edataFd)
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceNpDrmEdataGetDataSize %x", edataFd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceNpDrmOpen()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceNpDrmOpen");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelLoadModuleNpDrm()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceKernelLoadModuleNpDrm");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sceKernelLoadExecNpDrm()
|
||||
{
|
||||
ERROR_LOG(HLE, "UNIMPL sceKernelLoadExecNpDrm");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const HLEFunction sceNpDrm[] =
|
||||
{
|
||||
{0xA1336091, 0, "sceNpDrmSetLicenseeKey"},
|
||||
{0x9B745542, 0, "sceNpDrmClearLicenseeKey"},
|
||||
{0x275987D1, 0, "sceNpDrmRenameCheck"},
|
||||
{0x08d98894, WrapI_U<sceNpDrmEdataSetupKey>, "sceNpDrmEdataSetupKey"},
|
||||
{0x219EF5CC, WrapI_U<sceNpDrmEdataGetDataSize>, "sceNpDrmEdataGetDataSize"},
|
||||
{0x2BAA4294, 0, "sceNpDrmOpen"},
|
||||
{0xC618D0B1, 0, "sceKernelLoadModuleNpDrm"},
|
||||
{0xAA5FC85B, 0, "sceKernelLoadExecNpDrm"},
|
||||
};
|
||||
|
||||
void Register_sceNpDrm()
|
||||
{
|
||||
RegisterModule("sceNpDrm", ARRAY_SIZE(sceNpDrm), sceNpDrm);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
void Register_sceNpDrm();
|
||||
+79
-32
@@ -24,6 +24,8 @@
|
||||
|
||||
const int PSP_ERROR_UMD_INVALID_PARAM = 0x80010016;
|
||||
|
||||
const u64 MICRO_DELAY_ACTIVATE = 4000;
|
||||
|
||||
#define UMD_NOT_PRESENT 0x01
|
||||
#define UMD_PRESENT 0x02
|
||||
#define UMD_CHANGED 0x04
|
||||
@@ -31,12 +33,27 @@ const int PSP_ERROR_UMD_INVALID_PARAM = 0x80010016;
|
||||
#define UMD_READY 0x10
|
||||
#define UMD_READABLE 0x20
|
||||
|
||||
struct UmdWaitingThread
|
||||
{
|
||||
SceUID threadID;
|
||||
u32 stat;
|
||||
|
||||
inline static UmdWaitingThread Make(SceUID threadID, u32 stat)
|
||||
{
|
||||
UmdWaitingThread th;
|
||||
th.threadID = threadID;
|
||||
th.stat = stat;
|
||||
return th;
|
||||
}
|
||||
};
|
||||
|
||||
static u8 umdActivated = 1;
|
||||
static u32 umdStatus = 0;
|
||||
static u32 umdErrorStat = 0;
|
||||
static int driveCBId = -1;
|
||||
static int umdStatTimer = -1;
|
||||
static int umdStatTimeoutEvent = -1;
|
||||
static int umdStatChangeEvent = -1;
|
||||
static std::vector<UmdWaitingThread> umdWaitingThreads;
|
||||
|
||||
|
||||
#define PSP_UMD_TYPE_GAME 0x10
|
||||
@@ -49,10 +66,12 @@ struct PspUmdInfo {
|
||||
};
|
||||
|
||||
void __UmdStatTimeout(u64 userdata, int cyclesLate);
|
||||
void __UmdStatChange(u64 userdata, int cyclesLate);
|
||||
|
||||
void __UmdInit()
|
||||
{
|
||||
umdStatTimer = CoreTiming::RegisterEvent("UmdTimeout", __UmdStatTimeout);
|
||||
umdStatTimeoutEvent = CoreTiming::RegisterEvent("UmdTimeout", __UmdStatTimeout);
|
||||
umdStatChangeEvent = CoreTiming::RegisterEvent("UmdChange", __UmdStatChange);
|
||||
umdActivated = 1;
|
||||
umdStatus = 0;
|
||||
umdErrorStat = 0;
|
||||
@@ -65,8 +84,11 @@ void __UmdDoState(PointerWrap &p)
|
||||
p.Do(umdStatus);
|
||||
p.Do(umdErrorStat);
|
||||
p.Do(driveCBId);
|
||||
p.Do(umdStatTimer);
|
||||
CoreTiming::RestoreRegisterEvent(umdStatTimer, "UmdTimeout", __UmdStatTimeout);
|
||||
p.Do(umdStatTimeoutEvent);
|
||||
CoreTiming::RestoreRegisterEvent(umdStatTimeoutEvent, "UmdTimeout", __UmdStatTimeout);
|
||||
p.Do(umdStatChangeEvent);
|
||||
CoreTiming::RestoreRegisterEvent(umdStatChangeEvent, "UmdChange", __UmdStatChange);
|
||||
p.Do(umdWaitingThreads);
|
||||
p.DoMarker("sceUmd");
|
||||
}
|
||||
|
||||
@@ -83,24 +105,55 @@ u8 __KernelUmdGetState()
|
||||
return state;
|
||||
}
|
||||
|
||||
void __UmdStatChange(u64 userdata, int cyclesLate)
|
||||
{
|
||||
// TODO: Why not a bool anyway?
|
||||
umdActivated = userdata & 0xFF;
|
||||
|
||||
// Wake anyone waiting on this.
|
||||
for (size_t i = 0; i < umdWaitingThreads.size(); ++i)
|
||||
{
|
||||
UmdWaitingThread &info = umdWaitingThreads[i];
|
||||
|
||||
u32 error;
|
||||
SceUID waitID = __KernelGetWaitID(info.threadID, WAITTYPE_UMD, error);
|
||||
bool keep = false;
|
||||
if (waitID == 1)
|
||||
{
|
||||
if ((info.stat & __KernelUmdGetState()) != 0)
|
||||
__KernelResumeThreadFromWait(info.threadID, 0);
|
||||
// Only if they are still waiting do we keep them in the list.
|
||||
else
|
||||
keep = true;
|
||||
}
|
||||
|
||||
if (!keep)
|
||||
umdWaitingThreads.erase(umdWaitingThreads.begin() + i--);
|
||||
}
|
||||
}
|
||||
|
||||
void __KernelUmdActivate()
|
||||
{
|
||||
umdActivated = 1;
|
||||
u32 notifyArg = UMD_PRESENT | UMD_READABLE;
|
||||
__KernelNotifyCallbackType(THREAD_CALLBACK_UMD, -1, notifyArg);
|
||||
|
||||
// Don't activate immediately, take time to "spin up."
|
||||
CoreTiming::RemoveAllEvents(umdStatChangeEvent);
|
||||
CoreTiming::ScheduleEvent(usToCycles(MICRO_DELAY_ACTIVATE), umdStatChangeEvent, 1);
|
||||
}
|
||||
|
||||
void __KernelUmdDeactivate()
|
||||
{
|
||||
umdActivated = 0;
|
||||
u32 notifyArg = UMD_PRESENT | UMD_READY;
|
||||
__KernelNotifyCallbackType(THREAD_CALLBACK_UMD, -1, notifyArg);
|
||||
|
||||
CoreTiming::RemoveAllEvents(umdStatChangeEvent);
|
||||
__UmdStatChange(0, 0);
|
||||
}
|
||||
|
||||
// typedef int (*UmdCallback)(int unknown, int event);
|
||||
|
||||
|
||||
//int sceUmdCheckMedium(int a);
|
||||
int sceUmdCheckMedium()
|
||||
{
|
||||
DEBUG_LOG(HLE,"1=sceUmdCheckMedium(?)");
|
||||
//ignore PARAM(0)
|
||||
DEBUG_LOG(HLE, "1=sceUmdCheckMedium()");
|
||||
return 1; //non-zero: disc in drive
|
||||
}
|
||||
|
||||
@@ -128,7 +181,6 @@ int sceUmdActivate(u32 unknown, const char *name)
|
||||
if (unknown < 1 || unknown > 2)
|
||||
return PSP_ERROR_UMD_INVALID_PARAM;
|
||||
|
||||
bool changed = umdActivated == 0;
|
||||
__KernelUmdActivate();
|
||||
|
||||
if (unknown == 1)
|
||||
@@ -140,9 +192,6 @@ int sceUmdActivate(u32 unknown, const char *name)
|
||||
ERROR_LOG(HLE, "UNTESTED 0=sceUmdActivate(%d, %s)", unknown, name);
|
||||
}
|
||||
|
||||
u32 notifyArg = UMD_PRESENT | UMD_READABLE;
|
||||
__KernelNotifyCallbackType(THREAD_CALLBACK_UMD, -1, notifyArg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -152,7 +201,6 @@ int sceUmdDeactivate(u32 unknown, const char *name)
|
||||
if (unknown > 18)
|
||||
return PSP_ERROR_UMD_INVALID_PARAM;
|
||||
|
||||
bool changed = umdActivated != 0;
|
||||
__KernelUmdDeactivate();
|
||||
|
||||
if (unknown == 1)
|
||||
@@ -164,9 +212,6 @@ int sceUmdDeactivate(u32 unknown, const char *name)
|
||||
ERROR_LOG(HLE, "UNTESTED 0=sceUmdDeactivate(%d, %s)", unknown, name);
|
||||
}
|
||||
|
||||
u32 notifyArg = UMD_PRESENT | UMD_READY;
|
||||
__KernelNotifyCallbackType(THREAD_CALLBACK_UMD, -1, notifyArg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -225,6 +270,12 @@ void __UmdStatTimeout(u64 userdata, int cyclesLate)
|
||||
// Assuming it's still waiting.
|
||||
if (waitID == 1)
|
||||
__KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT);
|
||||
|
||||
for (size_t i = 0; i < umdWaitingThreads.size(); ++i)
|
||||
{
|
||||
if (umdWaitingThreads[i].threadID == threadID)
|
||||
umdWaitingThreads.erase(umdWaitingThreads.begin() + i--);
|
||||
}
|
||||
}
|
||||
|
||||
void __UmdWaitStat(u32 timeout)
|
||||
@@ -235,7 +286,7 @@ void __UmdWaitStat(u32 timeout)
|
||||
else if (timeout <= 215)
|
||||
timeout = 250;
|
||||
|
||||
CoreTiming::ScheduleEvent(usToCycles((int) timeout), umdStatTimer, __KernelGetCurThread());
|
||||
CoreTiming::ScheduleEvent(usToCycles((int) timeout), umdStatTimeoutEvent, __KernelGetCurThread());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,7 +301,10 @@ int sceUmdWaitDriveStat(u32 stat)
|
||||
DEBUG_LOG(HLE,"0=sceUmdWaitDriveStat(stat = %08x)", stat);
|
||||
|
||||
if ((stat & __KernelUmdGetState()) == 0)
|
||||
{
|
||||
umdWaitingThreads.push_back(UmdWaitingThread::Make(__KernelGetCurThread(), stat));
|
||||
__KernelWaitCurThread(WAITTYPE_UMD, 1, stat, 0, 0, "umd stat waited");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -262,7 +316,8 @@ int sceUmdWaitDriveStatWithTimer(u32 stat, u32 timeout)
|
||||
if ((stat & __KernelUmdGetState()) == 0)
|
||||
{
|
||||
__UmdWaitStat(timeout);
|
||||
__KernelWaitCurThread(WAITTYPE_UMD, 1, stat, 0, 0, "umd stat waited");
|
||||
umdWaitingThreads.push_back(UmdWaitingThread::Make(__KernelGetCurThread(), stat));
|
||||
__KernelWaitCurThread(WAITTYPE_UMD, 1, stat, 0, 0, "umd stat waited with timer");
|
||||
}
|
||||
else
|
||||
hleReSchedule("umd stat waited with timer");
|
||||
@@ -272,14 +327,7 @@ int sceUmdWaitDriveStatWithTimer(u32 stat, u32 timeout)
|
||||
|
||||
int sceUmdWaitDriveStatCB(u32 stat, u32 timeout)
|
||||
{
|
||||
if (driveCBId != -1)
|
||||
{
|
||||
DEBUG_LOG(HLE,"0=sceUmdWaitDriveStatCB(stat = %08x, timeout = %d)", stat, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(HLE, "0=sceUmdWaitDriveStatCB(stat = %08x, timeout = %d) without callback", stat, timeout);
|
||||
}
|
||||
DEBUG_LOG(HLE,"0=sceUmdWaitDriveStatCB(stat = %08x, timeout = %d)", stat, timeout);
|
||||
|
||||
hleCheckCurrentCallbacks();
|
||||
if ((stat & __KernelUmdGetState()) == 0)
|
||||
@@ -288,6 +336,7 @@ int sceUmdWaitDriveStatCB(u32 stat, u32 timeout)
|
||||
timeout = 8000;
|
||||
|
||||
__UmdWaitStat(timeout);
|
||||
umdWaitingThreads.push_back(UmdWaitingThread::Make(__KernelGetCurThread(), stat));
|
||||
__KernelWaitCurThread(WAITTYPE_UMD, 1, stat, 0, true, "umd stat waited");
|
||||
}
|
||||
else
|
||||
@@ -324,8 +373,6 @@ u32 sceUmdReplacePermit()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const HLEFunction sceUmdUser[] =
|
||||
{
|
||||
{0xC6183D47,WrapI_UC<sceUmdActivate>,"sceUmdActivate"},
|
||||
|
||||
@@ -88,6 +88,11 @@ void VagDecoder::GetSamples(s16 *outSamples, int numSamples) {
|
||||
return;
|
||||
}
|
||||
u8 *readp = Memory::GetPointer(read_);
|
||||
if (!readp)
|
||||
{
|
||||
WARN_LOG(HLE, "Bad VAG samples address?");
|
||||
return;
|
||||
}
|
||||
u8 *origp = readp;
|
||||
for (int i = 0; i < numSamples; i++) {
|
||||
if (curSample == 28) {
|
||||
|
||||
@@ -145,7 +145,12 @@ namespace MIPSComp
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Jit::Comp_RType2(u32 op)
|
||||
{
|
||||
DISABLE;
|
||||
}
|
||||
|
||||
void Jit::Comp_RType3(u32 op)
|
||||
{
|
||||
int rt = _RT;
|
||||
@@ -154,11 +159,11 @@ namespace MIPSComp
|
||||
|
||||
switch (op & 63)
|
||||
{
|
||||
//case 10: if (!R(rt)) R(rd) = R(rs); break; //movz
|
||||
//case 11: if (R(rt)) R(rd) = R(rs); break; //movn
|
||||
//case 10: if (!R(rt)) R(rd) = R(rs); break; //movz
|
||||
//case 11: if (R(rt)) R(rd) = R(rs); break; //movn
|
||||
|
||||
// case 32: //R(rd) = R(rs) + R(rt); break; //add
|
||||
case 33: //R(rd) = R(rs) + R(rt); break; //addu
|
||||
// case 32: //R(rd) = R(rs) + R(rt); break; //add
|
||||
case 33: //R(rd) = R(rs) + R(rt); break; //addu
|
||||
// Some optimized special cases
|
||||
if (rs == 0) {
|
||||
gpr.MapDirtyIn(rd, rt);
|
||||
@@ -171,25 +176,25 @@ namespace MIPSComp
|
||||
ADD(gpr.R(rd), gpr.R(rs), gpr.R(rt));
|
||||
}
|
||||
break;
|
||||
case 34: //R(rd) = R(rs) - R(rt); break; //sub
|
||||
case 34: //R(rd) = R(rs) - R(rt); break; //sub
|
||||
case 35:
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
SUB(gpr.R(rd), gpr.R(rs), gpr.R(rt));
|
||||
break;
|
||||
case 36: //R(rd) = R(rs) & R(rt); break; //and
|
||||
case 36: //R(rd) = R(rs) & R(rt); break; //and
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
AND(gpr.R(rd), gpr.R(rs), gpr.R(rt));
|
||||
break;
|
||||
case 37: //R(rd) = R(rs) | R(rt); break; //or
|
||||
case 37: //R(rd) = R(rs) | R(rt); break; //or
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
ORR(gpr.R(rd), gpr.R(rs), gpr.R(rt));
|
||||
break;
|
||||
case 38: //R(rd) = R(rs) ^ R(rt); break; //xor/eor
|
||||
case 38: //R(rd) = R(rs) ^ R(rt); break; //xor/eor
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
EOR(gpr.R(rd), gpr.R(rs), gpr.R(rt));
|
||||
break;
|
||||
|
||||
case 39: // R(rd) = ~(R(rs) | R(rt)); //nor
|
||||
case 39: // R(rd) = ~(R(rs) | R(rt)); break; //nor
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
if (rt == 0) {
|
||||
MVN(gpr.R(rd), gpr.R(rs));
|
||||
@@ -209,7 +214,7 @@ namespace MIPSComp
|
||||
SetCC(CC_AL);
|
||||
break;
|
||||
|
||||
case 43: //R(rd) = R(rs) < R(rt); break; //sltu
|
||||
case 43: //R(rd) = R(rs) < R(rt); break; //sltu
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
CMP(gpr.R(rs), gpr.R(rt));
|
||||
SetCC(CC_LO);
|
||||
@@ -219,11 +224,25 @@ namespace MIPSComp
|
||||
SetCC(CC_AL);
|
||||
break;
|
||||
|
||||
// case 44: R(rd) = (R(rs) > R(rt)) ? R(rs) : R(rt); break; //max
|
||||
// CMP(a,b); CMOVLT(a,b)
|
||||
case 44: //R(rd) = max(R(rs), R(rt); break; //max
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
CMP(gpr.R(rs), gpr.R(rt));
|
||||
SetCC(CC_GT);
|
||||
MOV(gpr.R(rd), gpr.R(rs));
|
||||
SetCC(CC_LE);
|
||||
MOV(gpr.R(rd), gpr.R(rt));
|
||||
SetCC(CC_AL);
|
||||
break;
|
||||
|
||||
// case 45: R(rd) = (R(rs) < R(rt)) ? R(rs) : R(rt); break; //min
|
||||
// CMP(a,b); CMOVGT(a,b)
|
||||
case 45: //R(rd) = min(R(rs), R(rt)); break; //min
|
||||
gpr.MapDirtyInIn(rd, rs, rt);
|
||||
CMP(gpr.R(rs), gpr.R(rt));
|
||||
SetCC(CC_LT);
|
||||
MOV(gpr.R(rd), gpr.R(rs));
|
||||
SetCC(CC_GE);
|
||||
MOV(gpr.R(rd), gpr.R(rt));
|
||||
SetCC(CC_AL);
|
||||
break;
|
||||
|
||||
default:
|
||||
// gpr.UnlockAll();
|
||||
@@ -263,15 +282,17 @@ namespace MIPSComp
|
||||
*/
|
||||
void Jit::Comp_ShiftType(u32 op)
|
||||
{
|
||||
int rs = _RS;
|
||||
int fd = _FD;
|
||||
// WARNIGN : ROTR
|
||||
switch (op & 0x3f)
|
||||
{
|
||||
case 0: CompShiftImm(op, ST_LSL); break;
|
||||
case 2: CompShiftImm(op, ST_LSR); break; // srl
|
||||
case 2: CompShiftImm(op, rs == 1 ? ST_ROR : ST_LSR); break; // srl
|
||||
case 3: CompShiftImm(op, ST_ASR); break; // sra
|
||||
|
||||
// case 4: CompShiftVar(op, &XEmitter::SHL); break; // R(rd) = R(rt) << R(rs); break; //sllv
|
||||
// case 6: CompShiftVar(op, &XEmitter::SHR); break; // R(rd) = R(rt) >> R(rs); break; //srlv
|
||||
// case 6: CompShiftVar(op, fd == 1 ? &XEmitter::ROR : &XEmitter::SHR); break; // R(rd) = R(rt) >> R(rs); break; //srlv
|
||||
// case 7: CompShiftVar(op, &XEmitter::SAR); break; // R(rd) = ((s32)R(rt)) >> R(rs); break; //srav
|
||||
|
||||
default:
|
||||
@@ -289,29 +310,44 @@ namespace MIPSComp
|
||||
|
||||
void Jit::Comp_Allegrex(u32 op)
|
||||
{
|
||||
DISABLE
|
||||
int rt = _RT;
|
||||
int rd = _RD;
|
||||
switch ((op >> 6) & 31)
|
||||
{
|
||||
/*
|
||||
case 16: // seb // R(rd) = (u32)(s32)(s8)(u8)R(rt);
|
||||
/*
|
||||
gpr.Lock(rd, rt);
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
MOV(32, R(EAX), gpr.R(rt)); // work around the byte-register addressing problem
|
||||
MOVSX(32, 8, gpr.RX(rd), R(EAX));
|
||||
gpr.UnlockAll();*/
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
case 24: // seh
|
||||
/*
|
||||
gpr.Lock(rd, rt);
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
MOVSX(32, 16, gpr.RX(rd), gpr.R(rt));
|
||||
gpr.UnlockAll();*/
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
*/
|
||||
case 20: //bitrev
|
||||
if (gpr.IsImm(rt))
|
||||
{
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
|
||||
u32 v = gpr.GetImm(rt);
|
||||
// swap odd and even bits
|
||||
v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
|
||||
// swap consecutive pairs
|
||||
v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2);
|
||||
// swap nibbles ...
|
||||
v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4);
|
||||
// swap bytes
|
||||
v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8);
|
||||
// swap 2-byte long pairs
|
||||
v = ( v >> 16 ) | ( v << 16);
|
||||
gpr.SetImm(rd,v);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Comp_Generic(op);
|
||||
return;
|
||||
@@ -355,6 +391,17 @@ namespace MIPSComp
|
||||
case 25: //multu (2nd) lo,hi = unsigned mul (rs * rt)
|
||||
gpr.MapDirtyDirtyInIn(MIPSREG_LO, MIPSREG_HI, rs, rt);
|
||||
UMULL(gpr.R(MIPSREG_LO), gpr.R(MIPSREG_HI), gpr.R(rs), gpr.R(rt));
|
||||
break;
|
||||
|
||||
case 28: //madd
|
||||
gpr.MapDirtyDirtyInIn(MIPSREG_LO, MIPSREG_HI, rs, rt, false);
|
||||
SMLAL(gpr.R(MIPSREG_LO), gpr.R(MIPSREG_HI), gpr.R(rs), gpr.R(rt));
|
||||
break;
|
||||
|
||||
case 29: //maddu
|
||||
gpr.MapDirtyDirtyInIn(MIPSREG_LO, MIPSREG_HI, rs, rt, false);
|
||||
UMLAL(gpr.R(MIPSREG_LO), gpr.R(MIPSREG_HI), gpr.R(rs), gpr.R(rt));
|
||||
break;
|
||||
|
||||
default:
|
||||
DISABLE;
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace MIPSComp
|
||||
void Jit::Comp_ITypeMem(u32 op)
|
||||
{
|
||||
int offset = (signed short)(op&0xFFFF);
|
||||
bool load = false;
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
int o = op>>26;
|
||||
@@ -93,62 +94,44 @@ namespace MIPSComp
|
||||
}
|
||||
switch (o)
|
||||
{
|
||||
case 37: //R(rt) = ReadMem16(addr); break; //lhu
|
||||
Comp_Generic(op);
|
||||
return;
|
||||
|
||||
case 35: //R(rt) = ReadMem32(addr); //lw
|
||||
case 36: //R(rt) = ReadMem8 (addr); break; //lbu
|
||||
if (g_Config.bFastMemory) {
|
||||
if (gpr.IsImm(rs)) {
|
||||
// We can compute the full address at compile time. Kickass.
|
||||
u32 addr = (offset + gpr.GetImm(rs)) & 0x3FFFFFFF;
|
||||
gpr.MapReg(rt, MAP_NOINIT | MAP_DIRTY); // must be OK even if rs == rt since we have the value from imm already.
|
||||
MOVI2R(R0, addr);
|
||||
} else {
|
||||
gpr.MapDirtyIn(rt, rs);
|
||||
SetR0ToEffectiveAddress(rs, offset);
|
||||
}
|
||||
if (o == 35) {
|
||||
LDR(gpr.R(rt), R11, R0, true, true);
|
||||
} else if (o == 36) {
|
||||
ADD(R0, R0, R11); // TODO: Merge with next instruction
|
||||
LDRB(gpr.R(rt), R0);
|
||||
}
|
||||
} else {
|
||||
Comp_Generic(op);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 41: //WriteMem16(addr, R(rt)); break; //sh
|
||||
Comp_Generic(op);
|
||||
return;
|
||||
|
||||
case 32: //lb
|
||||
case 33: //lh
|
||||
case 35: //lw
|
||||
case 36: //lbu
|
||||
case 37: //lhu
|
||||
load = true;
|
||||
case 40: //sb
|
||||
case 43: //WriteMem32(addr, R(rt)); break; //sw
|
||||
case 41: //sh
|
||||
case 43: //sw
|
||||
if (g_Config.bFastMemory) {
|
||||
if (gpr.IsImm(rs)) {
|
||||
// We can compute the full address at compile time. Kickass.
|
||||
u32 addr = (offset + gpr.GetImm(rs)) & 0x3FFFFFFF;
|
||||
gpr.MapReg(rt);
|
||||
// Must be OK even if rs == rt since we have the value from imm already.
|
||||
gpr.MapReg(rt, load ? MAP_NOINIT | MAP_DIRTY : 0);
|
||||
MOVI2R(R0, addr);
|
||||
} else {
|
||||
gpr.MapInIn(rt, rs);
|
||||
load ? gpr.MapDirtyIn(rt, rs) : gpr.MapInIn(rt, rs);
|
||||
SetR0ToEffectiveAddress(rs, offset);
|
||||
}
|
||||
if (o == 43) {
|
||||
STR(R0, gpr.R(rt), R11, true, true);
|
||||
} else if (o == 40) {
|
||||
ADD(R0, R0, R11);
|
||||
STRB(R0, gpr.R(rt));
|
||||
switch (o)
|
||||
{
|
||||
// Load
|
||||
case 35: LDR (gpr.R(rt), R11, R0, true, true); break;
|
||||
case 37: LDRH (gpr.R(rt), R11, R0, true, true); break;
|
||||
case 33: LDRSH(gpr.R(rt), R11, R0, true, true); break;
|
||||
case 36: LDRB (gpr.R(rt), R11, R0, true, true); break;
|
||||
case 32: LDRSB(gpr.R(rt), R11, R0, true, true); break;
|
||||
// Store
|
||||
case 43: STR (R0, gpr.R(rt), R11, true, true); break;
|
||||
case 41: STRH (R0, gpr.R(rt), R11, true, true); break;
|
||||
case 40: STRB (R0, gpr.R(rt), R11, true, true); break;
|
||||
}
|
||||
} else {
|
||||
Comp_Generic(op);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
// break;
|
||||
/*
|
||||
case 34: //lwl
|
||||
{
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace MIPSComp
|
||||
|
||||
fpr.ReleaseSpillLocks();
|
||||
}
|
||||
|
||||
|
||||
void Jit::Comp_Mftv(u32 op)
|
||||
{
|
||||
// DISABLE;
|
||||
|
||||
@@ -163,6 +163,7 @@ public:
|
||||
void Comp_Break(u32 op);
|
||||
|
||||
void Comp_IType(u32 op);
|
||||
void Comp_RType2(u32 op);
|
||||
void Comp_RType3(u32 op);
|
||||
void Comp_ShiftType(u32 op);
|
||||
void Comp_Allegrex(u32 op);
|
||||
@@ -187,7 +188,6 @@ public:
|
||||
void Comp_Vmtvc(u32 op);
|
||||
void Comp_Vmmov(u32 op);
|
||||
|
||||
|
||||
ArmJitBlockCache *GetBlockCache() { return &blocks; }
|
||||
|
||||
void ClearCache();
|
||||
|
||||
@@ -135,16 +135,16 @@ void ArmRegCache::MapInIn(MIPSReg rd, MIPSReg rs) {
|
||||
|
||||
void ArmRegCache::MapDirtyIn(MIPSReg rd, MIPSReg rs, bool avoidLoad) {
|
||||
SpillLock(rd, rs);
|
||||
bool overlap = avoidLoad && rd == rs;
|
||||
MapReg(rd, MAP_DIRTY | (overlap ? 0 : MAP_NOINIT));
|
||||
bool load = !avoidLoad || rd == rs;
|
||||
MapReg(rd, MAP_DIRTY | (load ? 0 : MAP_NOINIT));
|
||||
MapReg(rs);
|
||||
ReleaseSpillLocks();
|
||||
}
|
||||
|
||||
void ArmRegCache::MapDirtyInIn(MIPSReg rd, MIPSReg rs, MIPSReg rt, bool avoidLoad) {
|
||||
SpillLock(rd, rs, rt);
|
||||
bool overlap = avoidLoad && (rd == rs || rd == rt);
|
||||
MapReg(rd, MAP_DIRTY | (overlap ? 0 : MAP_NOINIT));
|
||||
bool load = !avoidLoad || (rd == rs || rd == rt);
|
||||
MapReg(rd, MAP_DIRTY | (load ? 0 : MAP_NOINIT));
|
||||
MapReg(rt);
|
||||
MapReg(rs);
|
||||
ReleaseSpillLocks();
|
||||
@@ -152,10 +152,10 @@ void ArmRegCache::MapDirtyInIn(MIPSReg rd, MIPSReg rs, MIPSReg rt, bool avoidLoa
|
||||
|
||||
void ArmRegCache::MapDirtyDirtyInIn(MIPSReg rd1, MIPSReg rd2, MIPSReg rs, MIPSReg rt, bool avoidLoad) {
|
||||
SpillLock(rd1, rd2, rs, rt);
|
||||
bool overlap1 = avoidLoad && (rd1 == rs || rd1 == rt);
|
||||
bool overlap2 = avoidLoad && (rd2 == rs || rd2 == rt);
|
||||
MapReg(rd1, MAP_DIRTY | (overlap1 ? 0 : MAP_NOINIT));
|
||||
MapReg(rd2, MAP_DIRTY | (overlap2 ? 0 : MAP_NOINIT));
|
||||
bool load1 = !avoidLoad || (rd1 == rs || rd1 == rt);
|
||||
bool load2 = !avoidLoad || (rd2 == rs || rd2 == rt);
|
||||
MapReg(rd1, MAP_DIRTY | (load1 ? 0 : MAP_NOINIT));
|
||||
MapReg(rd2, MAP_DIRTY | (load2 ? 0 : MAP_NOINIT));
|
||||
MapReg(rt);
|
||||
MapReg(rs);
|
||||
ReleaseSpillLocks();
|
||||
|
||||
@@ -74,7 +74,40 @@ public:
|
||||
|
||||
u32 GetRegValue(int cat, int index)
|
||||
{
|
||||
return cpu->r[index];
|
||||
switch (cat)
|
||||
{
|
||||
case 0:
|
||||
return cpu->r[index];
|
||||
|
||||
case 1:
|
||||
return *(u32 *)&cpu->f[index];
|
||||
|
||||
case 2:
|
||||
return *(u32 *)&cpu->v[index];
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SetRegValue(int cat, int index, u32 value)
|
||||
{
|
||||
switch (cat)
|
||||
{
|
||||
case 0:
|
||||
cpu->r[index] = value;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
cpu->f[index] = *(float *)&value;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
cpu->v[index] = *(float *)&value;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
+10
-10
@@ -76,7 +76,7 @@ namespace MIPSDis
|
||||
int ft = _FT;
|
||||
int rs = _RS;
|
||||
const char *name = MIPSGetName(op);
|
||||
sprintf(out, "%s\t%s, %d(%s)",name,FN(ft),offset,RN(rs));
|
||||
sprintf(out, "%s\t%s, 0x%X(%s)",name,FN(ft),offset,RN(rs));
|
||||
}
|
||||
void Dis_FPUComp(u32 op, char *out)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ namespace MIPSDis
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
const char *name = MIPSGetName(op);
|
||||
sprintf(out, "%s\t%s, %s, %i",name,RN(rt),RN(rs),imm);
|
||||
sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rt),RN(rs),imm);
|
||||
}
|
||||
void Dis_ori(u32 op, char *out)
|
||||
{
|
||||
@@ -160,9 +160,9 @@ namespace MIPSDis
|
||||
int rs = _RS;
|
||||
const char *name = MIPSGetName(op);
|
||||
if (rs == 0)
|
||||
sprintf(out, "li\t%s, %i",RN(rt),imm);
|
||||
sprintf(out, "li\t%s, 0x%X",RN(rt),imm);
|
||||
else
|
||||
sprintf(out, "%s\t%s, %s, %i",name,RN(rt),RN(rs),imm);
|
||||
sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rt),RN(rs),imm);
|
||||
}
|
||||
|
||||
void Dis_IType1(u32 op, char *out)
|
||||
@@ -170,7 +170,7 @@ namespace MIPSDis
|
||||
int imm = (signed short)(op&0xFFFF);
|
||||
int rt = _RT;
|
||||
const char *name = MIPSGetName(op);
|
||||
sprintf(out, "%s\t%s, %i",name,RN(rt),imm);
|
||||
sprintf(out, "%s\t%s, 0x%X",name,RN(rt),imm);
|
||||
}
|
||||
|
||||
void Dis_addi(u32 op, char *out)
|
||||
@@ -179,7 +179,7 @@ namespace MIPSDis
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
if (rs == 0)
|
||||
sprintf(out, "li\t%s, %i",RN(rt),imm);
|
||||
sprintf(out, "li\t%s, 0x%X",RN(rt),imm);
|
||||
else
|
||||
Dis_IType(op,out);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ namespace MIPSDis
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
const char *name = MIPSGetName(op);
|
||||
sprintf(out, "%s\t%s, %i(%s)",name,RN(rt),imm,RN(rs));
|
||||
sprintf(out, "%s\t%s, 0x%X(%s)",name,RN(rt),imm,RN(rs));
|
||||
}
|
||||
|
||||
void Dis_RType2(u32 op, char *out)
|
||||
@@ -237,7 +237,7 @@ namespace MIPSDis
|
||||
name = "rotr";
|
||||
if (((op & 0x3f) == 6) && sa == 1)
|
||||
name = "rotrv";
|
||||
sprintf(out, "%s\t%s, %s, %d",name,RN(rd),RN(rt),sa);
|
||||
sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rd),RN(rt),sa);
|
||||
}
|
||||
|
||||
void Dis_VarShiftType(u32 op, char *out)
|
||||
@@ -271,13 +271,13 @@ namespace MIPSDis
|
||||
case 0x0: //ext
|
||||
{
|
||||
int size = _SIZE + 1;
|
||||
sprintf(out,"%s\t%s, %s, %i, %i",name,RN(Rt),RN(rs),pos,size);
|
||||
sprintf(out,"%s\t%s, %s, 0x%X, 0x%X",name,RN(Rt),RN(rs),pos,size);
|
||||
}
|
||||
break;
|
||||
case 0x4: // ins
|
||||
{
|
||||
int size = (_SIZE + 1) - pos;
|
||||
sprintf(out,"%s\t%s, %s, %i, %i",name,RN(Rt),RN(rs),pos,size);
|
||||
sprintf(out,"%s\t%s, %s, 0x%X, 0x%X",name,RN(Rt),RN(rs),pos,size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+53
-6
@@ -187,7 +187,7 @@ namespace MIPSInt
|
||||
void Int_Break(u32 op)
|
||||
{
|
||||
ERROR_LOG(CPU, "BREAK!");
|
||||
coreState = CORE_STEPPING;
|
||||
Core_UpdateState(CORE_STEPPING);
|
||||
PC += 4;
|
||||
}
|
||||
|
||||
@@ -304,7 +304,6 @@ namespace MIPSInt
|
||||
_dbg_assert_msg_(CPU,0,"Jump in delay slot :(");
|
||||
}
|
||||
|
||||
|
||||
int rs = (op>>21)&0x1f;
|
||||
u32 addr = R(rs);
|
||||
switch (op & 0x3f)
|
||||
@@ -362,14 +361,18 @@ namespace MIPSInt
|
||||
switch (op >> 26)
|
||||
{
|
||||
case 48: // ll
|
||||
R(rt) = Memory::Read_U32(addr);
|
||||
if (rt != 0) {
|
||||
R(rt) = Memory::Read_U32(addr);
|
||||
}
|
||||
currentMIPS->llBit = 1;
|
||||
break;
|
||||
case 56: // sc
|
||||
if (currentMIPS->llBit) {
|
||||
Memory::Write_U32(R(rt), addr);
|
||||
R(rt) = 1;
|
||||
} else {
|
||||
if (rt != 0) {
|
||||
R(rt) = 1;
|
||||
}
|
||||
} else if (rt != 0) {
|
||||
R(rt) = 0;
|
||||
}
|
||||
break;
|
||||
@@ -388,6 +391,13 @@ namespace MIPSInt
|
||||
int rd = _RD;
|
||||
static bool has_warned = false;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op & 63)
|
||||
{
|
||||
case 10: if (R(rt) == 0) R(rd) = R(rs); break; //movz
|
||||
@@ -533,6 +543,14 @@ namespace MIPSInt
|
||||
{
|
||||
int rs = _RS;
|
||||
int rd = _RD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op & 63)
|
||||
{
|
||||
case 22: //clz
|
||||
@@ -675,6 +693,13 @@ namespace MIPSInt
|
||||
int rs = _RS;
|
||||
int rd = _RD;
|
||||
int sa = _FD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op & 0x3f)
|
||||
{
|
||||
@@ -720,6 +745,14 @@ namespace MIPSInt
|
||||
{
|
||||
int rt = _RT;
|
||||
int rd = _RD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch((op>>6)&31)
|
||||
{
|
||||
case 16: // seb
|
||||
@@ -756,6 +789,13 @@ namespace MIPSInt
|
||||
int rt = _RT;
|
||||
int rd = _RD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
{
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op & 0x3ff)
|
||||
{
|
||||
case 0xA0: //wsbh
|
||||
@@ -777,6 +817,13 @@ namespace MIPSInt
|
||||
int rt = _RT;
|
||||
int pos = _POS;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rt == 0)
|
||||
{
|
||||
PC += 4;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op & 0x3f)
|
||||
{
|
||||
case 0x0: //ext
|
||||
@@ -785,7 +832,7 @@ namespace MIPSInt
|
||||
R(rt) = (R(rs) >> pos) & ((1<<size) - 1);
|
||||
}
|
||||
break;
|
||||
case 0x4: // ins
|
||||
case 0x4: //ins
|
||||
{
|
||||
int size = (_SIZE + 1) - pos;
|
||||
int sourcemask = (1 << size) - 1;
|
||||
|
||||
+110
-40
@@ -84,7 +84,34 @@
|
||||
|
||||
#ifdef __APPLE__
|
||||
using std::isnan;
|
||||
using std::isinf;
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define isnan _isnan
|
||||
#define isinf(x) (!_finite(x) && !_isnan(x))
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
using __captured::isinf;
|
||||
#endif
|
||||
|
||||
// Preserves NaN in first param, takes sign of equal second param.
|
||||
// Technically, std::max may do this but it's undefined.
|
||||
inline float nanmax(float f, float cst)
|
||||
{
|
||||
return f <= cst ? cst : f;
|
||||
}
|
||||
|
||||
// Preserves NaN in first param, takes sign of equal second param.
|
||||
inline float nanmin(float f, float cst)
|
||||
{
|
||||
return f >= cst ? cst : f;
|
||||
}
|
||||
|
||||
// Preserves NaN in first param, takes sign of equal value in others.
|
||||
inline float nanclamp(float f, float lower, float upper)
|
||||
{
|
||||
return nanmin(nanmax(f, lower), upper);
|
||||
}
|
||||
|
||||
void ApplyPrefixST(float *v, u32 data, VectorSize size)
|
||||
{
|
||||
@@ -486,15 +513,16 @@ namespace MIPSInt
|
||||
case 0: d[i] = s[i]; break; //vmov
|
||||
case 1: d[i] = fabsf(s[i]); break; //vabs
|
||||
case 2: d[i] = -s[i]; break; //vneg
|
||||
case 4: if (s[i] < 0) d[i] = 0; else {if(s[i] > 1.0f) d[i] = 1.0f; else d[i] = s[i];} break; // vsat0
|
||||
// vsat0 changes -0.0 to +0.0.
|
||||
case 4: if (s[i] <= 0) d[i] = 0; else {if(s[i] > 1.0f) d[i] = 1.0f; else d[i] = s[i];} break; // vsat0
|
||||
case 5: if (s[i] < -1.0f) d[i] = -1.0f; else {if(s[i] > 1.0f) d[i] = 1.0f; else d[i] = s[i];} break; // vsat1
|
||||
case 16: d[i] = 1.0f / s[i]; break; //vrcp
|
||||
case 17: d[i] = 1.0f / sqrtf(s[i]); break; //vrsq
|
||||
case 18: d[i] = sinf((float)M_PI_2 * s[i]); break; //vsin
|
||||
case 19: d[i] = cosf((float)M_PI_2 * s[i]); break; //vcos
|
||||
case 20: d[i] = powf(2.0f, s[i]); break;
|
||||
case 21: d[i] = logf(s[i])/log(2.0f); break;
|
||||
case 22: d[i] = sqrtf(s[i]); break; //vsqrt
|
||||
case 20: d[i] = powf(2.0f, s[i]); break; //vexp2
|
||||
case 21: d[i] = logf(s[i])/log(2.0f); break; //vlog2
|
||||
case 22: d[i] = fabsf(sqrtf(s[i])); break; //vsqrt
|
||||
case 23: d[i] = asinf(s[i] * (float)M_2_PI); break; //vasin
|
||||
case 24: d[i] = -1.0f / s[i]; break; // vnrcp
|
||||
case 26: d[i] = -sinf((float)M_PI_2 * s[i]); break; // vnsin
|
||||
@@ -519,7 +547,8 @@ namespace MIPSInt
|
||||
ReadVector(s, sz, vs);
|
||||
for (int i = 0; i < GetNumVectorElements(sz); i++)
|
||||
{
|
||||
d[i] = 1.0f - s[i];
|
||||
// Always positive NaN.
|
||||
d[i] = isnan(s[i]) ? fabsf(s[i]) : 1.0f - s[i];
|
||||
}
|
||||
ApplyPrefixD(d, sz);
|
||||
WriteVector(d, sz, vd);
|
||||
@@ -536,13 +565,13 @@ namespace MIPSInt
|
||||
ReadVector(s, sz, vs);
|
||||
int n = GetNumVectorElements(sz);
|
||||
float x = s[0];
|
||||
d[0] = std::min(std::max(0.0f, 1.0f - x), 1.0f);
|
||||
d[1] = std::min(std::max(0.0f, x), 1.0f);
|
||||
d[0] = nanclamp(1.0f - x, 0.0f, 1.0f);
|
||||
d[1] = nanclamp(x, 0.0f, 1.0f);
|
||||
VectorSize outSize = V_Pair;
|
||||
if (n > 1) {
|
||||
float y = s[1];
|
||||
d[2] = std::min(std::max(0.0f, 1.0f - y), 1.0f);
|
||||
d[3] = std::min(std::max(0.0f, y), 1.0f);
|
||||
d[2] = nanclamp(1.0f - y, 0.0f, 1.0f);
|
||||
d[3] = nanclamp(y, 0.0f, 1.0f);
|
||||
outSize = V_Quad;
|
||||
}
|
||||
WriteVector(d, outSize, vd);
|
||||
@@ -616,8 +645,8 @@ namespace MIPSInt
|
||||
int imm = (op >> 16) & 0x1f;
|
||||
float mult = 1.0f/(float)(1 << imm);
|
||||
VectorSize sz = GetVecSize(op);
|
||||
ReadVector((float*)&s, sz, vs);
|
||||
ApplySwizzleS((float*)&s, sz); //TODO: and the mask to kill everything but swizzle
|
||||
ReadVector((float*)&s[0], sz, vs);
|
||||
ApplySwizzleS((float*)&s[0], sz); //TODO: and the mask to kill everything but swizzle
|
||||
for (int i = 0; i < GetNumVectorElements(sz); i++)
|
||||
{
|
||||
d[i] = (float)s[i] * mult;
|
||||
@@ -638,6 +667,7 @@ namespace MIPSInt
|
||||
};
|
||||
|
||||
// magic code from ryg: http://fgiesen.wordpress.com/2012/03/28/half-to-float-done-quic/
|
||||
// See also SSE2 version: https://gist.github.com/rygorous/2144712
|
||||
static FP32 half_to_float_fast5(FP16 h)
|
||||
{
|
||||
static const FP32 magic = { (127 + (127 - 15)) << 23 };
|
||||
@@ -658,6 +688,42 @@ namespace MIPSInt
|
||||
return fp.f;
|
||||
}
|
||||
|
||||
// More magic code: https://gist.github.com/rygorous/2156668
|
||||
static FP16 float_to_half_fast3(FP32 f)
|
||||
{
|
||||
static const FP32 f32infty = { 255 << 23 };
|
||||
static const FP32 f16infty = { 31 << 23 };
|
||||
static const FP32 magic = { 15 << 23 };
|
||||
static const u32 sign_mask = 0x80000000u;
|
||||
static const u32 round_mask = ~0xfffu;
|
||||
FP16 o = { 0 };
|
||||
|
||||
u32 sign = f.u & sign_mask;
|
||||
f.u ^= sign;
|
||||
|
||||
if (f.u >= f32infty.u) // Inf or NaN (all exponent bits set)
|
||||
o.u = (f.u > f32infty.u) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf
|
||||
else // (De)normalized number or zero
|
||||
{
|
||||
f.u &= round_mask;
|
||||
f.f *= magic.f;
|
||||
f.u -= round_mask;
|
||||
if (f.u > f16infty.u) f.u = f16infty.u; // Clamp to signed infinity if overflowed
|
||||
|
||||
o.u = f.u >> 13; // Take the bits!
|
||||
}
|
||||
|
||||
o.u |= sign >> 16;
|
||||
return o;
|
||||
}
|
||||
|
||||
static u16 ShrinkToHalf(float full) {
|
||||
FP32 fp32;
|
||||
fp32.f = full;
|
||||
FP16 fp = float_to_half_fast3(fp32);
|
||||
return fp.u;
|
||||
}
|
||||
|
||||
void Int_Vh2f(u32 op)
|
||||
{
|
||||
u32 s[4];
|
||||
@@ -665,7 +731,8 @@ namespace MIPSInt
|
||||
int vd = _VD;
|
||||
int vs = _VS;
|
||||
VectorSize sz = GetVecSize(op);
|
||||
ReadVector((float*)&s, sz, vs);
|
||||
ReadVector((float*)&s[0], sz, vs);
|
||||
ApplySwizzleS((float*)&s[0], sz);
|
||||
|
||||
VectorSize outsize = V_Pair;
|
||||
switch (sz) {
|
||||
@@ -686,35 +753,40 @@ namespace MIPSInt
|
||||
_dbg_assert_msg_(CPU, 0, "Trying to interpret Int_Vh2f instruction that can't be interpreted");
|
||||
break;
|
||||
}
|
||||
ApplyPrefixD(d, sz); //TODO: and the mask to kill everything but mask
|
||||
WriteVector(d, sz, vd);
|
||||
ApplyPrefixD(d, outsize);
|
||||
WriteVector(d, outsize, vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
|
||||
void Int_Vf2h(u32 op)
|
||||
{
|
||||
_dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted");
|
||||
// See http://stackoverflow.com/questions/1659440/32-bit-to-16-bit-floating-point-conversion
|
||||
|
||||
/*
|
||||
int s[4];
|
||||
float d[4];
|
||||
float s[4];
|
||||
u32 d[4];
|
||||
int vd = _VD;
|
||||
int vs = _VS;
|
||||
int imm = (op >> 16) & 0x1f;
|
||||
float mult = 1.0f/(float)(1 << imm);
|
||||
VectorSize sz = GetVecSize(op);
|
||||
ReadVector((float*)&s, sz, vs);
|
||||
ApplySwizzleS((float*)&s, sz); //TODO: and the mask to kill everything but swizzle
|
||||
ReadVector(s, sz, vs);
|
||||
ApplySwizzleS(s, sz);
|
||||
|
||||
for (int i = 0; i < GetNumVectorElements(sz); i++)
|
||||
{
|
||||
d[i] = (float)s[i] * mult;
|
||||
VectorSize outsize = V_Single;
|
||||
switch (sz) {
|
||||
case V_Pair:
|
||||
outsize = V_Single;
|
||||
d[0] = ShrinkToHalf(s[0]) | ((u32)ShrinkToHalf(s[1]) << 16);
|
||||
break;
|
||||
case V_Quad:
|
||||
outsize = V_Pair;
|
||||
d[0] = ShrinkToHalf(s[0]) | ((u32)ShrinkToHalf(s[1]) << 16);
|
||||
d[1] = ShrinkToHalf(s[2]) | ((u32)ShrinkToHalf(s[3]) << 16);
|
||||
break;
|
||||
case V_Single:
|
||||
case V_Triple:
|
||||
_dbg_assert_msg_(CPU, 0, "Trying to interpret Int_Vf2h instruction that can't be interpreted");
|
||||
break;
|
||||
}
|
||||
ApplyPrefixD(d, sz); //TODO: and the mask to kill everything but mask
|
||||
WriteVector(d, sz, vd);
|
||||
*/
|
||||
ApplyPrefixD((float*)&d[0], outsize);
|
||||
WriteVector((float*)&d[0], outsize, vd);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
}
|
||||
@@ -954,7 +1026,7 @@ namespace MIPSInt
|
||||
{
|
||||
sum += (i == n - 1) ? t[i] : s[i]*t[i];
|
||||
}
|
||||
d = sum;
|
||||
d = isnan(sum) ? fabsf(sum) : sum;
|
||||
ApplyPrefixD(&d,V_Single);
|
||||
V(vd) = d;
|
||||
PC += 4;
|
||||
@@ -1452,10 +1524,6 @@ namespace MIPSInt
|
||||
VC_NS
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
|
||||
void Int_Vcmp(u32 op)
|
||||
{
|
||||
int vs = _VS;
|
||||
@@ -1491,16 +1559,18 @@ namespace MIPSInt
|
||||
|
||||
case VC_EZ: c = s[i] == 0.0f || s[i] == -0.0f; break;
|
||||
case VC_EN: c = isnan(s[i]); break;
|
||||
case VC_EI: c = 0; break;
|
||||
case VC_ES: c = (s[i] != s[i]) || (s[i] == std::numeric_limits<float>::infinity()); break; // Tekken Dark Resurrection
|
||||
case VC_EI: c = isinf(s[i]); break;
|
||||
case VC_ES: c = isnan(s[i]) || isinf(s[i]); break; // Tekken Dark Resurrection
|
||||
|
||||
case VC_NZ: c = s[i] != 0; break;
|
||||
case VC_NN: c = s[i] != 0; break;
|
||||
case VC_NI: c = s[i] != 0; break;
|
||||
case VC_NS: c = s[i] != 0; break;
|
||||
case VC_NN: c = !isnan(s[i]); break;
|
||||
case VC_NI: c = !isinf(s[i]); break;
|
||||
case VC_NS: c = !isnan(s[i]) && !isinf(s[i]); break;
|
||||
|
||||
default:
|
||||
_dbg_assert_msg_(CPU,0,"Unsupported vcmp condition code %d", cond);
|
||||
PC += 4;
|
||||
EatPrefixes();
|
||||
return;
|
||||
}
|
||||
cc |= (c<<i);
|
||||
|
||||
+31
-31
@@ -194,8 +194,8 @@ const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxx
|
||||
INSTR("mtlo", &Jit::Comp_MulDivType, Dis_ToHiloTransfer, Int_MulDivType, IN_RS|OUT_OTHER),
|
||||
{-2},
|
||||
{-2},
|
||||
INSTR("clz", &Jit::Comp_Generic, Dis_RType2, Int_RType2, OUT_RD|IN_RS|IN_RT),
|
||||
INSTR("clo", &Jit::Comp_Generic, Dis_RType2, Int_RType2, OUT_RD|IN_RS|IN_RT),
|
||||
INSTR("clz", &Jit::Comp_RType2, Dis_RType2, Int_RType2, OUT_RD|IN_RS|IN_RT),
|
||||
INSTR("clo", &Jit::Comp_RType2, Dis_RType2, Int_RType2, OUT_RD|IN_RS|IN_RT),
|
||||
|
||||
//24
|
||||
INSTR("mult", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER),
|
||||
@@ -492,7 +492,7 @@ const MIPSInstruction tableVFPU1[8] =
|
||||
INSTR("vdot",&Jit::Comp_VDot, Dis_VectorDot, Int_VDot, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vscl",&Jit::Comp_Generic, Dis_VScl, Int_VScl, IS_VFPU|OUT_EAT_PREFIX),
|
||||
{-2},
|
||||
INSTR("vhdp",&Jit::Comp_Generic, Dis_Generic, Int_VHdp, IS_VFPU),
|
||||
INSTR("vhdp",&Jit::Comp_Generic, Dis_Generic, Int_VHdp, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vcrs",&Jit::Comp_Generic, Dis_Vcrs, Int_Vcrs, IS_VFPU),
|
||||
INSTR("vdet",&Jit::Comp_Generic, Dis_Generic, Int_Vdet, IS_VFPU),
|
||||
{-2},
|
||||
@@ -582,31 +582,31 @@ const MIPSInstruction tableVFPU7[32] =
|
||||
// 110100 00000 10111 0000000000000000
|
||||
const MIPSInstruction tableVFPU4[32] = //110100 00000 xxxxx
|
||||
{
|
||||
INSTR("vmov", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vabs", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vneg", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmov", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vabs", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vneg", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vidt", &Jit::Comp_Generic, Dis_VectorSet1, Int_Vidt,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsat0", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsat1", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vzero", &Jit::Comp_Generic, Dis_VectorSet1, Int_VVectorInit, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vone", &Jit::Comp_Generic, Dis_VectorSet1, Int_VVectorInit, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsat0", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsat1", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vzero", &Jit::Comp_VVectorInit, Dis_VectorSet1, Int_VVectorInit, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vone", &Jit::Comp_VVectorInit, Dis_VectorSet1, Int_VVectorInit, IS_VFPU|OUT_EAT_PREFIX),
|
||||
//8
|
||||
{-2},{-2},{-2},{-2},{-2},{-2},{-2},{-2},
|
||||
//16
|
||||
INSTR("vrcp", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vrsq", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsin", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vcos", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vexp2", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vlog2", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsqrt", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vasin", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vrcp", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vrsq", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vcos", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vexp2", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vlog2", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vsqrt", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vasin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
//24
|
||||
INSTR("vnrcp", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vnrcp", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
{-2},
|
||||
INSTR("vnsin", &Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vnsin", &Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op,IS_VFPU|OUT_EAT_PREFIX),
|
||||
{-2},
|
||||
INSTR("vrexp2",&Jit::Comp_Generic, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vrexp2",&Jit::Comp_VV2Op, Dis_VectorSet2, Int_VV2Op, IS_VFPU|OUT_EAT_PREFIX),
|
||||
{-2},{-2},{-2},
|
||||
//32
|
||||
};
|
||||
@@ -619,8 +619,8 @@ MIPSInstruction tableVFPU5[8] = //110111 xxx
|
||||
INSTR("vpfxt",&Jit::Comp_VPFX, Dis_VPFXST, Int_VPFX, IS_VFPU),
|
||||
INSTR("vpfxd", &Jit::Comp_VPFX, Dis_VPFXD, Int_VPFX, IS_VFPU),
|
||||
INSTR("vpfxd", &Jit::Comp_VPFX, Dis_VPFXD, Int_VPFX, IS_VFPU),
|
||||
INSTR("viim.s",&Jit::Comp_Generic, Dis_Viim,Int_Viim, IS_VFPU),
|
||||
INSTR("vfim.s",&Jit::Comp_Generic, Dis_Viim,Int_Viim, IS_VFPU),
|
||||
INSTR("viim.s",&Jit::Comp_Generic, Dis_Viim,Int_Viim, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vfim.s",&Jit::Comp_Generic, Dis_Viim,Int_Viim, IS_VFPU|OUT_EAT_PREFIX),
|
||||
};
|
||||
|
||||
const MIPSInstruction tableVFPU6[32] = //111100 xxx
|
||||
@@ -669,7 +669,7 @@ const MIPSInstruction tableVFPU6[32] = //111100 xxx
|
||||
|
||||
const MIPSInstruction tableVFPUMatrixSet1[16] = //111100 11100 0xxxx (rm x is 16)
|
||||
{
|
||||
INSTR("vmmov",&Jit::Comp_Generic, Dis_MatrixSet2, Int_Vmmov, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vmmov",&Jit::Comp_Vmmov, Dis_MatrixSet2, Int_Vmmov, IS_VFPU|OUT_EAT_PREFIX),
|
||||
{-2},
|
||||
{-2},
|
||||
INSTR("vmidt",&Jit::Comp_Generic, Dis_MatrixSet1, Int_VMatrixInit, IS_VFPU|OUT_EAT_PREFIX),
|
||||
@@ -690,14 +690,14 @@ const MIPSInstruction tableVFPU9[32] = //110100 00010 xxxxx
|
||||
INSTR("vbfy1", &Jit::Comp_Generic, Dis_Vbfy, Int_Vbfy, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vbfy2", &Jit::Comp_Generic, Dis_Vbfy, Int_Vbfy, IS_VFPU|OUT_EAT_PREFIX),
|
||||
//4
|
||||
INSTR("vocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vocp, IS_VFPU), // one's complement
|
||||
INSTR("vsocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsocp, IS_VFPU),
|
||||
INSTR("vocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vocp, IS_VFPU|OUT_EAT_PREFIX), // one's complement
|
||||
INSTR("vsocp", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsocp, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vfad", &Jit::Comp_Generic, Dis_Vfad, Int_Vfad, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vavg", &Jit::Comp_Generic, Dis_Vfad, Int_Vavg, IS_VFPU),
|
||||
//8
|
||||
INSTR("vsrt3", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt3, IS_VFPU),
|
||||
INSTR("vsrt4", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsrt4, IS_VFPU),
|
||||
INSTR("vsgn", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsgn, IS_VFPU),
|
||||
INSTR("vsgn", &Jit::Comp_Generic, Dis_Vbfy, Int_Vsgn, IS_VFPU|OUT_EAT_PREFIX),
|
||||
{-2},
|
||||
//12
|
||||
{-2},
|
||||
@@ -715,9 +715,9 @@ const MIPSInstruction tableVFPU9[32] = //110100 00010 xxxxx
|
||||
{-2},{-2},{-2},{-2},
|
||||
//24
|
||||
{-2},
|
||||
INSTR("vt4444", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU),
|
||||
INSTR("vt5551", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU),
|
||||
INSTR("vt5650", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU),
|
||||
INSTR("vt4444", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vt5551", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU|OUT_EAT_PREFIX),
|
||||
INSTR("vt5650", &Jit::Comp_Generic, Dis_Generic, Int_ColorConv, IS_VFPU|OUT_EAT_PREFIX),
|
||||
|
||||
//28
|
||||
{-2},{-2},{-2},{-2},
|
||||
@@ -738,7 +738,7 @@ const MIPSInstruction tableALLEGREX0[32] = //111111
|
||||
{-2},
|
||||
{-2},
|
||||
//20
|
||||
INSTR("bitrev",&Jit::Comp_Generic, Dis_Allegrex,Int_Allegrex, IN_RT|OUT_RD),
|
||||
INSTR("bitrev",&Jit::Comp_Allegrex, Dis_Allegrex,Int_Allegrex, IN_RT|OUT_RD),
|
||||
{-2},
|
||||
{-2},
|
||||
{-2},
|
||||
|
||||
@@ -246,6 +246,7 @@ MatrixSize GetMtxSize(u32 op)
|
||||
a += (b<<1);
|
||||
switch (a)
|
||||
{
|
||||
case 0: ERROR_LOG(CPU, "Unexpected matrix size 1x1."); return M_2x2;
|
||||
case 1: return M_2x2;
|
||||
case 2: return M_3x3;
|
||||
case 3: return M_4x4;
|
||||
|
||||
@@ -129,13 +129,7 @@ void AsmRoutineManager::Generate(MIPSState *mips, MIPSComp::Jit *jit)
|
||||
SetJumpTarget(notfound);
|
||||
|
||||
//Ok, no block, let's jit
|
||||
#ifdef _M_IX86
|
||||
ABI_AlignStack(0);
|
||||
CALL(reinterpret_cast<void *>(&Jit));
|
||||
ABI_RestoreStack(0);
|
||||
#elif _M_X64
|
||||
CALL((void *)&Jit);
|
||||
#endif
|
||||
ABI_CallFunction((void *)&Jit);
|
||||
JMP(dispatcherNoCheck); // Let's just dispatch again, we'll enter the block since we know it's there.
|
||||
|
||||
SetJumpTarget(bail);
|
||||
|
||||
+394
-65
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "Jit.h"
|
||||
#include "RegCache.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace MIPSAnalyst;
|
||||
#define _RS ((op>>21) & 0x1F)
|
||||
@@ -77,16 +78,26 @@ namespace MIPSComp
|
||||
|
||||
gpr.Lock(rt, rs);
|
||||
gpr.BindToRegister(rt, rt == rs, true);
|
||||
if (rt != rs)
|
||||
if (rt == rs || gpr.R(rs).IsSimpleReg())
|
||||
LEA(32, gpr.RX(rt), MDisp(gpr.RX(rs), simm));
|
||||
else
|
||||
{
|
||||
MOV(32, gpr.R(rt), gpr.R(rs));
|
||||
if (simm != 0)
|
||||
ADD(32, gpr.R(rt), Imm32((u32)(s32)simm));
|
||||
// TODO: Can also do LEA if both operands happen to be in registers.
|
||||
if (simm != 0)
|
||||
ADD(32, gpr.R(rt), Imm32((u32)(s32)simm));
|
||||
}
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
break;
|
||||
|
||||
case 10: // R(rt) = (s32)R(rs) < simm; break; //slti
|
||||
// There's a mips compiler out there asking it already knows the answer to...
|
||||
if (gpr.IsImmediate(rs))
|
||||
{
|
||||
gpr.SetImmediate32(rt, (s32)gpr.GetImmediate32(rs) < simm);
|
||||
break;
|
||||
}
|
||||
|
||||
gpr.Lock(rt, rs);
|
||||
gpr.BindToRegister(rs, true, false);
|
||||
gpr.BindToRegister(rt, rt == rs, true);
|
||||
@@ -98,6 +109,12 @@ namespace MIPSComp
|
||||
break;
|
||||
|
||||
case 11: // R(rt) = R(rs) < uimm; break; //sltiu
|
||||
if (gpr.IsImmediate(rs))
|
||||
{
|
||||
gpr.SetImmediate32(rt, gpr.GetImmediate32(rs) < uimm);
|
||||
break;
|
||||
}
|
||||
|
||||
gpr.Lock(rt, rs);
|
||||
gpr.BindToRegister(rs, true, false);
|
||||
gpr.BindToRegister(rt, rt == rs, true);
|
||||
@@ -141,6 +158,29 @@ namespace MIPSComp
|
||||
}
|
||||
}
|
||||
|
||||
void Jit::Comp_RType2(u32 op)
|
||||
{
|
||||
CONDITIONAL_DISABLE;
|
||||
int rs = _RS;
|
||||
int rd = _RD;
|
||||
|
||||
// Don't change $zr.
|
||||
if (rd == 0)
|
||||
return;
|
||||
|
||||
switch (op & 63)
|
||||
{
|
||||
case 22: //clz
|
||||
DISABLE;
|
||||
break;
|
||||
case 23: //clo
|
||||
DISABLE;
|
||||
break;
|
||||
default:
|
||||
DISABLE;
|
||||
}
|
||||
}
|
||||
|
||||
static u32 RType3_ImmAdd(const u32 a, const u32 b)
|
||||
{
|
||||
return a + b;
|
||||
@@ -180,17 +220,37 @@ namespace MIPSComp
|
||||
return;
|
||||
}
|
||||
|
||||
// Act like zero was used if the operand is equivalent. This happens.
|
||||
if (gpr.IsImmediate(rs) && gpr.GetImmediate32(rs) == 0)
|
||||
rs = 0;
|
||||
if (gpr.IsImmediate(rt) && gpr.GetImmediate32(rt) == 0)
|
||||
rt = 0;
|
||||
|
||||
gpr.Lock(rt, rs, rd);
|
||||
// Optimize out + 0 and | 0.
|
||||
if ((doImm == &RType3_ImmAdd || doImm == &RType3_ImmOr) && (rs == 0 || rt == 0))
|
||||
// Optimize out operations against 0... and is the only one that isn't a MOV.
|
||||
if (rt == 0 || (rs == 0 && doImm != &RType3_ImmSub))
|
||||
{
|
||||
int rsource = rt == 0 ? rs : rt;
|
||||
if (rsource != rd)
|
||||
if (doImm == &RType3_ImmAnd)
|
||||
gpr.SetImmediate32(rd, 0);
|
||||
else
|
||||
{
|
||||
gpr.BindToRegister(rd, false, true);
|
||||
MOV(32, gpr.R(rd), gpr.R(rsource));
|
||||
int rsource = rt == 0 ? rs : rt;
|
||||
if (rsource != rd)
|
||||
{
|
||||
gpr.BindToRegister(rd, false, true);
|
||||
MOV(32, gpr.R(rd), gpr.R(rsource));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gpr.IsImmediate(rt))
|
||||
{
|
||||
// No temporary needed.
|
||||
u32 rtval = gpr.GetImmediate32(rt);
|
||||
gpr.BindToRegister(rd, rs == rd, true);
|
||||
if (rs != rd)
|
||||
MOV(32, gpr.R(rd), gpr.R(rs));
|
||||
(this->*arith)(32, gpr.R(rd), Imm32(rtval));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use EAX as a temporary if we'd overwrite it.
|
||||
@@ -218,15 +278,63 @@ namespace MIPSComp
|
||||
|
||||
switch (op & 63)
|
||||
{
|
||||
//case 10: if (!R(rt)) R(rd) = R(rs); break; //movz
|
||||
//case 11: if (R(rt)) R(rd) = R(rs); break; //movn
|
||||
case 10: //if (R(rt) == 0) R(rd) = R(rs); break; //movz
|
||||
if (rd == rs)
|
||||
break;
|
||||
gpr.Lock(rt, rs, rd);
|
||||
if (!gpr.IsImmediate(rt))
|
||||
{
|
||||
gpr.KillImmediate(rs, true, false);
|
||||
// Need to load rd in case the condition fails.
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
CMP(32, gpr.R(rt), Imm32(0));
|
||||
CMOVcc(32, gpr.RX(rd), gpr.R(rs), CC_E);
|
||||
}
|
||||
else if (gpr.GetImmediate32(rt) == 0)
|
||||
{
|
||||
// Yes, this actually happens.
|
||||
if (gpr.IsImmediate(rs))
|
||||
gpr.SetImmediate32(rd, gpr.GetImmediate32(rs));
|
||||
else if (rd != rs)
|
||||
{
|
||||
gpr.BindToRegister(rd, false, true);
|
||||
MOV(32, gpr.R(rd), gpr.R(rs));
|
||||
}
|
||||
}
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
// case 32: //R(rd) = R(rs) + R(rt); break; //add
|
||||
case 11: //if (R(rt) != 0) R(rd) = R(rs); break; //movn
|
||||
if (rd == rs)
|
||||
break;
|
||||
gpr.Lock(rt, rs, rd);
|
||||
if (!gpr.IsImmediate(rt))
|
||||
{
|
||||
gpr.KillImmediate(rs, true, false);
|
||||
// Need to load rd in case the condition fails.
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
CMP(32, gpr.R(rt), Imm32(0));
|
||||
CMOVcc(32, gpr.RX(rd), gpr.R(rs), CC_NE);
|
||||
}
|
||||
else if (gpr.GetImmediate32(rt) != 0)
|
||||
{
|
||||
if (gpr.IsImmediate(rs))
|
||||
gpr.SetImmediate32(rd, gpr.GetImmediate32(rs));
|
||||
else if (rd != rs)
|
||||
{
|
||||
gpr.BindToRegister(rd, false, true);
|
||||
MOV(32, gpr.R(rd), gpr.R(rs));
|
||||
}
|
||||
}
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
case 32: //R(rd) = R(rs) + R(rt); break; //add
|
||||
case 33: //R(rd) = R(rs) + R(rt); break; //addu
|
||||
CompTriArith(op, &XEmitter::ADD, &RType3_ImmAdd);
|
||||
break;
|
||||
case 34: //R(rd) = R(rs) - R(rt); break; //sub
|
||||
case 35:
|
||||
case 35: //R(rd) = R(rs) - R(rt); break; //subu
|
||||
CompTriArith(op, &XEmitter::SUB, &RType3_ImmSub);
|
||||
break;
|
||||
case 36: //R(rd) = R(rs) & R(rt); break; //and
|
||||
@@ -248,45 +356,111 @@ namespace MIPSComp
|
||||
break;
|
||||
|
||||
case 42: //R(rd) = (int)R(rs) < (int)R(rt); break; //slt
|
||||
gpr.Lock(rt, rs, rd);
|
||||
gpr.BindToRegister(rs, true, true);
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
XOR(32, R(EAX), R(EAX));
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_L, R(EAX));
|
||||
MOV(32, gpr.R(rd), R(EAX));
|
||||
gpr.UnlockAll();
|
||||
if (gpr.IsImmediate(rs) && gpr.IsImmediate(rt))
|
||||
gpr.SetImmediate32(rd, (s32)gpr.GetImmediate32(rs) < (s32)gpr.GetImmediate32(rt));
|
||||
else
|
||||
{
|
||||
gpr.Lock(rt, rs, rd);
|
||||
gpr.BindToRegister(rs, true, false);
|
||||
gpr.BindToRegister(rd, rd == rt, true);
|
||||
XOR(32, R(EAX), R(EAX));
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_L, R(EAX));
|
||||
MOV(32, gpr.R(rd), R(EAX));
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
break;
|
||||
|
||||
case 43: //R(rd) = R(rs) < R(rt); break; //sltu
|
||||
gpr.Lock(rd, rs, rt);
|
||||
gpr.BindToRegister(rs, true, true);
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
XOR(32, R(EAX), R(EAX));
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_B, R(EAX));
|
||||
MOV(32, gpr.R(rd), R(EAX));
|
||||
gpr.UnlockAll();
|
||||
if (gpr.IsImmediate(rs) && gpr.IsImmediate(rt))
|
||||
gpr.SetImmediate32(rd, gpr.GetImmediate32(rs) < gpr.GetImmediate32(rt));
|
||||
else
|
||||
{
|
||||
gpr.Lock(rd, rs, rt);
|
||||
gpr.BindToRegister(rs, true, false);
|
||||
gpr.BindToRegister(rd, rd == rt, true);
|
||||
XOR(32, R(EAX), R(EAX));
|
||||
CMP(32, gpr.R(rs), gpr.R(rt));
|
||||
SETcc(CC_B, R(EAX));
|
||||
MOV(32, gpr.R(rd), R(EAX));
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
break;
|
||||
|
||||
// case 44: R(rd) = (R(rs) > R(rt)) ? R(rs) : R(rt); break; //max
|
||||
// CMP(a,b); CMOVLT(a,b)
|
||||
case 44: //R(rd) = (R(rs) > R(rt)) ? R(rs) : R(rt); break; //max
|
||||
if (gpr.IsImmediate(rs) && gpr.IsImmediate(rt))
|
||||
gpr.SetImmediate32(rd, std::max((s32)gpr.GetImmediate32(rs), (s32)gpr.GetImmediate32(rt)));
|
||||
else
|
||||
{
|
||||
int rsrc = rd == rt ? rs : rt;
|
||||
gpr.Lock(rd, rs, rt);
|
||||
gpr.KillImmediate(rsrc, true, false);
|
||||
gpr.BindToRegister(rd, rd == rs || rd == rt, true);
|
||||
if (rd != rt && rd != rs)
|
||||
MOV(32, gpr.R(rd), gpr.R(rs));
|
||||
CMP(32, gpr.R(rd), gpr.R(rsrc));
|
||||
CMOVcc(32, gpr.RX(rd), gpr.R(rsrc), CC_L);
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
break;
|
||||
|
||||
case 45: //R(rd) = (R(rs) < R(rt)) ? R(rs) : R(rt); break; //min
|
||||
if (gpr.IsImmediate(rs) && gpr.IsImmediate(rt))
|
||||
gpr.SetImmediate32(rd, std::min((s32)gpr.GetImmediate32(rs), (s32)gpr.GetImmediate32(rt)));
|
||||
else
|
||||
{
|
||||
int rsrc = rd == rt ? rs : rt;
|
||||
gpr.Lock(rd, rs, rt);
|
||||
gpr.KillImmediate(rsrc, true, false);
|
||||
gpr.BindToRegister(rd, rd == rs || rd == rt, true);
|
||||
if (rd != rt && rd != rs)
|
||||
MOV(32, gpr.R(rd), gpr.R(rs));
|
||||
CMP(32, gpr.R(rd), gpr.R(rsrc));
|
||||
CMOVcc(32, gpr.RX(rd), gpr.R(rsrc), CC_G);
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
break;
|
||||
|
||||
// case 45: R(rd) = (R(rs) < R(rt)) ? R(rs) : R(rt); break; //min
|
||||
// CMP(a,b); CMOVGT(a,b)
|
||||
default:
|
||||
Comp_Generic(op);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static u32 ShiftType_ImmLogicalLeft(const u32 a, const u32 b)
|
||||
{
|
||||
return a << (b & 0x1f);
|
||||
}
|
||||
|
||||
void Jit::CompShiftImm(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg))
|
||||
static u32 ShiftType_ImmLogicalRight(const u32 a, const u32 b)
|
||||
{
|
||||
return a >> (b & 0x1f);
|
||||
}
|
||||
|
||||
static u32 ShiftType_ImmArithRight(const u32 a, const u32 b)
|
||||
{
|
||||
return ((s32) a) >> (b & 0x1f);
|
||||
}
|
||||
|
||||
static u32 ShiftType_ImmRotateRight(const u32 a, const u32 b)
|
||||
{
|
||||
const s8 sa = b & 0x1f;
|
||||
return (a >> sa) | (a << (32 - sa));
|
||||
}
|
||||
|
||||
void Jit::CompShiftImm(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg), u32 (*doImm)(const u32, const u32))
|
||||
{
|
||||
int rd = _RD;
|
||||
int rt = _RT;
|
||||
gpr.Lock(rd, rt);
|
||||
int sa = _SA;
|
||||
|
||||
if (doImm && gpr.IsImmediate(rt))
|
||||
{
|
||||
gpr.SetImmediate32(rd, doImm(gpr.GetImmediate32(rt), sa));
|
||||
return;
|
||||
}
|
||||
|
||||
gpr.Lock(rd, rt);
|
||||
gpr.BindToRegister(rd, rd == rt, true);
|
||||
if (rd != rt)
|
||||
MOV(32, gpr.R(rd), gpr.R(rt));
|
||||
@@ -295,38 +469,56 @@ namespace MIPSComp
|
||||
}
|
||||
|
||||
// "over-shifts" work the same as on x86 - only bottom 5 bits are used to get the shift value
|
||||
void Jit::CompShiftVar(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg))
|
||||
void Jit::CompShiftVar(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg), u32 (*doImm)(const u32, const u32))
|
||||
{
|
||||
int rd = _RD;
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
gpr.FlushLockX(ECX);
|
||||
|
||||
if (doImm && gpr.IsImmediate(rs) && gpr.IsImmediate(rt))
|
||||
{
|
||||
gpr.SetImmediate32(rd, doImm(gpr.GetImmediate32(rt), gpr.GetImmediate32(rs)));
|
||||
return;
|
||||
}
|
||||
|
||||
gpr.Lock(rd, rt, rs);
|
||||
gpr.BindToRegister(rd, rd == rt || rd == rs, true);
|
||||
MOV(32, R(ECX), gpr.R(rs)); // Only ECX can be used for variable shifts.
|
||||
AND(32, R(ECX), Imm32(0x1f));
|
||||
if (rd != rt)
|
||||
MOV(32, gpr.R(rd), gpr.R(rt));
|
||||
(this->*shift)(32, gpr.R(rd), R(ECX));
|
||||
if (gpr.IsImmediate(rs))
|
||||
{
|
||||
int sa = gpr.GetImmediate32(rs);
|
||||
gpr.BindToRegister(rd, rd == rt, true);
|
||||
if (rd != rt)
|
||||
MOV(32, gpr.R(rd), gpr.R(rt));
|
||||
(this->*shift)(32, gpr.R(rd), Imm8(sa));
|
||||
}
|
||||
else
|
||||
{
|
||||
gpr.FlushLockX(ECX);
|
||||
gpr.BindToRegister(rd, rd == rt || rd == rs, true);
|
||||
MOV(32, R(ECX), gpr.R(rs)); // Only ECX can be used for variable shifts.
|
||||
AND(32, R(ECX), Imm32(0x1f));
|
||||
if (rd != rt)
|
||||
MOV(32, gpr.R(rd), gpr.R(rt));
|
||||
(this->*shift)(32, gpr.R(rd), R(ECX));
|
||||
gpr.UnlockAllX();
|
||||
}
|
||||
gpr.UnlockAll();
|
||||
gpr.UnlockAllX();
|
||||
}
|
||||
|
||||
void Jit::Comp_ShiftType(u32 op)
|
||||
{
|
||||
CONDITIONAL_DISABLE
|
||||
CONDITIONAL_DISABLE;
|
||||
int rs = _RS;
|
||||
int fd = _FD;
|
||||
// WARNIGN : ROTR
|
||||
switch (op & 0x3f)
|
||||
{
|
||||
case 0: CompShiftImm(op, &XEmitter::SHL); break;
|
||||
case 2: CompShiftImm(op, rs == 1 ? &XEmitter::ROR : &XEmitter::SHR); break; // srl, rotr
|
||||
case 3: CompShiftImm(op, &XEmitter::SAR); break; // sra
|
||||
case 0: CompShiftImm(op, &XEmitter::SHL, &ShiftType_ImmLogicalLeft); break;
|
||||
case 2: CompShiftImm(op, rs == 1 ? &XEmitter::ROR : &XEmitter::SHR, rs == 1 ? &ShiftType_ImmRotateRight : &ShiftType_ImmLogicalRight); break; // srl, rotr
|
||||
case 3: CompShiftImm(op, &XEmitter::SAR, &ShiftType_ImmArithRight); break; // sra
|
||||
|
||||
case 4: CompShiftVar(op, &XEmitter::SHL); break; //sllv
|
||||
case 6: CompShiftVar(op, fd == 1 ? &XEmitter::ROR : &XEmitter::SHR); break; //srlv
|
||||
case 7: CompShiftVar(op, &XEmitter::SAR); break; //srav
|
||||
case 4: CompShiftVar(op, &XEmitter::SHL, &ShiftType_ImmLogicalLeft); break; //sllv
|
||||
case 6: CompShiftVar(op, fd == 1 ? &XEmitter::ROR : &XEmitter::SHR, fd == 1 ? &ShiftType_ImmRotateRight : &ShiftType_ImmLogicalRight); break; //srlv
|
||||
case 7: CompShiftVar(op, &XEmitter::SAR, &ShiftType_ImmArithRight); break; //srav
|
||||
|
||||
default:
|
||||
Comp_Generic(op);
|
||||
@@ -337,8 +529,69 @@ namespace MIPSComp
|
||||
|
||||
void Jit::Comp_Special3(u32 op)
|
||||
{
|
||||
// ext, ins
|
||||
DISABLE;
|
||||
CONDITIONAL_DISABLE;
|
||||
int rs = _RS;
|
||||
int rt = _RT;
|
||||
int pos = _POS;
|
||||
|
||||
int size = _SIZE + 1;
|
||||
u32 mask = 0xFFFFFFFFUL >> (32 - size);
|
||||
|
||||
// Don't change $zr.
|
||||
if (rt == 0)
|
||||
return;
|
||||
|
||||
switch (op & 0x3f)
|
||||
{
|
||||
case 0x0: //ext
|
||||
if (gpr.IsImmediate(rs))
|
||||
{
|
||||
gpr.SetImmediate32(rt, (gpr.GetImmediate32(rs) >> pos) & mask);
|
||||
return;
|
||||
}
|
||||
|
||||
gpr.Lock(rs, rt);
|
||||
gpr.BindToRegister(rt, rs == rt, true);
|
||||
if (rs != rt)
|
||||
MOV(32, gpr.R(rt), gpr.R(rs));
|
||||
SHR(32, gpr.R(rt), Imm8(pos));
|
||||
AND(32, gpr.R(rt), Imm32(mask));
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
case 0x4: //ins
|
||||
{
|
||||
u32 sourcemask = mask >> pos;
|
||||
u32 destmask = ~(sourcemask << pos);
|
||||
if (gpr.IsImmediate(rs))
|
||||
{
|
||||
u32 inserted = (gpr.GetImmediate32(rs) & sourcemask) << pos;
|
||||
if (gpr.IsImmediate(rt))
|
||||
{
|
||||
gpr.SetImmediate32(rt, (gpr.GetImmediate32(rt) & destmask) | inserted);
|
||||
return;
|
||||
}
|
||||
|
||||
gpr.Lock(rs, rt);
|
||||
gpr.BindToRegister(rt, true, true);
|
||||
AND(32, gpr.R(rt), Imm32(destmask));
|
||||
OR(32, gpr.R(rt), Imm32(inserted));
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
gpr.Lock(rs, rt);
|
||||
gpr.BindToRegister(rt, true, true);
|
||||
MOV(32, R(EAX), gpr.R(rs));
|
||||
AND(32, R(EAX), Imm32(sourcemask));
|
||||
SHL(32, R(EAX), Imm8(pos));
|
||||
AND(32, gpr.R(rt), Imm32(destmask));
|
||||
OR(32, gpr.R(rt), R(EAX));
|
||||
gpr.UnlockAll();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -350,23 +603,98 @@ namespace MIPSComp
|
||||
switch ((op >> 6) & 31)
|
||||
{
|
||||
case 16: // seb // R(rd) = (u32)(s32)(s8)(u8)R(rt);
|
||||
gpr.Lock(rd, rt);
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
MOV(32, R(EAX), gpr.R(rt)); // work around the byte-register addressing problem
|
||||
MOVSX(32, 8, gpr.RX(rd), R(EAX));
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
if (gpr.IsImmediate(rt))
|
||||
{
|
||||
gpr.SetImmediate32(rd, (u32)(s32)(s8)(u8)gpr.GetImmediate32(rt));
|
||||
break;
|
||||
}
|
||||
|
||||
case 24: // seh
|
||||
gpr.Lock(rd, rt);
|
||||
// MOVSX doesn't like immediate arguments, for example, so let's force it to a register.
|
||||
gpr.BindToRegister(rt, true, false);
|
||||
gpr.BindToRegister(rd, true, true);
|
||||
MOVSX(32, 16, gpr.RX(rd), gpr.R(rt));
|
||||
gpr.BindToRegister(rd, rd == rt, true);
|
||||
#ifdef _M_IX86
|
||||
// work around the byte-register addressing problem
|
||||
if (!gpr.R(rt).IsSimpleReg(EDX) && !gpr.R(rt).IsSimpleReg(ECX))
|
||||
{
|
||||
MOV(32, R(EAX), gpr.R(rt));
|
||||
MOVSX(32, 8, gpr.RX(rd), R(EAX));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
gpr.KillImmediate(rt, true, false);
|
||||
MOVSX(32, 8, gpr.RX(rd), gpr.R(rt));
|
||||
}
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
case 20: //bitrev
|
||||
if (gpr.IsImmediate(rt))
|
||||
{
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
|
||||
u32 v = gpr.GetImmediate32(rt);
|
||||
// swap odd and even bits
|
||||
v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
|
||||
// swap consecutive pairs
|
||||
v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2);
|
||||
// swap nibbles ...
|
||||
v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4);
|
||||
// swap bytes
|
||||
v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8);
|
||||
// swap 2-byte long pairs
|
||||
v = ( v >> 16 ) | ( v << 16);
|
||||
gpr.SetImmediate32(rd, v);
|
||||
break;
|
||||
}
|
||||
|
||||
gpr.Lock(rd, rt);
|
||||
gpr.BindToRegister(rd, rd == rt, true);
|
||||
if (rd != rt)
|
||||
MOV(32, gpr.R(rd), gpr.R(rt));
|
||||
|
||||
LEA(32, EAX, MScaled(gpr.RX(rd), 2, 0));
|
||||
SHR(32, gpr.R(rd), Imm8(1));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
AND(32, gpr.R(rd), Imm32(0x55555555));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
|
||||
LEA(32, EAX, MScaled(gpr.RX(rd), 4, 0));
|
||||
SHR(32, gpr.R(rd), Imm8(2));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
AND(32, gpr.R(rd), Imm32(0x33333333));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
|
||||
MOV(32, R(EAX), gpr.R(rd));
|
||||
SHL(32, R(EAX), Imm8(4));
|
||||
SHR(32, gpr.R(rd), Imm8(4));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
AND(32, gpr.R(rd), Imm32(0x0F0F0F0F));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
|
||||
MOV(32, R(EAX), gpr.R(rd));
|
||||
SHL(32, R(EAX), Imm8(8));
|
||||
SHR(32, gpr.R(rd), Imm8(8));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
AND(32, gpr.R(rd), Imm32(0x00FF00FF));
|
||||
XOR(32, gpr.R(rd), R(EAX));
|
||||
|
||||
ROL(32, gpr.R(rd), Imm8(16));
|
||||
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
case 24: // seh // R(rd) = (u32)(s32)(s16)(u16)R(rt);
|
||||
if (gpr.IsImmediate(rt))
|
||||
{
|
||||
gpr.SetImmediate32(rd, (u32)(s32)(s16)(u16)gpr.GetImmediate32(rt));
|
||||
break;
|
||||
}
|
||||
|
||||
gpr.Lock(rd, rt);
|
||||
gpr.BindToRegister(rd, rd == rt, true);
|
||||
MOVSX(32, 16, gpr.RX(rd), gpr.R(rt));
|
||||
gpr.UnlockAll();
|
||||
break;
|
||||
|
||||
default:
|
||||
Comp_Generic(op);
|
||||
return;
|
||||
@@ -376,6 +704,7 @@ namespace MIPSComp
|
||||
|
||||
void Jit::Comp_MulDivType(u32 op)
|
||||
{
|
||||
CONDITIONAL_DISABLE;
|
||||
int rt = _RT;
|
||||
int rs = _RS;
|
||||
int rd = _RD;
|
||||
|
||||
@@ -144,7 +144,7 @@ void Jit::BranchRSRTComp(u32 op, Gen::CCFlags cc, bool likely)
|
||||
|
||||
if (rt == 0)
|
||||
{
|
||||
gpr.KillImmediate(rs, true, true);
|
||||
gpr.KillImmediate(rs, true, false);
|
||||
CMP(32, gpr.R(rs), Imm32(0));
|
||||
}
|
||||
else
|
||||
|
||||
+11
-3
@@ -348,6 +348,8 @@ void Jit::WriteExitDestInEAX()
|
||||
CMP(32, R(EAX), Imm32(PSP_GetUserMemoryEnd()));
|
||||
FixupBranch tooHigh = J_CC(CC_GE);
|
||||
|
||||
// Need to set neg flag again if necessary.
|
||||
SUB(32, M(¤tMIPS->downcount), Imm32(0));
|
||||
JMP(asm_.dispatcher, true);
|
||||
|
||||
SetJumpTarget(tooLow);
|
||||
@@ -355,12 +357,18 @@ void Jit::WriteExitDestInEAX()
|
||||
|
||||
ABI_CallFunctionA(thunks.ProtectFunction((void *) Memory::GetPointer, 1), R(EAX));
|
||||
CMP(32, R(EAX), Imm32(0));
|
||||
J_CC(CC_NE, asm_.dispatcher, true);
|
||||
FixupBranch skip = J_CC(CC_NE);
|
||||
|
||||
// TODO: "Ignore" this so other threads can continue?
|
||||
if (g_Config.bIgnoreBadMemAccess)
|
||||
MOV(32, M((void*)&coreState), Imm32(CORE_ERROR));
|
||||
ABI_CallFunctionA(thunks.ProtectFunction((void *) Core_UpdateState, 1), Imm32(CORE_ERROR));
|
||||
|
||||
SUB(32, M(¤tMIPS->downcount), Imm32(0));
|
||||
JMP(asm_.dispatcherCheckCoreState, true);
|
||||
SetJumpTarget(skip);
|
||||
|
||||
SUB(32, M(¤tMIPS->downcount), Imm32(0));
|
||||
J_CC(CC_NE, asm_.dispatcher, true);
|
||||
}
|
||||
else
|
||||
JMP(asm_.dispatcher, true);
|
||||
@@ -378,7 +386,7 @@ bool Jit::CheckJitBreakpoint(u32 addr, int downcountOffset)
|
||||
{
|
||||
FlushAll();
|
||||
MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
|
||||
CALL((void *)&JitBreakpoint);
|
||||
ABI_CallFunction((void *)&JitBreakpoint);
|
||||
|
||||
WriteDowncount(downcountOffset);
|
||||
JMP(asm_.dispatcherCheckCoreState, true);
|
||||
|
||||
+6
-2
@@ -171,6 +171,7 @@ public:
|
||||
void Comp_Break(u32 op);
|
||||
|
||||
void Comp_IType(u32 op);
|
||||
void Comp_RType2(u32 op);
|
||||
void Comp_RType3(u32 op);
|
||||
void Comp_ShiftType(u32 op);
|
||||
void Comp_Allegrex(u32 op);
|
||||
@@ -185,10 +186,13 @@ public:
|
||||
void Comp_SV(u32 op);
|
||||
void Comp_SVQ(u32 op);
|
||||
void Comp_VPFX(u32 op);
|
||||
void Comp_VVectorInit(u32 op);
|
||||
void Comp_VDot(u32 op);
|
||||
void Comp_VecDo3(u32 op);
|
||||
void Comp_VV2Op(u32 op);
|
||||
void Comp_Mftv(u32 op);
|
||||
void Comp_Vmtvc(u32 op);
|
||||
void Comp_Vmmov(u32 op);
|
||||
|
||||
void Comp_DoNothing(u32 op);
|
||||
|
||||
@@ -238,8 +242,8 @@ private:
|
||||
// Utilities to reduce duplicated code
|
||||
void CompImmLogic(u32 op, void (XEmitter::*arith)(int, const OpArg &, const OpArg &));
|
||||
void CompTriArith(u32 op, void (XEmitter::*arith)(int, const OpArg &, const OpArg &), u32 (*doImm)(const u32, const u32));
|
||||
void CompShiftImm(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg));
|
||||
void CompShiftVar(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg));
|
||||
void CompShiftImm(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg), u32 (*doImm)(const u32, const u32));
|
||||
void CompShiftVar(u32 op, void (XEmitter::*shift)(int, OpArg, OpArg), u32 (*doImm)(const u32, const u32));
|
||||
void CompITypeMemRead(u32 op, u32 bits, void (XEmitter::*mov)(int, int, X64Reg, OpArg), void *safeFunc);
|
||||
void CompITypeMemWrite(u32 op, u32 bits, void *safeFunc);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ static const int allocationOrder[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
GPRRegCache::GPRRegCache() : emit(0), mips(0) {
|
||||
GPRRegCache::GPRRegCache() : mips(0), emit(0) {
|
||||
memset(regs, 0, sizeof(regs));
|
||||
memset(xregs, 0, sizeof(xregs));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
u32 FPURegCache::tempValues[NUM_TEMPS];
|
||||
|
||||
FPURegCache::FPURegCache() : emit(0), mips(0) {
|
||||
FPURegCache::FPURegCache() : mips(0), emit(0) {
|
||||
memset(regs, 0, sizeof(regs));
|
||||
memset(xregs, 0, sizeof(xregs));
|
||||
vregs = regs + 32;
|
||||
|
||||
@@ -56,6 +56,10 @@ u8 *GetPointer(const u32 address)
|
||||
else
|
||||
{
|
||||
ERROR_LOG(MEMMAP, "Unknown GetPointer %08x PC %08x LR %08x", address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
|
||||
if (!g_Config.bIgnoreBadMemAccess) {
|
||||
Core_EnableStepping(true);
|
||||
host->SetDebugMode(true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,10 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string)
|
||||
if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.OLD").exists) {
|
||||
bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.OLD";
|
||||
}
|
||||
// bypass another patchers
|
||||
if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.DAT").exists) {
|
||||
bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.DAT";
|
||||
}
|
||||
bool hasEncrypted = false;
|
||||
u32 fd;
|
||||
if ((fd = pspFileSystem.OpenFile(bootpath, FILEACCESS_READ)) != 0)
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ namespace SaveState
|
||||
|
||||
// Don't actually run it until next CoreTiming::Advance().
|
||||
// It's possible there might be a duplicate but it won't hurt us.
|
||||
if (Core_IsStepping() && __KernelIsRunning())
|
||||
if (Core_IsInactive() && __KernelIsRunning())
|
||||
{
|
||||
// Warning: this may run on a different thread.
|
||||
Process(0, 0);
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Log.h"
|
||||
#include "BlockAllocator.h"
|
||||
#include "ChunkFile.h"
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
// Copyright (c) 2012- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -9,8 +25,7 @@
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
// Generic allocator thingy
|
||||
// Allocates blocks from a range
|
||||
// Generic allocator thingy. Allocates blocks from a range.
|
||||
|
||||
class BlockAllocator
|
||||
{
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../Globals.h"
|
||||
|
||||
// pool allocator
|
||||
template <class T, int size>
|
||||
class Pool
|
||||
{
|
||||
T pool[size];
|
||||
int count;
|
||||
public:
|
||||
Pool()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
void Reset()
|
||||
{
|
||||
count=0;
|
||||
}
|
||||
T* Alloc()
|
||||
{
|
||||
_dbg_assert_msg_(CPU,count<size-1,"Pool allocator overrun!");
|
||||
return &pool[count++];
|
||||
}
|
||||
};
|
||||
@@ -48,9 +48,11 @@ static const u8 flushOnChangedBeforeCommandList[] = {
|
||||
GE_CMD_TEXSCALEU,
|
||||
GE_CMD_TEXSCALEV,
|
||||
GE_CMD_CULLFACEENABLE,
|
||||
GE_CMD_CULL,
|
||||
GE_CMD_TEXTUREMAPENABLE,
|
||||
GE_CMD_LIGHTINGENABLE,
|
||||
GE_CMD_FOGENABLE,
|
||||
GE_CMD_DITHERENABLE,
|
||||
GE_CMD_ALPHABLENDENABLE,
|
||||
GE_CMD_ALPHATESTENABLE,
|
||||
GE_CMD_ALPHATEST,
|
||||
@@ -97,9 +99,7 @@ static const u8 flushOnChangedBeforeCommandList[] = {
|
||||
GE_CMD_VIEWPORTX2,GE_CMD_VIEWPORTY2,
|
||||
GE_CMD_VIEWPORTZ1,GE_CMD_VIEWPORTZ2,
|
||||
GE_CMD_LIGHTENABLE0,GE_CMD_LIGHTENABLE1,GE_CMD_LIGHTENABLE2,GE_CMD_LIGHTENABLE3,
|
||||
GE_CMD_CULL,
|
||||
GE_CMD_PATCHDIVISION,
|
||||
GE_CMD_MATERIALUPDATE,
|
||||
GE_CMD_CLEARMODE,
|
||||
GE_CMD_TEXMAPMODE,
|
||||
GE_CMD_TEXSHADELS,
|
||||
@@ -119,6 +119,7 @@ static const u8 flushOnChangedBeforeCommandList[] = {
|
||||
GE_CMD_MASKALPHA,
|
||||
GE_CMD_TEXBUFWIDTH0,
|
||||
GE_CMD_CLUTADDR,
|
||||
GE_CMD_CLUTADDRUPPER,
|
||||
GE_CMD_LOADCLUT,
|
||||
GE_CMD_CLUTFORMAT,
|
||||
GE_CMD_TEXADDR0,GE_CMD_TEXADDR1,GE_CMD_TEXADDR2,GE_CMD_TEXADDR3,
|
||||
@@ -202,8 +203,9 @@ void GLES_GPU::DeviceLost() {
|
||||
|
||||
void GLES_GPU::InitClear() {
|
||||
if (!g_Config.bBufferedRendering) {
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0,0,0,1);
|
||||
// glClearColor(1,0,1,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
@@ -280,26 +282,6 @@ void GLES_GPU::Break() {
|
||||
|
||||
}
|
||||
|
||||
static void EnterClearMode(u32 data) {
|
||||
bool colMask = (data >> 8) & 1;
|
||||
bool alphaMask = (data >> 9) & 1;
|
||||
bool updateZ = (data >> 10) & 1;
|
||||
glstate.colorMask.set(colMask, colMask, colMask, alphaMask);
|
||||
glstate.depthWrite.set(updateZ ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
static void LeaveClearMode() {
|
||||
// We have to reset the following state as per the state of the command registers:
|
||||
// Back face culling
|
||||
// Texture map enable (meh)
|
||||
// Fogging
|
||||
// Antialiasing
|
||||
// Alpha test
|
||||
glstate.colorMask.set(1,1,1,1);
|
||||
glstate.depthWrite.set(!(gstate.zmsk & 1) ? GL_TRUE : GL_FALSE);
|
||||
// dirtyshader?
|
||||
}
|
||||
|
||||
void GLES_GPU::PreExecuteOp(u32 op, u32 diff) {
|
||||
u32 cmd = op >> 24;
|
||||
if (flushBeforeCommand_[cmd] == 1 || (diff && flushBeforeCommand_[cmd] == 2))
|
||||
@@ -542,6 +524,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
||||
break;
|
||||
|
||||
case GE_CMD_CULLFACEENABLE:
|
||||
case GE_CMD_CULL:
|
||||
break;
|
||||
|
||||
case GE_CMD_TEXTUREMAPENABLE:
|
||||
@@ -642,6 +625,7 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
||||
case GE_CMD_CLUTADDR:
|
||||
case GE_CMD_CLUTADDRUPPER:
|
||||
case GE_CMD_LOADCLUT:
|
||||
case GE_CMD_CLUTFORMAT:
|
||||
gstate_c.textureChanged = true;
|
||||
// This could be used to "dirty" textures with clut.
|
||||
break;
|
||||
@@ -650,10 +634,6 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
||||
case GE_CMD_TEXSHADELS:
|
||||
break;
|
||||
|
||||
case GE_CMD_CLUTFORMAT:
|
||||
gstate_c.textureChanged = true;
|
||||
break;
|
||||
|
||||
case GE_CMD_TRANSFERSRC:
|
||||
case GE_CMD_TRANSFERSRCW:
|
||||
case GE_CMD_TRANSFERDST:
|
||||
@@ -807,9 +787,6 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
||||
case GE_CMD_LIGHTENABLE3:
|
||||
break;
|
||||
|
||||
case GE_CMD_CULL:
|
||||
break;
|
||||
|
||||
case GE_CMD_SHADEMODE:
|
||||
break;
|
||||
|
||||
@@ -826,14 +803,8 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
||||
// CLEARING
|
||||
//////////////////////////////////////////////////////////////////
|
||||
case GE_CMD_CLEARMODE:
|
||||
// If it becomes a performance problem, check diff&1
|
||||
if (data & 1)
|
||||
EnterClearMode(data);
|
||||
else
|
||||
LeaveClearMode();
|
||||
break;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// ALPHA BLENDING
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@@ -845,7 +816,12 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
||||
|
||||
case GE_CMD_ALPHATESTENABLE:
|
||||
case GE_CMD_COLORTESTENABLE:
|
||||
// This is done in the shader.
|
||||
// They are done in the fragment shader.
|
||||
break;
|
||||
|
||||
case GE_CMD_COLORTEST:
|
||||
case GE_CMD_COLORTESTMASK:
|
||||
shaderManager_->DirtyUniform(DIRTY_COLORMASK);
|
||||
break;
|
||||
|
||||
case GE_CMD_COLORREF:
|
||||
@@ -992,8 +968,8 @@ void GLES_GPU::UpdateStats() {
|
||||
gpuStats.numVertexShaders = shaderManager_->NumVertexShaders();
|
||||
gpuStats.numFragmentShaders = shaderManager_->NumFragmentShaders();
|
||||
gpuStats.numShaders = shaderManager_->NumPrograms();
|
||||
gpuStats.numTextures = textureCache_.NumLoadedTextures();
|
||||
gpuStats.numFBOs = framebufferManager_.NumVFBs();
|
||||
gpuStats.numTextures = (int)textureCache_.NumLoadedTextures();
|
||||
gpuStats.numFBOs = (int)framebufferManager_.NumVFBs();
|
||||
}
|
||||
|
||||
void GLES_GPU::DoBlockTransfer() {
|
||||
|
||||
@@ -94,6 +94,7 @@ void GenerateFragmentShader(char *buffer)
|
||||
WRITE(p, "uniform sampler2D tex;\n");
|
||||
if (enableAlphaTest || enableColorTest) {
|
||||
WRITE(p, "uniform vec4 u_alphacolorref;\n");
|
||||
WRITE(p, "uniform vec4 u_colormask;\n");
|
||||
}
|
||||
if (gstate.textureMapEnable & 1) {
|
||||
WRITE(p, "uniform vec3 u_texenv;\n");
|
||||
@@ -189,9 +190,8 @@ void GenerateFragmentShader(char *buffer)
|
||||
const char *colorTestFuncs[] = { "#", "#", " == ", " != " }; // never/always don't make sense}
|
||||
int colorTestMask = gstate.colormask;
|
||||
if (colorTestFuncs[colorTestFunc][0] != '#')
|
||||
WRITE(p, "if (!(v.rgb %s u_alphacolorref.rgb)) discard;\n", colorTestFuncs[colorTestFunc]);
|
||||
}*/
|
||||
|
||||
WRITE(p, "if (!(v.rgb %s (u_alphacolorref.rgb & u_colormask.rgb)) discard;\n", colorTestFuncs[colorTestFunc]);
|
||||
}*/
|
||||
if (enableFog) {
|
||||
WRITE(p, " float fogCoef = clamp(v_fogdepth, 0.0, 1.0);\n");
|
||||
WRITE(p, " gl_FragColor = mix(vec4(u_fogcolor, v.a), v, fogCoef);\n");
|
||||
|
||||
@@ -125,7 +125,9 @@ FramebufferManager::FramebufferManager() :
|
||||
|
||||
// And an initial clear. We don't clear per frame as the games are supposed to handle that
|
||||
// by themselves.
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
convBuf = new u8[480 * 272 * 4];
|
||||
@@ -235,7 +237,7 @@ void FramebufferManager::DrawActiveTexture(float x, float y, float w, float h, b
|
||||
glsl_unbind();
|
||||
}
|
||||
|
||||
FramebufferManager::VirtualFramebuffer *FramebufferManager::GetDisplayFBO() {
|
||||
VirtualFramebuffer *FramebufferManager::GetDisplayFBO() {
|
||||
for (auto iter = vfbs_.begin(); iter != vfbs_.end(); ++iter) {
|
||||
VirtualFramebuffer *v = *iter;
|
||||
if (MaskedEqual(v->fb_address, displayFramebufPtr_) && v->format == displayFormat_) {
|
||||
@@ -325,6 +327,7 @@ void FramebufferManager::SetRenderFrameBuffer() {
|
||||
vfb->renderWidth = (u16)(drawing_width * renderWidthFactor);
|
||||
vfb->renderHeight = (u16)(drawing_height * renderHeightFactor);
|
||||
vfb->format = fmt;
|
||||
vfb->usageFlags = FB_USAGE_RENDERTARGET;
|
||||
|
||||
switch (fmt) {
|
||||
case GE_FORMAT_4444: vfb->colorDepth = FBO_4444; break;
|
||||
@@ -333,12 +336,16 @@ void FramebufferManager::SetRenderFrameBuffer() {
|
||||
case GE_FORMAT_8888: vfb->colorDepth = FBO_8888; break;
|
||||
default: vfb->colorDepth = FBO_8888; break;
|
||||
}
|
||||
|
||||
if (g_Config.bTrueColor)
|
||||
vfb->colorDepth = FBO_8888;
|
||||
|
||||
//#ifdef ANDROID
|
||||
// vfb->colorDepth = FBO_8888;
|
||||
//#endif
|
||||
|
||||
vfb->fbo = fbo_create(vfb->renderWidth, vfb->renderHeight, 1, true, vfb->colorDepth);
|
||||
textureCache_->NotifyFramebuffer(vfb->fb_address, vfb->fbo);
|
||||
textureCache_->NotifyFramebuffer(vfb->fb_address, vfb);
|
||||
|
||||
vfb->last_frame_used = gpuStats.numFrames;
|
||||
vfbs_.push_back(vfb);
|
||||
@@ -347,6 +354,9 @@ void FramebufferManager::SetRenderFrameBuffer() {
|
||||
glEnable(GL_DITHER);
|
||||
glstate.viewport.set(0, 0, vfb->renderWidth, vfb->renderHeight);
|
||||
currentRenderVfb_ = vfb;
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
INFO_LOG(HLE, "Creating FBO for %08x : %i x %i x %i", vfb->fb_address, vfb->width, vfb->height, vfb->format);
|
||||
return;
|
||||
@@ -363,15 +373,22 @@ void FramebufferManager::SetRenderFrameBuffer() {
|
||||
vfb->last_frame_used = gpuStats.numFrames;
|
||||
|
||||
fbo_bind_as_render_target(vfb->fbo);
|
||||
|
||||
textureCache_->NotifyFramebuffer(vfb->fb_address, vfb);
|
||||
|
||||
#ifdef USING_GLES2
|
||||
// Some tiled mobile GPUs benefit IMMENSELY from clearing an FBO before rendering
|
||||
// to it. This broke stuff before, so now it only clears on the first use of an
|
||||
// FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs
|
||||
// performance-crushing framebuffer reloads from RAM, but we'll have to live with that.
|
||||
if (vfb->last_frame_used != gpuStats.numFrames)
|
||||
{
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
#endif
|
||||
textureCache_->NotifyFramebuffer(vfb->fb_address, vfb->fbo);
|
||||
glstate.viewport.set(0, 0, vfb->renderWidth, vfb->renderHeight);
|
||||
currentRenderVfb_ = vfb;
|
||||
}
|
||||
@@ -385,6 +402,8 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
if (!vfb) {
|
||||
DEBUG_LOG(HLE, "Found no FBO! displayFBPtr = %08x", displayFramebufPtr_);
|
||||
// No framebuffer to display! Clear to black.
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
return;
|
||||
@@ -403,10 +422,13 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
glstate.cullFace.disable();
|
||||
glstate.depthTest.disable();
|
||||
glstate.scissorTest.disable();
|
||||
|
||||
glstate.stencilTest.disable();
|
||||
|
||||
fbo_bind_color_as_texture(vfb->fbo, 0);
|
||||
|
||||
if (resized_) {
|
||||
glstate.depthWrite.set(GL_TRUE);
|
||||
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
@@ -431,6 +453,8 @@ void FramebufferManager::BeginFrame() {
|
||||
glstate.cullFace.disable();
|
||||
glstate.depthTest.disable();
|
||||
glstate.blend.disable();
|
||||
glstate.scissorTest.disable();
|
||||
glstate.stencilTest.disable();
|
||||
DrawPixels(pspframebuf, displayFormat_, displayStride_);
|
||||
// TODO: restore state?
|
||||
}
|
||||
@@ -477,7 +501,7 @@ void FramebufferManager::DecimateFBOs() {
|
||||
}
|
||||
if ((*iter)->last_frame_used + FBO_OLD_AGE < gpuStats.numFrames) {
|
||||
INFO_LOG(HLE, "Destroying FBO for %08x (%i x %i x %i)", vfb->fb_address, vfb->width, vfb->height, vfb->format)
|
||||
textureCache_->NotifyFramebufferDestroyed(vfb->fb_address, vfb->fbo);
|
||||
textureCache_->NotifyFramebufferDestroyed(vfb->fb_address, vfb);
|
||||
fbo_destroy(vfb->fbo);
|
||||
delete vfb;
|
||||
vfbs_.erase(iter++);
|
||||
@@ -490,7 +514,7 @@ void FramebufferManager::DecimateFBOs() {
|
||||
void FramebufferManager::DestroyAllFBOs() {
|
||||
for (auto iter = vfbs_.begin(); iter != vfbs_.end(); ++iter) {
|
||||
VirtualFramebuffer *vfb = *iter;
|
||||
textureCache_->NotifyFramebufferDestroyed(vfb->fb_address, vfb->fbo);
|
||||
textureCache_->NotifyFramebufferDestroyed(vfb->fb_address, vfb);
|
||||
fbo_destroy(vfb->fbo);
|
||||
delete vfb;
|
||||
}
|
||||
|
||||
+28
-19
@@ -38,6 +38,34 @@ enum PspDisplayPixelFormat {
|
||||
PSP_DISPLAY_PIXEL_FORMAT_8888 = 3,
|
||||
};
|
||||
|
||||
enum {
|
||||
FB_USAGE_RENDERTARGET = 1,
|
||||
FB_USAGE_TEXTURE = 2,
|
||||
};
|
||||
|
||||
|
||||
struct VirtualFramebuffer {
|
||||
int last_frame_used;
|
||||
|
||||
u32 fb_address;
|
||||
u32 z_address;
|
||||
int fb_stride;
|
||||
int z_stride;
|
||||
|
||||
// There's also a top left of the drawing region, but meh...
|
||||
u16 width;
|
||||
u16 height;
|
||||
u16 renderWidth;
|
||||
u16 renderHeight;
|
||||
|
||||
u16 usageFlags;
|
||||
|
||||
int format; // virtual, right now they are all RGBA8888
|
||||
FBOColorDepth colorDepth;
|
||||
FBO *fbo;
|
||||
};
|
||||
|
||||
|
||||
class FramebufferManager {
|
||||
public:
|
||||
FramebufferManager();
|
||||
@@ -47,25 +75,6 @@ public:
|
||||
textureCache_ = tc;
|
||||
}
|
||||
|
||||
struct VirtualFramebuffer {
|
||||
int last_frame_used;
|
||||
|
||||
u32 fb_address;
|
||||
u32 z_address;
|
||||
int fb_stride;
|
||||
int z_stride;
|
||||
|
||||
// There's also a top left of the drawing region, but meh...
|
||||
u16 width;
|
||||
u16 height;
|
||||
u16 renderWidth;
|
||||
u16 renderHeight;
|
||||
|
||||
int format; // virtual, right now they are all RGBA8888
|
||||
FBOColorDepth colorDepth;
|
||||
FBO *fbo;
|
||||
};
|
||||
|
||||
void DrawPixels(const u8 *framebuf, int pixelFormat, int linesize);
|
||||
void DrawActiveTexture(float x, float y, float w, float h, bool flip = false);
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ LinkedShader::LinkedShader(Shader *vs, Shader *fs)
|
||||
u_fogcolor = glGetUniformLocation(program, "u_fogcolor");
|
||||
u_fogcoef = glGetUniformLocation(program, "u_fogcoef");
|
||||
u_alphacolorref = glGetUniformLocation(program, "u_alphacolorref");
|
||||
u_colormask = glGetUniformLocation(program, "u_colormask");
|
||||
|
||||
// Transform
|
||||
u_view = glGetUniformLocation(program, "u_view");
|
||||
@@ -243,7 +244,7 @@ void LinkedShader::updateUniforms() {
|
||||
if (u_proj_through != -1 && (dirtyUniforms & DIRTY_PROJTHROUGHMATRIX))
|
||||
{
|
||||
Matrix4x4 proj_through;
|
||||
proj_through.setOrtho(0.0f, 480, 272, 0, -1, 0); // TODO: Store this somewhere instead of regenerating! And not in each LinkedShader object!
|
||||
proj_through.setOrtho(0.0f, 480, 272, 0, 0, 1);
|
||||
glUniformMatrix4fv(u_proj_through, 1, GL_FALSE, proj_through.getReadPtr());
|
||||
}
|
||||
if (u_texenv != -1 && (dirtyUniforms & DIRTY_TEXENV)) {
|
||||
@@ -252,6 +253,9 @@ void LinkedShader::updateUniforms() {
|
||||
if (u_alphacolorref != -1 && (dirtyUniforms & DIRTY_ALPHACOLORREF)) {
|
||||
SetColorUniform3Alpha(u_alphacolorref, gstate.colorref, (gstate.alphatest >> 8) & 0xFF);
|
||||
}
|
||||
if (u_colormask != -1 && (dirtyUniforms & DIRTY_COLORMASK)) {
|
||||
SetColorUniform3(u_colormask, gstate.colormask);
|
||||
}
|
||||
if (u_fogcolor != -1 && (dirtyUniforms & DIRTY_FOGCOLOR)) {
|
||||
SetColorUniform3(u_fogcolor, gstate.fogcolor);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
|
||||
// Fragment processing inputs
|
||||
int u_alphacolorref;
|
||||
int u_colormask;
|
||||
int u_fogcolor;
|
||||
int u_fogcoef;
|
||||
|
||||
@@ -88,7 +89,7 @@ enum
|
||||
DIRTY_TEXENV = (1 << 4),
|
||||
DIRTY_ALPHACOLORREF = (1 << 5),
|
||||
DIRTY_COLORREF = (1 << 6),
|
||||
|
||||
DIRTY_COLORMASK = (1 << 7),
|
||||
DIRTY_LIGHT0 = (1 << 8),
|
||||
DIRTY_LIGHT1 = (1 << 9),
|
||||
DIRTY_LIGHT2 = (1 << 10),
|
||||
|
||||
+50
-45
@@ -84,22 +84,19 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
|
||||
gstate_c.textureChanged = false;
|
||||
}
|
||||
|
||||
// TODO: The top bit of the alpha channel should be written to the stencil bit somehow. This appears to require very expensive multipass rendering :( Alternatively, one could do a
|
||||
// single fullscreen pass that converts alpha to stencil (or 2 passes, to set both the 0 and 1 values) very easily.
|
||||
|
||||
// Set cull
|
||||
bool wantCull = !gstate.isModeClear() && !gstate.isModeThrough() && prim != GE_PRIM_RECTANGLES && gstate.isCullEnabled();
|
||||
glstate.cullFace.set(wantCull);
|
||||
if (wantCull)
|
||||
glstate.cullFaceMode.set(cullingMode[gstate.getCullMode()]);
|
||||
|
||||
if (wantCull) {
|
||||
u8 cullMode = gstate.getCullMode();
|
||||
glstate.cullFaceMode.set(cullingMode[cullMode]);
|
||||
}
|
||||
// TODO: The top bit of the alpha channel should be written to the stencil bit somehow. This appears to require very expensive multipass rendering :( Alternatively, one could do a
|
||||
// single fullscreen pass that converts alpha to stencil (or 2 passes, to set both the 0 and 1 values) very easily.
|
||||
|
||||
// Set blend
|
||||
bool wantBlend = !gstate.isModeClear() && (gstate.alphaBlendEnable & 1);
|
||||
bool wantBlend = !gstate.isModeClear() && gstate.isAlphaBlendEnabled();
|
||||
glstate.blend.set(wantBlend);
|
||||
if(wantBlend) {
|
||||
if (wantBlend) {
|
||||
// This can't be done exactly as there are several PSP blend modes that are impossible to do on OpenGL ES 2.0, and some even on regular OpenGL for desktop.
|
||||
// HOWEVER - we should be able to approximate the 2x modes in the shader, although they will clip wrongly.
|
||||
|
||||
@@ -168,46 +165,54 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
|
||||
}
|
||||
}
|
||||
|
||||
bool wantDepthTest = gstate.isModeClear() || gstate.isDepthTestEnabled();
|
||||
glstate.depthTest.set(wantDepthTest);
|
||||
if(wantDepthTest) {
|
||||
// Force GL_ALWAYS if mode clear - without depth test, no depth write.
|
||||
int depthTestFunc = gstate.isModeClear() ? 1 : gstate.getDepthTestFunc();
|
||||
glstate.depthFunc.set(ztests[depthTestFunc]);
|
||||
}
|
||||
// Set Dither
|
||||
glstate.dither.set(gstate.isDitherEnabled());
|
||||
|
||||
// PSP color/alpha mask is per bit but we can only support per byte.
|
||||
// But let's do that, at least. And let's try a threshold.
|
||||
if (!gstate.isModeClear()) {
|
||||
// Set ColorMask/Stencil/Depth
|
||||
if (gstate.isModeClear()) {
|
||||
bool colorMask = (gstate.clearmode >> 8) & 1;
|
||||
bool alphaMask = (gstate.clearmode >> 9) & 1;
|
||||
bool depthMask = ((gstate.clearmode >> 10) & 1) || !(gstate.zmsk & 1);
|
||||
|
||||
glstate.colorMask.set(colorMask, colorMask, colorMask, alphaMask);
|
||||
|
||||
glstate.stencilTest.enable();
|
||||
glstate.stencilOp.set(GL_REPLACE, GL_REPLACE, GL_REPLACE);
|
||||
glstate.stencilFunc.set(GL_ALWAYS, 0, 0xFF);
|
||||
|
||||
glstate.depthTest.enable();
|
||||
glstate.depthFunc.set(GL_ALWAYS);
|
||||
glstate.depthWrite.set(depthMask ? GL_TRUE : GL_FALSE);
|
||||
|
||||
} else {
|
||||
if (gstate.isDepthTestEnabled()) {
|
||||
glstate.depthTest.enable();
|
||||
glstate.depthFunc.set(ztests[gstate.getDepthTestFunc()]);
|
||||
glstate.depthWrite.set(gstate.isDepthWriteEnabled() ? GL_TRUE : GL_FALSE);
|
||||
} else {
|
||||
glstate.depthTest.disable();
|
||||
}
|
||||
|
||||
// PSP color/alpha mask is per bit but we can only support per byte.
|
||||
// But let's do that, at least. And let's try a threshold.
|
||||
bool rmask = (gstate.pmskc & 0xFF) < 128;
|
||||
bool gmask = ((gstate.pmskc >> 8) & 0xFF) < 128;
|
||||
bool bmask = ((gstate.pmskc >> 16) & 0xFF) < 128;
|
||||
bool amask = (gstate.pmska & 0xFF) < 128;
|
||||
glstate.colorMask.set(rmask, gmask, bmask, amask);
|
||||
|
||||
if (gstate.isStencilTestEnabled()) {
|
||||
glstate.stencilTest.enable();
|
||||
glstate.stencilFunc.set(ztests[gstate.stenciltest & 0x7], // func
|
||||
(gstate.stenciltest >> 8) & 0xFF, // ref
|
||||
(gstate.stenciltest >> 16) & 0xFF); // mask
|
||||
glstate.stencilOp.set(stencilOps[gstate.stencilop & 0x7], // stencil fail
|
||||
stencilOps[(gstate.stencilop >> 8) & 0x7], // depth fail
|
||||
stencilOps[(gstate.stencilop >> 16) & 0x7]); // depth pass
|
||||
} else {
|
||||
glstate.stencilTest.disable();
|
||||
}
|
||||
}
|
||||
|
||||
// Stencil test
|
||||
if (!gstate.isModeClear() && gstate.isStencilTestEnabled()) {
|
||||
glstate.stencilTest.enable();
|
||||
glstate.stencilFunc.set(ztests[gstate.stenciltest & 0x7], // func
|
||||
(gstate.stenciltest >> 8) & 0xFF, // ref
|
||||
(gstate.stenciltest >> 16) & 0xFF); // mask
|
||||
glstate.stencilOp.set(stencilOps[gstate.stencilop & 0x7], // stencil fail
|
||||
stencilOps[(gstate.stencilop >> 8) & 0x7], // depth fail
|
||||
stencilOps[(gstate.stencilop >> 16) & 0x7]);
|
||||
} else if (gstate.isModeClear()) {
|
||||
glstate.stencilTest.enable();
|
||||
glstate.stencilOp.set(GL_REPLACE, GL_REPLACE, GL_REPLACE);
|
||||
glstate.stencilFunc.set(GL_ALWAYS, 0, 0xFF);
|
||||
} else {
|
||||
glstate.stencilTest.disable();
|
||||
}
|
||||
|
||||
// Dither
|
||||
glstate.dither.set(gstate.ditherEnable & 1);
|
||||
|
||||
bool wantDepthWrite = gstate.isModeClear() || gstate.isDepthWriteEnabled();
|
||||
glstate.depthWrite.set(wantDepthWrite ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
void TransformDrawEngine::UpdateViewportAndProjection() {
|
||||
@@ -236,7 +241,7 @@ void TransformDrawEngine::UpdateViewportAndProjection() {
|
||||
if (throughmode) {
|
||||
// No viewport transform here. Let's experiment with using region.
|
||||
glstate.viewport.set((0 + regionX1) * renderWidthFactor, (0 - regionY1) * renderHeightFactor, (regionX2 - regionX1) * renderWidthFactor, (regionY2 - regionY1) * renderHeightFactor);
|
||||
glstate.depthRange.set(1.0, 0.0);
|
||||
glstate.depthRange.set(0.0f, 1.0f);
|
||||
} else {
|
||||
// These we can turn into a glViewport call, offset by offsetX and offsetY. Math after.
|
||||
float vpXa = getFloat24(gstate.viewportx1);
|
||||
@@ -269,8 +274,8 @@ void TransformDrawEngine::UpdateViewportAndProjection() {
|
||||
// Sadly, as glViewport takes integers, we will not be able to support sub pixel offsets this way. But meh.
|
||||
// shaderManager_->DirtyUniform(DIRTY_PROJMATRIX);
|
||||
|
||||
float zScale = getFloat24(gstate.viewportz1) / 65535.f;
|
||||
float zOff = getFloat24(gstate.viewportz2) / 65535.f;
|
||||
float zScale = getFloat24(gstate.viewportz1) / 65535.0f;
|
||||
float zOff = getFloat24(gstate.viewportz2) / 65535.0f;
|
||||
float depthRangeMin = zOff - zScale;
|
||||
float depthRangeMax = zOff + zScale;
|
||||
glstate.depthRange.set(depthRangeMin, depthRangeMax);
|
||||
|
||||
+20
-30
@@ -18,11 +18,12 @@
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../../Core/MemMap.h"
|
||||
#include "../ge_constants.h"
|
||||
#include "../GPUState.h"
|
||||
#include "TextureCache.h"
|
||||
#include "../Core/Config.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "GPU/ge_constants.h"
|
||||
#include "GPU/GPUState.h"
|
||||
#include "GPU/GLES/TextureCache.h"
|
||||
#include "GPU/GLES/Framebuffer.h"
|
||||
#include "Core/Config.h"
|
||||
|
||||
// If a texture hasn't been seen for this many frames, get rid of it.
|
||||
#define TEXTURE_KILL_AGE 200
|
||||
@@ -79,7 +80,7 @@ void TextureCache::Clear(bool delete_them) {
|
||||
// Removes old textures.
|
||||
void TextureCache::Decimate() {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
for (TexCache::iterator iter = cache.begin(), end = cache.end(); iter != end; ) {
|
||||
for (TexCache::iterator iter = cache.begin(); iter != cache.end(); ) {
|
||||
if (iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFrames) {
|
||||
glDeleteTextures(1, &iter->second.texture);
|
||||
cache.erase(iter++);
|
||||
@@ -131,21 +132,21 @@ TextureCache::TexCacheEntry *TextureCache::GetEntryAt(u32 texaddr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TextureCache::NotifyFramebuffer(u32 address, FBO *fbo) {
|
||||
void TextureCache::NotifyFramebuffer(u32 address, VirtualFramebuffer *framebuffer) {
|
||||
// Must be in VRAM so | 0x04000000 it is.
|
||||
TexCacheEntry *entry = GetEntryAt(address | 0x04000000);
|
||||
if (entry) {
|
||||
DEBUG_LOG(HLE, "Render to texture detected at %08x!", address);
|
||||
if (!entry->fbo)
|
||||
entry->fbo = fbo;
|
||||
if (!entry->framebuffer)
|
||||
entry->framebuffer= framebuffer;
|
||||
// TODO: Delete the original non-fbo texture too.
|
||||
}
|
||||
}
|
||||
|
||||
void TextureCache::NotifyFramebufferDestroyed(u32 address, FBO *fbo) {
|
||||
void TextureCache::NotifyFramebufferDestroyed(u32 address, VirtualFramebuffer *fbo) {
|
||||
TexCacheEntry *entry = GetEntryAt(address | 0x04000000);
|
||||
if (entry && entry->fbo) {
|
||||
entry->fbo = 0;
|
||||
if (entry && entry->framebuffer) {
|
||||
entry->framebuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,7 +677,6 @@ void TextureCache::SetTexture() {
|
||||
}
|
||||
bool hasClut = formatUsesClut[format];
|
||||
|
||||
const u8 *texptr = Memory::GetPointer(texaddr);
|
||||
u64 cachekey = texaddr;
|
||||
|
||||
u32 clutformat, clutaddr;
|
||||
@@ -699,19 +699,15 @@ void TextureCache::SetTexture() {
|
||||
if (iter != cache.end()) {
|
||||
entry = &iter->second;
|
||||
// Check for FBO - slow!
|
||||
if (entry->fbo) {
|
||||
int w = 1 << (gstate.texsize[0] & 0xf);
|
||||
int h = 1 << ((gstate.texsize[0] >> 8) & 0xf);
|
||||
|
||||
fbo_bind_color_as_texture(entry->fbo, 0);
|
||||
if (entry->framebuffer) {
|
||||
fbo_bind_color_as_texture(entry->framebuffer->fbo, 0);
|
||||
UpdateSamplingParams(*entry, false);
|
||||
|
||||
int fbow, fboh;
|
||||
fbo_get_dimensions(entry->fbo, &fbow, &fboh);
|
||||
|
||||
// This isn't right.
|
||||
gstate_c.curTextureWidth = w; //w; //RoundUpToPowerOf2(fbow);
|
||||
gstate_c.curTextureHeight = h; // RoundUpToPowerOf2(fboh);
|
||||
gstate_c.curTextureWidth = entry->framebuffer->width;
|
||||
gstate_c.curTextureHeight = entry->framebuffer->height;
|
||||
int h = 1 << ((gstate.texsize[0] >> 8) & 0xf);
|
||||
gstate_c.actualTextureHeight = h;
|
||||
gstate_c.flipTexture = true;
|
||||
entry->lastFrame = gpuStats.numFrames;
|
||||
return;
|
||||
@@ -807,7 +803,7 @@ void TextureCache::SetTexture() {
|
||||
entry->hash = texhash;
|
||||
entry->format = format;
|
||||
entry->lastFrame = gpuStats.numFrames;
|
||||
entry->fbo = 0;
|
||||
entry->framebuffer = 0;
|
||||
entry->maxLevel = maxLevel;
|
||||
entry->lodBias = 0.0f;
|
||||
|
||||
@@ -1153,14 +1149,8 @@ bool TextureCache::DecodeTexture(u8* output, GPUgstate state)
|
||||
}
|
||||
|
||||
u32 clutformat = gstate.clutformat & 3;
|
||||
u32 clutaddr = GetClutAddr(clutformat == GE_CMODE_32BIT_ABGR8888 ? 4 : 2);
|
||||
|
||||
const u8 *texptr = Memory::GetPointer(texaddr);
|
||||
u32 texhash = texptr ? MiniHash((const u32*)texptr) : 0;
|
||||
|
||||
u64 cachekey = texaddr ^ texhash;
|
||||
if (formatUsesClut[format])
|
||||
cachekey |= (u64) clutaddr << 32;
|
||||
|
||||
int bufw = gstate.texbufwidth[0] & 0x3ff;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "gfx_es2/fbo.h"
|
||||
#include "GPU/GPUState.h"
|
||||
|
||||
struct VirtualFramebuffer;
|
||||
|
||||
class TextureCache
|
||||
{
|
||||
public:
|
||||
@@ -36,16 +38,16 @@ public:
|
||||
|
||||
// FramebufferManager keeps TextureCache updated about what regions of memory
|
||||
// are being rendered to. This is barebones so far.
|
||||
void NotifyFramebuffer(u32 address, FBO *fbo);
|
||||
void NotifyFramebufferDestroyed(u32 address, FBO *fbo);
|
||||
void NotifyFramebuffer(u32 address, VirtualFramebuffer *framebuffer);
|
||||
void NotifyFramebufferDestroyed(u32 address, VirtualFramebuffer *framebuffer);
|
||||
|
||||
size_t NumLoadedTextures() const {
|
||||
return cache.size();
|
||||
}
|
||||
|
||||
bool DecodeTexture(u8 *output, GPUgstate state);
|
||||
|
||||
private:
|
||||
|
||||
struct TexCacheEntry {
|
||||
// After marking STATUS_UNRELIABLE, if it stays the same this many frames we'll trust it again.
|
||||
const static int FRAMES_REGAIN_TRUST = 1000;
|
||||
@@ -60,7 +62,7 @@ private:
|
||||
int status;
|
||||
u32 addr;
|
||||
u32 hash;
|
||||
FBO *fbo; // if null, not sourced from an FBO.
|
||||
VirtualFramebuffer *framebuffer; // if null, not sourced from an FBO.
|
||||
u32 sizeInRAM;
|
||||
int lastFrame;
|
||||
int numFrames;
|
||||
|
||||
@@ -640,7 +640,7 @@ void TransformDrawEngine::SoftwareTransformAndDraw(
|
||||
transformed[index].fog = fogCoef;
|
||||
memcpy(&transformed[index].u, uv, 2 * sizeof(float));
|
||||
if (gstate_c.flipTexture)
|
||||
transformed[index].v = 1.0f - transformed[index].v * 2.0f;
|
||||
transformed[index].v = 1.0f - transformed[index].v; //(float)gstate_c.actualTextureHeight / gstate_c.curTextureHeight - transformed[index].v;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
transformed[index].color0[i] = c0[i] * 255.0f;
|
||||
}
|
||||
@@ -660,10 +660,6 @@ void TransformDrawEngine::SoftwareTransformAndDraw(
|
||||
numTrans = vertexCount;
|
||||
drawIndexed = true;
|
||||
} else {
|
||||
// Temporary storage for RECTANGLES emulation
|
||||
float v2[3] = {0};
|
||||
float uv2[2] = {0};
|
||||
|
||||
numTrans = 0;
|
||||
drawBuffer = transformedExpanded;
|
||||
TransformedVertex *trans = &transformedExpanded[0];
|
||||
@@ -930,7 +926,7 @@ void TransformDrawEngine::Flush() {
|
||||
|
||||
gpuStats.numFlushes++;
|
||||
|
||||
gpuStats.numTrackedVertexArrays = vai_.size();
|
||||
gpuStats.numTrackedVertexArrays = (int)vai_.size();
|
||||
|
||||
// TODO: This should not be done on every drawcall, we should collect vertex data
|
||||
// until critical state changes. That's when we draw (flush).
|
||||
|
||||
+63
-29
@@ -191,20 +191,43 @@ public:
|
||||
void ReadPos(float pos[3]) {
|
||||
switch (decFmt_.posfmt) {
|
||||
case DEC_FLOAT_3:
|
||||
memcpy(pos, data_ + decFmt_.posoff, 12);
|
||||
{
|
||||
const float *f = (const float *)(data_ + decFmt_.posoff);
|
||||
memcpy(pos, f, 12);
|
||||
if (isThrough()) {
|
||||
// Integer value passed in a float. Wraps and all, required for Monster Hunter.
|
||||
pos[2] = (float)((u16)(s32)pos[2]) * (1.0f / 65535.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DEC_S16_3:
|
||||
{
|
||||
const s16 *p = (s16 *)(data_ + decFmt_.posoff);
|
||||
for (int i = 0; i < 3; i++)
|
||||
pos[i] = p[i] * (1.f / 32768.f);
|
||||
// X and Y are signed 16 bit, Z is unsigned 16 bit
|
||||
const s16 *s = (const s16 *)(data_ + decFmt_.posoff);
|
||||
const u16 *u = (const u16 *)(data_ + decFmt_.posoff);
|
||||
if (isThrough()) {
|
||||
for (int i = 0; i < 2; i++)
|
||||
pos[i] = s[i];
|
||||
pos[2] = u[2] * (1.0f / 65535.0f);
|
||||
} else {
|
||||
for (int i = 0; i < 3; i++)
|
||||
pos[i] = s[i] * (1.f / 32767.f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DEC_S8_3:
|
||||
{
|
||||
const s8 *p = (s8 *)(data_ + decFmt_.posoff);
|
||||
for (int i = 0; i < 3; i++)
|
||||
pos[i] = p[i] * (1.f / 128.f);
|
||||
// X and Y are signed 8 bit, Z is unsigned 8 bit
|
||||
const s8 *b = (const s8 *)(data_ + decFmt_.posoff);
|
||||
const u8 *u = (const u8 *)(data_ + decFmt_.posoff);
|
||||
if (isThrough()) {
|
||||
for (int i = 0; i < 2; i++)
|
||||
pos[i] = b[i];
|
||||
pos[2] = u[2] / 255.0f;
|
||||
} else {
|
||||
for (int i = 0; i < 3; i++)
|
||||
pos[i] = b[i] * (1.f / 127.f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -216,20 +239,25 @@ public:
|
||||
void ReadNrm(float nrm[3]) {
|
||||
switch (decFmt_.nrmfmt) {
|
||||
case DEC_FLOAT_3:
|
||||
memcpy(nrm, data_ + decFmt_.nrmoff, 12);
|
||||
//memcpy(nrm, data_ + decFmt_.nrmoff, 12);
|
||||
{
|
||||
const float *f = (const float *)(data_ + decFmt_.nrmoff);
|
||||
for (int i = 0; i < 3; i++)
|
||||
nrm[i] = f[i] ;
|
||||
}
|
||||
break;
|
||||
case DEC_S16_3:
|
||||
{
|
||||
const s16 *p = (s16 *)(data_ + decFmt_.nrmoff);
|
||||
const s16 *s = (const s16 *)(data_ + decFmt_.nrmoff);
|
||||
for (int i = 0; i < 3; i++)
|
||||
nrm[i] = p[i] * (1.f / 32768.f);
|
||||
nrm[i] = s[i] * (1.f / 32767.f);
|
||||
}
|
||||
break;
|
||||
case DEC_S8_3:
|
||||
{
|
||||
const s8 *p = (s8 *)(data_ + decFmt_.nrmoff);
|
||||
const s8 *b = (const s8 *)(data_ + decFmt_.nrmoff);
|
||||
for (int i = 0; i < 3; i++)
|
||||
nrm[i] = p[i] * (1.f / 128.0f);
|
||||
nrm[i] = b[i] * (1.f / 127.f);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -259,8 +287,8 @@ public:
|
||||
case DEC_FLOAT_2:
|
||||
{
|
||||
const float *f = (const float *)(data_ + decFmt_.uvoff);
|
||||
uv[0] = f[0] * 2.0f;
|
||||
uv[1] = f[1] * 2.0f;
|
||||
uv[0] = f[0] * 2.f;
|
||||
uv[1] = f[1] * 2.f;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -281,13 +309,14 @@ public:
|
||||
switch (decFmt_.c0fmt) {
|
||||
case DEC_U8_4:
|
||||
{
|
||||
const u8 *p = (const u8 *)(data_ + decFmt_.c0off);
|
||||
const u8 *b = (const u8 *)(data_ + decFmt_.c0off);
|
||||
for (int i = 0; i < 4; i++)
|
||||
color[i] = p[i] * (1.f / 255.f);
|
||||
color[i] = b[i] * (1.f / 255.f);
|
||||
}
|
||||
break;
|
||||
case DEC_FLOAT_4:
|
||||
memcpy(color, data_ + decFmt_.c0off, 16); break;
|
||||
memcpy(color, data_ + decFmt_.c0off, 16);
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(G3D, "Reader: Unsupported C0 Format");
|
||||
break;
|
||||
@@ -298,13 +327,14 @@ public:
|
||||
switch (decFmt_.c1fmt) {
|
||||
case DEC_U8_4:
|
||||
{
|
||||
const u8 *p = (const u8 *)(data_ + decFmt_.c1off);
|
||||
const u8 *b = (const u8 *)(data_ + decFmt_.c1off);
|
||||
for (int i = 0; i < 3; i++)
|
||||
color[i] = p[i] * (1.f / 255.f);
|
||||
color[i] = b[i] * (1.f / 255.f);
|
||||
}
|
||||
break;
|
||||
case DEC_FLOAT_4:
|
||||
memcpy(color, data_ + decFmt_.c1off, 12); break;
|
||||
memcpy(color, data_ + decFmt_.c1off, 12);
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG(G3D, "Reader: Unsupported C1 Format");
|
||||
break;
|
||||
@@ -313,7 +343,7 @@ public:
|
||||
|
||||
void ReadWeights(float weights[8]) {
|
||||
const float *f = (const float *)(data_ + decFmt_.w0off);
|
||||
const u8 *p = (const u8 *)(data_ + decFmt_.w0off);
|
||||
const u8 *b = (const u8 *)(data_ + decFmt_.w0off);
|
||||
const u16 *s = (const u16 *)(data_ + decFmt_.w0off);
|
||||
switch (decFmt_.w0fmt) {
|
||||
case DEC_FLOAT_1:
|
||||
@@ -321,12 +351,12 @@ public:
|
||||
case DEC_FLOAT_3:
|
||||
case DEC_FLOAT_4:
|
||||
for (int i = 0; i <= decFmt_.w0fmt - DEC_FLOAT_1; i++)
|
||||
weights[i] = f[i] * 2.0;
|
||||
weights[i] = f[i] * 2.f;
|
||||
break;
|
||||
case DEC_U8_1: weights[0] = p[0] * (1.f / 128.f); break;
|
||||
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i] = p[i] * (1.f / 128.f); break;
|
||||
case DEC_U8_3: for (int i = 0; i < 3; i++) weights[i] = p[i] * (1.f / 128.f); break;
|
||||
case DEC_U8_4: for (int i = 0; i < 4; i++) weights[i] = p[i] * (1.f / 128.f); break;
|
||||
case DEC_U8_1: weights[0] = b[0] * (1.f / 128.f); break;
|
||||
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i] = b[i] * (1.f / 128.f); break;
|
||||
case DEC_U8_3: for (int i = 0; i < 3; i++) weights[i] = b[i] * (1.f / 128.f); break;
|
||||
case DEC_U8_4: for (int i = 0; i < 4; i++) weights[i] = b[i] * (1.f / 128.f); break;
|
||||
case DEC_U16_1: weights[0] = s[0] * (1.f / 32768.f); break;
|
||||
case DEC_U16_2: for (int i = 0; i < 2; i++) weights[i] = s[i] * (1.f / 32768.f); break;
|
||||
case DEC_U16_3: for (int i = 0; i < 3; i++) weights[i] = s[i] * (1.f / 32768.f); break;
|
||||
@@ -336,8 +366,8 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
f = (const float*)(data_ + decFmt_.w1off);
|
||||
p = (const u8 *)(data_ + decFmt_.w1off);
|
||||
f = (const float *)(data_ + decFmt_.w1off);
|
||||
b = (const u8 *)(data_ + decFmt_.w1off);
|
||||
s = (const u16 *)(data_ + decFmt_.w1off);
|
||||
switch (decFmt_.w1fmt) {
|
||||
case 0:
|
||||
@@ -348,8 +378,12 @@ public:
|
||||
case DEC_FLOAT_3:
|
||||
case DEC_FLOAT_4:
|
||||
for (int i = 0; i <= decFmt_.w1fmt - DEC_FLOAT_1; i++)
|
||||
weights[i+4] = f[i] * 2.0;
|
||||
weights[i+4] = f[i] * 2.f;
|
||||
break;
|
||||
case DEC_U8_1: weights[4] = b[0] * (1.f / 128.f); break;
|
||||
case DEC_U8_2: for (int i = 0; i < 2; i++) weights[i+4] = b[i] * (1.f / 128.f); break;
|
||||
case DEC_U8_3: for (int i = 0; i < 3; i++) weights[i+4] = b[i] * (1.f / 128.f); break;
|
||||
case DEC_U8_4: for (int i = 0; i < 4; i++) weights[i+4] = b[i] * (1.f / 128.f); break;
|
||||
case DEC_U16_1: weights[4] = s[0] * (1.f / 32768.f); break;
|
||||
case DEC_U16_2: for (int i = 0; i < 2; i++) weights[i+4] = s[i] * (1.f / 32768.f); break;
|
||||
case DEC_U16_3: for (int i = 0; i < 3; i++) weights[i+4] = s[i] * (1.f / 32768.f); break;
|
||||
|
||||
@@ -401,7 +401,7 @@ void GenerateVertexShader(int prim, char *buffer) {
|
||||
break;
|
||||
}
|
||||
if (flipV)
|
||||
WRITE(p, " v_texcoord.y = 1.0 - v_texcoord.y;\n");
|
||||
WRITE(p, " v_texcoord.y = 1.0 - v_texcoord.y * 2.0;\n");
|
||||
}
|
||||
|
||||
// Compute fogdepth
|
||||
|
||||
@@ -64,6 +64,9 @@ void InitGfxState()
|
||||
case GPU_GLES:
|
||||
gpu = new GLES_GPU();
|
||||
break;
|
||||
case GPU_SOFTWARE:
|
||||
gpu = new NullGPU();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -209,6 +209,8 @@ struct GPUgstate
|
||||
int getDepthTestFunc() const { return ztestfunc & 0x7; }
|
||||
bool isFogEnabled() const { return fogEnable & 1; }
|
||||
bool isStencilTestEnabled() const { return stencilTestEnable & 1; }
|
||||
bool isAlphaBlendEnabled() const { return alphaBlendEnable & 1; }
|
||||
bool isDitherEnabled() const { return ditherEnable & 1; }
|
||||
|
||||
// UV gen
|
||||
int getUVGenMode() const { return texmapmode & 3;} // 2 bits
|
||||
@@ -255,6 +257,7 @@ struct GPUStateCache
|
||||
|
||||
u32 curTextureWidth;
|
||||
u32 curTextureHeight;
|
||||
u32 actualTextureHeight;
|
||||
|
||||
float vpWidth;
|
||||
float vpHeight;
|
||||
|
||||
@@ -18,6 +18,11 @@ x86 {
|
||||
HEADERS += ../Core/MIPS/x86/*.h
|
||||
}
|
||||
|
||||
win32 {
|
||||
SOURCES += ../Windows/OpenGLBase.cpp
|
||||
HEADERS += ../Windows/OpenGLBase.h
|
||||
}
|
||||
|
||||
SOURCES += ../Core/CPU.cpp \ # Core
|
||||
../Core/Config.cpp \
|
||||
../Core/Core.cpp \
|
||||
@@ -34,6 +39,7 @@ SOURCES += ../Core/CPU.cpp \ # Core
|
||||
../Core/Dialog/*.cpp \
|
||||
../Core/ELF/*.cpp \
|
||||
../Core/FileSystems/*.cpp \
|
||||
../Core/Font/*.cpp \
|
||||
../Core/HLE/*.cpp \
|
||||
../Core/HW/*.cpp \
|
||||
../Core/MIPS/*.cpp \
|
||||
@@ -63,6 +69,7 @@ HEADERS += ../Core/CPU.h \
|
||||
../Core/Dialog/*.h \
|
||||
../Core/ELF/*.h \
|
||||
../Core/FileSystems/*.h \
|
||||
../Core/Font/*.h \
|
||||
../Core/HLE/*.h \
|
||||
../Core/HW/*.h \
|
||||
../Core/MIPS/*.h \
|
||||
|
||||
+8
-1
@@ -10,7 +10,14 @@ include(Settings.pri)
|
||||
# Libs
|
||||
symbian: LIBS += -lCore.lib -lCommon.lib -lNative.lib -lcone -leikcore -lavkon -lezlib
|
||||
blackberry: LIBS += -L. -lCore -lCommon -lNative -lscreen -lsocket -lstdc++
|
||||
win32: LIBS += -L$$OUT_PWD/release -lCore -lCommon -lNative -lwinmm -lws2_32 -lkernel32 -luser32 -lgdi32 -lshell32 -lcomctl32 -ldsound -lxinput
|
||||
win32 {
|
||||
CONFIG(release, debug|release) {
|
||||
LIBS += -L$$OUT_PWD/release
|
||||
} else {
|
||||
LIBS += -L$$OUT_PWD/debug
|
||||
}
|
||||
LIBS += -lCore -lCommon -lNative -lwinmm -lws2_32 -lkernel32 -luser32 -lgdi32 -lshell32 -lcomctl32 -ldsound -lxinput
|
||||
}
|
||||
linux: LIBS += -L. -lCore -lCommon -lNative
|
||||
|
||||
linux:!mobile_platform {
|
||||
|
||||
+9
-4
@@ -1,5 +1,4 @@
|
||||
DEFINES += USING_QT_UI
|
||||
blackberry|symbian|contains(MEEGO_EDITION,harmattan): CONFIG += mobile_platform
|
||||
unix:!blackberry:!symbian:!macx: CONFIG += linux
|
||||
|
||||
# Global specific
|
||||
@@ -8,7 +7,7 @@ INCLUDEPATH += ../ext/zlib ../native/ext/glew ../Common
|
||||
|
||||
win32-msvc* {
|
||||
QMAKE_CXXFLAGS_RELEASE += /O2 /arch:SSE2 /fp:fast
|
||||
DEFINES += _MBCS GLEW_STATIC NOMINMAX
|
||||
DEFINES += _MBCS GLEW_STATIC NOMINMAX NODRAWTEXT _CRT_SECURE_NO_WARNINGS
|
||||
PRECOMPILED_HEADER = ../Windows/stdafx.h
|
||||
PRECOMPILED_SOURCE = ../Windows/stdafx.cpp
|
||||
} else {
|
||||
@@ -17,7 +16,8 @@ win32-msvc* {
|
||||
}
|
||||
|
||||
# Arch specific
|
||||
contains(QT_ARCH, i686)|contains(QT_ARCH, x86)|contains(QT_ARCH, x86_64)|contains(QT_ARCH, windows): {
|
||||
xarch = $$find(QT_ARCH, "86")
|
||||
contains(QT_ARCH, windows)|count(xarch, 1) {
|
||||
!win32-msvc*: QMAKE_CXXFLAGS += -msse2
|
||||
CONFIG += x86
|
||||
}
|
||||
@@ -25,8 +25,13 @@ else { # Assume ARM
|
||||
DEFINES += ARM
|
||||
CONFIG += arm
|
||||
}
|
||||
mobile_platform: DEFINES += USING_GLES2
|
||||
|
||||
gleslib = $$lower($$QMAKE_LIBS_OPENGL)
|
||||
gleslib = $$find(gleslib, "gles")
|
||||
!count(gleslib,0) {
|
||||
DEFINES += USING_GLES2
|
||||
CONFIG += mobile_platform
|
||||
}
|
||||
|
||||
# Platform specific
|
||||
contains(MEEGO_EDITION,harmattan): DEFINES += MEEGO_EDITION_HARMATTAN "_SYS_UCONTEXT_H=1"
|
||||
|
||||
+26
-40
@@ -33,26 +33,15 @@ void CtrlDisAsmView::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
int page=(rect().bottom()/rowHeight)/2-1;
|
||||
|
||||
if(e->key() == Qt::Key_Down)
|
||||
switch (e->key())
|
||||
{
|
||||
curAddress += align;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_Up)
|
||||
{
|
||||
curAddress -= align;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_PageDown)
|
||||
{
|
||||
curAddress += page*align;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_PageUp)
|
||||
{
|
||||
curAddress -= page*align;
|
||||
e->accept();
|
||||
case Qt::Key_Down: curAddress += align; break;
|
||||
case Qt::Key_Up: curAddress -= align; break;
|
||||
case Qt::Key_PageDown: curAddress += page*align; break;
|
||||
case Qt::Key_PageUp: curAddress -= page*align; break;
|
||||
default: QWidget::keyPressEvent(e); break;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -68,7 +57,6 @@ void CtrlDisAsmView::mousePressEvent(QMouseEvent *e)
|
||||
selecting=true;
|
||||
if (!oldselecting || (selection!=oldSelection))
|
||||
redraw();
|
||||
e->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,7 +65,6 @@ void CtrlDisAsmView::mousePressEvent(QMouseEvent *e)
|
||||
EmuThread_LockDraw(false);
|
||||
parentWindow->Update();
|
||||
redraw();
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +72,11 @@ void CtrlDisAsmView::wheelEvent(QWheelEvent* e)
|
||||
{
|
||||
int numDegrees = e->delta() / 8;
|
||||
int numSteps = numDegrees / 15;
|
||||
if (e->orientation() == Qt::Horizontal) {
|
||||
} else {
|
||||
if (e->orientation() == Qt::Vertical)
|
||||
{
|
||||
curAddress -= numSteps*align;
|
||||
e->accept();
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CtrlDisAsmView::redraw()
|
||||
@@ -243,7 +229,7 @@ void CtrlDisAsmView::RenameFunction()
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(this,"Warning","No symbol selected",QMessageBox::Ok);
|
||||
QMessageBox::information(this,tr("Warning"),tr("No symbol selected"),QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,20 +251,20 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *)
|
||||
int width = rect().width();
|
||||
int numRows=(rect().height()/rowHeight)/2+1;
|
||||
|
||||
QColor bgColor = QColor(0xFFFFFFFF);
|
||||
QPen nullPen= QPen(bgColor);
|
||||
QPen currentPen=QPen(QColor(0,0,0));
|
||||
QPen selPen=QPen(QColor(0xFF808080));
|
||||
QPen condPen=QPen(QColor(0xFFFF3020));
|
||||
QColor bgColor(0xFFFFFFFF);
|
||||
QPen nullPen(bgColor);
|
||||
QPen currentPen(QColor(0,0,0));
|
||||
QPen selPen(QColor(0xFF808080));
|
||||
QPen condPen(QColor(0xFFFF3020));
|
||||
|
||||
QBrush lbr;
|
||||
lbr.setColor(bgColor);
|
||||
QBrush currentBrush=QBrush(QColor(0xFFFFEfE8));
|
||||
QBrush pcBrush=QBrush(QColor(0xFF70FF70));
|
||||
QBrush currentBrush(QColor(0xFFFFEfE8));
|
||||
QBrush pcBrush(QColor(0xFF70FF70));
|
||||
|
||||
QFont normalFont = QFont("Arial", 10);
|
||||
QFont boldFont = QFont("Arial", 10);
|
||||
QFont alignedFont = QFont("Monospace", 10);
|
||||
QFont normalFont("Arial", 10);
|
||||
QFont boldFont("Arial", 10);
|
||||
QFont alignedFont("Monospace", 10);
|
||||
boldFont.setBold(true);
|
||||
painter.setFont(normalFont);
|
||||
|
||||
@@ -295,17 +281,17 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *)
|
||||
int rowY1 = rect().bottom()/2 + rowHeight*i - rowHeight/2;
|
||||
int rowY2 = rect().bottom()/2 + rowHeight*i + rowHeight/2 - 1;
|
||||
|
||||
lbr.setColor(marker==address?QColor(0xFFFFEEE0):QColor(debugger->getColor(address)));
|
||||
lbr.setColor((unsigned int)marker == address ? QColor(0xFFFFEEE0) : QColor(debugger->getColor(address)));
|
||||
QColor bg = lbr.color();
|
||||
painter.setPen(nullPen);
|
||||
painter.drawRect(0,rowY1,16-1,rowY2-rowY1);
|
||||
|
||||
if (selecting && address == selection)
|
||||
if (selecting && address == (unsigned int)selection)
|
||||
painter.setPen(selPen);
|
||||
else
|
||||
painter.setPen(i==0 ? currentPen : nullPen);
|
||||
|
||||
QBrush mojsBrush=QBrush(lbr.color());
|
||||
QBrush mojsBrush(lbr.color());
|
||||
painter.setBrush(mojsBrush);
|
||||
|
||||
if (address == debugger->getPC())
|
||||
@@ -315,7 +301,7 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *)
|
||||
|
||||
painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);
|
||||
painter.setBrush(currentBrush);
|
||||
QPen textPen = QPen(QColor(halfAndHalf(bg.rgba(),0)));
|
||||
QPen textPen(QColor(halfAndHalf(bg.rgba(),0)));
|
||||
painter.setPen(textPen);
|
||||
painter.setFont(alignedFont);
|
||||
painter.drawText(17,rowY1-3+rowHeight,QString("%1").arg(address,8,16,QChar('0')));
|
||||
@@ -412,7 +398,7 @@ void CtrlDisAsmView::paintEvent(QPaintEvent *)
|
||||
{
|
||||
painter.setPen(branches[i].conditional ? condPen : currentPen);
|
||||
int x=280+(branches[i].srcAddr%9)*8;
|
||||
QPoint curPos = QPoint(x-2,branches[i].src);
|
||||
QPoint curPos(x-2,branches[i].src);
|
||||
|
||||
if (branches[i].dst<rect().bottom()+200 && branches[i].dst>-200)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,6 @@ class CtrlDisAsmView : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CtrlDisAsmView(QWidget *parent = 0);
|
||||
|
||||
|
||||
void redraw();
|
||||
void setAlign(int l)
|
||||
@@ -73,7 +72,6 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void keyPressEvent(QKeyEvent *);
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void CopyAddress();
|
||||
|
||||
+22
-36
@@ -15,7 +15,6 @@
|
||||
CtrlMemView::CtrlMemView(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
|
||||
curAddress=0;
|
||||
rowHeight=14;
|
||||
align=4;
|
||||
@@ -32,44 +31,30 @@ void CtrlMemView::redraw()
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void CtrlMemView::wheelEvent(QWheelEvent* e)
|
||||
{
|
||||
int numDegrees = e->delta() / 8;
|
||||
int numSteps = numDegrees / 15;
|
||||
if (e->orientation() == Qt::Horizontal) {
|
||||
} else {
|
||||
if (e->orientation() == Qt::Vertical)
|
||||
{
|
||||
curAddress -= numSteps*align*alignMul;
|
||||
e->accept();
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CtrlMemView::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
int page=(rect().bottom()/rowHeight)/2-1;
|
||||
|
||||
if(e->key() == Qt::Key_Up)
|
||||
switch (e->key())
|
||||
{
|
||||
curAddress-=align*alignMul;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_Down)
|
||||
{
|
||||
curAddress+=align*alignMul;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_PageUp)
|
||||
{
|
||||
curAddress-=page*align*alignMul;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_PageDown)
|
||||
{
|
||||
curAddress+=page*align*alignMul;
|
||||
e->accept();
|
||||
case Qt::Key_Up: curAddress -= align*alignMul; break;
|
||||
case Qt::Key_Down: curAddress += align*alignMul; break;
|
||||
case Qt::Key_PageUp: curAddress -= page*align*alignMul; break;
|
||||
case Qt::Key_PageDown: curAddress += page*align*alignMul; break;
|
||||
default: QWidget::keyPressEvent(e); break;
|
||||
}
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
@@ -86,17 +71,17 @@ void CtrlMemView::paintEvent(QPaintEvent *)
|
||||
int width = rect().width();
|
||||
int numRows=(rect().bottom()/rowHeight)/2+1;
|
||||
|
||||
QPen nullPen=QPen(0xFFFFFF);
|
||||
QPen currentPen=QPen(0xFF000000);
|
||||
QPen selPen=QPen(0x808080);
|
||||
QBrush lbr = QBrush(0xFFFFFF);
|
||||
QBrush nullBrush=QBrush(0xFFFFFF);
|
||||
QBrush currentBrush=QBrush(0xFFEfE8);
|
||||
QBrush pcBrush=QBrush(0x70FF70);
|
||||
QPen nullPen(0xFFFFFF);
|
||||
QPen currentPen(0xFF000000);
|
||||
QPen selPen(0x808080);
|
||||
QBrush lbr(0xFFFFFF);
|
||||
QBrush nullBrush(0xFFFFFF);
|
||||
QBrush currentBrush(0xFFEFE8);
|
||||
QBrush pcBrush(0x70FF70);
|
||||
QPen textPen;
|
||||
|
||||
QFont normalFont = QFont("Arial", 10);
|
||||
QFont alignedFont = QFont("Monospace", 10);
|
||||
QFont normalFont("Arial", 10);
|
||||
QFont alignedFont("Monospace", 10);
|
||||
painter.setFont(normalFont);
|
||||
|
||||
int i;
|
||||
@@ -112,7 +97,7 @@ void CtrlMemView::paintEvent(QPaintEvent *)
|
||||
|
||||
painter.setBrush(currentBrush);
|
||||
|
||||
if (selecting && address == selection)
|
||||
if (selecting && address == (unsigned int)selection)
|
||||
painter.setPen(selPen);
|
||||
else
|
||||
painter.setPen(i==0 ? currentPen : nullPen);
|
||||
@@ -188,6 +173,7 @@ void CtrlMemView::paintEvent(QPaintEvent *)
|
||||
painter.drawText(85,rowY1 - 2 + rowHeight, temp);
|
||||
break;
|
||||
}
|
||||
case MV_MAX: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +245,7 @@ void CtrlMemView::Change()
|
||||
if (ok && !text.isEmpty())
|
||||
{
|
||||
EmuThread_LockDraw(true);
|
||||
Memory::WriteUnchecked_U32(text.toInt(0,16),selection);
|
||||
Memory::WriteUnchecked_U32(text.toUInt(0,16),selection);
|
||||
EmuThread_LockDraw(false);
|
||||
redraw();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ protected:
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void CopyValue();
|
||||
|
||||
+18
-31
@@ -68,26 +68,15 @@ void CtrlRegisterList::scrollChanged(int action)
|
||||
|
||||
void CtrlRegisterList::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if(e->key() == Qt::Key_Down)
|
||||
switch (e->key())
|
||||
{
|
||||
selection += 1;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_Up)
|
||||
{
|
||||
selection -= 1;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_PageDown)
|
||||
{
|
||||
selection += 4;
|
||||
e->accept();
|
||||
}
|
||||
else if(e->key() == Qt::Key_PageUp)
|
||||
{
|
||||
selection -= 4;
|
||||
e->accept();
|
||||
case Qt::Key_Down: selection += 1; break;
|
||||
case Qt::Key_Up: selection -= 1; break;
|
||||
case Qt::Key_PageDown: selection += 4; break;
|
||||
case Qt::Key_PageUp: selection -= 4; break;
|
||||
default: QWidget::keyPressEvent(e); break;
|
||||
}
|
||||
|
||||
int maxRowsDisplay =rect().bottom()/rowHeight - 1;
|
||||
curVertOffset = std::min(std::max(curVertOffset, selection-maxRowsDisplay),selection);
|
||||
update();
|
||||
@@ -127,19 +116,17 @@ void CtrlRegisterList::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
redraw();
|
||||
}
|
||||
e->accept();
|
||||
}
|
||||
|
||||
void CtrlRegisterList::wheelEvent(QWheelEvent* e)
|
||||
{
|
||||
int numDegrees = e->delta() / 8;
|
||||
int numSteps = numDegrees / 15;
|
||||
if (e->orientation() == Qt::Horizontal) {
|
||||
} else {
|
||||
if (e->orientation() == Qt::Vertical)
|
||||
{
|
||||
curVertOffset -= numSteps;
|
||||
e->accept();
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,17 +162,17 @@ void CtrlRegisterList::paintEvent(QPaintEvent *)
|
||||
|
||||
int width = rect().width();
|
||||
|
||||
QColor bgColor = QColor(0xffffff);
|
||||
QPen nullPen=QPen(bgColor);
|
||||
QPen currentPen=QPen(QColor(0xFF000000));
|
||||
QPen selPen=QPen(0x808080);
|
||||
QColor bgColor(0xffffff);
|
||||
QPen nullPen(bgColor);
|
||||
QPen currentPen(QColor(0xFF000000));
|
||||
QPen selPen(0x808080);
|
||||
QPen textPen;
|
||||
|
||||
QBrush lbr;
|
||||
lbr.setColor(bgColor);
|
||||
QBrush nullBrush=QBrush(bgColor);
|
||||
QBrush currentBrush=QBrush(0xFFEfE8);
|
||||
QBrush pcBrush=QBrush(0x70FF70);
|
||||
QBrush nullBrush(bgColor);
|
||||
QBrush currentBrush(0xFFEfE8);
|
||||
QBrush pcBrush(0x70FF70);
|
||||
|
||||
int nc = cpu->GetNumCategories();
|
||||
for (int i=0; i<nc; i++)
|
||||
@@ -216,7 +203,7 @@ void CtrlRegisterList::paintEvent(QPaintEvent *)
|
||||
else
|
||||
painter.setPen(nullPen);
|
||||
|
||||
QBrush mojsBrush=QBrush(lbr.color());
|
||||
QBrush mojsBrush(lbr.color());
|
||||
painter.setBrush(mojsBrush);
|
||||
|
||||
painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);
|
||||
|
||||
+3
-3
@@ -25,11 +25,11 @@ void CtrlVfpuView::paintEvent(QPaintEvent *)
|
||||
if (!cpu)
|
||||
return;
|
||||
|
||||
QFont normalFont = QFont("Arial", 10);
|
||||
QFont normalFont("Arial", 10);
|
||||
painter.setFont(normalFont);
|
||||
|
||||
QPen currentPen=QPen(0xFF000000);
|
||||
QBrush nullBrush=QBrush(0xFFEfE8);
|
||||
QPen currentPen(0xFF000000);
|
||||
QBrush nullBrush(0xFFEfE8);
|
||||
painter.setPen(currentPen);
|
||||
painter.setBrush(nullBrush);
|
||||
|
||||
|
||||
+1
-5
@@ -27,13 +27,9 @@ public:
|
||||
void setMode(int newMode);
|
||||
void redraw();
|
||||
protected:
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
private:
|
||||
|
||||
private:
|
||||
DebugInterface *cpu;
|
||||
Debugger_Vfpu* parentWindow;
|
||||
int mode;
|
||||
|
||||
@@ -132,6 +132,8 @@ void Debugger_Disasm::StepHLE()
|
||||
|
||||
void Debugger_Disasm::UpdateDialog()
|
||||
{
|
||||
if(!isVisible())
|
||||
return;
|
||||
ui->DisasmView->setAlign(cpu->getInstructionSize(0));
|
||||
ui->DisasmView->redraw();
|
||||
ui->RegList->redraw();
|
||||
@@ -344,7 +346,7 @@ void Debugger_Disasm::FillFunctions()
|
||||
if(symbolMap.GetSymbolType(i) & ST_FUNCTION)
|
||||
{
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
item->setText(QString(symbolMap.GetSymbolName(i)) + " ("+ QString::number(symbolMap.GetSymbolSize(i)) +")");
|
||||
item->setText(QString("%1 (%2)").arg(symbolMap.GetSymbolName(i)).arg(symbolMap.GetSymbolSize(i)));
|
||||
item->setData(Qt::UserRole, symbolMap.GetAddress(i));
|
||||
ui->FuncList->addItem(item);
|
||||
}
|
||||
@@ -429,7 +431,7 @@ void Debugger_Disasm::UpdateThreadGUI()
|
||||
std::vector<DebugThreadInfo> threads = GetThreadsInfo();
|
||||
EmuThread_LockDraw(false);
|
||||
|
||||
for(int i = 0; i < threads.size(); i++)
|
||||
for(size_t i = 0; i < threads.size(); i++)
|
||||
{
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
item->setText(0,QString::number(threads[i].id));
|
||||
@@ -478,7 +480,7 @@ void Debugger_Disasm::on_threadList_customContextMenuRequested(const QPoint &pos
|
||||
connect(gotoEntryPoint, SIGNAL(triggered()), this, SLOT(GotoThreadEntryPoint()));
|
||||
menu.addAction(gotoEntryPoint);
|
||||
|
||||
QMenu* changeStatus = menu.addMenu("Change status");
|
||||
QMenu* changeStatus = menu.addMenu(tr("Change status"));
|
||||
|
||||
QAction *statusRunning = new QAction(tr("Running"), this);
|
||||
connect(statusRunning, SIGNAL(triggered()), this, SLOT(SetThreadStatusRun()));
|
||||
@@ -564,7 +566,7 @@ void Debugger_Disasm::UpdateDisplayListGUI()
|
||||
item->setText(3,QString("%1").arg(dl->pc,8,16,QChar('0')));
|
||||
item->setData(3, Qt::UserRole, dl->pc);
|
||||
ui->displayList->addTopLevelItem(item);
|
||||
if(curDlId == dl->id)
|
||||
if(curDlId == (u32)dl->id)
|
||||
{
|
||||
ui->displayList->setCurrentItem(item);
|
||||
displayListRowSelected = item;
|
||||
@@ -593,7 +595,7 @@ void Debugger_Disasm::UpdateDisplayListGUI()
|
||||
item->setText(3,QString("%1").arg(it->pc,8,16,QChar('0')));
|
||||
item->setData(3, Qt::UserRole, it->pc);
|
||||
ui->displayList->addTopLevelItem(item);
|
||||
if(curDlId == it->id)
|
||||
if(curDlId == (u32)it->id)
|
||||
{
|
||||
ui->displayList->setCurrentItem(item);
|
||||
displayListRowSelected = item;
|
||||
|
||||
+1
-19
@@ -58,49 +58,31 @@ private slots:
|
||||
void UpdateThreadGUI();
|
||||
|
||||
void on_GotoPc_clicked();
|
||||
|
||||
void on_Go_clicked();
|
||||
|
||||
void on_Stop_clicked();
|
||||
|
||||
void on_StepInto_clicked();
|
||||
|
||||
void on_StepOver_clicked();
|
||||
|
||||
void on_Skip_clicked();
|
||||
|
||||
void on_NextHLE_clicked();
|
||||
|
||||
void on_GotoLr_clicked();
|
||||
|
||||
void on_GotoInt_currentIndexChanged(int index);
|
||||
|
||||
void on_Address_textChanged(const QString &arg1);
|
||||
|
||||
void on_DisasmView_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void releaseLock();
|
||||
void on_RegList_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void on_vfpu_clicked();
|
||||
|
||||
void on_FuncList_itemClicked(QListWidgetItem *item);
|
||||
|
||||
void on_breakpointsList_itemClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
void on_breakpointsList_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void on_clearAllBP_clicked();
|
||||
|
||||
void on_threadList_itemClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
void on_threadList_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void SetThreadStatusRun();
|
||||
void SetThreadStatusWait();
|
||||
void SetThreadStatusSuspend();
|
||||
void on_displayList_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void releaseLock();
|
||||
|
||||
private:
|
||||
void SetThreadStatus(ThreadStatus status);
|
||||
|
||||
Loaded 100 of 159 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user