|
|
1.1 ! root 1: /*************************************************************************** ! 2: * WHSMK.C - Smacker code for Witchaven II ! 3: * ! 4: * 03/01/96 Les Bird ! 5: ***************************************************************************/ ! 6: ! 7: #include "smack.h" ! 8: #include "svga.h" ! 9: #include "icorp.h" ! 10: #include <memcheck.h> ! 11: ! 12: #define MAXRADBUFFS 64 ! 13: ! 14: #pragma pack(1); ! 15: ! 16: char *levelname[16] = { ! 17: "antechamber of asmodeus", ! 18: "halls of ragnoth", ! 19: "lokis tomb", ! 20: "forsaken realm", ! 21: "eye of midian", ! 22: "dungeon of disembowlment", ! 23: "stronghold of chaos", ! 24: "jaws of venom", ! 25: "descent into doom", ! 26: "hack n sniff", ! 27: "straits of perdition", ! 28: "plateau of insanity", ! 29: "crypt of decay", ! 30: "mausoleum of madness", ! 31: "gateway into oblivion", ! 32: "lungs of hell" ! 33: }; ! 34: ! 35: Smack *smk; ! 36: ! 37: struct radbuftype { ! 38: long cache_ptr; ! 39: long cache_length; ! 40: char cache_lock; ! 41: }; ! 42: ! 43: struct radbuftype radbuf[MAXRADBUFFS]; ! 44: ! 45: extern ! 46: unsigned vixen; ! 47: ! 48: extern ! 49: long frameplace; ! 50: ! 51: extern ! 52: char palshifted; ! 53: ! 54: extern ! 55: int treasurescnt, ! 56: treasuresfound, ! 57: killcnt, ! 58: kills, ! 59: expgained, ! 60: bonus; ! 61: ! 62: extern ! 63: int mapon; ! 64: ! 65: extern ! 66: long qsetmode; ! 67: ! 68: RCFUNC ! 69: void PTR4 *RADLINK ! 70: radmalloc(u32 numbytes) ! 71: { ! 72: int i; ! 73: ! 74: for (i = 0; i < MAXRADBUFFS; i++) { ! 75: if (radbuf[i].cache_ptr == 0L) { ! 76: break; ! 77: } ! 78: } ! 79: if (i == MAXRADBUFFS) { ! 80: crash("no more radbuff pointers"); ! 81: } ! 82: radbuf[i].cache_lock = 200; ! 83: radbuf[i].cache_length = numbytes; ! 84: allocache(&(radbuf[i].cache_ptr), radbuf[i].cache_length, ! 85: &(radbuf[i].cache_lock)); ! 86: if (radbuf[i].cache_ptr == 0L) { ! 87: crash("radmalloc failed on"); ! 88: } ! 89: return((void PTR4 *) radbuf[i].cache_ptr); ! 90: } ! 91: ! 92: RCFUNC ! 93: void RADLINK ! 94: radfree(void PTR4 * ptr) ! 95: { ! 96: int i; ! 97: ! 98: for (i = 0; i < MAXRADBUFFS; i++) { ! 99: if (radbuf[i].cache_ptr == (long) ptr) { ! 100: radbuf[i].cache_lock = 1; ! 101: break; ! 102: } ! 103: } ! 104: } ! 105: ! 106: void ! 107: smkinit(unsigned int digifh) ! 108: { ! 109: if (digifh != -1) { ! 110: SmackSoundUseSOS3(digifh, 120); ! 111: } ! 112: else { ! 113: SmackSoundUseSOS3(0, 120); ! 114: } ! 115: SmackTimerSetup(); ! 116: } ! 117: ! 118: #include <ctype.h> ! 119: #pragma off (argsused) ! 120: void ! 121: texttobuf(char *buffer,short x,short y,short fontstart,char *text,short pal) ! 122: { ! 123: short letter,i,offset,sl; ! 124: char ltr,space; ! 125: short xl,yl,termxl,termyl; ! 126: char *buf=NULL; ! 127: char *pic=NULL; ! 128: ! 129: /* ASSUMES BUF of 320 x 200 DIMENSION */ ! 130: ! 131: offset=0; ! 132: sl=strlen(text); ! 133: for( i=0; i<sl; i++ ) { ! 134: space=0; ! 135: ltr=toupper(text[i]); ! 136: if( (x+offset) > 320 ) { ! 137: break; ! 138: } ! 139: if( ltr == ' ' ) { ! 140: offset+=6; ! 141: continue; ! 142: } ! 143: if( (ltr >= 'A') && (ltr <= 'Z') ) { ! 144: letter=ltr-'A'; ! 145: } ! 146: else { ! 147: if( (ltr >= '0') && (ltr <= '9') ) { ! 148: letter=ltr-'0'+26; ! 149: } ! 150: else { ! 151: letter=0; ! 152: } ! 153: } ! 154: letter+=fontstart; ! 155: if( waloff[letter] == 0 ) loadtile(letter); ! 156: termxl=tilesizx[letter]; ! 157: termyl=tilesizy[letter]; ! 158: yl=0; ! 159: yloop: ! 160: xl=0; ! 161: buf=( char *)(buffer+(yl*320)+(y*320)); ! 162: pic=( char *)(waloff[letter]); ! 163: xloop: ! 164: if( *(pic+(xl*termyl)+yl) != 255 ) { ! 165: *(buf+x+offset+xl)=*(pic+(xl*termyl)+yl); ! 166: } ! 167: xl++; ! 168: if( xl < termxl ) goto xloop; ! 169: yl++; ! 170: if( yl < termyl ) goto yloop; ! 171: offset+=termxl; ! 172: } ! 173: } ! 174: #pragma on (argsused) ! 175: ! 176: void ! 177: smkplayseq(int s) ! 178: { ! 179: int frames=0; ! 180: long dax, ! 181: dax2, ! 182: day, ! 183: day2; ! 184: long bonus,i,killp,rating,treap; ! 185: char *ratings[]={ ! 186: "poor", ! 187: "average", ! 188: "good", ! 189: "perfect" ! 190: },*smklist[]={ ! 191: "intro.smk", ! 192: "ending1.smk", ! 193: "stairs.smk", ! 194: "ending2.smk", ! 195: "ending3.smk" ! 196: }; ! 197: struct radbuftype smkbuf; ! 198: struct player *plr; ! 199: ! 200: sprintf(tempbuf,"%c:\\smk\\%s",vixen,smklist[s]); ! 201: if (access(tempbuf,F_OK) != 0) { ! 202: strcpy(tempbuf,smklist[s]); ! 203: } ! 204: if ((s == 0 || s == 1 || s == 3 || s == 4) && SoundMode) { ! 205: smk=SmackOpen(tempbuf,SMACKTRACK1,SMACKAUTOEXTRA); ! 206: } ! 207: else { ! 208: smk=SmackOpen(tempbuf,0,SMACKAUTOEXTRA); ! 209: } ! 210: if (smk) { ! 211: smkbuf.cache_ptr=0L; ! 212: smkbuf.cache_length=(320*200); ! 213: smkbuf.cache_lock=200; ! 214: allocache(&(smkbuf.cache_ptr),smkbuf.cache_length, ! 215: &(smkbuf.cache_lock)); ! 216: if( smkbuf.cache_ptr == 0L ) return; ! 217: plr=&player[0]; ! 218: switch (s) { ! 219: case 0: ! 220: case 1: ! 221: case 3: ! 222: case 4: ! 223: SND_StopMusic(); ! 224: break; ! 225: case 2: ! 226: if (kills > killcnt) { ! 227: kills = killcnt; ! 228: } ! 229: killp = (kills * 100) / (killcnt+1); ! 230: if (treasuresfound > treasurescnt) { ! 231: treasuresfound = treasurescnt; ! 232: } ! 233: treap = (treasuresfound * 100) / (treasurescnt+1); ! 234: rating = (killp + treap) / 2; ! 235: if (rating >= 95) { ! 236: rating = 3; ! 237: } ! 238: else if (rating >= 70) { ! 239: rating = 2; ! 240: } ! 241: else if (rating >= 40) { ! 242: rating = 1; ! 243: } ! 244: else { ! 245: rating = 0; ! 246: } ! 247: bonus = rating * 500; ! 248: plr->score += bonus; ! 249: break; ! 250: } ! 251: keystatus[1] = 0; ! 252: keystatus[28] = 0; ! 253: keystatus[57] = 0; ! 254: SVGADetect(0); ! 255: if( !SVGASetup(320,200) ) { ! 256: goto done; ! 257: } ! 258: SmackToBuffer(smk,0L,0L,320L,200L,(void *)smkbuf.cache_ptr,0); ! 259: finishpaletteshifts(); ! 260: SVGASetGraph(); ! 261: while (1) { ! 262: if (smk->NewPalette) { ! 263: SVGASetPalette(smk->Palette); ! 264: } ! 265: SmackDoFrame(smk); ! 266: SmackNextFrame(smk); ! 267: if (s == 2) { ! 268: texttobuf(( void *)smkbuf.cache_ptr,10,13,THEFONT,levelname[mapon],0); ! 269: texttobuf(( void *)smkbuf.cache_ptr,10, 31, THEFONT, "level conquered", 0); ! 270: texttobuf(( void *)smkbuf.cache_ptr,10, 64, THEFONT, "enemies killed", 0); ! 271: sprintf(tempbuf, "%d of %d", kills, killcnt); ! 272: texttobuf(( void *)smkbuf.cache_ptr,160 + 48 + 14, 64, THEFONT, tempbuf, 0); ! 273: ! 274: texttobuf(( void *)smkbuf.cache_ptr,10, 64 + 18, THEFONT, "treasures found", 0); ! 275: sprintf(tempbuf, "%d of %d",treasuresfound, treasurescnt); ! 276: texttobuf(( void *)smkbuf.cache_ptr,160 + 48 + 14, 64 + 18, THEFONT, tempbuf, 0); ! 277: ! 278: texttobuf(( void *)smkbuf.cache_ptr,10, 64 + (18 * 2), THEFONT, ! 279: "experience gained", 0); ! 280: sprintf(tempbuf, "%d", expgained + bonus); ! 281: texttobuf(( void *)smkbuf.cache_ptr,160 + 48 + 14, 64 + (18 * 2), THEFONT, ! 282: tempbuf, 0); ! 283: ! 284: texttobuf(( void *)smkbuf.cache_ptr,10, 64 + (18 * 3), THEFONT, ! 285: "rating", 0); ! 286: texttobuf(( void *)smkbuf.cache_ptr,160 + 48 + 14, 64 + (18 * 3), THEFONT, ! 287: ratings[rating], 0); ! 288: ! 289: texttobuf(( void *)smkbuf.cache_ptr,10, 64 + (18 * 4), THEFONT, ! 290: "bonus", 0); ! 291: sprintf(tempbuf, "%d", bonus); ! 292: texttobuf(( void *)smkbuf.cache_ptr,160 + 48 + 14, 64 + (18 * 4), THEFONT, ! 293: tempbuf, 0); ! 294: } ! 295: SVGABlit(( void *)smkbuf.cache_ptr,0,0,320,200,320,0,0); ! 296: while (SmackWait(smk)) { ! 297: #ifdef ALLOWSCREENCAPTURE ! 298: if( (svga == 0) && (keystatus[0x58] != 0) ) { ! 299: keystatus[0x58] = 0; ! 300: screencapture("captxxxx.pcx", keystatus[0x2A]|keystatus[0x36]); ! 301: } ! 302: #endif ! 303: if (keystatus[1] || keystatus[57] || keystatus[28]) { ! 304: goto done; ! 305: } ! 306: } ! 307: if (keystatus[1] || keystatus[57] || keystatus[28]) { ! 308: goto done; ! 309: } ! 310: if (s == 1 || s == 3 || s == 4) { ! 311: frames++; ! 312: if (frames == smk->Frames) { ! 313: goto done; ! 314: } ! 315: } ! 316: } ! 317: done: ! 318: smkbuf.cache_lock=1; ! 319: SmackClose(smk); ! 320: for (i = 0 ; i < MAXRADBUFFS ; i++) { ! 321: radbuf[i].cache_lock = 1; ! 322: } ! 323: qsetmode=201; ! 324: setgamemode(); ! 325: if( plr->dimension == 3 && svga == 0 ) { ! 326: dax = (XDIM >> 1) - (plr->screensize >> 1); ! 327: dax2 = dax + plr->screensize - 1; ! 328: day = (STATUSSCREEN >> 1) - (((plr->screensize * STATUSSCREEN) / XDIM) >> 1); ! 329: day2 = day + ((plr->screensize * STATUSSCREEN) / XDIM) - 1; ! 330: setview(dax, day, dax2, day2); ! 331: updatestatusbar(); ! 332: } ! 333: if( plr->dimension == 3 && svga == 1 ) { ! 334: if( plr->screensize == 320 ) { ! 335: setview(0L, 0L, 639L, 371L); ! 336: } ! 337: else { ! 338: setview(0L, 0L, 639L, 479L); ! 339: } ! 340: updatestatusbar(); ! 341: } ! 342: } ! 343: } ! 344:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.