- else // Time for some silence\r
- {\r
- asm in al,0x61 // Turn the speaker & gate off\r
- asm and al,0xfc // ~3\r
- asm out 0x61,al\r
- }\r
-\r
- asm popf\r
- }\r
-\r
- if (!(--pcLengthLeft))\r
- {\r
- SDL_PCStopSound();\r
- SDL_SoundFinished();\r
- }\r
- }\r
-}\r
-#endif\r
-\r
-///////////////////////////////////////////////////////////////////////////\r
-//\r
-// SDL_ShutPC() - Turns off the pc speaker\r
-//\r
-///////////////////////////////////////////////////////////////////////////\r
-static void\r
-SDL_ShutPC(void)\r
-{\r
-asm pushf\r
-asm cli\r
-\r
- pcSound = 0;\r
-\r
-asm in al,0x61 // Turn the speaker & gate off\r
-asm and al,0xfc // ~3\r
-asm out 0x61,al\r
-\r
-asm popf\r
-}\r
-\r
-//\r
-// Stuff for digitized sounds\r
-//\r
-memptr\r
-SDL_LoadDigiSegment(word page)\r
-{\r
- memptr addr;\r
-\r
-#if 0 // for debugging\r
-asm mov dx,STATUS_REGISTER_1\r
-asm in al,dx\r
-asm mov dx,ATR_INDEX\r
-asm mov al,ATR_OVERSCAN\r
-asm out dx,al\r
-asm mov al,10 // bright green\r
-asm out dx,al\r
-#endif\r
-\r
- addr = PM_GetSoundPage(page);\r
- PM_SetPageLock(PMSoundStart + page,pml_Locked);\r
-\r
-#if 0 // for debugging\r
-asm mov dx,STATUS_REGISTER_1\r
-asm in al,dx\r
-asm mov dx,ATR_INDEX\r
-asm mov al,ATR_OVERSCAN\r
-asm out dx,al\r
-asm mov al,3 // blue\r
-asm out dx,al\r
-asm mov al,0x20 // normal\r
-asm out dx,al\r
-#endif\r
-\r
- return(addr);\r
-}\r
-\r
-void\r
-SDL_PlayDigiSegment(memptr addr,word len)\r
-{\r
- switch (DigiMode)\r
- {\r
- case sds_PC:\r
- SDL_PCPlaySample(addr,len);\r
- break;\r
- case sds_SoundSource:\r
- SDL_SSPlaySample(addr,len);\r
- break;\r
- case sds_SoundBlaster:\r
- SDL_SBPlaySample(addr,len);\r
- break;\r
- }\r
-}\r
-\r
-void\r
-SD_StopDigitized(void)\r
-{\r
- int i;\r
-\r
-asm pushf\r
-asm cli\r
-\r
- DigiLeft = 0;\r
- DigiNextAddr = nil;\r
- DigiNextLen = 0;\r
- DigiMissed = false;\r
- DigiPlaying = false;\r
- DigiNumber = DigiPriority = 0;\r
- SoundPositioned = false;\r
- if ((DigiMode == sds_PC) && (SoundMode == sdm_PC))\r
- SDL_SoundFinished();\r
-\r
- switch (DigiMode)\r
- {\r
- case sds_PC:\r
- SDL_PCStopSample();\r
- break;\r
- case sds_SoundSource:\r
- SDL_SSStopSample();\r
- break;\r
- case sds_SoundBlaster:\r
- SDL_SBStopSample();\r
- break;\r
- }\r
-\r
-asm popf\r
-\r
- for (i = DigiLastStart;i < DigiLastEnd;i++)\r
- PM_SetPageLock(i + PMSoundStart,pml_Unlocked);\r
- DigiLastStart = 1;\r
- DigiLastEnd = 0;\r
-}\r
-\r
-void\r
-SD_Poll(void)\r
-{\r
- if (DigiLeft && !DigiNextAddr)\r
- {\r
- DigiNextLen = (DigiLeft >= PMPageSize)? PMPageSize : (DigiLeft % PMPageSize);\r
- DigiLeft -= DigiNextLen;\r
- if (!DigiLeft)\r
- DigiLastSegment = true;\r
- DigiNextAddr = SDL_LoadDigiSegment(DigiPage++);\r
- }\r
- if (DigiMissed && DigiNextAddr)\r
- {\r
- SDL_PlayDigiSegment(DigiNextAddr,DigiNextLen);\r
- DigiNextAddr = nil;\r
- DigiMissed = false;\r
- if (DigiLastSegment)\r
- {\r
- DigiPlaying = false;\r
- DigiLastSegment = false;\r
- }\r
- }\r
- SDL_SetTimerSpeed();\r
-}\r
-\r
-void\r
-SD_SetPosition(int leftpos,int rightpos)\r
-{\r
- if\r
- (\r
- (leftpos < 0)\r
- || (leftpos > 15)\r
- || (rightpos < 0)\r
- || (rightpos > 15)\r
- || ((leftpos == 15) && (rightpos == 15))\r
- )\r
- Quit("SD_SetPosition: Illegal position");\r
-\r
- switch (DigiMode)\r
- {\r
- case sds_SoundBlaster:\r
- SDL_PositionSBP(leftpos,rightpos);\r
- break;\r
- }\r
-}\r
-\r
-void\r
-SD_PlayDigitized(word which,int leftpos,int rightpos)\r
-{\r
- word len;\r
- memptr addr;\r
-\r
- if (!DigiMode)\r
- return;\r
-\r
- SD_StopDigitized();\r
- if (which >= NumDigi)\r
- Quit("SD_PlayDigitized: bad sound number");\r
-\r
- SD_SetPosition(leftpos,rightpos);\r
-\r
- DigiPage = DigiList[(which * 2) + 0];\r
- DigiLeft = DigiList[(which * 2) + 1];\r
-\r
- DigiLastStart = DigiPage;\r
- DigiLastEnd = DigiPage + ((DigiLeft + (PMPageSize - 1)) / PMPageSize);\r
-\r
- len = (DigiLeft >= PMPageSize)? PMPageSize : (DigiLeft % PMPageSize);\r
- addr = SDL_LoadDigiSegment(DigiPage++);\r
-\r
- DigiPlaying = true;\r
- DigiLastSegment = false;\r
-\r
- SDL_PlayDigiSegment(addr,len);\r
- DigiLeft -= len;\r
- if (!DigiLeft)\r
- DigiLastSegment = true;\r
-\r
- SD_Poll();\r
-}\r
-\r
-void\r
-SDL_DigitizedDone(void)\r
-{\r
- if (DigiNextAddr)\r
- {\r
- SDL_PlayDigiSegment(DigiNextAddr,DigiNextLen);\r
- DigiNextAddr = nil;\r
- DigiMissed = false;\r
- }\r
- else\r
- {\r
- if (DigiLastSegment)\r
- {\r
- DigiPlaying = false;\r
- DigiLastSegment = false;\r
- if ((DigiMode == sds_PC) && (SoundMode == sdm_PC))\r