home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
SLOWRUNS.ZIP
/
SLOWSRC.ZIP
/
MAGIC3.H
< prev
next >
Wrap
C/C++ Source or Header
|
1997-06-30
|
6KB
|
183 lines
#define GRAPHICS_MODE13 0x13 /* 320x200x256 */
#define TEXT_MODE 0x03 /* 80x25 text mode */
#define COLOR_MASK 0x3C6 // the bit mask register
#define COLOR_REGISTER_RD 0x3C7 // set read index at this I/O
#define COLOR_REGISTER_WR 0x3C8 // set write index at this I/O
#define COLOR_DATA 0x3C9 // the R/W data is here
#define ROM_CHAR_SET_SEG 0xF000 // segment of 8x8 ROM character set
#define ROM_CHAR_SET_OFF 0xFA6E // beginning offset of 8x8 ROM character set
#define ROM_CHAR_HEIGHT 8
#define ROM_CHAR_WIDTH 8
#define MODE13_WIDTH (unsigned int)320 // offset to next line of 8x8 ROM character
#define MODE_Y_WIDTH (unsigned int)80 // offset to next line of video buffer
#define MODE_X_WIDTH (unsigned int)80
#define SCREEN_WIDTH (unsigned int)320
#define SCREEN_HEIGHT (unsigned int)200
#define SPRITE_WIDTH 16
#define SPRITE_HEIGHT 16
#define MAX_SPRITE_FRAMES 24
#define SPRITE_DEAD 0
#define SPRITE_ALIVE 1
#define SPRITE_DYING 2
// Mode Z defines ////////////////
// ...the VGA card controller ports
#define SEQUENCER 0x3C4 // the sequencer's index port
#define CRT_CONTROLLER 0x3D4 // the crt controller's index port
#define GFX_CONTROLLER 0x3CE // the graphics controller's index port
#define GC_DATA_REG 0x3CF
#define ATTR_CONTROLLER_FF 0x3DA // the attribute controller's Flip Flop
#define ATTR_CONTROLLER_DATA 0x3C0 // the attribute controller's data port
#define VGA_INPUT_STATUS_1 0x3DA // vertical retrace flag
#define VGA_VRETRACE_MASK 0x08 // masks off unwanted bit of status reg
#define VR_BIT (0x08)
#define DISPLAY_ENABLE (0x01)
// ...defines for the CRT controller registers of interest
#define CRT_MAX_SCANLINE 0x09 // the maximum scanline register
// used to select how many scanlines
// per row
#define CRT_ADDR_MODE 0x14 // the address mode register
// used to select byte addressing
// for VGA
// also known as the underline register
#define CRT_MODE_CONTROL 0x17 // the mode control register
// used to select single byte addressing
// ...defines for the GFX controller registers of interest
#define GFX_WRITE_MODE 0x05 // the memory write mode register
// used to deselect even/odd plane
// addressing
#define GFX_MISC 0x06 // the miscellaneous register
// used to deselect the chaining
// of memory
// ...defines for the SEQUENCER registers of interest
#define SEQ_PLANE_ENABLE 0x02 // plane enable register, used to select
// which planes are written to by a
// CPU write
#define SEQ_MEMORY_MODE 0x04 // the memory mode register
// used to deselect memory chain mode
// and odd/even memory addressing
// MODEX DEFINES /////////////////////////////////////////////////
#define MISC_OUTPUT_REG 0x3C2
#define CRTC_INDEX_REG 0x3D4
#define VERT_TOTAL_INDEX 0x06
#define OVERFLOW_INDEX 0x07
#define MAX_SCAN_LINE_INDEX 0x09
#define VERT_RETRACE_START_INDEX 0x10
#define VERT_RETRACE_END_INDEX 0x11
#define VERT_DISPLAY_END_INDEX 0x12
#define UNDERLINE_LOCATION_INDEX 0x14
#define START_VERT_BLANK_INDEX 0x15
#define END_VERT_BLANK_INDEX 0x16
#define MODE_CONTROL_INDEX 0x17
// M A C R O S - for use with MODE Z //////////////////////////////
#define SET_BITS(x,bits) (x | bits) // used to set bits in a word
#define RESET_BITS(x,bits) (x & ~bits) // used to reset bits in a word
// S T R U C T U R E S //////////////////
// this structure holds a RGB triple in three unsigned bytes
typedef struct RGB_color_typ
{
unsigned char red; //red component of color 0-63
unsigned char green; //green component of color 0-63
unsigned char blue; //blue component of color 0-63
} RGB_color, *RGB_color_ptr;
typedef struct RGB_palette_typ
{
int start_reg; // index of the starting register that is saved
int end_reg; // index of the ending register that is saved
RGB_color colors[256]; // the storage area for the palette
} RGB_palette, *RGB_palette_ptr;
// G L O B A L S /////////////////////////////////////////////////////////////
extern unsigned char far *video_buffer; // video ram byte ptr
extern unsigned char far *rom_char_set; // rom characters 8x8
// ...The following are all function prototypes used by MAGIC3.C
void Time_Delay(int clicks);
// Elementary Graphics Functions
void Set_Graphics_Mode(int mode);
void Fill_Screen(int color);
void Write_Pixel(int x, int y, int color);
int Read_Pixel(int x, int y);
void Line_H(int x1, int x2, int y, int color);
void Line_V(int y1, int y2, int x, int color);
void Draw_Rectangle(int x1, int y1, int x2, int y2, int color);
// palette functions
void Write_Color_Reg(int index, RGB_color_ptr color);
RGB_color_ptr Read_Color_Reg(int index, RGB_color_ptr color);
void Read_Palette(int start_reg, int end_reg, RGB_palette_ptr the_palette);
void Write_Palette(int start_reg,int end_reg, RGB_palette_ptr the_palette);
void Print_Char(int xc, int yc, char c, int color, int transparent);
void Print_String(int x, int y, int color, char *string, int transparent);
// mode Z functions
void Set_Mode_Z(void);
void Fill_Screen_Z(int color);
void Write_Pixel_Z(int x, int y, int color);
void Line_H_Mode_Z(int x1, int x2, int y, int color);
void Line_V_Mode_Z(int y1, int y2, int x, int color);
// Mode Y Functions
void Set_Mode_Y(void);
void Fill_Screen_Y(int color);
void Write_Pixel_Y(int x, int y, int color);
void Print_Char_Mode_Y(int xc, int yc, char c, int color, int transparent);
void Print_String_Mode_Y(int x, int y, int color, char *string, int transparent);
void Line_H_Mode_Y(int x1, int x2, int y, int color);
void Line_V_Mode_Y(int y1, int y2, int x, int color);
// Mode X Functions
void Set_Mode_X(void);
// new routines hijacked from someone elses material...
void Wait_Vertical_Retrace_End(void);
void Wait_Display_Mode(void);
void Wait_Retrace_Mode(void);
int Vertical_Retrace_Occuring(void);