Remove whitespace from empty lines.


svn path=/branches/ntvdm/; revision=59296
This commit is contained in:
Aleksandar Andrejevic 2013-06-23 00:11:45 +00:00
parent 2bd695b42e
commit 030a935096
4 changed files with 86 additions and 86 deletions

View file

@ -55,27 +55,27 @@ BOOLEAN BiosInitialize()
CursorRow = ConsoleInfo.dwCursorPosition.Y; CursorRow = ConsoleInfo.dwCursorPosition.Y;
ConsoleWidth = ConsoleInfo.dwSize.X; ConsoleWidth = ConsoleInfo.dwSize.X;
ConsoleHeight = ConsoleInfo.dwSize.Y; ConsoleHeight = ConsoleInfo.dwSize.Y;
/* Initialize the PIC */ /* Initialize the PIC */
PicWriteCommand(PIC_MASTER_CMD, PIC_ICW1 | PIC_ICW1_ICW4); PicWriteCommand(PIC_MASTER_CMD, PIC_ICW1 | PIC_ICW1_ICW4);
PicWriteCommand(PIC_SLAVE_CMD, PIC_ICW1 | PIC_ICW1_ICW4); PicWriteCommand(PIC_SLAVE_CMD, PIC_ICW1 | PIC_ICW1_ICW4);
/* Set the interrupt offsets */ /* Set the interrupt offsets */
PicWriteData(PIC_MASTER_DATA, BIOS_PIC_MASTER_INT); PicWriteData(PIC_MASTER_DATA, BIOS_PIC_MASTER_INT);
PicWriteData(PIC_SLAVE_DATA, BIOS_PIC_SLAVE_INT); PicWriteData(PIC_SLAVE_DATA, BIOS_PIC_SLAVE_INT);
/* Tell the master PIC there is a slave at IRQ 2 */ /* Tell the master PIC there is a slave at IRQ 2 */
PicWriteData(PIC_MASTER_DATA, 1 << 2); PicWriteData(PIC_MASTER_DATA, 1 << 2);
PicWriteData(PIC_SLAVE_DATA, 2); PicWriteData(PIC_SLAVE_DATA, 2);
/* Make sure the PIC is in 8086 mode */ /* Make sure the PIC is in 8086 mode */
PicWriteData(PIC_MASTER_DATA, PIC_ICW4_8086); PicWriteData(PIC_MASTER_DATA, PIC_ICW4_8086);
PicWriteData(PIC_SLAVE_DATA, PIC_ICW4_8086); PicWriteData(PIC_SLAVE_DATA, PIC_ICW4_8086);
/* Clear the masks for both PICs */ /* Clear the masks for both PICs */
PicWriteData(PIC_MASTER_DATA, 0x00); PicWriteData(PIC_MASTER_DATA, 0x00);
PicWriteData(PIC_SLAVE_DATA, 0x00); PicWriteData(PIC_SLAVE_DATA, 0x00);
PitWriteCommand(0x34); PitWriteCommand(0x34);
PitWriteData(0, 0x00); PitWriteData(0, 0x00);
PitWriteData(0, 0x00); PitWriteData(0, 0x00);
@ -230,7 +230,7 @@ VOID BiosVideoService()
Position.X = Rect.Left; Position.X = Rect.Left;
if (HIBYTE(Eax) == 0x06) Position.Y = Rect.Top - LOBYTE(Eax); if (HIBYTE(Eax) == 0x06) Position.Y = Rect.Top - LOBYTE(Eax);
else Position.Y = Rect.Top + LOBYTE(Eax); else Position.Y = Rect.Top + LOBYTE(Eax);
ScrollConsoleScreenBuffer(ConsoleOutput, ScrollConsoleScreenBuffer(ConsoleOutput,
&Rect, &Rect,
&Rect, &Rect,

View file

@ -581,7 +581,7 @@ VOID DosInt21h(WORD CodeSegment)
(Eax & 0xFFFFFF00) | SystemTime.wDayOfWeek); (Eax & 0xFFFFFF00) | SystemTime.wDayOfWeek);
break; break;
} }
/* Set system date */ /* Set system date */
case 0x2B: case 0x2B:
{ {
@ -589,7 +589,7 @@ VOID DosInt21h(WORD CodeSegment)
SystemTime.wYear = LOWORD(Ecx); SystemTime.wYear = LOWORD(Ecx);
SystemTime.wMonth = HIBYTE(Edx); SystemTime.wMonth = HIBYTE(Edx);
SystemTime.wDay = LOBYTE(Edx); SystemTime.wDay = LOBYTE(Edx);
if (SetLocalTime(&SystemTime)) if (SetLocalTime(&SystemTime))
{ {
/* Return success */ /* Return success */
@ -600,7 +600,7 @@ VOID DosInt21h(WORD CodeSegment)
/* Return failure */ /* Return failure */
EmulatorSetRegister(EMULATOR_REG_AX, Eax | 0xFF); EmulatorSetRegister(EMULATOR_REG_AX, Eax | 0xFF);
} }
break; break;
} }
@ -618,7 +618,7 @@ VOID DosInt21h(WORD CodeSegment)
| (SystemTime.wMilliseconds / 10)); | (SystemTime.wMilliseconds / 10));
break; break;
} }
/* Set system time */ /* Set system time */
case 0x2D: case 0x2D:
{ {
@ -627,7 +627,7 @@ VOID DosInt21h(WORD CodeSegment)
SystemTime.wMinute = LOBYTE(Ecx); SystemTime.wMinute = LOBYTE(Ecx);
SystemTime.wSecond = HIBYTE(Edx); SystemTime.wSecond = HIBYTE(Edx);
SystemTime.wMilliseconds = LOBYTE(Edx) * 10; SystemTime.wMilliseconds = LOBYTE(Edx) * 10;
if (SetLocalTime(&SystemTime)) if (SetLocalTime(&SystemTime))
{ {
/* Return success */ /* Return success */
@ -638,7 +638,7 @@ VOID DosInt21h(WORD CodeSegment)
/* Return failure */ /* Return failure */
EmulatorSetRegister(EMULATOR_REG_AX, Eax | 0xFF); EmulatorSetRegister(EMULATOR_REG_AX, Eax | 0xFF);
} }
break; break;
} }

