#include <stdio.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>
#include <alloc.h>
#include <stdlib.h>
#include <math.h>
#define KEYBOARD_INT 0x09
#define KEY_BUFFER 0x60
#define KEY_CONTROL 0x61
#define INT_CONTROL 0x20
#define MAKE_RIGHT 77
#define MAKE_LEFT 75
#define MAKE_UP 72
#define MAKE_DOWN 80
#define MAKE_SPACE 57
#define MAKE_X 45
#define MAKE_N 49
#define BREAK_RIGHT 205
#define BREAK_LEFT 203
#define BREAK_UP 200
#define BREAK_DOWN 208
#define BREAK_SPACE 185
#define BREAK_X 173
#define BREAK_N 177
#define INDEX_UP 0
#define INDEX_DOWN 1
#define INDEX_RIGHT 2
#define INDEX_LEFT 3
#define INDEX_SPACE 4
#define INDEX_X 5
#define INDEX_N 6
#define COLS 41 // note the cols should be 2 more than the screen size
#define ROWS 24 // because if we have a point at the extremes and we check to see
#define TOTAL_TILES ROWS*COLS+1 // if we can go in all directions, we don't need a special case to check these. (same for rows)
#define SHIFT 4 /* change this to reflect the the size.
Ex. 16x16 tile equals 2^4. or a shift of 4 */
#define TILESIZE 16 /* change this also to reflect tile size. 16x16. */
typedef int boolean;
struct NODE {
long f,h;
int g,tmpg;
int x,y;
int NodeNum;
struct NODE *Parent;
struct NODE *Child[8]; /* a node may have upto 8+(NULL) children. */
struct NODE *NextNode; /* for filing purposes */
};
struct NODE *OPEN;
struct NODE *CLOSED;
/**************************************************************************/
/* STACK */
/**************************************************************************/
struct STACK {
struct NODE *NodePtr;
struct STACK *NextStackPtr;
};
struct STACK *Stack;
void (_interrupt _far *Old_Isr)(void);
int raw_key;
int key_table[7]={0,0,0,0,0,0,0};
int FINISHED=0;
int TileMap[TOTAL_TILES];
int g_driver=VGA,g_mode=VGAHI;
void _interrupt _far New_Key_Int(void);
void RestoreKeyboard(void);
void InitKeyboard(void);
void SetUp(void);
void DrawScreen(void);
void DrawSquare(int deltax,int deltay,int flag);
void DisplayPath(int x1,int y1,int x2,int y2);
int TileNum(int x, int y);
boolean FreeTile(int x, int y);
void BoundaryTiles(void);
struct NODE *FindPath(long sx,long sy,long dx,long dy);
struct NODE *ReturnBestNode(void);
void GenerateSuccessors(struct NODE *BestNode,long dx,long dy);
void GenerateSucc(struct NODE *BestNode,long x, long y, long dx, long dy);
struct NODE *CheckOPEN(int tilenum);
struct NODE *CheckCLOSED(int tilenum);
void Insert(struct NODE *Successor);
void PropagateDown(struct NODE *Old);
void Push(struct NODE *Node);
struct NODE *Pop(void);