From 57cd734dbcc5c2e6529f824dbe38f6370b930f00 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 19 Apr 2016 07:20:41 +0200 Subject: [PATCH] Don't regulate Framerate on Pandora Restrict the Eps precision change only to Pandora platform fix Inverted Right and Middle button on certain case with SDL Added some Failsafe. Fixed a crash in the new game intro cinematic (when Boss of TFE die and Sam goes to the UFO) on the Pandora Some Pandora fine-tunning Tried some asynchronus input method, but doesn't seems to works --- Sources/Engine/Base/SDL/SDLInput.cpp | 38 +++++++++++++++------------ Sources/Engine/Engine.cpp | 15 +++++++++++ Sources/Engine/Math/Quaternion.h | 4 +++ Sources/Engine/Rendering/RendASER.cpp | 5 ++-- Sources/SeriousSam/SeriousSam.cpp | 3 +++ 5 files changed, 45 insertions(+), 20 deletions(-) mode change 100644 => 100755 Sources/Engine/Engine.cpp mode change 100644 => 100755 Sources/Engine/Rendering/RendASER.cpp mode change 100644 => 100755 Sources/SeriousSam/SeriousSam.cpp diff --git a/Sources/Engine/Base/SDL/SDLInput.cpp b/Sources/Engine/Base/SDL/SDLInput.cpp index d378cc1..17ebefa 100755 --- a/Sources/Engine/Base/SDL/SDLInput.cpp +++ b/Sources/Engine/Base/SDL/SDLInput.cpp @@ -251,6 +251,10 @@ static int _iMouseZ = 0; static BOOL _bWheelUp = FALSE; static BOOL _bWheelDn = FALSE; +// emulate Win32: A single mouse wheel rotation +// is +120 (upwards) or -120 (downwards) +#define MOUSE_SCROLL_INTERVAL 120 + CTCriticalSection csInput; // which keys are pressed, as recorded by message interception (by KIDs) @@ -314,15 +318,20 @@ static void sdl_event_handler(const SDL_Event *event) case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: - if (event->button.button <= 5) - _abKeysPressed[KID_MOUSE1 + (event->button.button-1)] = (event->button.state == SDL_PRESSED) ? TRUE : FALSE; + if (event->button.button <= 5) { + int button = KID_MOUSE1; + switch(event->button.button) { + case SDL_BUTTON_RIGHT: button = KID_MOUSE2; break; + case SDL_BUTTON_MIDDLE: button = KID_MOUSE3; break; + case 4: button = KID_MOUSE4; break; + case 5: button = KID_MOUSE5; break; + } + _abKeysPressed[button] = (event->button.state == SDL_PRESSED) ? TRUE : FALSE; + } break; case SDL_MOUSEWHEEL: - if (event->wheel.y > 0) - _abKeysPressed[KID_MOUSEWHEELUP] = TRUE; - else if (event->wheel.y < 0) - _abKeysPressed[KID_MOUSEWHEELDOWN] = TRUE; + _iMouseZ += event->wheel.y * MOUSE_SCROLL_INTERVAL; break; case SDL_KEYDOWN: @@ -715,6 +724,7 @@ void CInput::GetInput(BOOL bPreScan) // clear button's buffer memset( inp_ubButtonsBuffer, 0, sizeof( inp_ubButtonsBuffer)); + Uint8 *keystate = SDL_GetKeyboardState(NULL); // for each Key for (INDEX iKey=0; iKey=0) { // is state is pressed - if (SDL_GetKeyboardState(NULL)[SDL_GetScancodeFromKey((SDL_Keycode)iVirt)]) { + if (keystate[SDL_GetScancodeFromKey((SDL_Keycode)iVirt)]) { // mark it as pressed inp_ubButtonsBuffer[iKID] = 0xFF; } @@ -744,10 +754,6 @@ void CInput::GetInput(BOOL bPreScan) } } - // reset this every frame (since we explicitly ignore the button-up events). - _abKeysPressed[KID_MOUSEWHEELUP] = FALSE; - _abKeysPressed[KID_MOUSEWHEELDOWN] = FALSE; - // read mouse position #ifdef USE_MOUSEWARP int iMx, iMy; @@ -816,17 +822,16 @@ void CInput::GetInput(BOOL bPreScan) } #endif -/* // if not pre-scanning if (!bPreScan) { // detect wheel up/down movement - _bWheelDn = FALSE; + if (_iMouseZ>0) { if (_bWheelUp) { inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00; } else { inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF; - _iMouseZ = ClampDn(_iMouseZ-120, 0); + _iMouseZ = ClampDn(_iMouseZ-MOUSE_SCROLL_INTERVAL, 0); } } _bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP]; @@ -835,12 +840,11 @@ void CInput::GetInput(BOOL bPreScan) inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00; } else { inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF; - _iMouseZ = ClampUp(_iMouseZ+120, 0); + _iMouseZ = ClampUp(_iMouseZ+MOUSE_SCROLL_INTERVAL, 0); } } _bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN]; } -*/ inp_bLastPrescan = bPreScan; diff --git a/Sources/Engine/Engine.cpp b/Sources/Engine/Engine.cpp old mode 100644 new mode 100755 index 15021ca..84e5944 --- a/Sources/Engine/Engine.cpp +++ b/Sources/Engine/Engine.cpp @@ -127,6 +127,9 @@ static void DetectCPU(void) { #if (defined USE_PORTABLE_C) // rcg10072001 CPrintF(TRANSV(" (No CPU detection in this binary.)\n")); + #ifdef PLATFORM_PANDORA + sys_iCPUMHz = 400; // conservative, ARM -> x86 cpu translation is not 1 to 1. + #endif #else char strVendor[12+1]; @@ -398,7 +401,19 @@ static void SetupMemoryManager(void) sys_iRAMSwap = ms.dwTotalPageFile/MB; #elif (defined PLATFORM_UNIX) + #ifdef PLATFORM_PANDORA + sys_iRAMPhys = 256; // conservative here, there is 256MB models and 512MB... + FILE* esrev = fopen("/etc/powervr-esrev", "r"); + if (esrev) { + int rev = 0; + fscanf(esrev,"%d", &rev); + if (rev==3 || rev==5) + sys_iRAMPhys = 512; + fclose(esrev); + }; + #else sys_iRAMPhys = 1; // !!! FIXME: This is bad. Bad. BAD. + #endif sys_iRAMSwap = 1; #else diff --git a/Sources/Engine/Math/Quaternion.h b/Sources/Engine/Math/Quaternion.h index b46c078..19dbae5 100755 --- a/Sources/Engine/Math/Quaternion.h +++ b/Sources/Engine/Math/Quaternion.h @@ -370,7 +370,11 @@ void Quaternion::FromEuler(const Vector &a) template Type Quaternion::EPS(Type orig) const { +#ifdef PLATFORM_PANDORA + if ((orig <= 1e-4f) && (orig >= -1e-4f)) +#else if ((orig <= 10e-6f) && (orig >= -10e-6f)) +#endif return(0.0f); return(orig); diff --git a/Sources/Engine/Rendering/RendASER.cpp b/Sources/Engine/Rendering/RendASER.cpp old mode 100644 new mode 100755 index e5d52b0..7428a11 --- a/Sources/Engine/Rendering/RendASER.cpp +++ b/Sources/Engine/Rendering/RendASER.cpp @@ -34,7 +34,6 @@ void CRenderer::AddAddListToActiveList(INDEX iScanLine) // allocate space in destination for sum of source and add INDEX ctActiveEdges = re_aaceActiveEdges.Count(); re_aaceActiveEdgesTmp.Push(ctAddEdges+ctActiveEdges); - // check that the add list is sorted right #if ASER_EXTREME_CHECKING { @@ -66,18 +65,18 @@ void CRenderer::AddAddListToActiveList(INDEX iScanLine) // start at begining of add list, source active list and destination active list LISTITER(CAddEdge, ade_lnInAdd) itadeAdd(lhAdd); CActiveEdge *paceSrc = &re_aaceActiveEdges[0]; + CActiveEdge *paceEnd = &re_aaceActiveEdges[re_aaceActiveEdges.Count()-1]; CActiveEdge *paceDst = &re_aaceActiveEdgesTmp[0]; IFDEBUG(INDEX ctNewActive=0); IFDEBUG(INDEX ctOldActive1=0); IFDEBUG(INDEX ctOldActive2=0); - // for each edge in add list while(!itadeAdd.IsPastEnd()) { CAddEdge &ade = *itadeAdd; // while the edge in active list is left of the edge in add list - while (paceSrc->ace_xI.slHolder < itadeAdd->ade_xI.slHolder) { + while ((paceSrc->ace_xI.slHolder < ade.ade_xI.slHolder) && (paceSrc!=paceEnd)) { // copy the active edge ASSERT(paceSrc<=&re_aaceActiveEdges[ctActiveEdges-1]); *paceDst++=*paceSrc++; diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp old mode 100644 new mode 100755 index 9b76471..b28ffff --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -281,6 +281,8 @@ static void UpdatePauseState(void) // limit current frame rate if neeeded void LimitFrameRate(void) { + // do not limit FPS on the Pandora, it's not powerfull enough and doesn't "iconise" games either + #ifndef PLATFORM_PANDORA // measure passed time for each loop static CTimerValue tvLast(-1.0f); CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); @@ -299,6 +301,7 @@ void LimitFrameRate(void) // remember new time tvLast = _pTimer->GetHighPrecisionTimer(); + #endif } // load first demo