32-bit color support

This commit is contained in:
elasota
2020-06-13 04:33:41 -04:00
parent 24f43b973a
commit 4920781619
42 changed files with 1161 additions and 450 deletions

View File

@@ -429,6 +429,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
g_gpWindowsGlobals.m_translateWindowsMessageFunc = TranslateWindowsMessage; g_gpWindowsGlobals.m_translateWindowsMessageFunc = TranslateWindowsMessage;
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_D3D11; g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_D3D11;
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_XAudio2; g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_XAudio2;
EGpInputDriverType inputDrivers[] = EGpInputDriverType inputDrivers[] =

View File

@@ -73,6 +73,14 @@
"id" : 0, "id" : 0,
"enabled" : true "enabled" : true
}, },
{
"name" : "32-bit color (Requires restart)",
"itemType" : "CheckBox",
"pos" : [ 8, 162 ],
"size" : [ 256, 18 ],
"id" : 0,
"enabled" : true
},
{ {
"name" : "", "name" : "",
"itemType" : "UserItem", "itemType" : "UserItem",

View File

@@ -68,10 +68,10 @@ void DrawBanner (Point *topLeft)
partPage.top = partPage.bottom - 30; partPage.top = partPage.bottom - 30;
mapBounds = partPage; mapBounds = partPage;
ZeroRectCorner(&mapBounds); ZeroRectCorner(&mapBounds);
theErr = CreateOffScreenGWorld(&tempMap, &mapBounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &mapBounds);
LoadGraphicCustom(tempMap, kBannerPageBottomPICT); LoadGraphicCustom(tempMap, kBannerPageBottomPICT);
theErr = CreateOffScreenGWorld(&tempMask, &mapBounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &mapBounds, GpPixelFormats::kBW1);
LoadGraphicCustom(tempMask, kBannerPageBottomMask); LoadGraphicCustom(tempMask, kBannerPageBottomMask);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),

View File

@@ -82,7 +82,7 @@ short BackUpToSavedMap (Rect *theRect, SInt16 where, SInt16 who, SInt16 componen
ZeroRectCorner(&mapRect); ZeroRectCorner(&mapRect);
savedMaps[numSavedMaps].dest = *theRect; savedMaps[numSavedMaps].dest = *theRect;
// CreateOffScreenPixMap(&mapRect, &savedMaps[numSavedMaps].map); // CreateOffScreenPixMap(&mapRect, &savedMaps[numSavedMaps].map);
theErr = CreateOffScreenGWorld(&savedMaps[numSavedMaps].map, &mapRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&savedMaps[numSavedMaps].map, &mapRect);
CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap), CopyBits((BitMap *)*GetGWorldPixMap(backSrcMap),
GetPortBitMapForCopyBits(savedMaps[numSavedMaps].map), GetPortBitMapForCopyBits(savedMaps[numSavedMaps].map),

View File

@@ -207,30 +207,6 @@ Boolean DoWeHaveDragManager (void)
return true; return true;
} }
//-------------------------------------------------------------- WhatsOurDepth
// Determines the pixel bit depth for current device (monitor).
short WhatsOurDepth (void)
{
GpPixelFormat_t pixelFormat;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nil, nil, &pixelFormat);
switch (pixelFormat)
{
case GpPixelFormats::k8BitCustom:
case GpPixelFormats::k8BitStandard:
return 8;
case GpPixelFormats::kRGB555:
return 16;
case GpPixelFormats::kRGB24:
case GpPixelFormats::kRGB32:
return 32;
default:
return 0;
}
}
void SwitchToDepth (short, Boolean) void SwitchToDepth (short, Boolean)
{ {
} }
@@ -321,9 +297,6 @@ void CheckOurEnvirons (void)
thisMac.can4Bit = true; thisMac.can4Bit = true;
thisMac.can8Bit = true; thisMac.can8Bit = true;
thisMac.numScreens = HowManyUsableScreens(false, true, true); thisMac.numScreens = HowManyUsableScreens(false, true, true);
thisMac.wasDepth = WhatsOurDepth();
thisMac.wasColorOrGray = AreWeColorOrGrayscale();
thisMac.isResolutionDirty = true; thisMac.isResolutionDirty = true;
FlushResolutionChange(); FlushResolutionChange();
@@ -417,53 +390,21 @@ void ReflectSecondMonitorEnvirons (Boolean use1Bit, Boolean use4Bit, Boolean use
void HandleDepthSwitching (void) void HandleDepthSwitching (void)
{ {
if (thisMac.hasColor) switch (isDepthPref)
{ {
switch (isDepthPref) case 32:
{ PortabilityLayer::DisplayDeviceManager::GetInstance()->SetPixelFormat(GpPixelFormats::kRGB32);
case kSwitchIfNeeded: break;
if ((thisMac.wasDepth != 8) && case 8:
((thisMac.wasDepth != 4) || (thisMac.wasColorOrGray))) PortabilityLayer::DisplayDeviceManager::GetInstance()->SetPixelFormat(GpPixelFormats::k8BitStandard);
SwitchDepthOrAbort(); break;
break; default:
isDepthPref = 8;
case kSwitchTo256Colors: PortabilityLayer::DisplayDeviceManager::GetInstance()->SetPixelFormat(GpPixelFormats::k8BitStandard);
if (thisMac.wasDepth != 8) break;
{
if (thisMac.can8Bit)
SwitchToDepth(8, true);
else
SwitchDepthOrAbort();
}
break;
case kSwitchTo16Grays:
if ((thisMac.wasDepth != 4) || (thisMac.wasColorOrGray))
{
if (thisMac.can4Bit)
SwitchToDepth(4, false);
else
SwitchDepthOrAbort();
}
break;
default:
break;
}
} }
thisMac.isDepth = WhatsOurDepth();
}
//-------------------------------------------------------------- RestoreColorDepth thisMac.isDepth = isDepthPref;
// Restores a monitor to its previous depth when we quit (if we changed it).
void RestoreColorDepth (void)
{
if ((thisMac.hasColor) && ((thisMac.wasDepth != thisMac.isDepth) ||
(thisMac.wasColorOrGray != AreWeColorOrGrayscale())))
SwitchToDepth(thisMac.wasDepth, true);
} }
//-------------------------------------------------------------- CheckMemorySize //-------------------------------------------------------------- CheckMemorySize
@@ -574,7 +515,7 @@ void GetDeviceRect(Rect *rect)
{ {
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, &height, nil); PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, &height);
SetRect(rect, 0, 0, static_cast<short>(width), static_cast<short>(height)); SetRect(rect, 0, 0, static_cast<short>(width), static_cast<short>(height));
} }

View File

@@ -12,7 +12,7 @@ typedef struct
{ {
Rect fullScreen, constrainedScreen, gray; Rect fullScreen, constrainedScreen, gray;
long dirID; long dirID;
short wasDepth, isDepth; short isDepth;
short numScreens; short numScreens;
short vRefNum; short vRefNum;
Boolean can1Bit; Boolean can1Bit;

View File

@@ -21,10 +21,6 @@ namespace PortabilityLayer
class RenderedFont; class RenderedFont;
} }
#define kPreferredDepth 8
#define kPreferredPixelFormat (GpPixelFormats::k8BitStandard)
#define kNilPointer 0L #define kNilPointer 0L
#define kPutInFront (PL_GetPutInFrontWindowPtr()) #define kPutInFront (PL_GetPutInFrontWindowPtr())
#define kNormalUpdates TRUE #define kNormalUpdates TRUE
@@ -168,15 +164,12 @@ void DumpToResEditFile (Ptr, long);
void HandleEvent (void); // --- Event.c void HandleEvent (void); // --- Event.c
void IgnoreThisClick (void); void IgnoreThisClick (void);
short WhatsOurDepth (void); // --- Environs.c void SwitchToDepth (short, Boolean); // --- Environs.c
void SwitchToDepth (short, Boolean);
void CheckOurEnvirons (void); void CheckOurEnvirons (void);
void InstallResolutionHandler (void); void InstallResolutionHandler (void);
//void ReflectSecondMonitorEnvirons (Boolean, Boolean, Boolean); //void ReflectSecondMonitorEnvirons (Boolean, Boolean, Boolean);
void HandleDepthSwitching (void); void HandleDepthSwitching (void);
void RestoreColorDepth (void);
void CheckMemorySize (void); void CheckMemorySize (void);
void SetAppMemorySize (long);
Boolean CheckFileError (short, const PLPasStr &); // --- File Error.c Boolean CheckFileError (short, const PLPasStr &); // --- File Error.c

View File

@@ -278,14 +278,14 @@ void InitDiedGameOver (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&pageSrcRect, 0, 0, 25, 32 * 8); QSetRect(&pageSrcRect, 0, 0, 25, 32 * 8);
theErr = CreateOffScreenGWorld(&gameOverSrcMap, &pageSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&gameOverSrcMap, &pageSrcRect);
LoadGraphic(gameOverSrcMap, kLettersPictID); LoadGraphic(gameOverSrcMap, kLettersPictID);
QSetRect(&pageSrcRect, 0, 0, 32, 32 * kPageFrames); QSetRect(&pageSrcRect, 0, 0, 32, 32 * kPageFrames);
theErr = CreateOffScreenGWorld(&pageSrcMap, &pageSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&pageSrcMap, &pageSrcRect);
LoadGraphic(pageSrcMap, kPagesPictID); LoadGraphic(pageSrcMap, kPagesPictID);
theErr = CreateOffScreenGWorld(&pageMaskMap, &pageSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&pageMaskMap, &pageSrcRect, GpPixelFormats::kBW1);
LoadGraphic(pageMaskMap, kPagesMaskID); LoadGraphic(pageMaskMap, kPagesMaskID);
for (i = 0; i < kPageFrames; i++) // initialize src page rects for (i = 0; i < kPageFrames; i++) // initialize src page rects

View File

@@ -41,8 +41,6 @@
#define kYellowCantOrderLinks 24 #define kYellowCantOrderLinks 24
#define kSwitchIfNeeded 0 #define kSwitchIfNeeded 0
#define kSwitchTo256Colors 1
#define kSwitchTo16Grays 2
#define kProdGameScoreMode -4 #define kProdGameScoreMode -4
#define kKickGameScoreMode -3 #define kKickGameScoreMode -3

View File

@@ -131,10 +131,10 @@ void DrawHighScores (DrawSurface *surface)
dropIt = 129 + splashOriginV; dropIt = 129 + splashOriginV;
QSetRect(&tempRect, 0, 0, 332, 30); QSetRect(&tempRect, 0, 0, 332, 30);
theErr = CreateOffScreenGWorld(&tempMap, &tempRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &tempRect);
LoadGraphic(tempMap, kHighScoresPictID); LoadGraphic(tempMap, kHighScoresPictID);
theErr = CreateOffScreenGWorld(&tempMask, &tempRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &tempRect, GpPixelFormats::kBW1);
LoadGraphic(tempMask, kHighScoresMaskID); LoadGraphic(tempMask, kHighScoresMaskID);
tempRect2 = tempRect; tempRect2 = tempRect;

