|
|
1.1 ! root 1: /*----------------------------------------------------------------------*/ ! 2: /* */ ! 3: /* PACMAN for BBN BitGraphs */ ! 4: /* */ ! 5: /* File: pacman.h */ ! 6: /* Contents: Constants, types, and global variables */ ! 7: /* Author: Bob Brown (rlb) */ ! 8: /* Purdue CS */ ! 9: /* Date: May, 1982 */ ! 10: /* Description: Manifest constants, some alterable, others */ ! 11: /* not easily changed. */ ! 12: /* Type names are short and lower case. */ ! 13: /* Global variables are all capitalized. */ ! 14: /* */ ! 15: /*----------------------------------------------------------------------*/ ! 16: ! 17: #if BLIT ! 18: #include <jerq.h> ! 19: #endif ! 20: #undef min ! 21: #undef max ! 22: ! 23: #define iabs(x) ((x)<0?-(x):(x)) ! 24: #define min(a,b) ((a)<(b)?(a):(b)) ! 25: #define max(a,b) ((a)>(b)?(a):(b)) ! 26: ! 27: /* ! 28: ** Game board sizes, not easily changed. ! 29: */ ! 30: ! 31: #define FONTSIZE 24 /* basic font size in bits */ ! 32: #define BIGFONT 40 /* font size for pacman and monsters */ ! 33: #define MAZECOLS 28 /* dimensions of the maze */ ! 34: #define MAZEROWS 31 /* ... */ ! 35: #define DOTS 240 /* This many dots on the maze (should compute) */ ! 36: ! 37: #define SCOREROW 2 /* "S C O R E : " goes here */ ! 38: #define SCORECOL 13 /* "S C O R E : " goes here */ ! 39: #define HIGHCOL 22 /* High score message column */ ! 40: #define WAVEROW 2 /* "W A V E : " goes here */ ! 41: #define WAVECOL 60 /* "W A V E : " goes here */ ! 42: #define MAXFACES 10 /* No more than this many extra faces displayed*/ ! 43: #define MAXGAMES 5 /* Maximum number of games */ ! 44: ! 45: #define PACROW 23 /* Where the pacman starts */ ! 46: #define PACCOL 14 ! 47: #define PACFACE 1 /* initial facing for pacman */ ! 48: ! 49: #define FRUITROW 17 /* position in maze coordinates of fruit */ ! 50: #define FRUITCOL 14 ! 51: ! 52: #define STARTROW 33 /* When monsters get here, they're ready to go */ ! 53: #define STARTCOL 42 /* THESE COORDINATES MUST ALIGN!!! */ ! 54: ! 55: /* ! 56: ** Game parameters ! 57: */ ! 58: ! 59: #define PACMEN 3 /* initially, the number of pacmen */ ! 60: #define MAXMONSTER 4 /* Number of monsters */ ! 61: #define FRUITSPERWAVE 2 /* Max fruits per wave, may be less */ ! 62: ! 63: /* ! 64: ** Scheduler delays for board components. ! 65: ** If these seem fast - you need more practice. ! 66: ** There are 1000 clock ticks per second. ! 67: */ ! 68: ! 69: #define DOTDELAY 6 /* Gobbling a dot slows down the Pacman */ ! 70: #define EYESDELAY 20 /* For eyes moving back to the stable */ ! 71: #define FRUITTIME 12000 /* Fruit is on this long */ ! 72: #define MAXFRUITDELAY 45000 /* Fruit is scheduled before this long. */ ! 73: #define MINFRUITDELAY 15000 /* Fruit is scheduled after this long. */ ! 74: #define MINMONTIME 20 /* Monsters won't go faster than this */ ! 75: #define MINPACTIME 25 /* Pacman won't go faster than this */ ! 76: #define MINPOWERTIME 600 /* Power pill will never last less than this */ ! 77: #define MONDELTA 3 /* Monsters get this much faster */ ! 78: #define PACDELTA 2 /* Pacman gets this much faster */ ! 79: #define PACTIME 47 /* Scheduler time delay for pacman */ ! 80: #define POWERDELAY 20 /* Power pills slow monsters this much */ ! 81: #define POWERDELTA 500 /* Power last this much less per wave */ ! 82: #define POWERTIME 10000 /* Pacman's power, initially, lasts this long */ ! 83: #define SLOWDELTA 20 /* Monsters go Pacman.time-& in slow corridor */ ! 84: #define STARTDELAY 500 /* Pause this long at beginning of each wave */ ! 85: #define SNDDOTDELAY 30 /* Components of gobble sound */ ! 86: ! 87: /* ! 88: ** Value of board components ! 89: */ ! 90: ! 91: #define SCOREMOD 10000 /* New man after Score mod & crosses zero */ ! 92: #define VALFRUIT 100 /* This much more every other wave */ ! 93: #define VALGOLD 5 /* Ten in the arcade version - seems excessive */ ! 94: #define VALMONSTER 200 /* Increases exponentially per monster caught */ ! 95: #define VALPILL 50 /* This much just for swallowing a pill */ ! 96: ! 97: /* ! 98: ** Human factors hook - direction changes within this many units of a ! 99: ** possible turn are honored - smaller values make for tricky driving. ! 100: */ ! 101: ! 102: #define PENDCOUNT 20 ! 103: ! 104: #define NOSCORE -1 ! 105: ! 106: /* ! 107: ** operation codes for the blt routines ! 108: */ ! 109: ! 110: #define REPLACE 0 ! 111: #define PAINT 1 ! 112: #define INVERT 2 ! 113: #define COMPL 4 ! 114: ! 115: /* ! 116: ** BBN Rastop codes ! 117: */ ! 118: ! 119: #define RASTS F_STORE ! 120: #define RASTSXD F_XOR ! 121: ! 122: /* ! 123: ** Argument to "pacpower" ! 124: */ ! 125: ! 126: #define ON 0 ! 127: #define CLOSE 1 ! 128: #define OFF 2 ! 129: ! 130: /* ! 131: ** Font characters of significance ! 132: */ ! 133: ! 134: #define CLOSECHAR 'q' ! 135: #define EYESCHAR 'o' ! 136: #define FACECHAR 'c' ! 137: #define FRUITCHAR 'r' ! 138: #define GHOSTCHAR 'p' ! 139: #define MONSTERCHAR "nnvwx" ! 140: #define GOLDCHAR 'h' ! 141: #define PILLCHAR 'i' ! 142: ! 143: /* ! 144: ** Game Board types ! 145: */ ! 146: ! 147: #define TYPEMASK 017 ! 148: #define DOOR 6 ! 149: #define WALLMAX 6 /* Wall characters are 0-6 */ ! 150: #define FIXGOLD 7 /* '7' - this spot initialized to a dot */ ! 151: #define FIXPILL 8 /* '8' - initialized to a power pill */ ! 152: #define VACANT 9 /* '9' - initialized to empty */ ! 153: #define SLOW 10 /* ':' - mosters go slow here */ ! 154: #define SAFE 11 /* ';' - pacman invisible to monsters */ ! 155: #define BLKDOT 12 /* '<' - blocked to monsters & dot */ ! 156: #define BLKNODOT 13 /* '=' - blocked to monsters, no dot */ ! 157: #define PILL 020 ! 158: #define GOLD 040 ! 159: ! 160: /* ! 161: ** Keyboard characters ! 162: */ ! 163: ! 164: #define ABORT 'q' ! 165: #define ALTDOWN 0301 /* Keypad two = down */ ! 166: #define ALTALTDOWN 0321 /* Keypad five = down */ ! 167: #define ALTLEFT 0320 /* Keypad four = left */ ! 168: #define ALTUP 0342 /* Keypad eight = up */ ! 169: #define ALTRIGHT 0322 /* Keypad six = right */ ! 170: #define DOWN 'j' ! 171: #define FREEZE 'f' ! 172: #define GAME1 '1' ! 173: #define GAME2 '2' ! 174: #define GAME3 '3' ! 175: #define GAME4 '4' ! 176: #define GAME5 '5' ! 177: #define LEFT 'h' ! 178: #define NEWGAME 'n' ! 179: #define RIGHT 'l' ! 180: #define SILENT 's' ! 181: #define STOP ' ' ! 182: #define ALTSTOP 0261 /* Keypad zero? = stop */ ! 183: #define UP 'k' ! 184: ! 185: ! 186: /* ! 187: ** Monster states (mptr->movestate) ! 188: ** ! 189: ** STABLED ... bouncing around, won't leave until delay up and pacman safe. ! 190: ** LEAVING ... disjoint from STABLED because a monster might get stuck in ! 191: ** to door is pacman swallows a pill right then. ! 192: ** HOMING .... seeking the entrance to the stable. ! 193: ** HOMING2 ... seeking the home position in the stable. ! 194: */ ! 195: ! 196: #define STABLED 1 /* In the stable, bouncing around */ ! 197: #define LEAVING 2 /* Heading for the door */ ! 198: #define ROAMING 3 /* roaming the maze */ ! 199: #define SEEKING 4 /* seeking the pacman */ ! 200: #define HOMING 5 /* seeking stable entrance */ ! 201: #define HOMING2 6 /* entering stable */ ! 202: ! 203: /* ! 204: ** values for monster state field ! 205: */ ! 206: ! 207: #define DANGEROUS 1 ! 208: #define EDIBLE 2 ! 209: #define DEAD 3 ! 210: /* ! 211: ** Directions ! 212: */ ! 213: ! 214: #define MOVERIGHT 1 ! 215: #define MOVEUP 2 ! 216: #define MOVELEFT 3 ! 217: #define MOVEDOWN 4 ! 218: #define MOVESTOP 0 ! 219: ! 220: #define BYTESIZE 8 ! 221: #if BLIT ! 222: #define RASTROWLEN 100 ! 223: #define RASTCOLLEN 128 ! 224: #else ! 225: #define RASTROWLEN 128 ! 226: #define RASTCOLLEN 96 ! 227: #endif ! 228: ! 229: /* ! 230: ** Address conversion macros ! 231: ** ! 232: ** MZtoSC - maze to screen ! 233: ** SCtoMZ - screen to maze ! 234: ** SCtoROW - screen to character row ! 235: ** SCtoCOL - screen to character column ! 236: ** SCtoMEM - screen to memory ! 237: */ ! 238: ! 239: /* fast times three */ ! 240: #define MZtoSC(x) ((x)+((x)<<1)) ! 241: #define SCtoMZ(x) ((x)/3) ! 242: #define SCtoROW(r) (((r)>>1)+3) ! 243: #define SCtoCOL(c) ((((c)<<3)/9)+2) ! 244: #if BLIT ! 245: #define SCtoMEM(r,c) ((unsigned char *)(addr(&display,Pt(0,(r)*BYTESIZE))))+(c) ! 246: #endif ! 247: #if V1_25 ! 248: #define SCtoMEM(r,c) (unsigned char *)(DISPLAY+((RASTCOLLEN-(c)-6)*BYTESIZE*RASTROWLEN+(r)+6)) ! 249: #endif ! 250: #if V1_76 | V2_0 ! 251: #define SCtoMEM(r,c) (unsigned char *)(DISPLAY+(((c)+6)*BYTESIZE*RASTROWLEN+(RASTROWLEN-(r)-6))) ! 252: #endif ! 253: /* ! 254: ** TYPES... ! 255: */ ! 256: ! 257: typedef struct { ! 258: bool alive; /* TRUE => Pacman is alive */ ! 259: int col; /* Column position in 8x8 coordinates */ ! 260: int dir; /* velocity right(1), up(2), left(3), down(4) */ ! 261: char font; /* Current font character */ ! 262: int mouth; /* Mouth state 0..6 */ ! 263: bool moving; ! 264: int pendcnt; /* Time (in moves) remaining for pending move */ ! 265: int pending; /* Pending move direction */ ! 266: int power; /* Number of power pills in effect */ ! 267: bool safe; /* TRUE => Monsters can't find him */ ! 268: int row; /* position in 8x8 coordinates */ ! 269: int time; /* Current scheduler time delay */ ! 270: int mrow; /* current position in maze coordinates */ ! 271: int mcol; /* current position in maze coordinates */ ! 272: int adjusttime; /* time adjustment factor - when eating dots */ ! 273: } pacman; ! 274: ! 275: ! 276: typedef struct { ! 277: int initrow; /* initial row */ ! 278: int initcol; /* initial column */ ! 279: int initdir; /* initial direction */ ! 280: int initdelay; /* initial time delay in the stable */ ! 281: int inittime; /* Scheduler time delay added to Monbase*/ ! 282: int bonus; /* bonus points in seeking pacman */ ! 283: /* end static part */ ! 284: int time; /* current scheduler delay */ ! 285: int movestate; /* monster movement state */ ! 286: int state; /* monster state */ ! 287: int row; ! 288: int col; ! 289: int dir; ! 290: int delay; /* delay before coming out */ ! 291: char font; ! 292: bool canreverse; ! 293: int mrow; /* maze row position */ ! 294: int mcol; /* maze column position */ ! 295: } monster; ! 296: ! 297: /* ! 298: ** Fruit structure ! 299: */ ! 300: ! 301: typedef struct { ! 302: bool alive; ! 303: int row; /* Constants, defined at init time */ ! 304: int col; ! 305: int value; ! 306: char font; ! 307: int thiswave; ! 308: } fruit; ! 309: ! 310: /* ! 311: ** Movement structure - passed around by monster move routines ! 312: */ ! 313: ! 314: typedef struct { ! 315: int row; /* In maze coordinates */ ! 316: int col; ! 317: int dir; ! 318: } move; ! 319: ! 320: extern unsigned char chr24[][FONTSIZE*FONTSIZE/BYTESIZE]; ! 321: extern unsigned char chr40[][BIGFONT*BIGFONT/BYTESIZE]; ! 322: extern char *Board[]; ! 323: pacman Pacman; ! 324: extern monster Monster[]; ! 325: fruit Fruit; ! 326: int Seekprob; ! 327: int Seekinc; ! 328: bool Silent; ! 329: int Wave; ! 330: int Dotsrem; ! 331: bool Monseeking; ! 332: int Monvalue; ! 333: int Pacmen; ! 334: int Monbase; ! 335: extern int textmode; ! 336: /* ! 337: ** Non integer routines ! 338: */ ! 339: move *dumbmove(); ! 340: move *seekmove(); ! 341: move *closest(); ! 342: move *bounce(); ! 343: move *tostart(); ! 344: move *furthest(); ! 345: move *tostable(); ! 346: move *todoor(); ! 347: ! 348: int pacmove(); ! 349: int monmove(); ! 350: int pacpower();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.