1 // 2 // SNDMOD HEADER AND DEF'S 3 // 4 5 #ifndef __sndmod_h__ 6 #define __sndmod_h__ 7 8 // #define SND_CALLER 9 10 #define S_THUNDER1 0 11 #define S_THUNDER2 1 12 #define S_THUNDER3 2 13 #define S_THUNDER4 3 14 #define S_WINDLOOP1 4 15 #define S_WAVELOOP1 5 16 #define S_LAVALOOP1 6 17 #define S_FIRELOOP1 7 18 #define S_STONELOOP1 8 19 #define S_BATSLOOP 9 20 #define S_PLRWEAPON0 10 21 #define S_PLRWEAPON1 11 22 #define S_PLRWEAPON2 12 23 #define S_PLRWEAPON3 13 24 #define S_PLRWEAPON4 14 25 #define S_GOBLIN1 15 26 #define S_GOBLIN2 16 27 #define S_GOBLIN3 17 28 #define S_GOBPAIN1 18 29 #define S_GOBPAIN2 19 30 #define S_GOBDIE1 20 31 #define S_GOBDIE2 21 32 #define S_GOBDIE3 22 33 #define S_KSNARL1 23 34 #define S_KSNARL2 24 35 #define S_KSNARL3 25 36 #define S_KSNARL4 26 37 #define S_KPAIN1 27 38 #define S_KPAIN2 28 39 #define S_KDIE1 29 40 #define S_KDIE2 30 41 #define S_DEMON1 31 42 #define S_DEMON2 32 43 #define S_DEMON3 33 44 #define S_DEMON4 34 45 #define S_DEMON5 35 46 #define S_DEMONDIE1 36 47 #define S_DEMONDIE2 37 48 #define S_MSNARL1 38 49 #define S_MSNARL2 39 50 #define S_MSNARL3 40 51 #define S_MSNARL4 41 52 #define S_MPAIN1 42 53 #define S_MDEATH1 43 54 #define S_DRAGON1 44 55 #define S_DRAGON2 45 56 #define S_DRAGON3 46 57 #define S_RIP1 47 58 #define S_RIP2 48 59 #define S_RIP3 49 60 #define S_SKELHIT1 50 61 #define S_SKELHIT2 51 62 #define S_SKELETONDIE 52 63 #define S_GUARDIAN1 53 64 #define S_GUARDIAN2 54 65 #define S_GUARDIANPAIN1 55 66 #define S_GUARDIANPAIN2 56 67 #define S_GUARDIANDIE 57 68 #define S_WISP 58 69 #define S_WISP2 59 70 #define S_SPLASH1 60 71 #define S_SPLASH2 61 72 #define S_SPLASH3 62 73 #define S_SPLASH4 63 74 #define S_SPLASH5 64 75 #define S_SPLASH6 65 76 #define S_WILLOWDIE 66 77 #define S_FATWITCHDIE 67 78 #define S_JUDY1 68 79 #define S_JUDY2 69 80 #define S_JUDY3 70 81 #define S_JUDY4 71 82 #define S_JUDYDIE 72 83 #define S_SKULLWITCH1 73 84 #define S_SKULLWITCH2 74 85 #define S_SKULLWITCH3 75 86 #define S_SKULLWITCHDIE 76 87 #define S_GRONDEATHA 77 88 #define S_GRONDEATHB 78 89 #define S_GRONDEATHC 79 90 #define S_CHAIN1 80 91 #define S_FLAME1 81 92 #define S_GRONPAINA 82 93 #define S_GRONPAINB 83 94 #define S_GRONPAINC 84 95 #define S_CLUNK 85 96 #define S_DEMONTHROW 86 97 #define S_WITCHTHROW 87 98 #define S_DOOR1 88 99 #define S_DOOR2 89 100 #define S_DOOR3 90 101 #define S_CREAKDOOR1 91 102 #define S_CREAKDOOR2 92 103 #define S_CREAKDOOR3 93 104 #define S_STING1 94 105 #define S_STING2 95 106 #define S_POTION1 96 107 #define S_GENTHROW 97 108 #define S_GENSWING 98 109 #define S_ARROWHIT 99 110 #define S_WALLHIT1 100 111 #define S_GONG 101 112 #define S_SPELL1 102 113 #define S_FREEZE 103 114 #define S_FREEZEDIE 104 115 #define S_TRAP1 105 116 #define S_TRAP2 106 117 #define S_RATS1 107 118 #define S_RATS2 108 119 #define S_WINDLOOP2 109 120 #define S_BREATH1 110 121 #define S_BREATH2 111 122 #define S_PUSH1 112 123 #define S_PUSH2 113 124 #define S_PLRPAIN1 114 125 #define S_PLRPAIN2 115 126 #define S_GORE1 116 127 #define S_GORE2 117 128 #define S_GORE1A 118 129 #define S_GORE1B 119 130 #define S_DEADSTEP 120 131 #define S_HEARTBEAT 121 132 #define S_SOFTCHAINWALK 122 133 #define S_SOFTCREAKWALK 123 134 #define S_LOUDCHAINWALK 124 135 #define S_GRATEWALK 125 136 #define S_SCARYDUDE 126 137 #define S_WATERY 127 138 #define S_GLASSBREAK1 128 139 #define S_GLASSBREAK2 129 140 #define S_GLASSBREAK3 130 141 #define S_TREASURE1 131 142 #define S_SWORD1 132 143 #define S_SWORD2 133 144 #define S_SWORDCLINK1 134 145 #define S_SWORDCLINK2 135 146 #define S_SWORDCLINK3 136 147 #define S_SWORDCLINK4 137 148 #define S_SOCK1 138 149 #define S_SOCK2 139 150 #define S_SOCK3 140 151 #define S_SOCK4 141 152 #define S_KOBOLDHIT 142 153 #define S_SPIDERBITE 143 154 #define S_FIREBALL 144 155 #define S_WOOD1 145 156 #define S_CHAINDOOR1 146 157 #define S_PULLCHAIN1 147 158 #define S_PICKUPAXE 148 159 #define S_EXPLODE 149 160 #define S_SKELSEE 150 161 #define S_BARRELBREAK 151 162 #define S_WARP 152 163 #define S_SPELL2 153 164 #define S_THROWPIKE 154 165 #define S_PICKUPFLAG 155 166 #define S_DROPFLAG 156 167 #define S_LAUGH 157 168 #define S_DRINK 158 169 #define S_PAGE 159 170 #define S_BOTTLES 160 171 #define S_CRACKING 161 172 #define S_PLRDIE1 162 173 #define S_FATLAUGH 163 174 175 176 #define _OFF 0 177 #define _ON 1 178 #define _STANDARD_MUSIC 1 179 #define _DIG_MIDI_MUSIC 2 180 #define _LOOP_MUSIC 3 181 182 #define MAX_AUX_TIMERS 4 183 #define MAX_ACTIVE_SAMPLES 10 184 #define MAX_ACTIVE_SONGS 4 185 //num of array elements in ambsoundarray[] 186 #define MAX_AMB_SOUNDS 6 187 #define MAX_ACTIVE_FXLOOPS 4 188 189 #define MAX_SND_LOOPS 8 190 191 #define DIG_MIDI 2 192 #define MIDI 1 193 #define DIGI 0 194 195 #define MENUSONG 0 196 #define DEATHSONG 1 197 198 #define BASE_SONG 0 199 #define EMB_SONG 1 200 #define SPICE_SONG 2 201 202 #define WINDSNDBIT 1 203 #define WAVESNDBIT 2 204 #define WATERSNDBIT 4 205 #define LAVASNDBIT 8 206 #define GRATESNDBIT 16 207 #define CARTSNDBIT 32 208 #define FIRE1SNDBIT 64 209 #define FIRE2SNDBIT 128 210 211 /* 212 struct SampleType 213 { 214 int playing; 215 uint32_t SOSHandle; 216 uint32_t number; 217 int32_t priority; 218 int32_t x, y; 219 }; 220 */ 221 222 struct ambsounds { 223 int soundnum; //the actual sound number S_x 224 int hsound; //the handle returned by hmi 225 }; 226 227 #ifdef SND_CALLER 228 229 void _far _loadds timerevent(void); 230 231 //Callback functions 232 void _far cdecl sosDIGISampleCallback( int16_t, int16_t, int16_t ); 233 void _far sosMIDISongCallback( int16_t ); 234 void _far cdecl _loadds sosMIDITriggerCallback( int16_t, BYTE, BYTE ); 235 236 // 237 //defs for hmi Setup 238 // 239 // profile structure 240 typedef struct _tagINIInstance 241 { 242 243 int16_t wFlags; // misc. flags 244 BYTE szName[ 128 ]; // name of .ini file 245 246 PSTR pData; // pointer to .ini file in memory 247 int16_t wSize; // size, in bytes, of file 248 int16_t wMaxSize; // maximum size in bytes of the .ini 249 250 PSTR pCurrent; // current location in file 251 int16_t wCurrent; // current location in file 252 253 PSTR pSection; // pointer to section start 254 255 PSTR pItemPtr; // pointer to the start of line w/item 256 PSTR pItem; // pointer to last item 257 PSTR pList; // pointer to last item location, for list 258 // management. 259 PSTR pListPtr; // pointer for raw string list 260 261 } _INI_INSTANCE; 262 263 // equates 264 #define _INI_SECTION_START '[' 265 #define _INI_SECTION_END ']' 266 #define _INI_EQUATE '=' 267 #define _INI_SPACE ' ' 268 #define _INI_TAB 0x9 269 #define _INI_STRING_START '"' 270 #define _INI_STRING_END '"' 271 #define _INI_EOL 0x0d 272 #define _INI_CR 0x0d 273 #define _INI_LF 0x0a 274 #define _INI_HEX_INDICATOR 'x' 275 #define _INI_LIST_SEPERATOR ',' 276 277 // amount of bytes to allocate in addition to file size so that the 278 // .ini file may be modified by the application. 279 #define _INI_EXTRA_MEMORY 1024 280 281 // various flags for .ini structure 282 #define _INI_MODIFIED 0x8000 283 284 285 // function prototypes 286 BOOL cdecl hmiINIOpen ( _INI_INSTANCE * sInstance, PSTR szName ); 287 BOOL cdecl hmiINIClose ( _INI_INSTANCE * sInstance ); 288 BOOL cdecl hmiINILocateSection ( _INI_INSTANCE * sInstance, PSTR szName ); 289 BOOL cdecl hmiINILocateItem ( _INI_INSTANCE * sInstance, PSTR szItem ); 290 BOOL cdecl hmiINIGetDecimal ( _INI_INSTANCE * sInstance, int16_t * wValue ); 291 BOOL cdecl hmiINIGetItemDecimal ( _INI_INSTANCE * sInstance, PSTR szItem, int16_t * wValue ); 292 293 BOOL cdecl sosEZGetConfig( PSTR ); 294 295 int16_t wMIDIDeviceID,wDIGIDeviceID; 296 297 298 // 299 // DIGI SPECIFIC 300 // 301 #define _SOS_DMA_BUFFERSIZE 0x2000 302 #define _SOS_SAMPLE_RATE 11025 303 //#define _SOS_FILL_TIMER_RATE 40 304 #define _SOS_FILL_TIMER_RATE 100 305 306 #define _SAMPLE0 0x1000 307 #define _SAMPLE1 0x1001 308 #define _SAMPLE2 0x1002 309 #define _SAMPLE3 0x1003 310 #define _SAMPLE4 0x1004 311 #define _SAMPLE5 0x1005 312 #define _SAMPLE6 0x1006 313 #define _SAMPLE7 0x1007 314 #define _SAMPLE8 0x1008 315 #define _SAMPLE9 0x1009 316 #define _SAMPLE10 0x100a 317 #define _SAMPLE11 0x100b 318 #define _LSAMPLE1 0x100c 319 #define _LSAMPLE2 0x100d 320 321 UINT PanArray[] = { 322 //REAR to HARD LEFT (angle = 0->512) 323 0x8000,0x7000,0x6000,0x5000,0x4000,0x3000,0x2000,0x1000,0x0000, 324 //HARD LEFT to CENTER (angle = 513-1024) 325 0x1000,0x20f0,0x2000,0x3000,0x4000,0x5000,0x6000,0x7000,0x8000, 326 //CENTER to HARD RIGHT (angle = 1025-1536) 327 0x70f0,0x8000,0x9000,0xa000,0xb000,0xc000,0xd000,0xe000,0xf000, 328 //HARD RIGHT to REAR (angle = 1537-2047) 329 0xffff,0xf000,0xe000,0xd000,0xc000,0xb000,0xa000,0x9000,0x8000 330 }; 331 332 volatile SampleType SampleRay[MAX_ACTIVE_SAMPLES]; 333 BYTE ActiveSampleBits = 0x00; 334 335 volatile SampleType FXLoopRay[MAX_ACTIVE_FXLOOPS]; 336 337 _SOS_CAPABILITIES sSOSDeviceCaps; 338 _SOS_HARDWARE sDIGIHardware; 339 _SOS_INIT_DRIVER sSOSInitDriver = { 340 _SOS_DMA_BUFFERSIZE, 341 _NULL, 342 _TRUE, 343 _SOS_SAMPLE_RATE, 344 19, 345 0L, 346 _NULL, 347 _NULL, 348 _NULL, 349 _SOS_NORMAL_TIMER 350 }; 351 352 _SOS_INIT_DRIVER sSOSInitDriver1 = { 353 _SOS_DMA_BUFFERSIZE, 354 _NULL, 355 _TRUE, 356 _SOS_SAMPLE_RATE, 357 19, 358 0L, 359 _NULL, 360 _NULL, 361 _NULL, 362 _SOS_NORMAL_TIMER 363 }; 364 365 366 _SOS_START_SAMPLE sSOSSampleData[12] = { 367 368 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 369 _SAMPLE0, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 370 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 371 0L, 0, 0, 0L, 0L, 0L }, 372 373 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 374 _SAMPLE1, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 375 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 376 0L, 0, 0, 0L, 0L, 0L }, 377 378 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 379 _SAMPLE2, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 380 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 381 0L, 0, 0, 0L, 0L, 0L }, 382 383 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 384 _SAMPLE3, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 385 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 386 0L, 0, 0, 0L, 0L, 0L }, 387 388 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 389 _SAMPLE4, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 390 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 391 0L, 0, 0, 0L, 0L, 0L }, 392 393 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 394 _SAMPLE5, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 395 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 396 0L, 0, 0, 0L, 0L, 0L }, 397 398 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 399 _SAMPLE6, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 400 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 401 0L, 0, 0, 0L, 0L, 0L }, 402 403 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 404 _SAMPLE7, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 405 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 406 0L, 0, 0, 0L, 0L, 0L }, 407 408 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 409 _SAMPLE8, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 410 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 411 0L, 0, 0, 0L, 0L, 0L }, 412 413 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 414 _SAMPLE9, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 415 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 416 0L, 0, 0, 0L, 0L, 0L }, 417 418 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 419 _SAMPLE10, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 420 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 421 0L, 0, 0, 0L, 0L, 0L }, 422 423 { _NULL, 0L, 0, _CENTER_CHANNEL, 0x7fff, 424 _SAMPLE11, sosDIGISampleCallback, 0, _VOLUME | _PANNING | _LOOPING, 425 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 426 0L, 0, 0, 0L, 0L, 0L }, 427 428 }; 429 430 //array for loop and pending loop MUSIC 431 _SOS_START_SAMPLE LoopSampleData[2] = 432 { 433 {_NULL, 0L, -1, _CENTER_CHANNEL, 0x7fff, 434 _LSAMPLE1, sosDIGISampleCallback, 0, _LOOPING | _VOLUME, 435 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 436 0L, 0, 0, 0L, 0L, 0L}, 437 438 {_NULL, 0L, -1, _CENTER_CHANNEL, 0x7fff, 439 _LSAMPLE2, sosDIGISampleCallback, 0, _LOOPING | _VOLUME, 440 0L, 0L, 0L, 0L, 0, 0, 0, 0x8000, 0, 0, 0, 0, 441 0L, 0, 0, 0L, 0L, 0L}, 442 }; 443 444 445 int16_t LoopHandles[2]; 446 int16_t LoopPending=0,LoopIndex=0,looptoggle=0,loopmusepauseflag=0; 447 int16_t Metronome; 448 449 Dint16_t *DigiList; 450 Dint16_t *LoopList; 451 Dint16_t *SongList; 452 Dint16_t SeekIndex; 453 454 // 455 // MIDI SPECIFIC 456 // 457 _SOS_MIDI_HARDWARE sMIDIHardware; 458 _SOS_MIDI_INIT_DRIVER sSOSMIDIInitDriver; 459 _SOS_MIDI_DIGI_INIT_DRIVER sSOSMIDIDIGIInitDriver; 460 461 //midimusic vars 462 int16_t Metronome; 463 int16_t SongPending,BranchPending; 464 465 int16_t hSOSSongHandles[MAX_ACTIVE_SONGS]; 466 BYTE ActiveSongBits = 0x00; 467 468 BYTE *m_bnkptr,*d_bnkptr,*digi_bnkptr; 469 BYTE _huge *lpMIDISong; 470 471 _SOS_MIDI_INIT_SONG sSOSInitSongs[MAX_ACTIVE_SONGS]; 472 473 _SOS_MIDI_TRACK_DEVICE sSOSTrackMap[MAX_ACTIVE_SONGS] = { 474 { 475 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 476 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 477 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 478 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK 479 }, 480 { 481 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 482 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 483 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 484 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK 485 }, 486 { 487 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 488 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 489 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 490 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK 491 }, 492 { 493 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 494 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 495 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, 496 _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK, _MIDI_MAP_TRACK 497 } 498 }; 499 500 501 // 502 // MISC/COMMON STUFF 503 // 504 int16_t hSOSDriverHandles[3]; 505 int16_t hSOSDriverHandles1; 506 507 int16_t SD_Started=0; 508 BOOL Midi_Loaded,Digi_Loaded,DigMidi_Loaded; 509 int16_t wError,wIndex; 510 511 int16_t hSoundFile = -1; // Handle for Sound F/X file 512 int16_t hLoopFile = -1; // Handle for Loop file 513 int16_t hSongFile = -1; 514 int16_t hMiscHandle = -1; 515 516 517 518 // 519 // TIMER STUFF 520 // 521 int16_t hTimerT_ClockHandle; // Handle for the game timer (TotalClock) 522 int16_t hTimerDig_FillHandle; // Handle for the sSOSInitDriver.lpFillHandler 523 int16_t hTimerRec_FillHandle; // Handle for the sSOSInitDriver.lpFillHandler 524 525 int16_t AuxTimerList[MAX_AUX_TIMERS]; 526 BYTE ActiveTimerBits = 0x00; 527 528 int16_t LoopSndsPlaying=0; 529 530 531 532 533 534 535 536 // 537 // GLOBAL VARIABLES 538 // 539 540 541 542 // 543 // EXTERN STUFF 544 // 545 extern keytimerstuff(); 546 extern volatile long totalclock; 547 extern long posx[],posy[]; 548 549 //JSA temp int to show vol and pan 550 int gVol,gPan; 551 552 #else 553 554 555 extern int Metronome,SongPending,BranchPending; 556 extern int hSOSSongHandles[]; 557 558 559 extern int SoundMode,wDIGIVol,MusicMode,wMIDIVol,use_dig_midi, 560 LoopPending,LoopIndex,looptoggle,LoopSndsPlaying, 561 gPan,gVol; 562 563 //extern SampleType SampleRay[],FXLoopRay[]; 564 565 extern struct ambsounds ambsoundarray[]; 566 extern int lavasnd,batsnd,cartsnd; 567 568 569 #endif 570 571 #endif 572