home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
SLOWRUNS.ZIP
/
SLOWSRC.ZIP
/
MAGIC4.H
< prev
next >
Wrap
C/C++ Source or Header
|
1997-08-28
|
8KB
|
233 lines
/* magic4.h */
#define SCREEN_DARKNESS 0 // fade to black
#define SCREEN_WHITENESS 1 // fade to white
#define SCREEN_WARP 2 // warp the screen image
#define SCREEN_SWIPE_X 3 // do a horizontal swipe
#define SCREEN_SWIPE_Y 4 // do a vertical swipe
#define SCREEN_DISSOLVE 5 // a pixel dissolve
#define FULL_SCREEN_DARKNESS 6
// these are used to change the visual page of the VGA
#define CRT_ADDR_LOW 0x0D // the index of the low byte of the start address
#define CRT_ADDR_HI 0x0C // the index of the hi byte of the start address
// mode X (if other routines supported it), Y, Z page defines
#define PAGE_0 0
#define PAGE_1 1
#define PAGE_2 2
#define PAGE_3 3
// programmer defined types and alias's //////////////
typedef struct bitmap_typ
{
int x,y; // position of bitmap
int width,height; // size of bitmap
unsigned char far *buffer; // buffer holding image
} bitmap, *bitmap_ptr;
// PCX file structure
typedef struct pcx_header_typ
{
char manufacturer; // the manufacturer of the file
char version; // the file format version
char encoding; // type of compression
char bits_per_pixel; // number of bits per pixel
int x,y; // starting location of image
int width,height; // size of image
int horz_res; // resolution in DPI (dots per inch)
int vert_res;
char ega_palette[48]; // the old EGA palette (usually ignored)
char reserved; // don't care
char num_color_planes; // number of color planes
int bytes_per_line; // number of bytes per line of the image
int palette_type; // 1 for color, 2 for grey scale palette
char padding[58]; // extra bytes
} pcx_header, *pcx_header_ptr;
// this holds the PCX header and the actual image
typedef struct pcx_picture_typ
{
pcx_header header; // the header of the PCX file
RGB_color palette[256]; // the palette data
unsigned char far *buffer; // a pointer to the 64,000 byte buffer
// holding the decompressed image
} pcx_picture, *pcx_picture_ptr;
// this is a sprite structure
typedef struct sprite_typ
{
int x,y; // position of sprite
int width,height; // dimensions of sprite
int counter_1; // some counters for timing and animation
int counter_2;
int counter_3;
int threshold_1; // thresholds for the counters (if needed)
int threshold_2;
int threshold_3;
unsigned char far *frames[MAX_SPRITE_FRAMES]; // array of pointers to
// the images
int curr_frame; // current frame being displayed
int num_frames; // total number of frames
int state; // state of sprite, alive, dead...
unsigned char far *background; // image under the sprite
int x_clip,y_clip; // clipped position of sprite
int width_clip,height_clip; // clipped size of sprite used
int visible; // by sprite engine to flag
// if a sprite was invisible last
// time it was drawn hence the background
// need not be replaced
} sprite, *sprite_ptr;
// this is a typedef used for the layers in parallax scrolling
// note it is identical to a bitmap, but we'll make a separate typedef
// in the event we later need to add fields to it
typedef struct layer_typ
{
int x,y; // used to hold position information
// no specific function
int width,height; // size of layer, note: width must
// be divisible by 2
unsigned char far *buffer; // the layer buffer
} layer, *layer_ptr;
// E X T E R N A L S /////////////////////////////////////////////////////////
extern unsigned char far *double_buffer; // the double buffer
extern unsigned int double_buffer_height; // height of double buffer
extern unsigned int double_buffer_size; // total size of buffer in bytes
extern unsigned int sprite_width; // width of a sprite
extern unsigned int sprite_height; // of a sprite
// MODE Z STUFF...
extern unsigned char far *page_0_buffer; // pointer to mode z page 0
extern unsigned char far *page_1_buffer; // pointer to mode z page 1
extern int mode_z_page; // current mode z page
// MODE Y STUFF...
extern unsigned char far *pagey_0_buffer; // pointer to mode y page 0
extern unsigned char far *pagey_1_buffer; // pointer to mode y page 1
extern unsigned char far *pagey_2_buffer;
extern unsigned char far *pagey_3_buffer;
extern int mode_y_page; // current mode y page
extern unsigned char far *never_displayed_buffer_mode_y;
extern unsigned char far *never_prime;
// P R O T O T Y P E S ///////////////////////////////////////////////////////
// function prototypes ////////////////////////
void Screen_Transition(int effect);
// Double Buffer stuff...
void Line_HDB(int x1, int x2, int y, int color);
void Line_VDB(int y1, int y2, int x, int color);
void Write_Pixel_DB(int x, int y, int color);
int Create_Double_Buffer(int num_lines);
void Fill_Double_Buffer(int color);
void Display_Double_Buffer(unsigned char far *buffer, int y);
void Delete_Double_Buffer(void);
// Bitmap stuff...
void Bitmap_Put(bitmap_ptr image, unsigned char far *destination, int transparent);
void Bitmap_Get(bitmap_ptr image, unsigned char far *source);
// PCX stuff...
int PCX_Init(pcx_picture_ptr image);
void PCX_Delete(pcx_picture_ptr image);
int PCX_Load(char *filename, pcx_picture_ptr image, int load_palette);
void PCX_Show_Buffer(pcx_picture_ptr image);
// Sprite stuff...
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);
void Sprite_Delete(sprite_ptr sprite);
void PCX_Get_Sprite(pcx_picture_ptr image, sprite_ptr sprite, int sprite_frame, int cell_x, int cell_y);
void Sprite_Draw(sprite_ptr sprite, unsigned char far *buffer, int transparent);
void Sprite_Under(sprite_ptr sprite, unsigned char far *buffer);
void Sprite_Erase(sprite_ptr sprite, unsigned char far *buffer);
void PCX_Copy_To_Buffer(pcx_picture_ptr image, unsigned char far *buffer);
void PCX_Copy_To_Buffer_XYZ_Mode(pcx_picture_ptr image, unsigned char far *buffer);
void fwordcpy(void far *destination, void far *source, int num_words);
void fwordset(void far *destination, int color, int num_words);
void Sprite_Draw_Clip(sprite_ptr sprite, unsigned char far *buffer, int transparent);
void Sprite_Erase_Clip(sprite_ptr sprite, unsigned char far *buffer);
void Sprite_Under_Clip(sprite_ptr sprite, unsigned char far *buffer);
// planar Sprite Put
void Sprite_Draw_Clip_Special(sprite_ptr sprite, unsigned char far *buffer);
int Layer_Create(layer_ptr dest_layer, int width, int height);
void Layer_Delete(layer_ptr the_layer);
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);
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);
void Wait_For_Vertical_Retrace(void);
// Text routines configured to OUTPUT to the double buffer
void Print_Char_DB(int xc, int yc, char c, int color, int transparent);
void Print_String_DB(int x, int y, int color, char *string, int transparent);
void Write_Pixel_DB(int x, int y, int color);
int Read_Pixel_DB(int x, int y);
// Mode Z Stuff
void Set_Working_Page_Mode_Z(int page);
void Set_Visual_Page_Mode_Z(int page);
void Set_Visual_Page_Mode_Z_Half(int page);
// Mode Y Stuff
void Set_Working_Page_Mode_Y(int page);
void Set_Visual_Page_Mode_Y(int page);
void Set_Visual_Page_Mode_Y_Half(int page);
// ROUTINES THAT ARE A LITTLE TOO SPECIFIC FOR A GENERAL PURPOSE
// LIBRARY. (HINT: USED IN THE GAMELET - "SLOW RUNNINGS"
void PCX_Copy_To_Video_Mem(pcx_picture_ptr image, unsigned char far *dest);
void Copy_From_Unseen_Vram_to_Page(unsigned char far *buffer1, unsigned char far *buffer2, int to_row);
void Planar_Special_Fade_to(unsigned char far *buffer1, unsigned char far *buffer2, int to_row);