home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / macraysh.sit / Code / Source / macinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-27  |  1.2 KB  |  68 lines

  1. /* macinit.c
  2.  * 
  3.  * A bunch of initialization routines which prepare the mac, ready of operation.
  4.  * The equivalent shutdown routines are also here
  5.  *
  6.  */
  7.  
  8. #include <MacHeaders>
  9. #include <Palettes.h>
  10. #include "common.h"
  11.  
  12. #define STACK_SIZE (500*1024)
  13.  
  14. void CantOpen() ;
  15.  
  16. /*
  17.  * MacInitialize()
  18.  *
  19.  * Initialize all the managers & memory
  20.  *
  21.  */
  22. void MacInitialize(void)
  23. {    
  24.     /* A nice hefty stack */
  25.     SetApplLimit(ApplicZone()+STACK_SIZE) ;
  26.  
  27.     InitGraf(&thePort);
  28.     InitFonts();
  29.     FlushEvents(everyEvent, 0);
  30.     InitWindows();
  31.     InitMenus();
  32.     TEInit();
  33.     InitDialogs(0L);
  34.     InitCursor();
  35.     if (GetResource('MENU', 1)==0) {
  36.         /* Foul up has occured, no resources ! */
  37.         SysBeep(20);
  38.         CantOpen();
  39.         ExitToShell() ;
  40.     }
  41.     SetUpMenus();
  42. }
  43.  
  44. void
  45. RSGetCpuTime(usertime, systime)
  46. Float *usertime, *systime;
  47. {
  48.     *usertime = 0.;
  49.     *systime = (Float)TickCount()/6.;
  50. }
  51.  
  52.  
  53. void CantOpen()
  54. {
  55.     Rect r;
  56.     WindowPtr errorWindow;
  57.  
  58.     SetRect(&r, 152, 60, 356, 132);
  59.     SetPort((errorWindow = NewWindow( (Ptr) 0L, &r, "\p", true, dBoxProc, (WindowPtr) -1L, false, 0L)));
  60.     TextFont(0);
  61.     MoveTo(4, 20);
  62.     DrawString("\pCan't open resource file.");
  63.     MoveTo(4, 40);
  64.     DrawString("\pClick mouse to exit.");
  65.     do {
  66.     } while (!Button());
  67. }
  68.