View File

@@ -395,7 +395,6 @@ int gpAppMain()
} }
} }
WriteOutPrefs(); WriteOutPrefs();
RestoreColorDepth();
PL_DEAD(FlushEvents()); PL_DEAD(FlushEvents());
// theErr = LoadScrap(); // theErr = LoadScrap();

View File

@@ -762,7 +762,7 @@ void CreateNailOffscreen (void)
if (nailSrcMap == nil) if (nailSrcMap == nil)
{ {
QSetRect(&nailSrcRect, 0, 0, kMapRoomWidth, kMapRoomHeight * (kNumBackgrounds + 1)); QSetRect(&nailSrcRect, 0, 0, kMapRoomWidth, kMapRoomHeight * (kNumBackgrounds + 1));
theErr = CreateOffScreenGWorld(&nailSrcMap, &nailSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&nailSrcMap, &nailSrcRect);
LoadGraphic(nailSrcMap, kThumbnailPictID); LoadGraphic(nailSrcMap, kThumbnailPictID);
} }

View File

@@ -169,10 +169,10 @@ void DrawMailboxLeft (Rect *theRect, short down)
} }
bounds = srcRects[kMailboxLf]; bounds = srcRects[kMailboxLf];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, kMailboxLeftPictID); LoadGraphic(tempMap, kMailboxLeftPictID);
theErr = CreateOffScreenGWorld(&tempMask, &bounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &bounds, GpPixelFormats::kBW1);
LoadGraphic(tempMask, kMailboxLeftMaskID); LoadGraphic(tempMask, kMailboxLeftMaskID);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
@@ -241,10 +241,10 @@ void DrawMailboxRight (Rect *theRect, short down)
} }
bounds = srcRects[kMailboxRt]; bounds = srcRects[kMailboxRt];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, kMailboxRightPictID); LoadGraphic(tempMap, kMailboxRightPictID);
theErr = CreateOffScreenGWorld(&tempMask, &bounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &bounds, GpPixelFormats::kBW1);
LoadGraphic(tempMask, kMailboxRightMaskID); LoadGraphic(tempMask, kMailboxRightMaskID);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
@@ -604,10 +604,10 @@ void DrawTV (Rect *theRect, Boolean isOn, Boolean isLit)
if (isLit) if (isLit)
{ {
bounds = srcRects[kTV]; bounds = srcRects[kTV];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, kTVPictID); LoadGraphic(tempMap, kTVPictID);
theErr = CreateOffScreenGWorld(&tempMask, &bounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &bounds, GpPixelFormats::kBW1);
LoadGraphic(tempMask, kTVMaskID); LoadGraphic(tempMask, kTVMaskID);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
@@ -690,10 +690,10 @@ void DrawVCR (Rect *theRect, Boolean isOn, Boolean isLit)
if (isLit) if (isLit)
{ {
bounds = srcRects[kVCR]; bounds = srcRects[kVCR];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, kVCRPictID); LoadGraphic(tempMap, kVCRPictID);
theErr = CreateOffScreenGWorld(&tempMask, &bounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &bounds, GpPixelFormats::kBW1);
LoadGraphic(tempMask, kVCRMaskID); LoadGraphic(tempMask, kVCRMaskID);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
@@ -737,10 +737,10 @@ void DrawStereo (Rect *theRect, Boolean isOn, Boolean isLit)
if (isLit) if (isLit)
{ {
bounds = srcRects[kStereo]; bounds = srcRects[kStereo];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, kStereoPictID); LoadGraphic(tempMap, kStereoPictID);
theErr = CreateOffScreenGWorld(&tempMask, &bounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &bounds, GpPixelFormats::kBW1);
LoadGraphic(tempMask, kStereoMaskID); LoadGraphic(tempMask, kStereoMaskID);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
@@ -784,10 +784,10 @@ void DrawMicrowave (Rect *theRect, Boolean isOn, Boolean isLit)
if (isLit) if (isLit)
{ {
bounds = srcRects[kMicrowave]; bounds = srcRects[kMicrowave];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, kMicrowavePictID); LoadGraphic(tempMap, kMicrowavePictID);
theErr = CreateOffScreenGWorld(&tempMask, &bounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &bounds, GpPixelFormats::kBW1);
LoadGraphic(tempMask, kMicrowaveMaskID); LoadGraphic(tempMask, kMicrowaveMaskID);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
@@ -1162,10 +1162,10 @@ void DrawPictWithMaskObject (short what, Rect *theRect)
} }
bounds = srcRects[what]; bounds = srcRects[what];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, pictID); LoadGraphic(tempMap, pictID);
theErr = CreateOffScreenGWorld(&tempMask, &bounds, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&tempMask, &bounds, GpPixelFormats::kBW1);
LoadGraphic(tempMask, maskID); LoadGraphic(tempMask, maskID);
CopyMask((BitMap *)*GetGWorldPixMap(tempMap), CopyMask((BitMap *)*GetGWorldPixMap(tempMap),
@@ -1273,7 +1273,7 @@ void DrawPictSansWhiteObject (short what, Rect *theRect)
} }
bounds = srcRects[what]; bounds = srcRects[what];
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphic(tempMap, pictID); LoadGraphic(tempMap, pictID);
CopyBits((BitMap *)*GetGWorldPixMap(tempMap), CopyBits((BitMap *)*GetGWorldPixMap(tempMap),
@@ -1293,7 +1293,7 @@ void DrawCustPictSansWhite (short pictID, Rect *theRect)
bounds = *theRect; bounds = *theRect;
ZeroRectCorner(&bounds); ZeroRectCorner(&bounds);
theErr = CreateOffScreenGWorld(&tempMap, &bounds, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tempMap, &bounds);
LoadGraphicCustom(tempMap, pictID); LoadGraphicCustom(tempMap, pictID);
CopyBits((BitMap *)*GetGWorldPixMap(tempMap), CopyBits((BitMap *)*GetGWorldPixMap(tempMap),

View File

@@ -436,7 +436,7 @@ void DoRoomInfo(void)
NumToString(thisRoom->numObjects, objectsStr); NumToString(thisRoom->numObjects, objectsStr);
DialogTextSubstitutions substitutions(floorStr, suiteStr, objectsStr); DialogTextSubstitutions substitutions(floorStr, suiteStr, objectsStr);
theErr = CreateOffScreenGWorld(&tileSrcMap, &tileSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&tileSrcMap, &tileSrcRect);
// CreateOffScreenPixMap(&tileSrcRect, &tileSrcMap); // CreateOffScreenPixMap(&tileSrcRect, &tileSrcMap);
// SetPort((GrafPtr)tileSrcMap); // SetPort((GrafPtr)tileSrcMap);
if ((tempBack > kStars) && (!PictIDExists(tempBack))) if ((tempBack > kStars) && (!PictIDExists(tempBack)))

View File

@@ -34,12 +34,12 @@
#define kDisplay9Item 5 #define kDisplay9Item 5
#define kBorder1Item 8 #define kBorder1Item 8
#define kDoColorFadeItem 9 #define kDoColorFadeItem 9
//#define kCurrentDepth 10 #define k32BitColorItem 10
//#define k256Depth 11 //#define k256Depth 11
//#define k16Depth 12 //#define k16Depth 12
#define kBorder2Item 10 #define kBorder2Item 11
#define kBorder3Item 11 #define kBorder3Item 12
#define kDispDefault 12 #define kDispDefault 13
//#define kUseQDItem 13 //#define kUseQDItem 13
//#define kUseScreen2Item 14 //#define kUseScreen2Item 14
#define kSofterItem 4 #define kSofterItem 4
@@ -906,6 +906,7 @@ void DisplayUpdate (Dialog *theDialog)
DrawDefaultButton(theDialog); DrawDefaultButton(theDialog);
SetDialogItemValue(theDialog, kDoColorFadeItem, (short)wasFade); SetDialogItemValue(theDialog, kDoColorFadeItem, (short)wasFade);
SetDialogItemValue(theDialog, k32BitColorItem, wasDepthPref == 32);
FrameDisplayIcon(theDialog, StdColors::Red()); FrameDisplayIcon(theDialog, StdColors::Red());
FrameDialogItemC(theDialog, kBorder1Item, kRedOrangeColor8); FrameDialogItemC(theDialog, kBorder1Item, kRedOrangeColor8);
@@ -1001,9 +1002,6 @@ void DoDisplayPrefs (void)
BringUpDialog(&prefDlg, kDisplayPrefsDialID, nullptr); BringUpDialog(&prefDlg, kDisplayPrefsDialID, nullptr);
if (!thisMac.can8Bit)
MyDisableControl(prefDlg, kDoColorFadeItem);
wasNeighbors = numNeighbors; wasNeighbors = numNeighbors;
wasFade = isDoColorFade; wasFade = isDoColorFade;
wasDepthPref = isDepthPref; wasDepthPref = isDepthPref;
@@ -1060,6 +1058,14 @@ void DoDisplayPrefs (void)
SetDialogItemValue(prefDlg, kDoColorFadeItem, (short)wasFade); SetDialogItemValue(prefDlg, kDoColorFadeItem, (short)wasFade);
break; break;
case k32BitColorItem:
if (wasDepthPref == 32)
wasDepthPref = 8;
else
wasDepthPref = 32;
SetDialogItemValue(prefDlg, k32BitColorItem, wasDepthPref == 32);
break;
case kDispDefault: case kDispDefault:
FrameDisplayIcon(prefDlg, StdColors::White()); FrameDisplayIcon(prefDlg, StdColors::White());
DisplayDefaults(); DisplayDefaults();

View File

@@ -73,7 +73,7 @@ void InitScoreboardMap(void)
boardSrcRect = houseRect; boardSrcRect = houseRect;
ZeroRectCorner(&boardSrcRect); ZeroRectCorner(&boardSrcRect);
boardSrcRect.bottom = kScoreboardTall; boardSrcRect.bottom = kScoreboardTall;
theErr = CreateOffScreenGWorld(&boardSrcMap, &boardSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&boardSrcMap, &boardSrcRect);
if (boardSrcRect.right >= 640) if (boardSrcRect.right >= 640)
hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2; hOffset = (RectWide(&boardSrcRect) - kMaxViewWidth) / 2;
@@ -91,7 +91,7 @@ void InitScoreboardMap(void)
QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels
if (!badgeSrcMap) if (!badgeSrcMap)
{ {
theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect);
LoadGraphic(badgeSrcMap, kBadgePictID); LoadGraphic(badgeSrcMap, kBadgePictID);
} }
@@ -104,7 +104,7 @@ void InitScoreboardMap(void)
QSetRect(&boardTSrcRect, 0, 0, 256, 12); // room title QSetRect(&boardTSrcRect, 0, 0, 256, 12); // room title
if (!boardTSrcMap) if (!boardTSrcMap)
{ {
theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&boardTSrcMap, &boardTSrcRect);
} }
boardTDestRect = boardTSrcRect; boardTDestRect = boardTSrcRect;
QOffsetRect(&boardTDestRect, 137 + hOffset, 5); QOffsetRect(&boardTDestRect, 137 + hOffset, 5);
@@ -112,7 +112,7 @@ void InitScoreboardMap(void)
QSetRect(&boardGSrcRect, 0, 0, 20, 10); // # gliders QSetRect(&boardGSrcRect, 0, 0, 20, 10); // # gliders
if (!boardGSrcMap) if (!boardGSrcMap)
{ {
theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&boardGSrcMap, &boardGSrcRect);
} }
boardGDestRect = boardGSrcRect; boardGDestRect = boardGSrcRect;
QOffsetRect(&boardGDestRect, 526 + hOffset, 5); QOffsetRect(&boardGDestRect, 526 + hOffset, 5);
@@ -121,7 +121,7 @@ void InitScoreboardMap(void)
QSetRect(&boardPSrcRect, 0, 0, 64, 10); // points QSetRect(&boardPSrcRect, 0, 0, 64, 10); // points
if (!boardPSrcMap) if (!boardPSrcMap)
{ {
theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&boardPSrcMap, &boardPSrcRect);
} }
boardPDestRect = boardPSrcRect; boardPDestRect = boardPSrcRect;
QOffsetRect(&boardPDestRect, 570 + hOffset, 5); // total = 6396 pixels QOffsetRect(&boardPDestRect, 570 + hOffset, 5); // total = 6396 pixels
@@ -166,13 +166,13 @@ void InitGliderMap (void)
short i; short i;
QSetRect(&glidSrcRect, 0, 0, kGliderWide, 668); // 32112 pixels QSetRect(&glidSrcRect, 0, 0, kGliderWide, 668); // 32112 pixels
theErr = CreateOffScreenGWorld(&glidSrcMap, &glidSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&glidSrcMap, &glidSrcRect);
LoadGraphic(glidSrcMap, kGliderPictID); LoadGraphic(glidSrcMap, kGliderPictID);
theErr = CreateOffScreenGWorld(&glid2SrcMap, &glidSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&glid2SrcMap, &glidSrcRect);
LoadGraphic(glid2SrcMap, kGlider2PictID); LoadGraphic(glid2SrcMap, kGlider2PictID);
theErr = CreateOffScreenGWorld(&glidMaskMap, &glidSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&glidMaskMap, &glidSrcRect, GpPixelFormats::kBW1);
LoadGraphic(glidMaskMap, kGliderPictID + 1000); LoadGraphic(glidMaskMap, kGliderPictID + 1000);
for (i = 0; i <= 20; i++) for (i = 0; i <= 20; i++)
@@ -192,10 +192,10 @@ void InitGliderMap (void)
QOffsetRect(&gliderSrc[30], 0, 648); QOffsetRect(&gliderSrc[30], 0, 648);
QSetRect(&shadowSrcRect, 0, 0, kGliderWide, kShadowHigh * kNumShadowSrcRects); QSetRect(&shadowSrcRect, 0, 0, kGliderWide, kShadowHigh * kNumShadowSrcRects);
theErr = CreateOffScreenGWorld(&shadowSrcMap, &shadowSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&shadowSrcMap, &shadowSrcRect);
LoadGraphic(shadowSrcMap, kShadowPictID); LoadGraphic(shadowSrcMap, kShadowPictID);
theErr = CreateOffScreenGWorld(&shadowMaskMap, &shadowSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&shadowMaskMap, &shadowSrcRect, GpPixelFormats::kBW1);
LoadGraphic(shadowMaskMap, kShadowPictID + 1000); LoadGraphic(shadowMaskMap, kShadowPictID + 1000);
for (i = 0; i < kNumShadowSrcRects; i++) for (i = 0; i < kNumShadowSrcRects; i++)
@@ -205,10 +205,10 @@ void InitGliderMap (void)
} }
QSetRect(&bandsSrcRect, 0, 0, 16, 18); // 304 pixels QSetRect(&bandsSrcRect, 0, 0, 16, 18); // 304 pixels
theErr = CreateOffScreenGWorld(&bandsSrcMap, &bandsSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&bandsSrcMap, &bandsSrcRect);
LoadGraphic(bandsSrcMap, kRubberBandsPictID); LoadGraphic(bandsSrcMap, kRubberBandsPictID);
theErr = CreateOffScreenGWorld(&bandsMaskMap, &bandsSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&bandsMaskMap, &bandsSrcRect, GpPixelFormats::kBW1);
LoadGraphic(bandsMaskMap, kRubberBandsPictID + 1000); LoadGraphic(bandsMaskMap, kRubberBandsPictID + 1000);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
@@ -228,10 +228,10 @@ void InitBlowers (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&blowerSrcRect, 0, 0, 48, 402); // 19344 pixels QSetRect(&blowerSrcRect, 0, 0, 48, 402); // 19344 pixels
theErr = CreateOffScreenGWorld(&blowerSrcMap, &blowerSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&blowerSrcMap, &blowerSrcRect);
LoadGraphic(blowerSrcMap, kBlowerPictID); LoadGraphic(blowerSrcMap, kBlowerPictID);
theErr = CreateOffScreenGWorld(&blowerMaskMap, &blowerSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&blowerMaskMap, &blowerSrcRect, GpPixelFormats::kBW1);
LoadGraphic(blowerMaskMap, kBlowerPictID + 1000); LoadGraphic(blowerMaskMap, kBlowerPictID + 1000);
for (i = 0; i < kNumCandleFlames; i++) for (i = 0; i < kNumCandleFlames; i++)
@@ -271,10 +271,10 @@ void InitFurniture (void)
wasCPort = GetGraphicsPort(); wasCPort = GetGraphicsPort();
QSetRect(&furnitureSrcRect, 0, 0, 64, 278); // 17856 pixels QSetRect(&furnitureSrcRect, 0, 0, 64, 278); // 17856 pixels
theErr = CreateOffScreenGWorld(&furnitureSrcMap, &furnitureSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&furnitureSrcMap, &furnitureSrcRect);
LoadGraphic(furnitureSrcMap, kFurniturePictID); LoadGraphic(furnitureSrcMap, kFurniturePictID);
theErr = CreateOffScreenGWorld(&furnitureMaskMap, &furnitureSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&furnitureMaskMap, &furnitureSrcRect, GpPixelFormats::kBW1);
LoadGraphic(furnitureMaskMap, kFurniturePictID + 1000); LoadGraphic(furnitureMaskMap, kFurniturePictID + 1000);
QSetRect(&tableSrc, 0, 0, 64, 22); QSetRect(&tableSrc, 0, 0, 64, 22);
@@ -314,10 +314,10 @@ void InitPrizes (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&bonusSrcRect, 0, 0, 88, 378); // 33264 pixels QSetRect(&bonusSrcRect, 0, 0, 88, 378); // 33264 pixels
theErr = CreateOffScreenGWorld(&bonusSrcMap, &bonusSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&bonusSrcMap, &bonusSrcRect);
LoadGraphic(bonusSrcMap, kBonusPictID); LoadGraphic(bonusSrcMap, kBonusPictID);
theErr = CreateOffScreenGWorld(&bonusMaskMap, &bonusSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&bonusMaskMap, &bonusSrcRect, GpPixelFormats::kBW1);
LoadGraphic(bonusMaskMap, kBonusPictID + 1000); LoadGraphic(bonusMaskMap, kBonusPictID + 1000);
for (i = 0; i < 11; i++) for (i = 0; i < 11; i++)
@@ -365,10 +365,10 @@ void InitPrizes (void)
sparkleSrc[1] = sparkleSrc[3]; sparkleSrc[1] = sparkleSrc[3];
QSetRect(&pointsSrcRect, 0, 0, 24, 120); // 2880 pixels QSetRect(&pointsSrcRect, 0, 0, 24, 120); // 2880 pixels
theErr = CreateOffScreenGWorld(&pointsSrcMap, &pointsSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&pointsSrcMap, &pointsSrcRect);
LoadGraphic(pointsSrcMap, kPointsPictID); LoadGraphic(pointsSrcMap, kPointsPictID);
theErr = CreateOffScreenGWorld(&pointsMaskMap, &pointsSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&pointsMaskMap, &pointsSrcRect, GpPixelFormats::kBW1);
LoadGraphic(pointsMaskMap, kPointsPictID + 1000); LoadGraphic(pointsMaskMap, kPointsPictID + 1000);
for (i = 0; i < 15; i++) for (i = 0; i < 15; i++)
@@ -387,10 +387,10 @@ void InitTransports (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&transSrcRect, 0, 0, 56, 32); // 1848 pixels QSetRect(&transSrcRect, 0, 0, 56, 32); // 1848 pixels
theErr = CreateOffScreenGWorld(&transSrcMap, &transSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&transSrcMap, &transSrcRect);
LoadGraphic(transSrcMap, kTransportPictID); LoadGraphic(transSrcMap, kTransportPictID);
theErr = CreateOffScreenGWorld(&transMaskMap, &transSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&transMaskMap, &transSrcRect, GpPixelFormats::kBW1);
LoadGraphic(transMaskMap, kTransportPictID + 1000); LoadGraphic(transMaskMap, kTransportPictID + 1000);
} }
@@ -403,7 +403,7 @@ void InitSwitches (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&switchSrcRect, 0, 0, 32, 104); // 3360 pixels QSetRect(&switchSrcRect, 0, 0, 32, 104); // 3360 pixels
theErr = CreateOffScreenGWorld(&switchSrcMap, &switchSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&switchSrcMap, &switchSrcRect);
LoadGraphic(switchSrcMap, kSwitchPictID); LoadGraphic(switchSrcMap, kSwitchPictID);
QSetRect(&lightSwitchSrc[0], 0, 0, 15, 24); QSetRect(&lightSwitchSrc[0], 0, 0, 15, 24);
@@ -442,10 +442,10 @@ void InitLights (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&lightSrcRect, 0, 0, 72, 126); // 9144 pixels QSetRect(&lightSrcRect, 0, 0, 72, 126); // 9144 pixels
theErr = CreateOffScreenGWorld(&lightSrcMap, &lightSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&lightSrcMap, &lightSrcRect);
LoadGraphic(lightSrcMap, kLightPictID); LoadGraphic(lightSrcMap, kLightPictID);
theErr = CreateOffScreenGWorld(&lightMaskMap, &lightSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&lightMaskMap, &lightSrcRect, GpPixelFormats::kBW1);
LoadGraphic(lightMaskMap, kLightPictID + 1000); LoadGraphic(lightMaskMap, kLightPictID + 1000);
QSetRect(&flourescentSrc1, 0, 0, 16, 12); QSetRect(&flourescentSrc1, 0, 0, 16, 12);
@@ -471,24 +471,24 @@ void InitAppliances (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&applianceSrcRect, 0, 0, 80, 269); // 21600 pixels QSetRect(&applianceSrcRect, 0, 0, 80, 269); // 21600 pixels
theErr = CreateOffScreenGWorld(&applianceSrcMap, &applianceSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&applianceSrcMap, &applianceSrcRect);
LoadGraphic(applianceSrcMap, kAppliancePictID); LoadGraphic(applianceSrcMap, kAppliancePictID);
theErr = CreateOffScreenGWorld(&applianceMaskMap, &applianceSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&applianceMaskMap, &applianceSrcRect, GpPixelFormats::kBW1);
LoadGraphic(applianceMaskMap, kAppliancePictID + 1000); LoadGraphic(applianceMaskMap, kAppliancePictID + 1000);
QSetRect(&toastSrcRect, 0, 0, 32, 174); // 5600 pixels QSetRect(&toastSrcRect, 0, 0, 32, 174); // 5600 pixels
theErr = CreateOffScreenGWorld(&toastSrcMap, &toastSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&toastSrcMap, &toastSrcRect);
LoadGraphic(toastSrcMap, kToastPictID); LoadGraphic(toastSrcMap, kToastPictID);
theErr = CreateOffScreenGWorld(&toastMaskMap, &toastSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&toastMaskMap, &toastSrcRect, GpPixelFormats::kBW1);
LoadGraphic(toastMaskMap, kToastPictID + 1000); LoadGraphic(toastMaskMap, kToastPictID + 1000);
QSetRect(&shredSrcRect, 0, 0, 40, 35); // 1440 pixels QSetRect(&shredSrcRect, 0, 0, 40, 35); // 1440 pixels
theErr = CreateOffScreenGWorld(&shredSrcMap, &shredSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&shredSrcMap, &shredSrcRect);
LoadGraphic(shredSrcMap, kShreddedPictID); LoadGraphic(shredSrcMap, kShreddedPictID);
theErr = CreateOffScreenGWorld(&shredMaskMap, &shredSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&shredMaskMap, &shredSrcRect, GpPixelFormats::kBW1);
LoadGraphic(shredMaskMap, kShreddedPictID + 1000); LoadGraphic(shredMaskMap, kShreddedPictID + 1000);
QSetRect(&plusScreen1, 0, 0, 32, 22); QSetRect(&plusScreen1, 0, 0, 32, 22);
@@ -544,52 +544,52 @@ void InitEnemies (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&balloonSrcRect, 0, 0, 24, 30 * kNumBalloonFrames); QSetRect(&balloonSrcRect, 0, 0, 24, 30 * kNumBalloonFrames);
theErr = CreateOffScreenGWorld(&balloonSrcMap, &balloonSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&balloonSrcMap, &balloonSrcRect);
LoadGraphic(balloonSrcMap, kBalloonPictID); LoadGraphic(balloonSrcMap, kBalloonPictID);
theErr = CreateOffScreenGWorld(&balloonMaskMap, &balloonSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&balloonMaskMap, &balloonSrcRect, GpPixelFormats::kBW1);
LoadGraphic(balloonMaskMap, kBalloonPictID + 1000); LoadGraphic(balloonMaskMap, kBalloonPictID + 1000);
QSetRect(&copterSrcRect, 0, 0, 32, 30 * kNumCopterFrames); QSetRect(&copterSrcRect, 0, 0, 32, 30 * kNumCopterFrames);
theErr = CreateOffScreenGWorld(&copterSrcMap, &copterSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&copterSrcMap, &copterSrcRect);
LoadGraphic(copterSrcMap, kCopterPictID); LoadGraphic(copterSrcMap, kCopterPictID);
theErr = CreateOffScreenGWorld(&copterMaskMap, &copterSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&copterMaskMap, &copterSrcRect, GpPixelFormats::kBW1);
LoadGraphic(copterMaskMap, kCopterPictID + 1000); LoadGraphic(copterMaskMap, kCopterPictID + 1000);
QSetRect(&dartSrcRect, 0, 0, 64, 19 * kNumDartFrames); QSetRect(&dartSrcRect, 0, 0, 64, 19 * kNumDartFrames);
theErr = CreateOffScreenGWorld(&dartSrcMap, &dartSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&dartSrcMap, &dartSrcRect);
LoadGraphic(dartSrcMap, kDartPictID); LoadGraphic(dartSrcMap, kDartPictID);
theErr = CreateOffScreenGWorld(&dartMaskMap, &dartSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&dartMaskMap, &dartSrcRect, GpPixelFormats::kBW1);
LoadGraphic(dartMaskMap, kDartPictID + 1000); LoadGraphic(dartMaskMap, kDartPictID + 1000);
QSetRect(&ballSrcRect, 0, 0, 32, 32 * kNumBallFrames); QSetRect(&ballSrcRect, 0, 0, 32, 32 * kNumBallFrames);
theErr = CreateOffScreenGWorld(&ballSrcMap, &ballSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&ballSrcMap, &ballSrcRect);
LoadGraphic(ballSrcMap, kBallPictID); LoadGraphic(ballSrcMap, kBallPictID);
theErr = CreateOffScreenGWorld(&ballMaskMap, &ballSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&ballMaskMap, &ballSrcRect, GpPixelFormats::kBW1);
LoadGraphic(ballMaskMap, kBallPictID + 1000); LoadGraphic(ballMaskMap, kBallPictID + 1000);
QSetRect(&dripSrcRect, 0, 0, 16, 12 * kNumDripFrames); QSetRect(&dripSrcRect, 0, 0, 16, 12 * kNumDripFrames);
theErr = CreateOffScreenGWorld(&dripSrcMap, &dripSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&dripSrcMap, &dripSrcRect);
LoadGraphic(dripSrcMap, kDripPictID); LoadGraphic(dripSrcMap, kDripPictID);
theErr = CreateOffScreenGWorld(&dripMaskMap, &dripSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&dripMaskMap, &dripSrcRect, GpPixelFormats::kBW1);
LoadGraphic(dripMaskMap, kDripPictID + 1000); LoadGraphic(dripMaskMap, kDripPictID + 1000);
QSetRect(&enemySrcRect, 0, 0, 36, 33); QSetRect(&enemySrcRect, 0, 0, 36, 33);
theErr = CreateOffScreenGWorld(&enemySrcMap, &enemySrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&enemySrcMap, &enemySrcRect);
LoadGraphic(enemySrcMap, kEnemyPictID); LoadGraphic(enemySrcMap, kEnemyPictID);
theErr = CreateOffScreenGWorld(&enemyMaskMap, &enemySrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&enemyMaskMap, &enemySrcRect, GpPixelFormats::kBW1);
LoadGraphic(enemyMaskMap, kEnemyPictID + 1000); LoadGraphic(enemyMaskMap, kEnemyPictID + 1000);
QSetRect(&fishSrcRect, 0, 0, 16, 16 * kNumFishFrames); QSetRect(&fishSrcRect, 0, 0, 16, 16 * kNumFishFrames);
theErr = CreateOffScreenGWorld(&fishSrcMap, &fishSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&fishSrcMap, &fishSrcRect);
LoadGraphic(fishSrcMap, kFishPictID); LoadGraphic(fishSrcMap, kFishPictID);
theErr = CreateOffScreenGWorld(&fishMaskMap, &fishSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&fishMaskMap, &fishSrcRect, GpPixelFormats::kBW1);
LoadGraphic(fishMaskMap, kFishPictID + 1000); LoadGraphic(fishMaskMap, kFishPictID + 1000);
for (i = 0; i < kNumBalloonFrames; i++) for (i = 0; i < kNumBalloonFrames; i++)

