Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
DZMain.c
/* |
* File: DZMain.c |
* |
* Contents: Main entry point, main loop, initialize and exit code |
* |
* Copyright © 1996 Apple Computer, Inc. |
*/ |
#include <Dialogs.h> |
#include <Fonts.h> |
#include <Memory.h> |
#include <QuickDraw.h> |
#include <Types.h> |
#include <Windows.h> |
#include <QD3D.h> |
#include "DZDisplay.h" |
#include "DZDrone.h" |
#include "DZEvents.h" |
#include "DZGame.h" |
#include "DZInput.h" |
#include "DZMain.h" |
#include "DZMenu.h" |
#include "DZSound.h" |
#include "DZSpace.h" |
#ifdef APP_LOADS_SOUND_COMPONENT |
#include "S3Private.h" |
#endif |
void main( |
void); |
static void Init( |
void); |
static void Exit( |
void); |
static Boolean gAlive = false; |
/* ============================================================================= |
* main |
* |
* Initializes, processes events, does the idle-time stuff, and exits. |
* ========================================================================== */ |
void main( |
void) |
{ |
Init(); |
while (gAlive) |
{ |
Events_Process(); |
if (gAlive && Display_IsActive() && Game_GetState() == kGameState_Playing) |
{ |
Game_Process(); |
Display_DrawContents(); |
} |
} |
Exit(); |
} |
/* ============================================================================= |
* Main_LastRoundup (external) |
* |
* Requests the main event loop to gracefully exit. |
* ========================================================================== */ |
void Main_LastRoundup( |
void) |
{ |
gAlive = false; |
} |
/* ============================================================================= |
* Init (internal) |
* |
* Initialization of toolbox and our stuff. |
* ========================================================================== */ |
void Init( |
void) |
{ |
// Initialize the toolbox |
MaxApplZone(); |
MoreMasters(); |
InitGraf(&qd.thePort); |
InitFonts(); |
InitWindows(); |
InitDialogs(NULL); |
InitCursor(); |
InitMenus(); |
TEInit(); |
qd.randSeed = TickCount(); |
// Initialize QD3D |
Q3Initialize(); |
// Should we load S3Localization? |
#ifdef APP_LOADS_SOUND_COMPONENT |
{ |
ComponentDescription filterDesc; |
Handle filterNameHdl, infoHdl; |
// Register (or find) our components |
#ifdef REAL_3D_INSTALL |
filterDesc.componentType = kSoundEffectsType; |
#else |
filterDesc.componentType = 'sdec'; |
#endif |
filterDesc.componentSubType = kSSpLocalizationSubType; |
filterDesc.componentManufacturer = kAppleManufacturer; |
filterDesc.componentFlags = 0L; |
filterDesc.componentFlagsMask = 0L; |
filterNameHdl = NewHandle (sizeof (Str255)); |
BlockMove ((Ptr)"\pS3Localization", (Ptr)(*filterNameHdl), sizeof (Str255)); |
infoHdl = NewHandle (sizeof (Str255)); |
BlockMove ((Ptr)"\pThis component provides 3D Audio.", (Ptr)(*infoHdl), sizeof (Str255)); |
// Register the Filter component |
RegisterComponent (&filterDesc, NewComponentRoutineProc(SoundComponentProc), kRegisterGlobally, |
filterNameHdl, infoHdl, nil); |
} |
#endif |
// Initialize our modules |
Menu_Init(); |
Sound_Init(); |
Events_Init(); |
Display_Init(); |
Drone_Init(); |
Space_Init(); |
Input_Init(); |
Game_Init(); |
// We're off... |
gAlive = true; |
} |
/* ============================================================================= |
* Exit (internal) |
* |
* Cleans up before exit. |
* ========================================================================== */ |
void Exit( |
void) |
{ |
// Exit our modules |
Game_Exit(); |
Input_Exit(); |
Space_Exit(); |
Drone_Exit(); |
Display_Exit(); |
Events_Exit(); |
Sound_Exit(); |
Menu_Exit(); |
// Exit QD3D |
Q3Exit(); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-10-14