home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference / amiga_mail_vol2 / v-1 / genlockdemo.c < prev   
C/C++ Source or Header  |  1996-01-30  |  39KB  |  500 lines

  1. ;/* genlockdemo.c - Amiga Mail Jan/Feb '91 Genlock VideoControl example.
  2. sc DATA=NEAR NMINC STRMERGE STREQ NOSTKCHK IGNORE=73 genlockdemo.c
  3. slink FROM LIB:c.o,genlockdemo.o TO genlockdemo LIBRARY LIB:sc.lib,LIB:amiga.lib
  4. quit
  5. */
  6. /*
  7. Copyright (c) 1991 Commodore-Amiga, Inc.
  8.  
  9. This example is provided in electronic form by Commodore-Amiga,
  10. Inc. for use with the Amiga Mail Volume II technical publication.
  11. Amiga Mail Volume II contains additional information on the correct
  12. usage of the techniques and operating system functions presented in
  13. these examples.  The source and executable code of these examples may
  14. only be distributed in free electronic form, via bulletin board or
  15. as part of a fully non-commercial and freely redistributable
  16. diskette.  Both the source and executable code (including comments)
  17. must be included, without modification, in any copy.  This example
  18. may not be published in printed form or distributed with any
  19. commercial product. However, the programming techniques and support
  20. routines set forth in these examples may be used in the development
  21. of original executable software products for Commodore Amiga
  22. computers.
  23.  
  24. All other rights reserved.
  25.  
  26. This example is provided "as-is" and is subject to change; no
  27. warranties are made.  All use is at your own risk. No liability or
  28. responsibility is assumed.
  29. */
  30.  
  31. #include <exec/types.h>
  32. #include <exec/memory.h>
  33. #include <graphics/gfxbase.h>
  34. #include <graphics/displayinfo.h>
  35. #include <graphics/VideoControl.h>
  36. #include <graphics/view.h>
  37. #include <intuition/intuition.h>
  38. #include <intuition/screens.h>
  39. #include <libraries/gadtools.h>
  40.  
  41. #include <clib/alib_stdio_protos.h>
  42. #include <clib/intuition_protos.h>
  43. #include <clib/graphics_protos.h>
  44. #include <clib/exec_protos.h>
  45. #include <clib/gadtools_protos.h>
  46.  
  47. /* Some gadget ID's */
  48. #define BORDERBLANK_ID          16
  49. #define BORDERNOTRANS_ID        17
  50. #define BITPLANEKEY_ID          18
  51. #define CHROMAPLANE_ID          19
  52. #define CHROMAKEY_ID            20
  53.  
  54. /* Some protos */
  55. VOID main(VOID);
  56. BOOL CheckPAL(STRPTR);
  57. UWORD strlen(STRPTR);
  58.  
  59. struct IntuitionBase *IntuitionBase;
  60. struct GfxBase *GfxBase;
  61. struct Library *GadToolsBase;
  62.  
  63.  
  64. /* Give me 3D look window (I'll use a quiet screen */
  65. static UWORD dri_Pens[] =
  66. {0, 1, 1, 2, 1, 3, 1, 0, 3, ~0};
  67.  
  68. /* Just a demo, set everything to topaz 80. */
  69. static struct TextAttr Topaz80 = {"topaz.font", 8, 0, 0,};
  70.  
  71.  
  72. /* strings for cycle gadget */
  73. static STRPTR ChPlaneText[] = {"Plane 0", "Plane 1", "Plane 2", "Plane 3", NULL};
  74.  
  75.  
  76. struct EasyStruct failedES = {sizeof(struct EasyStruct), 0, "GenlockDemo", "%s", "Continue",};
  77.  
  78.  
  79. VOID main(VOID)
  80. {
  81.         struct Screen *genscreen;
  82.         struct Window *controlwindow;
  83.         struct Gadget *glist, *gadget, *hitgadget;
  84.         struct ViewPort *vp;
  85.         void *vi;
  86.         struct NewGadget ng;
  87.         struct IntuiMessage *imsg;
  88.         struct TagItem vtags[24];
  89.         ULONG GadgetPtrs[21];
  90.         ULONG iclass, icode;
  91.         STRPTR gtextbuffer, gtextptr;
  92.         UWORD i, j;
  93.         BOOL ABORT = FALSE;
  94.         BOOL IsPAL;
  95.         /* Fails silently if < V37 */
  96.         if (IntuitionBase = OpenLibrary("intuition.library", 37))
  97.         {
  98.                 if (GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37))
  99.                 {
  100.                         if (GadToolsBase = OpenLibrary("gadtools.library", 37))
  101.                         {
  102.                                 if (GfxBase->ChipRevBits0 & GFXF_HR_DENISE)
  103.                                 {
  104.                                         /* Check if the user happens to prefer PAL or if this is a true PAL System. */
  105.                                         IsPAL = CheckPAL("Workbench");
  106.                                         /* buffer for some gadget text */
  107.                                         if (gtextbuffer = AllocMem(256, MEMF_CLEAR))
  108.                                         {
  109.                                                 gtextptr = gtextbuffer;
  110.  
  111.                                                 /* Open a 'standard' HIRES screen */
  112.                                                 if (genscreen = OpenScreenTags(NULL, SA_Pens, (ULONG) dri_Pens,
  113.                                                 SA_DisplayID, HIRES_KEY,
  114.                                                 SA_Depth, 4,
  115.                                                 /* Give me a lot of border */
  116.                                                 SA_Width, 640,
  117.                                                 SA_Height, (IsPAL) ? 256 : 200,
  118.                                                 SA_Overscan, 0,
  119.                                                 /* Hold the titlebar, please */
  120.                                                 SA_Quiet, TRUE,
  121.                                                 /* Give me sysfont 0 as default rastport font. */
  122.                                                 SA_SysFont, 1,
  123.                                                 TAG_DONE))
  124.                                                 {
  125.  
  126.                                                         /* Blast some colorbars in screen's rastport, leave some color 0 gaps */
  127.                                                         for (i = 0, j = 0; i < 16; i++, j += 40)
  128.                                                         {
  129.                                                                 SetAPen(&(genscreen->RastPort), i);
  130.                                                                 RectFill(&(genscreen->RastPort), (j + 1), 0, (j + 30), (IsPAL) ? 255 : 199);
  131.  
  132.                                                         }
  133.                                                         /* A line to show where borders start */
  134.                                                         SetAPen(&(genscreen->RastPort), 5);
  135.                                                         Move(&(genscreen->RastPort),0,0);
  136.                                                         Draw(&(genscreen->RastPort),genscreen->Width-1,0);
  137.                                                         Draw(&(genscreen->RastPort),genscreen->Width-1,genscreen->Height-1);
  138.                                                         Draw(&(genscreen->RastPort),0,genscreen->Height-1);
  139.                                                         Draw(&(genscreen->RastPort),0,0);
  140.  
  141.                                                         /* Open a restricted window, no draggin, sizing, just closing.
  142.                                                          * (don't want to refresh screen)
  143.                                                          */
  144.                                                         if (controlwindow = OpenWindowTags(NULL, WA_Title, (ULONG) "VideoControl",
  145.                                                         WA_Left, 210,
  146.                                                         WA_Top, 20,
  147.                                                         WA_Width, 220,
  148.                                                         WA_Height, 150,
  149.                                                         WA_CustomScreen, genscreen,
  150.                                                         WA_Flags, WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_NOCAREREFRESH,
  151.                                                         WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_GADGETUP,
  152.                                                         TAG_DONE))
  153.                                                         {
  154.  
  155.                                                                 /* Ok, got a window, lets make some gadgets */
  156.                                                                 if (vi = GetVisualInfo(genscreen, TAG_END))
  157.                                                                 {
  158.                                                                         if (gadget = CreateContext(&glist))
  159.                                                                         {
  160.                                                                                 ng.ng_TextAttr = &Topaz80;
  161.                                                                                 ng.ng_VisualInfo = vi;
  162.                                                                                 ng.ng_Flags = PLACETEXT_LEFT | NG_HIGHLABEL;
  163.  
  164.                                                                                 ng.ng_LeftEdge = controlwindow->BorderLeft + 120;
  165.                                                                                 ng.ng_TopEdge = controlwindow->BorderTop + 2;
  166.                                                                                 ng.ng_Width = 12;
  167.                                                                                 ng.ng_Height = 12;
  168.                                                                                 ng.ng_GadgetText = "BORDERBLANK";
  169.                                                                                 ng.ng_GadgetID = BORDERBLANK_ID;
  170.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  171.                                                                                 GadgetPtrs[BORDERBLANK_ID] = (ULONG) gadget;
  172.  
  173.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  174.                                                                                 ng.ng_GadgetText = "BORDERNOTRANS";
  175.                                                                                 ng.ng_GadgetID = BORDERNOTRANS_ID;
  176.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  177.                                                                                 GadgetPtrs[BORDERNOTRANS_ID] = (ULONG) gadget;
  178.  
  179.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  180.                                                                                 ng.ng_GadgetText = "CHROMAKEY";
  181.                                                                                 ng.ng_GadgetID = CHROMAKEY_ID;
  182.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  183.                                                                                 GadgetPtrs[CHROMAKEY_ID] = (ULONG) gadget;
  184.  
  185.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  186.                                                                                 ng.ng_GadgetText = "BITPLANEKEY";
  187.                                                                                 ng.ng_GadgetID = BITPLANEKEY_ID;
  188.                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  189.                                                                                 GadgetPtrs[BITPLANEKEY_ID] = (ULONG) gadget;
  190.  
  191.                                                                                 ng.ng_TopEdge += gadget->Height + 2;
  192.                                                                                 ng.ng_Width = 90;
  193.                                                                                 ng.ng_GadgetText = "CHROMAPLANE";
  194.                                                                                 ng.ng_GadgetID = CHROMAPLANE_ID;
  195.                                                                                 gadget = CreateGadget(CYCLE_KIND, gadget, &ng, GTCY_Labels, (ULONG) ChPlaneText,
  196.                                                                                                       TAG_END);
  197.                                                                                 GadgetPtrs[CHROMAPLANE_ID] = (ULONG) gadget;
  198.  
  199.                                                                                 ng.ng_TopEdge += gadget->Height + 20;
  200.                                                                                 ng.ng_Width = 12;
  201.                                                                                 ng.ng_Flags = PLACETEXT_ABOVE | NG_HIGHLABEL;
  202.                                                                                 for (j = 0; j < 2; j++)
  203.                                                                                 {
  204.                                                                                         for (i = 0; i < 8; i++)
  205.                                                                                         {
  206.                                                                                                 ng.ng_LeftEdge = controlwindow->BorderLeft + 2 + (i * gadget->Width);
  207.                                                                                                 sprintf(gtextptr, "%ld", i + (j * 8));
  208.                                                                                                 ng.ng_GadgetText = gtextptr;
  209.                                                                                                 ng.ng_GadgetID = i + (j * 8);
  210.                                                                                                 gadget = CreateGadget(CHECKBOX_KIND, gadget, &ng, TAG_END);
  211.                                                                                                 GadgetPtrs[i] = (ULONG) gadget;
  212.                                                                                                 gtextptr += strlen(gtextptr) + 1;
  213.                                                                                         }
  214.                                                                                         ng.ng_TopEdge += gadget->Height;
  215.                                                                                         ng.ng_Flags = PLACETEXT_BELOW | NG_HIGHLABEL;
  216.                                                                                 }
  217.                                                                                 AddGList(controlwindow, glist, -1, -1, NULL);
  218.                                                                                 RefreshGList(glist, controlwindow, NULL, -1);
  219.                                                                                 GT_RefreshWindow(controlwindow, NULL);
  220.  
  221.                                                                                 /* Finally, a window with some gadgets...
  222.                                                                                  *
  223.                                                                                  * Get the current genlock state.
  224.                                                                                  * Obviously I already know what the settings will be (all off),
  225.                                                                                  * since I opened the screen myself. Do it just to show how to get them.
  226.                                                                                  */
  227.  
  228.                                                                                 vp = &(genscreen->ViewPort);
  229.  
  230.  
  231.  
  232.  
  233.                                                                                 /* Is borderblanking on? */
  234.                                                                                 vtags[0].ti_Tag = VTAG_BORDERBLANK_GET;
  235.                                                                                 vtags[0].ti_Data = NULL;
  236.                                                                                 /* Is bordertransparent set */
  237.                                                                                 vtags[1].ti_Tag = VTAG_BORDERNOTRANS_GET;
  238.                                                                                 vtags[1].ti_Data = NULL;
  239.                                                                                 /* Key on bitplane? */
  240.                                                                                 vtags[2].ti_Tag = VTAG_BITPLANEKEY_GET;
  241.                                                                                 vtags[2].ti_Tag = NULL;
  242.                                                                                 /* Get plane which is used to key on */
  243.                                                                                 vtags[3].ti_Tag = VTAG_CHROMA_PLANE_GET;
  244.                                                                                 vtags[3].ti_Data = NULL;
  245.                                                                                 /* Chromakey overlay on? */
  246.                                                                                 vtags[4].ti_Tag = VTAG_CHROMAKEY_GET;
  247.                                                                                 vtags[4].ti_Data = NULL;
  248.  
  249.                                                                                 for (i = 0; i < 16; i++)
  250.                                                                                 {
  251.                                                                                         /* Find out which colors overlay */
  252.                                                                                         vtags[i + 5].ti_Tag = VTAG_CHROMA_PEN_GET;
  253.                                                                                         vtags[i + 5].ti_Data = i;
  254.                                                                                 }
  255.  
  256.                                                                                 /* Indicate end of tag array */
  257.                                                                                 vtags[21].ti_Tag = VTAG_END_CM;
  258.                                                                                 vtags[21].ti_Data = NULL;
  259.  
  260.                                                                                 /* And send the commands. On return the Tags themself will
  261.                                                                                  * indicate the genlock settings for this ViewPort's ColorMap.
  262.                                                                                  */
  263.                                                                                 VideoControl(vp->ColorMap, vtags);
  264.  
  265.                                                                                 /* And initialize gadgets, according to genlock settings */
  266.                                                                                 if (vtags[0].ti_Tag == VTAG_BORDERBLANK_SET)
  267.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BORDERBLANK_ID],
  268.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  269.                                                                                 if (vtags[1].ti_Tag == VTAG_BORDERNOTRANS_SET)
  270.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BORDERNOTRANS_ID],
  271.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  272.                                                                                 if (vtags[2].ti_Tag == VTAG_BITPLANEKEY_SET)
  273.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[BITPLANEKEY_ID],
  274.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  275.                                                                                 if (vtags[3].ti_Tag == VTAG_CHROMA_PLANE_SET)
  276.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[CHROMAPLANE_ID],
  277.                                                                                                           controlwindow, NULL, GTCY_Active, vtags[3].ti_Data,
  278.                                                                                                           TAG_DONE);
  279.                                                                                 if (vtags[4].ti_Tag == VTAG_CHROMAKEY_SET)
  280.                                                                                         GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[CHROMAKEY_ID],
  281.                                                                                                           controlwindow, NULL, GTCB_Checked, TRUE, TAG_DONE);
  282.                                                                                 for (i = 0; i < 16; i++)
  283.                                                                                 {
  284.                                                                                         if (vtags[i + 5].ti_Tag == VTAG_CHROMA_PEN_SET)
  285.                                                                                                 GT_SetGadgetAttrs((struct Gadget *) GadgetPtrs[i],
  286.                                                                                                                   controlwindow, NULL, GTCB_Checked, TRUE);
  287.                                                                                 }
  288.  
  289.                                                                                 /* Will only send single commands from here on. */
  290.                                                                                 vtags[1].ti_Tag = VTAG_END_CM;
  291.  
  292.                                                                                 /* Get user input. */
  293.                                                                                 do
  294.                                                                                 {
  295.                                                                                         WaitPort(controlwindow->UserPort);
  296.                                                                                         while (imsg = GT_GetIMsg(controlwindow->UserPort)) {
  297.                                                                                                 iclass = imsg->Class;
  298.                                                                                                 icode = imsg->Code;
  299.                                                                                                 hitgadget = (struct Gadget *) imsg->IAddress;
  300.                                                                                                 GT_ReplyIMsg(imsg);
  301.  
  302.  
  303.  
  304.                                                                                                 switch (iclass)
  305.                                                                                                 {
  306.                                                                                                 case GADGETUP:
  307.                                                                                                         if (hitgadget->GadgetID < 16)
  308.                                                                                                         {
  309.                                                                                                                 /* Set colorkey */
  310.                                                                                                                 if (hitgadget->Flags & SELECTED)
  311.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PEN_SET;
  312.                                                                                                                 /* Clear colorkey */
  313.                                                                                                                 else
  314.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PEN_CLR;
  315.                                                                                                                 vtags[0].ti_Data = hitgadget->GadgetID;
  316.                                                                                                         }
  317.                                                                                                         else
  318.                                                                                                         {
  319.                                                                                                                 switch (hitgadget->GadgetID) {
  320.                                                                                                                 case BORDERBLANK_ID:
  321.                                                                                                                         /* Set borderblanking on */
  322.                                                                                                                         if (hitgadget->Flags & SELECTED)
  323.                                                                                                                                 vtags[0].ti_Tag =
  324.                                                                                                                                     VTAG_BORDERBLANK_SET;
  325.                                                                                                                         /* Turn borderblanking off */
  326.                                                                                                                         else
  327.                                                                                                                                 vtags[0].ti_Tag =
  328.                                                                                                                                     VTAG_BORDERBLANK_CLR;
  329.                                                                                                                         break;
  330.                                                                                                                 case BORDERNOTRANS_ID:
  331.                                                                                                                         /* Set bordertransparency on */
  332.                                                                                                                         if (hitgadget->Flags & SELECTED)
  333.                                                                                                                                 vtags[0].ti_Tag =
  334.                                                                                                                                     VTAG_BORDERNOTRANS_SET;
  335.                                                                                                                         /* Turn bordertransparency off */
  336.                                                                                                                         else
  337.                                                                                                                                 vtags[0].ti_Tag =
  338.                                                                                                                                     VTAG_BORDERNOTRANS_CLR;
  339.                                                                                                                         break;
  340.                                                                                                                 case BITPLANEKEY_ID:
  341.                                                                                                                         /* Key on current selected bitplane
  342.                                                                                                                          * (chromaplane) */
  343.                                                                                                                         if (hitgadget->Flags & SELECTED)
  344.                                                                                                                                 vtags[0].ti_Tag =
  345.                                                                                                                                     VTAG_BITPLANEKEY_SET;
  346.                                                                                                                         /* Turn bitplane keying off */
  347.                                                                                                                         else
  348.                                                                                                                                 vtags[0].ti_Tag =
  349.                                                                                                                                     VTAG_BITPLANEKEY_CLR;
  350.                                                                                                                         break;
  351.                                                                                                                 case CHROMAPLANE_ID:
  352.                                                                                                                         /* Set plane to key on */
  353.                                                                                                                         vtags[0].ti_Tag = VTAG_CHROMA_PLANE_SET;
  354.                                                                                                                         vtags[0].ti_Data = icode;
  355.                                                                                                                         break;
  356.                                                                                                                 case CHROMAKEY_ID:
  357.                                                                                                                         /* Set chromakey overlay on */
  358.                                                                                                                         if (hitgadget->Flags & SELECTED)
  359.                                                                                                                                 vtags[0].ti_Tag = VTAG_CHROMAKEY_SET;
  360.                                                                                                                         /* Turn chromakey overlay off */
  361.                                                                                                                         else
  362.                                                                                                                                 vtags[0].ti_Tag = VTAG_CHROMAKEY_CLR;
  363.                                                                                                                         break;
  364.                                                                                                                 }
  365.                                                                                                         }
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.                                                                                                         /* send video command */
  374.                                                                                                         VideoControl(vp->ColorMap, vtags);
  375.                                                                                                         /* Now use MakeScreen() and RethinkDisplay()
  376.                                                                                                          * to make the VideoControl changes
  377.                                                                                                          * take effect.  If we were using our own
  378.                                                                                                          * Viewport rather than borrowing one from
  379.                                                                                                          * a screen, we would instead do:
  380.                                                                                                                      *   MakeVPort(ViewAddress(),vp);
  381.                                                                                                          *   MrgCop(ViewAddress());
  382.                                                                                                          *   LoadView(ViewAddres());
  383.                                                                                                          */
  384.                                                                                                         MakeScreen(genscreen);
  385.                                                                                                         RethinkDisplay();
  386.                                                                                                         break;
  387.  
  388.                                                                                                 case CLOSEWINDOW:
  389.                                                                                                         /* Get out of here */
  390.                                                                                                         ABORT = TRUE;
  391.                                                                                                         break;
  392.                                                                                                 }
  393.                                                                                         }
  394.                                                                                 }
  395.                                                                                 while (ABORT == FALSE);
  396.  
  397.                                                                                 RemoveGList(controlwindow, glist, -1);
  398.                                                                                 FreeGadgets(glist);
  399.                                                                         }
  400.                                                                         else
  401.                                                                                 EasyRequest(NULL, &failedES, NULL, "Can't create gadget context");
  402.                                                                         FreeVisualInfo(vi);
  403.                                                                 }
  404.                                                                 else
  405.                                                                         EasyRequest(NULL, &failedES, NULL, "Can't get visual info");
  406.                                                                 CloseWindow(controlwindow);
  407.                                                         }
  408.                                                         else
  409.                                                                 EasyRequest(NULL, &failedES, NULL, "Can't open window");
  410.                                                         CloseScreen(genscreen);
  411.                                                 }
  412.                                                 else
  413.                                                         EasyRequest(NULL, &failedES, NULL, "Can't open screen");
  414.                                                 FreeMem(gtextbuffer, 256);
  415.                                         }
  416.                                         else
  417.                                                 EasyRequest(NULL, &failedES, NULL, "Out of memory");
  418.                                 }
  419.                                 else
  420.                                         EasyRequest(NULL, &failedES, NULL, "Requires ECS");
  421.                                 CloseLibrary(GadToolsBase);
  422.                         }
  423.                         CloseLibrary((struct Library *) GfxBase);
  424.                 }
  425.                 CloseLibrary(IntuitionBase);
  426.         }
  427. }
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440. BOOL CheckPAL(STRPTR screenname)
  441. {
  442.         struct Screen *screen;
  443.         ULONG modeID = LORES_KEY;
  444.         struct DisplayInfo displayinfo;
  445.         BOOL IsPAL;
  446.  
  447.         if (GfxBase->LibNode.lib_Version >= 36)
  448.         {
  449.         /*
  450.          * We got V36, so lets use the new calls to find out what
  451.          * kind of videomode the user (hopefully) prefers.
  452.          */
  453.  
  454.                 if (screen = LockPubScreen(screenname))
  455.                 {
  456.                         /*
  457.                          * Use graphics.library/GetVPModeID() to get the ModeID of the specified screen.
  458.                          * Will use the default public screen (Workbench most of the time) if NULL It is
  459.                          * _very_ unlikely that this would be invalid, heck it's impossible.
  460.                          */
  461.                         if ((modeID = GetVPModeID(&(screen->ViewPort))) != INVALID_ID)
  462.                         {
  463.                                 /*
  464.                                  * If the screen is in VGA mode, we can't tell whether the system is PAL or NTSC. So
  465.                                  * to be fullproof we fall back to the displayinfo of the default.monitor by
  466.                                  * inquiring about just the LORES_KEY displaymode if we don't know. The
  467.                                  * default.monitor reflects the initial video setup of the system, thus is an alias
  468.                                  * for either ntsc.monitor or pal.monitor. We only use the displaymode of the
  469.                                  * specified public screen if it's display mode is PAL or NTSC and NOT the default.
  470.                                  */
  471.  
  472.                                 if (!((modeID & MONITOR_ID_MASK) == NTSC_MONITOR_ID ||
  473.                                       (modeID & MONITOR_ID_MASK) == PAL_MONITOR_ID))
  474.                                         modeID = LORES_KEY;
  475.                         }
  476.                         UnlockPubScreen(NULL, screen);
  477.                 } /* if fails modeID = LORES_KEY. Can't lock screen, so fall back on default monitor. */
  478.  
  479.                 if (GetDisplayInfoData(NULL, (UBYTE *) & displayinfo,
  480.                     sizeof(struct DisplayInfo), DTAG_DISP, modeID))
  481.                 {
  482.                         if (displayinfo.PropertyFlags & DIPF_IS_PAL)
  483.                             IsPAL = TRUE;
  484.                         else
  485.                             IsPAL = FALSE;  /* Currently the default monitor is always either
  486.                                              * PAL or NTSC.
  487.                                              */
  488.                 }
  489.         }
  490.         else /* < V36. The enhancements to the videosystem in V36 cannot be better expressed than
  491.                 * with the simple way to determine PAL in V34.
  492.                 */
  493.                 IsPAL= (GfxBase->DisplayFlags & PAL) ? TRUE : FALSE;
  494.  
  495.         return(IsPAL);
  496. }
  497.  
  498.  
  499.  
  500.