View File

@@ -57,10 +57,10 @@ void InitClutter (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&clutterSrcRect, 0, 0, 128, 69); QSetRect(&clutterSrcRect, 0, 0, 128, 69);
theErr = CreateOffScreenGWorld(&clutterSrcMap, &clutterSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&clutterSrcMap, &clutterSrcRect);
LoadGraphic(clutterSrcMap, kClutterPictID); LoadGraphic(clutterSrcMap, kClutterPictID);
theErr = CreateOffScreenGWorld(&clutterMaskMap, &clutterSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&clutterMaskMap, &clutterSrcRect, GpPixelFormats::kBW1);
LoadGraphic(clutterMaskMap, kClutterPictID + 1000); LoadGraphic(clutterMaskMap, kClutterPictID + 1000);
QSetRect(&flowerSrc[0], 0, 0, 10, 28); QSetRect(&flowerSrc[0], 0, 0, 10, 28);
@@ -92,7 +92,7 @@ void InitSupport (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&suppSrcRect, 0, 0, kRoomWide, kFloorSupportTall); // 44 QSetRect(&suppSrcRect, 0, 0, kRoomWide, kFloorSupportTall); // 44
theErr = CreateOffScreenGWorld(&suppSrcMap, &suppSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&suppSrcMap, &suppSrcRect);
LoadGraphic(suppSrcMap, kSupportPictID); LoadGraphic(suppSrcMap, kSupportPictID);
} }
@@ -106,10 +106,10 @@ void InitAngel (void)
PLError_t theErr; PLError_t theErr;
QSetRect(&angelSrcRect, 0, 0, 96, 44); QSetRect(&angelSrcRect, 0, 0, 96, 44);
theErr = CreateOffScreenGWorld(&angelSrcMap, &angelSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&angelSrcMap, &angelSrcRect);
LoadGraphic(angelSrcMap, kAngelPictID); LoadGraphic(angelSrcMap, kAngelPictID);
theErr = CreateOffScreenGWorld(&angelMaskMap, &angelSrcRect, GpPixelFormats::kBW1); theErr = CreateOffScreenGWorldCustomDepth(&angelMaskMap, &angelSrcRect, GpPixelFormats::kBW1);
LoadGraphic(angelMaskMap, kAngelPictID + 1); LoadGraphic(angelMaskMap, kAngelPictID + 1);
} }
@@ -132,11 +132,11 @@ PLError_t RecreateOffscreens(void)
workSrcRect = houseRect; // Set up work map workSrcRect = houseRect; // Set up work map
ZeroRectCorner(&workSrcRect); ZeroRectCorner(&workSrcRect);
theErr = CreateOffScreenGWorld(&workSrcMap, &workSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&workSrcMap, &workSrcRect);
backSrcRect = houseRect; // Set up background map backSrcRect = houseRect; // Set up background map
ZeroRectCorner(&backSrcRect); ZeroRectCorner(&backSrcRect);
theErr = CreateOffScreenGWorld(&backSrcMap, &backSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&backSrcMap, &backSrcRect);
return PLErrors::kNone; return PLErrors::kNone;
} }

