Update PPSSPP.cpp

This commit is contained in:
恍兮惚兮 2024-03-22 03:44:04 +08:00
parent 29f87a22f5
commit 22f20cb7b2

View File

@ -72,7 +72,6 @@ public:
struct emfuncinfo{
const char* hookname;
void* hookfunc;
void* filterfun;
const wchar_t* _id;
};
std::unordered_map<uintptr_t,emfuncinfo>emfunctionhooks;
@ -107,7 +106,6 @@ bool hookPPSSPPDoJit(){
hpinternal.address=ret;
hpinternal.type=CODEC_UTF16|USING_STRING|NO_CONTEXT;
hpinternal.text_fun=(decltype(hpinternal.text_fun))op.hookfunc;
hpinternal.filter_fun=(decltype(hpinternal.filter_fun))op.filterfun;
NewHook(hpinternal,op.hookname);
};
NewHook(hpinternal,"DoJitPtrRet");
@ -132,16 +130,13 @@ void ULJS00403(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* spl
hp->type=USING_STRING|NO_CONTEXT;
hp->codepage=932;
auto address= emu_arg(stack)[1];
*data=address;
*len=strlen((char*)address);
}
bool ULJS00403_filter(void* data, size_t* len, HookParam* hp){
std::string result = std::string((char*)data,*len);
std::string result = std::string((char*)address);
std::regex newlinePattern(R"((\\n)+)");
result = std::regex_replace(result, newlinePattern, " ");
std::regex pattern(R"((\\d$|^\@[a-z]+|#.*?#|\$))");
result = std::regex_replace(result, pattern, "");
return write_string_overwrite(data,len,result);
write_string_new(data,len,result);
}
// @name [ULJS00339] Amagami
@ -222,11 +217,8 @@ void NPJH50909(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* spl
hp->type=USING_STRING|NO_CONTEXT;
hp->codepage=932;
auto address= emu_arg(stack)[0];
*data=address;
*len=strlen((char*)address);
}
bool NPJH50909_filter(void* data, size_t* len, HookParam* hp){
std::string result = std::string((char*)data,*len);
std::string result = std::string((char*)address);
// Remove single line markers
result = std::regex_replace(result, std::regex("(\\%N)+"), " ");
@ -241,7 +233,7 @@ bool NPJH50909_filter(void* data, size_t* len, HookParam* hp){
result = std::regex_replace(result, std::regex("^[^「]+"), "");
result = name + "\n" + result;
}
return write_string_overwrite(data,len,result);
write_string_new(data,len,result);
}
// @name [ULJM06119] Dunamis15
@ -253,11 +245,8 @@ bool NPJH50909_filter(void* data, size_t* len, HookParam* hp){
void ULJM06119(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
hp->type=USING_STRING|NO_CONTEXT|CODEC_UTF8;
auto address= emu_arg(stack)[0];
*data=address;
*len=strlen((char*)address);
}
bool ULJM06119_filter(void* data, size_t* len, HookParam* hp){
std::string s = std::string((char*)data,*len);
std::string s = std::string((char*)address);
std::regex pattern(R"(/\[[^\]]+./g)");
s = std::regex_replace(s, pattern, "");
@ -270,7 +259,7 @@ bool ULJM06119_filter(void* data, size_t* len, HookParam* hp){
std::regex newlinePattern(R"(/\n+)");
s = std::regex_replace(s, newlinePattern, " ");
return write_string_overwrite(data,len,s);
write_string_new(data,len,s);
}
// @name [ULJM06036] Princess Evangile Portable
// @version 0.1
@ -279,26 +268,23 @@ bool ULJM06119_filter(void* data, size_t* len, HookParam* hp){
void ULJM06036(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
hp->type=USING_STRING|NO_CONTEXT|CODEC_UTF16;
auto address= emu_arg(stack)[2];
*data=address;
*len=wcslen((wchar_t*)address)*2;
}
bool ULJM06036_filter(void* data, size_t* len, HookParam* hp){
std::wstring result = std::wstring((wchar_t*)data,*len/2);
std::wstring result = std::wstring((wchar_t*)address);
std::wregex pattern(LR"(<R([^\/]+).([^>]+).>)");
result = std::regex_replace(result, pattern, L"$2");
std::wregex tagPattern(LR"(<[A-Z]+>)");
result = std::regex_replace(result, tagPattern, L"");
return write_string_overwrite(data,len,result);
write_string_new(data,len,result);
}
namespace{
auto _=[](){
emfunctionhooks={
{0x883bf34,{"Shinigami to Shoujo",ULJS00403,ULJS00403_filter,L"PCSG01282"}},
{0x0886775c,{"Amagami",ULJS00339,0,L"ULJS00339"}},
{0x8814adc,{"Sekai de Ichiban Dame na Koi",NPJH50909,NPJH50909_filter,L"NPJH50909"}},
{0x8850b2c,{"Sekai de Ichiban Dame na Koi",NPJH50909,NPJH50909_filter,L"NPJH50909"}},
{0x0891D72C,{"Dunamis15",ULJM06119,ULJM06119_filter,L"ULJM06119"}},
{0x88506d0,{"Princess Evangile Portable",ULJM06036,ULJM06036_filter,L"ULJM06036"}},
{0x883bf34,{"Shinigami to Shoujo",ULJS00403,L"PCSG01282"}},
{0x0886775c,{"Amagami",ULJS00339,L"ULJS00339"}},
{0x8814adc,{"Sekai de Ichiban Dame na Koi",NPJH50909,L"NPJH50909"}},
{0x8850b2c,{"Sekai de Ichiban Dame na Koi",NPJH50909,L"NPJH50909"}},
{0x0891D72C,{"Dunamis15",ULJM06119,L"ULJM06119"}},
{0x88506d0,{"Princess Evangile Portable",ULJM06036,L"ULJM06036"}},
};
return 1;
}();