Author: hbelusca
Date: Sat Nov 9 19:55:04 2013
New Revision: 60906
URL:
http://svn.reactos.org/svn/reactos?rev=60906&view=rev
Log:
[NTVDM]
- Make usage of MAKEWORD;
- Introduce BiosGetCursorPosition and use it in BiosPrintCharacter;
- Use EmulatorWriteMemory instead of VgaWriteMemory somewhere in BiosPrintCharacter;
- Add support for tabs in BiosPrintCharacter (taken from DosBox).
Modified:
branches/ntvdm/subsystems/ntvdm/bios.c
branches/ntvdm/subsystems/ntvdm/bios.h
Modified: branches/ntvdm/subsystems/ntvdm/bios.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.c?r…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios.c [iso-8859-1] Sat Nov 9 19:55:04 2013
@@ -430,7 +430,7 @@
Resolution = VgaGetDisplayResolution();
Bda->ScreenColumns = Resolution.X;
- Bda->ScreenRows = Resolution.Y - 1;
+ Bda->ScreenRows = Resolution.Y - 1;
return TRUE;
}
@@ -641,13 +641,23 @@
return CharacterData;
}
-VOID BiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page)
+VOID BiosGetCursorPosition(PBYTE Row, PBYTE Column, BYTE Page)
{
/* Make sure the selected video page is valid */
if (Page >= BIOS_MAX_PAGES) return;
+ /* Get the cursor location */
+ *Row = HIBYTE(Bda->CursorPosition[Page]);
+ *Column = LOBYTE(Bda->CursorPosition[Page]);
+}
+
+VOID BiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page)
+{
+ /* Make sure the selected video page is valid */
+ if (Page >= BIOS_MAX_PAGES) return;
+
/* Update the position in the BDA */
- Bda->CursorPosition[Page] = (Row << 8) | Column;
+ Bda->CursorPosition[Page] = MAKEWORD(Column, Row);
/* Check if this is the current video page */
if (Page == Bda->VideoPage)
@@ -687,7 +697,7 @@
/* Fill the window */
for (i = 0; i < WindowSize; i++)
{
- WindowData[i] = ' ' | (FillAttribute << 8);
+ WindowData[i] = MAKEWORD(' ', FillAttribute);
}
goto Done;
@@ -707,15 +717,14 @@
VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page)
{
- WORD CharData = (Attribute << 8) | Character;
+ WORD CharData = MAKEWORD(Character, Attribute);
BYTE Row, Column;
/* Make sure the page exists */
if (Page >= BIOS_MAX_PAGES) return;
/* Get the cursor location */
- Row = HIBYTE(Bda->CursorPosition[Page]);
- Column = LOBYTE(Bda->CursorPosition[Page]);
+ BiosGetCursorPosition(&Row, &Column, Page);
if (Character == '\a')
{
@@ -738,12 +747,23 @@
}
/* Erase the existing character */
- CharData = (Attribute << 8) | ' ';
- VgaWriteMemory(TO_LINEAR(TEXT_VIDEO_SEG,
- Page * Bda->VideoPageSize
- + (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
- (LPVOID)&CharData,
- sizeof(WORD));
+ CharData = MAKEWORD(' ', Attribute);
+ EmulatorWriteMemory(&EmulatorContext,
+ TO_LINEAR(TEXT_VIDEO_SEG,
+ Page * Bda->VideoPageSize +
+ (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
+ (LPVOID)&CharData,
+ sizeof(WORD));
+ }
+ else if (Character == '\t')
+ {
+ /* Horizontal Tabulation control character */
+ do
+ {
+ // Taken from DosBox
+ BiosPrintCharacter(' ', Attribute, Page);
+ BiosGetCursorPosition(&Row, &Column, Page);
+ } while (Column % 8);
}
else if (Character == '\n')
{
@@ -762,8 +782,8 @@
/* Write the character */
EmulatorWriteMemory(&EmulatorContext,
TO_LINEAR(TEXT_VIDEO_SEG,
- Page * Bda->VideoPageSize
- + (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
+ Page * Bda->VideoPageSize +
+ (Row * Bda->ScreenColumns + Column) * sizeof(WORD)),
(LPVOID)&CharData,
sizeof(WORD));
@@ -1174,6 +1194,18 @@
}
}
+VOID BiosEquipmentService(LPWORD Stack)
+{
+ /* Return the equipment list */
+ setAX(Bda->EquipmentList);
+}
+
+VOID BiosGetMemorySize(LPWORD Stack)
+{
+ /* Return the conventional memory size in kB, typically 640 kB */
+ setAX(Bda->MemorySize);
+}
+
VOID BiosKeyboardService(LPWORD Stack)
{
switch (getAH())
@@ -1298,18 +1330,6 @@
{
/* Increase the system tick count */
Bda->TickCounter++;
-}
-
-VOID BiosEquipmentService(LPWORD Stack)
-{
- /* Return the equipment list */
- setAX(Bda->EquipmentList);
-}
-
-VOID BiosGetMemorySize(LPWORD Stack)
-{
- /* Return the conventional memory size in kB, typically 640 kB */
- setAX(Bda->MemorySize);
}
VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack)
Modified: branches/ntvdm/subsystems/ntvdm/bios.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios.h?r…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/bios.h [iso-8859-1] Sat Nov 9 19:55:04 2013
@@ -17,12 +17,12 @@
#define ROM_AREA_START 0xE0000
#define ROM_AREA_END 0xFFFFF
-#define BDA_SEGMENT 0x40
+
+#define BDA_SEGMENT 0x40
+#define BIOS_SEGMENT 0xF000
#define BIOS_PIC_MASTER_INT 0x08
#define BIOS_PIC_SLAVE_INT 0x70
-
-#define BIOS_SEGMENT 0xF000
#define BIOS_VIDEO_INTERRUPT 0x10
#define BIOS_EQUIPMENT_INTERRUPT 0x11
@@ -157,6 +157,7 @@
BOOLEAN BiosSetVideoMode(BYTE ModeNumber);
WORD BiosPeekCharacter(VOID);
WORD BiosGetCharacter(VOID);
+VOID BiosGetCursorPosition(PBYTE Row, PBYTE Column, BYTE Page);
VOID BiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page);
VOID BiosVideoService(LPWORD Stack);
VOID BiosEquipmentService(LPWORD Stack);