View File

@@ -87,7 +87,7 @@ void CreateToolsOffscreen (void)
if (toolSrcMap == nil) if (toolSrcMap == nil)
{ {
QSetRect(&toolSrcRect, 0, 0, 360, 216); QSetRect(&toolSrcRect, 0, 0, 360, 216);
theErr = CreateOffScreenGWorld(&toolSrcMap, &toolSrcRect, kPreferredPixelFormat); theErr = CreateOffScreenGWorld(&toolSrcMap, &toolSrcRect);
LoadGraphic(toolSrcMap, kToolsPictID); LoadGraphic(toolSrcMap, kToolsPictID);
} }
} }

View File

@@ -15,6 +15,7 @@
#include "QDPixMap.h" #include "QDPixMap.h"
#include "BitmapImage.h" #include "BitmapImage.h"
#include "DialogManager.h" #include "DialogManager.h"
#include "DisplayDeviceManager.h"
#include "Externs.h" #include "Externs.h"
#include "HostSystemServices.h" #include "HostSystemServices.h"
#include "IconLoader.h" #include "IconLoader.h"
@@ -211,13 +212,17 @@ void CreateOffScreenPixMap (Rect *theRect, CGrafPtr *offScreen)
//-------------------------------------------------------------------- CreateOffScreenGWorld //-------------------------------------------------------------------- CreateOffScreenGWorld
// Creates an offscreen GWorldÊusing the depth passed in. // Creates an offscreen GWorldÊusing the depth passed in.
PLError_t CreateOffScreenGWorld (DrawSurface **theGWorld, Rect *bounds, GpPixelFormat_t pixelFormat) PLError_t CreateOffScreenGWorld (DrawSurface **theGWorld, Rect *bounds)
{ {
PLError_t theErr; GpPixelFormat_t pixelFormat = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetPixelFormat();
theErr = NewGWorld(theGWorld, pixelFormat, bounds, nil); return NewGWorld(theGWorld, pixelFormat, bounds, nil);
}
return theErr;
PLError_t CreateOffScreenGWorldCustomDepth(DrawSurface **theGWorld, Rect *bounds, GpPixelFormat_t pixelFormat)
{
return NewGWorld(theGWorld, pixelFormat, bounds, nil);
} }
//-------------------------------------------------------------- KillOffScreenPixMap //-------------------------------------------------------------- KillOffScreenPixMap

