Fake some of the on screen keyboard

Now games that use it assume the user has input "000000" which seems to
work for most games. Gets Pixel junk monsters deluxe and Worms battle
island in-game
This commit is contained in:
TMaul 2012-12-15 16:42:38 +00:00
parent ffdc96a06a
commit a2a4248381
9 changed files with 294 additions and 24 deletions

View File

@ -121,6 +121,7 @@
<ClCompile Include="Debugger\SymbolMap.cpp" />
<ClCompile Include="Dialog\PSPDialog.cpp" />
<ClCompile Include="Dialog\PSPMsgDialog.cpp" />
<ClCompile Include="Dialog\PSPOskDialog.cpp" />
<ClCompile Include="Dialog\PSPPlaceholderDialog.cpp" />
<ClCompile Include="Dialog\PSPSaveDialog.cpp" />
<ClCompile Include="Dialog\SavedataParam.cpp" />
@ -263,6 +264,7 @@
<ClInclude Include="Debugger\SymbolMap.h" />
<ClInclude Include="Dialog\PSPDialog.h" />
<ClInclude Include="Dialog\PSPMsgDialog.h" />
<ClInclude Include="Dialog\PSPOskDialog.h" />
<ClInclude Include="Dialog\PSPPlaceholderDialog.h" />
<ClInclude Include="Dialog\PSPSaveDialog.h" />
<ClInclude Include="Dialog\SavedataParam.h" />

View File

@ -339,6 +339,9 @@
<ClCompile Include="Dialog\SavedataParam.cpp">
<Filter>Dialog</Filter>
</ClCompile>
<ClCompile Include="Dialog\PSPOskDialog.cpp">
<Filter>Dialog</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@ -623,6 +626,9 @@
<ClInclude Include="Dialog\SavedataParam.h">
<Filter>Dialog</Filter>
</ClInclude>
<ClInclude Include="Dialog\PSPOskDialog.h">
<Filter>Dialog</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />

View File

