- When writing to port 61h, reset the PIT 2 gate only when needed.
- When the PIT 2 out signal is set, notify the speaker when there is really a change.
- PC speaker: Do not replay the same sound if it is the same.

svn path=/trunk/; revision=64345
This commit is contained in:
Hermès Bélusca-Maïto 2014-09-27 15:33:27 +00:00
parent c1441679a5
commit 7bafd10348
2 changed files with 29 additions and 12 deletions

View file

@ -262,7 +262,7 @@ static BYTE WINAPI Port61hRead(ULONG Port)
static VOID WINAPI Port61hWrite(ULONG Port, BYTE Data) static VOID WINAPI Port61hWrite(ULONG Port, BYTE Data)
{ {
// BOOLEAN SpeakerChange = FALSE; // BOOLEAN SpeakerStateChange = FALSE;
BYTE OldPort61hState = Port61hState; BYTE OldPort61hState = Port61hState;
/* Only the four lowest bytes can be written */ /* Only the four lowest bytes can be written */
@ -271,18 +271,17 @@ static VOID WINAPI Port61hWrite(ULONG Port, BYTE Data)
if ((OldPort61hState ^ Port61hState) & 0x01) if ((OldPort61hState ^ Port61hState) & 0x01)
{ {
DPRINT("PIT 2 Gate %s\n", Port61hState & 0x01 ? "on" : "off"); DPRINT("PIT 2 Gate %s\n", Port61hState & 0x01 ? "on" : "off");
// SpeakerChange = TRUE; PitSetGate(2, !!(Port61hState & 0x01));
// SpeakerStateChange = TRUE;
} }
PitSetGate(2, !!(Port61hState & 0x01));
if ((OldPort61hState ^ Port61hState) & 0x02) if ((OldPort61hState ^ Port61hState) & 0x02)
{ {
/* There were some change for the speaker... */ /* There were some change for the speaker... */
DPRINT("Speaker %s\n", Port61hState & 0x02 ? "on" : "off"); DPRINT("Speaker %s\n", Port61hState & 0x02 ? "on" : "off");
// SpeakerChange = TRUE; // SpeakerStateChange = TRUE;
} }
// if (SpeakerChange) SpeakerChange(); // if (SpeakerStateChange) SpeakerChange();
SpeakerChange(); SpeakerChange();
} }
@ -316,7 +315,7 @@ static VOID WINAPI PitChan1Out(LPVOID Param, BOOLEAN State)
static VOID WINAPI PitChan2Out(LPVOID Param, BOOLEAN State) static VOID WINAPI PitChan2Out(LPVOID Param, BOOLEAN State)
{ {
// BYTE OldPort61hState = Port61hState; BYTE OldPort61hState = Port61hState;
#if 0 #if 0
if (State) if (State)
@ -332,9 +331,12 @@ static VOID WINAPI PitChan2Out(LPVOID Param, BOOLEAN State)
#else #else
Port61hState = (Port61hState & 0xDF) | (State << 5); Port61hState = (Port61hState & 0xDF) | (State << 5);
#endif #endif
DPRINT("Speaker PIT out\n");
// if ((OldPort61hState ^ Port61hState) & 0x20) if ((OldPort61hState ^ Port61hState) & 0x20)
// SpeakerChange(); {
DPRINT("PitChan2Out -- Port61hState changed\n");
SpeakerChange();
}
} }

View file

@ -29,6 +29,9 @@ static HANDLE hBeep = NULL;
/* PRIVATE FUNCTIONS **********************************************************/ /* PRIVATE FUNCTIONS **********************************************************/
static DWORD OldReloadValue = 0;
static PIT_MODE OldMode = 0;
/* PUBLIC FUNCTIONS ***********************************************************/ /* PUBLIC FUNCTIONS ***********************************************************/
VOID SpeakerChange(VOID) VOID SpeakerChange(VOID)
@ -47,9 +50,18 @@ VOID SpeakerChange(VOID)
DWORD PitChannel2ReloadValue = PitChannel2->ReloadValue; DWORD PitChannel2ReloadValue = PitChannel2->ReloadValue;
if (PitChannel2ReloadValue == 0) PitChannel2ReloadValue = 65536; if (PitChannel2ReloadValue == 0) PitChannel2ReloadValue = 65536;
DPRINT("(1) PitChannel2(Bcd = %s, Mode = %d ; ReloadValue = %d)\n", PitChannel2->Bcd ? "true" : "false", PitChannel2->Mode, PitChannel2ReloadValue);
if (OldMode == PitChannel2->Mode && OldReloadValue == PitChannel2ReloadValue)
return;
OldMode = PitChannel2->Mode;
OldReloadValue = PitChannel2ReloadValue;
DPRINT("(2) PitChannel2(Bcd = %s, Mode = %d ; ReloadValue = %d)\n", PitChannel2->Bcd ? "true" : "false", PitChannel2->Mode, PitChannel2ReloadValue);
/* Set beep data */ /* Set beep data */
BeepSetParameters.Frequency = (PIT_BASE_FREQUENCY / PitChannel2ReloadValue) BeepSetParameters.Frequency = (PIT_BASE_FREQUENCY / PitChannel2ReloadValue);
/* * (PitChannel2->Mode == PIT_MODE_SQUARE_WAVE ? 2 : 1) */;
BeepSetParameters.Duration = INFINITE; BeepSetParameters.Duration = INFINITE;
/* Send the beep */ /* Send the beep */
@ -78,6 +90,9 @@ VOID SpeakerChange(VOID)
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
BEEP_SET_PARAMETERS BeepSetParameters; BEEP_SET_PARAMETERS BeepSetParameters;
OldMode = 0;
OldReloadValue = 0;
/* Set beep data */ /* Set beep data */
BeepSetParameters.Frequency = 0x00; BeepSetParameters.Frequency = 0x00;
BeepSetParameters.Duration = 0x00; BeepSetParameters.Duration = 0x00;