home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / SprocketInvaders / Source / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  3.8 KB  |  160 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        main.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1998-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                xxx put dri here xxx
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            xxx put technology here xxx
  17.  
  18.     Writers:
  19.  
  20.         (cjd)    Chris De Salvo
  21.         (sjb)    Steve Bollinger
  22.         (BWS)    Brent Schorsch
  23.  
  24.     Change History (most recent first):
  25.  
  26.       <SP17>      3/3/99    cjd        Added calls to register app as an Appearance client
  27.       <SP16>     1/29/99    cjd        Replaced old RedbookHandler code with new CD_Utils code.
  28.       <SP15>     1/21/99    cjd        Removing 68K build code
  29.         <14>     6/18/98    sjb        InputSprocket.h comes from <> place
  30.         <13>     6/12/98    BWS        Now uses InputSprocket 68k
  31. */
  32.  
  33. //•    ------------------------------------------------------------------------------------------    •
  34. //•
  35. //•    Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  36. //•
  37. //•
  38. //•        You may incorporate this sample code into your applications without
  39. //•        restriction, though the sample code has been provided "AS IS" and the
  40. //•        responsibility for its operation is 100% yours.  However, what you are
  41. //•        not permitted to do is to redistribute the source as "DSC Sample Code"
  42. //•        after having made changes. If you're going to re-distribute the source,
  43. //•        we require that you make it clear in the source that the code was
  44. //•        descended from Apple Sample Code, but that you've made changes.
  45. //•
  46. //•        Authors:
  47. //•            Chris De Salvo
  48. //•            Jamie Osborne
  49. //•
  50. //•    ------------------------------------------------------------------------------------------    •
  51.  
  52. //•    ------------------------------    Includes
  53.  
  54. #include <Appearance.h>
  55. #include <Fonts.h>
  56. #include <Movies.h>
  57. #include <StandardFile.h>
  58.  
  59. #include <DrawSprocket.h>
  60. #include <InputSprocket.h>
  61.  
  62. #include "ErrorHandler.h"
  63. #include "EventHandler.h"
  64. #include "Graphics.h"
  65. #include "MenuHandler.h"
  66. #include "MoviePlayback.h"
  67. #include "CD_Utils.h"
  68. #include "SoundHandler.h"
  69. #include "NetSprocketSupport.h"
  70.  
  71. //•    ------------------------------    Private Definitions
  72. //•    ------------------------------    Private Types
  73. //•    ------------------------------    Private Variables
  74.  
  75. static StandardFileReply    gTheReply;
  76.  
  77. //•    ------------------------------    Private Functions
  78.  
  79. void main(void);
  80. static void ToolboxInit(void);
  81.  
  82. //•    ------------------------------    Public Variables
  83.  
  84. Boolean    gCDAudio = true;
  85.  
  86. //•    --------------------    main
  87.  
  88. void
  89. main(void)
  90. {
  91. //•    When we start up we record the state of the modifier keys on the keyboard
  92. //•    and then pass those values to the various initialization routines in the game.
  93. SInt16    startupModifiers;
  94.  
  95.     ToolboxInit();
  96.  
  97.     RegisterAppearanceClient();
  98.  
  99.     //•    Make sure that the DrawSprocket and InputSprocket libraries are present
  100.     if (DSpStartup == nil)
  101.         FatalError("This game requires DrawSprocket.");
  102.  
  103.     if (ISpInit == nil)
  104.         FatalError("This game requires InputSprocket.");
  105.  
  106.     //•    Reseed the random number generator
  107.     qd.randSeed =  TickCount();
  108.  
  109.     startupModifiers = EventInit();
  110.     gNetSprocketPresent = InitNetworking();
  111.  
  112.     MenuInit();
  113.  
  114.     GraphicsInit(startupModifiers);
  115.     SoundHandlerInit();
  116.     CD_Open();
  117.     
  118.     //•    Run the game
  119.     EventLoop();
  120.  
  121.     ShutdownMoviePlayback();
  122.  
  123.     //•    Shut down the handlers and quit
  124.     SoundHandlerReset();
  125.     GraphicsReset();
  126.  
  127.     if (gNetSprocketPresent)
  128.         ShutdownNetworking();
  129.     
  130.     ISpStop();
  131.  
  132.     UnregisterAppearanceClient();
  133.  
  134.     FlushEvents(everyEvent, 0);
  135.     ExitToShell();
  136. }
  137.  
  138. //•    --------------------    main
  139.  
  140. static void
  141. ToolboxInit(void)
  142. {
  143.     MaxApplZone();
  144.  
  145.     InitGraf(&qd.thePort);
  146.     InitFonts();
  147.     InitWindows();
  148.     InitMenus();
  149.     TEInit();
  150.     InitDialogs(nil);
  151.     InitCursor();
  152.  
  153.     //•    Initialize the Quicktime Movie Toolbox
  154.     EnterMovies();
  155.  
  156.     //•    Flush out mouse and keyboard events.  This prevents some things like clicking through
  157.     //•    to the Finder while the app is launching, etc.
  158.     FlushEvents(mDownMask | keyDownMask | autoKeyMask, 0);
  159. }
  160.