/////////////////////////////////////////////////////////////////////////// // // SDL_PCService() - Handles playing the next sample in a PC sound // /////////////////////////////////////////////////////////////////////////// static void SDL_PCService(void) { byte s; word t; if (pcSound) { s = *pcSound++; if (s != pcLastSample) { asm pushf asm cli pcLastSample = s; if (s) // We have a frequency! { t = pcSoundLookup[s]; asm mov bx,[t] asm mov al,0xb6 // Write to channel 2 (speaker) timer asm out 43h,al asm mov al,bl asm out 42h,al // Low byte asm mov al,bh asm out 42h,al // High byte asm in al,0x61 // Turn the speaker & gate on asm or al,3 asm out 0x61,al } else // Time for some silence { asm in al,0x61 // Turn the speaker & gate off asm and al,0xfc // ~3 asm out 0x61,al } asm popf } if (!(--pcLengthLeft)) { SDL_PCStopSound(); SDL_SoundFinished(); } }
/////////////////////////////////////////////////////////////////////////// // // SD_StopSound() - if a sound is playing, stops it // /////////////////////////////////////////////////////////////////////////// void SD_StopSound(void) { if (DigiPlaying) SD_StopDigitized(); switch (SoundMode) { default: break; case sdm_PC: SDL_PCStopSound(); break; case sdm_AdLib: SDL_ALStopSound(); break; } SoundPositioned = false; SDL_SoundFinished(); }
/////////////////////////////////////////////////////////////////////////// // // SD_PlaySound() - plays the specified sound on the appropriate hardware // Returns the channel of the sound if it played, else 0. // /////////////////////////////////////////////////////////////////////////// int SD_PlaySound(const char* sound, SoundChannel chan) { bool ispos; int lp,rp; lp = LeftPosition; rp = RightPosition; LeftPosition = 0; RightPosition = 0; ispos = nextsoundpos; nextsoundpos = false; const SoundData &sindex = SoundInfo[sound]; if ((SoundMode != sdm_Off) && sindex.IsNull()) return 0; if ((DigiMode != sds_Off) && sindex.HasType(SoundData::DIGITAL)) { if ((DigiMode == sds_PC) && (SoundMode == sdm_PC)) { #ifdef NOTYET if (s->priority < SoundPriority) return 0; SDL_PCStopSound(); SD_PlayDigitized(sindex,lp,rp); SoundPositioned = ispos; SoundPriority = s->priority; #else return 0; #endif } else { #ifdef NOTYET if (s->priority < DigiPriority) return(false); #endif int channel = SD_PlayDigitized(sindex, lp, rp, chan); SoundPositioned = ispos; DigiPriority = sindex.GetPriority(); SoundPlaying = sound; return channel; } return(true); } if (SoundMode == sdm_Off) return 0; // if (!s->length) // Quit("SD_PlaySound() - Zero length sound"); if (sindex.GetPriority() < SoundPriority) return 0; bool didPlaySound = false; switch (SoundMode) { default: didPlaySound = true; break; case sdm_PC: if(sindex.HasType(SoundData::PCSPEAKER)) { SDL_PCPlaySound((PCSound *)sindex.GetData(SoundData::PCSPEAKER)); didPlaySound = true; } break; case sdm_AdLib: if(sindex.HasType(SoundData::ADLIB)) { SDL_ALPlaySound((AdLibSound *)sindex.GetData(SoundData::ADLIB)); didPlaySound = true; } break; } if (didPlaySound) { SoundPriority = sindex.GetPriority(); SoundPlaying = sound; } return 0; }