home *** CD-ROM | disk | FTP | other *** search
- /*
- Filename SystemInfo.c
- Copyright © 1993 David Hart. All rights reserved.
- Author David Hart
- Description SystemInfo module for After Dark
-
- Version Date Comments
- 2.00 18/03/93 Original Version for After Dark 2.0
- 2.01 22/03/93 To display the Blank Region enclosing rect
- */
-
- #include <QuickDraw.h>
- #include <Memory.h>
- #include <OSUtils.h>
- #include "GraphicsModule_Types.h"
-
- /* Function prototypes */
- void ShowBoolean(int h, int v, int bool, Str255 str);
- void ShowRect(int h, int v, Rect rect);
-
- /* Specific graphics module data structures */
- typedef struct MyStorage
- {
- int dummy;
- } MyStorage, *MyStoragePtr, **MyStorageHandle;
-
- /*
- DoInitialize is the first function called from After Dark.
- Memory for the structure is allocated and the variables are initialized.
- The allocated memory is assigned to "storage"
- and the function returns "noErr" if there are no problems.
- */
- OSErr DoInitialize(Handle *storage, RgnHandle blankRgn, GMParamBlockPtr params)
- {
- MyStorageHandle myStorage;
-
- /* allocate handle to my storage */
- myStorage = (MyStorageHandle)NewHandle(sizeof(MyStorage));
-
- if (!myStorage)
- return MemError();
-
- MoveHHi(myStorage);
- HLock(myStorage); /* Lock it down */
-
- *storage = (Handle)myStorage; /* Assign myStorage to passed handle */
-
- HUnlock(myStorage);
- return noErr;
- }
-
- /*
- DoBlank is the next function called.
- It is used to simply blank the screen.
- */
- OSErr DoBlank(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params)
- {
- FillRgn(blankRgn, params->qdGlobalsCopy->qdWhite); /* fill white */
- return noErr;
- }
-
- /*
- DoDrawFrame does almost all of the work.
- */
- OSErr DoDrawFrame(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params)
- {
- OSErr err = noErr;
- MyStoragePtr myStorage; /* to hold dereferenced storage handle */
- int h = 10;
- int v = 0;
- Str255 str;
- int monitor;
-
- /* Lock our storage down so we can dereference it once for faster access */
- MoveHHi(storage);
- HLock(storage);
- myStorage = (MyStoragePtr)*storage;
-
- TextFont(monaco);
- TextSize(9);
-
- /* Blank Region Enclosing Rect */
- MoveTo(h, v+=12);
- DrawString("\pBlank Region Rect:");
- ShowRect(h+h, v+=12, (**blankRgn).rgnBBox);
-
- /* Monitors */
- MoveTo(h, v+=12);
- DrawString("\pNumber of Monitors: ");
- NumToString(params->monitors->monitorCount, str);
- DrawString(str);
-
- /* For each monitor */
- for (monitor = 0; monitor < params->monitors->monitorCount; monitor++)
- {
- MoveTo(h, v+=12);
- DrawString("\pMonitor: ");
- NumToString(monitor+1, str);
- DrawString(str);
- ShowRect(h+h, v+=12, params->monitors->monitorList[monitor].bounds);
- DrawString("\p Current depth: ");
- NumToString(params->monitors->monitorList[monitor].curDepth, str);
- DrawString(str);
- }
-
- /* Color QuickDraw Available */
- ShowBoolean(h+h, v+=12, params->colorQDAvail, "\pColor QuickDraw Available: ");
-
- /* System Config */
- MoveTo(h, v+=12);
- DrawString("\pSystem Config: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & 1L, "\pMac has Color QuickDraw: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 1), "\pA monitor set to greater than 1 bit: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 2), "\pAll monitors set to greater than 1 bit: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 3), "\pA monitor in color mode: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 4), "\pAll monitors in color mode: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 5), "\pA monitor is a CLUT device: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 6), "\pAll monitors are CLUT devices: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 7), "\pAll monitors can dim: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 8), "\pThe main monitor can dim: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 9), "\pModule may not animate the color table: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 10), "\pMulti module running: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 14), "\pModule is running under version 2.0u or later: ");
- ShowBoolean(h+h, v+=12, params->systemConfig & (1L << 15), "\pThis version of After Dark supports sound: ");
-
- /* QuickDraw Globals */
- MoveTo(h, v+=12);
- DrawString("\pQuickDraw Globals:");
- ShowRect(h+h, v+=12, params->qdGlobalsCopy->qdThePort->portRect);
-
- /* Demo Rect */
- MoveTo(h, v+=12);
- DrawString("\pDemo Rect:");
- ShowRect(h+h, v+=12, params->demoRect);
-
- /* After Dark Version */
- MoveTo(h, v+=12);
- DrawString("\pAfter Dark Version: ");
- NumToString((params->adVersion & 0xFF00) >> 8, str);
- DrawString(str);
- DrawString("\p.");
- NumToString((params->adVersion & 0x00FF), str);
- DrawString(str);
-
- HUnlock(storage);
- return noErr;
- }
-
- /*
- DoClose is called when the user quits the screen saver.
- The memory is deallocated and the function returns "MemError"
- which will tell After Dark if there was a problem
- */
- OSErr DoClose(Handle storage, RgnHandle blankRgn, GMParamBlockPtr params)
- {
- MyStorageHandle myStorage = (MyStorageHandle)storage;
-
- /* Deallocate our storage */
- if (myStorage)
- {
- MoveHHi(myStorage);
- HLock(myStorage);
- DisposHandle(storage);
- }
-
- /* check for memory errors */
- return MemError();
- }
-
- /*
- DoSetUp is called if the user clicks on a button in the Control Panel.
- */
- OSErr DoSetUp(RgnHandle blankRgn, short message, GMParamBlockPtr params)
- {
- return noErr;
- }
-
- /*
- ShowBoolean displays boolean value as Yes or No
- */
- void ShowBoolean(int h, int v, int bool, Str255 str)
- {
- MoveTo(h, v);
- DrawString(str);
- MoveTo(h+300, v);
- if (bool)
- DrawString("\pYes");
- else
- DrawString("\pNo");
- }
-
- /*
- ShowRect displays rect coords
- */
- void ShowRect(int h, int v, Rect rect)
- {
- Str255 str;
-
- MoveTo(h, v);
- DrawString("\pLeft: ");
- NumToString(rect.left, str);
- DrawString(str);
- DrawString("\p Top: ");
- NumToString(rect.top, str);
- DrawString(str);
- DrawString("\p Right: ");
- NumToString(rect.right, str);
- DrawString(str);
- DrawString("\p Bottom: ");
- NumToString(rect.bottom, str);
- DrawString(str);
- }
-