Author: tkreuzer
Date: Sun Feb 22 16:31:58 2015
New Revision: 66411
URL:
http://svn.reactos.org/svn/reactos?rev=66411&view=rev
Log:
[NTVDM]
- Fix BINARY_TO_BCD and BCD_TO_BINARY
- Fix MSVC warnings
Modified:
trunk/reactos/subsystems/ntvdm/bios/vidbios.c
trunk/reactos/subsystems/ntvdm/emulator.h
Modified: trunk/reactos/subsystems/ntvdm/bios/vidbios.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/vidb…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/vidbios.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/vidbios.c [iso-8859-1] Sun Feb 22 16:31:58 2015
@@ -2014,6 +2014,8 @@
case SCROLL_DOWN:
{
+ INT Bottom;
+
/* Move text lines down */
for (i = Rectangle.Bottom - Amount; i >= Rectangle.Top; i--)
{
@@ -2024,7 +2026,8 @@
}
/* Fill the top of the rectangle */
- for (i = Rectangle.Top; i <= Rectangle.Top + Amount - 1; i++)
+ Bottom = Rectangle.Top + Amount - 1;
+ for (i = Rectangle.Top; i <= Bottom; i++)
{
for (j = Rectangle.Left; j <= Rectangle.Right; j++)
{
@@ -2078,7 +2081,8 @@
/* Fill the left of the rectangle */
for (i = Rectangle.Top; i <= Rectangle.Bottom; i++)
{
- for (j = Rectangle.Left; j <= Rectangle.Left + Amount - 1; j++)
+ INT Right = Rectangle.Left + Amount - 1;
+ for (j = Rectangle.Left; j <= Right; j++)
{
EmulatorWriteMemory(&EmulatorContext,
VideoAddress + (i * Bda->ScreenColumns + j) *
sizeof(WORD),
Modified: trunk/reactos/subsystems/ntvdm/emulator.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/emulator.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/emulator.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/emulator.h [iso-8859-1] Sun Feb 22 16:31:58 2015
@@ -36,9 +36,40 @@
/* BCD-Binary conversion */
-#define BINARY_TO_BCD(x) ((((x) / 1000) << 12) + (((x) / 100) << 8) + (((x) /
10) << 4) + ((x) % 10))
-#define BCD_TO_BINARY(x) (((x) >> 12) * 1000 + ((x) >> 8) * 100 + ((x)
>> 4) * 10 + ((x) & 0x0F))
+FORCEINLINE
+USHORT
+BINARY_TO_BCD(USHORT Value)
+{
+ USHORT Result;
+
+ Result = (Value / 1000) << 12;
+ Value %= 1000;
+ Result |= (Value / 100) << 8;
+ Value %= 100;
+ Result |= (Value / 10) << 4;
+ Value %= 10;
+ Result |= Value;
+
+ return Result;
+}
+
+FORCEINLINE
+USHORT
+BCD_TO_BINARY(USHORT Value)
+{
+ USHORT Result;
+
+ Result = Value & 0xF;
+ Value >>= 4;
+ Result += (Value & 0xF) * 10;
+ Value >>= 4;
+ Result += (Value & 0xF) * 100;
+ Value >>= 4;
+ Result += Value * 1000;
+
+ return Result;
+}
/* System I/O ports */
#define CONTROL_SYSTEM_PORT61H 0x61