home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-25 | 2.9 KB | 129 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CCrashedBehavior.cp ©1999 Eric Traut
- // ===========================================================================
-
- #include "CCrashedBehavior.h"
- #include "CShadowWindow.h"
-
-
- // ---------------------------------------------------------------------------
- // • CCrashedBehavior
- // ---------------------------------------------------------------------------
-
- CCrashedBehavior::CCrashedBehavior(
- CShadowWindow & inShadowWindow)
- : COffscreenBehavior(inShadowWindow, true, true)
- {
- mCrashState = 0;
- }
-
-
- // ---------------------------------------------------------------------------
- // • RenderToGWorld
- // ---------------------------------------------------------------------------
-
- enum
- {
- kPixelsToDrawOK = 3000,
- kPixelsToDrawGarbage = 1500
- };
-
- Boolean
- CCrashedBehavior::RenderToGWorld(
- StGWorldLocker & inBackingLocker,
- StGWorldLocker & inRenderingLocker)
- {
- UInt16 row;
- UInt16 column;
- UInt16 maxRow;
- UInt16 maxColumn;
- UInt16 srcRowWords;
- UInt16 destRowWords;
- UInt16 * srcRowPtr;
- UInt16 * destRowPtr;
- PixMapPtr tempPixMap;
-
- mCrashState += 2;
- if (mCrashState > 50)
- mCrashState = 50;
-
- tempPixMap = *inBackingLocker.GetPixMap();
- srcRowWords = (tempPixMap->rowBytes & 0x3FFF) / 2;
- srcRowPtr = reinterpret_cast<UInt16 *>(tempPixMap->baseAddr);
-
- tempPixMap = *inRenderingLocker.GetPixMap();
- destRowWords = (tempPixMap->rowBytes & 0x3FFF) / 2;
- destRowPtr = reinterpret_cast<UInt16 *>(tempPixMap->baseAddr);
-
- maxRow = tempPixMap->bounds.bottom - tempPixMap->bounds.top;
- maxColumn = tempPixMap->bounds.right - tempPixMap->bounds.left;
-
- UInt16 pixelValue = 0x5252;
- Boolean drawGarbage = false;
- UInt32 pixelsLeft = kPixelsToDrawOK;
-
- // Draw garbage in certain strips
- for (row = 0; row < maxRow; row++)
- {
- for (column = 0; column < maxColumn; column++)
- {
- if (drawGarbage)
- {
- destRowPtr[column] = pixelValue;
- pixelValue *= 13;
-
- if (--pixelsLeft == 0)
- {
- drawGarbage = false;
- pixelsLeft = kPixelsToDrawOK;
- }
- }
- else
- {
- destRowPtr[column] = srcRowPtr[column];
-
- if (--pixelsLeft == 0)
- {
- drawGarbage = true;
- pixelsLeft = kPixelsToDrawGarbage * mCrashState / 5;
- }
- }
- }
-
- srcRowPtr += srcRowWords;
- destRowPtr += destRowWords;
- }
-
- return true;
- }
-
-
- // ---------------------------------------------------------------------------
- // • ShouldEnableRestoreMenu
- // ---------------------------------------------------------------------------
-
- Boolean
- CCrashedBehavior::ShouldEnableRestoreMenu(void)
- {
- return false;
- }
-
-
- // ---------------------------------------------------------------------------
- // • HandleEvent
- // ---------------------------------------------------------------------------
-
- void
- CCrashedBehavior::HandleEvent(
- EventRecord * ioEvent,
- Boolean * ioResult)
- {
- #pragma unused (ioEvent)
-
- // Swallow all events. We're crashed.
- *ioResult = false;
- }
-
-
-
-