mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-13 19:49:36 +00:00
Refactoring. Add line drawing.
This commit is contained in:
@@ -42,13 +42,12 @@ extern Boolean quickerTransitions, demoGoing, isUseSecondScreen;
|
||||
void DrawBanner (Point *topLeft)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Rect wholePage, partPage, mapBounds;
|
||||
GWorldPtr tempMap;
|
||||
GWorldPtr tempMask;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&wholePage, 0, 0, 330, 220);
|
||||
mapBounds = thisMac.screen;
|
||||
@@ -58,7 +57,7 @@ void DrawBanner (Point *topLeft)
|
||||
topLeft->v = wholePage.top;
|
||||
partPage = wholePage;
|
||||
partPage.bottom = partPage.top + 190;
|
||||
SetGWorld(workSrcMap, nil);
|
||||
SetGraphicsPort(workSrcMap);
|
||||
LoadScaledGraphic(kBannerPageTopPICT, &partPage);
|
||||
|
||||
partPage = wholePage;
|
||||
@@ -66,20 +65,19 @@ void DrawBanner (Point *topLeft)
|
||||
mapBounds = partPage;
|
||||
ZeroRectCorner(&mapBounds);
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &mapBounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kBannerPageBottomPICT);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &mapBounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kBannerPageBottomMask);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
(BitMap *)*GetGWorldPixMap(tempMask),
|
||||
(BitMap *)*GetGWorldPixMap(workSrcMap),
|
||||
&mapBounds, &mapBounds, &partPage);
|
||||
SetPort((GrafPtr)workSrcMap);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
}
|
||||
@@ -116,11 +114,9 @@ void DrawBannerMessage (Point topLeft)
|
||||
Str255 bannerStr, subStr;
|
||||
short count;
|
||||
|
||||
CGrafPtr wasGWorld;
|
||||
GDHandle wasDevice;
|
||||
GetGWorld(&wasGWorld, &wasDevice);
|
||||
CGrafPtr wasGWorld = GetGraphicsPort();
|
||||
|
||||
SetGWorld(workSrcMap, nullptr);
|
||||
SetGraphicsPort(workSrcMap);
|
||||
|
||||
PasStringCopy((*thisHouse)->banner, bannerStr);
|
||||
|
||||
@@ -163,7 +159,7 @@ void DrawBannerMessage (Point topLeft)
|
||||
}
|
||||
ForeColor(blackColor);
|
||||
|
||||
SetGWorld(wasGWorld, wasDevice);
|
||||
SetGraphicsPort(wasGWorld);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- BringUpBanner
|
||||
|
||||
@@ -289,7 +289,6 @@ void CheckOurEnvirons (void)
|
||||
thisMac.hasQT = DoWeHaveQuickTime();
|
||||
thisMac.hasDrag = DoWeHaveDragManager();
|
||||
|
||||
FindOurDevice();
|
||||
thisMac.can1Bit = true;
|
||||
thisMac.can4Bit = true;
|
||||
thisMac.can8Bit = true;
|
||||
|
||||
@@ -253,23 +253,22 @@ void InitDiedGameOver (void)
|
||||
#define kPageBackUp 128
|
||||
short i;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&pageSrcRect, 0, 0, 25, 32 * 8);
|
||||
theErr = CreateOffScreenGWorld(&gameOverSrcMap, &pageSrcRect, kPreferredDepth);
|
||||
SetGWorld(gameOverSrcMap, nil);
|
||||
SetGraphicsPort(gameOverSrcMap);
|
||||
LoadGraphic(kLettersPictID);
|
||||
|
||||
QSetRect(&pageSrcRect, 0, 0, 32, 32 * kPageFrames);
|
||||
theErr = CreateOffScreenGWorld(&pageSrcMap, &pageSrcRect, kPreferredDepth);
|
||||
SetGWorld(pageSrcMap, nil);
|
||||
SetGraphicsPort(pageSrcMap);
|
||||
LoadGraphic(kPagesPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&pageMaskMap, &pageSrcRect, 1);
|
||||
SetGWorld(pageMaskMap, nil);
|
||||
SetGraphicsPort(pageMaskMap);
|
||||
LoadGraphic(kPagesMaskID);
|
||||
|
||||
for (i = 0; i < kPageFrames; i++) // initialize src page rects
|
||||
|
||||
@@ -103,19 +103,16 @@ void HandleGrease (void)
|
||||
}
|
||||
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
CGrafPtr wasCPort = GetGraphicsPort();
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
|
||||
SetGWorld(backSrcMap, nil);
|
||||
SetGraphicsPort(backSrcMap);
|
||||
PaintRect(&src);
|
||||
|
||||
SetGWorld(workSrcMap, nil);
|
||||
SetGraphicsPort(workSrcMap);
|
||||
PaintRect(&src);
|
||||
AddRectToWorkRects(&src);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
if (grease[i].isRight)
|
||||
@@ -270,7 +267,6 @@ void SpillGrease (short who, short index)
|
||||
void RedrawAllGrease (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Rect src;
|
||||
short i;
|
||||
|
||||
@@ -286,16 +282,16 @@ void RedrawAllGrease (void)
|
||||
{
|
||||
QOffsetRect(&src, playOriginH, playOriginV);
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
SetGWorld(backSrcMap, nil);
|
||||
SetGraphicsPort(backSrcMap);
|
||||
PaintRect(&src);
|
||||
|
||||
SetGWorld(workSrcMap, nil);
|
||||
SetGraphicsPort(workSrcMap);
|
||||
PaintRect(&src);
|
||||
AddRectToWorkRects(&src);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,6 @@ void DrawHighScores (void)
|
||||
{
|
||||
GWorldPtr tempMap, tempMask;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
houseType *thisHousePtr;
|
||||
Rect tempRect, tempRect2;
|
||||
@@ -107,15 +106,15 @@ void DrawHighScores (void)
|
||||
scoreLeft = ((thisMac.screen.right - thisMac.screen.left) - kScoreWide) / 2;
|
||||
dropIt = 129 + splashOriginV;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&tempRect, 0, 0, 332, 30);
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &tempRect, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kHighScoresPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &tempRect, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kHighScoresMaskID);
|
||||
|
||||
tempRect2 = tempRect;
|
||||
@@ -129,7 +128,7 @@ void DrawHighScores (void)
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
TextFont(applFont);
|
||||
TextFace(bold);
|
||||
|
||||
@@ -46,7 +46,6 @@ short splashOriginH, splashOriginV;
|
||||
short theMode;
|
||||
Boolean fadeGraysOut, isDoColorFade, splashDrawn;
|
||||
|
||||
extern GDHandle thisGDevice;
|
||||
extern short toolSelected;
|
||||
extern Boolean noRoomAtAll, isUseSecondScreen;
|
||||
extern Boolean quickerTransitions, houseIsReadOnly;
|
||||
|
||||
@@ -724,19 +724,18 @@ Boolean QueryNewRoom (void)
|
||||
void CreateNailOffscreen (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
if (nailSrcMap == nil)
|
||||
{
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&nailSrcRect, 0, 0, kMapRoomWidth, kMapRoomHeight * (kNumBackgrounds + 1));
|
||||
theErr = CreateOffScreenGWorld(&nailSrcMap, &nailSrcRect, kPreferredDepth);
|
||||
SetGWorld(nailSrcMap, nil);
|
||||
SetGraphicsPort(nailSrcMap);
|
||||
LoadGraphic(kThumbnailPictID);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ void DoMarquee (void)
|
||||
return;
|
||||
|
||||
SetPortWindowPort(mainWindow);
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
DrawMarquee();
|
||||
theMarquee.index++;
|
||||
@@ -64,7 +64,7 @@ void StartMarquee (Rect *theRect)
|
||||
theMarquee.active = true;
|
||||
theMarquee.paused = false;
|
||||
theMarquee.handled = false;
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
DrawMarquee();
|
||||
PenNormal();
|
||||
@@ -127,7 +127,7 @@ void StartMarqueeHandled (Rect *theRect, short direction, short dist)
|
||||
theMarquee.direction = direction;
|
||||
theMarquee.dist = dist;
|
||||
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
DrawMarquee();
|
||||
PenNormal();
|
||||
@@ -148,7 +148,7 @@ void StopMarquee (void)
|
||||
return;
|
||||
|
||||
SetPortWindowPort(mainWindow);
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
DrawMarquee();
|
||||
PenNormal();
|
||||
@@ -192,7 +192,7 @@ void DragOutMarqueeRect (Point start, Rect *theRect)
|
||||
SetPortWindowPort(mainWindow);
|
||||
InitCursor();
|
||||
QSetRect(theRect, start.h, start.v, start.h, start.v);
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
FrameRect(theRect);
|
||||
wasPt = start;
|
||||
@@ -222,7 +222,7 @@ void DragMarqueeRect (Point start, Rect *theRect, Boolean lockH, Boolean lockV)
|
||||
|
||||
SetCursor(&handCursor);
|
||||
StopMarquee();
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
theMarquee.bounds = *theRect;
|
||||
FrameRect(&theMarquee.bounds);
|
||||
@@ -266,7 +266,7 @@ void DragMarqueeHandle (Point start, short *dragged)
|
||||
else
|
||||
SetCursor(&horiCursor);
|
||||
StopMarquee();
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
FrameRect(&theMarquee.bounds);
|
||||
PaintRect(&theMarquee.handle);
|
||||
@@ -349,7 +349,7 @@ void DragMarqueeCorner (Point start, short *hDragged, short *vDragged, Boolean i
|
||||
|
||||
SetCursor(&diagCursor);
|
||||
StopMarquee();
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(&theMarquee.pats[theMarquee.index]);
|
||||
FrameRect(&theMarquee.bounds);
|
||||
PaintRect(&theMarquee.handle);
|
||||
|
||||
@@ -74,10 +74,9 @@ void DrawTiki (Rect *theRect, short down)
|
||||
#define kTikiPoleBase 300
|
||||
long darkGrayC, lightWoodC, darkWoodC;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -106,7 +105,7 @@ void DrawTiki (Rect *theRect, short down)
|
||||
theRect->left + 15, kTikiPoleBase + down - 1, darkGrayC);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(blowerSrcMap),
|
||||
(BitMap *)*GetGWorldPixMap(blowerMaskMap),
|
||||
@@ -120,16 +119,15 @@ void DrawInvisibleBlower (Rect *theRect)
|
||||
{
|
||||
Rect tempRect;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
QSetRect(&tempRect, 0, 0, 24, 24);
|
||||
QOffsetRect(&tempRect, theRect->left, theRect->top);
|
||||
|
||||
ColorFrameRect(&tempRect, 192);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawLiftArea
|
||||
@@ -137,12 +135,11 @@ void DrawInvisibleBlower (Rect *theRect)
|
||||
void DrawLiftArea (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameRect(theRect, 192);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawTable
|
||||
@@ -156,7 +153,6 @@ void DrawTable (Rect *tableTop, short down)
|
||||
long brownC, tanC, dkRedC, blackC;
|
||||
short hCenter, vShadow;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Pattern dummyPattern;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
@@ -174,8 +170,8 @@ void DrawTable (Rect *tableTop, short down)
|
||||
blackC = k8BlackColor;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
QSetRect(&tempRect, tableTop->left, 0, tableTop->right,
|
||||
RectWide(tableTop) / 10);
|
||||
@@ -183,7 +179,7 @@ void DrawTable (Rect *tableTop, short down)
|
||||
-HalfRectTall(&tempRect) + kTableShadowTop + down);
|
||||
QOffsetRect(&tempRect, kTableShadowOffset, -kTableShadowOffset);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patOr);
|
||||
PenMask(true);
|
||||
if (thisMac.isDepth == 4)
|
||||
ColorOval(&tempRect, 15);
|
||||
else
|
||||
@@ -250,7 +246,7 @@ void DrawTable (Rect *tableTop, short down)
|
||||
}
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
tempRect = tableSrc;
|
||||
QOffsetRect(&tempRect, -HalfRectWide(&tableSrc) + tableTop->left +
|
||||
@@ -273,7 +269,6 @@ void DrawShelf (Rect *shelfTop)
|
||||
long brownC, ltTanC, tanC, dkRedC, blackC;
|
||||
RgnHandle shadowRgn;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Pattern dummyPattern;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
@@ -293,8 +288,8 @@ void DrawShelf (Rect *shelfTop)
|
||||
blackC = k8BlackColor;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
shadowRgn = NewRgn();
|
||||
if (shadowRgn == nil)
|
||||
@@ -312,7 +307,7 @@ void DrawShelf (Rect *shelfTop)
|
||||
OpenRgn();
|
||||
CloseRgn(shadowRgn);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patOr);
|
||||
PenMask(true);
|
||||
if (thisMac.isDepth == 4)
|
||||
ColorRegion(shadowRgn, 15);
|
||||
else
|
||||
@@ -343,7 +338,7 @@ void DrawShelf (Rect *shelfTop)
|
||||
ColorLine(shelfTop->right - 1, shelfTop->top + 1,
|
||||
shelfTop->right - 1, shelfTop->bottom - 2, blackC);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
tempRect = shelfSrc;
|
||||
ZeroRectCorner(&tempRect);
|
||||
@@ -372,7 +367,6 @@ void DrawCabinet (Rect *cabinet)
|
||||
long brownC, dkGrayC, ltTanC, tanC, dkRedC, blackC;
|
||||
RgnHandle shadowRgn;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Pattern dummyPattern;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
@@ -394,8 +388,8 @@ void DrawCabinet (Rect *cabinet)
|
||||
blackC = k8BlackColor;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
MoveTo(cabinet->left, cabinet->bottom);
|
||||
shadowRgn = NewRgn();
|
||||
@@ -409,7 +403,7 @@ void DrawCabinet (Rect *cabinet)
|
||||
LineTo(cabinet->left, cabinet->bottom);
|
||||
CloseRgn(shadowRgn);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patOr);
|
||||
PenMask(true);
|
||||
if (thisMac.isDepth == 4)
|
||||
ColorRegion(shadowRgn, 15);
|
||||
else
|
||||
@@ -462,7 +456,7 @@ void DrawCabinet (Rect *cabinet)
|
||||
ColorLine(cabinet->left + kCabinetDeep + 10, cabinet->bottom - 10,
|
||||
cabinet->right - 11, cabinet->bottom - 10, tanC);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
tempRect = hingeSrc;
|
||||
ZeroRectCorner(&tempRect);
|
||||
@@ -515,7 +509,6 @@ void DrawCounter (Rect *counter)
|
||||
long brownC, dkGrayC, tanC, blackC, dkstRedC;
|
||||
short nRects, width, i;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Pattern dummyPattern;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
@@ -535,8 +528,8 @@ void DrawCounter (Rect *counter)
|
||||
dkstRedC = k8DkRed2Color;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
MoveTo(counter->right - 2, counter->bottom);
|
||||
shadowRgn = NewRgn();
|
||||
@@ -551,7 +544,7 @@ void DrawCounter (Rect *counter)
|
||||
LineTo(counter->right - 2, counter->bottom);
|
||||
CloseRgn(shadowRgn);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patOr);
|
||||
PenMask(true);
|
||||
if (thisMac.isDepth == 4)
|
||||
ColorRegion(shadowRgn, 15);
|
||||
else
|
||||
@@ -628,7 +621,7 @@ void DrawCounter (Rect *counter)
|
||||
ColorLine(counter->left + 1, counter->top + 8,
|
||||
counter->right - 2, counter->top + 8, dkstRedC);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
nRects = RectWide(counter) / 40;
|
||||
if (nRects == 0)
|
||||
@@ -660,7 +653,6 @@ void DrawDresser (Rect *dresser)
|
||||
RgnHandle shadowRgn;
|
||||
short nRects, height, i;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Pattern dummyPattern;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
@@ -680,8 +672,8 @@ void DrawDresser (Rect *dresser)
|
||||
dkstRedC = k8DkRed2Color;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
MoveTo(dresser->left + 10, dresser->bottom + 9);
|
||||
shadowRgn = NewRgn();
|
||||
@@ -696,7 +688,7 @@ void DrawDresser (Rect *dresser)
|
||||
LineTo(dresser->left + 10, dresser->bottom + 9);
|
||||
CloseRgn(shadowRgn);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patOr);
|
||||
PenMask(true);
|
||||
if (thisMac.isDepth == 4)
|
||||
ColorRegion(shadowRgn, 15);
|
||||
else
|
||||
@@ -756,7 +748,7 @@ void DrawDresser (Rect *dresser)
|
||||
QOffsetRect(&tempRect, 0, kDresserTopThick + height);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
dest = leftFootSrc;
|
||||
ZeroRectCorner(&dest);
|
||||
@@ -789,7 +781,6 @@ void DrawDeckTable (Rect *tableTop, short down)
|
||||
long bambooC, brownC, dkGrayC;
|
||||
short hCenter, vShadow;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Pattern dummyPattern;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
@@ -805,8 +796,8 @@ void DrawDeckTable (Rect *tableTop, short down)
|
||||
dkGrayC = k8DkstGrayColor;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
QSetRect(&tempRect, tableTop->left, 0, tableTop->right,
|
||||
RectWide(tableTop) / 10);
|
||||
@@ -814,7 +805,7 @@ void DrawDeckTable (Rect *tableTop, short down)
|
||||
-HalfRectTall(&tempRect) + kTableShadowTop + down);
|
||||
QOffsetRect(&tempRect, kTableShadowOffset, -kTableShadowOffset);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patOr);
|
||||
PenMask(true);
|
||||
ColorOval(&tempRect, dkGrayC);
|
||||
PenNormal();
|
||||
|
||||
@@ -878,7 +869,7 @@ void DrawDeckTable (Rect *tableTop, short down)
|
||||
}
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
tempRect = deckSrc;
|
||||
ZeroRectCorner(&tempRect);
|
||||
@@ -897,10 +888,9 @@ void DrawStool (Rect *theRect, short down)
|
||||
#define kStoolBase 304
|
||||
long grayC, dkGrayC;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -929,7 +919,7 @@ void DrawStool (Rect *theRect, short down)
|
||||
theRect->left + 26, kStoolBase + down - 1, dkGrayC);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(furnitureSrcMap),
|
||||
(BitMap *)*GetGWorldPixMap(furnitureMaskMap),
|
||||
@@ -942,12 +932,11 @@ void DrawStool (Rect *theRect, short down)
|
||||
void DrawInvisObstacle (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameRect(theRect, k8BrownColor);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawInvisBounce
|
||||
@@ -955,12 +944,11 @@ void DrawInvisObstacle (Rect *theRect)
|
||||
void DrawInvisBounce (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameRect(theRect, k8RedColor);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawRedClock
|
||||
@@ -1071,10 +1059,9 @@ void DrawCuckoo (Rect *theRect)
|
||||
void DrawClockHands (Point where, short bigHand, short littleHand)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
MoveTo(where.h, where.v);
|
||||
switch (bigHand)
|
||||
{
|
||||
@@ -1179,7 +1166,7 @@ void DrawClockHands (Point where, short bigHand, short littleHand)
|
||||
break;
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawClockHands
|
||||
@@ -1187,10 +1174,9 @@ void DrawClockHands (Point where, short bigHand, short littleHand)
|
||||
void DrawLargeClockHands (Point where, short bigHand, short littleHand)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ForeColor(whiteColor);
|
||||
|
||||
MoveTo(where.h, where.v);
|
||||
@@ -1298,7 +1284,7 @@ void DrawLargeClockHands (Point where, short bigHand, short littleHand)
|
||||
}
|
||||
|
||||
ForeColor(blackColor);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawSimplePrizes
|
||||
@@ -1317,7 +1303,6 @@ void DrawGreaseRt (Rect *theRect, short distance, Boolean state)
|
||||
{
|
||||
Rect spill, dest;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
dest = *theRect;
|
||||
if (state) // grease upright
|
||||
@@ -1335,12 +1320,12 @@ void DrawGreaseRt (Rect *theRect, short distance, Boolean state)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&greaseSrcRt[3], &greaseSrcRt[3], &dest);
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
QSetRect(&spill, 0, -2, distance - 5, 0);
|
||||
QOffsetRect(&spill, dest.right - 1, dest.bottom);
|
||||
PaintRect(&spill);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1350,7 +1335,6 @@ void DrawGreaseLf (Rect *theRect, short distance, Boolean state)
|
||||
{
|
||||
Rect spill, dest;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
dest = *theRect;
|
||||
if (state) // grease upright
|
||||
@@ -1368,12 +1352,12 @@ void DrawGreaseLf (Rect *theRect, short distance, Boolean state)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&greaseSrcLf[3], &greaseSrcLf[3], &dest);
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
QSetRect(&spill, -distance + 5, -2, 0, 0);
|
||||
QOffsetRect(&spill, dest.left + 1, dest.bottom);
|
||||
PaintRect(&spill);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1392,12 +1376,11 @@ void DrawFoil (Rect *theRect)
|
||||
void DrawInvisBonus (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameOval(theRect, 227);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawSlider
|
||||
@@ -1405,11 +1388,10 @@ void DrawInvisBonus (Rect *theRect)
|
||||
void DrawSlider (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
FrameRect(theRect);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,11 +117,10 @@ void DrawMailboxLeft (Rect *theRect, short down)
|
||||
GWorldPtr tempMask;
|
||||
long darkGrayC, lightWoodC, darkWoodC;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -168,15 +167,15 @@ void DrawMailboxLeft (Rect *theRect, short down)
|
||||
theRect->left + 62, down + kMailboxBase + 3, darkGrayC);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
bounds = srcRects[kMailboxLf];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kMailboxLeftPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &bounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kMailboxLeftMaskID);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
@@ -184,7 +183,7 @@ void DrawMailboxLeft (Rect *theRect, short down)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[kMailboxLf], &srcRects[kMailboxLf], theRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
@@ -200,11 +199,10 @@ void DrawMailboxRight (Rect *theRect, short down)
|
||||
GWorldPtr tempMask;
|
||||
long darkGrayC, lightWoodC, darkWoodC;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -251,15 +249,15 @@ void DrawMailboxRight (Rect *theRect, short down)
|
||||
theRect->left + 47, down + kMailboxBase + 3, darkGrayC);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
bounds = srcRects[kMailboxRt];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kMailboxRightPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &bounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kMailboxRightMaskID);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
@@ -267,7 +265,7 @@ void DrawMailboxRight (Rect *theRect, short down)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[kMailboxRt], &srcRects[kMailboxRt], theRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
@@ -289,12 +287,11 @@ void DrawSimpleTransport (short what, Rect *theRect)
|
||||
void DrawInvisTransport (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameRect(theRect, 32);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawLightSwitch
|
||||
@@ -376,12 +373,11 @@ void DrawKnifeSwitch (Rect *theRect, Boolean state)
|
||||
void DrawInvisibleSwitch (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameRect(theRect, kIntenseGreenColor);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawTrigger
|
||||
@@ -389,12 +385,11 @@ void DrawInvisibleSwitch (Rect *theRect)
|
||||
void DrawTrigger (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameRect(theRect, kIntenseBlueColor);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawSoundTrigger
|
||||
@@ -402,12 +397,11 @@ void DrawTrigger (Rect *theRect)
|
||||
void DrawSoundTrigger (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameRect(theRect, kIntenseYellowColor);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawSimpleLight
|
||||
@@ -427,7 +421,6 @@ void DrawFlourescent (Rect *theRect)
|
||||
Rect partRect;
|
||||
long grayC, gray2C, gray3C, gray4C, violetC;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -446,8 +439,8 @@ void DrawFlourescent (Rect *theRect)
|
||||
violetC = kPaleVioletColor;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
ColorLine(theRect->left + 16, theRect->top,
|
||||
theRect->right - 17, theRect->top, grayC);
|
||||
@@ -474,7 +467,7 @@ void DrawFlourescent (Rect *theRect)
|
||||
ColorLine(theRect->left + 16, theRect->top + 11,
|
||||
theRect->right - 17, theRect->top + 11, violetC);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
partRect = flourescentSrc1;
|
||||
ZeroRectCorner(&partRect);
|
||||
@@ -505,7 +498,6 @@ void DrawTrackLight (Rect *theRect)
|
||||
long grayC, gray2C, gray3C, gray4C;
|
||||
short which, howMany, i, spread;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -522,8 +514,8 @@ void DrawTrackLight (Rect *theRect)
|
||||
gray4C = k8DkGrayColor;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
ColorLine(theRect->left, theRect->top - 3,
|
||||
theRect->right - 1, theRect->top - 3, gray2C);
|
||||
@@ -538,7 +530,7 @@ void DrawTrackLight (Rect *theRect)
|
||||
ColorLine(theRect->left, theRect->top + 2,
|
||||
theRect->right - 1, theRect->top + 2, gray3C);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
partRect = trackLightSrc[0]; // left most track light
|
||||
ZeroRectCorner(&partRect);
|
||||
@@ -587,12 +579,11 @@ void DrawTrackLight (Rect *theRect)
|
||||
void DrawInvisLight (Rect *theRect)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
ColorFrameOval(theRect, 17);
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawSimpleAppliance
|
||||
@@ -644,20 +635,19 @@ void DrawTV (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
GWorldPtr tempMap;
|
||||
GWorldPtr tempMask;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
if (isLit)
|
||||
{
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
bounds = srcRects[kTV];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kTVPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &bounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kTVMaskID);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
@@ -665,7 +655,7 @@ void DrawTV (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[kTV], &srcRects[kTV], theRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
@@ -738,20 +728,19 @@ void DrawVCR (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
GWorldPtr tempMap;
|
||||
GWorldPtr tempMask;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
if (isLit)
|
||||
{
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
bounds = srcRects[kVCR];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kVCRPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &bounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kVCRMaskID);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
@@ -759,7 +748,7 @@ void DrawVCR (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[kVCR], &srcRects[kVCR], theRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
@@ -792,21 +781,20 @@ void DrawStereo (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
GWorldPtr tempMap;
|
||||
GWorldPtr tempMask;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
|
||||
if (isLit)
|
||||
{
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
bounds = srcRects[kStereo];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kStereoPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &bounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kStereoMaskID);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
@@ -814,7 +802,7 @@ void DrawStereo (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[kStereo], &srcRects[kStereo], theRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
@@ -847,21 +835,20 @@ void DrawMicrowave (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
GWorldPtr tempMap;
|
||||
GWorldPtr tempMask;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
|
||||
if (isLit)
|
||||
{
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
bounds = srcRects[kMicrowave];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(kMicrowavePictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &bounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(kMicrowaveMaskID);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
@@ -869,7 +856,7 @@ void DrawMicrowave (Rect *theRect, Boolean isOn, Boolean isLit)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[kMicrowave], &srcRects[kMicrowave], theRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
@@ -987,7 +974,6 @@ void DrawMirror (Rect *mirror)
|
||||
Rect tempRect;
|
||||
long grayC;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -998,8 +984,8 @@ void DrawMirror (Rect *mirror)
|
||||
grayC = k8DkGray2Color;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
tempRect = *mirror;
|
||||
ColorRect(&tempRect, k8WhiteColor);
|
||||
@@ -1011,7 +997,7 @@ void DrawMirror (Rect *mirror)
|
||||
InsetRect(&tempRect, 1, 1);
|
||||
ColorFrameRect(&tempRect, grayC);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawSimpleClutter
|
||||
@@ -1043,7 +1029,6 @@ void DrawWallWindow (Rect *window)
|
||||
long brownC, tanC, dkstRedC;
|
||||
short halfWay;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
if (thisMac.isDepth == 4)
|
||||
{
|
||||
@@ -1058,8 +1043,8 @@ void DrawWallWindow (Rect *window)
|
||||
dkstRedC = k8DkRed2Color;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
tempRect = *window;
|
||||
InsetRect(&tempRect, 3, 0);
|
||||
@@ -1125,7 +1110,7 @@ void DrawWallWindow (Rect *window)
|
||||
ColorLine(tempRect2.left - 5, tempRect2.top - 7,
|
||||
tempRect2.right + 5, tempRect2.top - 7, tanC);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawCalendar
|
||||
@@ -1137,10 +1122,9 @@ void DrawCalendar (Rect *theRect)
|
||||
PicHandle thePicture;
|
||||
Str255 monthStr;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
thePicture = GetPicture(kCalendarPictID);
|
||||
if (thePicture == nil)
|
||||
@@ -1161,7 +1145,7 @@ void DrawCalendar (Rect *theRect)
|
||||
MoveTo(theRect->left + ((64 - StringWidth(monthStr)) / 2), theRect->top + 55);
|
||||
ColorText(monthStr, kDarkFleshColor);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawBulletin
|
||||
@@ -1171,10 +1155,9 @@ void DrawBulletin (Rect *theRect)
|
||||
Rect bounds;
|
||||
PicHandle thePicture;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
thePicture = GetPicture(kBulletinPictID);
|
||||
if (thePicture == nil)
|
||||
@@ -1186,7 +1169,7 @@ void DrawBulletin (Rect *theRect)
|
||||
DrawPicture(thePicture, &bounds);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawPictObject
|
||||
@@ -1197,7 +1180,6 @@ void DrawPictObject (short what, Rect *theRect)
|
||||
PicHandle thePicture;
|
||||
short pictID;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
switch (what)
|
||||
{
|
||||
@@ -1230,8 +1212,8 @@ void DrawPictObject (short what, Rect *theRect)
|
||||
break;
|
||||
}
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
thePicture = GetPicture(pictID);
|
||||
if (thePicture == nil)
|
||||
@@ -1242,7 +1224,7 @@ void DrawPictObject (short what, Rect *theRect)
|
||||
DrawPicture(thePicture, &bounds);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- DrawPictWithMaskObject
|
||||
@@ -1254,10 +1236,9 @@ void DrawPictWithMaskObject (short what, Rect *theRect)
|
||||
GWorldPtr tempMask;
|
||||
short pictID, maskID;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
switch (what)
|
||||
{
|
||||
@@ -1274,11 +1255,11 @@ void DrawPictWithMaskObject (short what, Rect *theRect)
|
||||
|
||||
bounds = srcRects[what];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(pictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tempMask, &bounds, 1);
|
||||
SetGWorld(tempMask, nil);
|
||||
SetGraphicsPort(tempMask);
|
||||
LoadGraphic(maskID);
|
||||
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
@@ -1286,7 +1267,7 @@ void DrawPictWithMaskObject (short what, Rect *theRect)
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[what], &srcRects[what], theRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
DisposeGWorld(tempMask);
|
||||
@@ -1302,10 +1283,9 @@ void DrawPictSansWhiteObject (short what, Rect *theRect)
|
||||
CGrafPtr tempMap;
|
||||
short pictID;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
switch (what)
|
||||
{
|
||||
@@ -1392,14 +1372,14 @@ void DrawPictSansWhiteObject (short what, Rect *theRect)
|
||||
|
||||
bounds = srcRects[what];
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(pictID);
|
||||
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&srcRects[what], theRect, transparent, nil);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
// SetPort((GrafPtr)backSrcMap);
|
||||
@@ -1411,22 +1391,21 @@ void DrawCustPictSansWhite (short pictID, Rect *theRect)
|
||||
Rect bounds;
|
||||
GWorldPtr tempMap;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
bounds = *theRect;
|
||||
ZeroRectCorner(&bounds);
|
||||
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredDepth);
|
||||
SetGWorld(tempMap, nil);
|
||||
SetGraphicsPort(tempMap);
|
||||
LoadGraphic(pictID);
|
||||
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(tempMap),
|
||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||
&bounds, theRect, transparent, nil);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
DisposeGWorld(tempMap);
|
||||
// SetPort((GrafPtr)backSrcMap);
|
||||
|
||||
@@ -2303,11 +2303,10 @@ void DrawThisRoomsObjects (void)
|
||||
Rect tempRect;
|
||||
short i;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
Pattern dummyPattern;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
if ((noRoomAtAll) || (!houseUnlocked))
|
||||
return;
|
||||
@@ -2315,7 +2314,7 @@ void DrawThisRoomsObjects (void)
|
||||
{
|
||||
if (GetNumberOfLights(thisRoomNumber) <= 0)
|
||||
{
|
||||
PenMode(srcOr);
|
||||
PenMask(true);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PaintRect(&backSrcRect);
|
||||
PenNormal();
|
||||
@@ -2657,8 +2656,6 @@ void DrawThisRoomsObjects (void)
|
||||
}
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
|
||||
if (isFirstRoom)
|
||||
{
|
||||
CopyMask((BitMap *)*GetGWorldPixMap(glidSrcMap),
|
||||
@@ -2698,7 +2695,7 @@ void HiliteAllObjects (void)
|
||||
PauseMarquee();
|
||||
SetPort((GrafPtr)mainWindow);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
|
||||
for (i = 0; i < kMaxRoomObs; i++)
|
||||
FrameRect(&roomObjectRects[i]);
|
||||
|
||||
@@ -254,20 +254,17 @@ void NewGame (short mode)
|
||||
|
||||
if (!gameOver)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
CGrafPtr wasCPort = GetGraphicsPort();
|
||||
|
||||
InvalWindowRect(mainWindow, &mainWindowRect);
|
||||
|
||||
SetGWorld(workSrcMap, nil);
|
||||
SetGraphicsPort(workSrcMap);
|
||||
PaintRect(&workSrcRect);
|
||||
QSetRect(&tempRect, 0, 0, 640, 460);
|
||||
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
|
||||
LoadScaledGraphic(kSplash8BitPICT, &tempRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
WaitCommandQReleased();
|
||||
demoGoing = false;
|
||||
@@ -498,10 +495,7 @@ void PlayGame (void)
|
||||
countDown--;
|
||||
if (countDown <= 0)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
CGrafPtr wasCPort = GetGraphicsPort();
|
||||
|
||||
HideGlider(&theGlider);
|
||||
RefreshScoreboard(kNormalTitleMode);
|
||||
@@ -509,7 +503,7 @@ void PlayGame (void)
|
||||
#if BUILD_ARCADE_VERSION
|
||||
// Need to paint over the scoreboard black.
|
||||
|
||||
SetGWorld(boardSrcMap, nil);
|
||||
SetGraphicsPort(boardSrcMap);
|
||||
PaintRect(&boardSrcRect);
|
||||
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
|
||||
@@ -543,26 +537,23 @@ void PlayGame (void)
|
||||
else
|
||||
DoGameOver();
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILD_ARCADE_VERSION
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
CGrafPtr wasCPort = GetGraphicsPort();
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
|
||||
SetGWorld(boardSrcMap, nil);
|
||||
SetGraphicsPort(boardSrcMap);
|
||||
PaintRect(&boardSrcRect);
|
||||
|
||||
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
|
||||
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
|
||||
&boardSrcRect, &boardDestRect, srcCopy, 0L);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -45,7 +45,6 @@ void DrawLocale (void)
|
||||
short i, roomV;
|
||||
char wasState;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
ZeroFlamesAndTheLike();
|
||||
ZeroDinahs();
|
||||
@@ -67,8 +66,8 @@ void DrawLocale (void)
|
||||
}
|
||||
ListAllLocalObjects();
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
PaintRect(&backSrcRect);
|
||||
|
||||
if (numNeighbors > 3)
|
||||
@@ -115,14 +114,14 @@ void DrawLocale (void)
|
||||
DrawRoomBackground(localNumbers[kCentralRoom], kCentralRoom, roomV);
|
||||
DrawARoomsObjects(kCentralRoom, false);
|
||||
DrawLighting();
|
||||
|
||||
|
||||
if (numNeighbors > 3)
|
||||
DrawFloorSupport();
|
||||
RestoreWorkMap();
|
||||
shadowVisible = IsShadowVisible();
|
||||
takingTheStairs = false;
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LoadGraphicSpecial
|
||||
@@ -170,14 +169,13 @@ void DrawRoomBackground (short who, short where, short elevation)
|
||||
if ((numLights == 0) && (who != kRoomIsEmpty))
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
PaintRect(&localRoomsDest[where]);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,14 +184,13 @@ void DrawRoomBackground (short who, short where, short elevation)
|
||||
if (wardBitSet)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
|
||||
PaintRect(&localRoomsDest[where]);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -247,10 +244,9 @@ void DrawFloorSupport (void)
|
||||
Rect src, dest, whoCares;
|
||||
short i;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
wasCPort = GetGraphicsPort();
|
||||
SetGraphicsPort(backSrcMap);
|
||||
src = suppSrcRect;
|
||||
|
||||
if (isStructure[kNorthWestRoom])
|
||||
@@ -360,7 +356,7 @@ void DrawFloorSupport (void)
|
||||
}
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ReadyBackMap
|
||||
|
||||
@@ -130,7 +130,7 @@ void DragMiniTile (Point mouseIs, short *newTileOver)
|
||||
QOffsetRect(&dragRect,
|
||||
tileSrc.left + (tileOver * kMiniTileWide),
|
||||
tileSrc.top);
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
FrameRect(&dragRect);
|
||||
mouseWas = mouseIs;
|
||||
@@ -170,7 +170,7 @@ void DragMiniTile (Point mouseIs, short *newTileOver)
|
||||
}
|
||||
ForeColor(blackColor);
|
||||
PenNormal();
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
wasTileOver = *newTileOver;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void DragMiniTile (Point mouseIs, short *newTileOver)
|
||||
Line(kMiniTileWide, 0);
|
||||
ForeColor(blackColor);
|
||||
PenNormal();
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
wasTileOver = -1;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void DragMiniTile (Point mouseIs, short *newTileOver)
|
||||
Line(kMiniTileWide, 0);
|
||||
ForeColor(blackColor);
|
||||
PenNormal();
|
||||
PenMode(patXor);
|
||||
PenInvertMode(true);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
wasTileOver = -1;
|
||||
}
|
||||
@@ -386,10 +386,9 @@ void DoRoomInfo (void)
|
||||
Boolean leaving, wasFirstRoom, forceDraw;
|
||||
ModalFilterUPP roomFilterUPP;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
roomFilterUPP = NewModalFilterUPP(RoomFilter);
|
||||
|
||||
tileOver = -1;
|
||||
@@ -406,7 +405,7 @@ void DoRoomInfo (void)
|
||||
ParamText(floorStr, suiteStr, objectsStr, PSTR(""));
|
||||
|
||||
theErr = CreateOffScreenGWorld(&tileSrcMap, &tileSrcRect, kPreferredDepth);
|
||||
SetGWorld(tileSrcMap, nil);
|
||||
SetGraphicsPort(tileSrcMap);
|
||||
// CreateOffScreenPixMap(&tileSrcRect, &tileSrcMap);
|
||||
// SetPort((GrafPtr)tileSrcMap);
|
||||
if ((tempBack > kStars) && (!PictIDExists(tempBack)))
|
||||
@@ -420,7 +419,7 @@ void DoRoomInfo (void)
|
||||
else
|
||||
LoadScaledGraphic(tempBack, &tileSrcRect);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
|
||||
for (i = 0; i < kNumTiles; i++)
|
||||
tempTiles[i] = thisRoom->tiles[i];
|
||||
|
||||
@@ -61,18 +61,17 @@ void InitScoreboardMap (void)
|
||||
Rect bounds;
|
||||
PicHandle thePicture;
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
short hOffset;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
wasScoreboardMode = kScoreboardHigh;
|
||||
boardSrcRect = houseRect;
|
||||
ZeroRectCorner(&boardSrcRect);
|
||||
boardSrcRect.bottom = kScoreboardTall;
|
||||
theErr = CreateOffScreenGWorld(&boardSrcMap, &boardSrcRect, kPreferredDepth);
|
||||
SetGWorld(boardSrcMap, nil);
|
||||
SetGraphicsPort(boardSrcMap);
|
||||
|
||||
if (boardSrcRect.right >= 640)
|
||||
hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2;
|
||||
@@ -89,7 +88,7 @@ void InitScoreboardMap (void)
|
||||
|
||||
QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels
|
||||
theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredDepth);
|
||||
SetGWorld(badgeSrcMap, nil);
|
||||
SetGraphicsPort(badgeSrcMap);
|
||||
LoadGraphic(kBadgePictID);
|
||||
|
||||
boardDestRect = boardSrcRect;
|
||||
@@ -100,7 +99,7 @@ void InitScoreboardMap (void)
|
||||
|
||||
QSetRect(&boardTSrcRect, 0, 0, 256, 12); // room title
|
||||
theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect, kPreferredDepth);
|
||||
SetGWorld(boardTSrcMap, nil);
|
||||
SetGraphicsPort(boardTSrcMap);
|
||||
boardTDestRect = boardTSrcRect;
|
||||
QOffsetRect(&boardTDestRect, 137 + hOffset, 5);
|
||||
TextFont(applFont);
|
||||
@@ -109,7 +108,7 @@ void InitScoreboardMap (void)
|
||||
|
||||
QSetRect(&boardGSrcRect, 0, 0, 20, 10); // # gliders
|
||||
theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect, kPreferredDepth);
|
||||
SetGWorld(boardGSrcMap, nil);
|
||||
SetGraphicsPort(boardGSrcMap);
|
||||
boardGDestRect = boardGSrcRect;
|
||||
QOffsetRect(&boardGDestRect, 526 + hOffset, 5);
|
||||
TextFont(applFont);
|
||||
@@ -118,7 +117,7 @@ void InitScoreboardMap (void)
|
||||
|
||||
QSetRect(&boardPSrcRect, 0, 0, 64, 10); // points
|
||||
theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect, kPreferredDepth);
|
||||
SetGWorld(boardPSrcMap, nil);
|
||||
SetGraphicsPort(boardPSrcMap);
|
||||
boardPDestRect = boardPSrcRect;
|
||||
QOffsetRect(&boardPDestRect, 570 + hOffset, 5); // total = 6396 pixels
|
||||
boardPQDestRect = boardPDestRect;
|
||||
@@ -153,8 +152,8 @@ void InitScoreboardMap (void)
|
||||
QOffsetRect(&badgesDestRects[2], 467 + hOffset, 1);
|
||||
QSetRect(&badgesDestRects[3], 0, 0, 16, 17); // helium
|
||||
QOffsetRect(&badgesDestRects[3], 467 + hOffset, 1);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitGliderMap
|
||||
@@ -164,23 +163,22 @@ void InitScoreboardMap (void)
|
||||
void InitGliderMap (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
short i;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&glidSrcRect, 0, 0, kGliderWide, 668); // 32112 pixels
|
||||
theErr = CreateOffScreenGWorld(&glidSrcMap, &glidSrcRect, kPreferredDepth);
|
||||
SetGWorld(glidSrcMap, nil);
|
||||
SetGraphicsPort(glidSrcMap);
|
||||
LoadGraphic(kGliderPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&glid2SrcMap, &glidSrcRect, kPreferredDepth);
|
||||
SetGWorld(glid2SrcMap, nil);
|
||||
SetGraphicsPort(glid2SrcMap);
|
||||
LoadGraphic(kGlider2PictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&glidMaskMap, &glidSrcRect, 1);
|
||||
SetGWorld(glidMaskMap, nil);
|
||||
SetGraphicsPort(glidMaskMap);
|
||||
LoadGraphic(kGliderPictID + 1000);
|
||||
|
||||
for (i = 0; i <= 20; i++)
|
||||
@@ -201,11 +199,11 @@ void InitGliderMap (void)
|
||||
|
||||
QSetRect(&shadowSrcRect, 0, 0, kGliderWide, kShadowHigh * kNumShadowSrcRects);
|
||||
theErr = CreateOffScreenGWorld(&shadowSrcMap, &shadowSrcRect, kPreferredDepth);
|
||||
SetGWorld(shadowSrcMap, nil);
|
||||
SetGraphicsPort(shadowSrcMap);
|
||||
LoadGraphic(kShadowPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&shadowMaskMap, &shadowSrcRect, 1);
|
||||
SetGWorld(shadowMaskMap, nil);
|
||||
SetGraphicsPort(shadowMaskMap);
|
||||
LoadGraphic(kShadowPictID + 1000);
|
||||
|
||||
for (i = 0; i < kNumShadowSrcRects; i++)
|
||||
@@ -216,11 +214,11 @@ void InitGliderMap (void)
|
||||
|
||||
QSetRect(&bandsSrcRect, 0, 0, 16, 18); // 304 pixels
|
||||
theErr = CreateOffScreenGWorld(&bandsSrcMap, &bandsSrcRect, kPreferredDepth);
|
||||
SetGWorld(bandsSrcMap, nil);
|
||||
SetGraphicsPort(bandsSrcMap);
|
||||
LoadGraphic(kRubberBandsPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&bandsMaskMap, &bandsSrcRect, 1);
|
||||
SetGWorld(bandsMaskMap, nil);
|
||||
SetGraphicsPort(bandsMaskMap);
|
||||
LoadGraphic(kRubberBandsPictID + 1000);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
@@ -229,7 +227,7 @@ void InitGliderMap (void)
|
||||
QOffsetRect(&bandRects[i], 0, 6 * i);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitBlowers
|
||||
@@ -239,19 +237,18 @@ void InitGliderMap (void)
|
||||
void InitBlowers (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
short i;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&blowerSrcRect, 0, 0, 48, 402); // 19344 pixels
|
||||
theErr = CreateOffScreenGWorld(&blowerSrcMap, &blowerSrcRect, kPreferredDepth);
|
||||
SetGWorld(blowerSrcMap, nil);
|
||||
SetGraphicsPort(blowerSrcMap);
|
||||
LoadGraphic(kBlowerPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&blowerMaskMap, &blowerSrcRect, 1);
|
||||
SetGWorld(blowerMaskMap, nil);
|
||||
SetGraphicsPort(blowerMaskMap);
|
||||
LoadGraphic(kBlowerPictID + 1000);
|
||||
|
||||
for (i = 0; i < kNumCandleFlames; i++)
|
||||
@@ -278,7 +275,7 @@ void InitBlowers (void)
|
||||
QSetRect(&rightStartGliderSrc, 0, 0, 48, 16);
|
||||
QOffsetRect(&rightStartGliderSrc, 0, 374);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitFurniture
|
||||
@@ -288,18 +285,17 @@ void InitBlowers (void)
|
||||
void InitFurniture (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&furnitureSrcRect, 0, 0, 64, 278); // 17856 pixels
|
||||
theErr = CreateOffScreenGWorld(&furnitureSrcMap, &furnitureSrcRect, kPreferredDepth);
|
||||
SetGWorld(furnitureSrcMap, nil);
|
||||
SetGraphicsPort(furnitureSrcMap);
|
||||
LoadGraphic(kFurniturePictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&furnitureMaskMap, &furnitureSrcRect, 1);
|
||||
SetGWorld(furnitureMaskMap, nil);
|
||||
SetGraphicsPort(furnitureMaskMap);
|
||||
LoadGraphic(kFurniturePictID + 1000);
|
||||
|
||||
QSetRect(&tableSrc, 0, 0, 64, 22);
|
||||
@@ -326,7 +322,7 @@ void InitFurniture (void)
|
||||
QSetRect(&deckSrc, 0, 0, 64, 21);
|
||||
QOffsetRect(&deckSrc, 0, 162);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitPrizes
|
||||
@@ -336,19 +332,18 @@ void InitFurniture (void)
|
||||
void InitPrizes (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
short i;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&bonusSrcRect, 0, 0, 88, 378); // 33264 pixels
|
||||
theErr = CreateOffScreenGWorld(&bonusSrcMap, &bonusSrcRect, kPreferredDepth);
|
||||
SetGWorld(bonusSrcMap, nil);
|
||||
SetGraphicsPort(bonusSrcMap);
|
||||
LoadGraphic(kBonusPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&bonusMaskMap, &bonusSrcRect, 1);
|
||||
SetGWorld(bonusMaskMap, nil);
|
||||
SetGraphicsPort(bonusMaskMap);
|
||||
LoadGraphic(kBonusPictID + 1000);
|
||||
|
||||
for (i = 0; i < 11; i++)
|
||||
@@ -397,11 +392,11 @@ void InitPrizes (void)
|
||||
|
||||
QSetRect(&pointsSrcRect, 0, 0, 24, 120); // 2880 pixels
|
||||
theErr = CreateOffScreenGWorld(&pointsSrcMap, &pointsSrcRect, kPreferredDepth);
|
||||
SetGWorld(pointsSrcMap, nil);
|
||||
SetGraphicsPort(pointsSrcMap);
|
||||
LoadGraphic(kPointsPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&pointsMaskMap, &pointsSrcRect, 1);
|
||||
SetGWorld(pointsMaskMap, nil);
|
||||
SetGraphicsPort(pointsMaskMap);
|
||||
LoadGraphic(kPointsPictID + 1000);
|
||||
|
||||
for (i = 0; i < 15; i++)
|
||||
@@ -410,7 +405,7 @@ void InitPrizes (void)
|
||||
QOffsetRect(&pointsSrc[i], 0, i * 8);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitTransports
|
||||
@@ -420,21 +415,20 @@ void InitPrizes (void)
|
||||
void InitTransports (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld); // GlidePort: this line was missing?
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&transSrcRect, 0, 0, 56, 32); // 1848 pixels
|
||||
theErr = CreateOffScreenGWorld(&transSrcMap, &transSrcRect, kPreferredDepth);
|
||||
SetGWorld(transSrcMap, nil);
|
||||
SetGraphicsPort(transSrcMap);
|
||||
LoadGraphic(kTransportPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&transMaskMap, &transSrcRect, 1);
|
||||
SetGWorld(transMaskMap, nil);
|
||||
SetGraphicsPort(transMaskMap);
|
||||
LoadGraphic(kTransportPictID + 1000);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitSwitches
|
||||
@@ -444,14 +438,13 @@ void InitTransports (void)
|
||||
void InitSwitches (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&switchSrcRect, 0, 0, 32, 104); // 3360 pixels
|
||||
theErr = CreateOffScreenGWorld(&switchSrcMap, &switchSrcRect, kPreferredDepth);
|
||||
SetGWorld(switchSrcMap, nil);
|
||||
SetGraphicsPort(switchSrcMap);
|
||||
LoadGraphic(kSwitchPictID);
|
||||
|
||||
QSetRect(&lightSwitchSrc[0], 0, 0, 15, 24);
|
||||
@@ -479,7 +472,7 @@ void InitSwitches (void)
|
||||
QSetRect(&knifeSwitchSrc[1], 0, 0, 16, 24);
|
||||
QOffsetRect(&knifeSwitchSrc[1], 16, 80);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitLights
|
||||
@@ -489,19 +482,18 @@ void InitSwitches (void)
|
||||
void InitLights (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
short i;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&lightSrcRect, 0, 0, 72, 126); // 9144 pixels
|
||||
theErr = CreateOffScreenGWorld(&lightSrcMap, &lightSrcRect, kPreferredDepth);
|
||||
SetGWorld(lightSrcMap, nil);
|
||||
SetGraphicsPort(lightSrcMap);
|
||||
LoadGraphic(kLightPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&lightMaskMap, &lightSrcRect, 1);
|
||||
SetGWorld(lightMaskMap, nil);
|
||||
SetGraphicsPort(lightMaskMap);
|
||||
LoadGraphic(kLightPictID + 1000);
|
||||
|
||||
QSetRect(&flourescentSrc1, 0, 0, 16, 12);
|
||||
@@ -516,7 +508,7 @@ void InitLights (void)
|
||||
QOffsetRect(&trackLightSrc[i], 24 * i, 102);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitAppliances
|
||||
@@ -526,37 +518,36 @@ void InitLights (void)
|
||||
void InitAppliances (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
short i;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&applianceSrcRect, 0, 0, 80, 269); // 21600 pixels
|
||||
theErr = CreateOffScreenGWorld(&applianceSrcMap, &applianceSrcRect, kPreferredDepth);
|
||||
SetGWorld(applianceSrcMap, nil);
|
||||
SetGraphicsPort(applianceSrcMap);
|
||||
LoadGraphic(kAppliancePictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&applianceMaskMap, &applianceSrcRect, 1);
|
||||
SetGWorld(applianceMaskMap, nil);
|
||||
SetGraphicsPort(applianceMaskMap);
|
||||
LoadGraphic(kAppliancePictID + 1000);
|
||||
|
||||
QSetRect(&toastSrcRect, 0, 0, 32, 174); // 5600 pixels
|
||||
theErr = CreateOffScreenGWorld(&toastSrcMap, &toastSrcRect, kPreferredDepth);
|
||||
SetGWorld(toastSrcMap, nil);
|
||||
SetGraphicsPort(toastSrcMap);
|
||||
LoadGraphic(kToastPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&toastMaskMap, &toastSrcRect, 1);
|
||||
SetGWorld(toastMaskMap, nil);
|
||||
SetGraphicsPort(toastMaskMap);
|
||||
LoadGraphic(kToastPictID + 1000);
|
||||
|
||||
QSetRect(&shredSrcRect, 0, 0, 40, 35); // 1440 pixels
|
||||
theErr = CreateOffScreenGWorld(&shredSrcMap, &shredSrcRect, kPreferredDepth);
|
||||
SetGWorld(shredSrcMap, nil);
|
||||
SetGraphicsPort(shredSrcMap);
|
||||
LoadGraphic(kShreddedPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&shredMaskMap, &shredSrcRect, 1);
|
||||
SetGWorld(shredMaskMap, nil);
|
||||
SetGraphicsPort(shredMaskMap);
|
||||
LoadGraphic(kShreddedPictID + 1000);
|
||||
|
||||
QSetRect(&plusScreen1, 0, 0, 32, 22);
|
||||
@@ -601,7 +592,7 @@ void InitAppliances (void)
|
||||
QSetRect(µOff, 0, 0, 16, 35);
|
||||
QOffsetRect(µOff, 64, 187);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitEnemies
|
||||
@@ -611,73 +602,72 @@ void InitAppliances (void)
|
||||
void InitEnemies (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
short i;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&balloonSrcRect, 0, 0, 24, 30 * kNumBalloonFrames);
|
||||
theErr = CreateOffScreenGWorld(&balloonSrcMap, &balloonSrcRect, kPreferredDepth);
|
||||
SetGWorld(balloonSrcMap, nil);
|
||||
SetGraphicsPort(balloonSrcMap);
|
||||
LoadGraphic(kBalloonPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&balloonMaskMap, &balloonSrcRect, 1);
|
||||
SetGWorld(balloonMaskMap, nil);
|
||||
SetGraphicsPort(balloonMaskMap);
|
||||
LoadGraphic(kBalloonPictID + 1000);
|
||||
|
||||
QSetRect(&copterSrcRect, 0, 0, 32, 30 * kNumCopterFrames);
|
||||
theErr = CreateOffScreenGWorld(&copterSrcMap, &copterSrcRect, kPreferredDepth);
|
||||
SetGWorld(copterSrcMap, nil);
|
||||
SetGraphicsPort(copterSrcMap);
|
||||
LoadGraphic(kCopterPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&copterMaskMap, &copterSrcRect, 1);
|
||||
SetGWorld(copterMaskMap, nil);
|
||||
SetGraphicsPort(copterMaskMap);
|
||||
LoadGraphic(kCopterPictID + 1000);
|
||||
|
||||
QSetRect(&dartSrcRect, 0, 0, 64, 19 * kNumDartFrames);
|
||||
theErr = CreateOffScreenGWorld(&dartSrcMap, &dartSrcRect, kPreferredDepth);
|
||||
SetGWorld(dartSrcMap, nil);
|
||||
SetGraphicsPort(dartSrcMap);
|
||||
LoadGraphic(kDartPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&dartMaskMap, &dartSrcRect, 1);
|
||||
SetGWorld(dartMaskMap, nil);
|
||||
SetGraphicsPort(dartMaskMap);
|
||||
LoadGraphic(kDartPictID + 1000);
|
||||
|
||||
QSetRect(&ballSrcRect, 0, 0, 32, 32 * kNumBallFrames);
|
||||
theErr = CreateOffScreenGWorld(&ballSrcMap, &ballSrcRect, kPreferredDepth);
|
||||
SetGWorld(ballSrcMap, nil);
|
||||
SetGraphicsPort(ballSrcMap);
|
||||
LoadGraphic(kBallPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&ballMaskMap, &ballSrcRect, 1);
|
||||
SetGWorld(ballMaskMap, nil);
|
||||
SetGraphicsPort(ballMaskMap);
|
||||
LoadGraphic(kBallPictID + 1000);
|
||||
|
||||
QSetRect(&dripSrcRect, 0, 0, 16, 12 * kNumDripFrames);
|
||||
theErr = CreateOffScreenGWorld(&dripSrcMap, &dripSrcRect, kPreferredDepth);
|
||||
SetGWorld(dripSrcMap, nil);
|
||||
SetGraphicsPort(dripSrcMap);
|
||||
LoadGraphic(kDripPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&dripMaskMap, &dripSrcRect, 1);
|
||||
SetGWorld(dripMaskMap, nil);
|
||||
SetGraphicsPort(dripMaskMap);
|
||||
LoadGraphic(kDripPictID + 1000);
|
||||
|
||||
QSetRect(&enemySrcRect, 0, 0, 36, 33);
|
||||
theErr = CreateOffScreenGWorld(&enemySrcMap, &enemySrcRect, kPreferredDepth);
|
||||
SetGWorld(enemySrcMap, nil);
|
||||
SetGraphicsPort(enemySrcMap);
|
||||
LoadGraphic(kEnemyPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&enemyMaskMap, &enemySrcRect, 1);
|
||||
SetGWorld(enemyMaskMap, nil);
|
||||
SetGraphicsPort(enemyMaskMap);
|
||||
LoadGraphic(kEnemyPictID + 1000);
|
||||
|
||||
QSetRect(&fishSrcRect, 0, 0, 16, 16 * kNumFishFrames);
|
||||
theErr = CreateOffScreenGWorld(&fishSrcMap, &fishSrcRect, kPreferredDepth);
|
||||
SetGWorld(fishSrcMap, nil);
|
||||
SetGraphicsPort(fishSrcMap);
|
||||
LoadGraphic(kFishPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&fishMaskMap, &fishSrcRect, 1);
|
||||
SetGWorld(fishMaskMap, nil);
|
||||
SetGraphicsPort(fishMaskMap);
|
||||
LoadGraphic(kFishPictID + 1000);
|
||||
|
||||
for (i = 0; i < kNumBalloonFrames; i++)
|
||||
@@ -716,6 +706,6 @@ void InitEnemies (void)
|
||||
QOffsetRect(&fishSrc[i], 0, 16 * i);
|
||||
}
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ void InitAngel (void);
|
||||
|
||||
extern Rect suppSrcRect, justRoomsRect;
|
||||
extern Rect tileSrcRect, angelSrcRect;
|
||||
extern GDHandle thisGDevice;
|
||||
extern CGrafPtr tileSrcMap;
|
||||
extern FSSpecPtr theHousesSpecs;
|
||||
extern hotPtr hotSpots;
|
||||
@@ -54,18 +53,17 @@ extern short maxFiles;
|
||||
void InitClutter (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&clutterSrcRect, 0, 0, 128, 69);
|
||||
theErr = CreateOffScreenGWorld(&clutterSrcMap, &clutterSrcRect, kPreferredDepth);
|
||||
SetGWorld(clutterSrcMap, nil);
|
||||
SetGraphicsPort(clutterSrcMap);
|
||||
LoadGraphic(kClutterPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&clutterMaskMap, &clutterSrcRect, 1);
|
||||
SetGWorld(clutterMaskMap, nil);
|
||||
SetGraphicsPort(clutterMaskMap);
|
||||
LoadGraphic(kClutterPictID + 1000);
|
||||
|
||||
QSetRect(&flowerSrc[0], 0, 0, 10, 28);
|
||||
@@ -86,7 +84,7 @@ void InitClutter (void)
|
||||
QSetRect(&flowerSrc[5], 0, 0, 32, 51);
|
||||
QOffsetRect(&flowerSrc[5], 95, 0);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitSupport
|
||||
@@ -97,17 +95,16 @@ void InitClutter (void)
|
||||
void InitSupport (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&suppSrcRect, 0, 0, kRoomWide, kFloorSupportTall); // 44
|
||||
theErr = CreateOffScreenGWorld(&suppSrcMap, &suppSrcRect, kPreferredDepth);
|
||||
SetGWorld(suppSrcMap, nil);
|
||||
SetGraphicsPort(suppSrcMap);
|
||||
LoadGraphic(kSupportPictID);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- InitAngel
|
||||
@@ -118,21 +115,20 @@ void InitSupport (void)
|
||||
void InitAngel (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&angelSrcRect, 0, 0, 96, 44);
|
||||
theErr = CreateOffScreenGWorld(&angelSrcMap, &angelSrcRect, kPreferredDepth);
|
||||
SetGWorld(angelSrcMap, nil);
|
||||
SetGraphicsPort(angelSrcMap);
|
||||
LoadGraphic(kAngelPictID);
|
||||
|
||||
theErr = CreateOffScreenGWorld(&angelMaskMap, &angelSrcRect, 1);
|
||||
SetGWorld(angelMaskMap, nil);
|
||||
SetGraphicsPort(angelMaskMap);
|
||||
LoadGraphic(kAngelPictID + 1);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- CreateOffscreens
|
||||
@@ -144,10 +140,9 @@ void InitAngel (void)
|
||||
void CreateOffscreens (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
justRoomsRect = houseRect;
|
||||
ZeroRectCorner(&justRoomsRect);
|
||||
|
||||
@@ -74,19 +74,18 @@ Boolean isToolsOpen;
|
||||
void CreateToolsOffscreen (void)
|
||||
{
|
||||
CGrafPtr wasCPort;
|
||||
GDHandle wasWorld;
|
||||
OSErr theErr;
|
||||
|
||||
if (toolSrcMap == nil)
|
||||
{
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
wasCPort = GetGraphicsPort();
|
||||
|
||||
QSetRect(&toolSrcRect, 0, 0, 360, 216);
|
||||
theErr = CreateOffScreenGWorld(&toolSrcMap, &toolSrcRect, kPreferredDepth);
|
||||
SetGWorld(toolSrcMap, nil);
|
||||
SetGraphicsPort(toolSrcMap);
|
||||
LoadGraphic(kToolsPictID);
|
||||
|
||||
SetGWorld(wasCPort, wasWorld);
|
||||
SetGraphicsPort(wasCPort);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "Utilities.h"
|
||||
|
||||
|
||||
GDHandle thisGDevice;
|
||||
UInt32 theSeed;
|
||||
|
||||
|
||||
@@ -138,17 +137,6 @@ void RedAlert (short errorNumber)
|
||||
ExitToShell();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- FindOurDevice
|
||||
|
||||
// Finds the main device (monitor with the menu bar on it).
|
||||
|
||||
void FindOurDevice (void)
|
||||
{
|
||||
thisGDevice = GetMainDevice();
|
||||
if (thisGDevice == nil)
|
||||
RedAlert(kErrFailedGetDevice);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- CreateOffScreenBitMap
|
||||
// Creates an offscreen bit map (b&w - 1 bit depth).
|
||||
|
||||
@@ -245,10 +233,10 @@ OSErr CreateOffScreenGWorld (GWorldPtr *theGWorld, Rect *bounds, short depth)
|
||||
{
|
||||
OSErr theErr;
|
||||
|
||||
theErr = NewGWorld(theGWorld, depth, bounds, nil, nil, useTempMem);
|
||||
theErr = NewGWorld(theGWorld, depth, bounds, nil, useTempMem);
|
||||
|
||||
if (theErr)
|
||||
theErr = NewGWorld(theGWorld, depth, bounds, nil, nil, 0);
|
||||
theErr = NewGWorld(theGWorld, depth, bounds, nil, 0);
|
||||
|
||||
if (!theErr)
|
||||
LockPixels(GetGWorldPixMap(*theGWorld));
|
||||
|
||||
@@ -1270,7 +1270,8 @@ int main(int argc, const char **argv)
|
||||
|
||||
for (const char *filename : files)
|
||||
{
|
||||
std::string filePath = "D:\\Source Code\\GlidePort\\Packaged\\Houses\\";
|
||||
std::string fnameStr = filename;
|
||||
std::string filePath = (fnameStr == "ApplicationResources") ? "D:\\Source Code\\GlidePort\\Packaged\\" : "D:\\Source Code\\GlidePort\\Packaged\\Houses\\";
|
||||
filePath += filename;
|
||||
filePath += ".gpr";
|
||||
|
||||
@@ -1294,7 +1295,7 @@ int main(int argc, const char **argv)
|
||||
const MMHandleBlock *hBlock = resFile->GetResource('PICT', typeList->m_firstRef[i].m_resID, true);
|
||||
const void *pictData = hBlock->m_contents;
|
||||
|
||||
std::string dumpPath = "D:\\Source Code\\GlidePort\\PictDump\\";
|
||||
std::string dumpPath = "D:\\Source Code\\GlidePort\\DebugData\\PictDump\\";
|
||||
|
||||
dumpPath += filename;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "DisplayDeviceManager.h"
|
||||
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "QDStandardPalette.h"
|
||||
@@ -15,8 +16,8 @@ namespace PortabilityLayer
|
||||
void Init() override;
|
||||
void Shutdown() override;
|
||||
|
||||
GDevice **GetMainDevice() override;
|
||||
|
||||
GpPixelFormat_t GetPixelFormat() const override;
|
||||
void SyncPalette(IGpDisplayDriver *displayDriver) override;
|
||||
|
||||
void IncrementTickCount(uint32_t count) override;
|
||||
uint32_t GetTickCount() override;
|
||||
@@ -24,50 +25,62 @@ namespace PortabilityLayer
|
||||
static DisplayDeviceManagerImpl *GetInstance();
|
||||
|
||||
private:
|
||||
GDHandle m_mainDevice;
|
||||
uint32_t m_tickCount;
|
||||
GpPixelFormat_t m_pixelFormat;
|
||||
bool m_paletteIsDirty;
|
||||
|
||||
PortabilityLayer::RGBAColor *m_palette;
|
||||
uint8_t m_paletteStorage[256 * sizeof(PortabilityLayer::RGBAColor) + PL_SYSTEM_MEMORY_ALIGNMENT];
|
||||
|
||||
static DisplayDeviceManagerImpl ms_instance;
|
||||
};
|
||||
|
||||
DisplayDeviceManagerImpl::DisplayDeviceManagerImpl()
|
||||
: m_mainDevice(nullptr)
|
||||
, m_tickCount(1)
|
||||
: m_tickCount(1)
|
||||
, m_paletteIsDirty(true)
|
||||
, m_pixelFormat(GpPixelFormats::k8BitStandard)
|
||||
{
|
||||
uint8_t *paletteStorage = m_paletteStorage;
|
||||
while (reinterpret_cast<intptr_t>(paletteStorage) % PL_SYSTEM_MEMORY_ALIGNMENT != 0)
|
||||
paletteStorage++;
|
||||
|
||||
m_palette = reinterpret_cast<PortabilityLayer::RGBAColor*>(paletteStorage);
|
||||
|
||||
for (size_t i = 0; i < 256; i++)
|
||||
{
|
||||
PortabilityLayer::RGBAColor &color = m_palette[i];
|
||||
color.r = color.g = color.b = i;
|
||||
color.a = 255;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayDeviceManagerImpl::Init()
|
||||
{
|
||||
m_mainDevice = MemoryManager::GetInstance()->NewHandle<GDevice>();
|
||||
if (m_mainDevice)
|
||||
{
|
||||
GDevice *device = *m_mainDevice;
|
||||
HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, nullptr, &m_pixelFormat);
|
||||
|
||||
HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, nullptr, &device->pixelFormat);
|
||||
const PortabilityLayer::RGBAColor *spColors = StandardPalette::GetInstance()->GetColors();
|
||||
for (size_t i = 0; i < 256; i++)
|
||||
m_palette[i] = spColors[i];
|
||||
|
||||
uint8_t *paletteStorage = device->paletteStorage;
|
||||
while (reinterpret_cast<intptr_t>(paletteStorage) % PL_SYSTEM_MEMORY_ALIGNMENT != 0)
|
||||
paletteStorage++;
|
||||
|
||||
PortabilityLayer::RGBAColor *paletteData = reinterpret_cast<PortabilityLayer::RGBAColor*>(paletteStorage);
|
||||
device->paletteDataOffset = static_cast<uint8_t>(paletteStorage - device->paletteStorage);
|
||||
|
||||
const PortabilityLayer::RGBAColor *spColors = StandardPalette::GetInstance()->GetColors();
|
||||
for (size_t i = 0; i < 256; i++)
|
||||
paletteData[i] = spColors[i];
|
||||
|
||||
device->paletteIsDirty = true;
|
||||
}
|
||||
m_paletteIsDirty = true;
|
||||
}
|
||||
|
||||
void DisplayDeviceManagerImpl::Shutdown()
|
||||
{
|
||||
MemoryManager::GetInstance()->ReleaseHandle(reinterpret_cast<MMHandleBlock*>(m_mainDevice));
|
||||
}
|
||||
|
||||
GDevice **DisplayDeviceManagerImpl::GetMainDevice()
|
||||
GpPixelFormat_t DisplayDeviceManagerImpl::GetPixelFormat() const
|
||||
{
|
||||
return m_mainDevice;
|
||||
return m_pixelFormat;
|
||||
}
|
||||
|
||||
void DisplayDeviceManagerImpl::SyncPalette(IGpDisplayDriver *displayDriver)
|
||||
{
|
||||
if (m_paletteIsDirty)
|
||||
{
|
||||
displayDriver->UpdatePalette(m_palette);
|
||||
m_paletteIsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayDeviceManagerImpl::IncrementTickCount(uint32_t count)
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#ifndef __PL_DEVICE_MANAGER_H__
|
||||
#define __PL_DEVICE_MANAGER_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct GDevice;
|
||||
#include <stdint.h>
|
||||
#include "GpPixelFormat.h"
|
||||
|
||||
struct IGpDisplayDriver;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
@@ -12,9 +13,11 @@ namespace PortabilityLayer
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual GpPixelFormat_t GetPixelFormat() const = 0;
|
||||
virtual void SyncPalette(IGpDisplayDriver *displayDriver) = 0;
|
||||
|
||||
virtual GDevice **GetMainDevice() = 0;
|
||||
virtual void IncrementTickCount(uint32_t count) = 0;
|
||||
virtual uint32_t GetTickCount() = 0;
|
||||
|
||||
|
||||
@@ -553,7 +553,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
int depth = PortabilityLayer::QDManager::GetInstance()->DepthForPixelFormat(pixelFormat);
|
||||
|
||||
if (qdManager->NewGWorld(&m_menuBarGraf, depth, menuRect, nullptr, nullptr, 0) != 0)
|
||||
if (qdManager->NewGWorld(&m_menuBarGraf, depth, menuRect, nullptr, 0) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -569,11 +569,9 @@ namespace PortabilityLayer
|
||||
|
||||
RefreshMenuBarLayout();
|
||||
|
||||
CGraf *oldGraf;
|
||||
GDHandle oldDevice;
|
||||
GetGWorld(&oldGraf, &oldDevice);
|
||||
CGraf *oldGraf = GetGraphicsPort();
|
||||
|
||||
SetGWorld(m_menuBarGraf, nullptr);
|
||||
SetGraphicsPort(m_menuBarGraf);
|
||||
|
||||
PortabilityLayer::QDState *qdState = qdManager->GetState();
|
||||
|
||||
@@ -705,7 +703,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
SetGWorld(oldGraf, oldDevice);
|
||||
SetGraphicsPort(oldGraf);
|
||||
|
||||
m_menuBarGraf->m_port.SetDirty(QDPortDirtyFlag_Contents);
|
||||
}
|
||||
@@ -1019,15 +1017,13 @@ namespace PortabilityLayer
|
||||
GpPixelFormat_t pixelFormat;
|
||||
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, nullptr, &pixelFormat);
|
||||
|
||||
if (qdManager->NewGWorld(&m_menuGraf, qdManager->DepthForPixelFormat(pixelFormat), menuRect, nullptr, nullptr, 0) != 0)
|
||||
if (qdManager->NewGWorld(&m_menuGraf, qdManager->DepthForPixelFormat(pixelFormat), menuRect, nullptr, 0) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
CGrafPtr oldGraf = nullptr;
|
||||
GDHandle oldDevice = nullptr;
|
||||
GetGWorld(&oldGraf, &oldDevice);
|
||||
CGrafPtr oldGraf = GetGraphicsPort();
|
||||
|
||||
SetGWorld(m_menuGraf, nullptr);
|
||||
SetGraphicsPort(m_menuGraf);
|
||||
|
||||
QDState *qdState = qdManager->GetState();
|
||||
|
||||
@@ -1077,7 +1073,7 @@ namespace PortabilityLayer
|
||||
|
||||
m_menuGraf->m_port.SetDirty(QDPortDirtyFlag_Contents);
|
||||
|
||||
SetGWorld(oldGraf, oldDevice);
|
||||
SetGraphicsPort(oldGraf);
|
||||
}
|
||||
|
||||
MenuManager *MenuManager::GetInstance()
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace PortabilityLayer
|
||||
|
||||
void *imageData = m_pixMap->GetPixelData();
|
||||
|
||||
if (m_pixMap->GetPixelFormat() == GpPixelFormats::k8BitStandard)
|
||||
if (m_pixMap->GetPixelFormat() == GpPixelFormats::k8BitStandard || m_pixMap->GetPixelFormat() == GpPixelFormats::kBW1)
|
||||
{
|
||||
switch (m_blitType)
|
||||
{
|
||||
@@ -232,9 +232,9 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
OSErr NewGWorld(GWorldPtr *gworld, int depth, const Rect *bounds, CTabHandle colorTable, GDHandle device, int flags)
|
||||
OSErr NewGWorld(GWorldPtr *gworld, int depth, const Rect *bounds, CTabHandle colorTable, int flags)
|
||||
{
|
||||
return PortabilityLayer::QDManager::GetInstance()->NewGWorld(gworld, depth, *bounds, colorTable, device, flags);
|
||||
return PortabilityLayer::QDManager::GetInstance()->NewGWorld(gworld, depth, *bounds, colorTable, flags);
|
||||
}
|
||||
|
||||
void DisposeGWorld(GWorldPtr gworld)
|
||||
@@ -288,8 +288,7 @@ void DrawPicture(PicHandle pict, Rect *bounds)
|
||||
}
|
||||
|
||||
PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance();
|
||||
PortabilityLayer::QDPort *port;
|
||||
qdManager->GetPort(&port, nullptr);
|
||||
PortabilityLayer::QDPort *port = qdManager->GetPort();
|
||||
|
||||
if (!port)
|
||||
return;
|
||||
@@ -299,12 +298,15 @@ void DrawPicture(PicHandle pict, Rect *bounds)
|
||||
long handleSize = GetHandleSize(reinterpret_cast<Handle>(pict));
|
||||
PortabilityLayer::MemReaderStream stream(picPtr, handleSize);
|
||||
|
||||
// Adjust draw origin
|
||||
const PortabilityLayer::Vec2i drawOrigin = PortabilityLayer::Vec2i(bounds->left - picPtr->picFrame.left, bounds->top - picPtr->picFrame.top);
|
||||
|
||||
switch (pixMap->GetPixelFormat())
|
||||
{
|
||||
case GpPixelFormats::kBW1:
|
||||
case GpPixelFormats::k8BitStandard:
|
||||
{
|
||||
PortabilityLayer::PixMapBlitEmitter blitEmitter(PortabilityLayer::Vec2i(bounds->left, bounds->top), pixMap);
|
||||
PortabilityLayer::PixMapBlitEmitter blitEmitter(drawOrigin, pixMap);
|
||||
PortabilityLayer::QDPictDecoder decoder;
|
||||
|
||||
decoder.DecodePict(&stream, &blitEmitter);
|
||||
@@ -317,18 +319,17 @@ void DrawPicture(PicHandle pict, Rect *bounds)
|
||||
};
|
||||
}
|
||||
|
||||
void GetGWorld(CGrafPtr *gw, GDHandle *gdHandle)
|
||||
CGraf *GetGraphicsPort()
|
||||
{
|
||||
PortabilityLayer::QDPort *port;
|
||||
PortabilityLayer::QDManager::GetInstance()->GetPort(&port, gdHandle);
|
||||
PortabilityLayer::QDPort *port = PortabilityLayer::QDManager::GetInstance()->GetPort();
|
||||
|
||||
CGrafPtr grafPtr = reinterpret_cast<CGrafPtr>(port);
|
||||
CGraf *grafPtr = reinterpret_cast<CGraf *>(port);
|
||||
assert(&grafPtr->m_port == port);
|
||||
|
||||
*gw = grafPtr;
|
||||
return grafPtr;
|
||||
}
|
||||
|
||||
void SetGWorld(CGrafPtr gw, GDHandle gdHandle)
|
||||
void SetGraphicsPort(CGrafPtr gw)
|
||||
{
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(&gw->m_port, gdHandle);
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(&gw->m_port);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ enum QDFlags
|
||||
useTempMem = 1,
|
||||
};
|
||||
|
||||
OSErr NewGWorld(GWorldPtr *gworld, int depth, const Rect *bounds, CTabHandle colorTable, GDHandle device, int flags);
|
||||
OSErr NewGWorld(GWorldPtr *gworld, int depth, const Rect *bounds, CTabHandle colorTable, int flags);
|
||||
void DisposeGWorld(GWorldPtr gworld);
|
||||
|
||||
PixMapHandle GetGWorldPixMap(GWorldPtr gworld);
|
||||
@@ -37,8 +37,8 @@ void OffsetRect(Rect *rect, int right, int down);
|
||||
|
||||
void DrawPicture(PicHandle pict, Rect *bounds);
|
||||
|
||||
void GetGWorld(CGrafPtr *gw, GDHandle *gdHandle);
|
||||
void SetGWorld(CGrafPtr gw, GDHandle gdHandle);
|
||||
CGrafPtr GetGraphicsPort();
|
||||
void SetGraphicsPort(CGrafPtr gw);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
#include "DisplayDeviceManager.h"
|
||||
#include "FontFamily.h"
|
||||
#include "FontManager.h"
|
||||
#include "LinePlotter.h"
|
||||
#include "MMHandleBlock.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "HostFontHandler.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "RenderedFont.h"
|
||||
#include "RenderedGlyphMetrics.h"
|
||||
#include "Rect2i.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "ResTypeID.h"
|
||||
#include "RGBAColor.h"
|
||||
@@ -18,10 +20,21 @@
|
||||
#include "QDGraf.h"
|
||||
#include "QDPixMap.h"
|
||||
#include "QDUtils.h"
|
||||
#include "Vec2i.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
enum PaintColorResolution
|
||||
{
|
||||
PaintColorResolution_Fore,
|
||||
PaintColorResolution_Back,
|
||||
PaintColorResolution_Pen,
|
||||
};
|
||||
|
||||
static void PaintRectWithPCR(const Rect &rect, PaintColorResolution pcr);
|
||||
|
||||
void GetPort(GrafPtr *graf)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
@@ -29,11 +42,7 @@ void GetPort(GrafPtr *graf)
|
||||
|
||||
void SetPort(GrafPtr graf)
|
||||
{
|
||||
PortabilityLayer::QDManager *qd = PortabilityLayer::QDManager::GetInstance();
|
||||
|
||||
GDHandle device;
|
||||
qd->GetPort(nullptr, &device);
|
||||
qd->SetPort(graf, device);
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(graf);
|
||||
}
|
||||
|
||||
void BeginUpdate(WindowPtr graf)
|
||||
@@ -83,18 +92,10 @@ void SetRect(Rect *rect, short left, short top, short right, short bottom)
|
||||
rect->right = right;
|
||||
}
|
||||
|
||||
GDHandle GetMainDevice()
|
||||
{
|
||||
return PortabilityLayer::DisplayDeviceManager::GetInstance()->GetMainDevice();
|
||||
}
|
||||
|
||||
void SetPortWindowPort(WindowPtr window)
|
||||
{
|
||||
PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
|
||||
GDevice **device = wm->GetWindowDevice(window);
|
||||
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(&window->m_graf.m_port, device);
|
||||
PortabilityLayer::QDManager::GetInstance()->SetPort(&window->m_graf.m_port);
|
||||
}
|
||||
|
||||
void SetPortDialogPort(Dialog *dialog)
|
||||
@@ -131,9 +132,136 @@ void MoveTo(int x, int y)
|
||||
penPos.v = y;
|
||||
}
|
||||
|
||||
static void PlotLine(PortabilityLayer::QDState *qdState, PortabilityLayer::QDPort *qdPort, const PortabilityLayer::Vec2i &pointA, const PortabilityLayer::Vec2i &pointB)
|
||||
{
|
||||
const Rect lineRect = Rect::Create(
|
||||
std::min(pointA.m_y, pointB.m_y),
|
||||
std::min(pointA.m_x, pointB.m_x),
|
||||
std::max(pointA.m_y, pointB.m_y) + 1,
|
||||
std::max(pointA.m_x, pointB.m_x) + 1);
|
||||
|
||||
// If the points are a straight line, paint as a rect
|
||||
if (pointA.m_y == pointB.m_y || pointA.m_x == pointB.m_x)
|
||||
{
|
||||
PaintRectWithPCR(lineRect, PaintColorResolution_Fore);
|
||||
return;
|
||||
}
|
||||
|
||||
GpPixelFormat_t pixelFormat = qdPort->GetPixelFormat();
|
||||
|
||||
Rect constrainedRect = qdPort->GetRect();
|
||||
|
||||
if (qdState->m_clipRegion)
|
||||
{
|
||||
const Region ®ion = **qdState->m_clipRegion;
|
||||
|
||||
if (region.size > sizeof(Region))
|
||||
PL_NotYetImplemented();
|
||||
|
||||
constrainedRect = constrainedRect.Intersect(region.rect);
|
||||
}
|
||||
|
||||
constrainedRect = constrainedRect.Intersect(lineRect);
|
||||
|
||||
if (!constrainedRect.IsValid())
|
||||
return;
|
||||
|
||||
PortabilityLayer::Vec2i upperPoint = pointA;
|
||||
PortabilityLayer::Vec2i lowerPoint = pointB;
|
||||
|
||||
if (pointA.m_y > pointB.m_y)
|
||||
std::swap(upperPoint, lowerPoint);
|
||||
|
||||
PortabilityLayer::PixMapImpl *pixMap = static_cast<PortabilityLayer::PixMapImpl*>(*qdPort->GetPixMap());
|
||||
const size_t pitch = pixMap->GetPitch();
|
||||
uint8_t *pixData = static_cast<uint8_t*>(pixMap->GetPixelData());
|
||||
|
||||
PortabilityLayer::LinePlotter plotter;
|
||||
plotter.Reset(upperPoint, lowerPoint);
|
||||
|
||||
PortabilityLayer::Vec2i currentPoint = pointA;
|
||||
while (currentPoint.m_x < constrainedRect.left || currentPoint.m_y < constrainedRect.top || currentPoint.m_x >= constrainedRect.right)
|
||||
{
|
||||
PortabilityLayer::PlotDirection plotDir = plotter.PlotNext();
|
||||
if (plotDir == PortabilityLayer::PlotDirection_Exhausted)
|
||||
return;
|
||||
|
||||
currentPoint = plotter.GetPoint();
|
||||
}
|
||||
|
||||
assert(currentPoint.m_y < constrainedRect.bottom);
|
||||
|
||||
size_t plotIndex = static_cast<size_t>(currentPoint.m_y) * pitch + static_cast<size_t>(currentPoint.m_x);
|
||||
const size_t plotLimit = pixMap->GetPitch() * (pixMap->m_rect.bottom - pixMap->m_rect.top);
|
||||
|
||||
switch (pixelFormat)
|
||||
{
|
||||
case GpPixelFormats::k8BitStandard:
|
||||
{
|
||||
const size_t pixelSize = 1;
|
||||
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
|
||||
|
||||
while (currentPoint.m_x >= constrainedRect.left && currentPoint.m_x < constrainedRect.right && currentPoint.m_y < constrainedRect.bottom)
|
||||
{
|
||||
assert(plotIndex < plotLimit);
|
||||
pixData[plotIndex] = color;
|
||||
|
||||
PortabilityLayer::PlotDirection plotDir = plotter.PlotNext();
|
||||
if (plotDir == PortabilityLayer::PlotDirection_Exhausted)
|
||||
return;
|
||||
|
||||
switch (plotDir)
|
||||
{
|
||||
default:
|
||||
case PortabilityLayer::PlotDirection_Exhausted:
|
||||
return;
|
||||
|
||||
case PortabilityLayer::PlotDirection_NegX_NegY:
|
||||
case PortabilityLayer::PlotDirection_0X_NegY:
|
||||
case PortabilityLayer::PlotDirection_PosX_NegY:
|
||||
// These should never happen, the point order is swapped so that Y is always 0 or positive
|
||||
assert(false);
|
||||
return;
|
||||
|
||||
case PortabilityLayer::PlotDirection_NegX_PosY:
|
||||
currentPoint.m_x--;
|
||||
currentPoint.m_y++;
|
||||
plotIndex = plotIndex + pitch - pixelSize;
|
||||
break;
|
||||
case PortabilityLayer::PlotDirection_0X_PosY:
|
||||
currentPoint.m_y++;
|
||||
plotIndex = plotIndex + pitch;
|
||||
break;
|
||||
case PortabilityLayer::PlotDirection_PosX_PosY:
|
||||
currentPoint.m_x++;
|
||||
currentPoint.m_y++;
|
||||
plotIndex = plotIndex + pitch + pixelSize;
|
||||
break;
|
||||
|
||||
case PortabilityLayer::PlotDirection_NegX_0Y:
|
||||
currentPoint.m_x--;
|
||||
plotIndex = plotIndex - pixelSize;
|
||||
break;
|
||||
case PortabilityLayer::PlotDirection_PosX_0Y:
|
||||
currentPoint.m_x++;
|
||||
plotIndex = plotIndex + pixelSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PL_NotYetImplemented();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void LineTo(int x, int y)
|
||||
{
|
||||
PL_NotYetImplemented_TODO("Polys");
|
||||
PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance();
|
||||
PortabilityLayer::QDState *qdState = qdManager->GetState();
|
||||
|
||||
PlotLine(qdState, qdManager->GetPort(), PortabilityLayer::Vec2i(qdState->m_penPos.h, qdState->m_penPos.v), PortabilityLayer::Vec2i(x, y));
|
||||
}
|
||||
|
||||
void SetOrigin(int x, int y)
|
||||
@@ -216,9 +344,7 @@ void GetForeColor(RGBColor *color)
|
||||
|
||||
void Index2Color(int index, RGBColor *color)
|
||||
{
|
||||
PortabilityLayer::QDPort *port;
|
||||
|
||||
PortabilityLayer::QDManager::GetInstance()->GetPort(&port, nullptr);
|
||||
PortabilityLayer::QDPort *port = PortabilityLayer::QDManager::GetInstance()->GetPort();
|
||||
|
||||
GpPixelFormat_t pf = port->GetPixelFormat();
|
||||
if (pf == GpPixelFormats::k8BitCustom)
|
||||
@@ -315,8 +441,7 @@ void DrawString(const PLPasStr &str)
|
||||
{
|
||||
PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance();
|
||||
|
||||
PortabilityLayer::QDPort *port = nullptr;
|
||||
qdManager->GetPort(&port, nullptr);
|
||||
PortabilityLayer::QDPort *port = qdManager->GetPort();
|
||||
|
||||
PortabilityLayer::QDState *qdState = qdManager->GetState();
|
||||
|
||||
@@ -368,17 +493,16 @@ void DrawString(const PLPasStr &str)
|
||||
DrawGlyph(qdState, pixMap, rect, penPos, rfont, chars[i]);
|
||||
}
|
||||
|
||||
void PaintRect(const Rect *rect)
|
||||
void PaintRectWithPCR(const Rect &rect, PaintColorResolution pcr)
|
||||
{
|
||||
if (!rect->IsValid())
|
||||
if (!rect.IsValid())
|
||||
return;
|
||||
|
||||
PortabilityLayer::QDPort *qdPort;
|
||||
PortabilityLayer::QDManager::GetInstance()->GetPort(&qdPort, nullptr);
|
||||
PortabilityLayer::QDPort *qdPort = PortabilityLayer::QDManager::GetInstance()->GetPort();
|
||||
|
||||
GpPixelFormat_t pixelFormat = qdPort->GetPixelFormat();
|
||||
|
||||
Rect constrainedRect = *rect;
|
||||
Rect constrainedRect = rect;
|
||||
|
||||
PortabilityLayer::QDState *qdState = qdPort->GetState();
|
||||
|
||||
@@ -408,7 +532,19 @@ void PaintRect(const Rect *rect)
|
||||
{
|
||||
case GpPixelFormats::k8BitStandard:
|
||||
{
|
||||
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
|
||||
uint8_t color = 0;
|
||||
switch (pcr)
|
||||
{
|
||||
case PaintColorResolution_Fore:
|
||||
color = qdState->ResolveForeColor8(nullptr, 0);
|
||||
break;
|
||||
case PaintColorResolution_Back:
|
||||
color = qdState->ResolveBackColor8(nullptr, 0);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
size_t scanlineIndex = 0;
|
||||
for (size_t ln = 0; ln < numLines; ln++)
|
||||
@@ -425,6 +561,12 @@ void PaintRect(const Rect *rect)
|
||||
}
|
||||
}
|
||||
|
||||
void PaintRect(const Rect *rect)
|
||||
{
|
||||
PaintRectWithPCR(*rect, PaintColorResolution_Fore);
|
||||
}
|
||||
|
||||
|
||||
void PaintOval(const Rect *rect)
|
||||
{
|
||||
PL_NotYetImplemented_TODO("Ovals");
|
||||
@@ -462,14 +604,16 @@ void FrameRoundRect(const Rect *rect, int w, int h)
|
||||
PL_NotYetImplemented_TODO("Ovals");
|
||||
}
|
||||
|
||||
void PenMode(CopyBitsMode copyBitsMode)
|
||||
void PenInvertMode(bool invertMode)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
|
||||
qdState->m_penInvert = invertMode;
|
||||
}
|
||||
|
||||
void PenMode(PenModeID penMode)
|
||||
void PenMask(bool maskMode)
|
||||
{
|
||||
PL_NotYetImplemented_TODO("Polys");
|
||||
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
|
||||
qdState->m_penMask = maskMode;
|
||||
}
|
||||
|
||||
void PenPat(const Pattern *pattern)
|
||||
@@ -484,7 +628,9 @@ void PenSize(int w, int h)
|
||||
|
||||
void PenNormal()
|
||||
{
|
||||
PL_NotYetImplemented_TODO("Polys");
|
||||
PortabilityLayer::QDState *qdState = PortabilityLayer::QDManager::GetInstance()->GetState();
|
||||
qdState->m_penInvert = false;
|
||||
qdState->m_penMask = false;
|
||||
}
|
||||
|
||||
void EraseRect(const Rect *rect)
|
||||
@@ -507,7 +653,18 @@ void InsetRect(Rect *rect, int x, int y)
|
||||
|
||||
void Line(int x, int y)
|
||||
{
|
||||
PL_NotYetImplemented_TODO("Polys");
|
||||
PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance();
|
||||
PortabilityLayer::QDState *qdState = qdManager->GetState();
|
||||
|
||||
const PortabilityLayer::Vec2i oldPos = PortabilityLayer::Vec2i(qdState->m_penPos.h, qdState->m_penPos.v);
|
||||
|
||||
qdState->m_penPos.h += x;
|
||||
qdState->m_penPos.v += y;
|
||||
|
||||
const PortabilityLayer::Vec2i newPos = PortabilityLayer::Vec2i(qdState->m_penPos.h, qdState->m_penPos.v);
|
||||
|
||||
PlotLine(qdState, qdManager->GetPort(), oldPos, newPos);
|
||||
|
||||
}
|
||||
|
||||
Pattern *GetQDGlobalsGray(Pattern *pattern)
|
||||
@@ -555,6 +712,7 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap,
|
||||
const GpPixelFormat_t pixelFormat = srcBitmap->m_pixelFormat;
|
||||
const size_t srcPitch = srcBitmap->m_pitch;
|
||||
const size_t destPitch = destBitmap->m_pitch;
|
||||
const size_t maskPitch = (maskBitmap != nullptr) ? maskBitmap->m_pitch : 0;
|
||||
|
||||
if (srcRectBase->right - srcRectBase->left != destRectBase->right - destRectBase->left ||
|
||||
srcRectBase->bottom - srcRectBase->top != destRectBase->bottom - destRectBase->top)
|
||||
@@ -566,7 +724,8 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap,
|
||||
if (maskBitmap)
|
||||
{
|
||||
assert(maskRectBase);
|
||||
assert(maskRectBase->right - maskRectBase->left == destRectBase->right - destRectBase->left);
|
||||
assert(maskRectBase->right - maskRectBase->left == srcRectBase->right - srcRectBase->left);
|
||||
assert(maskBitmap->m_pixelFormat == GpPixelFormats::kBW1 || maskBitmap->m_pixelFormat == GpPixelFormats::k8BitStandard);
|
||||
}
|
||||
|
||||
assert((maskBitmap == nullptr) == (maskRectBase == nullptr));
|
||||
@@ -589,6 +748,15 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap,
|
||||
const int32_t srcTop = srcRectBase->top + topNudge;
|
||||
const int32_t srcBottom = srcRectBase->bottom + bottomNudge;
|
||||
|
||||
maskRect = Rect::Create(0, 0, 0, 0);
|
||||
if (maskRectBase)
|
||||
{
|
||||
maskRect.left = maskRectBase->left + leftNudge;
|
||||
maskRect.right = maskRectBase->right + rightNudge;
|
||||
maskRect.top = maskRectBase->top + topNudge;
|
||||
maskRect.bottom = maskRectBase->bottom + bottomNudge;
|
||||
}
|
||||
|
||||
if (srcTop >= srcBottom)
|
||||
return;
|
||||
|
||||
@@ -639,12 +807,24 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap,
|
||||
constrainedSrcRect.top += constrainedDestRect.top - destRect.top;
|
||||
constrainedSrcRect.bottom += constrainedDestRect.bottom - destRect.bottom;
|
||||
|
||||
Rect constrainedMaskRect = maskRect;
|
||||
if (maskRectBase != nullptr)
|
||||
{
|
||||
constrainedMaskRect.left += constrainedDestRect.left - destRect.left;
|
||||
constrainedMaskRect.right += constrainedDestRect.right - destRect.right;
|
||||
constrainedMaskRect.top += constrainedDestRect.top - destRect.top;
|
||||
constrainedMaskRect.bottom += constrainedDestRect.bottom - destRect.bottom;
|
||||
}
|
||||
|
||||
const size_t srcFirstCol = constrainedSrcRect.left - srcBitmap->m_rect.left;
|
||||
const size_t srcFirstRow = constrainedSrcRect.top - srcBitmap->m_rect.top;
|
||||
|
||||
const size_t destFirstCol = constrainedDestRect.left - destBitmap->m_rect.left;
|
||||
const size_t destFirstRow = constrainedDestRect.top - destBitmap->m_rect.top;
|
||||
|
||||
const size_t maskFirstCol = maskBitmap ? constrainedMaskRect.left - maskBitmap->m_rect.left : 0;
|
||||
const size_t maskFirstRow = maskBitmap ? constrainedMaskRect.top - maskBitmap->m_rect.top : 0;
|
||||
|
||||
if (mask && mask->size != sizeof(Region))
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
@@ -672,22 +852,65 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap,
|
||||
|
||||
const uint8_t *srcBytes = static_cast<const uint8_t*>(srcBitmap->m_data);
|
||||
uint8_t *destBytes = static_cast<uint8_t*>(destBitmap->m_data);
|
||||
const uint8_t *maskBytes = maskBitmap ? static_cast<uint8_t*>(maskBitmap->m_data) : nullptr;
|
||||
|
||||
const size_t firstSrcByte = srcFirstRow * srcPitch + srcFirstCol * pixelSizeBytes;
|
||||
const size_t firstDestByte = destFirstRow * destPitch + destFirstCol * pixelSizeBytes;
|
||||
const size_t firstMaskRowByte = maskBitmap ? maskFirstRow * maskPitch : 0;
|
||||
|
||||
const size_t numCopiedRows = srcRect.bottom - srcRect.top;
|
||||
const size_t numCopiedCols = srcRect.right - srcRect.left;
|
||||
const size_t numCopiedBytesPerScanline = numCopiedCols * pixelSizeBytes;
|
||||
|
||||
for (size_t i = 0; i < numCopiedRows; i++)
|
||||
memcpy(destBytes + firstDestByte + i * destPitch, srcBytes + firstSrcByte + i * srcPitch, numCopiedBytesPerScanline);
|
||||
if (maskBitmap)
|
||||
{
|
||||
for (size_t i = 0; i < numCopiedRows; i++)
|
||||
{
|
||||
uint8_t *destRow = destBytes + firstDestByte + i * destPitch;
|
||||
const uint8_t *srcRow = srcBytes + firstSrcByte + i * srcPitch;
|
||||
const uint8_t *rowMaskBytes = maskBytes + firstMaskRowByte + i * maskPitch;
|
||||
|
||||
size_t span = 0;
|
||||
|
||||
for (size_t col = 0; col < numCopiedCols; col++)
|
||||
{
|
||||
const size_t maskBitOffset = maskFirstCol + col;
|
||||
//const bool maskBit = ((maskBytes[maskBitOffset / 8] & (0x80 >> (maskBitOffset & 7))) != 0);
|
||||
const bool maskBit = (rowMaskBytes[maskBitOffset] != 0);
|
||||
if (maskBit)
|
||||
span += pixelSizeBytes;
|
||||
else
|
||||
{
|
||||
if (span != 0)
|
||||
memcpy(destRow + col * pixelSizeBytes - span, srcRow + col * pixelSizeBytes - span, span);
|
||||
|
||||
span = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (span != 0)
|
||||
memcpy(destRow + numCopiedCols * pixelSizeBytes - span, srcRow + numCopiedCols * pixelSizeBytes - span, span);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < numCopiedRows; i++)
|
||||
memcpy(destBytes + firstDestByte + i * destPitch, srcBytes + firstSrcByte + i * srcPitch, numCopiedBytesPerScanline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CopyBits(const BitMap *srcBitmap, BitMap *destBitmap, const Rect *srcRectBase, const Rect *destRectBase, CopyBitsMode copyMode, RgnHandle maskRegion)
|
||||
{
|
||||
CopyBitsComplete(srcBitmap, nullptr, destBitmap, srcRectBase, nullptr, destRectBase, maskRegion);
|
||||
const BitMap *maskBitmap = nullptr;
|
||||
const Rect *maskRect = nullptr;
|
||||
if (copyMode == transparent && srcBitmap->m_pixelFormat == GpPixelFormats::k8BitStandard)
|
||||
{
|
||||
maskBitmap = srcBitmap;
|
||||
maskRect = srcRectBase;
|
||||
}
|
||||
|
||||
CopyBitsComplete(srcBitmap, maskBitmap, destBitmap, srcRectBase, maskRect, destRectBase, maskRegion);
|
||||
}
|
||||
|
||||
void CopyMask(const BitMap *srcBitmap, const BitMap *maskBitmap, BitMap *destBitmap, const Rect *srcRectBase, const Rect *maskRectBase, const Rect *destRectBase)
|
||||
|
||||
@@ -56,8 +56,9 @@ enum CopyBitsMode
|
||||
|
||||
enum PenModeID
|
||||
{
|
||||
patOr = transparent + 1,
|
||||
patXor,
|
||||
PenMode_Solid,
|
||||
PenMode_Pattern,
|
||||
PenMode_PatternInvert,
|
||||
};
|
||||
|
||||
struct CIcon
|
||||
@@ -81,9 +82,6 @@ struct RGBColor
|
||||
unsigned short blue;
|
||||
};
|
||||
|
||||
typedef GDevice *GDPtr;
|
||||
typedef GDPtr *GDHandle;
|
||||
|
||||
typedef CIcon *CIconPtr;
|
||||
typedef CIconPtr *CIconHandle;
|
||||
|
||||
@@ -109,8 +107,6 @@ void DisposeCIcon(CIconHandle icon);
|
||||
|
||||
void SetRect(Rect *rect, short left, short top, short right, short bottom);
|
||||
|
||||
GDHandle GetMainDevice();
|
||||
|
||||
void TextSize(int sz);
|
||||
void TextFace(int face);
|
||||
void TextFont(int fontID);
|
||||
@@ -132,8 +128,8 @@ void ClipRect(const Rect *rect); // Sets the clipping area
|
||||
void FrameRect(const Rect *rect);
|
||||
void FrameOval(const Rect *rect);
|
||||
void FrameRoundRect(const Rect *rect, int w, int h);
|
||||
void PenMode(CopyBitsMode copyBitsMode);
|
||||
void PenMode(PenModeID mode);
|
||||
void PenInvertMode(bool invertMode);
|
||||
void PenMask(bool maskMode);
|
||||
void PenPat(const Pattern *pattern);
|
||||
void PenSize(int w, int h);
|
||||
void PenNormal();
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace PortabilityLayer
|
||||
QDManagerImpl();
|
||||
|
||||
void Init() override;
|
||||
void GetPort(QDPort **port, GDevice ***gdHandle) override;
|
||||
void SetPort(QDPort *gw, GDevice **gdHandle) override;
|
||||
int NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, GDevice **device, int flags) override;
|
||||
QDPort *GetPort() const override;
|
||||
void SetPort(QDPort *gw) override;
|
||||
int NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags) override;
|
||||
void DisposeGWorld(CGraf *gw) override;
|
||||
QDState *GetState() override;
|
||||
|
||||
@@ -28,14 +28,12 @@ namespace PortabilityLayer
|
||||
|
||||
private:
|
||||
QDPort *m_port;
|
||||
GDHandle m_gdHandle;
|
||||
|
||||
static QDManagerImpl ms_instance;
|
||||
};
|
||||
|
||||
QDManagerImpl::QDManagerImpl()
|
||||
: m_port(nullptr)
|
||||
, m_gdHandle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,21 +41,17 @@ namespace PortabilityLayer
|
||||
{
|
||||
}
|
||||
|
||||
void QDManagerImpl::GetPort(QDPort **port, GDevice ***gdHandle)
|
||||
QDPort *QDManagerImpl::GetPort() const
|
||||
{
|
||||
if (port)
|
||||
*port = m_port;
|
||||
if (gdHandle)
|
||||
*gdHandle = m_gdHandle;
|
||||
return m_port;
|
||||
}
|
||||
|
||||
void QDManagerImpl::SetPort(QDPort *gw, GDevice **gdHandle)
|
||||
void QDManagerImpl::SetPort(QDPort *gw)
|
||||
{
|
||||
m_port = gw;
|
||||
m_gdHandle = gdHandle;
|
||||
}
|
||||
|
||||
int QDManagerImpl::NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, GDevice **device, int flags)
|
||||
int QDManagerImpl::NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags)
|
||||
{
|
||||
GpPixelFormat_t pixelFormat;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
struct ColorTable;
|
||||
struct CGraf;
|
||||
struct GDevice;
|
||||
struct Rect;
|
||||
|
||||
namespace PortabilityLayer
|
||||
@@ -16,9 +15,9 @@ namespace PortabilityLayer
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void GetPort(QDPort **gw, GDevice ***gdHandle) = 0;
|
||||
virtual void SetPort(QDPort *gw, GDevice **gdHandle) = 0;
|
||||
virtual int NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, GDevice **device, int flags) = 0;
|
||||
virtual QDPort *GetPort() const = 0;
|
||||
virtual void SetPort(QDPort *gw) = 0;
|
||||
virtual int NewGWorld(CGraf **gw, int depth, const Rect &bounds, ColorTable **colorTable, int flags) = 0;
|
||||
virtual void DisposeGWorld(CGraf *gw) = 0;
|
||||
|
||||
virtual QDState *GetState() = 0;
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace PortabilityLayer
|
||||
, m_isForeResolved8(false)
|
||||
, m_isBackResolved8(false)
|
||||
, m_clipRegion(nullptr)
|
||||
, m_penInvert(false)
|
||||
, m_penMask(false)
|
||||
{
|
||||
m_backUnresolvedColor.r = m_backUnresolvedColor.g = m_backUnresolvedColor.b = m_backUnresolvedColor.a = 255;
|
||||
m_foreUnresolvedColor.r = m_foreUnresolvedColor.g = m_foreUnresolvedColor.b = 0;
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace PortabilityLayer
|
||||
int m_textSize;
|
||||
Region **m_clipRegion;
|
||||
Point m_penPos;
|
||||
bool m_penInvert;
|
||||
bool m_penMask;
|
||||
|
||||
void SetForeColor(const RGBAColor &color);
|
||||
void SetBackColor(const RGBAColor &color);
|
||||
|
||||
@@ -6,6 +6,19 @@ namespace PortabilityLayer
|
||||
{
|
||||
struct RGBAColor
|
||||
{
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
uint8_t r, g, b, a;
|
||||
|
||||
static RGBAColor Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||
};
|
||||
|
||||
inline RGBAColor RGBAColor::Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
{
|
||||
RGBAColor color;
|
||||
color.r = r;
|
||||
color.g = g;
|
||||
color.b = b;
|
||||
color.a = a;
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,12 +143,12 @@ namespace PortabilityLayer
|
||||
m_bottomRight.m_x = i;
|
||||
}
|
||||
|
||||
bool Rect2i::IsValid() const
|
||||
inline bool Rect2i::IsValid() const
|
||||
{
|
||||
return m_bottomRight.m_x >= m_topLeft.m_x && m_bottomRight.m_y >= m_topLeft.m_y;
|
||||
}
|
||||
|
||||
Rect2i Rect2i::Intersect(const Rect2i &other) const
|
||||
inline Rect2i Rect2i::Intersect(const Rect2i &other) const
|
||||
{
|
||||
const int32_t top = std::max(m_topLeft.m_y, other.m_topLeft.m_y);
|
||||
const int32_t left = std::max(m_topLeft.m_x, other.m_topLeft.m_x);
|
||||
@@ -158,7 +158,7 @@ namespace PortabilityLayer
|
||||
return Rect2i(top, left, bottom, right);
|
||||
}
|
||||
|
||||
Rect Rect2i::ToShortRect() const
|
||||
inline Rect Rect2i::ToShortRect() const
|
||||
{
|
||||
return Rect::Create(static_cast<int16_t>(m_topLeft.m_y), static_cast<int16_t>(m_topLeft.m_x), static_cast<int16_t>(m_bottomRight.m_y), static_cast<int16_t>(m_bottomRight.m_x));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace PortabilityLayer
|
||||
WindowImpl();
|
||||
~WindowImpl();
|
||||
|
||||
bool Init(const WindowDef &windowDef, GDevice **device);
|
||||
bool Init(const WindowDef &windowDef);
|
||||
bool Resize(int width, int height);
|
||||
|
||||
WindowImpl *GetWindowAbove() const;
|
||||
@@ -38,12 +38,9 @@ namespace PortabilityLayer
|
||||
bool IsVisible() const;
|
||||
void SetVisible(bool visible);
|
||||
|
||||
GDevice **GetDevice() const;
|
||||
|
||||
private:
|
||||
WindowImpl *m_windowAbove;
|
||||
WindowImpl *m_windowBelow;
|
||||
GDevice **m_device;
|
||||
|
||||
bool m_visible;
|
||||
};
|
||||
@@ -59,7 +56,6 @@ namespace PortabilityLayer
|
||||
void PutWindowBehind(Window *window, Window *otherWindow) override;
|
||||
void ShowWindow(Window *window) override;
|
||||
void HideWindow(Window *window) override;
|
||||
GDevice **GetWindowDevice(Window *window) override;
|
||||
void FindWindow(const Point &point, Window **outWindow, short *outRegion) const override;
|
||||
|
||||
void RenderFrame(IGpDisplayDriver *displayDriver) override;
|
||||
@@ -82,7 +78,6 @@ namespace PortabilityLayer
|
||||
WindowImpl::WindowImpl()
|
||||
: m_windowAbove(nullptr)
|
||||
, m_windowBelow(nullptr)
|
||||
, m_device(nullptr)
|
||||
, m_visible(true)
|
||||
{
|
||||
}
|
||||
@@ -92,7 +87,7 @@ namespace PortabilityLayer
|
||||
PL_NotYetImplemented();
|
||||
}
|
||||
|
||||
bool WindowImpl::Init(const WindowDef &windowDef, GDevice **device)
|
||||
bool WindowImpl::Init(const WindowDef &windowDef)
|
||||
{
|
||||
const Rect bounds = windowDef.m_initialRect;
|
||||
|
||||
@@ -101,10 +96,10 @@ namespace PortabilityLayer
|
||||
|
||||
const Rect adjustedBounds = Rect::Create(0, 0, bounds.bottom - bounds.top, bounds.right - bounds.left);
|
||||
|
||||
if (int errorCode = m_graf.Init(adjustedBounds, (*device)->pixelFormat))
|
||||
return false;
|
||||
GpPixelFormat_t pixelFormat = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetPixelFormat();
|
||||
|
||||
m_device = device;
|
||||
if (int errorCode = m_graf.Init(adjustedBounds, pixelFormat))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -148,11 +143,6 @@ namespace PortabilityLayer
|
||||
m_visible = visible;
|
||||
}
|
||||
|
||||
GDevice **WindowImpl::GetDevice() const
|
||||
{
|
||||
return m_device;
|
||||
}
|
||||
|
||||
WindowManagerImpl::WindowManagerImpl()
|
||||
: m_windowStackTop(nullptr)
|
||||
, m_windowStackBottom(nullptr)
|
||||
@@ -165,14 +155,12 @@ namespace PortabilityLayer
|
||||
if (!windowMem)
|
||||
return nullptr;
|
||||
|
||||
GDevice **device = DisplayDeviceManager::GetInstance()->GetMainDevice();
|
||||
|
||||
Rect portRect = windowDef.m_initialRect;
|
||||
if (!portRect.IsValid())
|
||||
return nullptr;
|
||||
|
||||
WindowImpl *window = new (windowMem) WindowImpl();
|
||||
if (!window->Init(windowDef, device))
|
||||
if (!window->Init(windowDef))
|
||||
{
|
||||
window->~WindowImpl();
|
||||
MemoryManager::GetInstance()->Release(windowMem);
|
||||
@@ -243,11 +231,6 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
GDevice **WindowManagerImpl::GetWindowDevice(Window *window)
|
||||
{
|
||||
return static_cast<WindowImpl*>(window)->GetDevice();
|
||||
}
|
||||
|
||||
void WindowManagerImpl::FindWindow(const Point &point, Window **outWindow, short *outRegion) const
|
||||
{
|
||||
// outRegion = One of:
|
||||
@@ -304,24 +287,15 @@ namespace PortabilityLayer
|
||||
|
||||
void WindowManagerImpl::RenderFrame(IGpDisplayDriver *displayDriver)
|
||||
{
|
||||
GDevice **mainDeviceHdl = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetMainDevice();
|
||||
PortabilityLayer::DisplayDeviceManager *dd = PortabilityLayer::DisplayDeviceManager::GetInstance();
|
||||
|
||||
if (mainDeviceHdl)
|
||||
dd->SyncPalette(displayDriver);
|
||||
|
||||
WindowImpl *window = m_windowStackBottom;
|
||||
while (window)
|
||||
{
|
||||
GDevice *mainDevice = *mainDeviceHdl;
|
||||
|
||||
if (mainDevice->paletteIsDirty)
|
||||
{
|
||||
displayDriver->UpdatePalette(mainDevice->paletteStorage + mainDevice->paletteDataOffset);
|
||||
mainDevice->paletteIsDirty = false;
|
||||
}
|
||||
|
||||
WindowImpl *window = m_windowStackBottom;
|
||||
while (window)
|
||||
{
|
||||
RenderWindow(window, displayDriver);
|
||||
window = window->GetWindowAbove();
|
||||
}
|
||||
RenderWindow(window, displayDriver);
|
||||
window = window->GetWindowAbove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace PortabilityLayer
|
||||
virtual void PutWindowBehind(Window *window, Window *otherWindow) = 0;
|
||||
virtual void ShowWindow(Window *window) = 0;
|
||||
virtual void HideWindow(Window *window) = 0;
|
||||
virtual GDevice **GetWindowDevice(Window *window) = 0;
|
||||
virtual void FindWindow(const Point &point, Window **outWindow, short *outRegion) const = 0;
|
||||
|
||||
virtual void RenderFrame(IGpDisplayDriver *displayDriver) = 0;
|
||||
|
||||
Reference in New Issue
Block a user