home *** CD-ROM | disk | FTP | other *** search
/ GRIPS 2: Government Rast…rocessing Software & Data / GRIPS_2.cdr / dos / pcshow / src / msc5_1 / impro.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-06  |  14.2 KB  |  298 lines

  1. /* include statements */
  2.  
  3. #include <stdio.h>        /* standard i/o routines */
  4. #include <fcntl.h>        /* other standard routines */
  5. #include <stdlib.h>        /* more lattice c standard i/o routines */
  6. /*#include <tardev.h>        /* targa header files */
  7. #include <math.h>        /* some math functions needed */
  8. /*#include <time.h>        /* some time functions needed */
  9. #include <dos.h>        /* used for NO9 init call */
  10. #include <ctype.h>        /* used for some character testing */
  11. #include <memory.h>        /* used for some memory allocation routines */
  12. #include <direct.h>        /* used for some directory routines */
  13. #include <search.h>        /* used for some search and sort routines */
  14. #include <string.h>        /* string functions */
  15. #include <io.h>            /* used for mktemp call */
  16. #include "df.h"            /* header file with defines for HDF */
  17.  
  18. #ifndef LATTICE
  19. typedef unsigned char byte;
  20. #endif
  21. typedef unsigned long ulong;
  22.  
  23. #include "externs.h"    /* declarations of the variable types of routines in ImProVise */
  24.  
  25. /* define statements */
  26. #define MOUSE                    /* define this variable if a mouse is to be used with this program */
  27. #define TRUE            1
  28. #define FALSE            0
  29. #define HI                2
  30. #define LO                3
  31. #define    SCRLLEFT        203        /* the values returned from my getchar() routines for keys on the keypad */
  32. #define    SCRLUP            200
  33. #define    SCRLDOWN        208
  34. #define    SCRLRIGHT        205
  35. #define    PAGEUP            201
  36. #define    PAGEDOWN        209
  37. #define    HOME            199
  38. #define    END                207
  39. #define ALTSCRLUP        152
  40. #define ALTSCRLDOWN        160
  41. #define ALTSCRLLEFT        155
  42. #define ALTSCRLRIGHT    157    
  43. #define ALTPAGEUP        153
  44. #define ALTPAGEDOWN        161
  45. #define ALTHOME            151
  46. #define ALTEND            159
  47. #define NO9            '9'            /* attempting to make references to which mode we are in easier */
  48. #define    VGA            'v'
  49. #define    EGA            'e'
  50. #define    TARGA        't'
  51. #define HDF            'h'
  52. #define RASTER        'b'
  53. #define TIFF        't'
  54. #define SDS            's'
  55. #define TEMPINFO    (*temp_list).wind_info
  56. #define SQR(x)        x*x
  57. #define PI            3.1415926535898
  58. #define LEFTARROW    0            /* actual ascii codes for these character names in the font */
  59. #define RIGHTARROW    1
  60. #define CLOSEBOX    2
  61. #define DOWNARROW    3
  62. #define    UPARROW        4
  63. #define    RESIZE        5
  64. #define    FILLTEXT    6
  65. #define    OPENFULLY    7
  66. #define LEFTEDGE    8
  67. #define    VERTBAR        16
  68. #define    HORIBAR        24
  69. #define SUPERN         30
  70. #define HIDE_BORDER 31
  71. #define ENTER        13
  72. #define ESCAPE        27
  73. #define SPACE        32
  74. #define DASH        10
  75. #define RAWSIZE 32000    /* maximum size of the block to be read in from disk */
  76. #ifdef QAK
  77. #define LINEEGA        egaline(xwhere,ywhere+i,store[i+yoff],xoff,max(min(xdim-xoff,maxx-xwhere),0)) /*,trans)*/
  78.     /* call to print a line on the ega screen */
  79. #define LINEVGA       vgaline1(xwhere,ywhere+i,store[i+yoff],xoff,max(min(maxx-xwhere,xdim-xoff),0))
  80.     /* call to print a line on the vga screen */
  81. #define LINENO9       no9line(xwhere,ywhere+i,store[i+yoff],xoff,max(min(maxx-xwhere,xdim-xoff),0))
  82.     /* call to print a line on the no. 9 screen */
  83. /*#define LINET16       t16line(xwhere,ywhere+i,store[i+yoff],xoff,max(min(maxx-xwhere,xdim-xoff),0))*/
  84.     /* call to print a line on the Targa16 screen */
  85. #endif
  86.  
  87. /* regular variables defined */
  88.  
  89. int    i,j,k,l,c,            /* temporary global counters and such */
  90.     xdim,ydim,            /* x & y dimensions for the image to be displayed */
  91.     file,                /* the file pointer for binary files */
  92.     pal_window=-1,        /* index to the window which contains the palette */
  93.     pal_hid=0,            /* whether the palette is hidden or not */
  94.     maxx=640,maxy=350,    /* the x & y dimensions of the default EGA screen */
  95.     lastref,            /* the last reference number used in palette searching */
  96.     lasttag,            /* the last tag number used in searching for palettes */
  97.     newref,                /* reference number for a new palette */
  98.     imref,                /* the current image's reference number */
  99.     imtag,                /* the current image's tag number */
  100.     animate=0,            /* the animation toggle */
  101.     one_file=0,            /* the one file animation toggle */
  102.     first_hdf=1,        /* boolean to flag the first time through an hdf animation */
  103.     oneimage=0,            /* boolean variable to indicate whether there are multiple binary images to be displayed */
  104.     leftbutton,            /* boolean variables for buttons on the mouse */
  105.     rightbutton,
  106.     mx,my,                /* last position where the mouse was at */
  107.     anispeed=0,            /* speed for animation */
  108.     doneinit=0,            /* boolean variable to keep track of whether the palette has been initialized for ega mode */
  109.     getout=0,            /* boolean variable to exit program */
  110.     pal_height=16,        /* height in bytes of the color bar on the screen */
  111.     expandit=1,            /* preference variable to do: contours (2), expand(1) or interpolate(0) */ 
  112.     contour_num=10,        /* number of contour levels for contour plot */
  113.     pal_mode=0,            /* which palette mode you are performing: drag & place (1), or rotate(0) */
  114.     window_num,            /* variable to keep track of the window open */
  115.     first_window=1,        /* boolean variable to keep track of the first window opened */
  116.     first_palette=1,    /* boolean to keep track of the first palette input */
  117.     font_width,            /* the width in pixels of a font character */
  118.     font_height,        /* the height in poixels of a font character */
  119.     font_space,            /* the amount of bytes a font character takes up */
  120.     file_err,            /* the error returned from file operations */
  121.     file_attr,            /* the file attribute to look for */
  122.     clear_color=0,        /* the color to clear to */
  123.     def_drive=4,        /* variable to set the default drive  A=0, B=1, ...*/
  124.     do_anim=0,            /* boolean whether animations are operating in the background */
  125.     top_image=-1,        /* window number of the top image in the window list */
  126.     contour_levels[26],    /* an array of contour levels for the picture */
  127.     *hide_num;            /* pointer to the length of the hide palette text */
  128.  
  129. unsigned int m1,m2,m3,m4;        /* mouse variables */
  130.  
  131. double def_xmag=1.0,    /* the default x magnification */
  132.     def_ymag=1.0;        /* the defualt y magnification */
  133.  
  134. /*unsigned short int l16[512];    /* array for the targa line */
  135.  
  136. char *p,                /* temporary character storage */
  137.     mode=EGA,            /* the display mode we are in = EGA,VGA,NO9,TARGA */
  138.     filetype=HDF;        /* the type of file to be read = 'h,'b' */
  139.  
  140. byte rmap[256],gmap[256],bmap[256],    /* the red, green, and blue bytes for 24 bit palettes */
  141.             *charset[128],                        /* pointers to the font data for windows */
  142.             filename[128],                        /* name of binary image file */
  143.             *scrap_name,                        /* the name of the scrapbook data */
  144.             **hide_name,                        /* handle of the hide palette pointer */
  145.             def_path[64]="\\improvis",            /* the default path to find improvise in */
  146.             dial_path[64],                        /* the path to the dialog box directory */
  147.             canvas_path[64],                    /* the path to the canvas directory */
  148.             palfile[128] = {0,0},                /* starts out = NULL */
  149.             trans[256]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},            /* translation table for palette in ega mode */
  150.             pal[768],                            /* for writing the palette out */
  151.             count[64],                            /* the colors to choose from in ega mode */
  152.             regrs[16];                            /* the actual palette for ega mode */
  153.  
  154. extern byte *DTAPTR;        /* pointer to a DTA containing filenames to be found (located in dosio.asm) */
  155.  
  156. FILE    *fp,    /* file pointer for binary image files */
  157.         *pfp;    /* file pointer for binary palette files */
  158.  
  159. /* number nine variables */
  160. char *NO9ram;
  161. int *NO9bank;         /* bank control registers */
  162.  
  163. typedef struct pentry {        /* define a palette entry format */
  164.     byte red,
  165.         green,
  166.         blue;
  167.   }pal_entry;
  168.  
  169. typedef struct pnode {        /* define a node structure for a palette linked list */
  170.     pal_entry    orig[256],        /* the original, unmodified palette */
  171.         updt[256],                /* the palette changes from the last palette mode */
  172.         mod[256];                /* the changed palette */
  173.     byte trans[256];            /* a copy of the translation table for ega palettes */
  174.     byte ega_regs[16];            /* a copy of the ega registers */
  175.     byte pal_name[128];            /* the file name of the palette */
  176.     int    cond;                    /* the condition of the palette, (0) - unmodified, (1) - modified */
  177.     struct pnode *next_node;    /* a pointer to the next node in the palette list */
  178.   }palette;
  179.  
  180. palette *head_pal,*curr_pal;        /* pointer to the head of the palette list and a pointer to the current palette being used */
  181.  
  182. struct over_list {    /* structure for a list of things to overlays on a window */
  183.     int    over_num,                    /* the number of the overlay */
  184.         type,                        /* what type of overlay this is (0 - line, 1 - grid, 2 - circle, 3 - rectangle, 4 - point, 5 - ellipse, 6 - window grid, 7 - image grid) */
  185.         x0,y0,                        /* location of the upper left hand corner of the overlay */
  186.         x1,y1,                        /* location of the lower right hand corner of the overlay */
  187.         rad,                        /* the radius of the circle */
  188.         xtype,ytype,                /* what type of grid spacing in the x and y directions (0 - linear, 1 - log)*/
  189.         xspace,yspace;                /* spacing (in pixels) between lines of a grid */
  190.     struct over_list *next_node;    /* pointer to the next button */
  191.   };
  192.  
  193. struct button_list {    /* structure for a list of button (in a window?) */
  194.     int x0,y0,                        /* location of the upper left hand corner of the button */
  195.         x1,y1,                        /* location of the lower right hand corner of the button */
  196.         num;                        /* the button number */
  197.     struct button_list *next_node;    /* pointer to the next button */
  198.   }**menu_button;
  199.  
  200. struct menu_list {    /* structure for the list of menu functions available */
  201.     byte *menustr;            /* pointer to a string for the menu function */
  202.     byte char_choice;        /* character which corresponds to the menu choice */
  203.     int        level_num;                /* a code for the level of the menu this function is at */
  204.     int        command_num;            /* a code for the command number on a level */
  205.     unsigned int    data_length;    /* the length of the string */
  206.     struct menu_list *next_node,    /* pointer to the next node on this level */
  207.         *prev_node;                    /* pointer to the previous node on this level */
  208.     struct menu_list *up_node,        /* pointer to the next level up */
  209.         *down_node;                    /* pointer to the next level down */
  210.   }*head_menu;
  211.  
  212. struct data_list {    /* structure for a list of data blocks for a window */
  213.     byte *dataptr;            /* pointer to a block of image */
  214.     int        block_num;                /* the block number in the list of blocks */
  215.     int        hi_lite;                /* boolean to determine if text should be high lighted on the screen */
  216.     unsigned int data_height,        /* the number of lines in this block */
  217.         data_length;                /* the length (in bytes) of a line in this block */
  218.     struct data_list *next_node;    /* pointer to the next node in the list */
  219.   }*head_data,*scrap_data;
  220.   
  221. struct info {    /* window information structure */
  222.     int    x0,y0,                    /* the location of the window on the screen */
  223.         print_width,            /* the width of the screen which can have data in it */
  224.         print_height,            /* the height of the screen which can have data in it */
  225.         print_x0,                /* the actual screen location to print data at in the x direction */
  226.         print_y0,                /* the actual screen location to print data at in the y direction */
  227.         xwhere,ywhere,            /* where in the window data is being shown */
  228.         save_width,                /* the width of the saved window data */
  229.         save_height,            /* the height of the saved window data */
  230.         border,                    /* whether this window has a border around it */
  231.         x_width,y_height;        /* the width and height of the window */
  232.     byte hidden,        /* boolean variable whether the window is hidden or not */
  233.         text_type,                /* whether the text in the window should be printed horizontally ('h') or vertically ('v') */
  234.         wind_id,                /* the window id character */
  235.         info1,                    /* a character which has info about the window */
  236.         info2;                    /* another character for info about the window */
  237.   };
  238.   
  239. struct wind_list {
  240.     struct info wind_info;            /* information about the window */
  241.     struct data_list *wind_data;    /* a list of window data */
  242.     struct over_list *wind_over;    /* a list of overlays for the window */
  243.     palette *wind_pal;                /* pointer to the palette for this window */
  244.     int    wind_num;                    /* the window number */
  245.     byte *wind_name,        /* the name of the window */
  246.         data[3];                    /* a 3 character wide data field for info about the window */
  247.     struct wind_list *next_node,    /* pointer to the next node in the linked list */
  248.         *prev_node;                    /* pointer to the previous node in the linked list */
  249.   }*head_list, *tail_list;
  250.  
  251. struct anim_list {
  252.     char *name;                        /* the name of the file */
  253.     int    is_hdf_file,                /* whether a file is hdf or not */
  254.         imtag,imref,                /* the tag and ref numbers for hdf files */
  255.         width,height,                /* the x and y dimensions of the image */
  256.         count;                        /* the number of this file in the sequence of animations */
  257.     struct anim_list *next_node,    /* the pointer to the next node in the linked list */
  258.         *prev_node;                    /* pointer to the previous node in the list */
  259.   }*head_anim;
  260.  
  261. struct anim_queue {                    /* a linked list of animations */
  262.     char *name;                        /* the name of the animation */
  263.     int active,                        /* whether to service this animation list */
  264.         dir,                        /* whether we are going forward (1) or backward (0) in the list */
  265.         anim_num;                    /* the window of the animation */
  266.     struct anim_list *first_node,    /* the pointer to the first node in the animation */
  267.         *curr_node;                    /* pointer to the current node in the list */
  268.     struct anim_queue *next_node;    /* pointer to the next animation list to service */
  269.   }*head_queue;
  270.  
  271. struct mouse_list {                /* a linked list of bad mouse positions */
  272.     int x0,y0,                        /* coor. of a bad area for the mouse */
  273.         x1,y1;
  274.     struct mouse_list *next_node;    /* pointer to the next animation list to service */
  275.   }*head_mouse;
  276.  
  277. struct err_code {                    /* an error code structure for better windows() error reporting */
  278.     int    error,where;
  279.   }err_type;
  280.  
  281. /* HDF stuff */
  282. DF *dff;            /* HDF file descriptor */
  283. DFdesc ddstr;        /* HDF structure for the tag & ref of something */
  284.  
  285. /* arrays and stuff for unrleit */
  286. byte *save, *savestart=NULL, *saveend=NULL;
  287.             /* save has a list of decompressed bytes not returned in
  288.                 previous call.  savestart and saveend specify the position
  289.                 at which this list starts and ends in the array save */
  290.  
  291. extern void vgaline1(),vgapt(),outlinev(),inversev(),vgablock(),line13(),invert13(),circle13(),incirc13();    /* vga routines */
  292. extern void no9line(),no9pt(),outline9(),inverse9(),no9block(),lineno9(),invert9(),circle9(),incirc9();        /* no9 routines */
  293. extern void egaline(),egapt(),outlinee(),inversee(),egablock(),line10(),invert10(),circle10(),incirc10();        /* ega routines */
  294.  
  295. void (*drawline)(),(*drawpt)(),(*outline)(),(*inverse)(),(*drawblock)(),(*invert_line)(),(*b_line)(),(*invert_ellipse)(),(*draw_ellipse)();    /* function pointers for drawing lines, points, etc. */
  296.  
  297. byte *wind_message="window_num";
  298.