From 129396ef5388741eddd5ea19717613723785e021 Mon Sep 17 00:00:00 2001 From: elasota Date: Sat, 4 Apr 2020 02:20:03 -0400 Subject: [PATCH] Fix more dynamics, fix end screen stars with large vertical resolutions --- Aerofoil/GpAppEnvironment.cpp | 5 + Aerofoil/GpAppEnvironment.h | 1 + Aerofoil/GpMain.cpp | 8 + GpApp/About.cpp | 4 +- GpApp/Banner.cpp | 6 +- GpApp/Dynamics3.cpp | 276 ++++++++++-------- GpApp/Environ.cpp | 22 +- GpApp/Environ.h | 2 +- GpApp/Events.cpp | 2 +- GpApp/GameOver.cpp | 39 ++- GpApp/GliderDefines.h | 2 +- GpApp/GpAppInterface.cpp | 11 + GpApp/HighScores.cpp | 2 +- GpApp/InterfaceInit.cpp | 12 +- GpApp/Main.cpp | 2 +- GpApp/MainWindow.cpp | 18 +- GpApp/Play.cpp | 7 +- GpApp/Settings.cpp | 4 +- GpApp/StructuresInit.cpp | 49 ++-- GpApp/WindowUtils.cpp | 2 +- GpCommon/GpDisplayDriverProperties.h | 4 + .../GpDisplayDriverD3D11.cpp | 6 +- PortabilityLayer/DisplayDeviceManager.h | 1 + PortabilityLayer/GpAppInterface.h | 5 +- 24 files changed, 305 insertions(+), 185 deletions(-) diff --git a/Aerofoil/GpAppEnvironment.cpp b/Aerofoil/GpAppEnvironment.cpp index 07a1d6e..20ede7a 100644 --- a/Aerofoil/GpAppEnvironment.cpp +++ b/Aerofoil/GpAppEnvironment.cpp @@ -94,6 +94,11 @@ void GpAppEnvironment::Render() GpAppInterface_Get()->PL_Render(m_displayDriver); } +void GpAppEnvironment::AdjustRequestedResolution(unsigned int &width, unsigned int &height) +{ + GpAppInterface_Get()->PL_AdjustRequestedResolution(width, height); +} + void GpAppEnvironment::SetDisplayDriver(IGpDisplayDriver *displayDriver) { m_displayDriver = displayDriver; diff --git a/Aerofoil/GpAppEnvironment.h b/Aerofoil/GpAppEnvironment.h index 75f9b6d..5b9bd74 100644 --- a/Aerofoil/GpAppEnvironment.h +++ b/Aerofoil/GpAppEnvironment.h @@ -28,6 +28,7 @@ public: GpDisplayDriverTickStatus_t Tick(IGpFiber *vosFiber); void Render(); + void AdjustRequestedResolution(unsigned int &width, unsigned int &height); void SetDisplayDriver(IGpDisplayDriver *displayDriver); void SetAudioDriver(IGpAudioDriver *audioDriver); diff --git a/Aerofoil/GpMain.cpp b/Aerofoil/GpMain.cpp index 60c1463..6824738 100644 --- a/Aerofoil/GpMain.cpp +++ b/Aerofoil/GpMain.cpp @@ -27,6 +27,11 @@ namespace { static_cast(context)->Render(); } + + void AdjustRequestedResolution(void *context, unsigned int &width, unsigned int &height) + { + static_cast(context)->AdjustRequestedResolution(width, height); + } } int GpMain::Run() @@ -52,6 +57,9 @@ int GpMain::Run() ddProps.m_renderFunc = RenderAppEnvironment; ddProps.m_renderFuncContext = appEnvironment; + ddProps.m_adjustRequestedResolutionFunc = AdjustRequestedResolution; + ddProps.m_adjustRequestedResolutionFuncContext = appEnvironment; + ddProps.m_type = g_gpGlobalConfig.m_displayDriverType; ddProps.m_osGlobals = g_gpGlobalConfig.m_osGlobals; ddProps.m_eventQueue = eventQueue; diff --git a/GpApp/About.cpp b/GpApp/About.cpp index 697987f..9a29500 100644 --- a/GpApp/About.cpp +++ b/GpApp/About.cpp @@ -149,10 +149,10 @@ static void UpdateMainPict (Dialog *theDial) DrawDialogUserText2(theDial, 7, theStr); PasStringCopy(PSTR("Screen: "), theStr); // display screen size/depth - NumToString((long)(thisMac.screen.right - thisMac.screen.left), theStr2); + NumToString((long)(thisMac.fullScreen.right - thisMac.fullScreen.left), theStr2); PasStringConcat(theStr, theStr2); PasStringConcat(theStr, PSTR("x")); - NumToString((long)(thisMac.screen.bottom - thisMac.screen.top), theStr2); + NumToString((long)(thisMac.fullScreen.bottom - thisMac.fullScreen.top), theStr2); PasStringConcat(theStr, theStr2); PasStringConcat(theStr, PSTR("x")); NumToString((long)thisMac.isDepth, theStr2); diff --git a/GpApp/Banner.cpp b/GpApp/Banner.cpp index 7ad70d7..16935b1 100644 --- a/GpApp/Banner.cpp +++ b/GpApp/Banner.cpp @@ -50,7 +50,7 @@ void DrawBanner (Point *topLeft) PLError_t theErr; QSetRect(&wholePage, 0, 0, 330, 220); - mapBounds = thisMac.screen; + mapBounds = thisMac.fullScreen; ZeroRectCorner(&mapBounds); CenterRectInRect(&wholePage, &mapBounds); topLeft->h = wholePage.left; @@ -203,8 +203,8 @@ void DisplayStarsRemaining (void) DrawSurface *surface = mainWindow->GetDrawSurface(); QSetRect(&bounds, 0, 0, 256, 64); - CenterRectInRect(&bounds, &thisMac.screen); - QOffsetRect(&bounds, -thisMac.screen.left, -thisMac.screen.top); + CenterRectInRect(&bounds, &thisMac.fullScreen); + QOffsetRect(&bounds, -thisMac.fullScreen.left, -thisMac.fullScreen.top); src = bounds; InsetRect(&src, 64, 32); diff --git a/GpApp/Dynamics3.cpp b/GpApp/Dynamics3.cpp index 41939e8..6e6c713 100644 --- a/GpApp/Dynamics3.cpp +++ b/GpApp/Dynamics3.cpp @@ -482,56 +482,74 @@ short AddDynamicObject (short what, Rect *where, objectType *who, break; case kBalloon: - dinahs[dynIndex].dest = balloonSrc[0]; - ZeroRectCorner(&dinahs[dynIndex].dest); - QOffsetRect(&dinahs[dynIndex].dest, where->left, 0); - dinahs[dynIndex].dest.bottom = kBalloonStart; - dinahs[dynIndex].dest.top = dinahs[dynIndex].dest.bottom - - RectTall(&balloonSrc[0]); - dinahs[dynIndex].whole = dinahs[dynIndex].dest; - - if (!keepExisting) { - dinahs[dynIndex].hVel = 0; - dinahs[dynIndex].vVel = -2; - dinahs[dynIndex].count = ((short)who->data.h.delay * 6) / kTicksPerFrame; - dinahs[dynIndex].frame = 0; - dinahs[dynIndex].timer = dinahs[dynIndex].count; - dinahs[dynIndex].position = 0; - dinahs[dynIndex].room = room; - dinahs[dynIndex].byte0 = (Byte)index; - dinahs[dynIndex].byte1 = 0; - dinahs[dynIndex].moving = false; - dinahs[dynIndex].active = isOn; // initially idle + short baselineDelta = 0; + if (keepExisting) + baselineDelta = dinahs[dynIndex].dest.bottom - kBalloonStart; + + dinahs[dynIndex].dest = balloonSrc[0]; + ZeroRectCorner(&dinahs[dynIndex].dest); + QOffsetRect(&dinahs[dynIndex].dest, where->left, 0); + dinahs[dynIndex].dest.bottom = kBalloonStart + baselineDelta; + dinahs[dynIndex].dest.top = dinahs[dynIndex].dest.bottom - + RectTall(&balloonSrc[0]); + dinahs[dynIndex].whole = dinahs[dynIndex].dest; + + if (!keepExisting) + { + dinahs[dynIndex].hVel = 0; + dinahs[dynIndex].vVel = -2; + dinahs[dynIndex].count = ((short)who->data.h.delay * 6) / kTicksPerFrame; + dinahs[dynIndex].frame = 0; + dinahs[dynIndex].timer = dinahs[dynIndex].count; + dinahs[dynIndex].position = 0; + dinahs[dynIndex].room = room; + dinahs[dynIndex].byte0 = (Byte)index; + dinahs[dynIndex].byte1 = 0; + dinahs[dynIndex].moving = false; + dinahs[dynIndex].active = isOn; // initially idle + } } break; case kCopterLf: case kCopterRt: - dinahs[dynIndex].dest = copterSrc[0]; - ZeroRectCorner(&dinahs[dynIndex].dest); - QOffsetRect(&dinahs[dynIndex].dest, where->left, 0); - dinahs[dynIndex].dest.top = kCopterStart; - dinahs[dynIndex].dest.bottom = dinahs[dynIndex].dest.top + - RectTall(&copterSrc[0]); - dinahs[dynIndex].whole = dinahs[dynIndex].dest; - dinahs[dynIndex].position = dinahs[dynIndex].dest.left; - - if (!keepExisting) { - if (what == kCopterLf) - dinahs[dynIndex].hVel = -1; - else - dinahs[dynIndex].hVel = 1; - dinahs[dynIndex].vVel = 2; - dinahs[dynIndex].count = ((short)who->data.h.delay * 6) / kTicksPerFrame; - dinahs[dynIndex].frame = 0; - dinahs[dynIndex].timer = dinahs[dynIndex].count; - dinahs[dynIndex].room = room; - dinahs[dynIndex].byte0 = (Byte)index; - dinahs[dynIndex].byte1 = 0; - dinahs[dynIndex].moving = false; - dinahs[dynIndex].active = isOn; // initially idle + short baselineDeltaH = 0; + short baselineDeltaV = 0; + + if (keepExisting) + { + baselineDeltaH = dinahs[dynIndex].dest.left - dinahs[dynIndex].position; + baselineDeltaV = dinahs[dynIndex].dest.top - kCopterStart; + } + + dinahs[dynIndex].dest = copterSrc[0]; + ZeroRectCorner(&dinahs[dynIndex].dest); + QOffsetRect(&dinahs[dynIndex].dest, where->left, 0); + dinahs[dynIndex].dest.top = kCopterStart + baselineDeltaV; + dinahs[dynIndex].dest.bottom = dinahs[dynIndex].dest.top + + RectTall(&copterSrc[0]); + dinahs[dynIndex].whole = dinahs[dynIndex].dest; + + if (!keepExisting) + { + dinahs[dynIndex].position = dinahs[dynIndex].dest.left; + + if (what == kCopterLf) + dinahs[dynIndex].hVel = -1; + else + dinahs[dynIndex].hVel = 1; + dinahs[dynIndex].vVel = 2; + dinahs[dynIndex].count = ((short)who->data.h.delay * 6) / kTicksPerFrame; + dinahs[dynIndex].frame = 0; + dinahs[dynIndex].timer = dinahs[dynIndex].count; + dinahs[dynIndex].room = room; + dinahs[dynIndex].byte0 = (Byte)index; + dinahs[dynIndex].byte1 = 0; + dinahs[dynIndex].moving = false; + dinahs[dynIndex].active = isOn; // initially idle + } } break; @@ -568,93 +586,117 @@ short AddDynamicObject (short what, Rect *where, objectType *who, break; case kBall: - dinahs[dynIndex].dest = ballSrc[0]; - ZeroRectCorner(&dinahs[dynIndex].dest); - QOffsetRect(&dinahs[dynIndex].dest, - where->left, where->top); - dinahs[dynIndex].whole = dinahs[dynIndex].dest; - dinahs[dynIndex].position = dinahs[dynIndex].dest.bottom; - - if (!keepExisting) { - dinahs[dynIndex].hVel = 0; - position = who->data.h.length; // reverse engineer init. vel. - velocity = 0; - evenFrame = true; - lilFrame = true; - do + short baselineDelta = 0; + + if (keepExisting) + baselineDelta = dinahs[dynIndex].dest.bottom - dinahs[dynIndex].position; + + dinahs[dynIndex].dest = ballSrc[0]; + ZeroRectCorner(&dinahs[dynIndex].dest); + QOffsetRect(&dinahs[dynIndex].dest, + where->left, where->top + baselineDelta); + dinahs[dynIndex].whole = dinahs[dynIndex].dest; + + if (!keepExisting) { - if (lilFrame) - velocity++; - lilFrame = !lilFrame; - position -= velocity; - } while (position > 0); - dinahs[dynIndex].vVel = -velocity; - dinahs[dynIndex].moving = false; - dinahs[dynIndex].count = -velocity; // count = initial velocity - dinahs[dynIndex].frame = 0; - dinahs[dynIndex].timer = 0; - dinahs[dynIndex].room = room; - dinahs[dynIndex].byte0 = (Byte)index; - dinahs[dynIndex].byte1 = 0; - dinahs[dynIndex].active = isOn; + dinahs[dynIndex].position = dinahs[dynIndex].dest.bottom; + + dinahs[dynIndex].hVel = 0; + position = who->data.h.length; // reverse engineer init. vel. + velocity = 0; + evenFrame = true; + lilFrame = true; + do + { + if (lilFrame) + velocity++; + lilFrame = !lilFrame; + position -= velocity; + } while (position > 0); + dinahs[dynIndex].vVel = -velocity; + dinahs[dynIndex].moving = false; + dinahs[dynIndex].count = -velocity; // count = initial velocity + dinahs[dynIndex].frame = 0; + dinahs[dynIndex].timer = 0; + dinahs[dynIndex].room = room; + dinahs[dynIndex].byte0 = (Byte)index; + dinahs[dynIndex].byte1 = 0; + dinahs[dynIndex].active = isOn; + } } break; case kDrip: - dinahs[dynIndex].dest = dripSrc[0]; - CenterRectInRect(&dinahs[dynIndex].dest, where); - VOffsetRect(&dinahs[dynIndex].dest, - where->top - dinahs[dynIndex].dest.top); - dinahs[dynIndex].whole = dinahs[dynIndex].dest; - dinahs[dynIndex].hVel = dinahs[dynIndex].dest.top; // remember - dinahs[dynIndex].position = dinahs[dynIndex].dest.top + - who->data.h.length; - - if (!keepExisting) { - dinahs[dynIndex].vVel = 0; - dinahs[dynIndex].count = ((short)who->data.h.delay * 6) / kTicksPerFrame; - dinahs[dynIndex].frame = 3; - dinahs[dynIndex].timer = dinahs[dynIndex].count; - dinahs[dynIndex].room = room; - dinahs[dynIndex].byte0 = (Byte)index; - dinahs[dynIndex].byte1 = 0; - dinahs[dynIndex].moving = false; - dinahs[dynIndex].active = isOn; + short baselineDelta = 0; + + if (keepExisting) + baselineDelta = dinahs[dynIndex].dest.top - dinahs[dynIndex].hVel; + + dinahs[dynIndex].dest = dripSrc[0]; + CenterRectInRect(&dinahs[dynIndex].dest, where); + VOffsetRect(&dinahs[dynIndex].dest, + where->top - dinahs[dynIndex].dest.top + baselineDelta); + dinahs[dynIndex].whole = dinahs[dynIndex].dest; + + if (!keepExisting) + { + dinahs[dynIndex].hVel = dinahs[dynIndex].dest.top; // remember + dinahs[dynIndex].position = dinahs[dynIndex].dest.top + + who->data.h.length; + + dinahs[dynIndex].vVel = 0; + dinahs[dynIndex].count = ((short)who->data.h.delay * 6) / kTicksPerFrame; + dinahs[dynIndex].frame = 3; + dinahs[dynIndex].timer = dinahs[dynIndex].count; + dinahs[dynIndex].room = room; + dinahs[dynIndex].byte0 = (Byte)index; + dinahs[dynIndex].byte1 = 0; + dinahs[dynIndex].moving = false; + dinahs[dynIndex].active = isOn; + } } break; case kFish: - dinahs[dynIndex].dest = fishSrc[0]; - QOffsetRect(&dinahs[dynIndex].dest, - where->left + 10, where->top + 8); - dinahs[dynIndex].whole = dinahs[dynIndex].dest; - dinahs[dynIndex].position = dinahs[dynIndex].dest.bottom; - - if (!keepExisting) { - dinahs[dynIndex].hVel = ((short)who->data.h.delay * 6) / kTicksPerFrame; - position = who->data.g.height; // reverse engineer init. vel. - velocity = 0; - evenFrame = true; - lilFrame = true; - do + short baselineDelta = 0; + + if (keepExisting) + baselineDelta = dinahs[dynIndex].dest.bottom - dinahs[dynIndex].position; + + dinahs[dynIndex].dest = fishSrc[0]; + QOffsetRect(&dinahs[dynIndex].dest, + where->left + 10, where->top + 8 + baselineDelta); + dinahs[dynIndex].whole = dinahs[dynIndex].dest; + + if (!keepExisting) { - if (lilFrame) - velocity++; - lilFrame = !lilFrame; - position -= velocity; - } while (position > 0); - dinahs[dynIndex].vVel = -velocity; - dinahs[dynIndex].count = -velocity; // count = initial velocity - dinahs[dynIndex].frame = 0; - dinahs[dynIndex].timer = dinahs[dynIndex].hVel; - dinahs[dynIndex].room = room; - dinahs[dynIndex].byte0 = (Byte)index; - dinahs[dynIndex].byte1 = 0; - dinahs[dynIndex].moving = false; - dinahs[dynIndex].active = isOn; + dinahs[dynIndex].position = dinahs[dynIndex].dest.bottom; + + dinahs[dynIndex].hVel = ((short)who->data.h.delay * 6) / kTicksPerFrame; + position = who->data.g.height; // reverse engineer init. vel. + velocity = 0; + evenFrame = true; + lilFrame = true; + do + { + if (lilFrame) + velocity++; + lilFrame = !lilFrame; + position -= velocity; + } while (position > 0); + dinahs[dynIndex].vVel = -velocity; + dinahs[dynIndex].count = -velocity; // count = initial velocity + dinahs[dynIndex].frame = 0; + dinahs[dynIndex].timer = dinahs[dynIndex].hVel; + dinahs[dynIndex].room = room; + dinahs[dynIndex].byte0 = (Byte)index; + dinahs[dynIndex].byte1 = 0; + dinahs[dynIndex].moving = false; + dinahs[dynIndex].active = isOn; + } } break; diff --git a/GpApp/Environ.cpp b/GpApp/Environ.cpp index 2d19672..ebfdbfa 100644 --- a/GpApp/Environ.cpp +++ b/GpApp/Environ.cpp @@ -279,8 +279,20 @@ void FlushResolutionChange(void) { if (thisMac.isResolutionDirty) { - GetDeviceRect(&thisMac.screen); - thisMac.gray = thisMac.screen; + GetDeviceRect(&thisMac.fullScreen); + thisMac.constrainedScreen = thisMac.fullScreen; + if (thisMac.constrainedScreen.Width() > kMaxViewWidth) + { + thisMac.constrainedScreen.left = 0; + thisMac.constrainedScreen.right = kMaxViewWidth; + } + if (thisMac.constrainedScreen.Height() > kMaxViewHeight) + { + thisMac.constrainedScreen.top = 0; + thisMac.constrainedScreen.bottom = kMaxViewHeight; + } + + thisMac.gray = thisMac.fullScreen; thisMac.gray.top = 20; thisMac.isResolutionDirty = false; } @@ -332,6 +344,10 @@ public: HandleResolutionChange(prevWidth, prevHeight, newWidth, newHeight); } + void AdjustRequestedResolution(uint32_t &width, uint32_t &height) override + { + } + static GpAppResolutionChangeHandler ms_instance; }; @@ -455,7 +471,7 @@ void CheckMemorySize (void) RedAlert(kErrNoMemory); else bytesNeeded += musicBytes; - bytesNeeded += 4L * (long)thisMac.screen.bottom; // main screen + bytesNeeded += 4L * (long)thisMac.constrainedScreen.bottom; // main screen bytesNeeded += (((long)houseRect.right - (long)houseRect.left) * ((long)houseRect.bottom + 1 - (long)houseRect.top) * (long)thisMac.isDepth) / 8L; // work map diff --git a/GpApp/Environ.h b/GpApp/Environ.h index 104eac8..7a40b28 100644 --- a/GpApp/Environ.h +++ b/GpApp/Environ.h @@ -10,7 +10,7 @@ typedef struct { - Rect screen, gray; + Rect fullScreen, constrainedScreen, gray; long dirID; short wasDepth, isDepth; short numScreens; diff --git a/GpApp/Events.cpp b/GpApp/Events.cpp index d02b2d9..33342bc 100644 --- a/GpApp/Events.cpp +++ b/GpApp/Events.cpp @@ -81,7 +81,7 @@ void HandleMouseEvent (const GpMouseInputEvent &theEvent, uint32_t tick) break; case RegionIDs::kTitleBar: - PortabilityLayer::WindowManager::GetInstance()->DragWindow(whichWindow, evtPoint, thisMac.screen); + PortabilityLayer::WindowManager::GetInstance()->DragWindow(whichWindow, evtPoint, thisMac.fullScreen); if (whichWindow == mainWindow) GetWindowLeftTop(whichWindow, &isEditH, &isEditV); else if (whichWindow == mapWindow) diff --git a/GpApp/GameOver.cpp b/GpApp/GameOver.cpp index 3caf2b6..2771501 100644 --- a/GpApp/GameOver.cpp +++ b/GpApp/GameOver.cpp @@ -102,7 +102,7 @@ void SetUpFinalScreen (void) do { GetLineOfText(tempStr, count, subStr); - offset = ((thisMac.screen.right - thisMac.screen.left) - + offset = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) - surface->MeasureString(subStr)) / 2; surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold); @@ -146,6 +146,12 @@ void DoGameOverStarAnimation (void) long nextLoop; short which, i, count, pass; Boolean noInteruption; + + short starFallSpeed = kStarFalls; + const int kStarSpacing = 32; + const int kAngelSpeed = 2; + const int kStarsReserved = 5; + const int kMaxFramesAlive = (kStarSpacing * kStarsReserved + kAngelSpeed - 1) / kAngelSpeed; angelDest = angelSrcRect; QOffsetRect(&angelDest, -96, 0); @@ -154,16 +160,19 @@ void DoGameOverStarAnimation (void) count = 0; pass = 0; FlushEvents(everyEvent, 0); + + if (workSrcRect.bottom - angelDest.bottom > kMaxFramesAlive * starFallSpeed) + starFallSpeed = (workSrcRect.bottom - angelDest.bottom + kMaxFramesAlive - 1) / kMaxFramesAlive; while (noInteruption) { - if ((angelDest.left % 32) == 0) // add a star + if ((angelDest.left % kStarSpacing) == 0) // add a star { PlayPrioritySound(kMysticSound, kMysticPriority); - which = angelDest.left / 32; - which = which % 5; + which = angelDest.left / kStarSpacing; + which = which % kStarsReserved; if (which < 0) - which += 5; + which += kStarsReserved; ZeroRectCorner(&pages[which].dest); QOffsetRect(&pages[which].dest, angelDest.left, angelDest.bottom); if (count < (which + 1)) @@ -184,13 +193,13 @@ void DoGameOverStarAnimation (void) &pages[i].dest); pages[i].was = pages[i].dest; - pages[i].was.top -= kStarFalls; + pages[i].was.top -= starFallSpeed; AddRectToWorkRectsWhole(&pages[i].was); AddRectToBackRects(&pages[i].dest); if (pages[i].dest.top < workSrcRect.bottom) - QOffsetRect(&pages[i].dest, 0, kStarFalls); + QOffsetRect(&pages[i].dest, 0, starFallSpeed); } if (angelDest.left <= (workSrcRect.right + 2)) @@ -199,11 +208,11 @@ void DoGameOverStarAnimation (void) (BitMap *)*GetGWorldPixMap(angelMaskMap), (BitMap *)*GetGWorldPixMap(workSrcMap), &angelSrcRect, &angelSrcRect, &angelDest); - angelDest.left -= 2; + angelDest.left -= kAngelSpeed; AddRectToWorkRectsWhole(&angelDest); - angelDest.left += 2; + angelDest.left += kAngelSpeed; AddRectToBackRects(&angelDest); - QOffsetRect(&angelDest, 2, 0); + QOffsetRect(&angelDest, kAngelSpeed, 0); pass = 0; } @@ -285,14 +294,14 @@ void InitDiedGameOver (void) for (i = 0; i < 8; i++) // initialize dest page rects { QSetRect(&pages[i].dest, 0, 0, 32, 32); - CenterRectInRect(&pages[i].dest, &thisMac.screen); - QOffsetRect(&pages[i].dest, -thisMac.screen.left, -thisMac.screen.top); + CenterRectInRect(&pages[i].dest, &thisMac.constrainedScreen); + QOffsetRect(&pages[i].dest, -thisMac.constrainedScreen.left, -thisMac.constrainedScreen.top); if (i < 4) QOffsetRect(&pages[i].dest, -kPageSpacing * (4 - i), 0); else QOffsetRect(&pages[i].dest, kPageSpacing * (i - 3), 0); - QOffsetRect(&pages[i].dest, (thisMac.screen.right - thisMac.screen.left) / -2, - (thisMac.screen.right - thisMac.screen.left) / -2); + QOffsetRect(&pages[i].dest, (thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) / -2, + (thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) / -2); if (pages[i].dest.left % 2 == 1) QOffsetRect(&pages[i].dest, 1, 0); pages[i].was = pages[i].dest; @@ -308,7 +317,7 @@ void InitDiedGameOver (void) } pagesStuck = 0; - stopPages = ((thisMac.screen.bottom - thisMac.screen.top) / 2) - 16; + stopPages = ((thisMac.constrainedScreen.bottom - thisMac.constrainedScreen.top) / 2) - 16; } //-------------------------------------------------------------- HandlePages diff --git a/GpApp/GliderDefines.h b/GpApp/GliderDefines.h index bbe5861..da8c74a 100644 --- a/GpApp/GliderDefines.h +++ b/GpApp/GliderDefines.h @@ -265,7 +265,7 @@ #define kMaxDynamicObs 18 #define kMaxMasterObjects 216 // kMaxRoomObs * 9 #define kMaxViewWidth 1536 -#define kMaxViewHeight 1026 +#define kMaxViewHeight (kTileHigh*3+20) #define kSelectTool 0 diff --git a/GpApp/GpAppInterface.cpp b/GpApp/GpAppInterface.cpp index f977a8e..b00209f 100644 --- a/GpApp/GpAppInterface.cpp +++ b/GpApp/GpAppInterface.cpp @@ -25,6 +25,7 @@ public: void PL_HostFontHandler_SetInstance(PortabilityLayer::HostFontHandler *instance) override; void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) override; void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) override; + void PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) override; }; @@ -79,6 +80,16 @@ void GpAppInterfaceImpl::PL_InstallHostSuspendHook(PortabilityLayer::HostSuspend PortabilityLayer::InstallHostSuspendHook(hook, context); } +void GpAppInterfaceImpl::PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) +{ + uint32_t w32 = width; + uint32_t h32 = height; + PortabilityLayer::DisplayDeviceManager::GetInstance()->GetResolutionChangeHandler()->AdjustRequestedResolution(w32, h32); + width = w32; + height = h32; +} + + static GpAppInterfaceImpl gs_application; diff --git a/GpApp/HighScores.cpp b/GpApp/HighScores.cpp index 45bcb89..e0deeac 100644 --- a/GpApp/HighScores.cpp +++ b/GpApp/HighScores.cpp @@ -123,7 +123,7 @@ void DrawHighScores (DrawSurface *surface) PortabilityLayer::RGBAColor whiteColor = PortabilityLayer::RGBAColor::Create(255, 255, 255, 255); PortabilityLayer::RGBAColor blueColor = PortabilityLayer::RGBAColor::Create(0, 0, 255, 255); - scoreLeft = ((thisMac.screen.right - thisMac.screen.left) - kScoreWide) / 2; + scoreLeft = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) - kScoreWide) / 2; dropIt = 129 + splashOriginV; QSetRect(&tempRect, 0, 0, 332, 30); diff --git a/GpApp/InterfaceInit.cpp b/GpApp/InterfaceInit.cpp index 7c2e7f6..1077f62 100644 --- a/GpApp/InterfaceInit.cpp +++ b/GpApp/InterfaceInit.cpp @@ -101,15 +101,21 @@ void GetExtraCursors (void) //-------------------------------------------------------------- RecomputeScreenRects void RecomputeInterfaceRects (void) { - houseRect = thisMac.screen; + houseRect = thisMac.constrainedScreen; houseRect.bottom -= kScoreboardTall; if (houseRect.right > kMaxViewWidth) houseRect.right = kMaxViewWidth; if (houseRect.bottom > kMaxViewHeight) houseRect.bottom = kMaxViewHeight; - playOriginH = (RectWide(&thisMac.screen) - kRoomWide) / 2; - playOriginV = (RectTall(&thisMac.screen) - kTileHigh) / 2; + // NOTE: This is actually buggy, since the visible area is houseRect, not screen. + // We preserve the buggy behavior for authenticity unless the window is very tall. + short poHeight = RectTall(&thisMac.constrainedScreen); + if (poHeight > kMaxViewHeight - kScoreboardTall) + poHeight = kMaxViewHeight - kScoreboardTall; + + playOriginH = (RectWide(&thisMac.constrainedScreen) - kRoomWide) / 2; + playOriginV = (poHeight - kTileHigh) / 2; for (int i = 0; i < 9; i++) { diff --git a/GpApp/Main.cpp b/GpApp/Main.cpp index 6df200d..dbd6be7 100644 --- a/GpApp/Main.cpp +++ b/GpApp/Main.cpp @@ -204,7 +204,7 @@ void ReadInPrefs (void) doBitchDialogs = true; } - if ((numNeighbors > 1) && (thisMac.screen.right <= 512)) + if ((numNeighbors > 1) && (thisMac.constrainedScreen.right <= 512)) numNeighbors = 1; UnivGetSoundVolume(&wasVolume, thisMac.hasSM3); diff --git a/GpApp/MainWindow.cpp b/GpApp/MainWindow.cpp index e2af743..452f02b 100644 --- a/GpApp/MainWindow.cpp +++ b/GpApp/MainWindow.cpp @@ -229,16 +229,16 @@ void OpenMainWindow (void) if (menuWindow == nil) { menuWindow = GetNewCWindow(kMenuWindowID, nil, kPutInFront); - SizeWindow(menuWindow, RectWide(&thisMac.screen), 20, false); - MoveWindow(menuWindow, thisMac.screen.left, - thisMac.screen.top, true); + SizeWindow(menuWindow, RectWide(&thisMac.constrainedScreen), 20, false); + MoveWindow(menuWindow, thisMac.constrainedScreen.left, + thisMac.constrainedScreen.top, true); ShowWindow(menuWindow); } if (boardWindow == nil) { PortabilityLayer::WindowManager *windowManager = PortabilityLayer::WindowManager::GetInstance(); - Rect scorebarRect = thisMac.screen; + Rect scorebarRect = thisMac.constrainedScreen; scorebarRect.bottom = scorebarRect.top + kScoreboardTall; PortabilityLayer::WindowDef windowDef = PortabilityLayer::WindowDef::Create(scorebarRect, PortabilityLayer::WindowStyleFlags::kBorderless, true, 0, 0, PSTR("Scoreboard")); @@ -248,14 +248,14 @@ void OpenMainWindow (void) else PL_NotYetImplemented_TODO("Errors"); } - mainWindowRect = thisMac.screen; + mainWindowRect = thisMac.constrainedScreen; ZeroRectCorner(&mainWindowRect); mainWindowRect.bottom -= 20; // thisMac.menuHigh mainWindow = GetNewCWindow(kMainWindowID, nil, kPutInFront); SizeWindow(mainWindow, mainWindowRect.right - mainWindowRect.left, mainWindowRect.bottom - mainWindowRect.top, false); - MoveWindow(mainWindow, thisMac.screen.left, - thisMac.screen.top + 20, true); // thisMac.menuHigh + MoveWindow(mainWindow, thisMac.constrainedScreen.left, + thisMac.constrainedScreen.top + 20, true); // thisMac.menuHigh ShowWindow(mainWindow); SetPortWindowPort(mainWindow); @@ -267,10 +267,10 @@ void OpenMainWindow (void) mainWindowSurface->SetBackColor(StdColors::White()); mainWindowSurface->FillRect(mainWindowRect); - splashOriginH = ((thisMac.screen.right - thisMac.screen.left) - 640) / 2; + splashOriginH = ((thisMac.constrainedScreen.right - thisMac.constrainedScreen.left) - 640) / 2; if (splashOriginH < 0) splashOriginH = 0; - splashOriginV = ((thisMac.screen.bottom - thisMac.screen.top) - 480) / 2; + splashOriginV = ((thisMac.constrainedScreen.bottom - thisMac.constrainedScreen.top) - 480) / 2; if (splashOriginV < 0) splashOriginV = 0; diff --git a/GpApp/Play.cpp b/GpApp/Play.cpp index f483877..83a183f 100644 --- a/GpApp/Play.cpp +++ b/GpApp/Play.cpp @@ -138,7 +138,7 @@ void NewGame (short mode) DrawSurface *mainWindowSurface = mainWindow->GetDrawSurface(); - tempRect = thisMac.screen; + tempRect = thisMac.constrainedScreen; tempRect.top = tempRect.bottom - 20; // thisMac.menuHigh mainWindowSurface->FillRect(tempRect); @@ -366,12 +366,12 @@ void SetHouseToSavedRoom (void) //-------------------------------------------------------------- HandleGameResolutionChange +extern DrawSurface *backSrcMap; void HandleGameResolutionChange(void) { short prevPlayOriginH = playOriginH; short prevPlayOriginV = playOriginV; - Rect prevResolution = thisMac.screen; FlushResolutionChange(); RecomputeInterfaceRects(); @@ -385,6 +385,7 @@ void HandleGameResolutionChange(void) OffsetDynamics(playOriginH - prevPlayOriginH, playOriginV - prevPlayOriginV); ResetLocale(true); + InitScoreboardMap(); RefreshScoreboard(wasScoreboardTitleMode); DumpScreenOn(&justRoomsRect); } @@ -757,7 +758,7 @@ void RestoreEntireGameScreen (void) #endif DrawSurface *surface = mainWindow->GetDrawSurface(); - tempRect = thisMac.screen; + tempRect = thisMac.constrainedScreen; surface->SetForeColor(StdColors::Black()); surface->FillRect(tempRect); diff --git a/GpApp/Settings.cpp b/GpApp/Settings.cpp index 778c733..a18fd53 100644 --- a/GpApp/Settings.cpp +++ b/GpApp/Settings.cpp @@ -1031,7 +1031,7 @@ void DoDisplayPrefs (void) break; case kDisplay3Item: - if (thisMac.screen.right > 512) + if (thisMac.constrainedScreen.right > 512) { FrameDisplayIcon(prefDlg, StdColors::White()); numNeighbors = 3; @@ -1040,7 +1040,7 @@ void DoDisplayPrefs (void) break; case kDisplay9Item: - if (thisMac.screen.right > 512) + if (thisMac.constrainedScreen.right > 512) { FrameDisplayIcon(prefDlg, StdColors::White()); numNeighbors = 9; diff --git a/GpApp/StructuresInit.cpp b/GpApp/StructuresInit.cpp index 9faa655..0cadedd 100644 --- a/GpApp/StructuresInit.cpp +++ b/GpApp/StructuresInit.cpp @@ -60,20 +60,23 @@ extern short wasScoreboardMode; // Any graphics and structures relating to the scoreboard that appearsÉ // across the top of the game are initialized and loaded up here. -void InitScoreboardMap (void) +void InitScoreboardMap(void) { Rect bounds; THandle thePicture; DrawSurface *wasCPort; PLError_t theErr; short hOffset; - + + if (boardSrcMap) + DisposeGWorld(boardSrcMap); + wasScoreboardMode = kScoreboardHigh; boardSrcRect = houseRect; ZeroRectCorner(&boardSrcRect); boardSrcRect.bottom = kScoreboardTall; theErr = CreateOffScreenGWorld(&boardSrcMap, &boardSrcRect, kPreferredPixelFormat); - + if (boardSrcRect.right >= 640) hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2; else @@ -86,40 +89,50 @@ void InitScoreboardMap (void) QOffsetRect(&bounds, hOffset, 0); boardSrcMap->DrawPicture(thePicture, bounds); thePicture.Dispose(); - + QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels - theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredPixelFormat); - LoadGraphic(badgeSrcMap, kBadgePictID); - + if (!badgeSrcMap) + { + theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredPixelFormat); + LoadGraphic(badgeSrcMap, kBadgePictID); + } + boardDestRect = boardSrcRect; - + hOffset = (RectWide(&houseRect) - 640) / 2; if (hOffset < 0) hOffset = -128; - + QSetRect(&boardTSrcRect, 0, 0, 256, 12); // room title - theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect, kPreferredPixelFormat); + if (!boardTSrcMap) + { + theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect, kPreferredPixelFormat); + boardTSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold); + } boardTDestRect = boardTSrcRect; QOffsetRect(&boardTDestRect, 137 + hOffset, 5); - boardTSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold); - QSetRect(&boardGSrcRect, 0, 0, 20, 10); // # gliders - theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect, kPreferredPixelFormat); + if (!boardGSrcMap) + { + theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect, kPreferredPixelFormat); + boardGSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold); + } boardGDestRect = boardGSrcRect; QOffsetRect(&boardGDestRect, 526 + hOffset, 5); - boardGSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold); - + QSetRect(&boardPSrcRect, 0, 0, 64, 10); // points - theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect, kPreferredPixelFormat); + if (!boardPSrcMap) + { + theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect, kPreferredPixelFormat); + boardPSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold); + } boardPDestRect = boardPSrcRect; QOffsetRect(&boardPDestRect, 570 + hOffset, 5); // total = 6396 pixels boardPQDestRect = boardPDestRect; boardGQDestRect = boardGDestRect; - boardPSrcMap->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold); - QSetRect(&badgesBlankRects[0], 0, 0, 16, 16); // foil QOffsetRect(&badgesBlankRects[0], 0, 0); QSetRect(&badgesBlankRects[1], 0, 0, 16, 16); // rubber bands diff --git a/GpApp/WindowUtils.cpp b/GpApp/WindowUtils.cpp index 75be2cc..7340d8a 100644 --- a/GpApp/WindowUtils.cpp +++ b/GpApp/WindowUtils.cpp @@ -109,7 +109,7 @@ void OpenMessageWindow (const PLPasStr &title) SetRect(&mssgWindowRect, 0, 0, 256, kMessageWindowTall); Rect placementRect = mssgWindowRect; - CenterRectInRect(&placementRect, &thisMac.screen); + CenterRectInRect(&placementRect, &thisMac.fullScreen); const PortabilityLayer::WindowDef wdef = PortabilityLayer::WindowDef::Create(placementRect, windowStyle, false, 0, 0, title); diff --git a/GpCommon/GpDisplayDriverProperties.h b/GpCommon/GpDisplayDriverProperties.h index 53d49b8..6f3366f 100644 --- a/GpCommon/GpDisplayDriverProperties.h +++ b/GpCommon/GpDisplayDriverProperties.h @@ -11,6 +11,7 @@ struct GpDisplayDriverProperties { typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber); typedef void(*RenderFunc_t)(void *context); + typedef void(*AdjustRequestedResolutionFunc_t)(void *context, unsigned int &width, unsigned int &height); EGpDisplayDriverType m_type; @@ -32,5 +33,8 @@ struct GpDisplayDriverProperties RenderFunc_t m_renderFunc; void *m_renderFuncContext; + AdjustRequestedResolutionFunc_t m_adjustRequestedResolutionFunc; + void *m_adjustRequestedResolutionFuncContext; + IGpVOSEventQueue *m_eventQueue; }; diff --git a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp index 339ae55..00d3860 100644 --- a/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp +++ b/GpDisplayDriver_D3D11/GpDisplayDriverD3D11.cpp @@ -683,13 +683,15 @@ void GpDisplayDriverD3D11::Run() RECT clientRect; GetClientRect(m_hwnd, &clientRect); - LONG desiredWidth = clientRect.right - clientRect.left; - LONG desiredHeight = clientRect.bottom - clientRect.top; + unsigned int desiredWidth = clientRect.right - clientRect.left; + unsigned int desiredHeight = clientRect.bottom - clientRect.top; if (clientRect.right - clientRect.left != m_windowWidth || clientRect.bottom - clientRect.top != m_windowHeight) { uint32_t prevWidth = m_windowWidth; uint32_t prevHeight = m_windowHeight; + m_properties.m_adjustRequestedResolutionFunc(m_properties.m_adjustRequestedResolutionFuncContext, desiredWidth, desiredHeight); + bool resizedOK = ResizeD3DWindow(m_hwnd, m_windowWidth, m_windowHeight, desiredWidth, desiredHeight, windowStyle, menus); resizedOK = resizedOK && DetachSwapChain(); resizedOK = resizedOK && ResizeSwapChain(m_swapChain, m_windowWidth, m_windowHeight); diff --git a/PortabilityLayer/DisplayDeviceManager.h b/PortabilityLayer/DisplayDeviceManager.h index 7808eeb..d929a0d 100644 --- a/PortabilityLayer/DisplayDeviceManager.h +++ b/PortabilityLayer/DisplayDeviceManager.h @@ -15,6 +15,7 @@ namespace PortabilityLayer struct IResolutionChangeHandler { virtual void OnResolutionChanged(uint32_t prevWidth, uint32_t prevHeight, uint32_t newWidth, uint32_t newHeight) = 0; + virtual void AdjustRequestedResolution(uint32_t &width, uint32_t &height) = 0; }; virtual void Init() = 0; diff --git a/PortabilityLayer/GpAppInterface.h b/PortabilityLayer/GpAppInterface.h index f00c2ec..31a5132 100644 --- a/PortabilityLayer/GpAppInterface.h +++ b/PortabilityLayer/GpAppInterface.h @@ -38,14 +38,15 @@ public: virtual int ApplicationMain() = 0; virtual void PL_IncrementTickCounter(uint32_t count) = 0; virtual void PL_Render(IGpDisplayDriver *displayDriver) = 0; + virtual void PL_HostAudioDriver_SetInstance(IGpAudioDriver *instance) = 0; virtual void PL_HostFileSystem_SetInstance(PortabilityLayer::HostFileSystem *instance) = 0; virtual void PL_HostDisplayDriver_SetInstance(IGpDisplayDriver *instance) = 0; virtual void PL_HostSystemServices_SetInstance(PortabilityLayer::HostSystemServices *instance) = 0; virtual void PL_HostFontHandler_SetInstance(PortabilityLayer::HostFontHandler *instance) = 0; virtual void PL_HostVOSEventQueue_SetInstance(PortabilityLayer::HostVOSEventQueue *instance) = 0; - virtual void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) = 0; - virtual void PL_HostAudioDriver_SetInstance(IGpAudioDriver *instance) = 0; + virtual void PL_InstallHostSuspendHook(PortabilityLayer::HostSuspendHook_t hook, void *context) = 0; + virtual void PL_AdjustRequestedResolution(unsigned int &width, unsigned int &height) = 0; }; GP_APP_DLL_EXPORT_API GpAppInterface *GpAppInterface_Get();