home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DVPG30FS.ZIP / VIEW-VAR.C < prev    next >
C/C++ Source or Header  |  1993-12-04  |  11KB  |  241 lines

  1. /*
  2.  * this is all global variables used by the viewer
  3.  */
  4.  
  5. #include "viewdef.h"        /* include all of the size definations */
  6. #include "jinclude.h"
  7. #include <time.h>
  8.  
  9. /*unsigned int JPEG_BUF_SIZE;        /* taken from a #define in the JPEG code to allow for a larger buffer */
  10.  
  11. /* amount of memory free after decoding a picture after all memory is alloced ... */
  12. unsigned long
  13. near_memory_view, far_memory_view;
  14.  
  15. char picture_description[file_name_len];        /* description of picture - read from a 4DOS file DESCRIPT.ION - perhaps add into my info later on */
  16.  
  17. char picture_text[file_name_len];            /* file-name to be put on the screen before and optionally after drawing picture  ie file name or a defined string */
  18. char picture_text_arguement[file_name_len];            /* title passed in as an arguement, either len 0 or the string */
  19.  
  20. char picture_title[file_name_len];            /* title to be put on the screen before and optionally after drawing picture  ie file name or a defined string */
  21. char picture_title_arguement[file_name_len];            /* title passed in as an arguement, either len 0 or the string - usually the 4DOS description */
  22.  
  23. int tint_loaded;                    /* flag to indicate if tinting adjustments are loaded for a picture */
  24.  
  25. char file_masks[max_file_masks][13];        /* array of file masks (14 char each ie 8.3 format + null), 0 if not used, string otherwise */
  26.  
  27. struct dir_info{            /* struct for file names, size ... */
  28.     char name[13];
  29.     char slide_num;                /* number (viewing order) for slide show ie 0=not used; 1 = first, 2 = 2nd ... */
  30.     unsigned  date;
  31.     long size;
  32.     } far * file_info_head;        /* pointer to start of whole struct */
  33.  
  34. time_t time_at_start;        /* slideshow delay timer */
  35.  
  36.  
  37. /* buffer pointer for panning if needed/possible */
  38. big_sarray_ptr raw_pic_ptr;        /* pointer to virt. pic. for panning, 3 used for hi_color mode; 1 otherwise */
  39.  
  40. int video_display_resolution;        /* used by dithering routines to calc. the error due to the 5, 6, 8 bit video display */
  41.                                             /* normal values are 1111,1000; 1111,1100; 1111,1111 */
  42. JSAMPARRAY remap;                /* colormap array for remaping 256 color GIF -> 16 grayscale for 16 color modes */
  43. JSAMPARRAY tint_table;        /* table to speed up tinting of 15/16/24 bit modes using look-up */
  44.  
  45. int current_graphics_mode,            /* set to the current graphics mode or -1 to save resetting the graphics screen all the time ie locked video mode */
  46.     mode_lock;                            /* either -1 or the video Y resolution that the user want to be locked into */
  47.  
  48. int config_found = 0;                /* set to 1 if configuration file is found/loaded, 0 otherwise */
  49.  
  50. int type_of_picture;    /* enum holding type of picture ie GIF, PBM, TGA ...*/
  51. int jpeg_type;            /* type of jpeg ie h2v2, h1v2, .... right now this is 1 for h2v2, 0 otherwise */
  52. int row_ordering;        /* enum holding format of picture ie INTERLACED, NORMAL, UPSIDE_DOWN */
  53. unsigned char far * line_buffer_ptr;        /* pointer to a buffer for 1 drawn line -> maximum 640 * 3 = 1920 bytes (currently) */
  54.  
  55. /*
  56.  * definations common to vidsetup and dvpeg
  57.  *
  58.  */
  59.  
  60. /* these are for the graphics interface */
  61.  
  62.     int twiddle_factor = 5;            /* the amount of "play" in pic size before the image shrinks or pans (X or Y axis)
  63.                                                 ie if the pick is < 640 + twiddle it will not use panning or shirk on a 640 wide screen ... */
  64.     unsigned char palbuf[256][3];
  65.     int svga;
  66.     int video_mode_used;    /* mode number index (into the video_cards array of data) for the viewing mode */
  67.     int card_used;          /* the current selected mode for viewing */
  68.     int card_id;            /* card id # - as found by autodetection (valid if svga = 1) */
  69.     int enable_pan;         /* enough memory for panning && needed?? */
  70.     int shrink;             /* 1 = normal, 2 = 1/2, 3 = 1/3 ... */
  71.     int zoom_inc;                /* zoom increment, if shrink = 1; zoom_inc, size = {3, 2:1; 2, 3:1; 1, 4:1; 0, 5:1}
  72.                                     /* for shrink > 1, zoom_inc must = 4 */
  73.     int any_hi_color;            /* flag to indicate presence of hi_color modes - only used by viewer */
  74.     int text_mode_number;    /* int 10 number for setting the video mode */
  75.     int text_height;            /* height of the custom text mode */
  76.     int slideshow_pause;        /* pause after a pic during slide show */
  77.  
  78.    int number_pallet_colors;        /* number of colors in the pallet used, usually 16 or 256 */
  79.     int x_max;                /* physical pixel size of the screen */
  80.     int y_max;
  81. /* maxx is the width of 1 line in video memory in bytes */
  82.  
  83. int
  84.     image_x_dim,    /* the actual image width in pixels */
  85.     image_y_dim,
  86.  
  87. /* these are the offsets of the image into the viewing window (if image < screen size)
  88.  *  - the only case not handled is having the image larger than the screen
  89.  */
  90.     image_x_offset,
  91.     image_y_offset,
  92.  
  93. /* now the maximum pixel values for the lower right corner of the image */
  94.     image_x_max,
  95.     image_y_max,
  96.  
  97.     bytes_per_pixel;            /* the number of bytes per pixel on the screen */
  98.  
  99. /* now do the image specific info
  100.  * ie what row do we start showing the image at?  picture_y_offset, picture_x_offset
  101.  * what is the maximum row?  the size ?    picture_max_y, picture_max_x, picture_x_dim, picture_y_dim
  102.  */
  103. int
  104.     picture_x_offset,
  105.     picture_y_offset,
  106.  
  107.     picture_x_center,        /* center of the picture, as displayed on the screen */
  108.     picture_y_center,
  109.  
  110.     picture_x_dim,
  111.     picture_y_dim,
  112.  
  113.     picture_x_max,
  114.     picture_y_max,
  115.  
  116.     picture_x_size,
  117.     picture_y_size,    /* picture size in picture elements */
  118.  
  119.     bytes_per_line,                /* the actual number of bytes storage for each video line */
  120.     visable_bytes_per_line;        /* the number of bytes for each visable line - ie for memory copying */
  121.  
  122. int
  123.     first_file,
  124.     number_files,
  125.     number_pages,
  126.     per_page,
  127.     num_cols,
  128.     column_width,
  129.     selected_file;
  130.  
  131. /* now some stuff for the configuration file */
  132.  
  133. char config_name[file_name_len];            /* path to configuration file -> assuem its in the same dir as vidsetup.exe */
  134. char default_path[file_name_len] = "";    /* default path to pictures */
  135.  
  136. int
  137.     view_defaults,        /* defaults from lsb up: grey_scale, dithering, smoothing, quantize, panning*/
  138.     more_defaults,        /* more defaults from the viewer */
  139.     defaults;                /* more viewing defaults in a bit pattern */
  140.  
  141. int    text_width,            /* text screen width - currently 80 char */
  142.         text_mode,            /* mode for the text screen */
  143.         sort_mode,            /* method to sort file list by */
  144.         buffer_ok,            /* setvbuf return flag, 0 indicates buffer was allocated */
  145.         buffer_size;        /* size of the viewing buffer, 8k default, 32k max  ie to speed up viewing */
  146.  
  147. /* These static variables are needed by the error routines. */
  148. /*static jmp_buf setjmp_buffer;    /* for return to caller */
  149. int exit_draw;            /* flag to indicate exiting the showing of a picture */
  150.  
  151.  
  152. /* stuff for file selection */
  153. char file_path[file_name_len];    /* current path to files to be viewed */
  154. char original_path[file_name_len];    /* the original or boot path - used to check for config file, default file .... */
  155. char code_path[file_name_len];        /* path to the executable code - used to search for config file as a last resort */
  156. char file_being_viewed[20];    /* current file being viewed */
  157. int  show_next_file;        /* flag to jump to next file in the list without menu stuff */
  158. int drive_list[drive_list_length];        /* list of good drives - floppy & hard */
  159. unsigned int
  160.     max_drives;            /* the maximum number of drives available */
  161.  
  162. int    sort_mode,        /* sort type for file names */
  163.     per_column,            /* the number of files per column on text screen */
  164.     files_per_page,    /* nominal # files per page ie 22 * 6 wide */
  165.     cols_per_page,        /* nominal # columns ie 2 blanks at sides */
  166.     min_col_width,        /* minimum column width currently 13 char (includes spaces) */
  167.     max_col_width,        /* maximum column width - currently 26 */
  168.     do_slide_show,        /* slide show flag to other modules */
  169.     video_resolution,    /* flag for type of video mode being used ie VGA,SVGA,SVGA_15_bit, ... */
  170.     lock_shrink_value,    /* value that the shrink is locked to */
  171.     text_drawing_for,        /* color to draw the text in the 256 color modes */
  172.     text_drawing_bk,        /* background ie color under the text drawn */
  173.     key_hit;                /* flag that a non ESC key was hit during decompression */
  174.  
  175.  
  176. /* globle tint, contrast, bright controls used in drawing routines
  177.  * these can be set from a user data base of personal preferces
  178.  */
  179. /* variables which should be initialized externally before any drawing */
  180. int red_tint, green_tint, blue_tint,    /* red, green, blue tint controls */
  181.     color_scale,        /* factor to scale pallete up or down  0 -> 32 */
  182.     contrast_scale,    /* factor to scale contrast up or down  0 -> +/-32 */
  183.     tint_factor_1,    /* intermediate variables for tint calculations ie it speeds up the calculations greatly */
  184.     tint_lookup,        /* lookup table version of tint_factor_1 for 15/16/24 bit tinting */
  185.     tint_factor_red,
  186.     tint_factor_blue,
  187.     tint_factor_green,
  188.  
  189.     allow_video_exit;        /* if set you can exit from panning/tint routines - if 0 then the whole screen must be repainted */
  190.  
  191. /* from put_pixel_rows - taken out so I can re-init them for 2nd, 3rn ... calls for pictures */
  192. int gr_row = 0,          /* gr_row,col for pixel plotting*/
  193.     gr_col,
  194.     col_cntr = 1,        /* column and row counters for shrinking */
  195.     row_cntr = 1,
  196.     read_row = 0;        /* row for indexing into big buffer for reading ie panning */
  197.  
  198.  
  199. /*
  200.  * this structure contains the info as stored in the dvpeg.vu file
  201.  * it has all the info necessary to setup the screen as the user left it
  202.  * complete with tint, zoom, ... info
  203.  */
  204.  
  205. struct view_info {
  206.     char file_name[13];        /* name in the 8.3 format with a terminating char */
  207.     char resolution;            /* resolution (ie SVGA, 15 bit, 24 bit ) */
  208.     char shrink;                /* shrink factor ie 1, 2, 3, 4 */
  209.     char red_tint;
  210.     char green_tint;
  211.     char blue_tint;
  212.     char contrast;
  213.     char bright;
  214.     int offset_x;        /* offset of the image - ie upper right corner to be viewed */
  215.     int offset_y;
  216.     int video_size_x;    /* size of the video screen in pixels */
  217.     int video_size_y;
  218.     } view_setup_info;
  219.  
  220. /*
  221.  * this is used by the viewer only
  222.  * vidsetup has the struct declared and define in modes.h
  223.  *
  224.  * This fully specs each video mode.
  225.  * There are two lists that point to it from dvpeg.  One is ok_mode which is
  226.  *   a list of modes that are "ok" for the current picture.  The other list
  227.  *   is called all_modes[].
  228.  */
  229.  
  230. #ifdef dvpeg_viewer
  231.  
  232. struct video_card {
  233.     int card_number;        /* same index as video_card_names and list in .asm video routines; a -1 indicates an unused struct slot */
  234.     int x_size;
  235.     int y_size;
  236.     int resolution;    /* check enum:  0 = 256, 1 = 15 bit, 2 = 24 bit */
  237.     int set_ax;        /* value to force AX, BX */
  238.     int set_bx;
  239.     int x_width;        /* x_width for odd sizes ie 15, 24 bit its the number of bytes per vertical row */
  240.     } video_cards[number_modes_in_list];
  241. #endif