home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SLOWRUNS.ZIP / SLOWSRC.ZIP / MAGIC4.H < prev    next >
C/C++ Source or Header  |  1997-08-28  |  8KB  |  233 lines

  1. /* magic4.h */
  2.  
  3. #define SCREEN_DARKNESS      0        // fade to black
  4. #define SCREEN_WHITENESS     1        // fade to white
  5. #define SCREEN_WARP             2        // warp the screen image
  6. #define SCREEN_SWIPE_X         3        // do a horizontal swipe
  7. #define SCREEN_SWIPE_Y         4        // do a vertical swipe
  8. #define SCREEN_DISSOLVE         5        // a pixel dissolve
  9. #define FULL_SCREEN_DARKNESS 6
  10.  
  11. // these are used to change the visual page of the VGA
  12.  
  13. #define CRT_ADDR_LOW            0x0D    // the index of the low byte of the start address
  14. #define CRT_ADDR_HI                0x0C    // the index of the hi byte of the start address
  15.  
  16. // mode X (if other routines supported it), Y, Z page defines
  17.  
  18. #define PAGE_0                    0
  19. #define PAGE_1                    1
  20. #define PAGE_2                    2
  21. #define PAGE_3                    3
  22.  
  23. // programmer defined types and alias's //////////////
  24.  
  25. typedef struct bitmap_typ
  26. {
  27.     int x,y;                    // position of bitmap
  28.     int width,height;            // size of bitmap
  29.     unsigned char far *buffer;  // buffer holding image
  30. } bitmap, *bitmap_ptr;
  31.  
  32.     // PCX file structure
  33.  
  34. typedef struct pcx_header_typ
  35. {
  36.     char manufacturer;            // the manufacturer of the file
  37.     char version;                // the file format version
  38.     char encoding;                // type of compression
  39.     char bits_per_pixel;        // number of bits per pixel
  40.     int x,y;                    // starting location of image
  41.     int width,height;            // size of image
  42.     int    horz_res;                // resolution in DPI (dots per inch)
  43.     int vert_res;
  44.     char ega_palette[48];        // the old EGA palette (usually ignored)
  45.     char reserved;                // don't care
  46.     char num_color_planes;        // number of color planes
  47.     int bytes_per_line;            // number of bytes per line of the image
  48.     int palette_type;            // 1 for color, 2 for grey scale palette
  49.     char padding[58];            // extra bytes
  50. } pcx_header, *pcx_header_ptr;
  51.  
  52.     // this holds the PCX header and the actual image
  53.  
  54. typedef struct pcx_picture_typ
  55. {
  56.     pcx_header header;            // the header of the PCX file
  57.     RGB_color palette[256];        // the palette data
  58.     unsigned char far *buffer;    // a pointer to the 64,000 byte buffer
  59.                                 // holding the decompressed image
  60. } pcx_picture, *pcx_picture_ptr;
  61.  
  62.     // this is a sprite structure
  63.  
  64. typedef struct sprite_typ
  65. {
  66.     int x,y;                        // position of sprite
  67.     int width,height;                // dimensions of sprite
  68.  
  69.     int counter_1;                    // some counters for timing and animation
  70.     int counter_2;
  71.     int counter_3;
  72.  
  73.     int threshold_1;                // thresholds for the counters (if needed)
  74.     int threshold_2;
  75.     int threshold_3;
  76.  
  77.     unsigned char far *frames[MAX_SPRITE_FRAMES]; // array of pointers to
  78.                                                   // the images
  79.  
  80.     int curr_frame;                    // current frame being displayed
  81.     int num_frames;                    // total number of frames
  82.     int state;                        // state of sprite, alive, dead...
  83.  
  84.     unsigned char far *background;  // image under the sprite
  85.  
  86.     int x_clip,y_clip;                // clipped position of sprite
  87.     int width_clip,height_clip;     // clipped size of sprite used
  88.     int visible;                    // by sprite engine to flag
  89.                                     // if a sprite was invisible last
  90.                                     // time it was drawn hence the background
  91.                                     // need not be replaced
  92. } sprite, *sprite_ptr;
  93.  
  94. // this is a typedef used for the layers in parallax scrolling
  95. // note it is identical to a bitmap, but we'll make a separate typedef
  96. // in the event we later need to add fields to it
  97.  
  98. typedef struct layer_typ
  99. {
  100.     int x,y;                    // used to hold position information
  101.                                 // no specific function
  102.     int width,height;            // size of layer, note: width must
  103.                                 // be divisible by 2
  104.     unsigned char far *buffer;    // the layer buffer
  105. } layer, *layer_ptr;
  106.  
  107. // E X T E R N A L S /////////////////////////////////////////////////////////
  108.  
  109. extern unsigned char far *double_buffer;     // the double buffer
  110.  
  111. extern unsigned int double_buffer_height;    // height of double buffer
  112.  
  113. extern unsigned int double_buffer_size;      // total size of buffer in bytes
  114.  
  115. extern unsigned int sprite_width;            // width of a sprite
  116.  
  117. extern unsigned int sprite_height;           // of a sprite
  118.  
  119. // MODE Z STUFF...
  120.  
  121. extern unsigned char far *page_0_buffer;     // pointer to mode z page 0
  122.  
  123. extern unsigned char far *page_1_buffer;     // pointer to mode z page 1
  124.  
  125. extern int mode_z_page;                      // current mode z page
  126.  
  127. // MODE Y STUFF...
  128.  
  129. extern unsigned char far *pagey_0_buffer;     // pointer to mode y page 0
  130.  
  131. extern unsigned char far *pagey_1_buffer;     // pointer to mode y page 1
  132.  
  133. extern unsigned char far *pagey_2_buffer;
  134.  
  135. extern unsigned char far *pagey_3_buffer;
  136.  
  137. extern int mode_y_page;                      // current mode y page
  138.  
  139. extern unsigned char far *never_displayed_buffer_mode_y;
  140.  
  141. extern unsigned char far *never_prime;
  142.  
  143. // P R O T O T Y P E S ///////////////////////////////////////////////////////
  144. // function prototypes ////////////////////////
  145.  
  146. void Screen_Transition(int effect);
  147.  
  148.     // Double Buffer stuff...
  149.  
  150. void Line_HDB(int x1, int x2, int y, int color);
  151. void Line_VDB(int y1, int y2, int x, int color);
  152.  
  153. void Write_Pixel_DB(int x, int y, int color);
  154. int Create_Double_Buffer(int num_lines);
  155. void Fill_Double_Buffer(int color);
  156. void Display_Double_Buffer(unsigned char far *buffer, int y);
  157. void Delete_Double_Buffer(void);
  158.  
  159.     // Bitmap stuff...
  160.  
  161. void Bitmap_Put(bitmap_ptr image, unsigned char far *destination, int transparent);
  162. void Bitmap_Get(bitmap_ptr image, unsigned char far *source);
  163.  
  164.     // PCX stuff...
  165.  
  166. int PCX_Init(pcx_picture_ptr image);
  167. void PCX_Delete(pcx_picture_ptr image);
  168. int PCX_Load(char *filename, pcx_picture_ptr image, int load_palette);
  169. void PCX_Show_Buffer(pcx_picture_ptr image);
  170.  
  171.     // Sprite stuff...
  172.  
  173. void Sprite_Init(sprite_ptr sprite, int x, int y, int width, int height, int c1, int c2, int c3, int t1, int t2, int t3);
  174. void Sprite_Delete(sprite_ptr sprite);
  175.  
  176. void PCX_Get_Sprite(pcx_picture_ptr image, sprite_ptr sprite, int sprite_frame, int cell_x, int cell_y);
  177.  
  178. void Sprite_Draw(sprite_ptr sprite, unsigned char far *buffer, int transparent);
  179. void Sprite_Under(sprite_ptr sprite, unsigned char far *buffer);
  180. void Sprite_Erase(sprite_ptr sprite, unsigned char far *buffer);
  181.  
  182. void PCX_Copy_To_Buffer(pcx_picture_ptr image, unsigned char far *buffer);
  183. void PCX_Copy_To_Buffer_XYZ_Mode(pcx_picture_ptr image, unsigned char far *buffer);
  184.  
  185. void fwordcpy(void far *destination, void far *source, int num_words);
  186. void fwordset(void far *destination, int color, int num_words);
  187.  
  188. void Sprite_Draw_Clip(sprite_ptr sprite, unsigned char far *buffer, int transparent);
  189. void Sprite_Erase_Clip(sprite_ptr sprite, unsigned char far *buffer);
  190. void Sprite_Under_Clip(sprite_ptr sprite, unsigned char far *buffer);
  191.  
  192. // planar Sprite Put
  193.  
  194. void Sprite_Draw_Clip_Special(sprite_ptr sprite, unsigned char far *buffer);
  195.  
  196. int Layer_Create(layer_ptr dest_layer, int width, int height);
  197. void Layer_Delete(layer_ptr the_layer);
  198. void Layer_Build(layer_ptr dest_layer, int dest_x, int dest_y, unsigned char far *source_buffer, int source_x, int source_y, int width, int height);
  199. void Layer_Draw(layer_ptr source_layer, int source_x, int source_y, unsigned char far *dest_buffer, int dest_y, int dest_height, int transparent);
  200.  
  201. void Wait_For_Vertical_Retrace(void);
  202.  
  203. // Text routines configured to OUTPUT to the double buffer
  204.  
  205. void Print_Char_DB(int xc, int yc, char c, int color, int transparent);
  206. void Print_String_DB(int x, int y, int color, char *string, int transparent);
  207. void Write_Pixel_DB(int x, int y, int color);
  208. int Read_Pixel_DB(int x, int y);
  209.  
  210. // Mode Z Stuff
  211.  
  212. void Set_Working_Page_Mode_Z(int page);
  213. void Set_Visual_Page_Mode_Z(int page);
  214.  
  215. void Set_Visual_Page_Mode_Z_Half(int page);
  216.  
  217. // Mode Y Stuff
  218.  
  219. void Set_Working_Page_Mode_Y(int page);
  220. void Set_Visual_Page_Mode_Y(int page);
  221.  
  222. void Set_Visual_Page_Mode_Y_Half(int page);
  223.  
  224. // ROUTINES THAT ARE A LITTLE TOO SPECIFIC FOR A GENERAL PURPOSE
  225. // LIBRARY. (HINT: USED IN THE GAMELET - "SLOW RUNNINGS"
  226.  
  227. void PCX_Copy_To_Video_Mem(pcx_picture_ptr image, unsigned char far *dest);
  228.  
  229. void Copy_From_Unseen_Vram_to_Page(unsigned char far *buffer1, unsigned char far *buffer2, int to_row);
  230.  
  231. void Planar_Special_Fade_to(unsigned char far *buffer1, unsigned char far *buffer2, int to_row);
  232.  
  233.