Author: hbelusca
Date: Sat Sep 27 15:33:27 2014
New Revision: 64345
URL:
http://svn.reactos.org/svn/reactos?rev=64345&view=rev
Log:
[NTVDM]
- 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.
Modified:
trunk/reactos/subsystems/ntvdm/emulator.c
trunk/reactos/subsystems/ntvdm/hardware/speaker.c
Modified: trunk/reactos/subsystems/ntvdm/emulator.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/emulator.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/emulator.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/emulator.c [iso-8859-1] Sat Sep 27 15:33:27 2014
@@ -262,7 +262,7 @@
static VOID WINAPI Port61hWrite(ULONG Port, BYTE Data)
{
- // BOOLEAN SpeakerChange = FALSE;
+ // BOOLEAN SpeakerStateChange = FALSE;
BYTE OldPort61hState = Port61hState;
/* Only the four lowest bytes can be written */
@@ -271,18 +271,17 @@
if ((OldPort61hState ^ Port61hState) & 0x01)
{
DPRINT("PIT 2 Gate %s\n", Port61hState & 0x01 ? "on" :
"off");
- // SpeakerChange = TRUE;
- }
-
- PitSetGate(2, !!(Port61hState & 0x01));
+ PitSetGate(2, !!(Port61hState & 0x01));
+ // SpeakerStateChange = TRUE;
+ }
if ((OldPort61hState ^ Port61hState) & 0x02)
{
/* There were some change for the speaker... */
DPRINT("Speaker %s\n", Port61hState & 0x02 ? "on" :
"off");
- // SpeakerChange = TRUE;
- }
- // if (SpeakerChange) SpeakerChange();
+ // SpeakerStateChange = TRUE;
+ }
+ // if (SpeakerStateChange) SpeakerChange();
SpeakerChange();
}
@@ -316,7 +315,7 @@
static VOID WINAPI PitChan2Out(LPVOID Param, BOOLEAN State)
{
- // BYTE OldPort61hState = Port61hState;
+ BYTE OldPort61hState = Port61hState;
#if 0
if (State)
@@ -332,9 +331,12 @@
#else
Port61hState = (Port61hState & 0xDF) | (State << 5);
#endif
- DPRINT("Speaker PIT out\n");
- // if ((OldPort61hState ^ Port61hState) & 0x20)
- // SpeakerChange();
+
+ if ((OldPort61hState ^ Port61hState) & 0x20)
+ {
+ DPRINT("PitChan2Out -- Port61hState changed\n");
+ SpeakerChange();
+ }
}
Modified: trunk/reactos/subsystems/ntvdm/hardware/speaker.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/hardware/…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/hardware/speaker.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/hardware/speaker.c [iso-8859-1] Sat Sep 27 15:33:27
2014
@@ -29,6 +29,9 @@
/* PRIVATE FUNCTIONS **********************************************************/
+static DWORD OldReloadValue = 0;
+static PIT_MODE OldMode = 0;
+
/* PUBLIC FUNCTIONS ***********************************************************/
VOID SpeakerChange(VOID)
@@ -47,9 +50,18 @@
DWORD PitChannel2ReloadValue = PitChannel2->ReloadValue;
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 */
- BeepSetParameters.Frequency = (PIT_BASE_FREQUENCY / PitChannel2ReloadValue)
- /* * (PitChannel2->Mode ==
PIT_MODE_SQUARE_WAVE ? 2 : 1) */;
+ BeepSetParameters.Frequency = (PIT_BASE_FREQUENCY / PitChannel2ReloadValue);
BeepSetParameters.Duration = INFINITE;
/* Send the beep */
@@ -77,6 +89,9 @@
NTSTATUS Status;
IO_STATUS_BLOCK IoStatusBlock;
BEEP_SET_PARAMETERS BeepSetParameters;
+
+ OldMode = 0;
+ OldReloadValue = 0;
/* Set beep data */
BeepSetParameters.Frequency = 0x00;