From 0414b072a4613c63b2740918301ecc6f7b841fed Mon Sep 17 00:00:00 2001 From: TMaul Date: Sat, 15 Dec 2012 17:13:58 +0000 Subject: [PATCH] Display OSK message And some cleanup --- Core/Dialog/PSPDialog.cpp | 5 ++++ Core/Dialog/PSPDialog.h | 2 +- Core/Dialog/PSPMsgDialog.cpp | 6 +---- Core/Dialog/PSPMsgDialog.h | 1 - Core/Dialog/PSPOskDialog.cpp | 50 ++++++++++++++++++++++++++++-------- Core/Dialog/PSPOskDialog.h | 2 ++ Core/HLE/sceRtc.cpp | 3 ++- Core/HLE/sceUtility.cpp | 9 ++++--- Core/MemMap.cpp | 16 ------------ Core/MemMap.h | 3 --- 10 files changed, 55 insertions(+), 42 deletions(-) diff --git a/Core/Dialog/PSPDialog.cpp b/Core/Dialog/PSPDialog.cpp index ff80ac13ca..0f0e469543 100644 --- a/Core/Dialog/PSPDialog.cpp +++ b/Core/Dialog/PSPDialog.cpp @@ -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; diff --git a/Core/Dialog/PSPDialog.h b/Core/Dialog/PSPDialog.h index 5f223f8ca6..efab28f823 100644 --- a/Core/Dialog/PSPDialog.h +++ b/Core/Dialog/PSPDialog.h @@ -63,7 +63,7 @@ public: void EndDraw(); protected: bool IsButtonPressed(int checkButton); - + void DisplayMessage(std::string text); DialogStatus status; unsigned int lastButtons; diff --git a/Core/Dialog/PSPMsgDialog.cpp b/Core/Dialog/PSPMsgDialog.cpp index 0d021e8063..de9c2b263a 100644 --- a/Core/Dialog/PSPMsgDialog.cpp +++ b/Core/Dialog/PSPMsgDialog.cpp @@ -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() { diff --git a/Core/Dialog/PSPMsgDialog.h b/Core/Dialog/PSPMsgDialog.h index 4b9017275a..e3c1af1699 100644 --- a/Core/Dialog/PSPMsgDialog.h +++ b/Core/Dialog/PSPMsgDialog.h @@ -46,7 +46,6 @@ public: void Shutdown(); private : - void DisplayMessage(std::string text); void DisplayBack(); void DisplayYesNo(); void DisplayEnterBack(); diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 32bf6f6330..dc993e3fa9 100644 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -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; diff --git a/Core/Dialog/PSPOskDialog.h b/Core/Dialog/PSPOskDialog.h index 3c0582a4ad..889fac9a7e 100644 --- a/Core/Dialog/PSPOskDialog.h +++ b/Core/Dialog/PSPOskDialog.h @@ -26,5 +26,7 @@ public: virtual int Init(u32 oskPtr); virtual void Update(); +private: + void HackyGetStringWide(std::string& _string, const u32 em_address); }; diff --git a/Core/HLE/sceRtc.cpp b/Core/HLE/sceRtc.cpp index bba0bb1f98..8d1f3256c7 100644 --- a/Core/HLE/sceRtc.cpp +++ b/Core/HLE/sceRtc.cpp @@ -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)) diff --git a/Core/HLE/sceUtility.cpp b/Core/HLE/sceUtility.cpp index 9974b922c7..a2530c7f04 100644 --- a/Core/HLE/sceUtility.cpp +++ b/Core/HLE/sceUtility.cpp @@ -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; } diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index fe046023bc..38a5027173 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -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 diff --git a/Core/MemMap.h b/Core/MemMap.h index b775a4ffc4..6f9a13b91e 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -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);