|
|
1.1 ! root 1: #define MAXSECTORS 1024 ! 2: #define MAXWALLS 8192 ! 3: #define MAXSPRITES 4096 ! 4: ! 5: #define MAXTILES 4096 ! 6: #define MAXSTATUS 1024 ! 7: #define MAXPLAYERS 16 ! 8: #define MAXXDIM 1600 ! 9: #define MAXYDIM 1200 ! 10: #define MAXPALOOKUPS 256 ! 11: #define MAXPSKYTILES 256 ! 12: #define MAXSPRITESONSCREEN 1024 ! 13: ! 14: //Make all variables in BUILD.H defined in the ENGINE, ! 15: //and externed in GAME ! 16: #ifdef ENGINE ! 17: #define EXTERN ! 18: #else ! 19: #define EXTERN extern ! 20: #endif ! 21: ! 22: //ceilingstat/floorstat: ! 23: // bit 0: 1 = parallaxing, 0 = not "P" ! 24: // bit 1: 1 = groudraw, 0 = not ! 25: // bit 2: 1 = swap x&y, 0 = not "F" ! 26: // bit 3: 1 = double smooshiness "E" ! 27: // bit 4: 1 = x-flip "F" ! 28: // bit 5: 1 = y-flip "F" ! 29: // bit 6: 1 = Align texture to first wall of sector "R" ! 30: // bits 7-15: reserved ! 31: ! 32: //40 bytes ! 33: typedef struct ! 34: { ! 35: short wallptr, wallnum; ! 36: long ceilingz, floorz; ! 37: short ceilingstat, floorstat; ! 38: short ceilingpicnum, ceilingheinum; ! 39: signed char ceilingshade; ! 40: char ceilingpal, ceilingxpanning, ceilingypanning; ! 41: short floorpicnum, floorheinum; ! 42: signed char floorshade; ! 43: char floorpal, floorxpanning, floorypanning; ! 44: char visibility, filler; ! 45: short lotag, hitag, extra; ! 46: } sectortype; ! 47: ! 48: //cstat: ! 49: // bit 0: 1 = Blocking wall (use with clipmove, getzrange) "B" ! 50: // bit 1: 1 = bottoms of invisible walls swapped, 0 = not "2" ! 51: // bit 2: 1 = align picture on bottom (for doors), 0 = top "O" ! 52: // bit 3: 1 = x-flipped, 0 = normal "F" ! 53: // bit 4: 1 = masking wall, 0 = not "M" ! 54: // bit 5: 1 = 1-way wall, 0 = not "1" ! 55: // bit 6: 1 = Blocking wall (use with hitscan / cliptype 1) "H" ! 56: // bit 7: 1 = Transluscence, 0 = not "T" ! 57: // bit 8: 1 = y-flipped, 0 = normal "F" ! 58: // bit 9: 1 = Transluscence reversing, 0 = normal "T" ! 59: // bits 10-15: reserved ! 60: ! 61: //32 bytes ! 62: typedef struct ! 63: { ! 64: long x, y; ! 65: short point2, nextwall, nextsector, cstat; ! 66: short picnum, overpicnum; ! 67: signed char shade; ! 68: char pal, xrepeat, yrepeat, xpanning, ypanning; ! 69: short lotag, hitag, extra; ! 70: } walltype; ! 71: ! 72: //cstat: ! 73: // bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B" ! 74: // bit 1: 1 = transluscence, 0 = normal "T" ! 75: // bit 2: 1 = x-flipped, 0 = normal "F" ! 76: // bit 3: 1 = y-flipped, 0 = normal "F" ! 77: // bits 5-4: 00 = FACE sprite (default) "R" ! 78: // 01 = WALL sprite (like masked walls) ! 79: // 10 = FLOOR sprite (parallel to ceilings&floors) ! 80: // bit 6: 1 = 1-sided sprite, 0 = normal "1" ! 81: // bit 7: 1 = Real centered centering, 0 = foot center "C" ! 82: // bit 8: 1 = Blocking sprite (use with hitscan / cliptype 1) "H" ! 83: // bit 9: 1 = Transluscence reversing, 0 = normal "T" ! 84: // bits 10-14: reserved ! 85: // bit 15: 1 = Invisible sprite, 0 = not invisible ! 86: ! 87: //44 bytes ! 88: typedef struct ! 89: { ! 90: long x, y, z; ! 91: short cstat, picnum; ! 92: signed char shade; ! 93: char pal, clipdist, filler; ! 94: unsigned char xrepeat, yrepeat; ! 95: signed char xoffset, yoffset; ! 96: short sectnum, statnum; ! 97: short ang, owner, xvel, yvel, zvel; ! 98: short lotag, hitag, extra; ! 99: } spritetype; ! 100: ! 101: EXTERN sectortype sector[MAXSECTORS]; ! 102: EXTERN walltype wall[MAXWALLS]; ! 103: EXTERN spritetype sprite[MAXSPRITES]; ! 104: ! 105: EXTERN long spritesortcnt; ! 106: EXTERN spritetype tsprite[MAXSPRITESONSCREEN]; ! 107: ! 108: EXTERN char vidoption; ! 109: EXTERN long xdim, ydim, ylookup[MAXYDIM+1], numpages; ! 110: EXTERN long yxaspect, xyaspect; ! 111: ! 112: EXTERN short numsectors, numwalls; ! 113: EXTERN volatile long totalclock; ! 114: EXTERN long numframes, randomseed; ! 115: EXTERN short sintable[2048]; ! 116: EXTERN char palette[768]; ! 117: EXTERN short numpalookups; ! 118: EXTERN char *palookup[MAXPALOOKUPS]; ! 119: EXTERN char parallaxtype, showinvisibility; ! 120: EXTERN long parallaxyoffs, parallaxyscale; ! 121: EXTERN long visibility, parallaxvisibility; ! 122: ! 123: EXTERN long windowx1, windowy1, windowx2, windowy2; ! 124: EXTERN short startumost[MAXXDIM], startdmost[MAXXDIM]; ! 125: ! 126: EXTERN short pskyoff[MAXPSKYTILES], pskybits; ! 127: ! 128: EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; ! 129: EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; ! 130: EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; ! 131: ! 132: EXTERN short tilesizx[MAXTILES], tilesizy[MAXTILES]; ! 133: EXTERN char walock[MAXTILES]; ! 134: EXTERN long numtiles, picanm[MAXTILES], waloff[MAXTILES]; ! 135: ! 136: //These variables are for auto-mapping with the draw2dscreen function. ! 137: //When you load a new board, these bits are all set to 0 - since ! 138: //you haven't mapped out anything yet. Note that these arrays are ! 139: //bit-mapped. ! 140: //If you want draw2dscreen() to show sprite #54 then you say: ! 141: // spritenum = 54; ! 142: // show2dsprite[spritenum>>3] |= (1<<(spritenum&7)); ! 143: //And if you want draw2dscreen() to not show sprite #54 then you say: ! 144: // spritenum = 54; ! 145: // show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7)); ! 146: //Automapping defaults to 0 (do nothing). If you set automapping to 1, ! 147: // then in 3D mode, the walls and sprites that you see will show up the ! 148: // next time you flip to 2D mode. ! 149: ! 150: EXTERN char show2dsector[MAXSECTORS>>3]; ! 151: EXTERN char show2dwall[MAXWALLS>>3]; ! 152: EXTERN char show2dsprite[MAXSPRITES>>3]; ! 153: EXTERN char automapping; ! 154: ! 155: EXTERN char gotpic[MAXTILES>>3]; ! 156: EXTERN char gotsector[MAXSECTORS>>3]; ! 157: ! 158: /************************************************************************* ! 159: POSITION VARIABLES: ! 160: ! 161: POSX is your x - position ranging from 0 to 65535 ! 162: POSY is your y - position ranging from 0 to 65535 ! 163: (the length of a side of the grid in EDITBORD would be 1024) ! 164: POSZ is your z - position (height) ranging from 0 to 65535, 0 highest. ! 165: ANG is your angle ranging from 0 to 2047. Instead of 360 degrees, or ! 166: 2 * PI radians, I use 2048 different angles, so 90 degrees would ! 167: be 512 in my system. ! 168: ! 169: SPRITE VARIABLES: ! 170: ! 171: EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; ! 172: EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; ! 173: EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; ! 174: ! 175: Example: if the linked lists look like the following: ! 176: ��������������������������������������������������������������Ŀ ! 177: � Sector lists: Status lists: � ! 178: ��������������������������������������������������������������Ĵ ! 179: � Sector0: 4, 5, 8 Status0: 2, 0, 8 � ! 180: � Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 � ! 181: � Sector2: 3, 9 � ! 182: ���������������������������������������������������������������� ! 183: Notice that each number listed above is shown exactly once on both the ! 184: left and right side. This is because any sprite that exists must ! 185: be in some sector, and must have some kind of status that you define. ! 186: ! 187: ! 188: Coding example #1: ! 189: To go through all the sprites in sector 1, the code can look like this: ! 190: ! 191: sectnum = 1; ! 192: i = headspritesect[sectnum]; ! 193: while (i != -1) ! 194: { ! 195: nexti = nextspritesect[i]; ! 196: ! 197: //your code goes here ! 198: //ex: printf("Sprite %d is in sector %d\n",i,sectnum); ! 199: ! 200: i = nexti; ! 201: } ! 202: ! 203: Coding example #2: ! 204: To go through all sprites with status = 1, the code can look like this: ! 205: ! 206: statnum = 1; //status 1 ! 207: i = headspritestat[statnum]; ! 208: while (i != -1) ! 209: { ! 210: nexti = nextspritestat[i]; ! 211: ! 212: //your code goes here ! 213: //ex: printf("Sprite %d has a status of 1 (active)\n",i,statnum); ! 214: ! 215: i = nexti; ! 216: } ! 217: ! 218: insertsprite(short sectnum, short statnum); ! 219: deletesprite(short spritenum); ! 220: changespritesect(short spritenum, short newsectnum); ! 221: changespritestat(short spritenum, short newstatnum); ! 222: ! 223: TILE VARIABLES: ! 224: NUMTILES - the number of tiles found TILES.DAT. ! 225: TILESIZX[MAXTILES] - simply the x-dimension of the tile number. ! 226: TILESIZY[MAXTILES] - simply the y-dimension of the tile number. ! 227: WALOFF[MAXTILES] - the actual 32-bit offset pointing to the top-left ! 228: corner of the tile. ! 229: PICANM[MAXTILES] - flags for animating the tile. ! 230: ! 231: TIMING VARIABLES: ! 232: TOTALCLOCK - When the engine is initialized, TOTALCLOCK is set to zero. ! 233: From then on, it is incremented 120 times a second by 1. That ! 234: means that the number of seconds elapsed is totalclock / 120. ! 235: NUMFRAMES - The number of times the draw3dscreen function was called ! 236: since the engine was initialized. This helps to determine frame ! 237: rate. (Frame rate = numframes * 120 / totalclock.) ! 238: ! 239: OTHER VARIABLES: ! 240: ! 241: STARTUMOST[320] is an array of the highest y-coordinates on each column ! 242: that my engine is allowed to write to. You need to set it only ! 243: once. ! 244: STARTDMOST[320] is an array of the lowest y-coordinates on each column ! 245: that my engine is allowed to write to. You need to set it only ! 246: once. ! 247: SINTABLE[2048] is a sin table with 2048 angles rather than the ! 248: normal 360 angles for higher precision. Also since SINTABLE is in ! 249: all integers, the range is multiplied by 16383, so instead of the ! 250: normal -1<sin(x)<1, the range of sintable is -16383<sintable[]<16383 ! 251: If you use this sintable, you can possibly speed up your code as ! 252: well as save space in memory. If you plan to use sintable, 2 ! 253: identities you may want to keep in mind are: ! 254: sintable[ang&2047] = sin(ang * (3.141592/1024)) * 16383 ! 255: sintable[(ang+512)&2047] = cos(ang * (3.141592/1024)) * 16383 ! 256: NUMSECTORS - the total number of existing sectors. Modified every time ! 257: you call the loadboard function. ! 258: ***************************************************************************/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.