Display OSK message

And some cleanup
This commit is contained in:
TMaul 2012-12-15 17:13:58 +00:00
parent a2a4248381
commit 0414b072a4
10 changed files with 55 additions and 42 deletions

View File

@ -48,6 +48,11 @@ void PSPDialog::EndDraw()
PPGeEnd();
}
void PSPDialog::DisplayMessage(std::string text)
{
PPGeDrawText(text.c_str(), 480/2, 100, PPGE_ALIGN_CENTER, 0.5f, 0xFFFFFFFF);
}
void PSPDialog::Shutdown()
{
status = SCE_UTILITY_STATUS_SHUTDOWN;

View File

@ -63,7 +63,7 @@ public:
void EndDraw();
protected:
bool IsButtonPressed(int checkButton);
void DisplayMessage(std::string text);
DialogStatus status;
unsigned int lastButtons;

View File

@ -60,16 +60,12 @@ void PSPMsgDialog::Init(unsigned int paramAddr)
}
void PSPMsgDialog::DisplayMessage(std::string text)
{
PPGeDrawText(text.c_str(), 480/2, 100, PPGE_ALIGN_CENTER, 0.5f, 0xFFFFFFFF);
}
void PSPMsgDialog::DisplayBack()
{
PPGeDrawImage(cancelButtonImg, 250, 220, 20, 20, 0, 0xFFFFFFFF);
PPGeDrawText("Back", 270, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
}
void PSPMsgDialog::DisplayYesNo()
{

View File

@ -46,7 +46,6 @@ public:
void Shutdown();
private :
void DisplayMessage(std::string text);
void DisplayBack();
void DisplayYesNo();
void DisplayEnterBack();

View File

@ -153,6 +153,22 @@ PSPOskDialog::~PSPOskDialog() {
}
// Same as get string but read out 16bit
void PSPOskDialog::HackyGetStringWide(std::string& _string, const u32 em_address)
{
char stringBuffer[2048];
char *string = stringBuffer;
char c;
u32 addr = em_address;
while ((c = (Memory::Read_U16(addr))))
{
*string++ = c;
addr+=2;
}
*string++ = '\0';
_string = stringBuffer;
}
int PSPOskDialog::Init(u32 oskPtr)
{
@ -165,9 +181,9 @@ int PSPOskDialog::Init(u32 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);
HackyGetStringWide(oskDesc, oskData.descPtr);
HackyGetStringWide(oskIntext, oskData.intextPtr);
HackyGetStringWide(oskOuttext, oskData.outtextPtr);
Memory::WriteStruct(oskParams.SceUtilityOskDataPtr, &oskData);
Memory::WriteStruct(oskPtr, &oskParams);
}
@ -182,6 +198,7 @@ int PSPOskDialog::Init(u32 oskPtr)
void PSPOskDialog::Update()
{
buttons = __CtrlPeekButtons();
//__UtilityUpdate();
if (status == SCE_UTILITY_STATUS_INITIALIZE)
{
@ -189,19 +206,30 @@ void PSPOskDialog::Update()
}
else if (status == SCE_UTILITY_STATUS_RUNNING)
{
status = SCE_UTILITY_STATUS_FINISHED;
StartDraw();
DisplayMessage(oskDesc);
PPGeDrawImage(I_CROSS, 200, 220, 20, 20, 0, 0xFFFFFFFF);
PPGeDrawText("Ignore", 230, 220, PPGE_ALIGN_LEFT, 0.5f, 0xFFFFFFFF);
// TODO : Dialogs should take control over input and not send them to the game while displaying
if (IsButtonPressed(CTRL_CROSS))
{
status = SCE_UTILITY_STATUS_FINISHED;
}
EndDraw();
}
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);
Memory::Write_U16(0x0030,oskData.outtextPtr);
Memory::Write_U16(0x0030,oskData.outtextPtr+2);
Memory::Write_U16(0x0030,oskData.outtextPtr+4);
Memory::Write_U16(0x0030,oskData.outtextPtr+6);
Memory::Write_U16(0x0030,oskData.outtextPtr+8);
Memory::Write_U16(0x0030,oskData.outtextPtr+10);
Memory::Write_U16(0x0030,oskData.outtextPtr+12);
oskData.outtextlength = 6;
oskParams.base.result= 0;
oskData.result = SceUtilityOskResult::PSP_UTILITY_OSK_RESULT_CHANGED;

View File

@ -26,5 +26,7 @@ public:
virtual int Init(u32 oskPtr);
virtual void Update();
private:
void HackyGetStringWide(std::string& _string, const u32 em_address);
};

View File

@ -184,7 +184,8 @@ u32 sceRtcGetTickResolution()
u32 sceRtcGetCurrentTick(u32 tickPtr)
{
DEBUG_LOG(HLE, "sceRtcGetCurrentTick(%08x)", tickPtr);
//Don't spam the log
//DEBUG_LOG(HLE, "sceRtcGetCurrentTick(%08x)", tickPtr);
u64 curTick = __RtcGetCurrentTick();
if (Memory::IsValidAddress(tickPtr))

View File

@ -138,12 +138,13 @@ void sceUtilityOskUpdate(unsigned int unknown)
int sceUtilityOskGetStatus()
{
int statusa = oskDialog.GetStatus();
if (statusa == 4)
int status = oskDialog.GetStatus();
// Seems that 4 is the cancelled status for OSK?
if (status == 4)
{
statusa = 5;
status = 5;
}
return statusa;
return status;
}

View File

@ -175,22 +175,6 @@ 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,9 +246,6 @@ 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);