mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-13 19:49:36 +00:00
Cleanup, add scanline mask builder
This commit is contained in:
@@ -131,9 +131,6 @@ void InitAnimatedCursor (acurHandle ballCursH)
|
||||
if (!compiledBallCursorH)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
|
||||
HNoPurge((Handle)ballCursH);
|
||||
MoveHHi((Handle)ballCursH);
|
||||
HLock((Handle)ballCursH);
|
||||
if (useColor)
|
||||
useColor = GetColorCursors(ballCursH, compiledBallCursorH);
|
||||
if (!useColor && !GetMonoCursors(ballCursH, compiledBallCursorH))
|
||||
|
||||
@@ -90,12 +90,9 @@ void DrawBanner (Point *topLeft)
|
||||
short CountStarsInHouse (void)
|
||||
{
|
||||
short i, h, numRooms, numStars;
|
||||
char wasState;
|
||||
|
||||
numStars = 0;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -106,7 +103,6 @@ short CountStarsInHouse (void)
|
||||
numStars++;
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (numStars);
|
||||
}
|
||||
@@ -119,12 +115,8 @@ void DrawBannerMessage (Point topLeft)
|
||||
{
|
||||
Str255 bannerStr, subStr;
|
||||
short count;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
PasStringCopy((*thisHouse)->banner, bannerStr);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
TextFont(applFont);
|
||||
TextFace(bold);
|
||||
|
||||
@@ -143,11 +143,7 @@ void GetDialogRect (Rect *bounds, short dialogID)
|
||||
dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID);
|
||||
if (dlogHandle != nil)
|
||||
{
|
||||
wasState = HGetState((Handle)dlogHandle);
|
||||
HLock((Handle)dlogHandle);
|
||||
|
||||
*bounds = (**dlogHandle).boundsRect;
|
||||
HSetState((Handle)dlogHandle, wasState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//============================================================================
|
||||
|
||||
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "PLAppleEvents.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLToolUtils.h"
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "Externs.h"
|
||||
#include "Environ.h"
|
||||
#include "House.h"
|
||||
|
||||
@@ -91,10 +91,7 @@ void SetUpFinalScreen (void)
|
||||
if (textDown < 0)
|
||||
textDown = 0;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
PasStringCopy((*thisHouse)->trailer, tempStr);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
count = 0;
|
||||
do
|
||||
|
||||
@@ -150,8 +150,6 @@ void DrawHighScores (void)
|
||||
TextFace(bold);
|
||||
TextSize(12);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
// message for score #1
|
||||
PasStringCopy(thisHousePtr->highScores.banner, tempStr);
|
||||
@@ -273,7 +271,6 @@ void DrawHighScores (void)
|
||||
DrawString(tempStr);
|
||||
|
||||
ForeColor(blackColor);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- SortHighScores
|
||||
@@ -287,8 +284,6 @@ void SortHighScores (void)
|
||||
short i, h, which;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
for (h = 0; h < kMaxScores; h++)
|
||||
@@ -314,8 +309,6 @@ void SortHighScores (void)
|
||||
}
|
||||
PasStringCopy(thisHousePtr->highScores.banner, tempScores.banner);
|
||||
thisHousePtr->highScores = tempScores;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ZeroHighScores
|
||||
@@ -327,8 +320,6 @@ void ZeroHighScores (void)
|
||||
short i;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
PasStringCopy(thisHouseName, thisHousePtr->highScores.banner);
|
||||
@@ -339,8 +330,6 @@ void ZeroHighScores (void)
|
||||
thisHousePtr->highScores.timeStamps[i] = 0L;
|
||||
thisHousePtr->highScores.levels[i] = 0;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ZeroAllButHighestScore
|
||||
@@ -352,8 +341,6 @@ void ZeroAllButHighestScore (void)
|
||||
short i;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
for (i = 1; i < kMaxScores; i++)
|
||||
@@ -363,8 +350,6 @@ void ZeroAllButHighestScore (void)
|
||||
thisHousePtr->highScores.timeStamps[i] = 0L;
|
||||
thisHousePtr->highScores.levels[i] = 0;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- TestHighScore
|
||||
@@ -381,8 +366,6 @@ Boolean TestHighScore (void)
|
||||
if (resumedSavedGame)
|
||||
return (false);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
lastHighScore = -1;
|
||||
@@ -415,8 +398,6 @@ Boolean TestHighScore (void)
|
||||
gameDirty = true;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
if (placing != -1)
|
||||
{
|
||||
DoHighScores();
|
||||
@@ -770,18 +751,14 @@ Boolean WriteScoresToDisk (void)
|
||||
}
|
||||
|
||||
byteCount = sizeof(scoresType);
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
theScores = &((*thisHouse)->highScores);
|
||||
|
||||
theErr = FSWrite(scoresRefNum, &byteCount, (Ptr)theScores);
|
||||
if (!CheckFileError(theErr, PSTR("High Scores File")))
|
||||
{
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
theErr = FSClose(scoresRefNum);
|
||||
return(false);
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
theErr = SetEOF(scoresRefNum, byteCount);
|
||||
if (!CheckFileError(theErr, PSTR("High Scores File")))
|
||||
@@ -835,18 +812,14 @@ Boolean ReadScoresFromDisk (void)
|
||||
return (false);
|
||||
}
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
theScores = &((*thisHouse)->highScores);
|
||||
|
||||
theErr = FSRead(scoresRefNum, &byteCount, theScores);
|
||||
if (!CheckFileError(theErr, PSTR("High Scores File")))
|
||||
{
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
theErr = FSClose(scoresRefNum);
|
||||
return (false);
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
theErr = FSClose(scoresRefNum);
|
||||
if (!CheckFileError(theErr, PSTR("High Scores File")))
|
||||
|
||||
@@ -123,7 +123,6 @@ Boolean InitializeEmptyHouse (void)
|
||||
return (false);
|
||||
}
|
||||
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
thisHousePtr->version = kHouseVersion;
|
||||
@@ -144,8 +143,6 @@ Boolean InitializeEmptyHouse (void)
|
||||
wardBitSet = false;
|
||||
phoneBitSet = false;
|
||||
|
||||
HUnlock((Handle)thisHouse);
|
||||
|
||||
numberRooms = 0;
|
||||
mapLeftRoom = 60;
|
||||
mapTopRoom = 50;
|
||||
@@ -174,8 +171,6 @@ short RealRoomNumberCount (void)
|
||||
short realRoomCount, i;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
realRoomCount = (*thisHouse)->nRooms;
|
||||
if (realRoomCount != 0)
|
||||
{
|
||||
@@ -185,7 +180,6 @@ short RealRoomNumberCount (void)
|
||||
realRoomCount--;
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (realRoomCount);
|
||||
}
|
||||
@@ -200,8 +194,6 @@ short GetFirstRoomNumber (void)
|
||||
short firstRoom;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
if ((*thisHouse)->nRooms <= 0)
|
||||
{
|
||||
firstRoom = -1;
|
||||
@@ -213,7 +205,6 @@ short GetFirstRoomNumber (void)
|
||||
if ((firstRoom >= (*thisHouse)->nRooms) || (firstRoom < 0))
|
||||
firstRoom = 0;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (firstRoom);
|
||||
}
|
||||
@@ -228,15 +219,11 @@ void WhereDoesGliderBegin (Rect *theRect, short mode)
|
||||
Point initialPt;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
if (mode == kResumeGameMode)
|
||||
initialPt = smallGame.where;
|
||||
else if (mode == kNewGameMode)
|
||||
initialPt = (*thisHouse)->initial;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
QSetRect(theRect, 0, 0, kGliderWide, kGliderHigh);
|
||||
QOffsetRect(theRect, initialPt.h, initialPt.v);
|
||||
}
|
||||
@@ -266,8 +253,6 @@ short CountHouseLinks (void)
|
||||
|
||||
numLinks = 0;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
numRooms = thisHousePtr->nRooms;
|
||||
|
||||
@@ -303,8 +288,6 @@ short CountHouseLinks (void)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (numLinks);
|
||||
}
|
||||
|
||||
@@ -324,8 +307,6 @@ void GenerateLinksList (void)
|
||||
short floor, suite, roomLinked, objectLinked;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
numRooms = thisHousePtr->nRooms;
|
||||
|
||||
@@ -382,8 +363,6 @@ void GenerateLinksList (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -468,8 +447,6 @@ void SortHouseObjects (void)
|
||||
|
||||
GenerateLinksList();
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
numRooms = thisHousePtr->nRooms;
|
||||
|
||||
@@ -498,7 +475,6 @@ void SortHouseObjects (void)
|
||||
}
|
||||
|
||||
SpinCursor(3);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
if (linksList != nil)
|
||||
DisposePtr((Ptr)linksList);
|
||||
ForceThisRoom(thisRoomNumber);
|
||||
@@ -516,8 +492,6 @@ short CountRoomsVisited (void)
|
||||
short numRooms, r, count;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
numRooms = thisHousePtr->nRooms;
|
||||
count = 0;
|
||||
@@ -528,7 +502,6 @@ short CountRoomsVisited (void)
|
||||
count++;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
return (count);
|
||||
}
|
||||
|
||||
@@ -548,8 +521,6 @@ void GenerateRetroLinks (void)
|
||||
for (i = 0; i < kMaxRoomObs; i++) // Initialize array.
|
||||
retroLinkList[i].room = -1;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
numRooms = thisHousePtr->nRooms;
|
||||
|
||||
@@ -610,8 +581,6 @@ void GenerateRetroLinks (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- UpdateGoToDialog
|
||||
@@ -759,9 +728,6 @@ void ConvertHouseVer1To2 (void)
|
||||
|
||||
SpinCursor(3);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -814,7 +780,6 @@ void ConvertHouseVer1To2 (void)
|
||||
}
|
||||
|
||||
(*thisHouse)->version = kHouseVersion;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
InitCursor();
|
||||
CloseMessageWindow();
|
||||
@@ -834,8 +799,6 @@ void ShiftWholeHouse (short howFar)
|
||||
|
||||
CopyThisRoomToRoom();
|
||||
wasRoom = thisRoomNumber;
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
|
||||
for (i = 0; i < numRooms; i++)
|
||||
@@ -852,7 +815,6 @@ void ShiftWholeHouse (short howFar)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
ForceThisRoom(wasRoom);
|
||||
|
||||
InitCursor();
|
||||
|
||||
@@ -662,7 +662,6 @@ Boolean ReadHouse (void)
|
||||
YellowAlert(kYellowNoMemory, 10);
|
||||
return(false);
|
||||
}
|
||||
MoveHHi((Handle)thisHouse);
|
||||
|
||||
theErr = SetFPos(houseRefNum, fsFromStart, 0L);
|
||||
if (theErr != noErr)
|
||||
@@ -671,13 +670,11 @@ Boolean ReadHouse (void)
|
||||
return(false);
|
||||
}
|
||||
|
||||
HLock((Handle)thisHouse);
|
||||
long readByteCount = byteCount;
|
||||
theErr = FSRead(houseRefNum, &readByteCount, *thisHouse);
|
||||
if (theErr != noErr || readByteCount != byteCount || byteCount < static_cast<long>(houseType::kBinaryDataSize))
|
||||
{
|
||||
CheckFileError(theErr, thisHouseName);
|
||||
HUnlock((Handle)thisHouse);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -702,7 +699,6 @@ Boolean ReadHouse (void)
|
||||
numberRooms = 0;
|
||||
noRoomAtAll = true;
|
||||
YellowAlert(kYellowNoRooms, 0);
|
||||
HUnlock((Handle)thisHouse);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -710,7 +706,6 @@ Boolean ReadHouse (void)
|
||||
if (wasHouseVersion >= kNewHouseVersion)
|
||||
{
|
||||
YellowAlert(kYellowNewerVersion, 0);
|
||||
HUnlock((Handle)thisHouse);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -732,8 +727,6 @@ Boolean ReadHouse (void)
|
||||
phoneBitSet = (((*thisHouse)->flags & 0x00000002) == 0x00000002);
|
||||
bannerStarCountOn = (((*thisHouse)->flags & 0x00000004) == 0x00000000);
|
||||
|
||||
HUnlock((Handle)thisHouse);
|
||||
|
||||
noRoomAtAll = (RealRoomNumberCount() == 0);
|
||||
thisRoomNumber = -1;
|
||||
previousRoom = -1;
|
||||
@@ -786,7 +779,6 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
if (checkIt)
|
||||
CheckHouseForProblems();
|
||||
|
||||
HLock((Handle)thisHouse);
|
||||
byteCount = GetHandleSize((Handle)thisHouse);
|
||||
|
||||
if (fileDirty)
|
||||
@@ -815,7 +807,6 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
{
|
||||
CheckFileError(theErr, thisHouseName);
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount));
|
||||
HUnlock((Handle)thisHouse);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -824,7 +815,6 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
{
|
||||
CheckFileError(theErr, thisHouseName);
|
||||
ByteSwapHouse(*thisHouse, static_cast<size_t>(byteCount));
|
||||
HUnlock((Handle)thisHouse);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -834,12 +824,9 @@ Boolean WriteHouse (Boolean checkIt)
|
||||
if (theErr != noErr)
|
||||
{
|
||||
CheckFileError(theErr, thisHouseName);
|
||||
HUnlock((Handle)thisHouse);
|
||||
return(false);
|
||||
}
|
||||
|
||||
HUnlock((Handle)thisHouse);
|
||||
|
||||
if (changeLockStateOfHouse)
|
||||
{
|
||||
changeLockStateOfHouse = false;
|
||||
|
||||
@@ -57,9 +57,6 @@ long CountTotalHousePoints (void)
|
||||
|
||||
pointTotal = (long)RealRoomNumberCount() * (long)kRoomVisitScore;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -100,8 +97,6 @@ long CountTotalHousePoints (void)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (pointTotal);
|
||||
}
|
||||
|
||||
@@ -218,9 +213,7 @@ void DoHouseInfo (void)
|
||||
houseFilterUPP = NewModalFilterUPP(HouseFilter);
|
||||
tempPhoneBit = phoneBitSet;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
numRooms = RealRoomNumberCount();
|
||||
HLock((Handle)thisHouse);
|
||||
PasStringCopy((*thisHouse)->banner, banner);
|
||||
PasStringCopy((*thisHouse)->trailer, trailer);
|
||||
version = (*thisHouse)->version;
|
||||
@@ -229,7 +222,6 @@ void DoHouseInfo (void)
|
||||
h = (long)(*thisHouse)->rooms[(*thisHouse)->firstRoom].suite;
|
||||
v = (long)(*thisHouse)->rooms[(*thisHouse)->firstRoom].floor;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
NumToString((long)version >> 8, versStr); // Convert version to two strings<67>
|
||||
NumToString((long)version % 0x0100, loVers); // the 1's and 1/10th's part.
|
||||
@@ -261,8 +253,6 @@ void DoHouseInfo (void)
|
||||
GetDialogString(houseInfoDialog, kBannerTextItem, banner);
|
||||
GetDialogString(houseInfoDialog, kTrailerTextItem, trailer);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
PasStringCopyNum(banner, (*thisHouse)->banner, 255);
|
||||
PasStringCopyNum(trailer, (*thisHouse)->trailer, 255);
|
||||
if (tempPhoneBit != phoneBitSet)
|
||||
@@ -273,7 +263,6 @@ void DoHouseInfo (void)
|
||||
else
|
||||
(*thisHouse)->flags = (*thisHouse)->flags & 0xFFFFDFFD;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
fileDirty = true;
|
||||
UpdateMenus(false);
|
||||
|
||||
@@ -54,8 +54,6 @@ Boolean KeepObjectLegal (void)
|
||||
|
||||
if (objActive == kInitialGliderSelected)
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
if ((*thisHouse)->initial.h < 0)
|
||||
(*thisHouse)->initial.h = 0;
|
||||
if ((*thisHouse)->initial.v < 0)
|
||||
@@ -64,7 +62,6 @@ Boolean KeepObjectLegal (void)
|
||||
(*thisHouse)->initial.h = kRoomWide - kGliderWide;
|
||||
if ((*thisHouse)->initial.v > (kTileHigh - kGliderHigh))
|
||||
(*thisHouse)->initial.v = kTileHigh - kGliderHigh;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
return (true);
|
||||
}
|
||||
|
||||
@@ -605,13 +602,8 @@ void WrapBannerAndTrailer (void)
|
||||
{
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
WrapText((*thisHouse)->banner, 40);
|
||||
WrapText((*thisHouse)->trailer, 64);
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ValidateNumberOfRooms
|
||||
@@ -623,9 +615,6 @@ void ValidateNumberOfRooms (void)
|
||||
long countedRooms, reportsRooms;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
reportsRooms = (long)(*thisHouse)->nRooms;
|
||||
countedRooms = (GetHandleSize((Handle)thisHouse) -
|
||||
sizeof(houseType)) / sizeof(roomType);
|
||||
@@ -635,8 +624,6 @@ void ValidateNumberOfRooms (void)
|
||||
numberRooms = (*thisHouse)->nRooms;
|
||||
houseErrors++;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- CheckDuplicateFloorSuite
|
||||
@@ -654,9 +641,6 @@ void CheckDuplicateFloorSuite (void)
|
||||
if (pidgeonHoles == nil)
|
||||
return;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -676,8 +660,6 @@ void CheckDuplicateFloorSuite (void)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
DisposePtr((Ptr)pidgeonHoles);
|
||||
}
|
||||
|
||||
@@ -691,9 +673,6 @@ void CompressHouse (void)
|
||||
char wasState;
|
||||
Boolean compressing, probing;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
wasFirstRoom = (*thisHouse)->firstRoom;
|
||||
compressing = true;
|
||||
roomNumber = (*thisHouse)->nRooms - 1; // start with last room
|
||||
@@ -729,8 +708,6 @@ void CompressHouse (void)
|
||||
compressing = false;
|
||||
}
|
||||
while (compressing);
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- LopOffExtraRooms
|
||||
@@ -744,9 +721,6 @@ void LopOffExtraRooms (void)
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
count = 0;
|
||||
r = (*thisHouse)->nRooms; // begin at last room
|
||||
do
|
||||
@@ -763,19 +737,16 @@ void LopOffExtraRooms (void)
|
||||
{
|
||||
r = (*thisHouse)->nRooms - count;
|
||||
newSize = sizeof(houseType) + (sizeof(roomType) * (long)r);
|
||||
HUnlock((Handle)thisHouse); // resize house handle (shrink)
|
||||
SetHandleSize((Handle)thisHouse, newSize);
|
||||
SetHandleSize((Handle)thisHouse, newSize); // resize house handle (shrink)
|
||||
if (MemError() != noErr) // problem?
|
||||
{
|
||||
ForeColor(redColor);
|
||||
GetLocalizedString(16, message);
|
||||
SetMessageWindowMessage(message);
|
||||
}
|
||||
HLock((Handle)thisHouse); // reflect new room count
|
||||
(*thisHouse)->nRooms -= count;
|
||||
numberRooms = (*thisHouse)->nRooms;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ValidateRoomNumbers
|
||||
@@ -788,9 +759,6 @@ void ValidateRoomNumbers (void)
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
if (numRooms < 0)
|
||||
{
|
||||
@@ -823,8 +791,6 @@ void ValidateRoomNumbers (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- CountUntitledRooms
|
||||
@@ -836,9 +802,6 @@ void CountUntitledRooms (void)
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -846,8 +809,6 @@ void CountUntitledRooms (void)
|
||||
(EqualString((*thisHouse)->rooms[i].name, PSTR("Untitled Room"), false, true)))
|
||||
houseErrors++;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- CheckRoomNameLength
|
||||
@@ -859,9 +820,6 @@ void CheckRoomNameLength (void)
|
||||
short i, numRooms;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -874,8 +832,6 @@ void CheckRoomNameLength (void)
|
||||
houseErrors++;
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- MakeSureNumObjectsJives
|
||||
@@ -887,9 +843,6 @@ void MakeSureNumObjectsJives (void)
|
||||
short i, h, numRooms, count;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -908,8 +861,6 @@ void MakeSureNumObjectsJives (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- KeepAllObjectsLegal
|
||||
@@ -922,9 +873,6 @@ void KeepAllObjectsLegal (void)
|
||||
char wasState;
|
||||
Str255 message;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -950,8 +898,6 @@ void KeepAllObjectsLegal (void)
|
||||
CopyThisRoomToRoom();
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- CheckForStaircasePairs
|
||||
@@ -965,9 +911,6 @@ void CheckForStaircasePairs (void)
|
||||
Boolean hasStairs;
|
||||
Str255 message;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
numRooms = (*thisHouse)->nRooms;
|
||||
for (i = 0; i < numRooms; i++)
|
||||
{
|
||||
@@ -1040,8 +983,6 @@ void CheckForStaircasePairs (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -83,25 +83,21 @@ void GetExtraCursors (void)
|
||||
handCursorH = GetCursor(kHandCursorID);
|
||||
if (handCursorH == nil)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
HLock((Handle)handCursorH);
|
||||
handCursor = **handCursorH;
|
||||
|
||||
vertCursorH = GetCursor(kVertCursorID);
|
||||
if (vertCursorH == nil)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
HLock((Handle)vertCursorH);
|
||||
vertCursor = **vertCursorH;
|
||||
|
||||
horiCursorH = GetCursor(kHoriCursorID);
|
||||
if (horiCursorH == nil)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
HLock((Handle)horiCursorH);
|
||||
horiCursor = **horiCursorH;
|
||||
|
||||
diagCursorH = GetCursor(kDiagCursorID);
|
||||
if (diagCursorH == nil)
|
||||
RedAlert(kErrFailedResourceLoad);
|
||||
HLock((Handle)diagCursorH);
|
||||
diagCursor = **diagCursorH;
|
||||
}
|
||||
|
||||
|
||||
@@ -295,8 +295,6 @@ void DoLink (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
if (linkerIsSwitch)
|
||||
{
|
||||
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.e.where =
|
||||
@@ -311,7 +309,6 @@ void DoLink (void)
|
||||
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.d.who =
|
||||
objActive;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
fileDirty = true;
|
||||
UpdateMenus(false);
|
||||
@@ -342,8 +339,6 @@ void DoUnlink (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
if (linkerIsSwitch)
|
||||
{
|
||||
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.e.where = -1;
|
||||
@@ -354,7 +349,6 @@ void DoUnlink (void)
|
||||
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.d.where = -1;
|
||||
(*thisHouse)->rooms[linkRoom].objects[linkObject].data.d.who = 255;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
fileDirty = true;
|
||||
UpdateMenus(false);
|
||||
|
||||
@@ -126,9 +126,6 @@ void FindNewActiveRoomRect (void)
|
||||
|
||||
activeRoomVisible = false;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
for (i = 0; i < mapRoomsHigh; i++)
|
||||
{
|
||||
for (h = 0; h < mapRoomsWide; h++)
|
||||
@@ -150,8 +147,6 @@ void FindNewActiveRoomRect (void)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
if (activeRoomVisible)
|
||||
{
|
||||
activeRoomRect.right++;
|
||||
@@ -211,9 +206,6 @@ void RedrawMapContents (void)
|
||||
ClipRect(&newClip);
|
||||
}
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
for (i = 0; i < mapRoomsHigh; i++)
|
||||
{
|
||||
for (h = 0; h < mapRoomsWide; h++)
|
||||
@@ -266,8 +258,6 @@ void RedrawMapContents (void)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
ForeColor(blackColor);
|
||||
PenNormal();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -723,12 +723,10 @@ short QueryResumeGame (void)
|
||||
|
||||
resumeFilterUPP = NewModalFilterUPP(ResumeFilter);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse); // get score & num. gliders
|
||||
HLock((Handle)thisHouse);
|
||||
// get score & num. gliders
|
||||
thisHousePtr = *thisHouse;
|
||||
hadPoints = thisHousePtr->savedGame.score;
|
||||
hadGliders = thisHousePtr->savedGame.numGliders;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
NumToString(hadPoints, scoreStr); // param text strings
|
||||
NumToString((long)hadGliders, glidStr);
|
||||
if (hadGliders == 1)
|
||||
|
||||
@@ -165,10 +165,7 @@ void StartGliderMailingIn (gliderPtr thisGlider, Rect *bounds, hotPtr who)
|
||||
objLinked = masterObjects[whoLinked].objectLink;
|
||||
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
thisGlider->frame = 0;
|
||||
thisGlider->clip = *bounds;
|
||||
@@ -228,10 +225,7 @@ void StartGliderDuctingDown (gliderPtr thisGlider, Rect *bounds, hotPtr who)
|
||||
objLinked = masterObjects[whoLinked].objectLink;
|
||||
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
thisGlider->frame = 0;
|
||||
thisGlider->clip = *bounds;
|
||||
@@ -261,10 +255,7 @@ void StartGliderDuctingUp (gliderPtr thisGlider, Rect *bounds, hotPtr who)
|
||||
objLinked = masterObjects[whoLinked].objectLink;
|
||||
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
thisGlider->frame = 0;
|
||||
thisGlider->clip = *bounds;
|
||||
@@ -303,10 +294,7 @@ void StartGliderTransporting (gliderPtr thisGlider, hotPtr who)
|
||||
objLinked = masterObjects[whoLinked].objectLink;
|
||||
linkedToWhat = WhatAreWeLinkedTo(transRoom, objLinked);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
GetObjectRect(&(*thisHouse)->rooms[transRoom].objects[objLinked], &transRect);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
thisGlider->dest.right = thisGlider->dest.left + kGliderWide;
|
||||
thisGlider->dest.bottom = thisGlider->dest.top + kGliderHigh;
|
||||
|
||||
@@ -233,15 +233,12 @@ OSErr LoadMusicSounds (void)
|
||||
if (theSound == nil)
|
||||
return (MemError());
|
||||
|
||||
HLock(theSound);
|
||||
soundDataSize = GetHandleSize(theSound) - 20L;
|
||||
HUnlock(theSound);
|
||||
|
||||
theMusicData[i] = NewPtr(soundDataSize);
|
||||
if (theMusicData[i] == nil)
|
||||
return (MemError());
|
||||
|
||||
HLock(theSound);
|
||||
BlockMove((Ptr)(static_cast<Byte*>(*theSound) + 20L), theMusicData[i], soundDataSize);
|
||||
ReleaseResource(theSound);
|
||||
}
|
||||
|
||||
@@ -829,8 +829,6 @@ short FindObjectSlotInRoom (short roomNumber)
|
||||
|
||||
emptySlot = -1;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNumber]);
|
||||
|
||||
for (i = 0; i < kMaxRoomObs; i++)
|
||||
@@ -840,9 +838,6 @@ short FindObjectSlotInRoom (short roomNumber)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (emptySlot);
|
||||
}
|
||||
|
||||
@@ -855,8 +850,6 @@ Boolean DoesRoomNumHaveObject (short room, short what)
|
||||
char wasState;
|
||||
Boolean hasIt;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[room]);
|
||||
|
||||
hasIt = false;
|
||||
@@ -868,9 +861,6 @@ Boolean DoesRoomNumHaveObject (short room, short what)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (hasIt);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "Objects.h"
|
||||
#include "RectUtils.h"
|
||||
#include "Room.h"
|
||||
#include "Vec2i.h"
|
||||
#include "ScanlineMask.h"
|
||||
#include "ScanlineMaskConverter.h"
|
||||
|
||||
|
||||
#define k8WhiteColor 0
|
||||
@@ -293,16 +296,20 @@ void DrawShelf (Rect *shelfTop)
|
||||
GetGWorld(&wasCPort, &wasWorld);
|
||||
SetGWorld(backSrcMap, nil);
|
||||
|
||||
MoveTo(shelfTop->left, shelfTop->bottom);
|
||||
shadowRgn = NewRgn();
|
||||
if (shadowRgn == nil)
|
||||
RedAlert(kErrUnnaccounted);
|
||||
|
||||
PortabilityLayer::Vec2i poly[5];
|
||||
poly[0] = PortabilityLayer::Vec2i(shelfTop->left, shelfTop->bottom);
|
||||
poly[1] = poly[0] + PortabilityLayer::Vec2i(kShelfShadowOff, kShelfShadowOff);
|
||||
poly[2] = poly[1] + PortabilityLayer::Vec2i(RectWide(shelfTop) - kShelfDeep, 0);
|
||||
poly[3] = poly[2] + PortabilityLayer::Vec2i(0, -kShelfThick + 1);
|
||||
poly[4] = poly[3] + PortabilityLayer::Vec2i(-kShelfShadowOff, -kShelfShadowOff);
|
||||
|
||||
//PortabilityLayer::ScanlineMask *mask = PortabilityLayer::ScanlineMaskConverter::CompilePoly(poly, sizeof(poly) / sizeof(poly[0]));
|
||||
|
||||
OpenRgn();
|
||||
Line(kShelfShadowOff, kShelfShadowOff);
|
||||
Line(RectWide(shelfTop) - kShelfDeep, 0);
|
||||
Line(0, -kShelfThick + 1);
|
||||
Line(-kShelfShadowOff, -kShelfShadowOff);
|
||||
LineTo(shelfTop->left, shelfTop->bottom);
|
||||
CloseRgn(shadowRgn);
|
||||
PenPat(GetQDGlobalsGray(&dummyPattern));
|
||||
PenMode(patOr);
|
||||
@@ -312,7 +319,9 @@ void DrawShelf (Rect *shelfTop)
|
||||
ColorRegion(shadowRgn, k8DkstGrayColor);
|
||||
PenNormal();
|
||||
DisposeRgn(shadowRgn);
|
||||
|
||||
//mask->Destroy();
|
||||
|
||||
MoveTo(shelfTop->left, shelfTop->bottom);
|
||||
InsetRect(shelfTop, 0, 1);
|
||||
ColorRect(shelfTop, brownC);
|
||||
InsetRect(shelfTop, 0, -1);
|
||||
|
||||
@@ -1146,9 +1146,7 @@ void DrawCalendar (Rect *theRect)
|
||||
if (thePicture == nil)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
|
||||
HLock((Handle)thePicture);
|
||||
bounds = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, theRect->left, theRect->top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
@@ -1182,9 +1180,7 @@ void DrawBulletin (Rect *theRect)
|
||||
if (thePicture == nil)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
|
||||
HLock((Handle)thePicture);
|
||||
bounds = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, theRect->left, theRect->top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
@@ -37,9 +37,6 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
|
||||
ZeroRectCorner(&testRect);
|
||||
isLit = (numLights > 0);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
for (i = 0; i < kMaxRoomObs; i++)
|
||||
{
|
||||
dynamicNum = -1;
|
||||
@@ -960,7 +957,5 @@ void DrawARoomsObjects (short neighbor, Boolean redraw)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
|
||||
@@ -529,11 +529,8 @@ void DragObject (Point where)
|
||||
|
||||
if (objActive == kInitialGliderSelected)
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
(*thisHouse)->initial.h += deltaH;
|
||||
(*thisHouse)->initial.v += deltaV;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
else if (objActive == kLeftGliderSelected)
|
||||
{
|
||||
@@ -805,8 +802,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kDoorExLf)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kDoorExLf;
|
||||
@@ -818,7 +813,6 @@ void AddObjectPairing (void)
|
||||
testRoomPtr->objects[emptySlot].data.d.wide = 0;
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
@@ -839,8 +833,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kDoorExRt)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kDoorExRt;
|
||||
@@ -853,8 +845,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -874,8 +864,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kDoorInLfLeft)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kDoorInLf;
|
||||
@@ -888,8 +876,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -909,8 +895,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kDoorInRtLeft)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kDoorInRt;
|
||||
@@ -923,8 +907,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -944,8 +926,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kWindowExRt)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kWindowExRt;
|
||||
@@ -958,8 +938,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -979,8 +957,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kWindowExLf)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kWindowExLf;
|
||||
@@ -993,8 +969,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -1014,8 +988,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kWindowInLf)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kWindowInLf;
|
||||
@@ -1028,8 +1000,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -1049,8 +1019,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kWindowInRt)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kWindowInRt;
|
||||
@@ -1063,8 +1031,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -1084,8 +1050,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kDownStairs)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kDownStairs;
|
||||
@@ -1099,8 +1063,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -1120,8 +1082,6 @@ void AddObjectPairing (void)
|
||||
emptySlot = FindObjectSlotInRoom(roomNum);
|
||||
if ((emptySlot != -1) && (!DoesRoomNumHaveObject(roomNum, kUpStairs)))
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
testRoomPtr = &((*thisHouse)->rooms[roomNum]);
|
||||
|
||||
testRoomPtr->objects[emptySlot].what = kUpStairs;
|
||||
@@ -1135,8 +1095,6 @@ void AddObjectPairing (void)
|
||||
|
||||
testRoomPtr->numObjects++;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
GetLocalizedString(45, message);
|
||||
OpenMessageWindow(message);
|
||||
ForeColor(blueColor);
|
||||
@@ -1486,11 +1444,8 @@ void MoveObject (short whichWay, Boolean shiftDown)
|
||||
if (objActive == kInitialGliderSelected)
|
||||
{
|
||||
wasRect = initialGliderRect;
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
(*thisHouse)->initial.h += deltaH;
|
||||
(*thisHouse)->initial.v += deltaV;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
else if (objActive == kLeftGliderSelected)
|
||||
{
|
||||
@@ -2288,9 +2243,7 @@ void GetThisRoomsObjRects (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
HLock((Handle)thePict);
|
||||
roomObjectRects[i] = (*thePict)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePict);
|
||||
}
|
||||
ZeroRectCorner(&roomObjectRects[i]);
|
||||
QOffsetRect(&roomObjectRects[i],
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
|
||||
|
||||
extern Rect roomObjectRects[];
|
||||
|
||||
@@ -226,9 +226,7 @@ void GetObjectRect (objectPtr who, Rect *itsRect)
|
||||
}
|
||||
else
|
||||
{
|
||||
HLock((Handle)thePict);
|
||||
*itsRect = (*thePict)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePict);
|
||||
}
|
||||
ZeroRectCorner(itsRect);
|
||||
QOffsetRect(itsRect,
|
||||
@@ -1140,9 +1138,6 @@ short GetUpStairsRightEdge (void)
|
||||
|
||||
rightEdge = kRoomWide;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
for (i = 0; i < kMaxRoomObs; i++)
|
||||
{
|
||||
thisObject = (*thisHouse)->rooms[thisRoomNumber].objects[i];
|
||||
@@ -1153,8 +1148,6 @@ short GetUpStairsRightEdge (void)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (rightEdge);
|
||||
}
|
||||
|
||||
@@ -1168,9 +1161,6 @@ short GetDownStairsLeftEdge (void)
|
||||
|
||||
leftEdge = 0;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
for (i = 0; i < kMaxRoomObs; i++)
|
||||
{
|
||||
thisObject = (*thisHouse)->rooms[thisRoomNumber].objects[i];
|
||||
@@ -1181,8 +1171,6 @@ short GetDownStairsLeftEdge (void)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (leftEdge);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,6 @@ Boolean IsThisValid (short where, short who)
|
||||
|
||||
itsGood = true;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
switch ((*thisHouse)->rooms[where].objects[who].what)
|
||||
{
|
||||
case kObjectIsEmpty:
|
||||
@@ -116,7 +114,6 @@ Boolean IsThisValid (short where, short who)
|
||||
itsGood = (*thisHouse)->rooms[where].objects[who].data.c.state;
|
||||
break;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (itsGood);
|
||||
}
|
||||
@@ -261,8 +258,6 @@ void ListOneRoomsObjects (short where)
|
||||
if (roomNum == kRoomIsEmpty)
|
||||
return;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
for (n = 0; n < kMaxRoomObs; n++)
|
||||
{
|
||||
if (numMasterObjects < kMaxMasterObjects)
|
||||
@@ -292,7 +287,6 @@ void ListOneRoomsObjects (short where)
|
||||
numLocalMasterObjects++;
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ListAllLocalObjects
|
||||
@@ -306,9 +300,6 @@ void ListAllLocalObjects (void)
|
||||
numLocalMasterObjects = 0;
|
||||
nHotSpots = 0;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
ListOneRoomsObjects(kCentralRoom);
|
||||
|
||||
if (numNeighbors > 1)
|
||||
@@ -327,8 +318,6 @@ void ListAllLocalObjects (void)
|
||||
ListOneRoomsObjects(kNorthWestRoom);
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
for (i = 0; i < numMasterObjects; i++) // correlate links with<74>
|
||||
{ // index into this list
|
||||
if ((masterObjects[i].roomLink != -1) && // if object has a link
|
||||
@@ -368,8 +357,6 @@ Boolean SetObjectState (short room, short object, short action, short local)
|
||||
char wasState;
|
||||
Boolean changed;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
switch ((*thisHouse)->rooms[room].objects[object].what)
|
||||
{
|
||||
case kFloorVent:
|
||||
@@ -693,7 +680,6 @@ Boolean SetObjectState (short room, short object, short action, short local)
|
||||
break;
|
||||
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (changed);
|
||||
}
|
||||
@@ -707,8 +693,6 @@ Boolean GetObjectState (short room, short object)
|
||||
|
||||
theState = true;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
switch ((*thisHouse)->rooms[room].objects[object].what)
|
||||
{
|
||||
case kFloorVent:
|
||||
@@ -864,8 +848,6 @@ Boolean GetObjectState (short room, short object)
|
||||
case kChimes:
|
||||
break;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (theState);
|
||||
}
|
||||
@@ -909,8 +891,6 @@ void BringSendFrontBack (Boolean bringFront)
|
||||
GenerateLinksList(); // Fill in links list with src/dest<73>
|
||||
} // data on objects and room numbers.
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse); // Lock down house.
|
||||
thisHousePtr = *thisHouse; // Get a pointer to house structure.
|
||||
|
||||
for (i = 0; i < kMaxRoomObs; i++) // Set up an ordered array.
|
||||
@@ -980,7 +960,6 @@ void BringSendFrontBack (Boolean bringFront)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
if (linksList != nil)
|
||||
DisposePtr((Ptr)linksList);
|
||||
|
||||
|
||||
@@ -528,9 +528,7 @@ void PlayGame (void)
|
||||
thePicture = GetPicture(kScoreboardPictID);
|
||||
if (!thePicture)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
HLock((Handle)thePicture);
|
||||
bounds = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
@@ -579,9 +577,7 @@ void PlayGame (void)
|
||||
thePicture = GetPicture(kScoreboardPictID);
|
||||
if (!thePicture)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
HLock((Handle)thePicture);
|
||||
bounds = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
@@ -605,8 +601,6 @@ void SetObjectsToDefaults (void)
|
||||
char wasState;
|
||||
Boolean initState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
numRooms = thisHousePtr->nRooms;
|
||||
@@ -701,7 +695,6 @@ void SetObjectsToDefaults (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- HideGlider
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
|
||||
|
||||
void FrameWHRect (short, short, short, short);
|
||||
|
||||
@@ -182,9 +182,6 @@ Boolean CreateNewRoom (short h, short v)
|
||||
for (i = 0; i < kMaxRoomObs; i++) // zero out all objects
|
||||
thisRoom->objects[i].what = kObjectIsEmpty;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
MoveHHi((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
availableRoom = -1; // assume no available rooms
|
||||
if ((*thisHouse)->nRooms > 0) // look for an empty room
|
||||
for (i = 0; i < (*thisHouse)->nRooms; i++)
|
||||
@@ -196,18 +193,13 @@ Boolean CreateNewRoom (short h, short v)
|
||||
|
||||
if (availableRoom == -1) // found no available rooms
|
||||
{
|
||||
HUnlock((Handle)thisHouse);
|
||||
howMuch = sizeof(roomType); // add new room to end of house
|
||||
theErr = PtrAndHand((Ptr)thisRoom, (Handle)thisHouse, howMuch);
|
||||
if (theErr != noErr)
|
||||
{
|
||||
YellowAlert(kYellowUnaccounted, theErr);
|
||||
MoveHHi((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
return (false);
|
||||
}
|
||||
MoveHHi((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
(*thisHouse)->nRooms++; // increment nRooms
|
||||
numberRooms = (*thisHouse)->nRooms;
|
||||
previousRoom = thisRoomNumber;
|
||||
@@ -222,8 +214,6 @@ Boolean CreateNewRoom (short h, short v)
|
||||
if (noRoomAtAll)
|
||||
(*thisHouse)->firstRoom = thisRoomNumber;
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
CopyThisRoomToRoom();
|
||||
UpdateEditWindowTitle();
|
||||
noRoomAtAll = false;
|
||||
@@ -278,9 +268,7 @@ void ReadyBackground (short theID, short *theTiles)
|
||||
}
|
||||
}
|
||||
|
||||
HLock((Handle)thePicture);
|
||||
dest = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
QOffsetRect(&dest, -dest.left, -dest.top);
|
||||
DrawPicture(thePicture, &dest);
|
||||
ReleaseResource((Handle)thePicture);
|
||||
@@ -359,10 +347,7 @@ void CopyThisRoomToRoom (void)
|
||||
if ((noRoomAtAll) || (thisRoomNumber == -1))
|
||||
return;
|
||||
|
||||
tagByte = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse); // copy back to house
|
||||
(*thisHouse)->rooms[thisRoomNumber] = *thisRoom;
|
||||
HSetState((Handle)thisHouse, tagByte);
|
||||
(*thisHouse)->rooms[thisRoomNumber] = *thisRoom; // copy back to house
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- ForceThisRoom
|
||||
@@ -374,13 +359,10 @@ void ForceThisRoom (short roomNumber)
|
||||
if (roomNumber == -1)
|
||||
return;
|
||||
|
||||
tagByte = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
if (roomNumber < (*thisHouse)->nRooms)
|
||||
*thisRoom = (*thisHouse)->rooms[roomNumber];
|
||||
else
|
||||
YellowAlert(kYellowIllegalRoomNum, 0);
|
||||
HSetState((Handle)thisHouse, tagByte);
|
||||
|
||||
previousRoom = thisRoomNumber;
|
||||
thisRoomNumber = roomNumber;
|
||||
@@ -401,8 +383,6 @@ Boolean RoomExists (short suite, short floor, short *roomNum)
|
||||
if (suite < 0)
|
||||
return (foundIt);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
for (i = 0; i < numberRooms; i++)
|
||||
@@ -416,8 +396,6 @@ Boolean RoomExists (short suite, short floor, short *roomNum)
|
||||
}
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (foundIt);
|
||||
}
|
||||
|
||||
@@ -455,14 +433,11 @@ void DeleteRoom (Boolean doWarn)
|
||||
|
||||
DeselectObject();
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
wasFloor = (*thisHouse)->rooms[thisRoomNumber].floor;
|
||||
wasSuite = (*thisHouse)->rooms[thisRoomNumber].suite;
|
||||
firstDeleted = ((*thisHouse)->firstRoom == thisRoomNumber); // is room "first"
|
||||
thisRoom->suite = kRoomIsEmpty;
|
||||
(*thisHouse)->rooms[thisRoomNumber].suite = kRoomIsEmpty;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
noRoomAtAll = (RealRoomNumberCount() == 0); // see if now no rooms
|
||||
if (noRoomAtAll)
|
||||
@@ -472,10 +447,7 @@ void DeleteRoom (Boolean doWarn)
|
||||
|
||||
if (firstDeleted)
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
(*thisHouse)->firstRoom = thisRoomNumber;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
newRoomNow = false;
|
||||
@@ -616,8 +588,6 @@ short GetNeighborRoomNumber (short which)
|
||||
}
|
||||
|
||||
roomNum = kRoomIsEmpty;
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
roomH = (*thisHouse)->rooms[thisRoomNumber].suite + hDelta;
|
||||
roomV = (*thisHouse)->rooms[thisRoomNumber].floor + vDelta;
|
||||
|
||||
@@ -630,7 +600,6 @@ short GetNeighborRoomNumber (short which)
|
||||
break;
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (roomNum);
|
||||
}
|
||||
@@ -647,9 +616,6 @@ void SetToNearestNeighborRoom (short wasFloor, short wasSuite)
|
||||
char wasState;
|
||||
Boolean finished;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
|
||||
finished = false;
|
||||
distance = 1; // we begin our walk a distance of one from source room
|
||||
h = -1; // we begin with the neighbor to the left<66>
|
||||
@@ -703,8 +669,6 @@ void SetToNearestNeighborRoom (short wasFloor, short wasSuite)
|
||||
}
|
||||
}
|
||||
} while (!finished);
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- GetRoomFloorSuite
|
||||
@@ -714,8 +678,6 @@ Boolean GetRoomFloorSuite (short room, short *floor, short *suite)
|
||||
char wasState;
|
||||
Boolean isRoom;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
if ((*thisHouse)->rooms[room].suite == kRoomIsEmpty)
|
||||
{
|
||||
*floor = 0;
|
||||
@@ -728,7 +690,6 @@ Boolean GetRoomFloorSuite (short room, short *floor, short *suite)
|
||||
*floor = (*thisHouse)->rooms[room].floor;
|
||||
isRoom = true;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (isRoom);
|
||||
}
|
||||
@@ -743,8 +704,6 @@ short GetRoomNumber (short floor, short suite)
|
||||
|
||||
roomNum = kRoomIsEmpty;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
for (i = 0; i < numberRooms; i++)
|
||||
{
|
||||
if (((*thisHouse)->rooms[i].suite == suite) &&
|
||||
@@ -754,7 +713,6 @@ short GetRoomNumber (short floor, short suite)
|
||||
break;
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (roomNum);
|
||||
}
|
||||
@@ -769,8 +727,6 @@ Boolean IsRoomAStructure (short roomNum)
|
||||
if (roomNum == kRoomIsEmpty)
|
||||
return (false);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
if ((*thisHouse)->rooms[roomNum].background >= kUserBackground)
|
||||
{
|
||||
if ((*thisHouse)->rooms[roomNum].bounds != 0)
|
||||
@@ -807,7 +763,6 @@ Boolean IsRoomAStructure (short roomNum)
|
||||
break;
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
return (isStructure);
|
||||
}
|
||||
@@ -950,7 +905,6 @@ short GetOriginalBounding (short theID)
|
||||
else
|
||||
{
|
||||
boundCode = 0;
|
||||
HLock((Handle)boundsRes);
|
||||
if ((*boundsRes)->left)
|
||||
boundCode += 1;
|
||||
if ((*boundsRes)->top)
|
||||
@@ -959,7 +913,6 @@ short GetOriginalBounding (short theID)
|
||||
boundCode += 4;
|
||||
if ((*boundsRes)->bottom)
|
||||
boundCode += 8;
|
||||
HUnlock((Handle)boundsRes);
|
||||
ReleaseResource((Handle)boundsRes);
|
||||
}
|
||||
|
||||
@@ -1033,8 +986,6 @@ short GetNumberOfLights (short where)
|
||||
}
|
||||
else
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
switch (thisHousePtr->rooms[where].background)
|
||||
{
|
||||
@@ -1094,7 +1045,6 @@ short GetNumberOfLights (short where)
|
||||
}
|
||||
}
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
@@ -58,10 +58,7 @@ void DrawLocale (void)
|
||||
tvInRoom = false;
|
||||
tvWithMovieNumber = -1;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
roomV = (*thisHouse)->rooms[thisRoomNumber].floor;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
@@ -147,9 +144,7 @@ void LoadGraphicSpecial (short resID)
|
||||
}
|
||||
}
|
||||
|
||||
HLock((Handle)thePicture);
|
||||
bounds = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
@@ -167,12 +162,9 @@ void DrawRoomBackground (short who, short where, short elevation)
|
||||
|
||||
if (where == kCentralRoom)
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisBackground = (*thisHouse)->rooms[who].background;
|
||||
for (i = 0; i < kNumTiles; i++)
|
||||
thisTiles[i] = (*thisHouse)->rooms[who].tiles[i];
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
if ((numLights == 0) && (who != kRoomIsEmpty))
|
||||
@@ -226,12 +218,9 @@ void DrawRoomBackground (short who, short where, short elevation)
|
||||
}
|
||||
else
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
pictID = (*thisHouse)->rooms[who].background;
|
||||
for (i = 0; i < kNumTiles; i++)
|
||||
tiles[i] = (*thisHouse)->rooms[who].tiles[i];
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
|
||||
SetPort((GrafPtr)workSrcMap);
|
||||
@@ -436,10 +425,7 @@ void RedrawRoomLighting (void)
|
||||
char wasState;
|
||||
Boolean wasLit, isLit;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
roomV = (*thisHouse)->rooms[thisRoomNumber].floor;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
wasLit = numLights > 0;
|
||||
numLights = GetNumberOfLights(localNumbers[kCentralRoom]);
|
||||
|
||||
@@ -447,10 +447,7 @@ void DoRoomInfo (void)
|
||||
ShowWindow(GetDialogWindow(roomInfoDialog));
|
||||
DrawDefaultButton(roomInfoDialog);
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
wasFirstRoom = ((*thisHouse)->firstRoom == thisRoomNumber);
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
SetDialogItemValue(roomInfoDialog, kRoomFirstCheck, (short)wasFirstRoom);
|
||||
|
||||
if (tempBack >= kUserBackground)
|
||||
@@ -473,9 +470,7 @@ void DoRoomInfo (void)
|
||||
PasStringCopyNum(tempStr, thisRoom->name, 27);
|
||||
if (wasFirstRoom)
|
||||
{
|
||||
HLock((Handle)thisHouse);
|
||||
(*thisHouse)->firstRoom = thisRoomNumber;
|
||||
HUnlock((Handle)thisHouse);
|
||||
}
|
||||
thisRoom->background = tempBack;
|
||||
if (tempBack < kUserBackground)
|
||||
|
||||
@@ -311,8 +311,6 @@ void SaveGame (Boolean doSave)
|
||||
if (twoPlayerGame)
|
||||
return;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
if (doSave)
|
||||
@@ -343,8 +341,6 @@ void SaveGame (Boolean doSave)
|
||||
thisHousePtr->hasGame = false;
|
||||
}
|
||||
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
if (doSave)
|
||||
{
|
||||
if (!WriteHouse(theMode == kEditMode))
|
||||
|
||||
@@ -225,7 +225,6 @@ OSErr LoadTriggerSound (short soundID)
|
||||
{
|
||||
soundDataSize = GetHandleSize(theSound) - 20L;
|
||||
theSoundData[kMaxSounds - 1] = NewPtr(soundDataSize);
|
||||
HLock(theSound);
|
||||
if (theSoundData[kMaxSounds - 1] == nil)
|
||||
{
|
||||
ReleaseResource(theSound);
|
||||
@@ -268,15 +267,12 @@ OSErr LoadBufferSounds (void)
|
||||
if (theSound == nil)
|
||||
return (MemError());
|
||||
|
||||
HLock(theSound);
|
||||
soundDataSize = GetHandleSize(theSound) - 20L;
|
||||
HUnlock(theSound);
|
||||
|
||||
theSoundData[i] = NewPtr(soundDataSize);
|
||||
if (theSoundData[i] == nil)
|
||||
return (MemError());
|
||||
|
||||
HLock(theSound);
|
||||
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[i], soundDataSize);
|
||||
ReleaseResource(theSound);
|
||||
}
|
||||
|
||||
@@ -81,9 +81,7 @@ void InitScoreboardMap (void)
|
||||
thePicture = GetPicture(kScoreboardPictID);
|
||||
if (thePicture == nil)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
HLock((Handle)thePicture);
|
||||
bounds = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
QOffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
QOffsetRect(&bounds, hOffset, 0);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
@@ -31,12 +31,8 @@ extern Boolean playerDead, playerSuicide, tvOn;
|
||||
short WhatAreWeLinkedTo (short where, Byte who)
|
||||
{
|
||||
short what, whatType;
|
||||
char wasState;
|
||||
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
what = (*thisHouse)->rooms[where].objects[who].what;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
|
||||
switch (what)
|
||||
{
|
||||
@@ -430,15 +426,11 @@ void MoveMailToMail (gliderPtr thisGlider)
|
||||
void HandleRoomVisitation (void)
|
||||
{
|
||||
houseType *thisHousePtr;
|
||||
char wasState;
|
||||
|
||||
if (!thisRoom->visited)
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
thisHousePtr = *thisHouse;
|
||||
thisHousePtr->rooms[localNumbers[kCentralRoom]].visited = true;
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
theScore += kRoomVisitScore;
|
||||
thisRoom->visited = true;
|
||||
}
|
||||
|
||||
@@ -173,8 +173,6 @@ void FireTrigger (short index)
|
||||
}
|
||||
else
|
||||
{
|
||||
wasState = HGetState((Handle)thisHouse);
|
||||
HLock((Handle)thisHouse);
|
||||
triggeredIs = masterObjects[triggerIs].localLink;
|
||||
switch ((*thisHouse)->rooms[triggers[index].room].
|
||||
objects[triggers[index].object].what)
|
||||
@@ -189,7 +187,6 @@ void FireTrigger (short index)
|
||||
}
|
||||
break;
|
||||
}
|
||||
HSetState((Handle)thisHouse, wasState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//============================================================================
|
||||
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "PLResources.h"
|
||||
#include "PLSound.h"
|
||||
@@ -302,9 +302,7 @@ void LoadGraphic (short resID)
|
||||
if (thePicture == nil)
|
||||
RedAlert(kErrFailedGraphicLoad);
|
||||
|
||||
HLock((Handle)thePicture);
|
||||
bounds = (*thePicture)->picFrame.ToRect();
|
||||
HUnlock((Handle)thePicture);
|
||||
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
DrawPicture(thePicture, &bounds);
|
||||
|
||||
@@ -327,31 +325,6 @@ void LoadScaledGraphic (short resID, Rect *theRect)
|
||||
ReleaseResource((Handle)thePicture);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------- PlotSICN
|
||||
// Draws a small icon (16 x 16 pixels).
|
||||
/*
|
||||
void PlotSICN (Rect *theRect, SICNHand theSICN, long theIndex)
|
||||
{
|
||||
char state;
|
||||
BitMap srcBits;
|
||||
|
||||
if ((theSICN != nil) &&
|
||||
((GetHandleSize((Handle)theSICN) / sizeof(SICN)) > theIndex))
|
||||
{
|
||||
state = HGetState((Handle)theSICN);
|
||||
HLock((Handle)theSICN);
|
||||
|
||||
srcBits.baseAddr = (Ptr)(*theSICN)[theIndex];
|
||||
srcBits.rowBytes = 2;
|
||||
SetRect(&srcBits.bounds, 0, 0, 16, 16);
|
||||
|
||||
CopyBits(&srcBits,&(*qd.thePort).portBits,
|
||||
&srcBits.bounds, theRect, srcCopy, nil);
|
||||
|
||||
HSetState((Handle) theSICN, state);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//-------------------------------------------------------------- LargeIconPlot
|
||||
// Draws a standard b&w icon (32 x 32) - resource is an 'ICON'.
|
||||
|
||||
|
||||
@@ -15,10 +15,23 @@ GpSystemServices_Win32::GpSystemServices_Win32()
|
||||
|
||||
uint32_t GpSystemServices_Win32::GetTime() const
|
||||
{
|
||||
// PL_NotYetImplemented
|
||||
//PL_NotYetImplemented_TODO("Time");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GpSystemServices_Win32::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const
|
||||
{
|
||||
SYSTEMTIME localTime;
|
||||
GetLocalTime(&localTime);
|
||||
|
||||
year = localTime.wYear;
|
||||
month = localTime.wMonth;
|
||||
day = localTime.wDay;
|
||||
hour = localTime.wHour;
|
||||
minute = localTime.wMinute;
|
||||
second = localTime.wSecond;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostMutex *GpSystemServices_Win32::CreateMutex()
|
||||
{
|
||||
return GpMutex_Win32::Create();
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
GpSystemServices_Win32();
|
||||
|
||||
uint32_t GetTime() const override;
|
||||
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
|
||||
PortabilityLayer::HostMutex *CreateMutex() override;
|
||||
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "DisplayDeviceManager.h"
|
||||
|
||||
#include "HostDisplayDriver.h"
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "QDStandardPalette.h"
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
public:
|
||||
virtual uint32_t GetTime() const = 0;
|
||||
virtual void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const = 0;
|
||||
virtual HostMutex *CreateMutex() = 0;
|
||||
virtual HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0;
|
||||
|
||||
|
||||
14
PortabilityLayer/IPlotter.h
Normal file
14
PortabilityLayer/IPlotter.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "PlotDirection.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
struct Vec2i;
|
||||
|
||||
struct IPlotter
|
||||
{
|
||||
virtual PlotDirection PlotNext() = 0;
|
||||
virtual const Vec2i &GetPoint() const = 0;
|
||||
};
|
||||
}
|
||||
101
PortabilityLayer/LinePlotter.cpp
Normal file
101
PortabilityLayer/LinePlotter.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include "LinePlotter.h"
|
||||
#include "Vec2i.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
LinePlotter::LinePlotter()
|
||||
: m_point(0, 0)
|
||||
, m_endPoint(0, 0)
|
||||
, m_dx(0)
|
||||
, m_dy(0)
|
||||
, m_err(0)
|
||||
, m_xIncrPos(true)
|
||||
, m_yIncrPos(true)
|
||||
, m_xMove(PlotDirection_Exhausted)
|
||||
, m_yMove(PlotDirection_Exhausted)
|
||||
, m_xyMove(PlotDirection_Exhausted)
|
||||
{
|
||||
}
|
||||
|
||||
PlotDirection LinePlotter::PlotNext()
|
||||
{
|
||||
if (m_point == m_endPoint)
|
||||
return PlotDirection_Exhausted;
|
||||
|
||||
bool movedX = false;
|
||||
const int32_t err2 = 2 * m_err;
|
||||
if (err2 >= m_dy)
|
||||
{
|
||||
m_err += m_dy;
|
||||
m_point.m_x += m_xIncrPos ? 1 : -1;
|
||||
movedX = true;
|
||||
}
|
||||
|
||||
if (err2 <= m_dx)
|
||||
{
|
||||
m_err += m_dx;
|
||||
m_point.m_y += m_yIncrPos ? 1 : -1;
|
||||
|
||||
if (movedX)
|
||||
return m_xyMove;
|
||||
else
|
||||
return m_yMove;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(movedX);
|
||||
return m_xMove;
|
||||
}
|
||||
}
|
||||
|
||||
const Vec2i &LinePlotter::GetPoint() const
|
||||
{
|
||||
return m_point;
|
||||
}
|
||||
|
||||
void LinePlotter::Reset(const Vec2i &pointA, const Vec2i &pointB)
|
||||
{
|
||||
m_dx = pointB.m_x - pointA.m_x;
|
||||
if (m_dx < 0)
|
||||
m_dx = -m_dx;
|
||||
|
||||
m_dy = pointB.m_y - pointA.m_y;
|
||||
if (m_dy > 0)
|
||||
m_dy = -m_dy;
|
||||
|
||||
m_xIncrPos = (pointA.m_x < pointB.m_x);
|
||||
m_yIncrPos = (pointA.m_y < pointB.m_y);
|
||||
|
||||
m_err = m_dx + m_dy;
|
||||
|
||||
m_point = pointA;
|
||||
m_endPoint = pointB;
|
||||
|
||||
if (m_xIncrPos)
|
||||
{
|
||||
if (m_yIncrPos)
|
||||
m_xyMove = PlotDirection_PosX_PosY;
|
||||
else
|
||||
m_xyMove = PlotDirection_PosX_NegY;
|
||||
|
||||
m_xMove = PlotDirection_PosX_0Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_yIncrPos)
|
||||
m_xyMove = PlotDirection_NegX_PosY;
|
||||
else
|
||||
m_xyMove = PlotDirection_NegX_NegY;
|
||||
|
||||
m_xMove = PlotDirection_NegX_0Y;
|
||||
}
|
||||
|
||||
|
||||
if (m_yIncrPos)
|
||||
m_yMove = PlotDirection_0X_PosY;
|
||||
else
|
||||
m_yMove = PlotDirection_0X_NegY;
|
||||
}
|
||||
}
|
||||
30
PortabilityLayer/LinePlotter.h
Normal file
30
PortabilityLayer/LinePlotter.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "PlotDirection.h"
|
||||
#include "Vec2i.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class LinePlotter
|
||||
{
|
||||
public:
|
||||
LinePlotter();
|
||||
PlotDirection PlotNext();
|
||||
const Vec2i &GetPoint() const;
|
||||
|
||||
void Reset(const Vec2i &pointA, const Vec2i &pointB);
|
||||
|
||||
private:
|
||||
Vec2i m_point;
|
||||
Vec2i m_endPoint;
|
||||
int32_t m_dx;
|
||||
int32_t m_dy;
|
||||
int32_t m_err;
|
||||
bool m_xIncrPos;
|
||||
bool m_yIncrPos;
|
||||
|
||||
PlotDirection m_xyMove;
|
||||
PlotDirection m_xMove;
|
||||
PlotDirection m_yMove;
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "PLApplication.h"
|
||||
#include "PLPasStr.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
|
||||
#include "AEManager.h"
|
||||
#include "DisplayDeviceManager.h"
|
||||
@@ -901,10 +901,17 @@ void GetDateTime(UInt32 *dateTime)
|
||||
|
||||
void GetTime(DateTimeRec *dateTime)
|
||||
{
|
||||
PL_NotYetImplemented_TODO("DateTime");
|
||||
dateTime->month = 1;
|
||||
dateTime->hour = 0;
|
||||
dateTime->minute = 0;
|
||||
unsigned int year;
|
||||
unsigned int month;
|
||||
unsigned int day;
|
||||
unsigned int hour;
|
||||
unsigned int minute;
|
||||
unsigned int second;
|
||||
PortabilityLayer::HostSystemServices::GetInstance()->GetLocalDateTime(year, month, day, hour, minute, second);
|
||||
|
||||
dateTime->month = month;
|
||||
dateTime->hour = hour;
|
||||
dateTime->minute = minute;
|
||||
}
|
||||
|
||||
UInt32 GetDblTime()
|
||||
@@ -955,22 +962,6 @@ long GetHandleSize(Handle handle)
|
||||
return static_cast<long>(block->m_size);
|
||||
}
|
||||
|
||||
void HNoPurge(Handle hdl)
|
||||
{
|
||||
}
|
||||
|
||||
void MoveHHi(Handle hdl)
|
||||
{
|
||||
}
|
||||
|
||||
void HLock(Handle hdl)
|
||||
{
|
||||
}
|
||||
|
||||
void HUnlock(Handle hdl)
|
||||
{
|
||||
}
|
||||
|
||||
OSErr PtrAndHand(const void *data, Handle handle, Size size)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
|
||||
@@ -369,11 +369,6 @@ Handle NewHandle(Size size);
|
||||
void DisposeHandle(Handle handle);
|
||||
long GetHandleSize(Handle handle);
|
||||
|
||||
void HNoPurge(Handle hdl); // Marks a handle as not purgeable
|
||||
void MoveHHi(Handle hdl); // Relocates a block to the top of the heap
|
||||
void HLock(Handle hdl); // Disable relocation
|
||||
void HUnlock(Handle hdl); // Re-enable relocation
|
||||
|
||||
OSErr PtrAndHand(const void *data, Handle handle, Size size); // Appends data to the end of a handle
|
||||
void SetHandleSize(Handle hdl, Size newSize);
|
||||
|
||||
@@ -384,9 +379,6 @@ void DisposePtr(void *ptr);
|
||||
Size MaxMem(Size *growBytes);
|
||||
void PurgeSpace(long *totalFree, long *contiguousFree);
|
||||
|
||||
void HSetState(Handle handle, char state);
|
||||
char HGetState(Handle handle);
|
||||
|
||||
OSErr MemError();
|
||||
|
||||
void BlockMove(const void *src, void *dest, Size size);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#define __PL_QDOFFSCREEN_H__
|
||||
|
||||
#include "PLCore.h"
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
|
||||
struct ColorTable
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "QDManager.h"
|
||||
#include "QDState.h"
|
||||
#include "DisplayDeviceManager.h"
|
||||
20
PortabilityLayer/PlotDirection.h
Normal file
20
PortabilityLayer/PlotDirection.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
enum PlotDirection
|
||||
{
|
||||
PlotDirection_NegX_NegY,
|
||||
PlotDirection_0X_NegY,
|
||||
PlotDirection_PosX_NegY,
|
||||
|
||||
PlotDirection_NegX_PosY,
|
||||
PlotDirection_0X_PosY,
|
||||
PlotDirection_PosX_PosY,
|
||||
|
||||
PlotDirection_NegX_0Y,
|
||||
PlotDirection_PosX_0Y,
|
||||
|
||||
PlotDirection_Exhausted,
|
||||
};
|
||||
}
|
||||
@@ -163,6 +163,8 @@
|
||||
<ClInclude Include="HostVOSEventQueue.h" />
|
||||
<ClInclude Include="InputManager.h" />
|
||||
<ClInclude Include="IOStream.h" />
|
||||
<ClInclude Include="IPlotter.h" />
|
||||
<ClInclude Include="LinePlotter.h" />
|
||||
<ClInclude Include="MacBinary2.h" />
|
||||
<ClInclude Include="MacFileMem.h" />
|
||||
<ClInclude Include="MacFileInfo.h" />
|
||||
@@ -194,6 +196,9 @@
|
||||
<ClInclude Include="PLLowMem.h" />
|
||||
<ClInclude Include="PLMacTypes.h" />
|
||||
<ClInclude Include="MenuManager.h" />
|
||||
<ClInclude Include="PlotDirection.h" />
|
||||
<ClInclude Include="ScanlineMaskBuilder.h" />
|
||||
<ClInclude Include="ScanlineMaskConverter.h" />
|
||||
<ClInclude Include="QDGraf.h" />
|
||||
<ClInclude Include="QDManager.h" />
|
||||
<ClInclude Include="QDPictEmitContext.h" />
|
||||
@@ -221,7 +226,7 @@
|
||||
<ClInclude Include="PLPasStr.h" />
|
||||
<ClInclude Include="PLQDOffscreen.h" />
|
||||
<ClInclude Include="PLMovies.h" />
|
||||
<ClInclude Include="PLQuickdraw.h" />
|
||||
<ClInclude Include="PLQDraw.h" />
|
||||
<ClInclude Include="ResourceManager.h" />
|
||||
<ClInclude Include="PLResources.h" />
|
||||
<ClInclude Include="PLScript.h" />
|
||||
@@ -265,6 +270,7 @@
|
||||
<ClCompile Include="HostSystemServices.cpp" />
|
||||
<ClCompile Include="HostVOSEventQueue.cpp" />
|
||||
<ClCompile Include="InputManager.cpp" />
|
||||
<ClCompile Include="LinePlotter.cpp" />
|
||||
<ClCompile Include="MacBinary2.cpp" />
|
||||
<ClCompile Include="MacFileInfo.cpp" />
|
||||
<ClCompile Include="MacFileMem.cpp" />
|
||||
@@ -286,11 +292,14 @@
|
||||
<ClCompile Include="PLNavigation.cpp" />
|
||||
<ClCompile Include="PLNumberFormatting.cpp" />
|
||||
<ClCompile Include="PLQDOffscreen.cpp" />
|
||||
<ClCompile Include="PLQuickdraw.cpp" />
|
||||
<ClCompile Include="PLQDraw.cpp" />
|
||||
<ClCompile Include="PLResourceManager.cpp" />
|
||||
<ClCompile Include="PLResources.cpp" />
|
||||
<ClCompile Include="PLSound.cpp" />
|
||||
<ClCompile Include="PLStringCompare.cpp" />
|
||||
<ClCompile Include="ScanlineMask.cpp" />
|
||||
<ClCompile Include="ScanlineMaskBuilder.cpp" />
|
||||
<ClCompile Include="ScanlineMaskConverter.cpp" />
|
||||
<ClCompile Include="QDGraf.cpp" />
|
||||
<ClCompile Include="QDManager.cpp" />
|
||||
<ClCompile Include="QDPictDecoder.cpp" />
|
||||
|
||||
@@ -90,9 +90,6 @@
|
||||
<ClInclude Include="PLMovies.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PLQuickdraw.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PLMacTypes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -369,6 +366,24 @@
|
||||
<ClInclude Include="..\GpCommon\GpBitfield.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LinePlotter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PlotDirection.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PLQDraw.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ScanlineMaskConverter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IPlotter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ScanlineMaskBuilder.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CFileStream.cpp">
|
||||
@@ -398,9 +413,6 @@
|
||||
<ClCompile Include="PLResources.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PLQuickdraw.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PLSound.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -554,5 +566,20 @@
|
||||
<ClCompile Include="..\stb\stb_image_write.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ScanlineMaskConverter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PLQDraw.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LinePlotter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ScanlineMaskBuilder.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ScanlineMask.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "PLBigEndian.h"
|
||||
#include "PLQuickdraw.h"
|
||||
#include "PLQDraw.h"
|
||||
#include "GpPixelFormat.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "QDState.h"
|
||||
|
||||
#include "PLQuickdraw.h"
|
||||
#include "QDStandardPalette.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
#include "PLQDraw.h"
|
||||
#include "QDStandardPalette.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
QDState::QDState()
|
||||
: m_fontID(applFont)
|
||||
, m_textSize(12)
|
||||
@@ -19,10 +19,10 @@ namespace PortabilityLayer
|
||||
, m_isBackResolved8(false)
|
||||
, m_clipRegion(nullptr)
|
||||
{
|
||||
m_backUnresolvedColor.r = m_backUnresolvedColor.g = m_backUnresolvedColor.b = m_backUnresolvedColor.a = 255;
|
||||
m_backUnresolvedColor.r = m_backUnresolvedColor.g = m_backUnresolvedColor.b = m_backUnresolvedColor.a = 255;
|
||||
m_foreUnresolvedColor.r = m_foreUnresolvedColor.g = m_foreUnresolvedColor.b = 0;
|
||||
m_foreUnresolvedColor.a = 255;
|
||||
m_penPos.h = m_penPos.v = 0;
|
||||
m_penPos.h = m_penPos.v = 0;
|
||||
}
|
||||
|
||||
void QDState::SetForeColor(const RGBAColor &color)
|
||||
@@ -77,6 +77,6 @@ namespace PortabilityLayer
|
||||
cached = resolvedColor;
|
||||
|
||||
return resolvedColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
PortabilityLayer/ScanlineMask.cpp
Normal file
80
PortabilityLayer/ScanlineMask.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "CoreDefs.h"
|
||||
#include "ScanlineMask.h"
|
||||
#include "ScanlineMaskBuilder.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
void ScanlineMask::Destroy()
|
||||
{
|
||||
this->~ScanlineMask();
|
||||
free(this);
|
||||
}
|
||||
|
||||
ScanlineMask *ScanlineMask::Create(const ScanlineMaskBuilder &builder)
|
||||
{
|
||||
size_t alignedPrefixSize = sizeof(ScanlineMask) + PL_SYSTEM_MEMORY_ALIGNMENT - 1;
|
||||
alignedPrefixSize -= alignedPrefixSize % PL_SYSTEM_MEMORY_ALIGNMENT;
|
||||
|
||||
const size_t longestSpan = builder.GetLongestSpan();
|
||||
const size_t numSpans = builder.GetNumSpans();
|
||||
const size_t *spans = builder.GetSpans();
|
||||
|
||||
size_t storageSize = numSpans;
|
||||
DataStorage dataStorage = DataStorage_UInt8;
|
||||
if (longestSpan <= 0xff)
|
||||
dataStorage = DataStorage_UInt8;
|
||||
else if (longestSpan <= 0xffff)
|
||||
{
|
||||
storageSize *= 2;
|
||||
dataStorage = DataStorage_UInt16;
|
||||
}
|
||||
else if (longestSpan <= 0xffffffff)
|
||||
{
|
||||
storageSize *= 4;
|
||||
dataStorage = DataStorage_UInt32;
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
void *storage = malloc(alignedPrefixSize + storageSize);
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
void *spanStorage = static_cast<uint8_t*>(storage) + alignedPrefixSize;
|
||||
|
||||
ScanlineMask *mask = new (storage) ScanlineMask(dataStorage, spanStorage, numSpans);
|
||||
|
||||
for (size_t i = 0; i < numSpans; i++)
|
||||
{
|
||||
switch (dataStorage)
|
||||
{
|
||||
case DataStorage_UInt8:
|
||||
static_cast<uint8_t*>(spanStorage)[i] = static_cast<uint8_t>(spans[i]);
|
||||
break;
|
||||
case DataStorage_UInt16:
|
||||
static_cast<uint16_t*>(spanStorage)[i] = static_cast<uint16_t>(spans[i]);
|
||||
break;
|
||||
case DataStorage_UInt32:
|
||||
static_cast<uint32_t*>(spanStorage)[i] = static_cast<uint32_t>(spans[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
ScanlineMask::ScanlineMask(DataStorage dataStorage, const void *data, size_t numSpans)
|
||||
: m_dataStorage(dataStorage)
|
||||
, m_data(data)
|
||||
, m_numSpans(numSpans)
|
||||
{
|
||||
}
|
||||
|
||||
ScanlineMask::~ScanlineMask()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
31
PortabilityLayer/ScanlineMask.h
Normal file
31
PortabilityLayer/ScanlineMask.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class ScanlineMaskBuilder;
|
||||
|
||||
class ScanlineMask
|
||||
{
|
||||
public:
|
||||
void Destroy();
|
||||
|
||||
static ScanlineMask *Create(const ScanlineMaskBuilder &builder);
|
||||
|
||||
private:
|
||||
enum DataStorage
|
||||
{
|
||||
DataStorage_UInt8,
|
||||
DataStorage_UInt16,
|
||||
DataStorage_UInt32,
|
||||
};
|
||||
|
||||
explicit ScanlineMask(DataStorage dataStorage, const void *data, size_t numSpans);
|
||||
~ScanlineMask();
|
||||
|
||||
const DataStorage m_dataStorage;
|
||||
const void *m_data;
|
||||
const size_t m_numSpans;
|
||||
};
|
||||
}
|
||||
66
PortabilityLayer/ScanlineMaskBuilder.cpp
Normal file
66
PortabilityLayer/ScanlineMaskBuilder.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "ScanlineMaskBuilder.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
ScanlineMaskBuilder::ScanlineMaskBuilder()
|
||||
: m_spans(nullptr)
|
||||
, m_numSpans(0)
|
||||
, m_capacity(0)
|
||||
, m_longestSpan(0)
|
||||
{
|
||||
}
|
||||
|
||||
ScanlineMaskBuilder::~ScanlineMaskBuilder()
|
||||
{
|
||||
if (m_spans)
|
||||
realloc(m_spans, 0);
|
||||
}
|
||||
|
||||
bool ScanlineMaskBuilder::AppendSpan(size_t span)
|
||||
{
|
||||
if (span > m_longestSpan)
|
||||
m_longestSpan = span;
|
||||
|
||||
if (m_capacity == 0)
|
||||
{
|
||||
m_capacity = 8;
|
||||
m_spans = static_cast<size_t*>(realloc(nullptr, sizeof(size_t) * m_capacity));
|
||||
if (!m_spans)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_numSpans == m_capacity)
|
||||
{
|
||||
if (m_capacity >= (SIZE_MAX / sizeof(size_t) / 2))
|
||||
return false;
|
||||
|
||||
m_capacity *= 2;
|
||||
void *newSpans = realloc(m_spans, sizeof(size_t) * m_capacity);
|
||||
if (!newSpans)
|
||||
return false;
|
||||
|
||||
m_spans = static_cast<size_t*>(newSpans);
|
||||
}
|
||||
|
||||
m_spans[m_numSpans++] = span;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t ScanlineMaskBuilder::GetLongestSpan() const
|
||||
{
|
||||
return m_longestSpan;
|
||||
}
|
||||
|
||||
const size_t *ScanlineMaskBuilder::GetSpans() const
|
||||
{
|
||||
return m_spans;
|
||||
}
|
||||
|
||||
size_t ScanlineMaskBuilder::GetNumSpans() const
|
||||
{
|
||||
return m_numSpans;
|
||||
}
|
||||
}
|
||||
25
PortabilityLayer/ScanlineMaskBuilder.h
Normal file
25
PortabilityLayer/ScanlineMaskBuilder.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class ScanlineMaskBuilder
|
||||
{
|
||||
public:
|
||||
ScanlineMaskBuilder();
|
||||
~ScanlineMaskBuilder();
|
||||
|
||||
bool AppendSpan(size_t span);
|
||||
|
||||
size_t GetLongestSpan() const;
|
||||
const size_t *GetSpans() const;
|
||||
size_t GetNumSpans() const;
|
||||
|
||||
private:
|
||||
size_t *m_spans;
|
||||
size_t m_numSpans;
|
||||
size_t m_capacity;
|
||||
size_t m_longestSpan;
|
||||
};
|
||||
}
|
||||
318
PortabilityLayer/ScanlineMaskConverter.cpp
Normal file
318
PortabilityLayer/ScanlineMaskConverter.cpp
Normal file
@@ -0,0 +1,318 @@
|
||||
#include "ScanlineMaskConverter.h"
|
||||
#include "ScanlineMask.h"
|
||||
#include "Vec2i.h"
|
||||
#include "LinePlotter.h"
|
||||
#include "ScanlineMaskBuilder.h"
|
||||
#include "IPlotter.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
#define PL_SCANLINE_MASKS_DEBUGGING 1
|
||||
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
#include "stb_image_write.h"
|
||||
#endif
|
||||
|
||||
// The algorithm that we're trying to emulate consistently paints on covered pixels of a line as in-bounds,
|
||||
// while also identifying which pixels are part of the poly interior.
|
||||
//
|
||||
// We use a plotting algorithm to generate an outline with some rules:
|
||||
// - If a plot moves vertically in the same direction as the previous vertical movement, then the inversion bit for the pixel is flipped.
|
||||
// - A scanline is then run across the row, toggling state between inversion points, and filling any that contain a plot point.
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
enum PlotterVertical
|
||||
{
|
||||
PlotterVertical_NegY,
|
||||
PlotterVertical_PosY,
|
||||
|
||||
PlotterVertical_None,
|
||||
};
|
||||
|
||||
static void FillPresenceFlag(uint8_t *bitfield, size_t element)
|
||||
{
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
bitfield[element * 4] = 255;
|
||||
#else
|
||||
bitfield[element / 4] |= 1 << ((element & 3) * 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool ReadPresenceFlag(const uint8_t *bitfield, size_t element)
|
||||
{
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
return bitfield[element * 4] == 255;;
|
||||
#else
|
||||
return (bitfield[element / 4] & (1 << ((element & 3) * 2))) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void FlipBorderFlag(uint8_t *bitfield, size_t element)
|
||||
{
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
bitfield[element * 4 + 1] ^= 255;
|
||||
#else
|
||||
bitfield[element / 4] ^= 2 << ((element & 3) * 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool ReadBorderFlag(const uint8_t *bitfield, size_t element)
|
||||
{
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
return bitfield[element * 4 + 1] == 255;
|
||||
#else
|
||||
return (bitfield[element / 4] & (2 << ((element & 3) * 2))) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static PlotterVertical VerticalForPlotDir(PlotDirection plotDir)
|
||||
{
|
||||
switch (plotDir)
|
||||
{
|
||||
case PlotDirection_NegX_NegY:
|
||||
case PlotDirection_0X_NegY:
|
||||
case PlotDirection_PosX_NegY:
|
||||
return PlotterVertical_NegY;
|
||||
case PlotDirection_NegX_PosY:
|
||||
case PlotDirection_0X_PosY:
|
||||
case PlotDirection_PosX_PosY:
|
||||
return PlotterVertical_PosY;
|
||||
default:
|
||||
return PlotterVertical_None;
|
||||
}
|
||||
}
|
||||
|
||||
static bool FlushScanline(const uint8_t *flagBits, size_t firstElement, size_t width, ScanlineMaskBuilder &maskBuilder)
|
||||
{
|
||||
size_t spanStart = 0;
|
||||
bool isBorderToggleActive = false;
|
||||
bool maskSpanState = false;
|
||||
|
||||
for (size_t col = 0; col < width; col++)
|
||||
{
|
||||
const size_t element = firstElement + col;
|
||||
|
||||
const bool presenceFlag = ReadPresenceFlag(flagBits, element);
|
||||
const bool borderFlag = ReadBorderFlag(flagBits, element);
|
||||
|
||||
if (borderFlag)
|
||||
isBorderToggleActive = !isBorderToggleActive;
|
||||
|
||||
const bool elementState = (isBorderToggleActive || presenceFlag);
|
||||
|
||||
if (elementState != maskSpanState)
|
||||
{
|
||||
if (!maskBuilder.AppendSpan(col - spanStart))
|
||||
return false;
|
||||
|
||||
spanStart = col;
|
||||
maskSpanState = elementState;
|
||||
}
|
||||
}
|
||||
|
||||
if (!maskBuilder.AppendSpan(width - spanStart))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ScanlineMask *ComputePlot(uint32_t width, uint32_t height, const Vec2i &minPoint, IPlotter &plotter)
|
||||
{
|
||||
assert(width > 0 && height > 0);
|
||||
|
||||
if (static_cast<uint64_t>(width) * static_cast<uint64_t>(height) > SIZE_MAX)
|
||||
return nullptr;
|
||||
|
||||
const size_t numElements = width * height;
|
||||
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
const size_t storageSize = numElements * 4;
|
||||
#else
|
||||
const size_t storageSize = (numElements * 2 + 7) / 8;
|
||||
#endif
|
||||
void *storage = malloc(storageSize);
|
||||
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
uint8_t *flagBits = static_cast<uint8_t*>(storage);
|
||||
memset(flagBits, 0, storageSize);
|
||||
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
{
|
||||
for (size_t i = 0; i < storageSize; i += 4)
|
||||
flagBits[i + 3] = 255;
|
||||
}
|
||||
#endif
|
||||
|
||||
const Vec2i initialPoint = plotter.GetPoint() - minPoint;
|
||||
|
||||
bool haveFirstVertical = false;
|
||||
size_t firstVerticalElement = 0; // First element that contains a vertical movement on the first row
|
||||
PlotterVertical firstVertical = PlotterVertical::PlotterVertical_None;
|
||||
PlotterVertical lastVertical = PlotterVertical::PlotterVertical_None;
|
||||
|
||||
size_t currentElement = static_cast<uint32_t>(initialPoint.m_y) * width + static_cast<uint32_t>(initialPoint.m_x);
|
||||
FillPresenceFlag(flagBits, currentElement);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const size_t prevElement = currentElement;
|
||||
|
||||
const PlotDirection plotDir = plotter.PlotNext();
|
||||
if (plotDir == PlotDirection_Exhausted)
|
||||
break;
|
||||
|
||||
switch (plotDir)
|
||||
{
|
||||
case PlotDirection_NegX_NegY:
|
||||
currentElement = currentElement - 1 - width;
|
||||
break;
|
||||
case PlotDirection_0X_NegY:
|
||||
currentElement = currentElement - width;
|
||||
break;
|
||||
case PlotDirection_PosX_NegY:
|
||||
currentElement = currentElement + 1 - width;
|
||||
break;
|
||||
|
||||
case PlotDirection_NegX_PosY:
|
||||
currentElement = currentElement + width - 1;
|
||||
break;
|
||||
case PlotDirection_0X_PosY:
|
||||
currentElement = currentElement + width;
|
||||
break;
|
||||
case PlotDirection_PosX_PosY:
|
||||
currentElement = currentElement + width + 1;
|
||||
break;
|
||||
|
||||
case PlotDirection_NegX_0Y:
|
||||
currentElement = currentElement - 1;
|
||||
break;
|
||||
case PlotDirection_PosX_0Y:
|
||||
currentElement = currentElement + 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
FillPresenceFlag(flagBits, currentElement);
|
||||
|
||||
#if PL_SCANLINE_MASKS_DEBUGGING
|
||||
const Vec2i expectedPoint = plotter.GetPoint() - minPoint;
|
||||
const int64_t expectedElement = static_cast<uint32_t>(expectedPoint.m_y) * width + expectedPoint.m_x;
|
||||
assert(currentElement == expectedElement);
|
||||
#endif
|
||||
assert(currentElement < numElements);
|
||||
|
||||
const PlotterVertical verticalForPlotDir = VerticalForPlotDir(plotDir);
|
||||
if (verticalForPlotDir != PlotterVertical_None)
|
||||
{
|
||||
if (!haveFirstVertical)
|
||||
{
|
||||
haveFirstVertical = true;
|
||||
firstVerticalElement = prevElement;
|
||||
firstVertical = verticalForPlotDir;
|
||||
}
|
||||
|
||||
if (verticalForPlotDir == lastVertical)
|
||||
FlipBorderFlag(flagBits, prevElement);
|
||||
|
||||
lastVertical = verticalForPlotDir;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastVertical == firstVertical)
|
||||
FlipBorderFlag(flagBits, firstVerticalElement);
|
||||
|
||||
assert(plotter.GetPoint() - minPoint == initialPoint);
|
||||
|
||||
ScanlineMaskBuilder maskBuilder;
|
||||
|
||||
bool failed = false;
|
||||
for (size_t rowFirstElement = 0; rowFirstElement < numElements; rowFirstElement += width)
|
||||
{
|
||||
if (!FlushScanline(flagBits, rowFirstElement, width, maskBuilder))
|
||||
{
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(storage);
|
||||
|
||||
return ScanlineMask::Create(maskBuilder);
|
||||
}
|
||||
|
||||
class PolyPlotter final : public IPlotter
|
||||
{
|
||||
public:
|
||||
PolyPlotter(const Vec2i *points, size_t numPoints);
|
||||
|
||||
PlotDirection PlotNext() override;
|
||||
const Vec2i &GetPoint() const override;
|
||||
|
||||
private:
|
||||
LinePlotter m_linePlotter;
|
||||
const Vec2i *m_points;
|
||||
size_t m_currentTargetPoint;
|
||||
size_t m_numPoints;
|
||||
};
|
||||
|
||||
PolyPlotter::PolyPlotter(const Vec2i *points, size_t numPoints)
|
||||
: m_points(points)
|
||||
, m_currentTargetPoint(0)
|
||||
, m_numPoints(numPoints)
|
||||
{
|
||||
m_linePlotter.Reset(points[numPoints - 1], points[0]);
|
||||
}
|
||||
|
||||
PlotDirection PolyPlotter::PlotNext()
|
||||
{
|
||||
if (m_currentTargetPoint == m_numPoints)
|
||||
return PlotDirection_Exhausted;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const PlotDirection plotDir = m_linePlotter.PlotNext();
|
||||
if (plotDir == PlotDirection_Exhausted)
|
||||
{
|
||||
m_currentTargetPoint++;
|
||||
if (m_currentTargetPoint == m_numPoints)
|
||||
return PlotDirection_Exhausted;
|
||||
|
||||
m_linePlotter.Reset(m_points[m_currentTargetPoint - 1], m_points[m_currentTargetPoint]);
|
||||
}
|
||||
else
|
||||
return plotDir;
|
||||
}
|
||||
}
|
||||
|
||||
const Vec2i &PolyPlotter::GetPoint() const
|
||||
{
|
||||
return m_linePlotter.GetPoint();
|
||||
}
|
||||
|
||||
ScanlineMask *ScanlineMaskConverter::CompilePoly(const Vec2i *points, size_t numPoints)
|
||||
{
|
||||
assert(numPoints > 0);
|
||||
|
||||
Vec2i minPoint = points[0];
|
||||
Vec2i maxPoint = points[0];
|
||||
|
||||
for (size_t i = 1; i < numPoints; i++)
|
||||
{
|
||||
minPoint.m_x = std::min<int32_t>(minPoint.m_x, points[i].m_x);
|
||||
minPoint.m_y = std::min<int32_t>(minPoint.m_y, points[i].m_y);
|
||||
maxPoint.m_x = std::max<int32_t>(maxPoint.m_x, points[i].m_x);
|
||||
maxPoint.m_y = std::max<int32_t>(maxPoint.m_y, points[i].m_y);
|
||||
}
|
||||
|
||||
const uint32_t width = static_cast<uint32_t>(maxPoint.m_x - minPoint.m_x) + 1;
|
||||
const uint32_t height = static_cast<uint32_t>(maxPoint.m_y - minPoint.m_y) + 1;
|
||||
|
||||
PolyPlotter polyPlotter(points, numPoints);
|
||||
return ComputePlot(width, height, minPoint, polyPlotter);
|
||||
}
|
||||
}
|
||||
15
PortabilityLayer/ScanlineMaskConverter.h
Normal file
15
PortabilityLayer/ScanlineMaskConverter.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class ScanlineMask;
|
||||
struct Vec2i;
|
||||
|
||||
class ScanlineMaskConverter
|
||||
{
|
||||
public:
|
||||
static ScanlineMask *CompilePoly(const Vec2i *points, size_t numPoints);
|
||||
};
|
||||
}
|
||||
@@ -17,7 +17,10 @@ namespace PortabilityLayer
|
||||
Vec2i operator-(const Vec2i &other) const;
|
||||
|
||||
Vec2i &operator+=(const Vec2i &other);
|
||||
Vec2i &operator-=(const Vec2i &other);
|
||||
Vec2i &operator-=(const Vec2i &other);
|
||||
|
||||
bool operator==(const Vec2i &other) const;
|
||||
bool operator!=(const Vec2i &other) const;
|
||||
};
|
||||
|
||||
inline Vec2i::Vec2i()
|
||||
@@ -60,6 +63,15 @@ namespace PortabilityLayer
|
||||
m_x -= other.m_x;
|
||||
m_y -= other.m_y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool Vec2i::operator==(const Vec2i &other) const
|
||||
{
|
||||
return m_x == other.m_x && m_y == other.m_y;
|
||||
}
|
||||
|
||||
inline bool Vec2i::operator!=(const Vec2i &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user