                  How to Write Action Games in C++
                            Volume 2
               (C) Freeware 1994 by Marty A. Lineberry
                         2111 School Str.              
                      Winston-Salem, NC 27105
                     BBS 1(910) 744-9054  14.4


    Volume 1 was released on August 1,1994 as a real simple approach
for people to learn how to program in C & C++. Volume 2 is a major
step up from Volume 1. It covers a lot of new ground of how to access
interrupts for mouse, keyboard, joystick ,and a few other misc routines
It also covers loading PCX picture formats and simple graphics.
    The style of Programming in these collections are as follows...     

1. Every attempt possible not to get into Object Oriented Programming YET!!
2. Keep everything to simple Function Calls.
3. Use as many comments as possible to explain what's happening.
4. Show how to create simple action games to explain it all.
5. Write it so you can use these routines in your own programs.
6. Use as few Global Variables as possible.
7. Show good structred programming.
8. Use variable names that make since. Not like n, etc.
8. Keep everything as simple as possible!!!!!!!!!!!!!!!!!!!

   Why action games and not serious stuff like database, business, or
other junk programs? Well to be honest it's boring. There are millions of
books and colleges that teaches you that stuff and to be honest you don't
you really don't learn a thing! Just my personal opion!

Source files included and definition.

********* IMPORTANT BE CAREFUL WHAT VALUE YOU SEND TO A BIOS INTERRUPT.
********* You could low-level format your HD among other nasty things!!!
********* Get a Dos Interrupt Book!!!!!!!!!

Filename             Definition
_____________________________________________
Action.CPP           Has all the routines that you'll need to write
		     small action games, also has all the C header
		     files plus all #define needed. You might want
		     separate it into the Action.h and Action.cpp
		     files.