View file

@ -64,7 +64,7 @@ static VOID EmulatorReadIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
*Buffer = PicReadCommand(Address); *Buffer = PicReadCommand(Address);
break; break;
} }
case PIC_MASTER_DATA: case PIC_MASTER_DATA:
case PIC_SLAVE_DATA: case PIC_SLAVE_DATA:
{ {
@ -77,7 +77,7 @@ static VOID EmulatorReadIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
static VOID EmulatorWriteIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size) static VOID EmulatorWriteIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size)
{ {
BYTE Byte = *Buffer; BYTE Byte = *Buffer;
switch (Address) switch (Address)
{ {
case PIT_COMMAND_PORT: case PIT_COMMAND_PORT:
@ -85,7 +85,7 @@ static VOID EmulatorWriteIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size
PitWriteCommand(Byte); PitWriteCommand(Byte);
break; break;
} }
case PIT_DATA_PORT(0): case PIT_DATA_PORT(0):
case PIT_DATA_PORT(1): case PIT_DATA_PORT(1):
case PIT_DATA_PORT(2): case PIT_DATA_PORT(2):
@ -93,14 +93,14 @@ static VOID EmulatorWriteIo(PVOID Context, UINT Address, LPBYTE Buffer, INT Size
PitWriteData(Address - PIT_DATA_PORT(0), Byte); PitWriteData(Address - PIT_DATA_PORT(0), Byte);
break; break;
} }
case PIC_MASTER_CMD: case PIC_MASTER_CMD:
case PIC_SLAVE_CMD: case PIC_SLAVE_CMD:
{ {
PicWriteCommand(Address, Byte); PicWriteCommand(Address, Byte);
break; break;
} }
case PIC_MASTER_DATA: case PIC_MASTER_DATA:
case PIC_SLAVE_DATA: case PIC_SLAVE_DATA:
{ {
@ -147,7 +147,7 @@ static VOID EmulatorSoftwareInt(PVOID Context, BYTE Number)
VdmRunning = FALSE; VdmRunning = FALSE;
return; return;
} }
/* Check if this was an PIC IRQ */ /* Check if this was an PIC IRQ */
if (IntNum >= BIOS_PIC_MASTER_INT && IntNum < BIOS_PIC_MASTER_INT + 8) if (IntNum >= BIOS_PIC_MASTER_INT && IntNum < BIOS_PIC_MASTER_INT + 8)
{ {

View file

@ -61,15 +61,15 @@ static BOOLEAN KeyboardQueuePush(BYTE ScanCode)
{ {
return FALSE; return FALSE;
} }
/* Insert the value in the queue */ /* Insert the value in the queue */
KeyboardQueue[KeyboardQueueEnd] = ScanCode; KeyboardQueue[KeyboardQueueEnd] = ScanCode;
KeyboardQueueEnd++; KeyboardQueueEnd++;
KeyboardQueueEnd %= KEYBOARD_BUFFER_SIZE; KeyboardQueueEnd %= KEYBOARD_BUFFER_SIZE;
/* Since we inserted a value, it's not empty anymore */ /* Since we inserted a value, it's not empty anymore */
KeyboardQueueEmpty = FALSE; KeyboardQueueEmpty = FALSE;
return TRUE; return TRUE;
} }
@ -78,20 +78,20 @@ static BOOLEAN KeyboardQueuePop(BYTE *ScanCode)
{ {
/* Make sure the keyboard queue is not empty */ /* Make sure the keyboard queue is not empty */
if (KeyboardQueueEmpty) return FALSE; if (KeyboardQueueEmpty) return FALSE;
/* Get the scan code */ /* Get the scan code */
*ScanCode = KeyboardQueue[KeyboardQueueStart]; *ScanCode = KeyboardQueue[KeyboardQueueStart];
/* Remove the value from the queue */ /* Remove the value from the queue */
KeyboardQueueStart++; KeyboardQueueStart++;
KeyboardQueueStart %= KEYBOARD_BUFFER_SIZE; KeyboardQueueStart %= KEYBOARD_BUFFER_SIZE;
/* Check if the queue is now empty */ /* Check if the queue is now empty */
if (KeyboardQueueStart == KeyboardQueueEnd) if (KeyboardQueueStart == KeyboardQueueEnd)
{ {
KeyboardQueueEmpty = TRUE; KeyboardQueueEmpty = TRUE;
} }
return TRUE; return TRUE;
} }
#endif #endif
@ -101,11 +101,11 @@ static BOOLEAN KeyboardQueuePop(BYTE *ScanCode)
BYTE PicReadCommand(BYTE Port) BYTE PicReadCommand(BYTE Port)
{ {
PPIC Pic; PPIC Pic;
/* Which PIC are we accessing? */ /* Which PIC are we accessing? */
if (Port == PIC_MASTER_CMD) Pic = &MasterPic; if (Port == PIC_MASTER_CMD) Pic = &MasterPic;
else Pic = &SlavePic; else Pic = &SlavePic;
if (Pic->ReadIsr) if (Pic->ReadIsr)
{ {
/* Read the in-service register */ /* Read the in-service register */
@ -122,11 +122,11 @@ BYTE PicReadCommand(BYTE Port)
VOID PicWriteCommand(BYTE Port, BYTE Value) VOID PicWriteCommand(BYTE Port, BYTE Value)
{ {
PPIC Pic; PPIC Pic;
/* Which PIC are we accessing? */ /* Which PIC are we accessing? */
if (Port == PIC_MASTER_CMD) Pic = &MasterPic; if (Port == PIC_MASTER_CMD) Pic = &MasterPic;
else Pic = &SlavePic; else Pic = &SlavePic;
if (Value & PIC_ICW1) if (Value & PIC_ICW1)
{ {
/* Start initialization */ /* Start initialization */
@ -136,7 +136,7 @@ VOID PicWriteCommand(BYTE Port, BYTE Value)
Pic->ConfigRegister = Value; Pic->ConfigRegister = Value;
return; return;
} }
if (Value & PIC_OCW3) if (Value & PIC_OCW3)
{ {
/* This is an OCR3 */ /* This is an OCR3 */
@ -145,10 +145,10 @@ VOID PicWriteCommand(BYTE Port, BYTE Value)
/* Return the ISR on next read from command port */ /* Return the ISR on next read from command port */
Pic->ReadIsr = TRUE; Pic->ReadIsr = TRUE;
} }
return; return;
} }
/* This is an OCW2 */ /* This is an OCW2 */
if (Value & PIC_OCW2_EOI) if (Value & PIC_OCW2_EOI)
{ {
@ -175,11 +175,11 @@ BYTE PicReadData(BYTE Port)
VOID PicWriteData(BYTE Port, BYTE Value) VOID PicWriteData(BYTE Port, BYTE Value)
{ {
PPIC Pic; PPIC Pic;
/* Which PIC are we accessing? */ /* Which PIC are we accessing? */
if (Port == PIC_MASTER_DATA) Pic = &MasterPic; if (Port == PIC_MASTER_DATA) Pic = &MasterPic;
else Pic = &SlavePic; else Pic = &SlavePic;
/* Is the PIC ready? */ /* Is the PIC ready? */
if (!Pic->Initialization) if (!Pic->Initialization)
{ {
@ -187,13 +187,13 @@ VOID PicWriteData(BYTE Port, BYTE Value)
Pic->MaskRegister = Value; Pic->MaskRegister = Value;
return; return;
} }
/* Has the interrupt offset been set? */ /* Has the interrupt offset been set? */
if (Pic->IntOffset == 0xFF) if (Pic->IntOffset == 0xFF)
{ {
/* This is an ICW2, set the offset (last three bits always zero) */ /* This is an ICW2, set the offset (last three bits always zero) */
Pic->IntOffset = Value & 0xF8; Pic->IntOffset = Value & 0xF8;
/* Check if we are in single mode and don't need an ICW4 */ /* Check if we are in single mode and don't need an ICW4 */
if ((Pic->ConfigRegister & PIC_ICW1_SINGLE) if ((Pic->ConfigRegister & PIC_ICW1_SINGLE)
&& !(Pic->ConfigRegister & PIC_ICW1_ICW4)) && !(Pic->ConfigRegister & PIC_ICW1_ICW4))
@ -203,14 +203,14 @@ VOID PicWriteData(BYTE Port, BYTE Value)
} }
return; return;
} }
/* Check if we are in cascade mode and the cascade register was not set */ /* Check if we are in cascade mode and the cascade register was not set */
if (!(Pic->ConfigRegister & PIC_ICW1_SINGLE) && !Pic->CascadeRegisterSet) if (!(Pic->ConfigRegister & PIC_ICW1_SINGLE) && !Pic->CascadeRegisterSet)
{ {
/* This is an ICW3 */ /* This is an ICW3 */
Pic->CascadeRegister = Value; Pic->CascadeRegister = Value;
Pic->CascadeRegisterSet = TRUE; Pic->CascadeRegisterSet = TRUE;
/* Check if we need an ICW4 */ /* Check if we need an ICW4 */
if (!(Pic->ConfigRegister & PIC_ICW1_ICW4)) if (!(Pic->ConfigRegister & PIC_ICW1_ICW4))
{ {
@ -219,22 +219,22 @@ VOID PicWriteData(BYTE Port, BYTE Value)
} }
return; return;
} }
/* This must be an ICW4, we will ignore the 8086 bit (assume always set) */ /* This must be an ICW4, we will ignore the 8086 bit (assume always set) */
if (Value & PIC_ICW4_AEOI) if (Value & PIC_ICW4_AEOI)
{ {
/* Use automatic end-of-interrupt */ /* Use automatic end-of-interrupt */
Pic->AutoEoi = TRUE; Pic->AutoEoi = TRUE;
} }
/* Done initializing */ /* Done initializing */
Pic->Initialization = FALSE; Pic->Initialization = FALSE;
} }
VOID PicInterruptRequest(BYTE Number) VOID PicInterruptRequest(BYTE Number)
{ {
BYTE i; BYTE i;
if (Number >= 0 && Number < 8) if (Number >= 0 && Number < 8)
{ {
/* Check if any of the higher-priorirty interrupts are busy */ /* Check if any of the higher-priorirty interrupts are busy */
@ -242,10 +242,10 @@ VOID PicInterruptRequest(BYTE Number)
{ {
if (MasterPic.InServiceRegister & (1 << Number)) return; if (MasterPic.InServiceRegister & (1 << Number)) return;
} }
/* Check if the interrupt is masked */ /* Check if the interrupt is masked */
if (MasterPic.MaskRegister & (1 << Number)) return; if (MasterPic.MaskRegister & (1 << Number)) return;
/* Set the appropriate bit in the ISR and interrupt the CPU */ /* Set the appropriate bit in the ISR and interrupt the CPU */
if (!MasterPic.AutoEoi) MasterPic.InServiceRegister |= 1 << Number; if (!MasterPic.AutoEoi) MasterPic.InServiceRegister |= 1 << Number;
EmulatorInterrupt(MasterPic.IntOffset + Number); EmulatorInterrupt(MasterPic.IntOffset + Number);
@ -253,7 +253,7 @@ VOID PicInterruptRequest(BYTE Number)
else if (Number >= 8 && Number < 16) else if (Number >= 8 && Number < 16)
{ {
Number -= 8; Number -= 8;
/* /*
* The slave PIC is connected to IRQ 2, always! If the master PIC * The slave PIC is connected to IRQ 2, always! If the master PIC
* was misconfigured, don't do anything. * was misconfigured, don't do anything.
@ -263,20 +263,20 @@ VOID PicInterruptRequest(BYTE Number)
{ {
return; return;
} }
/* Check if any of the higher-priorirty interrupts are busy */ /* Check if any of the higher-priorirty interrupts are busy */
if (MasterPic.InServiceRegister != 0) return; if (MasterPic.InServiceRegister != 0) return;
for (i = 0; i <= Number ; i++) for (i = 0; i <= Number ; i++)
{ {
if (SlavePic.InServiceRegister & (1 << Number)) return; if (SlavePic.InServiceRegister & (1 << Number)) return;
} }
/* Check if the interrupt is masked */ /* Check if the interrupt is masked */
if (SlavePic.MaskRegister & (1 << Number)) return; if (SlavePic.MaskRegister & (1 << Number)) return;
/* Set the IRQ 2 bit in the master ISR */ /* Set the IRQ 2 bit in the master ISR */
if (!MasterPic.AutoEoi) MasterPic.InServiceRegister |= 1 << 2; if (!MasterPic.AutoEoi) MasterPic.InServiceRegister |= 1 << 2;
/* Set the appropriate bit in the ISR and interrupt the CPU */ /* Set the appropriate bit in the ISR and interrupt the CPU */
if (!SlavePic.AutoEoi) SlavePic.InServiceRegister |= 1 << Number; if (!SlavePic.AutoEoi) SlavePic.InServiceRegister |= 1 << Number;
EmulatorInterrupt(SlavePic.IntOffset + Number); EmulatorInterrupt(SlavePic.IntOffset + Number);
@ -287,7 +287,7 @@ VOID PitWriteCommand(BYTE Value)
{ {
BYTE Channel = Value >> 6; BYTE Channel = Value >> 6;
BYTE Mode = (Value >> 1) & 0x07; BYTE Mode = (Value >> 1) & 0x07;
/* Check if this is a counter latch command */ /* Check if this is a counter latch command */
if (((Value >> 4) & 3) == 0) if (((Value >> 4) & 3) == 0)
{ {
@ -295,14 +295,14 @@ VOID PitWriteCommand(BYTE Value)
PitChannels[Channel].LatchedValue = PitChannels[Channel].CurrentValue; PitChannels[Channel].LatchedValue = PitChannels[Channel].CurrentValue;
return; return;
} }
/* Set the access mode and reset flip-flops */ /* Set the access mode and reset flip-flops */
PitChannels[Channel].AccessMode = (Value >> 4) & 3; PitChannels[Channel].AccessMode = (Value >> 4) & 3;
PitChannels[Channel].Pulsed = FALSE; PitChannels[Channel].Pulsed = FALSE;
PitChannels[Channel].LatchSet = FALSE; PitChannels[Channel].LatchSet = FALSE;
PitChannels[Channel].InputFlipFlop = FALSE; PitChannels[Channel].InputFlipFlop = FALSE;
PitChannels[Channel].OutputFlipFlop = FALSE; PitChannels[Channel].OutputFlipFlop = FALSE;
switch (Mode) switch (Mode)
{ {
case 0: case 0:
@ -315,13 +315,13 @@ VOID PitWriteCommand(BYTE Value)
PitChannels[Channel].Mode = Mode; PitChannels[Channel].Mode = Mode;
break; break;
} }
case 6: case 6:
{ {
PitChannels[Channel].Mode = PIT_MODE_RATE_GENERATOR; PitChannels[Channel].Mode = PIT_MODE_RATE_GENERATOR;
break; break;
} }
case 7: case 7:
{ {
PitChannels[Channel].Mode = PIT_MODE_SQUARE_WAVE; PitChannels[Channel].Mode = PIT_MODE_SQUARE_WAVE;
@ -339,20 +339,20 @@ BYTE PitReadData(BYTE Channel)
if (PitChannels[Channel].LatchSet) if (PitChannels[Channel].LatchSet)
{ {
CurrentValue = PitChannels[Channel].LatchedValue; CurrentValue = PitChannels[Channel].LatchedValue;
if (AccessMode == 1 || AccessMode == 2) if (AccessMode == 1 || AccessMode == 2)
{ {
/* The latched value was read as one byte */ /* The latched value was read as one byte */
PitChannels[Channel].LatchSet = FALSE; PitChannels[Channel].LatchSet = FALSE;
} }
} }
/* Use the flip-flop for access mode 3 */ /* Use the flip-flop for access mode 3 */
if (AccessMode == 3) if (AccessMode == 3)
{ {
AccessMode = PitChannels[Channel].InputFlipFlop ? 1 : 2; AccessMode = PitChannels[Channel].InputFlipFlop ? 1 : 2;
PitChannels[Channel].InputFlipFlop = !PitChannels[Channel].InputFlipFlop; PitChannels[Channel].InputFlipFlop = !PitChannels[Channel].InputFlipFlop;
/* Check if this was the last read for the latched value */ /* Check if this was the last read for the latched value */
if (!PitChannels[Channel].InputFlipFlop) if (!PitChannels[Channel].InputFlipFlop)
{ {
@ -360,7 +360,7 @@ BYTE PitReadData(BYTE Channel)
PitChannels[Channel].LatchSet = FALSE; PitChannels[Channel].LatchSet = FALSE;
} }
} }
switch (AccessMode) switch (AccessMode)
{ {
case 1: case 1:
@ -368,14 +368,14 @@ BYTE PitReadData(BYTE Channel)
/* Low byte */ /* Low byte */
return CurrentValue & 0x00FF; return CurrentValue & 0x00FF;
} }
case 2: case 2:
{ {
/* High byte */ /* High byte */
return CurrentValue >> 8; return CurrentValue >> 8;
} }
} }
/* Shouldn't get here */ /* Shouldn't get here */
return 0; return 0;
} }
@ -383,14 +383,14 @@ BYTE PitReadData(BYTE Channel)
VOID PitWriteData(BYTE Channel, BYTE Value) VOID PitWriteData(BYTE Channel, BYTE Value)
{ {
BYTE AccessMode = PitChannels[Channel].AccessMode; BYTE AccessMode = PitChannels[Channel].AccessMode;
/* Use the flip-flop for access mode 3 */ /* Use the flip-flop for access mode 3 */
if (PitChannels[Channel].AccessMode == 3) if (PitChannels[Channel].AccessMode == 3)
{ {
AccessMode = PitChannels[Channel].InputFlipFlop ? 1 : 2; AccessMode = PitChannels[Channel].InputFlipFlop ? 1 : 2;
PitChannels[Channel].InputFlipFlop = !PitChannels[Channel].InputFlipFlop; PitChannels[Channel].InputFlipFlop = !PitChannels[Channel].InputFlipFlop;
} }
switch (AccessMode) switch (AccessMode)
{ {
case 1: case 1:
@ -400,7 +400,7 @@ VOID PitWriteData(BYTE Channel, BYTE Value)
PitChannels[Channel].ReloadValue |= Value; PitChannels[Channel].ReloadValue |= Value;
break; break;
} }
case 2: case 2:
{ {
/* High byte */ /* High byte */
@ -413,7 +413,7 @@ VOID PitWriteData(BYTE Channel, BYTE Value)
VOID PitDecrementCount() VOID PitDecrementCount()
{ {
INT i; INT i;
for (i = 0; i < PIT_CHANNELS; i++) for (i = 0; i < PIT_CHANNELS; i++)
{ {
switch (PitChannels[i].Mode) switch (PitChannels[i].Mode)
@ -422,7 +422,7 @@ VOID PitDecrementCount()
{ {
/* Decrement the value */ /* Decrement the value */
PitChannels[i].CurrentValue--; PitChannels[i].CurrentValue--;
/* Did it fall to the terminal count? */ /* Did it fall to the terminal count? */
if (PitChannels[i].CurrentValue == 0 && !PitChannels[i].Pulsed) if (PitChannels[i].CurrentValue == 0 && !PitChannels[i].Pulsed)
{ {
@ -432,40 +432,40 @@ VOID PitDecrementCount()
} }
break; break;
} }
case PIT_MODE_RATE_GENERATOR: case PIT_MODE_RATE_GENERATOR:
{ {
/* Decrement the value */ /* Decrement the value */
PitChannels[i].CurrentValue--; PitChannels[i].CurrentValue--;
/* Did it fall to zero? */ /* Did it fall to zero? */
if (PitChannels[i].CurrentValue != 0) break; if (PitChannels[i].CurrentValue != 0) break;
/* Yes, raise the output line and reload */ /* Yes, raise the output line and reload */
if (i == 0) PicInterruptRequest(0); if (i == 0) PicInterruptRequest(0);
PitChannels[i].CurrentValue = PitChannels[i].ReloadValue; PitChannels[i].CurrentValue = PitChannels[i].ReloadValue;
break; break;
} }
case PIT_MODE_SQUARE_WAVE: case PIT_MODE_SQUARE_WAVE:
{ {
/* Decrement the value by 2 */ /* Decrement the value by 2 */
PitChannels[i].CurrentValue -= 2; PitChannels[i].CurrentValue -= 2;
/* Did it fall to zero? */ /* Did it fall to zero? */
if (PitChannels[i].CurrentValue != 0) break; if (PitChannels[i].CurrentValue != 0) break;
/* Yes, toggle the flip-flop */ /* Yes, toggle the flip-flop */
PitChannels[i].OutputFlipFlop = !PitChannels[i].OutputFlipFlop; PitChannels[i].OutputFlipFlop = !PitChannels[i].OutputFlipFlop;
/* Did this create a rising edge in the signal? */ /* Did this create a rising edge in the signal? */
if (PitChannels[i].OutputFlipFlop) if (PitChannels[i].OutputFlipFlop)
{ {
/* Yes, IRQ 0 if this is channel 0 */ /* Yes, IRQ 0 if this is channel 0 */
if (i == 0) PicInterruptRequest(0); if (i == 0) PicInterruptRequest(0);
} }
/* Reload the value, but make sure it's even */ /* Reload the value, but make sure it's even */
if (PitChannels[i].ReloadValue % 2) if (PitChannels[i].ReloadValue % 2)
{ {
@ -477,16 +477,16 @@ VOID PitDecrementCount()
/* It was even */ /* It was even */
PitChannels[i].CurrentValue = PitChannels[i].ReloadValue; PitChannels[i].CurrentValue = PitChannels[i].ReloadValue;
} }
break; break;
} }
case PIT_MODE_SOFTWARE_STROBE: case PIT_MODE_SOFTWARE_STROBE:
{ {
// TODO: NOT IMPLEMENTED // TODO: NOT IMPLEMENTED
break; break;
} }
case PIT_MODE_HARDWARE_ONE_SHOT: case PIT_MODE_HARDWARE_ONE_SHOT:
case PIT_MODE_HARDWARE_STROBE: case PIT_MODE_HARDWARE_STROBE:
{ {
@ -503,42 +503,42 @@ VOID CheckForInputEvents()
HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE); HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
DWORD i, j, Count, TotalEvents; DWORD i, j, Count, TotalEvents;
BYTE ScanCode; BYTE ScanCode;
/* Get the number of input events */ /* Get the number of input events */
if (!GetNumberOfConsoleInputEvents(ConsoleInput, &Count)) return; if (!GetNumberOfConsoleInputEvents(ConsoleInput, &Count)) return;
if (Count == 0) return; if (Count == 0) return;
/* Allocate the buffer */ /* Allocate the buffer */
Buffer = (PINPUT_RECORD)HeapAlloc(GetProcessHeap(), 0, Count * sizeof(INPUT_RECORD)); Buffer = (PINPUT_RECORD)HeapAlloc(GetProcessHeap(), 0, Count * sizeof(INPUT_RECORD));
if (Buffer == NULL) return; if (Buffer == NULL) return;
/* Peek the input events */ /* Peek the input events */
if (!ReadConsoleInput(ConsoleInput, Buffer, Count, &TotalEvents)) goto Cleanup; if (!ReadConsoleInput(ConsoleInput, Buffer, Count, &TotalEvents)) goto Cleanup;
for (i = 0; i < TotalEvents; i++) for (i = 0; i < TotalEvents; i++)
{ {
/* Check if this is a key event */ /* Check if this is a key event */
if (Buffer[i].EventType != KEY_EVENT) continue; if (Buffer[i].EventType != KEY_EVENT) continue;
/* Get the scan code */ /* Get the scan code */
ScanCode = Buffer[i].Event.KeyEvent.wVirtualScanCode; ScanCode = Buffer[i].Event.KeyEvent.wVirtualScanCode;
/* If this is a key release, set the highest bit in the scan code */ /* If this is a key release, set the highest bit in the scan code */
if (!Buffer[i].Event.KeyEvent.bKeyDown) ScanCode |= 0x80; if (!Buffer[i].Event.KeyEvent.bKeyDown) ScanCode |= 0x80;
/* Push the scan code onto the keyboard queue */ /* Push the scan code onto the keyboard queue */
for (j = 0; j < Buffer[i].Event.KeyEvent.wRepeatCount; j++) for (j = 0; j < Buffer[i].Event.KeyEvent.wRepeatCount; j++)
{ {
KeyboardQueuePush(ScanCode); KeyboardQueuePush(ScanCode);
} }
/* Yes, IRQ 1 */ /* Yes, IRQ 1 */
PicInterruptRequest(1); PicInterruptRequest(1);
/* Stop the loop */ /* Stop the loop */
break; break;
} }
Cleanup: Cleanup:
HeapFree(GetProcessHeap(), 0, Buffer); HeapFree(GetProcessHeap(), 0, Buffer);
} }