home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / commodities / superdark / main / modes.c < prev    next >
C/C++ Source or Header  |  1993-02-27  |  4KB  |  164 lines

  1. /****************/
  2. /* Modes.c    */
  3. /****************/
  4.  
  5. #include <exec/types.h>
  6. #include <exec/nodes.h>
  7. #include <exec/ports.h>
  8. #include <exec/memory.h>
  9. #include <graphics/displayinfo.h>
  10. #include <graphics/gfxbase.h>
  11. #include <graphics/gfxmacros.h>
  12. #include <clib/exec_protos.h>
  13. #include <clib/exec_protos.h>
  14. #include <clib/graphics_protos.h>
  15. #include <clib/macros.h>
  16. #include "/includes/struct.h"
  17.  
  18. /****************/
  19. /* Default mode */
  20. /****************/
  21.  
  22. #define DEF_MODE      0
  23. #define DEF_MODE_NAME "HighRes"
  24.  
  25. extern    UBYTE    flg_debug;
  26.  
  27. /* This function is only used in with wb1.3, to create    */
  28. /* a list of all availables modes            */
  29.  
  30. #ifdef WB_13
  31. add_mode(    struct List *ModeList,
  32.         int mx,
  33.         int my,
  34.         int MX,
  35.         int My,
  36.         int depth,
  37.         long id,
  38.         char *p_name)
  39. {
  40.   register struct ModeNode *ModeNode;
  41.   if (ModeNode=AllocMem(sizeof(struct ModeNode),MEMF_PUBLIC))
  42.    {
  43.     (void)strcpy(ModeNode->Name,p_name);
  44.     ModeNode->mn_Node.ln_Name=ModeNode->Name;
  45.     ModeNode->DisplayID=id;
  46.     ModeNode->MaxX=mx;
  47.     ModeNode->MaxY=my;
  48.     ModeNode->MaxDepth=depth;
  49.  
  50.     AddTail (ModeList,&ModeNode->mn_Node);
  51.    }
  52.   else
  53.    {
  54.     return NULL;
  55.    }
  56. }
  57. #endif
  58.  
  59. /********************************************************** get_modes() *****/
  60.  
  61. /********************************************************/
  62. /* We get the current modes availables in this computer */
  63. /********************************************************/
  64.  
  65. struct    List    *get_modes()
  66. {
  67.  struct List *ModeList;
  68.  ULONG DisplayID;
  69.  struct DimensionInfo DimInfo;
  70.  struct NameInfo NameInfo;
  71.  struct ModeNode *ModeNode;
  72.  
  73.  if (ModeList=AllocMem(sizeof(struct List),MEMF_PUBLIC)) NewList (ModeList);
  74.  else return NULL;
  75.  
  76. #ifndef    WB_13
  77.  DisplayID=INVALID_ID;
  78.  while ((DisplayID=NextDisplayInfo(DisplayID))!=INVALID_ID){
  79.   if ((DisplayID&MONITOR_ID_MASK)&&(ModeNotAvailable(DisplayID)==0L)){
  80.    if (GetDisplayInfoData(NULL,(UBYTE *)&DimInfo,sizeof(struct DimensionInfo),
  81.                           DTAG_DIMS,DisplayID)){
  82.     if (DimInfo.MaxDepth>1){
  83.      if (GetDisplayInfoData(NULL,(UBYTE *)&NameInfo,sizeof(struct NameInfo),
  84.                             DTAG_NAME,DisplayID)){
  85.       if (ModeNode=AllocMem(sizeof(struct ModeNode),MEMF_PUBLIC))
  86.        {
  87.  
  88.     ModeNode->MaxDepth=DimInfo.MaxDepth;
  89.     ModeNode->MinX=DimInfo.Nominal.MinX+1;
  90.     ModeNode->MaxX=DimInfo.Nominal.MaxX+1;
  91.     ModeNode->MinY=DimInfo.Nominal.MinY+1;
  92.     ModeNode->MaxY=DimInfo.Nominal.MaxY+1;
  93.  
  94.         (void)strcpy(ModeNode->Name,
  95.                      NameInfo.Name);
  96.     ModeNode->mn_Node.ln_Name=ModeNode->Name;
  97.         ModeNode->DisplayID=DisplayID;
  98.  
  99.     printd("%20s ",NameInfo.Name);
  100.     printd("M.depth:%d mx:%02d my:%02d MX:%03d MY:%03d ",DimInfo.MaxDepth,
  101.                 DimInfo.Nominal.MinX,
  102.                 DimInfo.Nominal.MinY,
  103.                 DimInfo.Nominal.MaxX,
  104.                 DimInfo.Nominal.MaxY);
  105.     printd("Flags:%lx\n",ModeNode->DisplayID);
  106.  
  107.         AddTail (ModeList,&ModeNode->mn_Node);
  108.       }
  109.      }
  110.     }
  111.    }
  112.   }
  113.  }    
  114.  if (ModeList->lh_Head->ln_Succ==NULL)
  115.   if (ModeNode=AllocMem(sizeof(struct ModeNode),MEMF_PUBLIC))
  116.    {
  117.     (void)strcpy(ModeNode->Name,
  118.                      DEF_MODE_NAME);
  119.     ModeNode->mn_Node.ln_Name=ModeNode->Name;
  120.     ModeNode->DisplayID=DEF_MODE;
  121.     ModeNode->MaxX=640;
  122.     ModeNode->MaxY=256;
  123.     ModeNode->MaxDepth=4;
  124.  
  125.     AddTail (ModeList,&ModeNode->mn_Node);
  126.    }
  127.   else
  128.    {
  129.     FreeMem ((APTR)ModeList,sizeof(struct List));
  130.     return NULL;
  131.    }
  132. #endif
  133. #ifdef    WB_13
  134.     add_mode(ModeList,0,0,320,256,5,LORES_KEY,"PAL Lores");
  135.     add_mode(ModeList,0,0,640,256,4,HIRES_KEY,"PAL Hires");
  136. /*    add_mode(ModeList,0,0,320,256,6,HAM_KEY,"PAL Ham");*/
  137.     add_mode(ModeList,0,0,320,512,5,LORESLACE_KEY,"PAL LoresLace");
  138.     add_mode(ModeList,0,0,640,512,4,HIRESLACE_KEY,"PAL HiresLace");
  139. /*    add_mode(ModeList,0,0,320,512,6,HAMLACE_KEY,"PAL HamLace");*/
  140. #endif
  141.  return ModeList;
  142. }
  143.  
  144. /************************************************************* free_modes() */
  145.  
  146.  
  147. /***********************************************/
  148. /* We delete the liste of the available modes */
  149. /***********************************************/
  150.  
  151. void free_modes(struct List *ModeList)
  152.  
  153. {
  154.     struct ModeNode *ModeNode;
  155.  
  156.     while (ModeList->lh_Head->ln_Succ){
  157.         ModeNode=(struct ModeNode *)ModeList->lh_Head;
  158.         RemHead (ModeList);
  159.         FreeMem ((APTR)ModeNode,sizeof(struct ModeNode));
  160.     }
  161.     FreeMem ((APTR)ModeList,sizeof(struct List));
  162. }
  163.  
  164.