home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 580a.lha / HDFView_v3.01 / source.LZH / source / src / openGraphics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-03  |  4.7 KB  |  171 lines

  1. #include <exec/types.h>
  2. #include <exec/ports.h>
  3. #include <exec/memory.h>
  4. #include <intuition/intuition.h>
  5. #include <libraries/dos.h>
  6.  
  7. #include <proto/intuition.h>
  8. #include <proto/graphics.h>
  9. #include <proto/exec.h>
  10.  
  11. #include <iff/iff.h>
  12. #include <iff/iffpragmas.h>
  13.  
  14. #include "hame_pragmas.h"
  15. #include "HameStruct.h"
  16. #include "HameProtos.h"
  17. #include "HameRev.h"
  18.  
  19. #include "View_define.h"
  20. #include "ViewProtos.h"
  21.  
  22. extern struct IntuitionBase *IntuitionBase;
  23. extern struct GfxBase *GfxBase;
  24. extern struct Library *HameBase;
  25. extern struct IFFBase *IFFBase;
  26. extern struct AslBase *AslBase;
  27.  
  28.  
  29. extern struct NewScreen newscreen;
  30. extern struct NewWindow newwindow;
  31. extern struct Screen  *imageScreen;
  32. extern struct Window  *imageWindow;
  33. extern struct Window  *sw;
  34. extern struct Window  *credwin;
  35. extern struct Window  *gWindow;
  36. extern struct MsgPort *messagePort;
  37. extern struct ViewPort *frontViewPort;
  38. extern struct HamePort *hamePort;
  39.  
  40. extern ULONG signalmask, signals;
  41.  
  42. extern int width, height;
  43. extern int mode;
  44. extern struct TagItem sTag[];
  45.  
  46. /* Open up all the graphics: screen, window, and construct a
  47.    message port to be used by more than one window */                  
  48. VOID
  49. openGraphics()
  50. {    
  51.    int cookies=4;
  52.    
  53.    if(!IntuitionBase)  
  54.       IntuitionBase = (struct IntuitionBase *)
  55.                      OpenLibrary("intuition.library",INTUITION_REV);
  56.    if(IntuitionBase == NULL)
  57.       myExit("Intuition Library");
  58.    
  59.    if(!GfxBase)
  60.       GfxBase = (struct GfxBase *)
  61.                      OpenLibrary("graphics.library",GRAPHICS_REV);
  62.    if(GfxBase == NULL)
  63.       myExit("Graphics Libarary");      
  64.    
  65.    if(!AslBase)
  66.       AslBase = (struct AslBase *)
  67.                      OpenLibrary("asl.library",36L);
  68.    if(AslBase==NULL)
  69.       myExit("asl.library");                                    
  70.       
  71.    if(!HameBase) 
  72.       HameBase = (struct Library *)
  73.                      OpenLibrary("hame.library",1L);
  74.    
  75.    if(!IFFBase)
  76.       IFFBase = (struct IFFBase *)
  77.                      OpenLibrary("iff.library",IFFVERSION); 
  78.    if(IFFBase == NULL)
  79.       myExit("iff.library");
  80.                                 
  81.    
  82. /*   if((HameBase!=NULL) && (gWindow==NULL) ) {
  83.       newscreen.Width=HIRES_WIDTH;
  84.       newscreen.Height=HEIGHT;
  85.       newscreen.LeftEdge=S_LEFTEDGE;
  86.       newscreen.TopEdge=S_TOPEDGE;
  87.       newscreen.ViewModes=HIRES;
  88.       newscreen.Depth = 4;
  89.       mode = COLORS_LACE_16;
  90.    } 
  91. */     
  92.    imageScreen = OpenScreenTagList(&newscreen,sTag);
  93.    if(imageScreen == NULL) myExit("OpenScreen()");
  94.    
  95.    
  96.    newwindow.Screen = imageScreen;
  97.    
  98.    if(messagePort==NULL) messagePort = CreatePort(NULL,0);
  99.    
  100.       /* Adjust the sizes of the image window, considering the screen
  101.          size */
  102.          newwindow.Width = imageScreen->Width;
  103.          newwindow.Height = imageScreen->Height;
  104.       
  105.          newwindow.Flags = SMART_REFRESH | NOCAREREFRESH | BACKDROP
  106.                            | BORDERLESS | RMBTRAP;
  107.          newwindow.TopEdge =  0;
  108.          newwindow.LeftEdge = 0;               
  109.  
  110.       newwindow.Screen = imageScreen;
  111.       imageWindow = OpenWindow(&newwindow);
  112.       if(imageWindow == NULL) myExit("Open Window()");
  113.       if(imageWindow->UserPort) DeletePort(imageWindow->UserPort);
  114.       imageWindow->UserPort = messagePort;
  115.       ModifyIDCMP(imageWindow,GADGETDOWN|MOUSEBUTTONS);
  116.       
  117.       frontViewPort = ViewPortAddress(imageWindow);
  118.       ShowTitle(imageScreen,0L);
  119.       
  120.       if( (mode==HAME) || (mode==HAME_LACE) ) 
  121.       {
  122.          if(mode==HAME_LACE) cookies=8;
  123.          hamePort = HAME_Init( imageScreen, imageScreen->Width,
  124.                                imageScreen->Height,
  125.                                imageScreen->Height,
  126.                                0,
  127.                                0,
  128.                                4,
  129.                                imageScreen->Height-cookies);
  130.          if(hamePort==NULL) myExit("HamePort");                               
  131.       }                        
  132.       setColors(mode);
  133.       
  134.       
  135.       signalmask = 1L << messagePort->mp_SigBit;
  136.    
  137. }
  138.  
  139. VOID 
  140. creditScreen(VOID)
  141. {
  142.    APTR ifffile=NULL;
  143.    int ret=0;
  144.    UWORD colortable[128];
  145.    
  146. /*   if(HameBase) 
  147.    {
  148.       ifffile = NewOpenIFF("HEtitle.iff",MEMF_PUBLIC);
  149.       if(ifffile)
  150.       {
  151.          GetColorTab(ifffile,colortable);
  152.          LoadRGB4(&(imageScreen->ViewPort),colortable,16);
  153.          ret = DecodePic(ifffile,&imageScreen->BitMap);
  154.          RemakeDisplay();
  155.          CloseIFF(ifffile);
  156.       }
  157.    }
  158.    else */
  159.    {
  160.       ifffile = NewOpenIFF("title.iff",MEMF_PUBLIC);
  161.       if(ifffile)
  162.       {
  163.          GetColorTab(ifffile,colortable);
  164.          LoadRGB4(&(imageScreen->ViewPort),colortable,32);
  165.          ret = DecodePic(ifffile,&imageScreen->BitMap);
  166.          RemakeDisplay();
  167.          CloseIFF(ifffile);
  168.       }
  169.    }
  170. }
  171.