mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Second to last commit
Everything but getting ISO name
This commit is contained in:
parent
0b2885c2fe
commit
9d2667fc0d
@ -22,6 +22,27 @@
|
|||||||
#include "CommonPaths.h"
|
#include "CommonPaths.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
|
||||||
|
long parseHexLong(std::string s) {
|
||||||
|
long value = 0;
|
||||||
|
|
||||||
|
if (s.substr(0,2) == "0x") {
|
||||||
|
//s = s.substr(2);
|
||||||
|
}
|
||||||
|
value = strtoul(s.c_str(),0, 0);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
long parseLong(std::string s) {
|
||||||
|
long value = 0;
|
||||||
|
if (s.substr(0,2) == "0x") {
|
||||||
|
s = s.substr(2);
|
||||||
|
value = strtol(s.c_str(),NULL, 16);
|
||||||
|
} else {
|
||||||
|
value = strtol(s.c_str(),NULL, 10);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// faster than sscanf
|
// faster than sscanf
|
||||||
bool AsciiToHex(const char* _szValue, u32& result)
|
bool AsciiToHex(const char* _szValue, u32& result)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
#include <base/stringutil.h>
|
#include <base/stringutil.h>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
long parseHexLong(std::string s);
|
||||||
|
long parseLong(std::string s);
|
||||||
std::string StringFromFormat(const char* format, ...);
|
std::string StringFromFormat(const char* format, ...);
|
||||||
// Cheap!
|
// Cheap!
|
||||||
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args);
|
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args);
|
||||||
|
@ -80,6 +80,7 @@ public:
|
|||||||
bool bTexDeposterize;
|
bool bTexDeposterize;
|
||||||
int iFpsLimit;
|
int iFpsLimit;
|
||||||
u32 iMaxRecent;
|
u32 iMaxRecent;
|
||||||
|
int iEnableCheats;
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
bool bEnableSound;
|
bool bEnableSound;
|
||||||
|
120
Core/CwCheat.cpp
120
Core/CwCheat.cpp
@ -1,39 +1,48 @@
|
|||||||
#include "CwCheat.h"
|
#include "CwCheat.h"
|
||||||
#include "../Core/CoreTiming.h"
|
#include "../Core/CoreTiming.h"
|
||||||
#include "../Core/CoreParameter.h"
|
#include "../Core/CoreParameter.h"
|
||||||
|
#include "StringUtils.h"
|
||||||
|
#include "Common/FileUtil.h"
|
||||||
|
#include "Config.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static int CheatEvent = -1;
|
static int CheatEvent = -1;
|
||||||
CheatsGUI member;
|
CWCheatEngine member;
|
||||||
CheatsGUI cheatsThread;
|
CWCheatEngine cheatsThread;
|
||||||
|
|
||||||
void hleCheat(u64 userdata, int cyclesLate);
|
void hleCheat(u64 userdata, int cyclesLate);
|
||||||
|
|
||||||
|
|
||||||
void __CheatInit() {
|
void __CheatInit() {
|
||||||
|
|
||||||
CheatEvent = CoreTiming::RegisterEvent("CheatEvent", &hleCheat);
|
CheatEvent = CoreTiming::RegisterEvent("CheatEvent", &hleCheat);
|
||||||
CoreTiming::ScheduleEvent(msToCycles(600), CheatEvent, 0);
|
CoreTiming::ScheduleEvent(msToCycles(77), CheatEvent, 0);
|
||||||
|
File::CreateFullPath("Cheats");
|
||||||
|
if (!File::Exists("Cheats/Cheats.ini")) {
|
||||||
|
File::CreateEmptyFile("Cheats/Cheats.ini");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void __CheatShutdown() {
|
void __CheatShutdown() {
|
||||||
member.Exit();
|
member.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hleCheat(u64 userdata, int cyclesLate) {
|
void hleCheat(u64 userdata, int cyclesLate) {
|
||||||
CoreTiming::ScheduleEvent(msToCycles(660), CheatEvent, 0);
|
CoreTiming::ScheduleEvent(msToCycles(77), CheatEvent, 0);
|
||||||
|
if (g_Config.iEnableCheats == 1) {
|
||||||
member.Run();
|
member.Run();
|
||||||
}
|
}
|
||||||
CheatsGUI::CheatsGUI() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatsGUI::Exit() {
|
CWCheatEngine::CWCheatEngine() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWCheatEngine::Exit() {
|
||||||
exit2 = true;
|
exit2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string CheatsGUI::GetNextCode() {
|
string CWCheatEngine::GetNextCode() {
|
||||||
string code;
|
string code;
|
||||||
string modifier = "_L";
|
string modifier = "_L";
|
||||||
char modifier2 = ' ';
|
char modifier2 = '0';
|
||||||
while (true) {
|
while (true) {
|
||||||
if (currentCode >= codes.size()) {
|
if (currentCode >= codes.size()) {
|
||||||
code.clear();
|
code.clear();
|
||||||
@ -53,7 +62,7 @@ string CheatsGUI::GetNextCode() {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatsGUI::skipCodes(int count) {
|
void CWCheatEngine::skipCodes(int count) {
|
||||||
for (int i = 0; i < count; i ++) {
|
for (int i = 0; i < count; i ++) {
|
||||||
if (GetNextCode() == "") {
|
if (GetNextCode() == "") {
|
||||||
break;
|
break;
|
||||||
@ -61,11 +70,11 @@ void CheatsGUI::skipCodes(int count) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatsGUI::skipAllCodes() {
|
void CWCheatEngine::skipAllCodes() {
|
||||||
currentCode = codes.size();
|
currentCode = codes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CheatsGUI::getAddress(int value) {
|
int CWCheatEngine::getAddress(int value) {
|
||||||
// The User space base address has to be added to given value
|
// The User space base address has to be added to given value
|
||||||
return (value + 0x08800000) & 0x3FFFFFFF;
|
return (value + 0x08800000) & 0x3FFFFFFF;
|
||||||
}
|
}
|
||||||
@ -73,7 +82,7 @@ int CheatsGUI::getAddress(int value) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CheatsGUI::AddCheatLine(string& line) {
|
void CWCheatEngine::AddCheatLine(string& line) {
|
||||||
//Need GUI text area here
|
//Need GUI text area here
|
||||||
string cheatCodes;
|
string cheatCodes;
|
||||||
if (cheatCodes.length() <= 0) {
|
if (cheatCodes.length() <= 0) {
|
||||||
@ -81,29 +90,7 @@ void CheatsGUI::AddCheatLine(string& line) {
|
|||||||
} else {
|
} else {
|
||||||
cheatCodes += "\n" + line;
|
cheatCodes += "\n" + line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline static long parseHexLong(string s) {
|
|
||||||
long value = 0;
|
|
||||||
|
|
||||||
if (s.substr(0,2) == "0x") {
|
|
||||||
s = s.substr(2);
|
|
||||||
}
|
|
||||||
value = strtol(s.c_str(),NULL, 16);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
inline static long parseLong(string s) {
|
|
||||||
long value = 0;
|
|
||||||
if (s.substr(0,2) == "0x") {
|
|
||||||
s = s.substr(2);
|
|
||||||
value = strtol(s.c_str(),NULL, 16);
|
|
||||||
} else {
|
|
||||||
value = strtol(s.c_str(),NULL, 10);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void trim2(string& str)
|
inline void trim2(string& str)
|
||||||
{
|
{
|
||||||
@ -128,40 +115,55 @@ inline vector<string> makeCodeParts(string l) {
|
|||||||
}
|
}
|
||||||
trim2(l);
|
trim2(l);
|
||||||
istringstream iss (l);
|
istringstream iss (l);
|
||||||
for (std::string each; std::getline(iss, each, split_char);parts.push_back(each))
|
std::string each;
|
||||||
{}
|
while (std::getline(iss, each, split_char)) {
|
||||||
|
parts.push_back(each);
|
||||||
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> CheatsGUI::GetCodesList() {
|
vector<string> CWCheatEngine::GetCodesList() {
|
||||||
string text = "0x203BFA00 0x05F5E0FF";
|
string line;
|
||||||
vector<string> codeslist;
|
char* skip = "//";
|
||||||
codeslist = makeCodeParts(text);
|
vector<string> codesList; //Read from INI here
|
||||||
trim2(codeslist[0]);
|
ifstream list("D:\\User\\Steven\\Documents\\GitHub\\ppsspp\\Cheats\\Cheats.ini");
|
||||||
trim2(codeslist[1]);
|
for (int i = 0; !list.eof(); i ++) {
|
||||||
return codeslist;
|
getline(list,line, '\n');
|
||||||
}
|
if (line.substr(0,2) == skip)
|
||||||
|
{line.clear();
|
||||||
void CheatsGUI::OnCheatsThreadEnded() {
|
|
||||||
test = 0;
|
|
||||||
}
|
}
|
||||||
void CheatsGUI::Dispose() {
|
else {
|
||||||
|
codesList.push_back(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for( int i = 0; i < codesList.size(); i++) {
|
||||||
|
trim2(codesList[i]);
|
||||||
|
}
|
||||||
|
return codesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatsGUI::Run() {
|
void CWCheatEngine::Run() {
|
||||||
CheatsGUI cheats;
|
CWCheatEngine cheats;
|
||||||
exit2 = false;
|
exit2 = false;
|
||||||
while (!exit2) {
|
while (!exit2) {
|
||||||
codes = cheats.GetCodesList(); //UI Member
|
codes = cheats.GetCodesList(); //UI Member
|
||||||
currentCode = 0;
|
currentCode = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
string code = "0x203BFA00 0x05F5E0FF";
|
string code = GetNextCode();
|
||||||
|
if (code == "") {
|
||||||
|
Exit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
vector<string>parts = makeCodeParts(code);
|
vector<string>parts = makeCodeParts(code);
|
||||||
|
if (parts[0] == "" || parts.size() < 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
trim2(parts[0]);
|
trim2(parts[0]);
|
||||||
trim2(parts[1]);
|
trim2(parts[1]);
|
||||||
cout << parts[0] << endl << parts[1];
|
//cout << parts[0] << endl << parts[1];
|
||||||
unsigned int comm = (unsigned int)parseHexLong(parts[0]);
|
unsigned int comm = (unsigned int)parseHexLong(parts[0]);
|
||||||
int arg = (int)parseHexLong(parts[1]);
|
int arg = (int)parseHexLong(parts[1]);
|
||||||
int addr = getAddress(comm & 0x0FFFFFFF);
|
int addr = getAddress(comm & 0x0FFFFFFF);
|
||||||
@ -465,16 +467,12 @@ void CheatsGUI::Run() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Exit();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// exiting...
|
// exiting...
|
||||||
cheats.OnCheatsThreadEnded();
|
Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,11 +14,9 @@ using namespace std;
|
|||||||
|
|
||||||
vector<string> makeCodeParts(string l);
|
vector<string> makeCodeParts(string l);
|
||||||
void trim2(string& str);
|
void trim2(string& str);
|
||||||
static long parseLong(string s);
|
|
||||||
static long parseHexLong(string s);
|
|
||||||
|
|
||||||
|
|
||||||
class CheatsGUI {
|
class CWCheatEngine {
|
||||||
private:
|
private:
|
||||||
static long const serialVersionUID = 6791588139795694296L;
|
static long const serialVersionUID = 6791588139795694296L;
|
||||||
static long const int cheatsThreadSleepMillis = 5;
|
static long const int cheatsThreadSleepMillis = 5;
|
||||||
@ -29,14 +27,11 @@ private:
|
|||||||
void skipCodes(int count);
|
void skipCodes(int count);
|
||||||
void skipAllCodes();
|
void skipAllCodes();
|
||||||
int getAddress(int value);
|
int getAddress(int value);
|
||||||
bool test;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CheatsGUI();
|
CWCheatEngine();
|
||||||
string String();
|
string String();
|
||||||
void AddCheatLine(string& line);
|
void AddCheatLine(string& line);
|
||||||
void OnCheatsThreadEnded();
|
|
||||||
void Dispose();
|
|
||||||
vector<string> GetCodesList();
|
vector<string> GetCodesList();
|
||||||
|
|
||||||
void Exit();
|
void Exit();
|
||||||
|
@ -939,6 +939,14 @@ void SystemScreen::render() {
|
|||||||
if (UICheckBox(GEN_ID, x, y += stride, s->T("12HR Time Format"), ALIGN_TOPLEFT, &tf)) {
|
if (UICheckBox(GEN_ID, x, y += stride, s->T("12HR Time Format"), ALIGN_TOPLEFT, &tf)) {
|
||||||
g_Config.itimeformat = tf ? 1 : 0;
|
g_Config.itimeformat = tf ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
bool bEnableCheats = g_Config.iEnableCheats != 0;
|
||||||
|
UICheckBox(GEN_ID, x, y += stride, s->T("Enable Cheats"), ALIGN_TOPLEFT, &bEnableCheats);
|
||||||
|
if (bEnableCheats) {
|
||||||
|
g_Config.iEnableCheats = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
g_Config.iEnableCheats = 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool reportingEnabled = Reporting::IsEnabled();
|
bool reportingEnabled = Reporting::IsEnabled();
|
||||||
const static std::string reportHostOfficial = "report.ppsspp.org";
|
const static std::string reportHostOfficial = "report.ppsspp.org";
|
||||||
|
@ -186,6 +186,9 @@ namespace MainWindow
|
|||||||
void setFpsLimit(int fps) {
|
void setFpsLimit(int fps) {
|
||||||
g_Config.iFpsLimit = fps;
|
g_Config.iFpsLimit = fps;
|
||||||
}
|
}
|
||||||
|
void enableCheats(int cheats){
|
||||||
|
g_Config.iEnableCheats = cheats;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL Show(HINSTANCE hInstance, int nCmdShow)
|
BOOL Show(HINSTANCE hInstance, int nCmdShow)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user