Fix more dynamics, fix end screen stars with large vertical resolutions

This commit is contained in:
elasota
2020-04-04 02:20:03 -04:00
parent 1cdd372e35
commit 129396ef53
24 changed files with 305 additions and 185 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -27,6 +27,11 @@ namespace
{
static_cast<GpAppEnvironment*>(context)->Render();
}
void AdjustRequestedResolution(void *context, unsigned int &width, unsigned int &height)
{
static_cast<GpAppEnvironment*>(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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -482,10 +482,15 @@ short AddDynamicObject (short what, Rect *where, objectType *who,
break;
case kBalloon:
{
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;
dinahs[dynIndex].dest.bottom = kBalloonStart + baselineDelta;
dinahs[dynIndex].dest.top = dinahs[dynIndex].dest.bottom -
RectTall(&balloonSrc[0]);
dinahs[dynIndex].whole = dinahs[dynIndex].dest;
@@ -504,21 +509,33 @@ short AddDynamicObject (short what, Rect *where, objectType *who,
dinahs[dynIndex].moving = false;
dinahs[dynIndex].active = isOn; // initially idle
}
}
break;
case kCopterLf:
case kCopterRt:
{
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;
dinahs[dynIndex].dest.top = kCopterStart + baselineDeltaV;
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)
{
dinahs[dynIndex].position = dinahs[dynIndex].dest.left;
if (what == kCopterLf)
dinahs[dynIndex].hVel = -1;
else
@@ -533,6 +550,7 @@ short AddDynamicObject (short what, Rect *where, objectType *who,
dinahs[dynIndex].moving = false;
dinahs[dynIndex].active = isOn; // initially idle
}
}
break;
case kDartLf:
@@ -568,15 +586,22 @@ short AddDynamicObject (short what, Rect *where, objectType *who,
break;
case kBall:
{
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);
where->left, where->top + baselineDelta);
dinahs[dynIndex].whole = dinahs[dynIndex].dest;
dinahs[dynIndex].position = dinahs[dynIndex].dest.bottom;
if (!keepExisting)
{
dinahs[dynIndex].position = dinahs[dynIndex].dest.bottom;
dinahs[dynIndex].hVel = 0;
position = who->data.h.length; // reverse engineer init. vel.
velocity = 0;
@@ -599,20 +624,28 @@ short AddDynamicObject (short what, Rect *where, objectType *who,
dinahs[dynIndex].byte1 = 0;
dinahs[dynIndex].active = isOn;
}
}
break;
case kDrip:
{
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);
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;
if (!keepExisting)
{
dinahs[dynIndex].vVel = 0;
dinahs[dynIndex].count = ((short)who->data.h.delay * 6) / kTicksPerFrame;
dinahs[dynIndex].frame = 3;
@@ -623,17 +656,25 @@ short AddDynamicObject (short what, Rect *where, objectType *who,
dinahs[dynIndex].moving = false;
dinahs[dynIndex].active = isOn;
}
}
break;
case kFish:
{
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);
where->left + 10, where->top + 8 + baselineDelta);
dinahs[dynIndex].whole = dinahs[dynIndex].dest;
dinahs[dynIndex].position = dinahs[dynIndex].dest.bottom;
if (!keepExisting)
{
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;
@@ -656,6 +697,7 @@ short AddDynamicObject (short what, Rect *where, objectType *who,
dinahs[dynIndex].moving = false;
dinahs[dynIndex].active = isOn;
}
}
break;
default:

View File

@@ -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

View File

@@ -10,7 +10,7 @@
typedef struct
{
Rect screen, gray;
Rect fullScreen, constrainedScreen, gray;
long dirID;
short wasDepth, isDepth;
short numScreens;

View File

@@ -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)

View File

@@ -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);
@@ -147,6 +147,12 @@ void DoGameOverStarAnimation (void)
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);
noInteruption = true;
@@ -155,15 +161,18 @@ void DoGameOverStarAnimation (void)
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

View File

@@ -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

View File

@@ -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;

View File

@@ -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);

View File

@@ -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++)
{

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -60,7 +60,7 @@ extern short wasScoreboardMode;
// Any graphics and structures relating to the scoreboard that appears<72>
// across the top of the game are initialized and loaded up here.
void InitScoreboardMap (void)
void InitScoreboardMap(void)
{
Rect bounds;
THandle<BitmapImage> thePicture;
@@ -68,6 +68,9 @@ void InitScoreboardMap (void)
PLError_t theErr;
short hOffset;
if (boardSrcMap)
DisposeGWorld(boardSrcMap);
wasScoreboardMode = kScoreboardHigh;
boardSrcRect = houseRect;
ZeroRectCorner(&boardSrcRect);
@@ -88,8 +91,11 @@ void InitScoreboardMap (void)
thePicture.Dispose();
QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels
if (!badgeSrcMap)
{
theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredPixelFormat);
LoadGraphic(badgeSrcMap, kBadgePictID);
}
boardDestRect = boardSrcRect;
@@ -98,28 +104,35 @@ void InitScoreboardMap (void)
hOffset = -128;
QSetRect(&boardTSrcRect, 0, 0, 256, 12); // room title
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
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
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

View File

@@ -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);

View File

@@ -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;
};

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();