home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d916 / screenmode.lha / ScreenMode / source / Example.c next >
C/C++ Source or Header  |  1993-10-04  |  4KB  |  114 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <intuition/intuition.h>
  4. #include <clib/exec_protos.h>
  5. #include <clib/dos_protos.h>
  6. #include <clib/intuition_protos.h>
  7. #include <clib/graphics_protos.h>
  8. #include <stdio.h>
  9.  
  10. #define USM_ERRTXT //--- use the error-text
  11. #include "UserScreenMode.h"
  12.  
  13. #define INTL struct IntuitionBase *
  14. #define GFXL struct GfxBase *
  15. #define LIBL struct Library *
  16.  
  17. GFXL GfxBase;        //---> Those must be defined,
  18. INTL IntuitionBase;  //---> not necessaryly opened.
  19. LIBL GadToolsBase;   //--->         -*-
  20.  
  21. PRPT proplist[] =
  22. {  //--- name[16],  include,                exclude  (see graphics/displayinfo.h)
  23.    //---------------------------------------------------------------------------
  24.     { "ALL",        ~0L,                    0L },
  25.     { "PAL ONLY",   DIPF_IS_PAL,            0L },
  26.     { "WORKBENCH",  DIPF_IS_WB,             0L },
  27.     { "LACE",       DIPF_IS_LACE,           0L },
  28.     { "HAM/NOLACE", DIPF_IS_HAM,            DIPF_IS_LACE },
  29.     { "NO HAM/EHB", ~0L,                    DIPF_IS_HAM|DIPF_IS_EXTRAHALFBRITE },
  30.     { "ECS/AA",     DIPF_IS_ECS|DIPF_IS_AA, 0L },
  31.     { "FOREIGN",    DIPF_IS_FOREIGN,        0L },
  32. };
  33.  
  34. PRPT *plist[] =     //---> this list must be passed!
  35. {
  36.     &proplist[0],
  37.     &proplist[1],
  38.     &proplist[2],
  39.     &proplist[3],
  40.     &proplist[4],
  41.     &proplist[5],
  42.     &proplist[6],
  43.     &proplist[7],
  44.     NULL            //---> end with a NULL pointer!
  45. };
  46.  
  47. UWORD pens1[] = { 1,0,~0 };
  48. UWORD pens2[] = { 1,0,1,2,1,3,1,0,1,~0 };
  49.  
  50. //-------------------------------------------------------- main
  51. void main(int argc,char **argv)
  52. {
  53. struct Screen *scr;
  54. SCRMODE scrmode;
  55. UWORD *pens;
  56. int testing = 1;
  57.  
  58.     if (GfxBase = (GFXL)OpenLibrary("graphics.library",37))
  59.     {
  60.         if (IntuitionBase = (INTL)OpenLibrary("intuition.library",37))
  61.         {
  62.             if (UserScreenMode(NULL,&scrmode,plist))
  63.             {
  64.                 while (testing)
  65.                 {
  66.                     pens = (scrmode.Depth) == 1 ? pens1 : pens2;
  67.  
  68.                     if (scr = OpenScreenTags (NULL,
  69.                         SA_Width,       scrmode.Width,
  70.                         SA_Height,      scrmode.Height,
  71.                         SA_Depth,       scrmode.Depth,
  72.                         SA_DisplayID,   scrmode.ModeID,
  73.                         SA_Overscan,    scrmode.OScan,
  74.                         SA_FullPalette, TRUE,
  75.                         SA_SysFont,     1L,
  76.                         SA_Type,        PUBLICSCREEN,
  77.                         SA_AutoScroll,  TRUE,
  78.                         SA_PubName,     "TestScreen",
  79.                         SA_Pens,        pens,
  80.                         TAG_END))
  81.                     {
  82.                         //-------- show palette
  83.                         {   register WORD y,w=scrmode.Width-1;
  84.                             for (y=0; y<scrmode.Height; y++)
  85.                             {   SetAPen(&scr->RastPort,y);
  86.                                 Move(&scr->RastPort,0,y);
  87.                                 Draw(&scr->RastPort,w,y);
  88.                             }
  89.                         }
  90.                         PubScreenStatus(scr,0);
  91.  
  92.                         if (!UserScreenMode("TestScreen",&scrmode,plist))
  93.                         {
  94.                             if (USM_Error) printf("ERROR: %s\n",USM_ErrorTxt[USM_Error]);
  95.                             testing = 0;
  96.                         }
  97.                         CloseScreen(scr);
  98.                     }
  99.                     else
  100.                     {
  101.                         printf("ERROR: Can't open screen.\n");
  102.                         testing = 0;
  103.                     }
  104.                 }
  105.             }
  106.             else if (USM_Error) printf("ERROR: %s.\n",USM_ERROR);
  107.  
  108.             CloseLibrary((LIBL)IntuitionBase);
  109.         }
  110.         CloseLibrary((LIBL)GfxBase);
  111.     }
  112. }
  113.  
  114.