diff --git a/ApplicationResourcePatches/PICT/1976.bmp b/ApplicationResourcePatches/PICT/1976.bmp index 301a28b..22b2156 100644 Binary files a/ApplicationResourcePatches/PICT/1976.bmp and b/ApplicationResourcePatches/PICT/1976.bmp differ diff --git a/ApplicationResourcePatches/PICT/1977.bmp b/ApplicationResourcePatches/PICT/1977.bmp index 7023eb1..d1a5ee1 100644 Binary files a/ApplicationResourcePatches/PICT/1977.bmp and b/ApplicationResourcePatches/PICT/1977.bmp differ diff --git a/GpApp/Externs.h b/GpApp/Externs.h index 6b64211..a8cf92c 100644 --- a/GpApp/Externs.h +++ b/GpApp/Externs.h @@ -201,6 +201,7 @@ short RandomInt (short); long RandomLong (long); void RedAlert (short); void LoadGraphic (DrawSurface *surface, short resID); // Only loads from app resources +void LoadGraphicNoDither (DrawSurface *surface, short resID); void LoadGraphicCustom (DrawSurface *surface, short resID); // Supports custom graphics void LoadScaledGraphic (DrawSurface *, short, Rect *); // Only loads from app resources void LoadScaledGraphicCustom (DrawSurface *, short, Rect *); // Supports custom graphics diff --git a/GpApp/GliderStructs.h b/GpApp/GliderStructs.h index d36c589..328c595 100644 --- a/GpApp/GliderStructs.h +++ b/GpApp/GliderStructs.h @@ -439,8 +439,8 @@ namespace touchScreenControlGraphics BandsDisabled, BandsActive, BandsIdle, - FlipActive, - FlipIdle, + StopActive, + StopIdle, MoveRightActive, MoveRightIdle, MoveLeftActive, diff --git a/GpApp/Input.cpp b/GpApp/Input.cpp index c022355..a7fa33f 100644 --- a/GpApp/Input.cpp +++ b/GpApp/Input.cpp @@ -494,6 +494,12 @@ void DoHeliumEngaged (gliderPtr thisGlider) if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl))) DoCommandKey(); + // Cheesy - Use touchscreen menu as quit + if (pendingTouchScreenMenu) + { + playing = false; + paused = false; + } #endif } diff --git a/GpApp/Play.cpp b/GpApp/Play.cpp index cd0f00a..70a165e 100644 --- a/GpApp/Play.cpp +++ b/GpApp/Play.cpp @@ -581,7 +581,11 @@ void ResetTouchScreenControlBounds (void) points[TouchScreenCtrlIDs::Movement] = Point::Create(mainWindowRect.left, mainWindowRect.top); points[TouchScreenCtrlIDs::BatteryHelium] = Point::Create(mainWindowRect.left + touchScreenControlEdgeSpacing, mainWindowRect.top + touchScreenControlEdgeSpacing); points[TouchScreenCtrlIDs::Bands] = Point::Create(mainWindowRect.right - touchScreenControlEdgeSpacing - touchScreenControlSize, mainWindowRect.top + touchScreenControlEdgeSpacing); - points[TouchScreenCtrlIDs::Menu] = Point::Create(points[TouchScreenCtrlIDs::Bands].h - touchScreenControlInterSpacing - touchScreenControlSize, points[TouchScreenCtrlIDs::BatteryHelium].v); + + if (demoGoing) + points[TouchScreenCtrlIDs::Menu] = Point::Create(mainWindowRect.right - touchScreenControlEdgeSpacing - touchScreenControlSize, mainWindowRect.top + touchScreenControlEdgeSpacing); + else + points[TouchScreenCtrlIDs::Menu] = Point::Create(points[TouchScreenCtrlIDs::Bands].h - touchScreenControlInterSpacing - touchScreenControlSize, points[TouchScreenCtrlIDs::BatteryHelium].v); for (int i = 0; i < TouchScreenCtrlIDs::Count; i++) sizes[i] = Point::Create(touchScreenControlSize, touchScreenControlSize); @@ -622,7 +626,7 @@ void InitTouchScreenControlState(void) Rect resRect = Rect::Create(0, 0, touchScreenControlSize, touchScreenControlSize); (void)CreateOffScreenGWorld(&touchScreen.graphics[i], &resRect); - LoadGraphic(touchScreen.graphics[i], resID); + LoadGraphicNoDither(touchScreen.graphics[i], resID); } pendingTouchScreenMenu = false; diff --git a/GpApp/Render.cpp b/GpApp/Render.cpp index 46e9f96..3ce5c7c 100644 --- a/GpApp/Render.cpp +++ b/GpApp/Render.cpp @@ -611,43 +611,62 @@ void RenderShreds (void) void RenderTouchScreenControls (void) { - if (demoGoing) - return; - DrawSurface *ctrlGraphics[TouchScreenCtrlIDs::Count]; for (int i = 0; i < TouchScreenCtrlIDs::Count; i++) ctrlGraphics[i] = nullptr; ctrlGraphics[TouchScreenCtrlIDs::Movement] = nullptr; - ctrlGraphics[TouchScreenCtrlIDs::Bands] = touchScreen.graphics[touchScreenControlGraphics::BandsDisabled]; - ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryDisabled]; - ctrlGraphics[TouchScreenCtrlIDs::Menu] = touchScreen.graphics[touchScreenControlGraphics::MenuIdle]; - if (batteryTotal < 0) - ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::HeliumIdle]; - else if (batteryTotal > 0) - ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryIdle]; + if (demoGoing) + { + ctrlGraphics[TouchScreenCtrlIDs::Bands] = nullptr; + ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = nullptr; + ctrlGraphics[TouchScreenCtrlIDs::Menu] = touchScreen.graphics[touchScreenControlGraphics::StopIdle]; + } + else + { + ctrlGraphics[TouchScreenCtrlIDs::Bands] = touchScreen.graphics[touchScreenControlGraphics::BandsDisabled]; + ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryDisabled]; + ctrlGraphics[TouchScreenCtrlIDs::Menu] = touchScreen.graphics[touchScreenControlGraphics::MenuIdle]; - if (bandsTotal > 0) - ctrlGraphics[TouchScreenCtrlIDs::Bands] = touchScreen.graphics[touchScreenControlGraphics::BandsIdle]; + if (batteryTotal < 0) + ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::HeliumIdle]; + else if (batteryTotal > 0) + ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryIdle]; + + if (bandsTotal > 0) + ctrlGraphics[TouchScreenCtrlIDs::Bands] = touchScreen.graphics[touchScreenControlGraphics::BandsIdle]; + } for (int i = 0; i < touchScreenControlState::kMaxFingers; i++) { - if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::BatteryHelium) + if (demoGoing) { - if (batteryTotal < 0) - ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::HeliumActive]; - else if (batteryTotal > 0) - ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryActive]; + if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::Menu) + { + ctrlGraphics[TouchScreenCtrlIDs::Menu] = touchScreen.graphics[touchScreenControlGraphics::StopActive]; + } } - else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::Bands) + else { - if (bandsTotal > 0) - ctrlGraphics[TouchScreenCtrlIDs::Bands] = touchScreen.graphics[touchScreenControlGraphics::BandsActive]; + if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::BatteryHelium) + { + if (batteryTotal < 0) + ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::HeliumActive]; + else if (batteryTotal > 0) + ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryActive]; + } + else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::Bands) + { + if (bandsTotal > 0) + ctrlGraphics[TouchScreenCtrlIDs::Bands] = touchScreen.graphics[touchScreenControlGraphics::BandsActive]; + } + else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::Menu) + { + ctrlGraphics[TouchScreenCtrlIDs::Menu] = touchScreen.graphics[touchScreenControlGraphics::MenuActive]; + } } - else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::Menu) - ctrlGraphics[TouchScreenCtrlIDs::Menu] = touchScreen.graphics[touchScreenControlGraphics::MenuActive]; } for (int i = 0; i < TouchScreenCtrlIDs::Count; i++) diff --git a/GpApp/Utilities.cpp b/GpApp/Utilities.cpp index 0513b93..aee7235 100644 --- a/GpApp/Utilities.cpp +++ b/GpApp/Utilities.cpp @@ -277,6 +277,22 @@ void LoadGraphic (DrawSurface *surface, short resID) thePicture.Dispose(); } +void LoadGraphicNoDither(DrawSurface *surface, short resID) +{ + Rect bounds; + THandle thePicture; + + thePicture = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', resID).StaticCast(); + if (thePicture == nil) + RedAlert(kErrFailedGraphicLoad); + + bounds = (*thePicture)->GetRect(); + OffsetRect(&bounds, -bounds.left, -bounds.top); + surface->DrawPicture(thePicture, bounds, false); + + thePicture.Dispose(); +} + //-------------------------------------------------------------- LoadGraphicCustom // Same as LoadGraphic but supports custom graphics void LoadGraphicCustom(DrawSurface *surface, short resID) diff --git a/PortabilityLayer/PLQDraw.cpp b/PortabilityLayer/PLQDraw.cpp index 2e0bb0a..9ac1760 100644 --- a/PortabilityLayer/PLQDraw.cpp +++ b/PortabilityLayer/PLQDraw.cpp @@ -543,7 +543,7 @@ static void RedistributeError(int16_t *errorDiffusionNextRow, int16_t *errorDiff } } -void DrawSurface::DrawPicture(THandle pictHdl, const Rect &bounds) +void DrawSurface::DrawPicture(THandle pictHdl, const Rect &bounds, bool errorDiffusion) { if (!pictHdl) return; @@ -722,7 +722,7 @@ void DrawSurface::DrawPicture(THandle pictHdl, const Rect &bounds) int16_t *errorDiffusionNextRow = nullptr; int16_t *errorDiffusionCurrentRow = nullptr; - if (bpp == 16 || bpp == 24) + if ((bpp == 16 || bpp == 24) && errorDiffusion) { errorDiffusionBuffer = static_cast(memManager->Alloc(sizeof(int16_t) * numCopyCols * 2 * 3)); if (!errorDiffusionBuffer) @@ -802,31 +802,58 @@ void DrawSurface::DrawPicture(THandle pictHdl, const Rect &bounds) } else { - for (size_t col = 0; col < numCopyCols; col++) + if (!errorDiffusion) { - const size_t srcColIndex = col + firstSourceCol; - const size_t destColIndex = col + firstDestCol; + for (size_t col = 0; col < numCopyCols; col++) + { + const size_t srcColIndex = col + firstSourceCol; + const size_t destColIndex = col + firstDestCol; - const uint8_t srcLow = currentSourceRow[srcColIndex * 2 + 0]; - const uint8_t srcHigh = currentSourceRow[srcColIndex * 2 + 1]; + const uint8_t srcLow = currentSourceRow[srcColIndex * 2 + 0]; + const uint8_t srcHigh = currentSourceRow[srcColIndex * 2 + 1]; - const unsigned int combinedValue = srcLow | (srcHigh << 8); - const unsigned int b = (combinedValue & 0x1f); - const unsigned int g = ((combinedValue >> 5) & 0x1f); - const unsigned int r = ((combinedValue >> 10) & 0x1f); + const unsigned int combinedValue = srcLow | (srcHigh << 8); + const unsigned int b = (combinedValue & 0x1f); + const unsigned int g = ((combinedValue >> 5) & 0x1f); + const unsigned int r = ((combinedValue >> 10) & 0x1f); - const unsigned int xr = (r << 5) | (r >> 2); - const unsigned int xg = (g << 5) | (g >> 2); - const unsigned int xb = (b << 5) | (b >> 2); + const unsigned int xr = (r << 5) | (r >> 2); + const unsigned int xg = (g << 5) | (g >> 2); + const unsigned int xb = (b << 5) | (b >> 2); - ErrorDiffusionWorkPixel wp = ApplyErrorDiffusion(errorDiffusionCurrentRow, xr, xg, xb, col, numCopyCols); + uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(xr, xg, xb, 255)); - uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(wp.m_8[0], wp.m_8[1], wp.m_8[2], 255)); - PortabilityLayer::RGBAColor resultColor = stdPalette->GetColors()[colorIndex]; + currentDestRow[destColIndex] = colorIndex; + } + } + else + { + for (size_t col = 0; col < numCopyCols; col++) + { + const size_t srcColIndex = col + firstSourceCol; + const size_t destColIndex = col + firstDestCol; - RedistributeError(errorDiffusionNextRow, errorDiffusionCurrentRow, wp.m_16[0], wp.m_16[1], wp.m_16[2], resultColor.r, resultColor.g, resultColor.b, col, numCopyCols); + const uint8_t srcLow = currentSourceRow[srcColIndex * 2 + 0]; + const uint8_t srcHigh = currentSourceRow[srcColIndex * 2 + 1]; - currentDestRow[destColIndex] = colorIndex; + const unsigned int combinedValue = srcLow | (srcHigh << 8); + const unsigned int b = (combinedValue & 0x1f); + const unsigned int g = ((combinedValue >> 5) & 0x1f); + const unsigned int r = ((combinedValue >> 10) & 0x1f); + + const unsigned int xr = (r << 5) | (r >> 2); + const unsigned int xg = (g << 5) | (g >> 2); + const unsigned int xb = (b << 5) | (b >> 2); + + ErrorDiffusionWorkPixel wp = ApplyErrorDiffusion(errorDiffusionCurrentRow, xr, xg, xb, col, numCopyCols); + + uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(wp.m_8[0], wp.m_8[1], wp.m_8[2], 255)); + PortabilityLayer::RGBAColor resultColor = stdPalette->GetColors()[colorIndex]; + + RedistributeError(errorDiffusionNextRow, errorDiffusionCurrentRow, wp.m_16[0], wp.m_16[1], wp.m_16[2], resultColor.r, resultColor.g, resultColor.b, col, numCopyCols); + + currentDestRow[destColIndex] = colorIndex; + } } } } @@ -855,19 +882,38 @@ void DrawSurface::DrawPicture(THandle pictHdl, const Rect &bounds) } else { - for (size_t col = 0; col < numCopyCols; col++) + if (!errorDiffusion) { - const size_t srcColIndex = col + firstSourceCol; - const size_t destColIndex = col + firstDestCol; + for (size_t col = 0; col < numCopyCols; col++) + { + const size_t srcColIndex = col + firstSourceCol; + const size_t destColIndex = col + firstDestCol; - ErrorDiffusionWorkPixel wp = ApplyErrorDiffusion(errorDiffusionCurrentRow, currentSourceRow[srcColIndex * 3 + 2], currentSourceRow[srcColIndex * 3 + 1], currentSourceRow[srcColIndex * 3 + 0], col, numCopyCols); + const uint8_t r = currentSourceRow[srcColIndex * 3 + 2]; + const uint8_t g = currentSourceRow[srcColIndex * 3 + 1]; + const uint8_t b = currentSourceRow[srcColIndex * 3 + 0]; - uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(wp.m_8[0], wp.m_8[1], wp.m_8[2], 255)); - PortabilityLayer::RGBAColor resultColor = stdPalette->GetColors()[colorIndex]; + uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(r, g, b, 255)); - RedistributeError(errorDiffusionNextRow, errorDiffusionCurrentRow, wp.m_16[0], wp.m_16[1], wp.m_16[2], resultColor.r, resultColor.g, resultColor.b, col, numCopyCols); + currentDestRow[destColIndex] = colorIndex; + } + } + else + { + for (size_t col = 0; col < numCopyCols; col++) + { + const size_t srcColIndex = col + firstSourceCol; + const size_t destColIndex = col + firstDestCol; - currentDestRow[destColIndex] = colorIndex; + ErrorDiffusionWorkPixel wp = ApplyErrorDiffusion(errorDiffusionCurrentRow, currentSourceRow[srcColIndex * 3 + 2], currentSourceRow[srcColIndex * 3 + 1], currentSourceRow[srcColIndex * 3 + 0], col, numCopyCols); + + uint8_t colorIndex = stdPalette->MapColorLUT(PortabilityLayer::RGBAColor::Create(wp.m_8[0], wp.m_8[1], wp.m_8[2], 255)); + PortabilityLayer::RGBAColor resultColor = stdPalette->GetColors()[colorIndex]; + + RedistributeError(errorDiffusionNextRow, errorDiffusionCurrentRow, wp.m_16[0], wp.m_16[1], wp.m_16[2], resultColor.r, resultColor.g, resultColor.b, col, numCopyCols); + + currentDestRow[destColIndex] = colorIndex; + } } } } diff --git a/PortabilityLayer/QDGraf.h b/PortabilityLayer/QDGraf.h index b9ebd53..1847837 100644 --- a/PortabilityLayer/QDGraf.h +++ b/PortabilityLayer/QDGraf.h @@ -81,7 +81,7 @@ struct DrawSurface void DrawStringConstrained(const Point &point, const PLPasStr &str, const Rect &constraintRect, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font); void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, PortabilityLayer::ResolveCachingColor &cacheColor, PortabilityLayer::RenderedFont *font); - void DrawPicture(THandle pictHandle, const Rect &rect); + void DrawPicture(THandle pictHandle, const Rect &rect, bool errorDiffusion = true); IGpDisplayDriverSurface *m_ddSurface;