View File

@@ -9,4 +9,5 @@
#include "GpPixelFormat.h" #include "GpPixelFormat.h"
PLError_t CreateOffScreenGWorld (DrawSurface **surface, Rect *bounds, GpPixelFormat_t pixelFormat); PLError_t CreateOffScreenGWorld (DrawSurface **surface, Rect *bounds);
PLError_t CreateOffScreenGWorldCustomDepth (DrawSurface **surface, Rect *bounds, GpPixelFormat_t pixelFormat);

View File

@@ -2,8 +2,8 @@
#define GP_BUILD_VERSION_MAJOR 1 #define GP_BUILD_VERSION_MAJOR 1
#define GP_BUILD_VERSION_MINOR 0 #define GP_BUILD_VERSION_MINOR 0
#define GP_BUILD_VERSION_UPDATE 1 #define GP_BUILD_VERSION_UPDATE 2
#define GP_APPLICATION_VERSION_STRING "1.0.1" #define GP_APPLICATION_VERSION_STRING "1.0.2"
#define GP_APPLICATION_COPYRIGHT_STRING "2020 Eric Lasota" #define GP_APPLICATION_COPYRIGHT_STRING "2020 Eric Lasota"
#define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil" #define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil"

View File

@@ -5,6 +5,7 @@
struct IGpDisplayDriverSurface; struct IGpDisplayDriverSurface;
struct IGpCursor; struct IGpCursor;
struct GpDisplayDriverProperties;
struct GpDisplayDriverSurfaceEffects struct GpDisplayDriverSurfaceEffects
{ {
@@ -26,7 +27,7 @@ public:
virtual void Run() = 0; virtual void Run() = 0;
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
virtual void GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *bpp) = 0; virtual void GetDisplayResolution(unsigned int *width, unsigned int *height) = 0;
virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) = 0; virtual IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) = 0;
virtual void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) = 0; virtual void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) = 0;
@@ -40,6 +41,8 @@ public:
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) = 0; virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) = 0;
virtual void RequestToggleFullScreen(uint32_t timestamp) = 0; virtual void RequestToggleFullScreen(uint32_t timestamp) = 0;
virtual const GpDisplayDriverProperties &GetProperties() const = 0;
}; };
inline GpDisplayDriverSurfaceEffects::GpDisplayDriverSurfaceEffects() inline GpDisplayDriverSurfaceEffects::GpDisplayDriverSurfaceEffects()

View File

@@ -1,46 +1,132 @@
static unsigned char gs_shaderData[] = { static unsigned char gs_shaderData[] = {
68, 88, 66, 67, 196, 70, 6, 103, 19, 68, 64, 241, 205, 255, 73, 68, 88, 66, 67, 79, 173, 176, 182, 205, 217, 61, 84, 80, 209, 33,
188, 120, 217, 29, 231, 1, 0, 0, 0, 116, 2, 0, 0, 5, 0, 250, 135, 89, 76, 198, 1, 0, 0, 0, 116, 7, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0, 176, 0, 0, 0, 8, 1, 0, 0, 60, 0, 0, 52, 0, 0, 0, 124, 2, 0, 0, 212, 2, 0, 0, 8,
1, 0, 0, 248, 1, 0, 0, 82, 68, 69, 70, 116, 0, 0, 0, 3, 0, 0, 248, 6, 0, 0, 82, 68, 69, 70, 64, 2, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 1, 0, 0, 0, 132, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
0, 0, 4, 255, 255, 0, 137, 0, 0, 75, 0, 0, 0, 60, 0, 0, 0, 4, 255, 255, 0, 137, 0, 0, 24, 2, 0, 0, 92, 0,
0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 255, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0, 0, 255,
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 9, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 9, 0, 0, 0,
115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114, 101, 0, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 0, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114,
105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 171, 73, 83, 71, 78, 101, 0, 83, 68, 114, 97, 119, 81, 117, 97, 100, 80, 105, 120, 101,
80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 108, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 171, 107, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 156, 0, 0, 0, 48, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 0, 0, 0, 0, 16,
0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 2, 0, 0, 0, 68, 1, 0, 0, 0, 0, 0, 0,
83, 86, 95, 80, 79, 83, 73, 84, 73, 79, 78, 0, 84, 69, 88, 84, 1, 0, 0, 16, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0,
67, 79, 79, 82, 68, 0, 171, 171, 171, 79, 83, 71, 78, 44, 0, 0, 108, 1, 0, 0, 0, 0, 0, 0, 124, 1, 0, 0, 24, 0,
0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 156, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 172, 1, 0, 0, 28, 0, 0, 0, 4, 0, 0, 0,
15, 0, 0, 0, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 2, 0, 0, 0, 156, 1, 0, 0, 0, 0, 0, 0, 202, 1, 0,
171, 83, 72, 68, 82, 180, 0, 0, 0, 64, 0, 0, 0, 45, 0, 0, 32, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 228, 1,
0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 85, 0, 0, 0, 0, 0, 0, 244, 1, 0, 0, 36, 0, 0, 0, 12,
85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 2, 0, 0, 0, 0, 0, 0,
101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95, 77, 111, 100, 117, 108,
2, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16, 0, 0, 0, 97, 116, 105, 111, 110, 0, 171, 171, 171, 1, 0, 3, 0, 1, 0,
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 54, 0, 0, 8, 194, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116,
0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 97, 110, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 65, 120, 105,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 115, 0, 171, 171, 1, 0, 2, 0, 1, 0, 2, 0, 0, 0, 0,
7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95,
0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5, 114, 70, 108, 105, 99, 107, 101, 114, 83, 116, 97, 114, 116, 84, 104, 114,
32, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0, 101, 115, 104, 111, 108, 100, 0, 0, 0, 2, 0, 1, 0, 1, 0,
54, 0, 0, 5, 130, 32, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110,
0, 0, 0, 128, 63, 62, 0, 0, 1, 83, 84, 65, 84, 116, 0, 116, 115, 95, 70, 108, 105, 99, 107, 101, 114, 69, 110, 100, 84, 104,
0, 0, 6, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 114, 101, 115, 104, 111, 108, 100, 0, 99, 111, 110, 115, 116, 97, 110,
116, 115, 95, 68, 101, 115, 97, 116, 117, 114, 97, 116, 105, 111, 110,
0, 171, 171, 171, 0, 0, 3, 0, 1, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95,
85, 110, 117, 115, 101, 100, 0, 171, 171, 171, 1, 0, 3, 0, 1,
0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 105, 99, 114,
111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72, 76, 83, 76, 32,
83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, 114,
32, 49, 48, 46, 49, 0, 73, 83, 71, 78, 80, 0, 0, 0, 2,
0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0,
0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0,
0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 83, 86, 95, 80, 79,
83, 73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79, 79, 82, 68,
0, 171, 171, 171, 79, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0,
0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 83,
86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83, 72, 68, 82,
232, 3, 0, 0, 64, 0, 0, 0, 250, 0, 0, 0, 89, 0, 0,
4, 70, 142, 32, 0, 0, 0, 0, 0, 3, 0, 0, 0, 88, 24,
0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 85, 85, 0, 0, 98,
16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0, 101, 0, 0, 3,
242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0, 2, 3, 0, 0,
0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0, 0, 0, 70, 16,
16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16, 0, 0,
0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 54, 0, 0, 8,
194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0,
0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14, 16, 0, 0,
0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 56, 0, 0, 9,
242, 0, 16, 0, 2, 0, 0, 0, 70, 142, 32, 0, 0, 0, 0,
0, 0, 0, 0, 0, 70, 142, 32, 0, 0, 0, 0, 0, 0, 0,
0, 0, 54, 0, 0, 5, 130, 0, 16, 0, 1, 0, 0, 0, 1,
64, 0, 0, 0, 0, 128, 63, 56, 0, 0, 7, 242, 0, 16, 0,
1, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0, 0, 70, 14, 16,
0, 2, 0, 0, 0, 38, 0, 0, 9, 0, 208, 0, 0, 50, 0,
16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 70,
128, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0, 30, 0, 0, 7,
18, 0, 16, 0, 0, 0, 0, 0, 26, 0, 16, 0, 0, 0, 0,
0, 10, 0, 16, 0, 0, 0, 0, 0, 34, 0, 0, 8, 34, 0,
16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0, 0, 42,
128, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0, 33, 0, 0, 8,
18, 0, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0,
0, 58, 128, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0, 55, 0,
0, 12, 242, 0, 16, 0, 1, 0, 0, 0, 86, 5, 16, 0, 0,
0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0,
0, 60, 0, 0, 7, 18, 0, 16, 0, 0, 0, 0, 0, 10, 0,
16, 0, 0, 0, 0, 0, 26, 0, 16, 0, 0, 0, 0, 0, 55,
0, 0, 12, 242, 0, 16, 0, 0, 0, 0, 0, 6, 0, 16, 0,
0, 0, 0, 0, 70, 14, 16, 0, 1, 0, 0, 0, 2, 64, 0,
0, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 128, 63, 0, 0,
128, 63, 29, 0, 0, 7, 18, 0, 16, 0, 1, 0, 0, 0, 1,
64, 0, 0, 0, 0, 0, 0, 58, 0, 16, 0, 0, 0, 0, 0,
13, 0, 4, 3, 10, 0, 16, 0, 1, 0, 0, 0, 57, 0, 0,
8, 18, 0, 16, 0, 1, 0, 0, 0, 10, 128, 32, 0, 0, 0,
0, 0, 2, 0, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 16,
0, 0, 10, 34, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0,
0, 0, 0, 0, 2, 64, 0, 0, 154, 153, 153, 62, 154, 153, 25,
63, 205, 204, 204, 61, 0, 0, 0, 0, 0, 0, 0, 9, 66, 0,
16, 0, 1, 0, 0, 0, 10, 128, 32, 128, 65, 0, 0, 0, 0,
0, 0, 0, 2, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63,
56, 0, 0, 8, 34, 0, 16, 0, 1, 0, 0, 0, 26, 0, 16,
0, 1, 0, 0, 0, 10, 128, 32, 0, 0, 0, 0, 0, 2, 0,
0, 0, 50, 0, 0, 9, 226, 0, 16, 0, 1, 0, 0, 0, 6,
9, 16, 0, 0, 0, 0, 0, 166, 10, 16, 0, 1, 0, 0, 0,
86, 5, 16, 0, 1, 0, 0, 0, 55, 32, 0, 9, 114, 0, 16,
0, 0, 0, 0, 0, 6, 0, 16, 0, 1, 0, 0, 0, 150, 7,
16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0, 47,
0, 0, 5, 114, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0,
0, 0, 0, 0, 56, 0, 0, 10, 114, 0, 16, 0, 0, 0, 0,
0, 70, 2, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 102, 102,
230, 63, 102, 102, 230, 63, 102, 102, 230, 63, 0, 0, 0, 0, 25,
0, 0, 5, 114, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0,
0, 0, 0, 0, 56, 0, 0, 10, 114, 0, 16, 0, 1, 0, 0,
0, 86, 5, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 150, 246,
160, 189, 43, 199, 117, 63, 40, 177, 243, 60, 0, 0, 0, 0, 50,
0, 0, 12, 114, 0, 16, 0, 1, 0, 0, 0, 6, 0, 16, 0,
0, 0, 0, 0, 2, 64, 0, 0, 87, 203, 136, 63, 86, 131, 197,
60, 225, 104, 227, 58, 0, 0, 0, 0, 70, 2, 16, 0, 1, 0,
0, 0, 50, 0, 0, 12, 114, 32, 16, 0, 0, 0, 0, 0, 166,
10, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0, 5, 9, 34, 60,
158, 151, 129, 60, 194, 240, 119, 63, 0, 0, 0, 0, 70, 2, 16,
0, 1, 0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0, 0,
0, 0, 58, 0, 16, 0, 0, 0, 0, 0, 62, 0, 0, 1, 83,
84, 65, 84, 116, 0, 0, 0, 30, 0, 0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 2, 0, 0, 0, 15, 0, 0, 0, 4, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0,
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}; };
namespace GpBinarizedShaders namespace GpBinarizedShaders

