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 / HDFView.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-03  |  3.0 KB  |  141 lines

  1. /* An simple HDF image viewer 
  2.    4/26/91 Richard A. Gerber
  3. */
  4.  
  5. #include <exec/types.h>
  6. #include <exec/memory.h>
  7. #include <exec/ports.h>
  8. #include <intuition/intuition.h>
  9. #include <libraries/dos.h>
  10. #include <graphics/gfxbase.h>
  11. #include <graphics/gfxmacros.h>
  12.  
  13. #include <proto/exec.h>
  14. #include <proto/intuition.h>
  15. #include <proto/dos.h>
  16. #include <proto/graphics.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <math.h>
  21.  
  22. #include <libraries/asl.h>
  23. #include <iff/iff.h>
  24.  
  25.  
  26. #include "hame_pragmas.h"
  27. #include "HameStruct.h"
  28. #include "HameProtos.h"
  29. #include "HameRev.h"
  30.  
  31. #include "View_define.h"
  32. #include "View_screen.h"
  33. #include "View_window.h"
  34. #include "ViewProtos.h"
  35. #include "ViewRequester.h"
  36. #include "globals.h"
  37.    
  38. VOID main(int argc, char *argv[])
  39. {
  40.    UBYTE done = 0;
  41.    setGlobalColors(); 
  42.    
  43.    mode=COLORS_LACE_32;
  44.    getDefPal(NULL);                          /* 32 color mode */
  45.    openGraphics();
  46.    creditScreen();
  47.    Delay(1*50);
  48.    
  49.    gadgetScreen();
  50.    
  51.    newscreen.Height = HEIGHT;
  52.    newscreen.Width = WIDTH;
  53.    newscreen.TopEdge = S_TOPEDGE;
  54.    newscreen.LeftEdge = S_LEFTEDGE;
  55.    newscreen.ViewModes = NULL;
  56.    newscreen.Depth = 5;
  57.    mode=COLORS_32;
  58.     
  59.    while (!done)                       /* Wait for IDCMP messages */
  60.    {
  61.       signals = Wait(signalmask);
  62.       if (signals & signalmask)
  63.          done = handleIDCMP();
  64.    };
  65.    
  66.    myExit(NULL);
  67.    
  68. }
  69.  
  70.  
  71.  
  72.  
  73. /* Exit program, returning all resources to the system */
  74.  
  75. VOID myExit (text)
  76. char *text;
  77. {
  78.       char fullmsg[81];
  79.       
  80.       if (imageWindow) closeWind( imageWindow );
  81.       if(sw) closeWind(sw);
  82.       if(credwin) closeWind(credwin);
  83.       if(gWindow) closeWind(gWindow);
  84.                      
  85.       if ( messagePort ) DeletePort(messagePort);
  86.    
  87.       
  88.       if (hamePort) HAME_Dispose(hamePort);
  89.       if (imageScreen) CloseScreen( imageScreen );
  90.       if (gScreen) CloseScreen( gScreen );      
  91.    
  92.    if (IntuitionBase) CloseLibrary( (struct Library *)IntuitionBase );
  93.    if (GfxBase) CloseLibrary( (struct Library *)GfxBase );
  94.    if (HameBase) CloseLibrary( (struct Library *)HameBase );
  95.    if (IFFBase) CloseLibrary( (struct Library *)IFFBase );
  96.    if (AslBase) CloseLibrary( (struct Library *)AslBase );
  97.  
  98.  
  99.       if(image)
  100.          FreeMem(image,width*height*sizeof(char));
  101.    
  102.    if(text) {
  103.       sprintf(fullmsg,"Program ending. Problem with: %s.",text);
  104.       request(fullmsg,NULL);
  105.    }
  106.    exit(0);
  107. }
  108.     
  109.  
  110. /* Another in the very useful RKM routines. Closes down a window
  111.    in a nice manner while leaving a shared message port intact.
  112. */       
  113. VOID
  114. closeWind(struct Window *w)
  115. {
  116.    struct IntuiMessage *msg, *succ;
  117.    
  118.    Forbid();
  119.    
  120.    msg = (struct IntuiMessage *)messagePort->mp_MsgList.lh_Head;
  121.    
  122.    while(succ = (struct IntuiMessage *)msg->ExecMessage.mn_Node.ln_Succ)
  123.    {
  124.       if(msg->IDCMPWindow == w)
  125.       {
  126.          Remove((struct Node*)msg);
  127.          ReplyMsg((struct Message*)msg);
  128.       }
  129.    msg = succ;
  130.    }
  131.    
  132.    w->UserPort = NULL;
  133.    ModifyIDCMP(w,0);
  134.    Permit();
  135.    CloseWindow(w);
  136. }
  137.  
  138.  
  139.  
  140.  
  141.