@ -24,6 +24,20 @@
#define SCE_UTILITY_DIALOG_RESULT_CANCEL 1
#define SCE_UTILITY_DIALOG_RESULT_ABORT 2
typedef struct
{
unsigned int size; /** Size of the structure */
int language; /** Language */
int buttonSwap; /** Set to 1 for X/O button swap */
int graphicsThread; /** Graphics thread priority */
int accessThread; /** Access/fileio thread priority (SceJobThread) */
int fontThread; /** Font thread priority (ScePafThread) */
int soundThread; /** Sound thread priority */
int result; /** Result */
int reserved[4]; /** Set to 0 */
} pspUtilityDialogCommon;
class PSPDialog
{

View File

@ -24,20 +24,6 @@
#define SCE_UTILITY_MSGDIALOG_OPTION_YESNO 0x00000010
#define SCE_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO 0x00000100
typedef struct
{
unsigned int size; /** Size of the structure */
int language; /** Language */
int buttonSwap; /** Set to 1 for X/O button swap */
int graphicsThread; /** Graphics thread priority */
int accessThread; /** Access/fileio thread priority (SceJobThread) */
int fontThread; /** Font thread priority (ScePafThread) */
int soundThread; /** Sound thread priority */
int result; /** Result */
int reserved[4]; /** Set to 0 */
} pspUtilityDialogCommon;
struct pspMessageDialog
{
pspUtilityDialogCommon common;

View File

@ -0,0 +1,211 @@
// 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 "PSPOskDialog.h"
#include "../Util/PPGeDraw.h"
#include "../HLE/sceCtrl.h"
/**
* Enumeration for input language
*/
enum SceUtilityOskInputLanguage
{
PSP_UTILITY_OSK_LANGUAGE_DEFAULT = 0x00,
PSP_UTILITY_OSK_LANGUAGE_JAPANESE = 0x01,
PSP_UTILITY_OSK_LANGUAGE_ENGLISH = 0x02,
PSP_UTILITY_OSK_LANGUAGE_FRENCH = 0x03,
PSP_UTILITY_OSK_LANGUAGE_SPANISH = 0x04,
PSP_UTILITY_OSK_LANGUAGE_GERMAN = 0x05,
PSP_UTILITY_OSK_LANGUAGE_ITALIAN = 0x06,
PSP_UTILITY_OSK_LANGUAGE_DUTCH = 0x07,
PSP_UTILITY_OSK_LANGUAGE_PORTUGESE = 0x08,
PSP_UTILITY_OSK_LANGUAGE_RUSSIAN = 0x09,
PSP_UTILITY_OSK_LANGUAGE_KOREAN = 0x0a
};
/**
* Enumeration for OSK internal state
*/
enum SceUtilityOskState
{
PSP_UTILITY_OSK_DIALOG_NONE = 0, /**< No OSK is currently active */
PSP_UTILITY_OSK_DIALOG_INITING, /**< The OSK is currently being initialized */
PSP_UTILITY_OSK_DIALOG_INITED, /**< The OSK is initialised */
PSP_UTILITY_OSK_DIALOG_VISIBLE, /**< The OSK is visible and ready for use */
PSP_UTILITY_OSK_DIALOG_QUIT, /**< The OSK has been cancelled and should be shut down */
PSP_UTILITY_OSK_DIALOG_FINISHED /**< The OSK has successfully shut down */
};
/**
* Enumeration for OSK field results
*/
enum SceUtilityOskResult
{
PSP_UTILITY_OSK_RESULT_UNCHANGED = 0,
PSP_UTILITY_OSK_RESULT_CANCELLED,
PSP_UTILITY_OSK_RESULT_CHANGED
};
/**
* Enumeration for input types (these are limited by initial choice of language)
*/
enum SceUtilityOskInputType
{
PSP_UTILITY_OSK_INPUTTYPE_ALL = 0x00000000,
PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT = 0x00000001,
PSP_UTILITY_OSK_INPUTTYPE_LATIN_SYMBOL = 0x00000002,
PSP_UTILITY_OSK_INPUTTYPE_LATIN_LOWERCASE = 0x00000004,
PSP_UTILITY_OSK_INPUTTYPE_LATIN_UPPERCASE = 0x00000008,
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_DIGIT = 0x00000100,
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_SYMBOL = 0x00000200,
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_LOWERCASE = 0x00000400,
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_UPPERCASE = 0x00000800,
// http://en.wikipedia.org/wiki/Hiragana
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HIRAGANA = 0x00001000,
// http://en.wikipedia.org/wiki/Katakana
// Half-width Katakana
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HALF_KATAKANA = 0x00002000,
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KATAKANA = 0x00004000,
// http://en.wikipedia.org/wiki/Kanji
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KANJI = 0x00008000,
PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_LOWERCASE = 0x00010000,
PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_UPPERCASE = 0x00020000,
PSP_UTILITY_OSK_INPUTTYPE_KOREAN = 0x00040000,
PSP_UTILITY_OSK_INPUTTYPE_URL = 0x00080000
};
/**
* OSK Field data
*/
typedef struct _SceUtilityOskData
{
/** Unknown. Pass 0. */
int unk_00;
/** Unknown. Pass 0. */
int unk_04;
/** One of ::SceUtilityOskInputLanguage */
int language;
/** Unknown. Pass 0. */
int unk_12;
/** One or more of ::SceUtilityOskInputType (types that are selectable by pressing SELECT) */
int inputtype;
/** Number of lines */
int lines;
/** Unknown. Pass 0. */
int unk_24;
/** Description text */
u32 descPtr;
/** Initial text */
u32 intextPtr;
/** Length of output text */
int outtextlength;
/** Pointer to the output text */
u32 outtextPtr;
/** Result. One of ::SceUtilityOskResult */
int result;
/** The max text that can be input */
int outtextlimit;
} SceUtilityOskData;
/**
* OSK parameters
*/
typedef struct _SceUtilityOskParams
{
pspUtilityDialogCommon base;
int datacount; /** Number of input fields */
u32 SceUtilityOskDataPtr; /** Pointer to the start of the data for the input fields */
int state; /** The local OSK state, one of ::SceUtilityOskState */
int unk_60;/** Unknown. Pass 0 */
} SceUtilityOskParams;
SceUtilityOskParams oskParams;
SceUtilityOskData oskData;
std::string oskDesc;
std::string oskIntext;
std::string oskOuttext;
int oskParamsAddr;
PSPOskDialog::PSPOskDialog() : PSPDialog() {
}
PSPOskDialog::~PSPOskDialog() {
}
int PSPOskDialog::Init(u32 oskPtr)
{
status = SCE_UTILITY_STATUS_INITIALIZE;
memset(&oskParams, 0, sizeof(oskParams));
memset(&oskData, 0, sizeof(oskData));
oskParamsAddr = oskPtr;
if (Memory::IsValidAddress(oskPtr))
{
Memory::ReadStruct(oskPtr, &oskParams);
Memory::ReadStruct(oskParams.SceUtilityOskDataPtr, &oskData);
Memory::GetStringWide(oskDesc, oskData.descPtr);
Memory::GetStringWide(oskIntext, oskData.intextPtr);
Memory::GetString(oskOuttext, oskData.outtextPtr);
Memory::WriteStruct(oskParams.SceUtilityOskDataPtr, &oskData);
Memory::WriteStruct(oskPtr, &oskParams);
}
else
{
return -1;
}
return 0;
}
void PSPOskDialog::Update()
{
//__UtilityUpdate();
if (status == SCE_UTILITY_STATUS_INITIALIZE)
{
status = SCE_UTILITY_STATUS_RUNNING;
}
else if (status == SCE_UTILITY_STATUS_RUNNING)
{
status = SCE_UTILITY_STATUS_FINISHED;
}
else if (status == SCE_UTILITY_STATUS_FINISHED)
{
status = SCE_UTILITY_STATUS_SHUTDOWN;
}
Memory::Write_U16(0x0050,oskData.outtextPtr);
Memory::Write_U16(0x0050,oskData.outtextPtr+2);
Memory::Write_U16(0x0050,oskData.outtextPtr+4);
Memory::Write_U16(0x0050,oskData.outtextPtr+6);
Memory::Write_U16(0x0050,oskData.outtextPtr+8);
Memory::Write_U16(0x0050,oskData.outtextPtr+10);
Memory::Write_U16(0x0050,oskData.outtextPtr+12);
oskData.outtextlength = 6;
oskParams.base.result= 0;
oskData.result = SceUtilityOskResult::PSP_UTILITY_OSK_RESULT_CHANGED;
Memory::WriteStruct(oskParams.SceUtilityOskDataPtr, &oskData);
Memory::WriteStruct(oskParamsAddr, &oskParams);
}

View File

@ -0,0 +1,30 @@
// 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
#include "PSPDialog.h"
#include "../Core/MemMap.h"
class PSPOskDialog: public PSPDialog {
public:
PSPOskDialog();
virtual ~PSPOskDialog();
virtual int Init(u32 oskPtr);
virtual void Update();
};

View File

@ -27,15 +27,15 @@
#include "../Dialog/PSPSaveDialog.h"
#include "../Dialog/PSPMsgDialog.h"
#include "../Dialog/PSPPlaceholderDialog.h"
#include "../Dialog/PSPOskDialog.h"
PSPSaveDialog saveDialog;
PSPMsgDialog msgDialog;
PSPPlaceholderDialog oskDialog;
PSPOskDialog oskDialog;
PSPPlaceholderDialog netDialog;
void __UtilityInit()
{
SavedataParam::Init();
}
@ -66,7 +66,6 @@ void sceUtilitySavedataUpdate(u32 unknown)
return;
}
#define PSP_AV_MODULE_AVCODEC 0
#define PSP_AV_MODULE_SASCORE 1
#define PSP_AV_MODULE_ATRAC3PLUS 2 // Requires PSP_AV_MODULE_AVCODEC loading first
@ -118,29 +117,33 @@ u32 sceUtilityMsgDialogGetStatus()
// On screen keyboard
int sceUtilityOskInitStart(unsigned int)
int sceUtilityOskInitStart(u32 oskPtr)
{
DEBUG_LOG(HLE,"FAKE sceUtilityOskInitStart(%i)", PARAM(0));
oskDialog.Init();
return 0;
ERROR_LOG(HLE,"FAKE sceUtilityOskInitStart(%i)", PARAM(0));
return oskDialog.Init(oskPtr);
}
int sceUtilityOskShutdownStart()
{
DEBUG_LOG(HLE,"FAKE sceUtilityOskShutdownStart(%i)", PARAM(0));
ERROR_LOG(HLE,"FAKE sceUtilityOskShutdownStart(%i)", PARAM(0));
oskDialog.Shutdown();
return 0;
}
void sceUtilityOskUpdate(unsigned int unknown)
{
DEBUG_LOG(HLE,"FAKE sceUtilityOskUpdate(%i)", unknown);
ERROR_LOG(HLE,"FAKE sceUtilityOskUpdate(%i)", unknown);
oskDialog.Update();
}
int sceUtilityOskGetStatus()
{
return oskDialog.GetStatus();
int statusa = oskDialog.GetStatus();
if (statusa == 4)
{
statusa = 5;
}
return statusa;
}

View File

@ -175,6 +175,22 @@ void GetString(std::string& _string, const u32 em_address)
_string = stringBuffer;
}
// Same as get string but read out 16bit
void GetStringWide(std::string& _string, const u32 em_address)
{
char stringBuffer[2048];
char *string = stringBuffer;
char c;
u32 addr = em_address;
while ((c = (Read_U16(addr))))
{
*string++ = c;
addr+=2;
}
*string++ = '\0';
_string = stringBuffer;
}
const char *GetAddressName(u32 address)
{
// TODO, follow GetPointer

View File

@ -246,6 +246,8 @@ inline void Write_Float(float f, u32 address)
// Reads a zero-terminated string from memory at the address.
void GetString(std::string& _string, const u32 _Address);
void GetStringWide(std::string& _string, const u32 _Address);
u8* GetPointer(const u32 address);
bool IsValidAddress(const u32 address);