View File

@@ -1205,14 +1205,12 @@ void GpDisplayDriverD3D11::Shutdown()
free(this); free(this);
} }
void GpDisplayDriverD3D11::GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *pixelFormat) void GpDisplayDriverD3D11::GetDisplayResolution(unsigned int *width, unsigned int *height)
{ {
if (width) if (width)
*width = m_windowWidthVirtual; *width = m_windowWidthVirtual;
if (height) if (height)
*height = m_windowHeightVirtual; *height = m_windowHeightVirtual;
if (pixelFormat)
*pixelFormat = GpPixelFormats::k8BitStandard;
} }
IGpDisplayDriverSurface *GpDisplayDriverD3D11::CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) IGpDisplayDriverSurface *GpDisplayDriverD3D11::CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat)
@@ -1424,6 +1422,11 @@ void GpDisplayDriverD3D11::RequestToggleFullScreen(uint32_t timestamp)
} }
} }
const GpDisplayDriverProperties &GpDisplayDriverD3D11::GetProperties() const
{
return m_properties;
}
GpDisplayDriverD3D11 *GpDisplayDriverD3D11::Create(const GpDisplayDriverProperties &properties) GpDisplayDriverD3D11 *GpDisplayDriverD3D11::Create(const GpDisplayDriverProperties &properties)
{ {
void *storage = malloc(sizeof(GpDisplayDriverD3D11)); void *storage = malloc(sizeof(GpDisplayDriverD3D11));

View File

@@ -36,7 +36,7 @@ public:
void Run() override; void Run() override;
void Shutdown() override; void Shutdown() override;
void GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *bpp) override; void GetDisplayResolution(unsigned int *width, unsigned int *height) override;
IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) override; IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) override;
void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) override; void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) override;
@@ -51,6 +51,8 @@ public:
void RequestToggleFullScreen(uint32_t timestamp) override; void RequestToggleFullScreen(uint32_t timestamp) override;
const GpDisplayDriverProperties &GetProperties() const override;
static GpDisplayDriverD3D11 *Create(const GpDisplayDriverProperties &properties); static GpDisplayDriverD3D11 *Create(const GpDisplayDriverProperties &properties);
private: private:

View File

@@ -1,6 +1,9 @@
#include "AntiAliasTable.h" #include "AntiAliasTable.h"
#include "RGBAColor.h" #include "RGBAColor.h"
#include <algorithm>
#include <math.h>
// TODO: This is not gamma correct... // TODO: This is not gamma correct...
namespace PortabilityLayer namespace PortabilityLayer
{ {
@@ -116,5 +119,29 @@ namespace PortabilityLayer
} }
} }
} }
void AntiAliasTable::GenerateForSimpleScale(uint8_t colorChannel)
{
const double gamma = 1.8;
const double rcpGamma = 1.0 / gamma;
const double rcp255 = 1.0 / 255.0;
const double rcp15 = 1.0 / 15.0;
double colorChannelLinear = pow(colorChannel * rcp255, gamma);
for (size_t baseColor = 0; baseColor < 256; baseColor++)
{
const double baseColorLinear = pow(baseColor * rcp255, gamma);
for (size_t opacity = 0; opacity < 16; opacity++)
{
const double opacityF = static_cast<double>(opacity) * rcp15;
const double blendedColor = colorChannelLinear * opacityF + (1.0 - opacityF) * baseColorLinear;
const double blendedColorGammaSpace = pow(std::min(std::max(0.0, blendedColor), 1.0), rcpGamma);
m_aaTranslate[baseColor][opacity] = static_cast<uint8_t>(floor(blendedColorGammaSpace * 255.0 + 0.5));
}
}
}
#endif #endif
} }

View File

@@ -12,5 +12,6 @@ namespace PortabilityLayer
uint8_t m_aaTranslate[256][16]; uint8_t m_aaTranslate[256][16];
void GenerateForPalette(const RGBAColor &baseColor, const RGBAColor *colors, size_t numColors); void GenerateForPalette(const RGBAColor &baseColor, const RGBAColor *colors, size_t numColors);
void GenerateForSimpleScale(uint8_t colorChannel);
}; };
} }

View File

@@ -830,7 +830,7 @@ namespace PortabilityLayer
void DialogManagerImpl::PositionWindow(Window *window, const Rect &rect) const void DialogManagerImpl::PositionWindow(Window *window, const Rect &rect) const
{ {
unsigned int displayWidth, displayHeight; unsigned int displayWidth, displayHeight;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight, nullptr); PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&displayWidth, &displayHeight);
const unsigned int halfDisplayHeight = displayHeight / 2; const unsigned int halfDisplayHeight = displayHeight / 2;
const unsigned int quarterDisplayWidth = displayHeight / 4; const unsigned int quarterDisplayWidth = displayHeight / 4;

View File