*** Has to be compiled in Large Memory Model!!!!!!!!!!!!!!!!!!!!
*** if used in a program or it'll reboot or lock up your computer!!
PCX.CPP		     Has everything you need to display 680x480 16
		     color PCX picture files. Can easily be motified
		     for 256 color and different size graphics.
		     just uses if(Display_PCX("Filename.pcx");
		     and that's it!

****** Unzip Game_Kid into it's own directory. Has everything to compile
and run the program. Try playing the games first before looking
at code to better understand what's happening. If you would like
to write some games for this let me know. I'm also planning on doing
a 256 color in 13h mode version of this game with separate files for 
each game. It's gonna be pretty cool when done!

Game_Kid.ZIP         A Great Example of putting all of this stuff
                     together.     




Box_Game.CPP         A simple fast paced(for BGI!) graphics game.
		     Just use the spacebar, up arrow key to fire.
		     Move left and right with the arrow keys.
		     No score is kept. Could be greatly improved!

Chk_ANSI.CPP	     Uses Bios Interrupts to detect if ansi.sys is
		     loaded. Can't be used over modem. Will return
		     a value that could be used in a batch file
		     though.

DEMO.CPP	     Shows all Joystick, Mouse, Keyboard events
		     in action and how they act.

FastKey.CPP	     My Favorite. Uses Bios Interrupts to set
		     Typematic Rate and Delay to Maximum!
		     Great after returning from windows.

Key2.CPP             Shows the Keyboard event routines!

Load_Dos.CPP         Neat little routine to simple Re-Load Dos.
		     This is Not a Warm or Cold Boot. It doesn't
		     check mem or nothing. Use with care!
		     Actually if I remember correctly it's called
		     Basic Loader. Yes remember the ol days. It
		     goes to beggining sector of HD and simple Loads
		     what's there, and in our case, Dos!

PCX_Demo.CPP         Demostration of loading PCX files.

From file ACTION.CPP
********************************************************************
****************** Function Definitions ****************************
********************************************************************

*****************************************
Keyboard Functions  *********************
*****************************************

flush_buffer();       //Flushes Keyboard of any a-waiting characters
                      //stops that annoying beeping when the keyboard
                      //buffer gets full. Will slowdown the game a
                      //little.

int key();            //Returns CTRL ALT SHIFT Keypress's as a int number.
                      //CTRL etc are already defined to the correct number
                      //example:
                      //if(key() == CTRL) do this action;
                     
int C_Break(void);    //Goes here if Ctrl+Break pressed
                      //See your own complier for this function
                     
int Key_Press(char *); //Returns Keypress's and character.
                       //The char * is the ASCII character you pressed.
                       //You press the letter Y and it returns the Y.
                       //The RETURNED int from the function call
                       //is used for arrow keys and returns a number
                       //for most of keypad
                       //UP, DOWN, ESC ,RIGHT ,SHIFT_RIGHT, F1 ,etc
                       //are also defined so you can just use the names

void Pause(int t_f);   //Pause till any keypress
                       //if t_f is TRUE prints       Pause Press a key
                       //if t_f is FALSE just waits till keypress



**********************************************************
Misc Functions *******************************************
**********************************************************

void Slow_Down(int pause);            //Uses delay() but checks for
				      //Variable sent to see if greater
				      // Zero 0

void Basic_Sound(int freq,int pause); //Sounds a frequency for delay(pause)

void Reboot(void);                     //Reboots computer

char ascii(int num);                   //changes Ascii number to character

void Type_Writer(char string[]);       //Prints out a String like a
  Example:  Type_Writer("Hello");      //TypeWriter was typing it.
				       //Will start a new line if exceeds
				       //80 characters

//Prints the text string to a specific screen location
//specified with column & row, it then shows the (INTEGAR)
//variable passed to it. This function is used for
//monitering a variable while a program is running.
//Example printXY(1,1,"My Ship On Screen",Ship_XY);

int printXY(int column,int row,char string[],int Variable);



**********************************************************
Graphics Functions ***************************************
**********************************************************

void InitGraphics(int VIDEOMODE);//Initialize graphics to graphics mode.
Variable passed if =
			1:  gdriver = CGA, gmode = CGAHI
			2:  gdriver = EGA, gmode = EGAHI
			3:  gdriver = EGA, gmode = EGALO
			4:  gdriver = EGA64, gmode = EGALO
			5:  gdriver = EGA64, gmode = EGAHI
			6:  gdriver = VGA, gmode = VGALO
			7:  gdriver = VGA, gmode = VGAMED
			8:  gdriver = IBM8514, gmode = IBM8514LO
			9:  gdriver = VGA, gmode = VGAHI
			Detect:  Chooses Highest Graphics Mode
Clears Graphics Screen & Gets Max_X and Max_Y screen size before
returning.


void DrawBox(int X,int Y,int width,int height,int color,int fillsw);//see function
// X     -> upper left horiz corner of box
// Y     -> upper left vert  corner of box
//width  -> width of box starting from X to the right
//height -> height of box starting from Y down
//color well is color ...it restores color before leaving
//fillsw ->  1 Draws a filled box using indiviual pixels
//           0 Draws a empty box
//           3 Draws a filled box using floodfill()



**********************************************************
Mouse Functions ******************************************
**********************************************************

int Detect_Mouse(void); //Checks to see if mouse is present and sets MousePresent to TRUE or FALSE
%NOTE% None of the other Mouse Functions will work without using Detect_Mouse();
first. It sets GLOBAL variable MousePresent, which every other mouse function
looks for first!


int Number_Of_Buttons(void); //Returns number of mouse buttons available.

void Move_Mouse(int Mouse_X,int Mouse_Y);//Moves mouse to new X,Y position.

void Display_Mouse(void);//Shows Mouse cursor

void Hide_Mouse(void);//Hides Mouse cursor

void Mouse_Position(int *Mouse_X,int *Mouse_Y);//Returns current mouse X,Y position

int Mouse_Held(void);//Checks to see if any mouse buttons held down

void Vert_Mouse_Limit(int Mouse_Y_Min,int Mouse_Y_Max); //Sets Mouse Y limits of movement

void Horiz_Mouse_Limit(int Mouse_X_Min,int Mouse_X_Max);//Sets Mouse X limits of movement


//Returns Mouse Button pressed and the location of the mouse cursor
int Button_XY(int *Mouse_X,int *Mouse_Y,int Button_Check);

//This function is used with Display_Mouse(); to hide the mouse cursor
//Has to be turned off if drawing on the screen where the mouse is located
//at.**NOTE** if you hide the mouse 2 times you have to display it 2 times
//to get it back!
void Hide_Mouse_XY(int left_X,int right_X,int top_Y,int bottom_Y);//See function.

//Changes the Mouse Sensitivity
void Mouse_Sens(int Speed_X,int Speed_Y,int threshold);

//Returns the Mouse's movement from the last call to this function
void Mouse_Motion(int *Mickeys_X,int *Mickeys_Y);

//Changes mouse cursor shape...Kinda acts weird sometimes
void Cursor_Shape(int X_Hot_Spot,int Y_Hot_Spot,int cursor_select);//See function.



*****************************************************
Joystick Functions **********************************
*****************************************************

//returns buttons pressed and variables the X,Y
int JoyStick_Switches(int *switch_0,int *switch_1,int *switch_2,int *switch_3);

int JoyStick_XY(int *A_X,int *A_Y,int *B_X,int *B_Y);
//You'll have to mess around with these to get the joystick center


*********************************************************
Global Variables ****************************************
*********************************************************

//Run MousePresent to detect wether a mouse is installed.
//Change this value in program to allow user to switch from
//no mouse to mouse
int MousePresent = FALSE;

//Not used at present time
int JoyStickPresent = FALSE;

int Max_X; //Holds Maximum Screen Size for graphics mode chosen

int Max_Y; //with initgraph()




As always if these programs causes your computer to start talking to
you or blow up I not resonsible. In other words, use at your risk.
If your computer starts talking to you ask it how to get the mouse
cursor to act right in different memory models hehehhheh!
