home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1996 #3 / AmigaPlus_CD-ROM-EXTRA_Nr.3.bin / aminet-spiele / denk&grübel / crazyclock / source / main.c < prev    next >
C/C++ Source or Header  |  1993-10-10  |  3KB  |  99 lines

  1. /*
  2.  * main.c V1.1
  3.  *
  4.  * Crazy Clock main entry point
  5.  *
  6.  * (c) 1992-1993 Holger Brunst
  7.  */
  8.  
  9. #include <CClock.h>
  10.  
  11. /* Version string */
  12. static const char   version[] = "\0$VER: CrazyClock "VERSION"."REVISION" ("DATE")\r\n";
  13.  
  14. /* Use 3D look */
  15. static const UWORD  new3d[] = {~0};
  16. static ULONG        displayID = HIRES_KEY;
  17.  
  18. /* Garnet font pointer */
  19. static struct TextFont  *grntFont;
  20.  
  21. /* Main entry point of Crazy Clock */
  22. LONG main(void)
  23. {
  24.  BOOL   goOn = TRUE;
  25.  ULONG  idcmpSigMsk;
  26.  struct IntuiMessage    *msg;
  27.  
  28.  /* Get garnet-Font */
  29.  if (grntFont = (struct TextFont *) OpenDiskFont(&GrntAttr)) {
  30.   /* NTSC monitor available? */ 
  31.   if (!ModeNotAvailable(NTSC_MONITOR_ID))
  32.    /* Yes, add NTSC-ID to displayID */
  33.    displayID |= NTSC_MONITOR_ID;
  34.   /* Open clock screen */
  35.   if (Screen = OpenScreenTags(NULL, SA_Title, GAME_NAME,
  36.                                     SA_Width, 640,
  37.                                     SA_Height, 200,
  38.                                     SA_DisplayID, displayID,
  39.                                     SA_Depth, 4,
  40.                                     SA_PubName, GAME_NAME" Screen",
  41.                                     SA_Type, PUBLICSCREEN,
  42.                                     SA_Pens, new3d,
  43.                                     SA_Font, &GrntAttr,
  44.                                     SA_ShowTitle, FALSE,
  45.                                     TAG_DONE)) {
  46.    /* Get visual info */
  47.    if (ScreenVI = GetVisualInfo(Screen, TAG_DONE)) {
  48.     /* Open clock window */
  49.     if (idcmpSigMsk = OpenClockWindow()) {
  50.      /* Increase task priority (not necessary) */
  51.      SetTaskPri(FindTask(NULL), 1);
  52.  
  53.      /* Get highscore */
  54.      LoadHighScore();
  55.  
  56.      /* Input event handling */ 
  57.      while (goOn) {
  58.  
  59.       /* Wait for IDCMP signals */ 
  60.       Wait(idcmpSigMsk);
  61.  
  62.       /* Read IDCMP messages */
  63.       while (msg = GT_GetIMsg(IDCMPPort)) {
  64.        void *data;
  65.        HandleIDCMPFunc *func = msg->IDCMPWindow->UserData;
  66.  
  67.        /* Handle IDCMP message. Window closed? */
  68.        if (data = (*func)(msg))
  69.         /* Yes. Update window? */
  70.         if (UpdateWindow)
  71.          /* Yes, update window */
  72.          (*UpdateWindow)(data);
  73.         else
  74.          /* No, quit */
  75.          goOn = FALSE;
  76.        else
  77.         /* No, reply message */
  78.         GT_ReplyIMsg(msg);
  79.       }
  80.      }
  81.      /* Free resources */
  82.      SaveHighScore();
  83.      CloseClockWindow();
  84.     }
  85.     FreeVisualInfo(ScreenVI);
  86.    }
  87.    CloseScreen(Screen);
  88.   }
  89.   CloseFont(grntFont);
  90.  }
  91.  return (NULL);
  92. }
  93.  
  94. /* WB entry point */
  95. int wbmain(struct WBStartup *wbs)
  96. {
  97.  return(main());
  98. }
  99.