@@ -16,6 +16,7 @@ namespace PortabilityLayer
void Init() override; void Init() override;
void Shutdown() override; void Shutdown() override;
void SetPixelFormat(GpPixelFormat_t pixelFormat) override;
GpPixelFormat_t GetPixelFormat() const override; GpPixelFormat_t GetPixelFormat() const override;
void SyncPalette(IGpDisplayDriver *displayDriver) override; void SyncPalette(IGpDisplayDriver *displayDriver) override;
@@ -62,8 +63,6 @@ namespace PortabilityLayer
void DisplayDeviceManagerImpl::Init() void DisplayDeviceManagerImpl::Init()
{ {
HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, nullptr, &m_pixelFormat);
const PortabilityLayer::RGBAColor *spColors = StandardPalette::GetInstance()->GetColors(); const PortabilityLayer::RGBAColor *spColors = StandardPalette::GetInstance()->GetColors();
for (size_t i = 0; i < 256; i++) for (size_t i = 0; i < 256; i++)
m_palette[i] = spColors[i]; m_palette[i] = spColors[i];
@@ -75,6 +74,11 @@ namespace PortabilityLayer
{ {
} }
void DisplayDeviceManagerImpl::SetPixelFormat(GpPixelFormat_t pixelFormat)
{
m_pixelFormat = pixelFormat;
}
GpPixelFormat_t DisplayDeviceManagerImpl::GetPixelFormat() const GpPixelFormat_t DisplayDeviceManagerImpl::GetPixelFormat() const
{ {
return m_pixelFormat; return m_pixelFormat;

View File

@@ -21,6 +21,7 @@ namespace PortabilityLayer
virtual void Init() = 0; virtual void Init() = 0;
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
virtual void SetPixelFormat(GpPixelFormat_t pixelFormat) = 0;
virtual GpPixelFormat_t GetPixelFormat() const = 0; virtual GpPixelFormat_t GetPixelFormat() const = 0;
virtual void SyncPalette(IGpDisplayDriver *displayDriver) = 0; virtual void SyncPalette(IGpDisplayDriver *displayDriver) = 0;

View File

@@ -1,6 +1,9 @@
#include "IconLoader.h" #include "IconLoader.h"
#include "DisplayDeviceManager.h"
#include "PLCore.h" #include "PLCore.h"
#include "PLCTabReducer.h" #include "PLCTabReducer.h"
#include "PLStandardColors.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "QDStandardPalette.h" #include "QDStandardPalette.h"
#include "QDPixMap.h" #include "QDPixMap.h"
@@ -119,8 +122,12 @@ namespace PortabilityLayer
return false; return false;
uint8_t remapping[256]; uint8_t remapping[256];
PortabilityLayer::RGBAColor palette[256];
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{
remapping[i] = 0; remapping[i] = 0;
palette[i] = StdColors::Black();
}
for (size_t i = 0; i < numItems; i++) for (size_t i = 0; i < numItems; i++)
{ {
@@ -133,6 +140,7 @@ namespace PortabilityLayer
return false; return false;
const PortabilityLayer::RGBAColor remappedColor = CTabReducer::DecodeClutItem(ctabItem); const PortabilityLayer::RGBAColor remappedColor = CTabReducer::DecodeClutItem(ctabItem);
palette[i] = remappedColor;
remapping[index] = StandardPalette::GetInstance()->MapColorLUT(remappedColor); remapping[index] = StandardPalette::GetInstance()->MapColorLUT(remappedColor);
} }
@@ -141,7 +149,9 @@ namespace PortabilityLayer
if (!rect.IsValid()) if (!rect.IsValid())
return false; return false;
THandle<PixMapImpl> pixMap = PixMapImpl::Create(rect, GpPixelFormats::k8BitStandard); GpPixelFormat_t pixelFormat = DisplayDeviceManager::GetInstance()->GetPixelFormat();
THandle<PixMapImpl> pixMap = PixMapImpl::Create(rect, pixelFormat);
if (!pixMap) if (!pixMap)
return false; return false;
@@ -152,49 +162,117 @@ namespace PortabilityLayer
uint8_t *outData = static_cast<uint8_t*>((*pixMap)->GetPixelData()); uint8_t *outData = static_cast<uint8_t*>((*pixMap)->GetPixelData());
const size_t outPitch = (*pixMap)->GetPitch(); const size_t outPitch = (*pixMap)->GetPitch();
for (size_t row = 0; row < height; row++) if (pixelFormat == GpPixelFormats::k8BitStandard)
{ {
if (numItems > 16) for (size_t row = 0; row < height; row++)
{ {
// 8bpp if (numItems > 16)
for (size_t col = 0; col < width; col++)
{ {
const unsigned int index = inData[col]; // 8bpp
outData[col] = remapping[index]; for (size_t col = 0; col < width; col++)
{
const unsigned int index = inData[col];
outData[col] = remapping[index];
}
} }
} else if (numItems > 4)
else if (numItems > 4)
{
// 4bpp
for (size_t col = 0; col < width; col++)
{ {
const unsigned int index = (inData[col / 2] >> (4 - ((col & 1) * 4))) & 0x0f; // 4bpp
outData[col] = remapping[index]; for (size_t col = 0; col < width; col++)
{
const unsigned int index = (inData[col / 2] >> (4 - ((col & 1) * 4))) & 0x0f;
outData[col] = remapping[index];
}
} }
} else if (numItems > 2)
else if (numItems > 2)
{
// 2bpp
for (size_t col = 0; col < width; col++)
{ {
const unsigned int index = (inData[col / 4] >> (6 - ((col & 3) * 2))) & 0x03; // 2bpp
outData[col] = remapping[index]; for (size_t col = 0; col < width; col++)
{
const unsigned int index = (inData[col / 4] >> (6 - ((col & 3) * 2))) & 0x03;
outData[col] = remapping[index];
}
} }
} else
else
{
// 1bpp
for (size_t col = 0; col < width; col++)
{ {
const unsigned int index = (inData[col / 4] >> (7 - (col & 7))) & 0x01; // 1bpp
outData[col] = remapping[index]; for (size_t col = 0; col < width; col++)
{
const unsigned int index = (inData[col / 4] >> (7 - (col & 7))) & 0x01;
outData[col] = remapping[index];
}
} }
}
inData += inPitch; inData += inPitch;
outData += outPitch; outData += outPitch;
}
} }
else if (pixelFormat == GpPixelFormats::kRGB32)
{
for (size_t row = 0; row < height; row++)
{
if (numItems > 16)
{
// 8bpp
for (size_t col = 0; col < width; col++)
{
const unsigned int index = inData[col];
const PortabilityLayer::RGBAColor &color = palette[index];
outData[col * 4 + 0] = color.r;
outData[col * 4 + 1] = color.g;
outData[col * 4 + 2] = color.b;
outData[col * 4 + 3] = 255;
}
}
else if (numItems > 4)
{
// 4bpp
for (size_t col = 0; col < width; col++)
{
const unsigned int index = (inData[col / 2] >> (4 - ((col & 1) * 4))) & 0x0f;
const PortabilityLayer::RGBAColor &color = palette[index];
outData[col * 4 + 0] = color.r;
outData[col * 4 + 1] = color.g;
outData[col * 4 + 2] = color.b;
outData[col * 4 + 3] = 255;
}
}
else if (numItems > 2)
{
// 2bpp
for (size_t col = 0; col < width; col++)
{
const unsigned int index = (inData[col / 4] >> (6 - ((col & 3) * 2))) & 0x03;
const PortabilityLayer::RGBAColor &color = palette[index];
outData[col * 4 + 0] = color.r;
outData[col * 4 + 1] = color.g;
outData[col * 4 + 2] = color.b;
outData[col * 4 + 3] = 255;
}
}
else
{
// 1bpp
for (size_t col = 0; col < width; col++)
{
const unsigned int index = (inData[col / 4] >> (7 - (col & 7))) & 0x01;
const PortabilityLayer::RGBAColor &color = palette[index];
outData[col * 4 + 0] = color.r;
outData[col * 4 + 1] = color.g;
outData[col * 4 + 2] = color.b;
outData[col * 4 + 3] = 255;
}
}
inData += inPitch;
outData += outPitch;
}
}
else
{
PL_NotYetImplemented();
}
outHandle = pixMap; outHandle = pixMap;
dataPtr = inData; dataPtr = inData;
@@ -245,7 +323,10 @@ namespace PortabilityLayer
return THandle<PixMapImpl>(); return THandle<PixMapImpl>();
const Rect rect = Rect::Create(0, 0, 32, 32); const Rect rect = Rect::Create(0, 0, 32, 32);
THandle<PixMapImpl> pixMap = PixMapImpl::Create(rect, GpPixelFormats::k8BitStandard);
GpPixelFormat_t pixelFormat = DisplayDeviceManager::GetInstance()->GetPixelFormat();
THandle<PixMapImpl> pixMap = PixMapImpl::Create(rect, pixelFormat);
if (!pixMap) if (!pixMap)
return THandle<PixMapImpl>(); return THandle<PixMapImpl>();
@@ -253,13 +334,34 @@ namespace PortabilityLayer
uint8_t *outData = static_cast<uint8_t*>((*pixMap)->GetPixelData()); uint8_t *outData = static_cast<uint8_t*>((*pixMap)->GetPixelData());
const size_t outPitch = (*pixMap)->GetPitch(); const size_t outPitch = (*pixMap)->GetPitch();
for (size_t row = 0; row < 32; row++) if (pixelFormat == GpPixelFormats::kRGB32)
{ {
for (size_t col = 0; col < 32; col++) const PortabilityLayer::RGBAColor *palette = StandardPalette::GetInstance()->GetColors();
outData[col] = inData[col];
inData += 32; for (size_t row = 0; row < 32; row++)
outData += outPitch; {
uint32_t *outU32 = reinterpret_cast<uint32_t*>(outData);
for (size_t col = 0; col < 32; col++)
outU32[col] = palette[inData[col]].AsUInt32();
inData += 32;
outData += outPitch;
}
}
else if (pixelFormat == GpPixelFormats::k8BitStandard)
{
for (size_t row = 0; row < 32; row++)
{
for (size_t col = 0; col < 32; col++)
outData[col] = inData[col];
inData += 32;
outData += outPitch;
}
}
else
{
PL_NotYetImplemented();
} }
return pixMap; return pixMap;

View File

@@ -819,8 +819,9 @@ namespace PortabilityLayer
} }
unsigned int width; unsigned int width;
GpPixelFormat_t pixelFormat; HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, nullptr);
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(&width, nullptr, &pixelFormat);
GpPixelFormat_t pixelFormat = DisplayDeviceManager::GetInstance()->GetPixelFormat();
PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance(); PortabilityLayer::QDManager *qdManager = PortabilityLayer::QDManager::GetInstance();
@@ -1310,7 +1311,7 @@ namespace PortabilityLayer
int32_t popupBottom = m_popupPosition.m_y + menu->layoutFinalHeight; int32_t popupBottom = m_popupPosition.m_y + menu->layoutFinalHeight;
unsigned int displayHeight = 0; unsigned int displayHeight = 0;
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight, nullptr); PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, &displayHeight);
if (popupBottom > static_cast<int32_t>(displayHeight)) if (popupBottom > static_cast<int32_t>(displayHeight))
m_popupPosition.m_y -= popupBottom - static_cast<int32_t>(displayHeight); m_popupPosition.m_y -= popupBottom - static_cast<int32_t>(displayHeight);
} }
@@ -1397,8 +1398,7 @@ namespace PortabilityLayer
if (m_menuGraf == nullptr) if (m_menuGraf == nullptr)
{ {
GpPixelFormat_t pixelFormat; GpPixelFormat_t pixelFormat = DisplayDeviceManager::GetInstance()->GetPixelFormat();
PortabilityLayer::HostDisplayDriver::GetInstance()->GetDisplayResolution(nullptr, nullptr, &pixelFormat);
if (qdManager->NewGWorld(&m_menuGraf, pixelFormat, menuRect, nullptr) != 0) if (qdManager->NewGWorld(&m_menuGraf, pixelFormat, menuRect, nullptr) != 0)
return; return;

File diff suppressed because it is too large Load Diff

View File

@@ -8,8 +8,8 @@
DrawSurface::~DrawSurface() DrawSurface::~DrawSurface()
{ {
if (m_cachedAATable) if (m_cachedAATables)
PortabilityLayer::MemoryManager::GetInstance()->Release(m_cachedAATable); PortabilityLayer::MemoryManager::GetInstance()->Release(m_cachedAATables);
} }
void DrawSurface::PushToDDSurface(IGpDisplayDriver *displayDriver) void DrawSurface::PushToDDSurface(IGpDisplayDriver *displayDriver)

View File

@@ -32,7 +32,7 @@ struct DrawSurface
: m_port(PortabilityLayer::QDPortType_DrawSurface) : m_port(PortabilityLayer::QDPortType_DrawSurface)
, m_ddSurface(nullptr) , m_ddSurface(nullptr)
, m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255)) , m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
, m_cachedAATable(nullptr) , m_cachedAATables(nullptr)
{ {
} }
@@ -40,7 +40,7 @@ struct DrawSurface
: m_port(overridePortType) : m_port(overridePortType)
, m_ddSurface(nullptr) , m_ddSurface(nullptr)
, m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255)) , m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
, m_cachedAATable(nullptr) , m_cachedAATables(nullptr)
{ {
} }
@@ -85,7 +85,7 @@ struct DrawSurface
IGpDisplayDriverSurface *m_ddSurface; IGpDisplayDriverSurface *m_ddSurface;
PortabilityLayer::AntiAliasTable *m_cachedAATable; PortabilityLayer::AntiAliasTable *m_cachedAATables;
PortabilityLayer::RGBAColor m_cachedAAColor; PortabilityLayer::RGBAColor m_cachedAAColor;
PortabilityLayer::QDPort m_port; PortabilityLayer::QDPort m_port;

View File

@@ -1,9 +1,12 @@
#include "QDPixMap.h" #include "QDPixMap.h"
#include "CoreDefs.h" #include "CoreDefs.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "QDStandardPalette.h"
#include <assert.h> #include <assert.h>
static const PortabilityLayer::RGBAColor *gs_staticPalette = PortabilityLayer::StandardPalette::GetInstance()->GetColors();
class PixMapSampler_8BitStandard class PixMapSampler_8BitStandard
{ {
public: public:
@@ -11,6 +14,26 @@ public:
{ {
return static_cast<const uint8_t*>(rowData)[index]; return static_cast<const uint8_t*>(rowData)[index];
} }
inline static uint32_t ReadAsRGBA(const void *rowData, size_t index)
{
return gs_staticPalette[static_cast<const uint8_t*>(rowData)[index]].AsUInt32();
}
};
class PixMapSampler_32Bit
{
public:
inline static uint8_t ReadAs8BitStandard(const void *rowData, size_t index)
{
const uint8_t *pixelData = static_cast<const uint8_t*>(rowData) + index * 4;
return PortabilityLayer::StandardPalette::GetInstance()->MapColorLUT(PortabilityLayer::RGBAColor::Create(pixelData[0], pixelData[1], pixelData[2], 255));
}
inline static uint32_t ReadAsRGBA(const void *rowData, size_t index)
{
return static_cast<const uint32_t*>(rowData)[index];
}
}; };
template<class TSampler> template<class TSampler>
@@ -23,6 +46,16 @@ public:
} }
}; };
template<class TSampler>
class PixMapCopier_32Bit
{
public:
inline static void Copy(const void *inData, size_t inIndex, void *outData, size_t outIndex)
{
static_cast<uint32_t*>(outData)[outIndex] = TSampler::ReadAsRGBA(inData, inIndex);
}
};
template<class TCopier> template<class TCopier>
class PixMapColBlitter class PixMapColBlitter
{ {
@@ -139,6 +172,9 @@ public:
case GpPixelFormats::k8BitStandard: case GpPixelFormats::k8BitStandard:
blitFunc = PixMapRowBlitter<PixMapCopier_8BitStandard<TSampler> >::Blit; blitFunc = PixMapRowBlitter<PixMapCopier_8BitStandard<TSampler> >::Blit;
break; break;
case GpPixelFormats::kRGB32:
blitFunc = PixMapRowBlitter<PixMapCopier_32Bit<TSampler> >::Blit;
break;
default: default:
PL_NotYetImplemented(); PL_NotYetImplemented();
break; break;
@@ -163,6 +199,9 @@ public:
case GpPixelFormats::k8BitStandard: case GpPixelFormats::k8BitStandard:
blitFunc = PixMapBlitTargetDisambiguator<PixMapSampler_8BitStandard>::Blit; blitFunc = PixMapBlitTargetDisambiguator<PixMapSampler_8BitStandard>::Blit;
break; break;
case GpPixelFormats::kRGB32:
blitFunc = PixMapBlitTargetDisambiguator<PixMapSampler_32Bit>::Blit;
break;
default: default:
PL_NotYetImplemented(); PL_NotYetImplemented();
break; break;

View File

@@ -115,6 +115,9 @@ namespace PortabilityLayer
m_blackAATable.GenerateForPalette(RGBAColor::Create(0, 0, 0, 255), m_colors, 256); m_blackAATable.GenerateForPalette(RGBAColor::Create(0, 0, 0, 255), m_colors, 256);
m_whiteAATable.GenerateForPalette(RGBAColor::Create(255, 255, 255, 255), m_colors, 256); m_whiteAATable.GenerateForPalette(RGBAColor::Create(255, 255, 255, 255), m_colors, 256);
#endif #endif
m_whiteToneAATable.GenerateForSimpleScale(255);
m_blackToneAATable.GenerateForSimpleScale(0);
} }
const RGBAColor *StandardPalette::GetColors() const const RGBAColor *StandardPalette::GetColors() const
@@ -273,5 +276,15 @@ namespace PortabilityLayer
return m_blackAATable; return m_blackAATable;
} }
const AntiAliasTable &StandardPalette::GetWhiteToneAATable() const
{
return m_whiteToneAATable;
}
const AntiAliasTable &StandardPalette::GetBlackToneAATable() const
{
return m_blackToneAATable;
}
StandardPalette StandardPalette::ms_instance; StandardPalette StandardPalette::ms_instance;
} }

View File

@@ -23,6 +23,9 @@ namespace PortabilityLayer
const AntiAliasTable &GetWhiteAATable() const; const AntiAliasTable &GetWhiteAATable() const;
const AntiAliasTable &GetBlackAATable() const; const AntiAliasTable &GetBlackAATable() const;
const AntiAliasTable &GetWhiteToneAATable() const;
const AntiAliasTable &GetBlackToneAATable() const;
static const StandardPalette *GetInstance(); static const StandardPalette *GetInstance();
private: private:
@@ -31,6 +34,8 @@ namespace PortabilityLayer
RGBAColor m_colors[kSize]; RGBAColor m_colors[kSize];
AntiAliasTable m_whiteAATable; AntiAliasTable m_whiteAATable;
AntiAliasTable m_blackAATable; AntiAliasTable m_blackAATable;
AntiAliasTable m_whiteToneAATable;
AntiAliasTable m_blackToneAATable;
uint8_t m_lut[16 * 16 * 16]; uint8_t m_lut[16 * 16 * 16];
}; };
} }

View File

@@ -10,7 +10,9 @@ namespace PortabilityLayer
bool operator==(const RGBAColor &other) const; bool operator==(const RGBAColor &other) const;
bool operator!=(const RGBAColor &other) const; bool operator!=(const RGBAColor &other) const;
static RGBAColor Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a); static RGBAColor Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
uint32_t AsUInt32() const;
}; };
inline RGBAColor RGBAColor::Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a) inline RGBAColor RGBAColor::Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
@@ -32,5 +34,16 @@ namespace PortabilityLayer
inline bool RGBAColor::operator!=(const RGBAColor &other) const inline bool RGBAColor::operator!=(const RGBAColor &other) const
{ {
return !((*this) == other); return !((*this) == other);
} }
inline uint32_t RGBAColor::AsUInt32() const
{
uint32_t rgbaColor = 0;
uint8_t *rgbaColorBytes = reinterpret_cast<uint8_t*>(&rgbaColor);
rgbaColorBytes[0] = r;
rgbaColorBytes[1] = g;
rgbaColorBytes[2] = b;
rgbaColorBytes[3] = a;
return rgbaColor;
}
} }

View File

@@ -92,6 +92,42 @@ namespace PortabilityLayer
} }
} }
break; break;
case GpPixelFormats::kRGB32:
{
uint8_t *destFirstPixel = static_cast<uint8_t*>(pixMapData) + destXOffset * 4 + destYOffset * destPitch;
const PortabilityLayer::RGBAColor *srcPixel = m_pixelData;
for (size_t row = 0; row < srcHeight; row++)
{
uint8_t *destRowFirstPixel = destFirstPixel + row * destPitch;
if (maskData)
{
for (size_t col = 0; col < srcWidth; col++)
{
if (maskData[maskOffset / 8] & (0x80 >> (maskOffset & 7)))
{
destRowFirstPixel[col * 4 + 0] = srcPixel->r;
destRowFirstPixel[col * 4 + 1] = srcPixel->g;
destRowFirstPixel[col * 4 + 2] = srcPixel->b;
}
srcPixel++;
maskOffset++;
}
}
else
{
for (size_t col = 0; col < srcWidth; col++)
{
destRowFirstPixel[col * 4 + 0] = srcPixel->r;
destRowFirstPixel[col * 4 + 1] = srcPixel->g;
destRowFirstPixel[col * 4 + 2] = srcPixel->b;
srcPixel++;
}
}
}
}
break;
default: default:
PL_NotYetImplemented(); PL_NotYetImplemented();
break; break;

View File

@@ -839,6 +839,9 @@ namespace PortabilityLayer
if (int errorCode = m_surface.Init(adjustedBounds, pixelFormat)) if (int errorCode = m_surface.Init(adjustedBounds, pixelFormat))
return false; return false;
PortabilityLayer::ResolveCachingColor whiteColor = StdColors::White();
m_surface.FillRect(adjustedBounds, whiteColor);
m_title.Set(windowDef.m_title[0], reinterpret_cast<const char*>(windowDef.m_title + 1)); m_title.Set(windowDef.m_title[0], reinterpret_cast<const char*>(windowDef.m_title + 1));
// Resolve chrome // Resolve chrome

View File

@@ -1,4 +1,6 @@
#include "DrawQuad.h" #include "DrawQuad.h"
#include "DrawQuadPixelConstants.h"
#include "Functions.h"
SamplerState surfaceSampler : register(s0); SamplerState surfaceSampler : register(s0);
Texture2D<float3> surfaceTexture : register(t0); Texture2D<float3> surfaceTexture : register(t0);
@@ -8,11 +10,24 @@ struct SDrawQuadPixelOutput
float4 color : SV_TARGET; float4 color : SV_TARGET;
}; };
float3 SamplePixel(int2 texCoord)
{
return surfaceTexture.Load(int3(texCoord, 0));
}
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input) SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
{ {
float3 surfaceColor = surfaceTexture.Load(int3(input.texCoord.xy, 0)).rgb;
SDrawQuadPixelOutput result; SDrawQuadPixelOutput result;
result.color = float4(surfaceColor, 1.0); int2 pixelCoordinate = int2(floor(input.texCoord.xy));
result.color = float4(SamplePixel(int2(floor(input.texCoord.xy))), 1.0);
result.color *= constants_Modulation;
result.color = ApplyFlicker(pixelCoordinate, constants_FlickerStartThreshold, constants_FlickerEndThreshold, result.color * constants_Modulation);
result.color = ApplyDesaturation(constants_Desaturation, result.color);
if (result.color.a <= 0.0)
discard;
result.color.rgb = AppleRGBToSRGBLinear(result.color.rgb);
return result; return result;
} }