Commit in freeldr/freeldr on MAIN
Makefile+10-61.56 -> 1.57
bootmgr.c+4-31.9 -> 1.10
custom.c+21-101.1 -> 1.2
debug.c+1-11.23 -> 1.24
freeldr.c+1-11.29 -> 1.30
machine.c+104-131.4 -> 1.5
arch/i386/pcrtc.c+107added 1.1
         /pcvideo.c+1109added 1.1
         /xboxcons.c+78added 1.1
         /xboxrtc.c+85added 1.1
         /i386rtl.c-2671.3 -> 1.4
         /i386trap.S+2-21.6 -> 1.7
         /i386vid.c-5561.2 -> 1.3
         /machpc.c+18-41.4 -> 1.5
         /machpc.h+18-31.4 -> 1.5
         /machxbox.c+16-41.4 -> 1.5
         /machxbox.h+18-41.4 -> 1.5
         /pccons.c+56-211.2 -> 1.3
         /xboxvideo.c+79-441.2 -> 1.3
include/machine.h+41-71.4 -> 1.5
       /rtl.h-91.10 -> 1.11
       /video.h+13-1471.5 -> 1.6
inifile/parse.c+2-11.8 -> 1.9
mm/mm.c+7-61.13 -> 1.14
reactos/setupldr.c+2-21.16 -> 1.17
rtl/print.c+6-61.8 -> 1.9
ui/tui.c+30-331.12 -> 1.13
  /tuimenu.c+11-81.4 -> 1.5
  /ui.c+39-801.8 -> 1.9
video/bank.c+4-381.2 -> 1.3
     /fade.c+9-91.2 -> 1.3
     /palette.c+4-211.2 -> 1.3
     /pixel.c+26-281.4 -> 1.5
     /video.c+2-251.3 -> 1.4
     /vidmode.c-3131.4 removed
+1923-1672
4 added + 1 removed + 30 modified, total 35 files
Add UI support on the Xbox

freeldr/freeldr
Makefile 1.56 -> 1.57
diff -u -r1.56 -r1.57
--- Makefile	12 Nov 2004 17:17:07 -0000	1.56
+++ Makefile	14 Nov 2004 22:04:38 -0000	1.57
@@ -135,7 +135,7 @@
 #############################################
 # COMPILER COMMAND LINE OPTIONS
 #
-COMPILER_OPTIONS = -Wall -nostdlib -nostdinc -ffreestanding -fno-builtin -fno-inline \
+COMPILER_OPTIONS = -Wall -Werror -nostdlib -nostdinc -ffreestanding -fno-builtin -fno-inline \
                    -fno-zero-initialized-in-bss -O1 -MD
 # FreeLoader does not use any of the standard libraries, includes, or built-in functions
 
@@ -215,10 +215,15 @@
 			pccons.o	\
 			pcdisk.o	\
 			pcmem.o		\
+			pcrtc.o		\
+			pcvideo.o	\
+			xboxcons.o	\
 			xboxdisk.o	\
 			xboxfont.o	\
 			xboxmem.o	\
+			xboxrtc.o	\
 			xboxvideo.o	\
+			flashleds.o	\
 			_alloca.o		# For Mingw32 builds
 
 
@@ -265,11 +270,10 @@
 INFFILE_OBJS=	inffile.o
 
 VIDEO_OBJS	=	video.o		\
-				vidmode.o	\
-				fade.o		\
-				palette.o	\
-				pixel.o		\
-				bank.o
+			fade.o		\
+			palette.o	\
+			pixel.o		\
+			bank.o
 
 # libgcc2.o contains code (__udivdi3, __umoddi3) necessary to do
 # 64-bit division on the i386 (and other 32-bit) architectures

freeldr/freeldr
bootmgr.c 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- bootmgr.c	4 Nov 2004 13:44:18 -0000	1.9
+++ bootmgr.c	14 Nov 2004 22:04:38 -0000	1.10
@@ -35,6 +35,7 @@
 #include <drivemap.h>
 #include <keycodes.h>
 #include <cmdline.h>
+#include <machine.h>
 
 
 VOID RunLoader(VOID)
@@ -52,21 +53,21 @@
 	if (!IniFileInitialize())
 	{
 		printf("Press any key to reboot.\n");
-		getch();
+		MachConsGetCh();
 		return;
 	}
 
 	if (!IniOpenSection("FreeLoader", &SectionId))
 	{
 		printf("Section [FreeLoader] not found in freeldr.ini.\n");
-		getch();
+		MachConsGetCh();
 		return;
 	}
 
 	if (!UiInitialize())
 	{
 		printf("Press any key to reboot.\n");
-		getch();
+		MachConsGetCh();
 		return;
 	}
 

freeldr/freeldr
custom.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- custom.c	18 Jan 2003 10:21:23 -0000	1.1
+++ custom.c	14 Nov 2004 22:04:38 -0000	1.2
@@ -29,6 +29,7 @@
 #include <linux.h>
 #include <reactos.h>
 #include <drivemap.h>
+#include <machine.h>
 
 
 UCHAR	BootDrivePrompt[] = "Enter the boot drive.\n\nExamples:\nfd0 - first floppy drive\nhd0 - first hard drive\nhd1 - second hard drive\ncd0 - first CD-ROM drive.\n\nBIOS drive numbers may also be used:\n0 - first floppy drive\n0x80 - first hard drive\n0x81 - second hard drive";
@@ -78,7 +79,8 @@
 {
 	UCHAR	SectionName[100];
 	UCHAR	BootDriveString[20];
-	U32		SectionId;
+	U32	SectionId;
+	U32	Year, Month, Day, Hour, Minute, Second;
 
 	RtlZeroMemory(SectionName, sizeof(SectionName));
 	RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -89,7 +91,8 @@
 	}
 
 	// Generate a unique section name
-	sprintf(SectionName, "CustomBootDisk%d%d%d%d%d%d", getyear(), getday(), getmonth(), gethour(), getminute(), getsecond());
+	MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
+	sprintf(SectionName, "CustomBootDisk%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
 
 	// Add the section
 	if (!IniAddSection(SectionName, &SectionId))
@@ -119,7 +122,8 @@
 	UCHAR	SectionName[100];
 	UCHAR	BootDriveString[20];
 	UCHAR	BootPartitionString[20];
-	U32		SectionId;
+	U32	SectionId;
+	U32	Year, Month, Day, Hour, Minute, Second;
 
 	RtlZeroMemory(SectionName, sizeof(SectionName));
 	RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -136,7 +140,8 @@
 	}
 
 	// Generate a unique section name
-	sprintf(SectionName, "CustomBootPartition%d%d%d%d%d%d", getyear(), getday(), getmonth(), gethour(), getminute(), getsecond());
+	MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
+	sprintf(SectionName, "CustomBootPartition%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
 
 	// Add the section
 	if (!IniAddSection(SectionName, &SectionId))
@@ -173,7 +178,8 @@
 	UCHAR	BootDriveString[20];
 	UCHAR	BootPartitionString[20];
 	UCHAR	BootSectorFileString[200];
-	U32		SectionId;
+	U32	SectionId;
+	U32	Year, Month, Day, Hour, Minute, Second;
 
 	RtlZeroMemory(SectionName, sizeof(SectionName));
 	RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -196,7 +202,8 @@
 	}
 
 	// Generate a unique section name
-	sprintf(SectionName, "CustomBootSectorFile%d%d%d%d%d%d", getyear(), getday(), getmonth(), gethour(), getminute(), getsecond());
+	MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
+	sprintf(SectionName, "CustomBootSectorFile%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
 
 	// Add the section
 	if (!IniAddSection(SectionName, &SectionId))
@@ -241,7 +248,8 @@
 	UCHAR	ReactOSSystemPath[200];
 	UCHAR	ReactOSARCPath[200];
 	UCHAR	ReactOSOptions[200];
-	U32		SectionId;
+	U32	SectionId;
+	U32	Year, Month, Day, Hour, Minute, Second;
 
 	RtlZeroMemory(SectionName, sizeof(SectionName));
 	RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -270,7 +278,8 @@
 	}
 
 	// Generate a unique section name
-	sprintf(SectionName, "CustomReactOS%d%d%d%d%d%d", getyear(), getday(), getmonth(), gethour(), getminute(), getsecond());
+	MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
+	sprintf(SectionName, "CustomReactOS%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
 
 	// Add the section
 	if (!IniAddSection(SectionName, &SectionId))
@@ -312,7 +321,8 @@
 	UCHAR	LinuxKernelString[200];
 	UCHAR	LinuxInitrdString[200];
 	UCHAR	LinuxCommandLineString[200];
-	U32		SectionId;
+	U32	SectionId;
+	U32	Year, Month, Day, Hour, Minute, Second;
 
 	RtlZeroMemory(SectionName, sizeof(SectionName));
 	RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@@ -347,7 +357,8 @@
 	}
 
 	// Generate a unique section name
-	sprintf(SectionName, "CustomLinux%d%d%d%d%d%d", getyear(), getday(), getmonth(), gethour(), getminute(), getsecond());
+	MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
+	sprintf(SectionName, "CustomLinux%d%d%d%d%d%d", Year, Day, Month, Hour, Minute, Second);
 
 	// Add the section
 	if (!IniAddSection(SectionName, &SectionId))

freeldr/freeldr
debug.c 1.23 -> 1.24
diff -u -r1.23 -r1.24
--- debug.c	9 Nov 2004 23:36:19 -0000	1.23
+++ debug.c	14 Nov 2004 22:04:38 -0000	1.24
@@ -95,7 +95,7 @@
 	}
 	else
 	{
-		MachPutChar(Character);
+		MachConsPutChar(Character);
 	}
 }
 

freeldr/freeldr
freeldr.c 1.29 -> 1.30
diff -u -r1.29 -r1.30
--- freeldr.c	8 Nov 2004 22:02:47 -0000	1.29
+++ freeldr.c	14 Nov 2004 22:04:38 -0000	1.30
@@ -40,7 +40,7 @@
 	if (!MmInitializeMemoryManager())
 	{
 		printf("Press any key to reboot.\n");
-		getch();
+		MachConsGetCh();
 		return;
 	}
 

freeldr/freeldr
machine.c 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- machine.c	12 Nov 2004 17:17:07 -0000	1.4
+++ machine.c	14 Nov 2004 22:04:38 -0000	1.5
@@ -1,4 +1,4 @@
-/* $Id: machine.c,v 1.4 2004/11/12 17:17:07 gvg Exp $
+/* $Id: machine.c,v 1.5 2004/11/14 22:04:38 gvg Exp $
  *
  *  FreeLoader
  *
@@ -20,33 +20,118 @@
 #include "freeldr.h"
 #include "machine.h"
 
-#undef MachClearScreenAttr
-#undef MachPutChar
-#undef MachPutCharAttrAtLoc
+#undef MachConsPutChar
+#undef MachConsKbHit
+#undef MachConsGetCh
+#undef MachVideoClearScreen
+#undef MachVideoSetDisplayMode
+#undef MachVideoGetDisplaySize
+#undef MachVideoGetBufferSize
+#undef MachVideoSetTextCursorPosition
+#undef MachVideoHideShowTextCursor
+#undef MachVideoPutChar
+#undef MachVideoCopyOffScreenBufferToVRAM
+#undef MachVideoIsPaletteFixed
+#undef MachVideoSetPaletteColor
+#undef MachVideoGetPaletteColor
+#undef MachVideoSync
 #undef MachGetMemoryMap
 #undef MachDiskReadLogicalSectors
 #undef MachDiskGetPartitionEntry
 #undef MachDiskGetDriveGeometry
 #undef MachDiskGetCacheableBlockCount
+#undef MachRTCGetCurrentDateTime
 
 MACHVTBL MachVtbl;
 
-void 
-MachClearScreenAttr(U8 Attr)
+VOID
+MachConsPutChar(int Ch)
 {
-  MachVtbl.ClearScreenAttr(Attr);
+  MachVtbl.ConsPutChar(Ch);
 }
 
-void
-MachPutChar(int Ch)
+BOOL
+MachConsKbHit()
+{
+  return MachVtbl.ConsKbHit();
+}
+
+int
+MachConsGetCh()
+{
+  return MachVtbl.ConsGetCh();
+}
+
+VOID
+MachVideoClearScreen(U8 Attr)
+{
+  MachVtbl.VideoClearScreen(Attr);
+}
+
+VIDEODISPLAYMODE
+MachVideoSetDisplayMode(char *DisplayMode, BOOL Init)
+{
+  return MachVtbl.VideoSetDisplayMode(DisplayMode, Init);
+}
+
+VOID
+MachVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
+{
+  return MachVtbl.VideoGetDisplaySize(Width, Height, Depth);
+}
+
+U32
+MachVideoGetBufferSize(VOID)
+{
+  return MachVtbl.VideoGetBufferSize();
+}
+
+VOID
+MachVideoSetTextCursorPosition(U32 X, U32 Y)
+{
+  return MachVtbl.VideoSetTextCursorPosition(X, Y);
+}
+
+VOID
+MachVideoHideShowTextCursor(BOOL Show)
+{
+  MachVtbl.VideoHideShowTextCursor(Show);
+}
+
+VOID
+MachVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
 {
-  MachVtbl.PutChar(Ch);
+  MachVtbl.VideoPutChar(Ch, Attr, X, Y);
 }
 
-void
-MachPutCharAttrAtLoc(int Ch, U8 Attr, unsigned X, unsigned Y)
+VOID
+MachVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
 {
-  MachVtbl.PutCharAttrAtLoc(Ch, Attr, X, Y);
+  MachVtbl.VideoCopyOffScreenBufferToVRAM(Buffer);
+}
+
+BOOL
+MachVideoIsPaletteFixed(VOID)
+{
+  return MachVtbl.VideoIsPaletteFixed();
+}
+
+VOID
+MachVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
+{
+  return MachVtbl.VideoSetPaletteColor(Color, Red, Green, Blue);
+}
+
+VOID
+MachVideoGetPaletteColor(U8 Color, U8 *Red, U8 *Green, U8 *Blue)
+{
+  return MachVtbl.VideoGetPaletteColor(Color, Red, Green, Blue);
+}
+
+VOID
+MachVideoSync(VOID)
+{
+  return MachVtbl.VideoSync();
 }
 
 U32
@@ -79,4 +164,10 @@
   return MachVtbl.DiskGetCacheableBlockCount(DriveNumber);
 }
 
+VOID
+MachRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
+{
+  MachVtbl.RTCGetCurrentDateTime(Year, Month, Day, Hour, Minute, Second);
+}
+
 /* EOF */

freeldr/freeldr/arch/i386
pcrtc.c added at 1.1
diff -N pcrtc.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pcrtc.c	14 Nov 2004 22:04:38 -0000	1.1
@@ -0,0 +1,107 @@
+/* $Id: pcrtc.c,v 1.1 2004/11/14 22:04:38 gvg Exp $
+ *
+ *  FreeLoader
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "freeldr.h"
+#include "arch.h"
+#include "machine.h"
+#include "machpc.h"
+
+#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
+
+VOID
+PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
+{
+  REGS Regs;
+
+  if (NULL != Year || NULL != Month || NULL != Day)
+    {
+      /* Some BIOSes, such es the 1998/07/25 system ROM
+       * in the Compaq Deskpro EP/SB, leave CF unchanged
+       * if successful, so CF should be cleared before
+       * calling this function. */
+      __asm__ ("clc");
+
+      /* Int 1Ah AH=04h
+       * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
+       *
+       * AH = 04h
+       * CF clear to avoid bug
+       * Return:
+       * CF clear if successful
+       * CH = century (BCD)
+       * CL = year (BCD)
+       * DH = month (BCD)
+       * DL = day (BCD)
+       * CF set on error
+       */
+      Regs.b.ah = 0x04;
+      Int386(0x1A, &Regs, &Regs);
+
+      if (NULL != Year)
+        {
+          *Year = 100 * BCD_INT(Regs.b.cl) + BCD_INT(Regs.b.ch);
+        }
+      if (NULL != Month)
+        {
+          *Month = BCD_INT(Regs.b.dh);
+        }
+      if (NULL != Day)
+        {
+          *Day = BCD_INT(Regs.b.dl);
+        }
+    }
+
+  if (NULL != Hour || NULL != Minute || NULL != Second)
+    {
+      /* Some BIOSes leave CF unchanged if successful,
+       * so CF should be cleared before calling this function. */
+      __asm__ ("clc");
+
+      /* Int 1Ah AH=02h
+       * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
+       *
+       * AH = 02h
+       * CF clear to avoid bug
+       * Return:
+       * CF clear if successful
+       * CH = hour (BCD)
+       * CL = minutes (BCD)
+       * DH = seconds (BCD)
+       * DL = daylight savings flag (00h standard time, 01h daylight time)
+       * CF set on error (i.e. clock not running or in middle of update)
+       */
+      Regs.b.ah = 0x02;
+      Int386(0x1A, &Regs, &Regs);
+
+      if (NULL != Hour)
+        {
+          *Hour = BCD_INT(Regs.b.ch);
+        }
+      if (NULL != Minute)
+        {
+          *Minute = BCD_INT(Regs.b.cl);
+        }
+      if (NULL != Second)
+        {
+          *Second = BCD_INT(Regs.b.dh);
+        }
+    }
+}
+
+/* EOF */

freeldr/freeldr/arch/i386
pcvideo.c added at 1.1
diff -N pcvideo.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pcvideo.c	14 Nov 2004 22:04:38 -0000	1.1
@@ -0,0 +1,1109 @@
+/* $Id: pcvideo.c,v 1.1 2004/11/14 22:04:38 gvg Exp $
+ *
+ *  FreeLoader
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "freeldr.h"
+#include "machine.h"
+#include "arch.h"
+#include "debug.h"
+#include "machpc.h"
+#include "rtl.h"
+#include "portio.h"
+
+#define VIDEOPORT_PALETTE_READ		0x03C7
+#define VIDEOPORT_PALETTE_WRITE		0x03C8
+#define VIDEOPORT_PALETTE_DATA		0x03C9
+#define VIDEOPORT_VERTICAL_RETRACE	0x03DA
+
+#define VIDEOVGA_MEM_ADDRESS  0xA0000
+#define VIDEOTEXT_MEM_ADDRESS 0xB8000
+#define VIDEOTEXT_MEM_SIZE    0x8000
+
+#define	VIDEOCARD_CGA_OR_OTHER 0
+#define VIDEOCARD_EGA          1
+#define VIDEOCARD_VGA          2
+
+#define VIDEOMODE_NORMAL_TEXT   0
+#define VIDEOMODE_EXTENDED_TEXT 1
+#define	VIDEOMODE_80X28         0x501C
+#define	VIDEOMODE_80X30         0x501E
+#define	VIDEOMODE_80X34         0x5022
+#define	VIDEOMODE_80X43         0x502B
+#define	VIDEOMODE_80X60         0x503C
+#define	VIDEOMODE_132X25        0x8419
+#define	VIDEOMODE_132X43        0x842B
+#define	VIDEOMODE_132X50        0x8432
+#define	VIDEOMODE_132X60        0x843C
+
+#define VERTRES_200_SCANLINES		0x00
+#define VERTRES_350_SCANLINES		0x01
+#define VERTRES_400_SCANLINES		0x02
+
+typedef struct
+{
+  U16 ModeAttributes;             /* mode attributes (see #00080) */
+  U8  WindowAttributesA;          /* window attributes, window A (see #00081) */
+  U8  WindowsAttributesB;         /* window attributes, window B (see #00081) */
+  U16 WindowGranularity;          /* window granularity in KB */
+  U16 WindowSize;                 /* window size in KB */
+  U16 WindowAStartSegment;        /* start segment of window A (0000h if not supported) */
+  U16 WindowBStartSegment;        /* start segment of window B (0000h if not supported) */
+  U32 WindowPositioningFunction;  /* -> FAR window positioning function (equivalent to AX=4F05h) */
+  U16 BytesPerScanLine;           /* bytes per scan line */
+  /* ---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes--- */
+  U16 WidthInPixels;              /* width in pixels (graphics) or characters (text) */
+  U16 HeightInPixels;             /* height in pixels (graphics) or characters (text) */
+  U8  CharacterWidthInPixels;     /* width of character cell in pixels */
+  U8  CharacterHeightInPixels;    /* height of character cell in pixels */
+  U8  NumberOfMemoryPlanes;       /* number of memory planes */
+  U8  BitsPerPixel;               /* number of bits per pixel */
+  U8  NumberOfBanks;              /* number of banks */
+  U8  MemoryModel;                /* memory model type (see #00082) */
+  U8  BankSize;                   /* size of bank in KB */
+  U8  NumberOfImagePanes;         /* number of image pages (less one) that will fit in video RAM */
+  U8  Reserved1;                  /* reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0) */
+  /* ---VBE v1.2+ --- */
+  U8  RedMaskSize;                /* red mask size */
+  U8  RedMaskPosition;            /* red field position */
+  U8  GreenMaskSize;              /* green mask size */
+  U8  GreenMaskPosition;          /* green field size */
+  U8  BlueMaskSize;               /* blue mask size */
+  U8  BlueMaskPosition;           /* blue field size */
+  U8  ReservedMaskSize;           /* reserved mask size */
+  U8  ReservedMaskPosition;       /* reserved mask position */
+  U8  DirectColorModeInfo;        /* direct color mode info */
+                                  /* bit 0:Color ramp is programmable */
+                                  /* bit 1:Bytes in reserved field may be used by application */
+  /* ---VBE v2.0+ --- */
+  U32 LinearVideoBufferAddress;   /* physical address of linear video buffer */
+  U32 OffscreenMemoryPointer;     /* pointer to start of offscreen memory */
+  U16 OffscreenMemorySize;        /* KB of offscreen memory */
+  /* ---VBE v3.0 --- */
+  U16 LinearBytesPerScanLine;     /* bytes per scan line in linear modes */
+  U8  BankedNumberOfImages;       /* number of images (less one) for banked video modes */
+  U8  LinearNumberOfImages;       /* number of images (less one) for linear video modes */
+  U8  LinearRedMaskSize;          /* linear modes:Size of direct color red mask (in bits) */
+  U8  LinearRedMaskPosition;      /* linear modes:Bit position of red mask LSB (e.g. shift count) */
+  U8  LinearGreenMaskSize;        /* linear modes:Size of direct color green mask (in bits) */
+  U8  LinearGreenMaskPosition;    /* linear modes:Bit position of green mask LSB (e.g. shift count) */
+  U8  LinearBlueMaskSize;         /* linear modes:Size of direct color blue mask (in bits) */
+  U8  LinearBlueMaskPosition;     /* linear modes:Bit position of blue mask LSB (e.g. shift count) */
+  U8  LinearReservedMaskSize;     /* linear modes:Size of direct color reserved mask (in bits) */
+  U8  LinearReservedMaskPosition; /* linear modes:Bit position of reserved mask LSB */
+  U32 MaximumPixelClock;          /* maximum pixel clock for graphics video mode, in Hz */
+  U8  Reserved2[190];             /* 190 BYTEs  reserved (0) */
+} PACKED SVGA_MODE_INFORMATION, *PSVGA_MODE_INFORMATION;
+
+static U32 BiosVideoMode;                              /* Current video mode as known by BIOS */
+static U32 ScreenWidth = 80;	                       /* Screen Width in characters */
+static U32 ScreenHeight = 25;                          /* Screen Height in characters */
+static U32 BytesPerScanLine = 160;                     /* Number of bytes per scanline (delta) */
+static VIDEODISPLAYMODE DisplayMode = VideoTextMode;   /* Current display mode */
+static BOOL VesaVideoMode = FALSE;                     /* Are we using a VESA mode? */
+static SVGA_MODE_INFORMATION VesaVideoModeInformation; /* Only valid when in VESA mode */
+static U32 CurrentMemoryBank = 0;                      /* Currently selected VESA bank */
+
+static U32
+PcVideoDetectVideoCard(VOID)
+{
+  REGS Regs;
+
+  /* Int 10h AH=12h BL=10h
+   * VIDEO - ALTERNATE FUNCTION SELECT (PS,EGA,VGA,MCGA) - GET EGA INFO
+   *
+   * AH = 12h
+   * BL = 10h
+   * Return:
+   * BH = video state
+   * 00h color mode in effect (I/O port 3Dxh)
+   * 01h mono mode in effect (I/O port 3Bxh)
+   * BL = installed memory (00h = 64K, 01h = 128K, 02h = 192K, 03h = 256K)
+   * CH = feature connector bits
+   * CL = switch settings
+   * AH destroyed (at least by Tseng ET4000 BIOS v8.00n)
+   * 
+   * Installation check;EGA
+   */
+  Regs.b.ah = 0x12;
+  Regs.b.bl = 0x10;
+  Int386(0x10, &Regs, &Regs);
+
+  /* If BL is still equal to 0x10 then there is no EGA/VGA present */
+  if (0x10 == Regs.b.bl)
+    {
+      return VIDEOCARD_CGA_OR_OTHER;
+    }
+
+  /* Int 10h AX=1A00h
+   * VIDEO - GET DISPLAY COMBINATION CODE (PS,VGA/MCGA)
+   *
+   * AX = 1A00h
+   * Return:
+   * AL = 1Ah if function was supported
+   * BL = active display code
+   * BH = alternate display code
+   *
+   * This function is commonly used to check for the presence of a VGA.
+   *
+   * Installation check;VGA
+   * 
+   * Values for display combination code:
+   * 00h    no display
+   * 01h    monochrome adapter w/ monochrome display
+   * 02h    CGA w/ color display
+   * 03h    reserved
+   * 04h    EGA w/ color display
+   * 05h    EGA w/ monochrome display
+   * 06h    PGA w/ color display
+   * 07h    VGA w/ monochrome analog display
+   * 08h    VGA w/ color analog display
+   * 09h    reserved
+   * 0Ah    MCGA w/ digital color display
+   * 0Bh    MCGA w/ monochrome analog display
+   * 0Ch    MCGA w/ color analog display
+   * FFh    unknown display type
+   */
+  Regs.b.ah = 0x12;
+  Regs.b.bl = 0x10;
+  Int386(0x10, &Regs, &Regs);
+
+  if (0x1a == Regs.b.al)
+    {
+      return VIDEOCARD_VGA;
+    }
+  else
+    {
+      return VIDEOCARD_EGA;
+    }
+}
+
+static VOID PcVideoSetBiosMode(U32 VideoMode)
+{
+  REGS Regs;
+
+  /* Int 10h AH=00h
+   * VIDEO - SET VIDEO MODE
+   *
+   * AH = 00h
+   * AL = desired video mode
+   * Return:
+   * AL = video mode flag (Phoenix, AMI BIOS)
+   * 20h mode > 7
+   * 30h modes 0-5 and 7
+   * 3Fh mode 6
+   * AL = CRT controller mode byte (Phoenix 386 BIOS v1.10)
+   */
+  Regs.b.ah = 0x00;
+  Regs.b.al = VideoMode;
+  Int386(0x10, &Regs, &Regs);
+}
+
+static VOID
+PcVideoSetFont8x8(VOID)
+{
+  REGS Regs;
+
+  /* Int 10h AX=1112h
+   * VIDEO - TEXT-MODE CHARGEN - LOAD ROM 8x8 DBL-DOT PATTERNS (PS,EGA,VGA)
+   *
+   * AX = 1112h
+   * BL = block to load
+   * Return:
+   * Nothing
+   */
+  Regs.w.ax = 0x1112;
+  Regs.b.bl = 0x00;
+  Int386(0x10, &Regs, &Regs);
+}
+
+static VOID
+PcVideoSetFont8x14(VOID)
+{
+  REGS Regs;
+
+  /* Int 10h AX=1111h
+   * VIDEO - TEXT-MODE CHARGEN - LOAD ROM MONOCHROME PATTERNS (PS,EGA,VGA)
+   *
+   * AX = 1111h
+   * BL = block to load
+   * Return:
+   * Nothing
+   */
+  Regs.w.ax = 0x1111;
+  Regs.b.bl = 0;
+  Int386(0x10, &Regs, &Regs);
+}
+
+VOID PcVideoSelectAlternatePrintScreen(VOID)
+{
+  REGS Regs;
+
+  /* Int 10h AH=12h BL=20h
+   * VIDEO - ALTERNATE FUNCTION SELECT (PS,EGA,VGA,MCGA) - ALTERNATE PRTSC
+   *
+   * AH = 12h
+   * BL = 20h select alternate print screen routine
+   * Return:
+   * Nothing
+   *
+   * Installs a PrtSc routine from the video card's BIOS to replace the
+   * default PrtSc handler from the ROM BIOS, which usually does not
+   * understand screen heights other than 25 lines.
+   *
+   * Some adapters disable print-screen instead of enhancing it.
+   */
+  Regs.b.ah = 0x12;
+  Regs.b.bl = 0x20;
+  Int386(0x10, &Regs, &Regs);
+}
+
+VOID PcVideoDisableCursorEmulation(VOID)
+{
+  REGS Regs;
+
+  /* Int 10h AH=12h BL=34h
+   * VIDEO - ALTERNATE FUNCTION SELECT (VGA) - CURSOR EMULATION
+   *
+   * AH = 12h
+   * BL = 34h
+   * AL = new state
+   * 00h enable alphanumeric cursor emulation
+   * 01h disable alphanumeric cursor emulation
+   * Return:
+   * AL = 12h if function supported
+   *
+   * Specify whether the BIOS should automatically remap cursor start/end
+   * according to the current character height in text modes.
+   */
+  Regs.b.ah = 0x12;
+  Regs.b.bl = 0x34;
+  Regs.b.al = 0x01;
+  Int386(0x10, &Regs, &Regs);
+}
+
+static VOID
+PcVideoDefineCursor(U32 StartScanLine, U32 EndScanLine)
+{
+  REGS Regs;
+
+  /* Int 10h AH=01h
+   * VIDEO - SET TEXT-MODE CURSOR SHAPE
+   *
+   * AH = 01h
+   * CH = cursor start and options
+   * CL = bottom scan line containing cursor (bits 0-4)
+   * Return:
+   * Nothing
+   * 
+   * Specify the starting and ending scan lines to be occupied
+   * by the hardware cursor in text modes.
+   *
+   * AMI 386 BIOS and AST Premier 386 BIOS will lock up the
+   * system if AL is not equal to the current video mode.
+   * 
+   * Bitfields for cursor start and options:
+   * 
+   * Bit(s)    Description
+   * 7         should be zero
+   * 6,5       cursor blink
+   * (00=normal, 01=invisible, 10=erratic, 11=slow).
+   * (00=normal, other=invisible on EGA/VGA)
+   * 4-0       topmost scan line containing cursor
+   */
+  Regs.b.ah = 0x01;
+  Regs.b.al = 0x03;
+  Regs.b.ch = StartScanLine;
+  Regs.b.cl = EndScanLine;
+  Int386(0x10, &Regs, &Regs);
+}
+
+static VOID
+PcVideoSetVerticalResolution(U32 ScanLines)
+{
+  REGS Regs;
+
+  /* Int 10h AH=12h BL=30h
+   * VIDEO - ALTERNATE FUNCTION SELECT (VGA) - SELECT VERTICAL RESOLUTION
+   *
+   * AH = 12h
+   * BL = 30h
+   * AL = vertical resolution
+   * 00h 200 scan lines
+   * 01h 350 scan lines
+   * 02h 400 scan lines
+   * Return:
+   * AL = 12h if function supported
+   *
+   * Specifiy the number of scan lines used to display text modes.
+   *
+   * The specified resolution will take effect on the next mode set.
+   */
+  Regs.b.ah = 0x12;
+  Regs.b.bl = 0x30;
+  Regs.b.al = ScanLines;
+  Int386(0x10, &Regs, &Regs);
+}
+
+static VOID
+PcVideoSet480ScanLines(VOID)
+{
+  int CRTC;
+
+  /* Read CRTC port */
+  CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
+
+  if (CRTC & 1)
+    {
+      CRTC = 0x3D4;
+    }
+  else
+    {
+      CRTC = 0x3B4;
+    }
+
+  /* Vertical sync end (also unlocks CR0-7) */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x11);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0C);
+
+  /* Vertical total */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x06);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0B);
+
+  /* (vertical) overflow */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x07);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x3E);
+
+  /* Vertical sync start */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x10);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xEA);
+
+  /* Vertical display end */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x12);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
+
+  /* Vertical blank start */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x15);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xE7);
+
+  /* Vertical blank end */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x16);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x04);
+
+  /* Misc output register (read) */
+  CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
+
+  /* Preserve clock select bits and color bit */
+  CRTC = (CRTC & 0x0D);
+  /* Set correct sync polarity */
+  CRTC = (CRTC | 0xE2);
+
+  /* (write) */
+  WRITE_PORT_UCHAR((PUCHAR)0x03C2, CRTC);
+}
+
+static VOID
+PcVideoSetDisplayEnd(VOID)
+{
+  int	CRTC;
+
+  /* Read CRTC port */
+  CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
+
+  if (CRTC & 1)
+    {
+      CRTC = 0x3D4;
+    }
+  else
+    {
+      CRTC = 0x3B4;
+    }
+
+  /* Vertical display end */
+  WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x12);
+  WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
+}
+
+static BOOL
+PcVideoVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformation)
+{
+  REGS Regs;
+
+  RtlZeroMemory((PVOID)BIOSCALLBUFFER, 256);
+
+  /* VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION
+   * AX = 4F01h
+   * CX = SuperVGA video mode (see #04082 for bitfields)
+   * ES:DI -> 256-byte buffer for mode information (see #00079)
+   * Return:
+   * AL = 4Fh if function supported
+   * AH = status
+   * 00h successful
+   * ES:DI buffer filled
+   * 01h failed
+   *
+   * Desc: Determine the attributes of the specified video mode
+   *
+   * Note: While VBE 1.1 and higher will zero out all unused bytes
+   * of the buffer, v1.0 did not, so applications that want to be
+   * backward compatible should clear the buffer before calling 
+   */
+  Regs.w.ax = 0x4F01;
+  Regs.w.cx = Mode;
+  Regs.w.es = BIOSCALLBUFSEGMENT;
+  Regs.w.di = BIOSCALLBUFOFFSET;
+  Int386(0x10, &Regs, &Regs);
+
+  if (Regs.w.ax != 0x004F)
+    {
+      return FALSE;
+    }
+
+  RtlCopyMemory(ModeInformation, (PVOID)BIOSCALLBUFFER, sizeof(SVGA_MODE_INFORMATION));
+
+  DbgPrint((DPRINT_UI, "\n"));
+  DbgPrint((DPRINT_UI, "BiosVesaGetSVGAModeInformation() mode 0x%x\n", Mode));
+  DbgPrint((DPRINT_UI, "ModeAttributes = 0x%x\n", ModeInformation->ModeAttributes));
+  DbgPrint((DPRINT_UI, "WindowAttributesA = 0x%x\n", ModeInformation->WindowAttributesA));
+  DbgPrint((DPRINT_UI, "WindowAttributesB = 0x%x\n", ModeInformation->WindowsAttributesB));
+  DbgPrint((DPRINT_UI, "WindowGranularity = %dKB\n", ModeInformation->WindowGranularity));
+  DbgPrint((DPRINT_UI, "WindowSize = %dKB\n", ModeInformation->WindowSize));
+  DbgPrint((DPRINT_UI, "WindowAStartSegment = 0x%x\n", ModeInformation->WindowAStartSegment));
+  DbgPrint((DPRINT_UI, "WindowBStartSegment = 0x%x\n", ModeInformation->WindowBStartSegment));
+  DbgPrint((DPRINT_UI, "WindowPositioningFunction = 0x%x\n", ModeInformation->WindowPositioningFunction));
+  DbgPrint((DPRINT_UI, "BytesPerScanLine = %d\n", ModeInformation->BytesPerScanLine));
+  DbgPrint((DPRINT_UI, "WidthInPixels = %d\n", ModeInformation->WidthInPixels));
+  DbgPrint((DPRINT_UI, "HeightInPixels = %d\n", ModeInformation->HeightInPixels));
+  DbgPrint((DPRINT_UI, "CharacterWidthInPixels = %d\n", ModeInformation->CharacterWidthInPixels));
+  DbgPrint((DPRINT_UI, "CharacterHeightInPixels = %d\n", ModeInformation->CharacterHeightInPixels));
+  DbgPrint((DPRINT_UI, "NumberOfMemoryPlanes = %d\n", ModeInformation->NumberOfMemoryPlanes));
+  DbgPrint((DPRINT_UI, "BitsPerPixel = %d\n", ModeInformation->BitsPerPixel));
+  DbgPrint((DPRINT_UI, "NumberOfBanks = %d\n", ModeInformation->NumberOfBanks));
+  DbgPrint((DPRINT_UI, "MemoryModel = %d\n", ModeInformation->MemoryModel));
+  DbgPrint((DPRINT_UI, "BankSize = %d\n", ModeInformation->BankSize));
+  DbgPrint((DPRINT_UI, "NumberOfImagePlanes = %d\n", ModeInformation->NumberOfImagePanes));
+  DbgPrint((DPRINT_UI, "---VBE v1.2+ ---\n"));
+  DbgPrint((DPRINT_UI, "RedMaskSize = %d\n", ModeInformation->RedMaskSize));
+  DbgPrint((DPRINT_UI, "RedMaskPosition = %d\n", ModeInformation->RedMaskPosition));
+  DbgPrint((DPRINT_UI, "GreenMaskSize = %d\n", ModeInformation->GreenMaskSize));
+  DbgPrint((DPRINT_UI, "GreenMaskPosition = %d\n", ModeInformation->GreenMaskPosition));
+  DbgPrint((DPRINT_UI, "BlueMaskSize = %d\n", ModeInformation->BlueMaskSize));
+  DbgPrint((DPRINT_UI, "BlueMaskPosition = %d\n", ModeInformation->BlueMaskPosition));
+  DbgPrint((DPRINT_UI, "ReservedMaskSize = %d\n", ModeInformation->ReservedMaskSize));
+  DbgPrint((DPRINT_UI, "ReservedMaskPosition = %d\n", ModeInformation->ReservedMaskPosition));
+  DbgPrint((DPRINT_UI, "\n"));
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetBiosVesaMode(U16 Mode)
+{
+  REGS Regs;
+
+  /* Int 10h AX=4F02h
+   * VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE
+   *
+   * AX = 4F02h
+   * BX = new video mode
+   * ES:DI -> (VBE 3.0+) CRTC information block, bit mode bit 11 set
+   * Return:
+   * AL = 4Fh if function supported
+   * AH = status
+   * 00h successful
+   * 01h failed
+   *
+   * Values for VESA video mode:
+   * 00h-FFh OEM video modes (see #00010 at AH=00h)
+   * 100h   640x400x256
+   * 101h   640x480x256
+   * 102h   800x600x16
+   * 103h   800x600x256
+   * 104h   1024x768x16
+   * 105h   1024x768x256
+   * 106h   1280x1024x16
+   * 107h   1280x1024x256
+   * 108h   80x60 text
+   * 109h   132x25 text
+   * 10Ah   132x43 text
+   * 10Bh   132x50 text
+   * 10Ch   132x60 text
+   * ---VBE v1.2+ ---
+   * 10Dh   320x200x32K
+   * 10Eh   320x200x64K
+   * 10Fh   320x200x16M
+   * 110h   640x480x32K
+   * 111h   640x480x64K
+   * 112h   640x480x16M
+   * 113h   800x600x32K
+   * 114h   800x600x64K
+   * 115h   800x600x16M
+   * 116h   1024x768x32K
+   * 117h   1024x768x64K
+   * 118h   1024x768x16M
+   * 119h   1280x1024x32K (1:5:5:5)
+   * 11Ah   1280x1024x64K (5:6:5)
+   * 11Bh   1280x1024x16M
+   * ---VBE 2.0+ ---
+   * 120h   1600x1200x256
+   * 121h   1600x1200x32K
+   * 122h   1600x1200x64K
+   * 81FFh   special full-memory access mode
+   * 
+   * Notes: The special mode 81FFh preserves the contents of the video memory and gives
+   * access to all of the memory; VESA recommends that the special mode be a packed-pixel
+   * mode. For VBE 2.0+, it is required that the VBE implement the mode, but not place it
+   * in the list of available modes (mode information for this mode can be queried
+   * directly, however).. As of VBE 2.0, VESA will no longer define video mode numbers
+   */
+  Regs.w.ax = 0x4F02;
+  Regs.w.bx = Mode;
+  Int386(0x10, &Regs, &Regs);
+
+  if (0x004F != Regs.w.ax)
+    {
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode80x25(VOID)
+{
+  PcVideoSetBiosMode(0x03);
+  ScreenWidth = 80;
+  ScreenHeight = 25;
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode80x50_80x43(VOID)
+{
+  if (VIDEOCARD_VGA == PcVideoDetectVideoCard())
+    {
+      PcVideoSetBiosMode(0x03);
+      PcVideoSetFont8x8();
+      PcVideoSelectAlternatePrintScreen();
+      PcVideoDisableCursorEmulation();
+      PcVideoDefineCursor(6, 7);
+      ScreenWidth = 80;
+      ScreenHeight = 50;
+    }
+  else if (VIDEOCARD_EGA == PcVideoDetectVideoCard())
+    {
+      PcVideoSetBiosMode(0x03);
+      PcVideoSetFont8x8();
+      PcVideoSelectAlternatePrintScreen();
+      PcVideoDisableCursorEmulation();
+      PcVideoDefineCursor(6, 7);
+      ScreenWidth = 80;
+      ScreenHeight = 43;
+    }
+  else /* VIDEOCARD_CGA_OR_OTHER */
+    {
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode80x28(VOID)
+{
+  /* FIXME: Is this VGA-only? */
+  PcVideoSetMode80x25();
+  PcVideoSetFont8x14();
+  PcVideoDefineCursor(11, 12);
+  ScreenWidth = 80;
+  ScreenHeight = 28;
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode80x30(VOID)
+{
+  /* FIXME: Is this VGA-only? */
+  PcVideoSetMode80x25();
+  PcVideoSet480ScanLines();
+  ScreenWidth = 80;
+  ScreenHeight = 30;
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode80x34(VOID)
+{
+  /* FIXME: Is this VGA-only? */
+  PcVideoSetMode80x25();
+  PcVideoSet480ScanLines();
+  PcVideoSetFont8x14();
+  PcVideoDefineCursor(11, 12);
+  PcVideoSetDisplayEnd();
+  ScreenWidth = 80;
+  ScreenHeight = 34;
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode80x43(VOID)
+{
+  /* FIXME: Is this VGA-only? */
+  PcVideoSetVerticalResolution(VERTRES_350_SCANLINES);
+  PcVideoSetMode80x25();
+  PcVideoSetFont8x8();
+  PcVideoSelectAlternatePrintScreen();
+  PcVideoDisableCursorEmulation();
+  PcVideoDefineCursor(6, 7);
+  ScreenWidth = 80;
+  ScreenHeight = 43;
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode80x60(VOID)
+{
+  /* FIXME: Is this VGA-only? */
+  PcVideoSetMode80x25();
+  PcVideoSet480ScanLines();
+  PcVideoSetFont8x8();
+  PcVideoSelectAlternatePrintScreen();
+  PcVideoDisableCursorEmulation();
+  PcVideoDefineCursor(6, 7);
+  PcVideoSetDisplayEnd();
+  ScreenWidth = 80;
+  ScreenHeight = 60;
+
+  return TRUE;
+}
+
+static BOOL
+PcVideoSetMode(U32 NewMode)
+{
+  CurrentMemoryBank = 0;
+
+  /* Set the values for the default text modes
+   * If they are setting a graphics mode then
+   * these values will be changed.
+   */
+  BiosVideoMode = NewMode;
+  ScreenWidth = 80;
+  ScreenHeight = 25;
+  BytesPerScanLine = 160;
+  DisplayMode = VideoTextMode;
+  VesaVideoMode = FALSE;
+
+  switch (NewMode)
+    {
+      case VIDEOMODE_NORMAL_TEXT:
+      case 0x03: /* BIOS 80x25 text mode number */
+        return PcVideoSetMode80x25();
+      case VIDEOMODE_EXTENDED_TEXT:
+        return PcVideoSetMode80x50_80x43();
+      case VIDEOMODE_80X28:
+        return PcVideoSetMode80x28();
+      case VIDEOMODE_80X30:
+        return PcVideoSetMode80x30();
+      case VIDEOMODE_80X34:
+        return PcVideoSetMode80x34();
+      case VIDEOMODE_80X43:
+        return PcVideoSetMode80x43();
+      case VIDEOMODE_80X60:
+        return PcVideoSetMode80x60();
+   }
+
+  if (0x12 == NewMode)
+    {
+      /* 640x480x16 */
+      PcVideoSetBiosMode(NewMode);
+      WRITE_PORT_USHORT((U16*)0x03CE, 0x0F01); /* For some reason this is necessary? */
+      ScreenWidth = 640;
+      ScreenHeight = 480;
+      BytesPerScanLine = 80;
+      BiosVideoMode = NewMode;
+      DisplayMode = VideoGraphicsMode;
+
+      return TRUE;
+    }
+  else if (0x13 == NewMode)
+    {
+      /* 320x200x256 */
+      PcVideoSetBiosMode(NewMode);
+      ScreenWidth = 320;
+      ScreenHeight = 200;
+      BytesPerScanLine = 320;
+      BiosVideoMode = NewMode;
+      DisplayMode = VideoGraphicsMode;
+
+      return TRUE;
+    }
+  else if (0x0108 <= NewMode && NewMode <= 0x010C)
+    {
+      /* VESA Text Mode */
+      if (! PcVideoVesaGetSVGAModeInformation(NewMode, &VesaVideoModeInformation))
+        {
+          return FALSE;
+        }
+
+      if (! PcVideoSetBiosVesaMode(NewMode))
+        {
+          return FALSE;
+        }
+
+      ScreenWidth = VesaVideoModeInformation.WidthInPixels;
+      ScreenHeight = VesaVideoModeInformation.HeightInPixels;
+      BytesPerScanLine = VesaVideoModeInformation.BytesPerScanLine;
+      BiosVideoMode = NewMode;
+      DisplayMode = VideoTextMode;
+      VesaVideoMode = TRUE;
+
+      return TRUE;
+    }
+  else
+    {
+      /* VESA Graphics Mode */
+      if (! PcVideoVesaGetSVGAModeInformation(NewMode, &VesaVideoModeInformation))
+        {
+          return FALSE;
+        }
+
+      if (! PcVideoSetBiosVesaMode(NewMode))
+        {
+          return FALSE;
+        }
+
+      ScreenWidth = VesaVideoModeInformation.WidthInPixels;
+      ScreenHeight = VesaVideoModeInformation.HeightInPixels;
+      BytesPerScanLine = VesaVideoModeInformation.BytesPerScanLine;
+      BiosVideoMode = NewMode;
+      DisplayMode = VideoTextMode;
+      VesaVideoMode = TRUE;
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+static VOID
+PcVideoSetBlinkBit(BOOL Enable)
+{
+  REGS Regs;
+
+  /* Int 10h AX=1003h
+   * VIDEO - TOGGLE INTENSITY/BLINKING BIT (Jr, PS, TANDY 1000, EGA, VGA)
+   *
+   * AX = 1003h
+   * BL = new state
+   * 00h background intensity enabled
+   * 01h blink enabled
+   * BH = 00h to avoid problems on some adapters
+   * Return:
+   * Nothing
+   *
+   * Note: although there is no function to get
+   * the current status, bit 5 of 0040h:0065h
+   * indicates the state.
+   */
+  Regs.w.ax = 0x1003;
+  Regs.w.bx = Enable ? 0x0001 : 0x0000;
+  Int386(0x10, &Regs, &Regs);
+}
+
+static VOID
+PcVideoSetMemoryBank(U16 BankNumber)
+{
+  REGS Regs;
+
+  if (CurrentMemoryBank != BankNumber)
+    {
+      /* Int 10h AX=4F05h
+       * VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL
+       *
+       * AX = 4F05h
+       * BH = subfunction
+       * 00h select video memory window
+       * 01h get video memory window
+       * DX = window address in video memory (in granularity units)
+       * Return:
+       * DX = window address in video memory (in gran. units)
+       * BL = window number
+       * 00h window A
+       * 01h window B.
+       * Return:
+       * AL = 4Fh if function supported
+       * AH = status
+       * 00h successful
+       * 01h failed
+       */
+      Regs.w.ax = 0x4F05;
+      Regs.w.bx = 0x0000;
+      Regs.w.dx = BankNumber;
+      Int386(0x10, &Regs, &Regs);
+
+      if (0x004F == Regs.w.ax)
+        {
+          CurrentMemoryBank = BankNumber;
+	}
+    }
+}
+
+VIDEODISPLAYMODE
+PcVideoSetDisplayMode(char *DisplayModeName, BOOL Init)
+{
+  U32 VideoMode = VIDEOMODE_NORMAL_TEXT;
+
+  if (NULL == DisplayModeName || '\0' == *DisplayModeName)
+    {
+      PcVideoSetBlinkBit(! Init);
+      return DisplayMode;
+    }
+
+  if (VIDEOCARD_CGA_OR_OTHER == PcVideoDetectVideoCard())
+    {
+      DbgPrint((DPRINT_UI, "CGA or other display adapter detected.\n"));
+      printf("CGA or other display adapter detected.\n");
+      printf("Using 80x25 text mode.\n");
+      VideoMode = VIDEOMODE_NORMAL_TEXT;
+    }
+  else if (VIDEOCARD_EGA == PcVideoDetectVideoCard())
+    {
+      DbgPrint((DPRINT_UI, "EGA display adapter detected.\n"));
+      printf("EGA display adapter detected.\n");
+      printf("Using 80x25 text mode.\n");
+      VideoMode = VIDEOMODE_NORMAL_TEXT;
+    }
+  else /* if (VIDEOCARD_VGA == PcVideoDetectVideoCard()) */
+    {
+      DbgPrint((DPRINT_UI, "VGA display adapter detected.\n"));
+
+      if (0 == stricmp(DisplayModeName, "NORMAL_VGA"))
+        {
+          VideoMode = VIDEOMODE_NORMAL_TEXT;
+        }
+      else if (0 == stricmp(DisplayModeName, "EXTENDED_VGA"))
+        {
+          VideoMode = VIDEOMODE_EXTENDED_TEXT;
+        }
+      else
+        {
+          VideoMode = atoi(DisplayModeName);
+        }
+    }
+
+  if (! PcVideoSetMode(VideoMode))
+    {
+      printf("Error: unable to set video display mode 0x%x\n", (int) VideoMode);
+      printf("Defaulting to 80x25 text mode.\n");
+      printf("Press any key to continue.\n");
+      PcConsGetCh();
+
+      PcVideoSetMode(VIDEOMODE_NORMAL_TEXT);
+    }
+
+  PcVideoSetBlinkBit(! Init);
+
+
+  return DisplayMode;
+}
+
+VOID
+PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
+{
+  *Width = ScreenWidth;
+  *Height = ScreenHeight;
+  if (VideoGraphicsMode == DisplayMode && VesaVideoMode)
+    {
+      if (16 == VesaVideoModeInformation.BitsPerPixel)
+        {
+          /* 16-bit color modes give green an extra bit (5:6:5)
+           * 15-bit color modes have just 5:5:5 for R:G:B */
+          *Depth = (6 == VesaVideoModeInformation.GreenMaskSize ? 16 : 15);
+        }
+      else
+        {
+          *Depth = VesaVideoModeInformation.BitsPerPixel;
+        }
+    }
+  else
+    {
+      *Depth = 0;
+    }
+}
+
+U32
+PcVideoGetBufferSize(VOID)
+{
+  return ScreenHeight * BytesPerScanLine;
+}
+
+VOID
+PcVideoSetTextCursorPosition(U32 X, U32 Y)
+{
+  REGS Regs;
+
+  /* Int 10h AH=02h
+   * VIDEO - SET CURSOR POSITION
+   *
+   * AH = 02h
+   * BH = page number
+   * 0-3 in modes 2&3
+   * 0-7 in modes 0&1
+   * 0 in graphics modes
+   * DH = row (00h is top)
+   * DL = column (00h is left)
+   * Return:
+   * Nothing
+   */
+  Regs.b.ah = 0x02;
+  Regs.b.bh = 0x00;
+  Regs.b.dh = Y;
+  Regs.b.dl = X;
+  Int386(0x10, &Regs, &Regs);
+}
+
+VOID
+PcVideoHideShowTextCursor(BOOL Show)
+{
+  if (Show)
+    {
+      PcVideoDefineCursor(0x0D, 0x0E);
+    }
+  else
+    {
+      PcVideoDefineCursor(0x20, 0x00);
+    }
+}
+
[truncated at 1000 lines; 113 more skipped]

freeldr/freeldr/arch/i386
xboxcons.c added at 1.1
diff -N xboxcons.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ xboxcons.c	14 Nov 2004 22:04:38 -0000	1.1
@@ -0,0 +1,78 @@
+/* $Id: xboxcons.c,v 1.1 2004/11/14 22:04:38 gvg Exp $
+ *
+ *  FreeLoader
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "freeldr.h"
+#include "machine.h"
+#include "machxbox.h"
+
+static unsigned CurrentCursorX = 0;
+static unsigned CurrentCursorY = 0;
+static unsigned CurrentAttr = 0x0f;
+
+VOID
+XboxConsPutChar(int c)
+{
+  U32 Width;
+  U32 Height;
+  U32 Depth;
+
+  if ('\r' == c)
+    {
+      CurrentCursorX = 0;
+    }
+  else if ('\n' == c)
+    {
+      CurrentCursorX = 0;
+      CurrentCursorY++;
+    }
+  else if ('\t' == c)
+    {
+      CurrentCursorX = (CurrentCursorX + 8) & ~ 7;
+    }
+  else
+    {
+      XboxVideoPutChar(c, CurrentAttr, CurrentCursorX, CurrentCursorY);
+      CurrentCursorX++;
+    }
+  XboxVideoGetDisplaySize(&Width, &Height, &Depth);
+  if (Width <= CurrentCursorX)
+    {
+      CurrentCursorX = 0;
+      CurrentCursorY++;
+    }
+}
+
+BOOL
+XboxConsKbHit(VOID)
+{
+  /* No keyboard support yet */
+  return FALSE;
+}
+
+int
+XboxConsGetCh(void)
+{
+  /* No keyboard support yet */
+  while (1)
+    {
+      ;
+    }
+}
+
+/* EOF */

freeldr/freeldr/arch/i386
xboxrtc.c added at 1.1
diff -N xboxrtc.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ xboxrtc.c	14 Nov 2004 22:04:38 -0000	1.1
@@ -0,0 +1,85 @@
+/* $Id: xboxrtc.c,v 1.1 2004/11/14 22:04:38 gvg Exp $
+ *
+ *  FreeLoader
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "freeldr.h"
+#include "machine.h"
+#include "machxbox.h"
+#include "portio.h"
+
+#define RTC_REGISTER_A   0x0A
+#define   RTC_REG_A_UIP  0x80  /* Update In Progress bit */
+
+#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
+
+static UCHAR
+HalpQueryCMOS(UCHAR Reg)
+{
+  UCHAR Val;
+  Reg |= 0x80;
+
+  WRITE_PORT_UCHAR((PUCHAR)0x70, Reg);
+  Val = READ_PORT_UCHAR((PUCHAR)0x71);
+  WRITE_PORT_UCHAR((PUCHAR)0x70, 0);
+
+  return(Val);
+}
+
+VOID
+XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second)
+{
+  while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
+    {
+      ;
+    }
+
+  if (NULL != Second)
+    {
+      *Second = BCD_INT(HalpQueryCMOS(0));
+    }
+  if (NULL != Minute)
+    {
+      *Minute = BCD_INT(HalpQueryCMOS(2));
+    }
+  if (NULL != Hour)
+    {
+      *Hour = BCD_INT(HalpQueryCMOS(4));
+    }
+  if (NULL != Day)
+    {
+      *Day = BCD_INT(HalpQueryCMOS(7));
+    }
+  if (NULL != Month)
+    {
+      *Month = BCD_INT(HalpQueryCMOS(8));
+    }
+  if (NULL != Year)
+    {
+      *Year = BCD_INT(HalpQueryCMOS(9));
+      if (*Year > 80)
+        {
+          *Year += 1900;
+        }
+      else
+        {
+          *Year += 2000;
+        }
+    }
+}
+
+/* EOF */

freeldr/freeldr/arch/i386
i386rtl.c 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- i386rtl.c	8 Nov 2004 22:02:47 -0000	1.3
+++ i386rtl.c	14 Nov 2004 22:04:38 -0000	1.4
@@ -22,273 +22,6 @@
 #include <rtl.h>
 #include <portio.h>
 
-int kbhit(void)
-{
-	REGS	Regs;
-
-	// Int 16h AH=01h
-	// KEYBOARD - CHECK FOR KEYSTROKE
-	//
-	// AH = 01h
-	// Return:
-	// ZF set if no keystroke available
-	// ZF clear if keystroke available
-	// AH = BIOS scan code
-	// AL = ASCII character
-	Regs.b.ah = 0x01;
-	Int386(0x16, &Regs, &Regs);
-
-	if (Regs.x.eflags & I386FLAG_ZF)
-	{
-		return 0;
-	}
-
-	return 1;
-}
-
-int getch(void)
-{
-	REGS	Regs;
-	static BOOL		ExtendedKey = FALSE;
-	static char		ExtendedScanCode = 0;
-
-	// If the last time we were called an
-	// extended key was pressed then return
-	// that keys scan code.
-	if (ExtendedKey)
-	{
-		ExtendedKey = FALSE;
-		return ExtendedScanCode;
-	}
-
-	// Int 16h AH=00h
-	// KEYBOARD - GET KEYSTROKE
-	//
-	// AH = 00h
-	// Return:
-	// AH = BIOS scan code
-	// AL = ASCII character
-	Regs.b.ah = 0x00;
-	Int386(0x16, &Regs, &Regs);
-
-	// Check for an extended keystroke
-	if (Regs.b.al == 0)
-	{
-		ExtendedKey = TRUE;
-		ExtendedScanCode = Regs.b.ah;
-	}
-
-	// Return keystroke
-	return Regs.b.al;
-}
-
-int getyear(void)
-{
-	REGS	Regs;
-	U16		Digit1;
-	U16		Digit2;
-	U16		Cent1;
-	U16		Cent2;
-	U16		Year;
-
-	// Some BIOSes, such es the 1998/07/25 system ROM
-	// in the Compaq Deskpro EP/SB, leave CF unchanged
-	// if successful, so CF should be cleared before
-	// calling this function.
-	__asm__ ("clc");
-
-	// Int 1Ah AH=04h
-	// TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
-	//
-	// AH = 04h
-	// CF clear to avoid bug
-	// Return:
-	// CF clear if successful
-	// CH = century (BCD)
-	// CL = year (BCD)
-	// DH = month (BCD)
-	// DL = day (BCD)
-	// CF set on error
-	Regs.b.ah = 0x04;
-	Int386(0x1A, &Regs, &Regs);
-
-	/* Convert from BCD to normal */
-	Digit1 = Regs.b.cl & 0x0F;
-	Digit2 = ((Regs.b.cl >> 4) & 0x0F) * 10;
-	Cent1 = Regs.b.ch & 0x0F;
-	Cent2 = ((Regs.b.ch >> 4) & 0x0F) * 10;
-
-	Year = Cent1 + Cent2;
-	Year *= 100;
-	Year += Digit1 + Digit2;
-
-	return Year;
-}
-
-int getday(void)
-{
-	REGS	Regs;
-	U16		Digit1;
-	U16		Digit2;
-
-	// Some BIOSes, such es the 1998/07/25 system ROM
-	// in the Compaq Deskpro EP/SB, leave CF unchanged
-	// if successful, so CF should be cleared before
-	// calling this function.
-	__asm__ ("clc");
-
-	// Int 1Ah AH=04h
-	// TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
-	//
-	// AH = 04h
-	// CF clear to avoid bug
-	// Return:
-	// CF clear if successful
-	// CH = century (BCD)
-	// CL = year (BCD)
-	// DH = month (BCD)
-	// DL = day (BCD)
-	// CF set on error
-	Regs.b.ah = 0x04;
-	Int386(0x1A, &Regs, &Regs);
-
-	/* Convert from BCD to normal */
-	Digit1 = Regs.b.dl & 0x0F;
-	Digit2 = ((Regs.b.dl >> 4) & 0x0F) * 10;
-
-	return (Digit1 + Digit2);
-}
-
-int getmonth(void)
-{
-	REGS	Regs;
-	U16		Digit1;
-	U16		Digit2;
-
-	// Some BIOSes, such es the 1998/07/25 system ROM
-	// in the Compaq Deskpro EP/SB, leave CF unchanged
-	// if successful, so CF should be cleared before
-	// calling this function.
-	__asm__ ("clc");
-
-	// Int 1Ah AH=04h
-	// TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
-	//
-	// AH = 04h
-	// CF clear to avoid bug
-	// Return:
-	// CF clear if successful
-	// CH = century (BCD)
-	// CL = year (BCD)
-	// DH = month (BCD)
-	// DL = day (BCD)
-	// CF set on error
-	Regs.b.ah = 0x04;
-	Int386(0x1A, &Regs, &Regs);
-
-	/* Convert from BCD to normal */
-	Digit1 = Regs.b.dh & 0x0F;
-	Digit2 = ((Regs.b.dh >> 4) & 0x0F) * 10;
-
-	return (Digit1 + Digit2);
-}
-
-int gethour(void)
-{
-	REGS	Regs;
-	U16		Digit1;
-	U16		Digit2;
-
-	// Some BIOSes leave CF unchanged if successful,
-	// so CF should be cleared before calling this function.
-	__asm__ ("clc");
-
-	// Int 1Ah AH=02h
-	// TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
-	//
-	// AH = 02h
-	// CF clear to avoid bug
-	// Return:
-	// CF clear if successful
-	// CH = hour (BCD)
-	// CL = minutes (BCD)
-	// DH = seconds (BCD)
-	// DL = daylight savings flag (00h standard time, 01h daylight time)
-	// CF set on error (i.e. clock not running or in middle of update)
-	Regs.b.ah = 0x02;
-	Int386(0x1A, &Regs, &Regs);
-
-	/* Convert from BCD to normal */
-	Digit1 = Regs.b.ch & 0x0F;
-	Digit2 = ((Regs.b.ch >> 4) & 0x0F) * 10;
-
-	return (Digit1 + Digit2);
-}
-
-int getminute(void)
-{
-	REGS	Regs;
-	U16		Digit1;
-	U16		Digit2;
-
-	// Some BIOSes leave CF unchanged if successful,
-	// so CF should be cleared before calling this function.
-	__asm__ ("clc");
-
-	// Int 1Ah AH=02h
-	// TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
-	//
-	// AH = 02h
-	// CF clear to avoid bug
-	// Return:
-	// CF clear if successful
-	// CH = hour (BCD)
-	// CL = minutes (BCD)
-	// DH = seconds (BCD)
-	// DL = daylight savings flag (00h standard time, 01h daylight time)
-	// CF set on error (i.e. clock not running or in middle of update)
-	Regs.b.ah = 0x02;
-	Int386(0x1A, &Regs, &Regs);
-
-	/* Convert from BCD to normal */
-	Digit1 = Regs.b.cl & 0x0F;
-	Digit2 = ((Regs.b.cl >> 4) & 0x0F) * 10;
-
-	return (Digit1 + Digit2);
-}
-
-int getsecond(void)
-{
-	REGS	Regs;
-	U16		Digit1;
-	U16		Digit2;
-
-	// Some BIOSes leave CF unchanged if successful,
-	// so CF should be cleared before calling this function.
-	__asm__ ("clc");
-
-	// Int 1Ah AH=02h
-	// TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
-	//
-	// AH = 02h
-	// CF clear to avoid bug
-	// Return:
-	// CF clear if successful
-	// CH = hour (BCD)
-	// CL = minutes (BCD)
-	// DH = seconds (BCD)
-	// DL = daylight savings flag (00h standard time, 01h daylight time)
-	// CF set on error (i.e. clock not running or in middle of update)
-	Regs.b.ah = 0x02;
-	Int386(0x1A, &Regs, &Regs);
-
-	/* Convert from BCD to normal */
-	Digit1 = Regs.b.dh & 0x0F;
-	Digit2 = ((Regs.b.dh >> 4) & 0x0F) * 10;
-
-	return (Digit1 + Digit2);
-}
-
 void beep(void)
 {
 	sound(700);

freeldr/freeldr/arch/i386
i386trap.S 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- i386trap.S	8 Nov 2004 22:02:47 -0000	1.6
+++ i386trap.S	14 Nov 2004 22:04:38 -0000	1.7
@@ -273,7 +273,7 @@
 	SAVE_CPU_REGS
 
 	pushl	$SCREEN_ATTR
-	call	_MachClearScreenAttr
+	call	_MachVideoClearScreen
 	add	$4,%esp
 
 	movl	$i386ExceptionHandlerText,%esi
@@ -485,7 +485,7 @@
 	pushl	$SCREEN_ATTR
 	andl	$0xff,%eax
 	pushl	%eax
-	call	_MachPutCharAttrAtLoc
+	call	_MachVideoPutChar
 	addl	$16,%esp
 
 	ret

freeldr/freeldr/arch/i386
i386vid.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- i386vid.c	19 Jan 2003 01:03:58 -0000	1.2
+++ i386vid.c	14 Nov 2004 22:04:38 -0000	1.3
@@ -90,59 +90,6 @@
 // only AX=4F00h; this case may be assumed if the list of supported video modes
 // is empty (consisting of a single word of FFFFh) 
 
-
-VOID BiosSetVideoMode(U32 VideoMode)
-{
-	REGS	Regs;
-
-	// Int 10h AH=00h
-	// VIDEO - SET VIDEO MODE
-	//
-	// AH = 00h
-	// AL = desired video mode
-	// Return:
-	// AL = video mode flag (Phoenix, AMI BIOS)
-	// 20h mode > 7
-	// 30h modes 0-5 and 7
-	// 3Fh mode 6
-	// AL = CRT controller mode byte (Phoenix 386 BIOS v1.10)
-	Regs.b.ah = 0x00;
-	Regs.b.al = VideoMode;
-	Int386(0x10, &Regs, &Regs);
-}
-
-VOID BiosSetVideoFont8x8(VOID)
-{
-	REGS	Regs;
-
-	// Int 10h AX=1112h
-	// VIDEO - TEXT-MODE CHARGEN - LOAD ROM 8x8 DBL-DOT PATTERNS (PS,EGA,VGA)
-	//
-	// AX = 1112h
-	// BL = block to load
-	// Return:
-	// Nothing
-	Regs.w.ax = 0x1112;
-	Regs.b.bl = 0x00;
-	Int386(0x10, &Regs, &Regs);
-}
-
-VOID BiosSetVideoFont8x14(VOID)
-{
-	REGS	Regs;
-
-	// Int 10h AX=1111h
-	// VIDEO - TEXT-MODE CHARGEN - LOAD ROM MONOCHROME PATTERNS (PS,EGA,VGA)
-	//
-	// AX = 1111h
-	// BL = block to load
-	// Return:
-	// Nothing
-	Regs.w.ax = 0x1111;
-	Regs.b.bl = 0;
-	Int386(0x10, &Regs, &Regs);
-}
-
 VOID BiosSetVideoFont8x16(VOID)
 {
 	REGS	Regs;
@@ -159,289 +106,8 @@
 	Int386(0x10, &Regs, &Regs);
 }
 
-VOID BiosSelectAlternatePrintScreen(VOID)
-{
-	REGS	Regs;
-
-	// Int 10h AH=12h BL=20h
-	// VIDEO - ALTERNATE FUNCTION SELECT (PS,EGA,VGA,MCGA) - ALTERNATE PRTSC
-	//
-	// AH = 12h
-	// BL = 20h select alternate print screen routine
-	// Return:
-	// Nothing
-	//
-	// Installs a PrtSc routine from the video card's BIOS to replace the
-	// default PrtSc handler from the ROM BIOS, which usually does not
-	// understand screen heights other than 25 lines.
-	//
-	// Some adapters disable print-screen instead of enhancing it.
-	Regs.b.ah = 0x12;
-	Regs.b.bl = 0x20;
-	Int386(0x10, &Regs, &Regs);
-}
-
-VOID BiosDisableCursorEmulation(VOID)
-{
-	REGS	Regs;
-
-	// Int 10h AH=12h BL=34h
-	// VIDEO - ALTERNATE FUNCTION SELECT (VGA) - CURSOR EMULATION
-	//
-	// AH = 12h
-	// BL = 34h
-	// AL = new state
-	// 00h enable alphanumeric cursor emulation
-	// 01h disable alphanumeric cursor emulation
-	// Return:
-	// AL = 12h if function supported
-	//
-	// Specify whether the BIOS should automatically remap cursor start/end
-	// according to the current character height in text modes.
-	Regs.b.ah = 0x12;
-	Regs.b.bl = 0x34;
-	Regs.b.al = 0x01;
-	Int386(0x10, &Regs, &Regs);
-}
-
-VOID BiosDefineCursor(U32 StartScanLine, U32 EndScanLine)
-{
-	REGS	Regs;
-
-	// Int 10h AH=01h
-	// VIDEO - SET TEXT-MODE CURSOR SHAPE
-	//
-	// AH = 01h
-	// CH = cursor start and options
-	// CL = bottom scan line containing cursor (bits 0-4)
-	// Return:
-	// Nothing
-	//
-	// Specify the starting and ending scan lines to be occupied
-	// by the hardware cursor in text modes.
-	//
-	// AMI 386 BIOS and AST Premier 386 BIOS will lock up the
-	// system if AL is not equal to the current video mode.
-	//
-	// Bitfields for cursor start and options:
-	//
-	// Bit(s)    Description
-	// 7         should be zero
-	// 6,5       cursor blink
-	// (00=normal, 01=invisible, 10=erratic, 11=slow).
-	// (00=normal, other=invisible on EGA/VGA)
-	// 4-0       topmost scan line containing cursor
-	Regs.b.ah = 0x01;
-	Regs.b.al = 0x03;
-	Regs.b.ch = StartScanLine;
-	Regs.b.cl = EndScanLine;
-	Int386(0x10, &Regs, &Regs);
-}
-
-U32 BiosDetectVideoCard(VOID)
-{
-	REGS	Regs;
-
-	// Int 10h AH=12h BL=10h
-	// VIDEO - ALTERNATE FUNCTION SELECT (PS,EGA,VGA,MCGA) - GET EGA INFO
-	//
-	// AH = 12h
-	// BL = 10h
-	// Return:
-	// BH = video state
-	// 00h color mode in effect (I/O port 3Dxh)
-	// 01h mono mode in effect (I/O port 3Bxh)
-	// BL = installed memory (00h = 64K, 01h = 128K, 02h = 192K, 03h = 256K)
-	// CH = feature connector bits
-	// CL = switch settings
-	// AH destroyed (at least by Tseng ET4000 BIOS v8.00n)
-	//
-	// Installation check;EGA
-	Regs.b.ah = 0x12;
-	Regs.b.bl = 0x10;
-	Int386(0x10, &Regs, &Regs);
-
-	// If BL is still equal to 0x10 then there is no EGA/VGA present
-	if (Regs.b.bl == 0x10)
-	{
-		return VIDEOCARD_CGA_OR_OTHER;
-	}
-
-	// Int 10h AX=1A00h
-	// VIDEO - GET DISPLAY COMBINATION CODE (PS,VGA/MCGA)
-	//
-	// AX = 1A00h
-	// Return:
-	// AL = 1Ah if function was supported
-	// BL = active display code
-	// BH = alternate display code
-	//
-	// This function is commonly used to check for the presence of a VGA.
-	//
-	// Installation check;VGA
-	//
-	// Values for display combination code:
-	// 00h    no display
-	// 01h    monochrome adapter w/ monochrome display
-	// 02h    CGA w/ color display
-	// 03h    reserved
-	// 04h    EGA w/ color display
-	// 05h    EGA w/ monochrome display
-	// 06h    PGA w/ color display
-	// 07h    VGA w/ monochrome analog display
-	// 08h    VGA w/ color analog display
-	// 09h    reserved
-	// 0Ah    MCGA w/ digital color display
-	// 0Bh    MCGA w/ monochrome analog display
-	// 0Ch    MCGA w/ color analog display
-	// FFh    unknown display type
-	Regs.b.ah = 0x12;
-	Regs.b.bl = 0x10;
-	Int386(0x10, &Regs, &Regs);
-
-	if (Regs.b.al == 0x1A)
-	{
-		return VIDEOCARD_VGA;
-	}
-	else
-	{
-		return VIDEOCARD_EGA;
-	}
-}
-
-VOID BiosSetVerticalResolution(U32 ScanLines)
-{
-	REGS	Regs;
-
-	// Int 10h AH=12h BL=30h
-	// VIDEO - ALTERNATE FUNCTION SELECT (VGA) - SELECT VERTICAL RESOLUTION
-	//
-	// AH = 12h
-	// BL = 30h
-	// AL = vertical resolution
-	// 00h 200 scan lines
-	// 01h 350 scan lines
-	// 02h 400 scan lines
-	// Return:
-	// AL = 12h if function supported
-	//
-	// Specifiy the number of scan lines used to display text modes.
-	//
-	// The specified resolution will take effect on the next mode set.
-	Regs.b.ah = 0x12;
-	Regs.b.bl = 0x30;
-	Regs.b.al = ScanLines;
-	Int386(0x10, &Regs, &Regs);
-}
-
-VOID BiosSet480ScanLines(VOID)
-{
-	int	CRTC;
-
-	// Read CRTC port
-	CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
-
-	if (CRTC & 1)
-	{
-		CRTC = 0x3D4;
-	}
-	else
-	{
-		CRTC = 0x3B4;
-	}
-
-	// Vertical sync end (also unlocks CR0-7)
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x11);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0C);
-
-	// Vertical total
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x06);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x0B);
-
-	// (vertical) overflow
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x07);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x3E);
-
-	// Vertical sync start
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x10);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xEA);
-
-	// Vertical display end
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x12);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
-
-	// Vertical blank start
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x15);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xE7);
-
-	// Vertical blank end
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x16);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0x04);
-
-	// Misc output register (read)
-	CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
-
-	// Preserve clock select bits and color bit
-	CRTC = (CRTC & 0x0D);
-	// Set correct sync polarity
-	CRTC = (CRTC | 0xE2);
-
-	// (write)
-	WRITE_PORT_UCHAR((PUCHAR)0x03C2, CRTC);
-}
-
-VOID BiosSetVideoDisplayEnd(VOID)
-{
-	int	CRTC;
-
-	// Read CRTC port
-	CRTC = READ_PORT_UCHAR((PUCHAR)0x03CC);
-
-	if (CRTC & 1)
-	{
-		CRTC = 0x3D4;
-	}
-	else
-	{
-		CRTC = 0x3B4;
-	}
-
-	// Vertical display end
-	WRITE_PORT_UCHAR((PUCHAR)CRTC, 0x12);
-	WRITE_PORT_UCHAR((PUCHAR)CRTC+1, 0xDF);
-}
-
 VOID VideoSetTextCursorPosition(U32 X, U32 Y)
 {
-	REGS	Regs;
-
-	// Int 10h AH=02h
-	// VIDEO - SET CURSOR POSITION
-	//
-	// AH = 02h
-	// BH = page number
-	// 0-3 in modes 2&3
-	// 0-7 in modes 0&1
-	// 0 in graphics modes
-	// DH = row (00h is top)
-	// DL = column (00h is left)
-	// Return:
-	// Nothing
-	Regs.b.ah = 0x02;
-	Regs.b.bh = 0x00;
-	Regs.b.dh = Y;
-	Regs.b.dl = X;
-	Int386(0x10, &Regs, &Regs);
-}
-
-VOID VideoHideTextCursor(VOID)
-{
-	BiosDefineCursor(0x20, 0x00);
-}
-
-VOID VideoShowTextCursor(VOID)
-{
-	BiosDefineCursor(0x0D, 0x0E);
 }
 
 U32 VideoGetTextCursorPositionX(VOID)
@@ -494,52 +160,6 @@
 	return Regs.b.dh;
 }
 
-VOID BiosVideoDisableBlinkBit(VOID)
-{
-	REGS	Regs;
-
-	// Int 10h AX=1003h
-	// VIDEO - TOGGLE INTENSITY/BLINKING BIT (Jr, PS, TANDY 1000, EGA, VGA)
-	//
-	// AX = 1003h
-	// BL = new state
-	// 00h background intensity enabled
-	// 01h blink enabled
-	// BH = 00h to avoid problems on some adapters
-	// Return:
-	// Nothing
-	//
-	// Note: although there is no function to get
-	// the current status, bit 5 of 0040h:0065h
-	// indicates the state.
-	Regs.w.ax = 0x1003;
-	Regs.w.bx = 0x0000;
-	Int386(0x10, &Regs, &Regs);
-}
-
-VOID BiosVideoEnableBlinkBit(VOID)
-{
-	REGS	Regs;
-
-	// Int 10h AX=1003h
-	// VIDEO - TOGGLE INTENSITY/BLINKING BIT (Jr, PS, TANDY 1000, EGA, VGA)
-	//
-	// AX = 1003h
-	// BL = new state
-	// 00h background intensity enabled
-	// 01h blink enabled
-	// BH = 00h to avoid problems on some adapters
-	// Return:
-	// Nothing
-	//
-	// Note: although there is no function to get
-	// the current status, bit 5 of 0040h:0065h
-	// indicates the state.
-	Regs.w.ax = 0x1003;
-	Regs.w.bx = 0x0001;
-	Int386(0x10, &Regs, &Regs);
-}
-
 U16 BiosIsVesaSupported(VOID)
 {
 	REGS			Regs;
@@ -629,179 +249,3 @@
 
 	return SvgaInfo->VesaVersion;
 }
-
-BOOL BiosVesaSetBank(U16 Bank)
-{
-	REGS	Regs;
-
-	// Int 10h AX=4F05h
-	// VESA SuperVGA BIOS - CPU VIDEO MEMORY CONTROL
-	//
-	// AX = 4F05h
-	// BH = subfunction
-	//   00h select video memory window
-	//   01h get video memory window
-	// DX = window address in video memory (in granularity units)
-	// Return:
-	// DX = window address in video memory (in gran. units)
-	// BL = window number
-	//   00h window A
-	//   01h window B.
-	// Return:
-	// AL = 4Fh if function supported
-	// AH = status
-	//   00h successful
-	//   01h failed
-
-	Regs.w.ax = 0x4F05;
-	Regs.w.bx = 0x0000;
-	Regs.w.dx = Bank;
-	Int386(0x10, &Regs, &Regs);
-
-	if (Regs.w.ax != 0x004F)
-	{
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL BiosVesaSetVideoMode(U16 Mode)
-{
-	REGS	Regs;
-
-	// Int 10h AX=4F02h
-	// VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE
-	//
-	// AX = 4F02h
-	// BX = new video mode
-	// ES:DI -> (VBE 3.0+) CRTC information block, bit mode bit 11 set
-	// Return:
-	// AL = 4Fh if function supported
-	// AH = status
-	//   00h successful
-	//   01h failed
-	//
-	// Values for VESA video mode:
-	// 00h-FFh OEM video modes (see #00010 at AH=00h)
-	// 100h   640x400x256
-	// 101h   640x480x256
-	// 102h   800x600x16
-	// 103h   800x600x256
-	// 104h   1024x768x16
-	// 105h   1024x768x256
-	// 106h   1280x1024x16
-	// 107h   1280x1024x256
-	// 108h   80x60 text
-	// 109h   132x25 text
-	// 10Ah   132x43 text
-	// 10Bh   132x50 text
-	// 10Ch   132x60 text
-	// ---VBE v1.2+ ---
-	// 10Dh   320x200x32K
-	// 10Eh   320x200x64K
-	// 10Fh   320x200x16M
-	// 110h   640x480x32K
-	// 111h   640x480x64K
-	// 112h   640x480x16M
-	// 113h   800x600x32K
-	// 114h   800x600x64K
-	// 115h   800x600x16M
-	// 116h   1024x768x32K
-	// 117h   1024x768x64K
-	// 118h   1024x768x16M
-	// 119h   1280x1024x32K (1:5:5:5)
-	// 11Ah   1280x1024x64K (5:6:5)
-	// 11Bh   1280x1024x16M
-	// ---VBE 2.0+ ---
-	// 120h   1600x1200x256
-	// 121h   1600x1200x32K
-	// 122h   1600x1200x64K
-	// 81FFh   special full-memory access mode
-
-	// Notes: The special mode 81FFh preserves the contents of the video memory and gives
-	// access to all of the memory; VESA recommends that the special mode be a packed-pixel
-	// mode. For VBE 2.0+, it is required that the VBE implement the mode, but not place it
-	// in the list of available modes (mode information for this mode can be queried
-	// directly, however).. As of VBE 2.0, VESA will no longer define video mode numbers 
-	Regs.w.ax = 0x4F02;
-	Regs.w.bx = Mode;
-	Int386(0x10, &Regs, &Regs);
-
-	if (Regs.w.ax != 0x004F)
-	{
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL BiosVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformation)
-{
-	REGS	Regs;
-
-	RtlZeroMemory((PVOID)BIOSCALLBUFFER, 256);
-
-	// VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION
-	// AX = 4F01h
-	// CX = SuperVGA video mode (see #04082 for bitfields)
-	// ES:DI -> 256-byte buffer for mode information (see #00079)
-	// Return:
-	// AL = 4Fh if function supported
-	// AH = status
-	// 00h successful
-	// ES:DI buffer filled
-	// 01h failed
-	//
-	// Desc: Determine the attributes of the specified video mode
-	//
-	// Note: While VBE 1.1 and higher will zero out all unused bytes
-	// of the buffer, v1.0 did not, so applications that want to be
-	// backward compatible should clear the buffer before calling 
-	Regs.w.ax = 0x4F01;
-	Regs.w.cx = Mode;
-	Regs.w.es = BIOSCALLBUFSEGMENT;
-	Regs.w.di = BIOSCALLBUFOFFSET;
-	Int386(0x10, &Regs, &Regs);
-
-	if (Regs.w.ax != 0x004F)
-	{
-		return FALSE;
-	}
-
-	RtlCopyMemory(ModeInformation, (PVOID)BIOSCALLBUFFER, sizeof(SVGA_MODE_INFORMATION));
-
-	DbgPrint((DPRINT_UI, "\n"));
-	DbgPrint((DPRINT_UI, "BiosVesaGetSVGAModeInformation() mode 0x%x\n", Mode));
-	DbgPrint((DPRINT_UI, "ModeAttributes = 0x%x\n", ModeInformation->ModeAttributes));
-	DbgPrint((DPRINT_UI, "WindowAttributesA = 0x%x\n", ModeInformation->WindowAttributesA));
-	DbgPrint((DPRINT_UI, "WindowAttributesB = 0x%x\n", ModeInformation->WindowsAttributesB));
-	DbgPrint((DPRINT_UI, "WindowGranularity = %dKB\n", ModeInformation->WindowGranularity));
-	DbgPrint((DPRINT_UI, "WindowSize = %dKB\n", ModeInformation->WindowSize));
-	DbgPrint((DPRINT_UI, "WindowAStartSegment = 0x%x\n", ModeInformation->WindowAStartSegment));
-	DbgPrint((DPRINT_UI, "WindowBStartSegment = 0x%x\n", ModeInformation->WindowBStartSegment));
-	DbgPrint((DPRINT_UI, "WindowPositioningFunction = 0x%x\n", ModeInformation->WindowPositioningFunction));
-	DbgPrint((DPRINT_UI, "BytesPerScanLine = %d\n", ModeInformation->BytesPerScanLine));
-	DbgPrint((DPRINT_UI, "WidthInPixels = %d\n", ModeInformation->WidthInPixels));
-	DbgPrint((DPRINT_UI, "HeightInPixels = %d\n", ModeInformation->HeightInPixels));
-	DbgPrint((DPRINT_UI, "CharacterWidthInPixels = %d\n", ModeInformation->CharacterWidthInPixels));
-	DbgPrint((DPRINT_UI, "CharacterHeightInPixels = %d\n", ModeInformation->CharacterHeightInPixels));
-	DbgPrint((DPRINT_UI, "NumberOfMemoryPlanes = %d\n", ModeInformation->NumberOfMemoryPlanes));
-	DbgPrint((DPRINT_UI, "BitsPerPixel = %d\n", ModeInformation->BitsPerPixel));
-	DbgPrint((DPRINT_UI, "NumberOfBanks = %d\n", ModeInformation->NumberOfBanks));
-	DbgPrint((DPRINT_UI, "MemoryModel = %d\n", ModeInformation->MemoryModel));
-	DbgPrint((DPRINT_UI, "BankSize = %d\n", ModeInformation->BankSize));
-	DbgPrint((DPRINT_UI, "NumberOfImagePlanes = %d\n", ModeInformation->NumberOfImagePanes));
-	DbgPrint((DPRINT_UI, "---VBE v1.2+ ---\n"));
-	DbgPrint((DPRINT_UI, "RedMaskSize = %d\n", ModeInformation->RedMaskSize));
-	DbgPrint((DPRINT_UI, "RedMaskPosition = %d\n", ModeInformation->RedMaskPosition));
-	DbgPrint((DPRINT_UI, "GreenMaskSize = %d\n", ModeInformation->GreenMaskSize));
-	DbgPrint((DPRINT_UI, "GreenMaskPosition = %d\n", ModeInformation->GreenMaskPosition));
-	DbgPrint((DPRINT_UI, "BlueMaskSize = %d\n", ModeInformation->BlueMaskSize));
-	DbgPrint((DPRINT_UI, "BlueMaskPosition = %d\n", ModeInformation->BlueMaskPosition));
-	DbgPrint((DPRINT_UI, "ReservedMaskSize = %d\n", ModeInformation->ReservedMaskSize));
-	DbgPrint((DPRINT_UI, "ReservedMaskPosition = %d\n", ModeInformation->ReservedMaskPosition));
-	DbgPrint((DPRINT_UI, "\n"));
-
-	return TRUE;
-}

freeldr/freeldr/arch/i386
machpc.c 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- machpc.c	12 Nov 2004 17:17:07 -0000	1.4
+++ machpc.c	14 Nov 2004 22:04:38 -0000	1.5
@@ -1,4 +1,4 @@
-/* $Id: machpc.c,v 1.4 2004/11/12 17:17:07 gvg Exp $
+/* $Id: machpc.c,v 1.5 2004/11/14 22:04:38 gvg Exp $
  *
  *  FreeLoader
  *
@@ -30,14 +30,28 @@
   EnableA20();
 
   /* Setup vtbl */
-  MachVtbl.ClearScreenAttr = PcConsClearScreenAttr;
-  MachVtbl.PutChar = PcConsPutChar;
-  MachVtbl.PutCharAttrAtLoc = PcConsPutCharAttrAtLoc;
+  MachVtbl.ConsPutChar = PcConsPutChar;
+  MachVtbl.ConsKbHit = PcConsKbHit;
+  MachVtbl.ConsGetCh = PcConsGetCh;
+  MachVtbl.VideoClearScreen = PcVideoClearScreen;
+  MachVtbl.VideoSetDisplayMode = PcVideoSetDisplayMode;
+  MachVtbl.VideoGetDisplaySize = PcVideoGetDisplaySize;
+  MachVtbl.VideoGetBufferSize = PcVideoGetBufferSize;
+  MachVtbl.VideoSetTextCursorPosition = PcVideoSetTextCursorPosition;
+  MachVtbl.VideoSetTextCursorPosition = PcVideoSetTextCursorPosition;
+  MachVtbl.VideoHideShowTextCursor = PcVideoHideShowTextCursor;
+  MachVtbl.VideoPutChar = PcVideoPutChar;
+  MachVtbl.VideoCopyOffScreenBufferToVRAM = PcVideoCopyOffScreenBufferToVRAM;
+  MachVtbl.VideoIsPaletteFixed = PcVideoIsPaletteFixed;
+  MachVtbl.VideoSetPaletteColor = PcVideoSetPaletteColor;
+  MachVtbl.VideoGetPaletteColor = PcVideoGetPaletteColor;
+  MachVtbl.VideoSync = PcVideoSync;
   MachVtbl.GetMemoryMap = PcMemGetMemoryMap;
   MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;
   MachVtbl.DiskGetPartitionEntry = PcDiskGetPartitionEntry;
   MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
   MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
+  MachVtbl.RTCGetCurrentDateTime = PcRTCGetCurrentDateTime;
 }
 
 /* EOF */

freeldr/freeldr/arch/i386
machpc.h 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- machpc.h	12 Nov 2004 17:17:07 -0000	1.4
+++ machpc.h	14 Nov 2004 22:04:38 -0000	1.5
@@ -1,4 +1,4 @@
-/* $Id: machpc.h,v 1.4 2004/11/12 17:17:07 gvg Exp $
+/* $Id: machpc.h,v 1.5 2004/11/14 22:04:38 gvg Exp $
  *
  *  FreeLoader
  *
@@ -28,9 +28,22 @@
 
 VOID PcMachInit(VOID);
 
-VOID PcConsClearScreenAttr(U8 Attr);
 VOID PcConsPutChar(int Ch);
-VOID PcConsPutCharAttrAtLoc(int Ch, U8 Attr, unsigned X, unsigned Y);
+BOOL PcConsKbHit();
+int PcConsGetCh();
+
+VOID PcVideoClearScreen(U8 Attr);
+VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayMode, BOOL Init);
+VOID PcVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
+U32 PcVideoGetBufferSize(VOID);
+VOID PcVideoSetTextCursorPosition(U32 X, U32 Y);
+VOID PcVideoHideShowTextCursor(BOOL Show);
+VOID PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
+VOID PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
+BOOL PcVideoIsPaletteFixed(VOID);
+VOID PcVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
+VOID PcVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
+VOID PcVideoSync(VOID);
 
 U32 PcMemGetMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
 
@@ -39,6 +52,8 @@
 BOOL PcDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
 U32 PcDiskGetCacheableBlockCount(U32 DriveNumber);
 
+VOID PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
+
 #endif /* __I386_MACHPC_H_ */
 
 /* EOF */

freeldr/freeldr/arch/i386
machxbox.c 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- machxbox.c	12 Nov 2004 17:17:07 -0000	1.4
+++ machxbox.c	14 Nov 2004 22:04:38 -0000	1.5
@@ -1,4 +1,4 @@
-/* $Id: machxbox.c,v 1.4 2004/11/12 17:17:07 gvg Exp $
+/* $Id: machxbox.c,v 1.5 2004/11/14 22:04:38 gvg Exp $
  *
  *  FreeLoader
  *
@@ -30,12 +30,24 @@
   XboxVideoInit();
 
   /* Setup vtbl */
-  MachVtbl.ClearScreenAttr = XboxVideoClearScreenAttr;
-  MachVtbl.PutChar = XboxVideoPutChar;
-  MachVtbl.PutCharAttrAtLoc = XboxVideoPutCharAttrAtLoc;
+  MachVtbl.ConsPutChar = XboxConsPutChar;
+  MachVtbl.ConsKbHit = XboxConsKbHit;
+  MachVtbl.ConsGetCh = XboxConsGetCh;
+  MachVtbl.VideoClearScreen = XboxVideoClearScreen;
+  MachVtbl.VideoSetDisplayMode = XboxVideoSetDisplayMode;
+  MachVtbl.VideoGetDisplaySize = XboxVideoGetDisplaySize;
+  MachVtbl.VideoGetBufferSize = XboxVideoGetBufferSize;
+  MachVtbl.VideoHideShowTextCursor = XboxVideoHideShowTextCursor;
+  MachVtbl.VideoPutChar = XboxVideoPutChar;
+  MachVtbl.VideoCopyOffScreenBufferToVRAM = XboxVideoCopyOffScreenBufferToVRAM;
+  MachVtbl.VideoIsPaletteFixed = XboxVideoIsPaletteFixed;
+  MachVtbl.VideoSetPaletteColor = XboxVideoSetPaletteColor;
+  MachVtbl.VideoGetPaletteColor = XboxVideoGetPaletteColor;
+  MachVtbl.VideoSync = XboxVideoSync;
   MachVtbl.GetMemoryMap = XboxMemGetMemoryMap;
   MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;
   MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
   MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
   MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount;
+  MachVtbl.RTCGetCurrentDateTime = XboxRTCGetCurrentDateTime;
 }

freeldr/freeldr/arch/i386
machxbox.h 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- machxbox.h	12 Nov 2004 17:17:07 -0000	1.4
+++ machxbox.h	14 Nov 2004 22:04:38 -0000	1.5
@@ -1,4 +1,4 @@
-/* $Id: machxbox.h,v 1.4 2004/11/12 17:17:07 gvg Exp $
+/* $Id: machxbox.h,v 1.5 2004/11/14 22:04:38 gvg Exp $
  *
  *  FreeLoader
  *
@@ -28,10 +28,23 @@
 
 VOID XboxMachInit(VOID);
 
+VOID XboxConsPutChar(int Ch);
+BOOL XboxConsKbHit();
+int XboxConsGetCh();
+
 VOID XboxVideoInit(VOID);
-VOID XboxVideoClearScreenAttr(U8 Attr);
-VOID XboxVideoPutChar(int Ch);
-VOID XboxVideoPutCharAttrAtLoc(int Ch, U8 Attr, unsigned X, unsigned Y);
+VOID XboxVideoClearScreen(U8 Attr);
+VIDEODISPLAYMODE XboxVideoSetDisplayMode(char *DisplayModem, BOOL Init);
+VOID XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth);
+U32 XboxVideoGetBufferSize(VOID);
+VOID XboxVideoSetTextCursorPosition(U32 X, U32 Y);
+VOID XboxVideoHideShowTextCursor(BOOL Show);
+VOID XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y);
+VOID XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer);
+BOOL XboxVideoIsPaletteFixed(VOID);
+VOID XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
+VOID XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
+VOID XboxVideoSync(VOID);
 
 VOID XboxMemInit(VOID);
 PVOID XboxMemReserveMemory(U32 MbToReserve);
@@ -42,6 +55,7 @@
 BOOL XboxDiskGetDriveGeometry(U32 DriveNumber, PGEOMETRY DriveGeometry);
 U32 XboxDiskGetCacheableBlockCount(U32 DriveNumber);
 
+VOID XboxRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
 #endif /* __I386_HWXBOX_H_ */
 
 /* EOF */

freeldr/freeldr/arch/i386
pccons.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- pccons.c	10 Nov 2004 23:45:37 -0000	1.2
+++ pccons.c	14 Nov 2004 22:04:38 -0000	1.3
@@ -1,4 +1,4 @@
-/* $Id: pccons.c,v 1.2 2004/11/10 23:45:37 gvg Exp $
+/* $Id: pccons.c,v 1.3 2004/11/14 22:04:38 gvg Exp $
  *
  *  FreeLoader
  *
@@ -31,21 +31,6 @@
 #define TEXT_LINES 25
 
 VOID
-PcConsClearScreenAttr(U8 Attr)
-{
-  U16 AttrChar;
-  U16 *BufPtr;
-
-  AttrChar = ((U16) Attr << 8) | ' ';
-  for (BufPtr = (U16 *) TEXTMODE_BUFFER;
-       BufPtr < (U16 *) (TEXTMODE_BUFFER + TEXTMODE_BUFFER_SIZE);
-       BufPtr++)
-    {
-      *BufPtr = AttrChar;
-    }
-}
-
-VOID
 PcConsPutChar(int Ch)
 {
   REGS Regs;
@@ -86,13 +71,63 @@
   Int386(0x10, &Regs, &Regs);
 }
 
-VOID
-PcConsPutCharAttrAtLoc(int Ch, U8 Attr, unsigned X, unsigned Y)
+BOOL
+PcConsKbHit(VOID)
+{
+  REGS Regs;
+
+  /* Int 16h AH=01h
+   * KEYBOARD - CHECK FOR KEYSTROKE
+   *
+   * AH = 01h
+   * Return:
+   * ZF set if no keystroke available
+   * ZF clear if keystroke available
+   * AH = BIOS scan code
+   * AL = ASCII character
+   */
+  Regs.b.ah = 0x01;
+  Int386(0x16, &Regs, &Regs);
+
+  return 0 == (Regs.x.eflags & I386FLAG_ZF);
+}
+
+int
+PcConsGetCh(void)
 {
-  U16 *BufPtr;
+  REGS Regs;
+  static BOOL ExtendedKey = FALSE;
+  static char ExtendedScanCode = 0;
+
+  /* If the last time we were called an
+   * extended key was pressed then return
+   * that keys scan code. */
+  if (ExtendedKey)
+    {
+      ExtendedKey = FALSE;
+      return ExtendedScanCode;
+    }
+
+  /* Int 16h AH=00h
+   * KEYBOARD - GET KEYSTROKE
+   *
+   * AH = 00h
+   * Return:
+   * AH = BIOS scan code
+   * AL = ASCII character
+   */
+  Regs.b.ah = 0x00;
+  Int386(0x16, &Regs, &Regs);
+
+  /* Check for an extended keystroke */
+  if (0 == Regs.b.al)
+    {
+      ExtendedKey = TRUE;
+      ExtendedScanCode = Regs.b.ah;
+    }
 
-  BufPtr = (U16 *) (TEXTMODE_BUFFER + (Y * TEXT_COLS + X) * 2);
-  *BufPtr = ((U16) Attr << 8) | (Ch & 0xff);
+  /* Return keystroke */
+  return Regs.b.al;
 }
 
 /* EOF */

freeldr/freeldr/arch/i386
xboxvideo.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- xboxvideo.c	10 Nov 2004 23:45:37 -0000	1.2
+++ xboxvideo.c	14 Nov 2004 22:04:38 -0000	1.3
@@ -1,4 +1,4 @@
-/* $Id: xboxvideo.c,v 1.2 2004/11/10 23:45:37 gvg Exp $
+/* $Id: xboxvideo.c,v 1.3 2004/11/14 22:04:38 gvg Exp $
  *
  *  FreeLoader
  *
@@ -32,11 +32,6 @@
 static U32 BytesPerPixel;
 static U32 Delta;
 
-static unsigned CurrentCursorX;
-static unsigned CurrentCursorY;
-static unsigned CurrentFgColor;
-static unsigned CurrentBgColor;
-
 #define CHAR_WIDTH  8
 #define CHAR_HEIGHT 16
 
@@ -91,7 +86,7 @@
 }
 
 static VOID
-XboxVideoClearScreen(U32 Color, BOOL FullScreen)
+XboxVideoClearScreenColor(U32 Color, BOOL FullScreen)
 {
   U32 Line, Col;
   PU32 p;
@@ -107,45 +102,17 @@
 }
 
 VOID
-XboxVideoClearScreenAttr(U8 Attr)
+XboxVideoClearScreen(U8 Attr)
 {
   U32 FgColor, BgColor;
 
   XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
 
-  XboxVideoClearScreen(BgColor, FALSE);
-}
-
-VOID
-XboxVideoPutChar(int c)
-{
-  if ('\r' == c)
-    {
-      CurrentCursorX = 0;
-    }
-  else if ('\n' == c)
-    {
-      CurrentCursorX = 0;
-      CurrentCursorY++;
-    }
-  else if ('\t' == c)
-    {
-      CurrentCursorX = (CurrentCursorX + 8) & ~ 7;
-    }
-  else
-    {
-      XboxVideoOutputChar(c, CurrentCursorX, CurrentCursorY, CurrentFgColor, CurrentBgColor);
-      CurrentCursorX++;
-    }
-  if (ScreenWidth / CHAR_WIDTH <= CurrentCursorX)
-    {
-      CurrentCursorX = 0;
-      CurrentCursorY++;
-    }
+  XboxVideoClearScreenColor(BgColor, FALSE);
 }
 
 VOID
-XboxVideoPutCharAttrAtLoc(int Ch, U8 Attr, unsigned X, unsigned Y)
+XboxVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y)
 {
   U32 FgColor, BgColor;
 
@@ -163,15 +130,83 @@
   BytesPerPixel = 4;
   Delta = (ScreenWidth * BytesPerPixel + 3) & ~ 0x3;
 
-  CurrentCursorX = 0;
-  CurrentCursorY = 0;
-  CurrentFgColor = MAKE_COLOR(192, 192, 192);
-  CurrentBgColor = MAKE_COLOR(0, 0, 0);
-
-  XboxVideoClearScreen(CurrentBgColor, TRUE);
+  XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE);
 
   /* Tell the nVidia controller about the framebuffer */
   *((PU32) 0xfd600800) = (U32) FrameBuffer;
 }
 
+VIDEODISPLAYMODE
+XboxVideoSetDisplayMode(char *DisplayMode, BOOL Init)
+{
+  /* We only have one mode, semi-text */
+  return VideoTextMode;
+}
+
+VOID
+XboxVideoGetDisplaySize(PU32 Width, PU32 Height, PU32 Depth)
+{
+  *Width = ScreenWidth / CHAR_WIDTH;
+  *Height = (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT;
+  *Depth = 0;
+}
+
+U32
+XboxVideoGetBufferSize(VOID)
+{
+  return (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT * (ScreenWidth / CHAR_WIDTH) * 2;
+}
+
+VOID
+XboxVideoSetTextCursorPosition(U32 X, U32 Y)
+{
+  /* We don't have a cursor yet */
+}
+
+VOID
+XboxVideoHideShowTextCursor(BOOL Show)
+{
+  /* We don't have a cursor yet */
+}
+
+VOID
+XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
+{
+  PU8 OffScreenBuffer = (PU8) Buffer;
+  U32 Col, Line;
+
+  for (Line = 0; Line < (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT; Line++)
+    {
+      for (Col = 0; Col < ScreenWidth / CHAR_WIDTH; Col++)
+        {
+          XboxVideoPutChar(OffScreenBuffer[0], OffScreenBuffer[1], Col, Line);
+          OffScreenBuffer += 2;
+        }
+    }
+}
+
+BOOL
+XboxVideoIsPaletteFixed(VOID)
+{
+  return FALSE;
+}
+
+VOID
+XboxVideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
+{
+  /* Not supported */
+}
+
+VOID
+XboxVideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
+{
+  /* Not supported */
+}
+
+VOID
+XboxVideoSync()
+{
+  /* Not supported */
+}
+
 /* EOF */

freeldr/freeldr/include
machine.h 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- machine.h	12 Nov 2004 17:17:08 -0000	1.4
+++ machine.h	14 Nov 2004 22:04:39 -0000	1.5
@@ -1,4 +1,4 @@
-/* $Id: machine.h,v 1.4 2004/11/12 17:17:08 gvg Exp $
+/* $Id: machine.h,v 1.5 2004/11/14 22:04:39 gvg Exp $
  *
  *  FreeLoader
  *
@@ -28,11 +28,30 @@
 #include "mm.h"
 #endif
 
+typedef enum tagVIDEODISPLAYMODE
+{
+  VideoTextMode,
+  VideoGraphicsMode
+} VIDEODISPLAYMODE, *PVIDEODISPLAYMODE;
+
 typedef struct tagMACHVTBL
 {
-  VOID (*ClearScreenAttr)(U8 Attr);
-  VOID (*PutChar)(int Ch);
-  VOID (*PutCharAttrAtLoc)(int Ch, U8 Attr, unsigned X, unsigned Y);
+  VOID (*ConsPutChar)(int Ch);
+  BOOL (*ConsKbHit)(VOID);
+  int (*ConsGetCh)(VOID);
+  
+  VOID (*VideoClearScreen)(U8 Attr);
+  VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOL Init);
+  VOID (*VideoGetDisplaySize)(PU32 Width, PU32 Height, PU32 Depth);
+  U32 (*VideoGetBufferSize)(VOID);
+  VOID (*VideoSetTextCursorPosition)(U32 X, U32 Y);
+  VOID (*VideoHideShowTextCursor)(BOOL Show);
+  VOID (*VideoPutChar)(int Ch, U8 Attr, unsigned X, unsigned Y);
+  VOID (*VideoCopyOffScreenBufferToVRAM)(PVOID Buffer);
+  BOOL (*VideoIsPaletteFixed)(VOID);
+  VOID (*VideoSetPaletteColor)(U8 Color, U8 Red, U8 Green, U8 Blue);
+  VOID (*VideoGetPaletteColor)(U8 Color, U8* Red, U8* Green, U8* Blue);
+  VOID (*VideoSync)(VOID);
 
   U32 (*GetMemoryMap)(PBIOS_MEMORY_MAP BiosMemoryMap, U32 MaxMemoryMapSize);
 
@@ -40,20 +59,35 @@
   BOOL (*DiskGetPartitionEntry)(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
   BOOL (*DiskGetDriveGeometry)(U32 DriveNumber, PGEOMETRY DriveGeometry);
   U32 (*DiskGetCacheableBlockCount)(U32 DriveNumber);
+
+  VOID (*RTCGetCurrentDateTime)(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 Second);
 } MACHVTBL, *PMACHVTBL;
 
 VOID MachInit(VOID);
 
 extern MACHVTBL MachVtbl;
 
-#define MachClearScreenAttr(Attr)		MachVtbl.ClearScreenAttr(Attr)
-#define MachPutChar(Ch)				MachVtbl.PutChar(Ch)
-#define MachPutCharAttrAtLoc(Ch, Attr, X, Y)	MachVtbl.PutCharAttrAtLoc((Ch), (Attr), (X), (Y))
+#define MachConsPutChar(Ch)			MachVtbl.ConsPutChar(Ch)
+#define MachConsKbHit()				MachVtbl.ConsKbHit()
+#define MachConsGetCh()				MachVtbl.ConsGetCh()
+#define MachVideoClearScreen(Attr)		MachVtbl.VideoClearScreen(Attr)
+#define MachVideoSetDisplayMode(Mode, Init)	MachVtbl.VideoSetDisplayMode((Mode), (Init))
+#define MachVideoGetDisplaySize(W, H, D)	MachVtbl.VideoGetDisplaySize((W), (H), (D))
+#define MachVideoGetBufferSize()		MachVtbl.VideoGetBufferSize()
+#define MachVideoSetTextCursorPosition(X, Y)	MachVtbl.VideoSetTextCursorPosition((X), (Y))
+#define MachVideoHideShowTextCursor(Show)	MachVtbl.VideoHideShowTextCursor(Show)
+#define MachVideoPutChar(Ch, Attr, X, Y)	MachVtbl.VideoPutChar((Ch), (Attr), (X), (Y))
+#define MachVideoCopyOffScreenBufferToVRAM(Buf)	MachVtbl.VideoCopyOffScreenBufferToVRAM(Buf)
+#define MachVideoIsPaletteFixed()		MachVtbl.VideoIsPaletteFixed()
+#define MachVideoSetPaletteColor(Col, R, G, B)	MachVtbl.VideoSetPaletteColor((Col), (R), (G), (B))
+#define MachVideoGetPaletteColor(Col, R, G, B)	MachVtbl.VideoGetPaletteColor((Col), (R), (G), (B))
+#define MachVideoSync()				MachVtbl.VideoSync()
 #define MachGetMemoryMap(MMap, Size)		MachVtbl.GetMemoryMap((MMap), (Size))
 #define MachDiskReadLogicalSectors(Drive, Start, Count, Buf)	MachVtbl.DiskReadLogicalSectors((Drive), (Start), (Count), (Buf))
 #define MachDiskGetPartitionEntry(Drive, Part, Entry)	MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry))
 #define MachDiskGetDriveGeometry(Drive, Geom)	MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
 #define MachDiskGetCacheableBlockCount(Drive)	MachVtbl.DiskGetCacheableBlockCount(Drive)
+#define MachRTCGetCurrentDateTime(Y, Mo, D, H, Mi, S)	MachVtbl.RTCGetCurrentDateTime((Y), (Mo), (D), (H), (Mi), (S));
 
 #endif /* __MACHINE_H_ */
 

freeldr/freeldr/include
rtl.h 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- rtl.h	9 Nov 2004 23:36:20 -0000	1.10
+++ rtl.h	14 Nov 2004 22:04:39 -0000	1.11
@@ -72,15 +72,6 @@
 char *	convert_to_ascii(char *buf, int c, ...);
 char *	convert_i64_to_ascii(char *buf, int c, ...);
 
-int		kbhit(void);			// Implemented in asmcode.S
-int		getch(void);			// Implemented in asmcode.S
-int		getyear(void);			// Implemented in asmcode.S
-int		getday(void);			// Implemented in asmcode.S
-int		getmonth(void);			// Implemented in asmcode.S
-int		gethour(void);			// Implemented in asmcode.S
-int		getminute(void);		// Implemented in asmcode.S
-int		getsecond(void);		// Implemented in asmcode.S
-
 void	beep(void);
 void	delay(unsigned msec);
 void	sound(int freq);

freeldr/freeldr/include
video.h 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- video.h	19 Jan 2003 01:03:59 -0000	1.5
+++ video.h	14 Nov 2004 22:04:39 -0000	1.6
@@ -20,174 +20,40 @@
 #ifndef __VIDEO_H
 #define __VIDEO_H
 
-
-
-#define	VIDEOCARD_CGA_OR_OTHER		0
-#define VIDEOCARD_EGA				1
-#define VIDEOCARD_VGA				2
-
-#define VERTRES_200_SCANLINES		0x00
-#define VERTRES_350_SCANLINES		0x01
-#define VERTRES_400_SCANLINES		0x02
-
-#define MODETYPE_TEXT				0
-#define MODETYPE_GRAPHICS			1
-
-#define VIDEOMODE_NORMAL_TEXT		0
-#define VIDEOMODE_EXTENDED_TEXT		1
-#define	VIDEOMODE_80X28				0x501C
-#define	VIDEOMODE_80X30				0x501E
-#define	VIDEOMODE_80X34				0x5022
-#define	VIDEOMODE_80X43				0x502B
-#define	VIDEOMODE_80X60				0x503C
-#define	VIDEOMODE_132X25			0x8419
-#define	VIDEOMODE_132X43			0x842B
-#define	VIDEOMODE_132X50			0x8432
-#define	VIDEOMODE_132X60			0x843C
-
-#define VIDEOPORT_PALETTE_READ		0x03C7
-#define VIDEOPORT_PALETTE_WRITE		0x03C8
-#define VIDEOPORT_PALETTE_DATA		0x03C9
-#define VIDEOPORT_VERTICAL_RETRACE	0x03DA
-
-#define VIDEOVGA_MEM_ADDRESS		0xA0000
-#define VIDEOTEXT_MEM_ADDRESS		0xB8000
-
 typedef struct
 {
-	U8	Red;
-	U8	Green;
-	U8	Blue;
+  U8 Red;
+  U8 Green;
+  U8 Blue;
 } PACKED PALETTE_ENTRY, *PPALETTE_ENTRY;
 
-typedef struct
-{
-	U16	ModeAttributes;				// mode attributes (see #00080)
-	U8	WindowAttributesA;			// window attributes, window A (see #00081)
-	U8	WindowsAttributesB;			// window attributes, window B (see #00081)
-	U16	WindowGranularity;			// window granularity in KB
-	U16	WindowSize;					// window size in KB
-	U16	WindowAStartSegment;		// start segment of window A (0000h if not supported)
-	U16	WindowBStartSegment;		// start segment of window B (0000h if not supported)
-	U32	WindowPositioningFunction;	// -> FAR window positioning function (equivalent to AX=4F05h)
-	U16	BytesPerScanLine;			// bytes per scan line
-	//---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes---
-	U16	WidthInPixels;				// width in pixels (graphics) or characters (text)
-	U16	HeightInPixels;				// height in pixels (graphics) or characters (text)
-	U8	CharacterWidthInPixels;		// width of character cell in pixels
-	U8	CharacterHeightInPixels;	// height of character cell in pixels
-	U8	NumberOfMemoryPlanes;		// number of memory planes
-	U8	BitsPerPixel;				// number of bits per pixel
-	U8	NumberOfBanks;				// number of banks
-	U8	MemoryModel;				// memory model type (see #00082)
-	U8	BankSize;					// size of bank in KB
-	U8	NumberOfImagePanes;			// number of image pages (less one) that will fit in video RAM
-	U8	Reserved1;					// reserved (00h for VBE 1.0-2.0, 01h for VBE 3.0)
-	//---VBE v1.2+ ---
-	U8	RedMaskSize;				// red mask size
-	U8	RedMaskPosition;			// red field position
-	U8	GreenMaskSize;				// green mask size
-	U8	GreenMaskPosition;			// green field size
-	U8	BlueMaskSize;				// blue mask size
-	U8	BlueMaskPosition;			// blue field size
-	U8	ReservedMaskSize;			// reserved mask size
-	U8	ReservedMaskPosition;		// reserved mask position
-	U8	DirectColorModeInfo;		// direct color mode info
-									// bit 0:Color ramp is programmable
-									// bit 1:Bytes in reserved field may be used by application
-	//---VBE v2.0+ ---
-	U32	LinearVideoBufferAddress;	// physical address of linear video buffer
-	U32	OffscreenMemoryPointer;		// pointer to start of offscreen memory
-	U16	OffscreenMemorySize;		// KB of offscreen memory
-	//---VBE v3.0 ---
-	U16	LinearBytesPerScanLine;		// bytes per scan line in linear modes
-	U8	BankedNumberOfImages;		// number of images (less one) for banked video modes
-	U8	LinearNumberOfImages;		// number of images (less one) for linear video modes
-	U8	LinearRedMaskSize;			// linear modes:Size of direct color red mask (in bits)
-	U8	LinearRedMaskPosition;		// linear modes:Bit position of red mask LSB (e.g. shift count)
-	U8	LinearGreenMaskSize;		// linear modes:Size of direct color green mask (in bits)
-	U8	LinearGreenMaskPosition;	// linear modes:Bit position of green mask LSB (e.g. shift count)
-	U8	LinearBlueMaskSize;			// linear modes:Size of direct color blue mask (in bits)
-	U8	LinearBlueMaskPosition;		// linear modes:Bit position of blue mask LSB (e.g. shift count)
-	U8	LinearReservedMaskSize;		// linear modes:Size of direct color reserved mask (in bits)
-	U8	LinearReservedMaskPosition;	// linear modes:Bit position of reserved mask LSB
-	U32	MaximumPixelClock;			// maximum pixel clock for graphics video mode, in Hz
-	U8	Reserved2[190];				// 190 BYTEs  reserved (0)
-} PACKED SVGA_MODE_INFORMATION, *PSVGA_MODE_INFORMATION;
-
-
-extern	U32						CurrentMemoryBank;
-extern	SVGA_MODE_INFORMATION	VesaVideoModeInformation;
-
-extern	PVOID					VideoOffScreenBuffer;
-
-
-
-
-VOID	BiosSetVideoMode(U32 VideoMode);				// Implemented in i386vid.S
-VOID	BiosSetVideoFont8x8(VOID);						// Implemented in i386vid.S
-VOID	BiosSetVideoFont8x14(VOID);						// Implemented in i386vid.S
-VOID	BiosSetVideoFont8x16(VOID);						// Implemented in i386vid.S
-VOID	BiosSelectAlternatePrintScreen(VOID);			// Implemented in i386vid.S
-VOID	BiosDisableCursorEmulation(VOID);				// Implemented in i386vid.S
-VOID	BiosDefineCursor(U32 StartScanLine, U32 EndScanLine);	// Implemented in i386vid.S
-U32		BiosDetectVideoCard(VOID);						// Implemented in i386vid.S
-VOID	BiosSetVerticalResolution(U32 ScanLines);		// Implemented in i386vid.S, must be called right before BiosSetVideoMode()
-VOID	BiosSet480ScanLines(VOID);						// Implemented in i386vid.S, must be called right after BiosSetVideoMode()
-VOID	BiosSetVideoDisplayEnd(VOID);					// Implemented in i386vid.S
-VOID	BiosVideoDisableBlinkBit(VOID);					// Implemented in i386vid.S
-VOID	BiosVideoEnableBlinkBit(VOID);					// Implemented in i386vid.S
+extern	PVOID	VideoOffScreenBuffer;
 
 U16		BiosIsVesaSupported(VOID);						// Implemented in i386vid.S, returns the VESA version
-BOOL	BiosVesaSetBank(U16 Bank);						// Implemented in i386vid.S
-BOOL	BiosVesaSetVideoMode(U16 Mode);					// Implemented in i386vid.S
-BOOL	BiosVesaGetSVGAModeInformation(U16 Mode, PSVGA_MODE_INFORMATION ModeInformation);	// Implemented in i386vid.S
-
-VOID	VideoSetTextCursorPosition(U32 X, U32 Y);		// Implemented in i386vid.S
-VOID	VideoHideTextCursor(VOID);						// Implemented in i386vid.S
-VOID	VideoShowTextCursor(VOID);						// Implemented in i386vid.S
-U32		VideoGetTextCursorPositionX(VOID);				// Implemented in i386vid.S
-U32		VideoGetTextCursorPositionY(VOID);				// Implemented in i386vid.S
-
-BOOL	VideoSetMode(U32 VideoMode);
-BOOL	VideoSetMode80x25(VOID);						// Sets 80x25
-BOOL	VideoSetMode80x50_80x43(VOID);					// Sets 80x50 (VGA) or 80x43 (EGA) 8-pixel mode
-BOOL	VideoSetMode80x28(VOID);						// Sets 80x28. Works on all VGA's. Standard 80x25 with 14-point font
-BOOL	VideoSetMode80x43(VOID);						// Sets 80x43. Works on all VGA's. It's a 350-scanline mode with 8-pixel font.
-BOOL	VideoSetMode80x30(VOID);						// Sets 80x30. Works on all VGA's. 480 scanlines, 16-pixel font.
-BOOL	VideoSetMode80x34(VOID);						// Sets 80x34. Works on all VGA's. 480 scanlines, 14-pixel font.
-BOOL	VideoSetMode80x60(VOID);						// Sets 80x60. Works on all VGA's. 480 scanlines, 8-pixel font.
-U32		VideoGetCurrentModeResolutionX(VOID);
-U32		VideoGetCurrentModeResolutionY(VOID);
-U32		VideoGetBytesPerScanLine(VOID);
-U32		VideoGetCurrentMode(VOID);
-U32		VideoGetCurrentModeType(VOID);					// MODETYPE_TEXT or MODETYPE_GRAPHICS
-BOOL	VideoIsCurrentModeVesa(VOID);
-U32		VideoGetCurrentModeColorDepth(VOID);			// Returns 0 for text mode, 16 for 4-bit, 256 for 8-bit, 32768 for 15-bit, 65536 for 16-bit, etc.
 
-VOID	VideoClearScreen(VOID);
-VOID	VideoWaitForVerticalRetrace(VOID);
 PVOID	VideoAllocateOffScreenBuffer(VOID);				// Returns a pointer to an off-screen buffer sufficient for the current video mode
 
-U32		VideoGetMemoryBankForPixel(U32 X, U32 Y);
-U32		VideoGetMemoryBankForPixel16(U32 X, U32 Y);
-U32		VideoGetBankOffsetForPixel(U32 X, U32 Y);
-U32		VideoGetBankOffsetForPixel16(U32 X, U32 Y);
+#if 0 /* Not used */
+U32	VideoGetMemoryBankForPixel(U32 X, U32 Y);
+U32	VideoGetMemoryBankForPixel16(U32 X, U32 Y);
+U32	VideoGetBankOffsetForPixel(U32 X, U32 Y);
+U32	VideoGetBankOffsetForPixel16(U32 X, U32 Y);
 VOID	VideoSetMemoryBank(U16 BankNumber);
-U32		VideoGetOffScreenMemoryOffsetForPixel(U32 X, U32 Y);
+U32	VideoGetOffScreenMemoryOffsetForPixel(U32 X, U32 Y);
+#endif
 VOID	VideoCopyOffScreenBufferToVRAM(VOID);
 
-VOID	VideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue);
-VOID	VideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue);
 VOID	VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount);
 VOID	VideoRestorePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount);
 
+#if 0 /* Not used */
 VOID	VideoSetPixel16(U32 X, U32 Y, U8 Color);
 VOID	VideoSetPixel256(U32 X, U32 Y, U8 Color);
 VOID	VideoSetPixelRGB(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue);
 VOID	VideoSetPixel16_OffScreen(U32 X, U32 Y, U8 Color);
 VOID	VideoSetPixel256_OffScreen(U32 X, U32 Y, U8 Color);
 VOID	VideoSetPixelRGB_OffScreen(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue);
+#endif
 
 VOID	VideoSetAllColorsToBlack(U32 ColorCount);
 VOID	VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount);

freeldr/freeldr/inifile
parse.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- parse.c	2 Jun 2004 22:19:54 -0000	1.8
+++ parse.c	14 Nov 2004 22:04:39 -0000	1.9
@@ -22,6 +22,7 @@
 #include <rtl.h>
 #include <mm.h>
 #include <debug.h>
+#include <machine.h>
 
 
 PINI_SECTION		IniFileSectionListHead = NULL;
@@ -125,7 +126,7 @@
 			{
 				printf("Error: freeldr.ini:%ld: Setting '%s' found outside of a [section].\n", CurrentLineNumber, IniFileLine);
 				printf("Press any key to continue...\n");
-				getch();
+				MachConsGetCh();
 				CurrentLineNumber++;
 				continue;
 			}

freeldr/freeldr/mm
mm.c 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- mm.c	19 Jun 2004 22:42:41 -0000	1.13
+++ mm.c	14 Nov 2004 22:04:39 -0000	1.14
@@ -23,6 +23,7 @@
 #include <rtl.h>
 #include <debug.h>
 #include <ui.h>
+#include <machine.h>
 
 
 #ifdef DEBUG
@@ -377,25 +378,25 @@
 
 	MemPtr1 = MmAllocateMemory(4096);
 	printf("MemPtr1: 0x%x\n", (int)MemPtr1);
-	getch();
+	MachConsGetCh();
 	MemPtr2 = MmAllocateMemory(4096);
 	printf("MemPtr2: 0x%x\n", (int)MemPtr2);
-	getch();
+	MachConsGetCh();
 	MemPtr3 = MmAllocateMemory(4096);
 	printf("MemPtr3: 0x%x\n", (int)MemPtr3);
 	DumpMemoryAllocMap();
 	VerifyHeap();
-	getch();
+	MachConsGetCh();
 
 	MmFreeMemory(MemPtr2);
-	getch();
+	MachConsGetCh();
 
 	MemPtr4 = MmAllocateMemory(2048);
 	printf("MemPtr4: 0x%x\n", (int)MemPtr4);
-	getch();
+	MachConsGetCh();
 	MemPtr5 = MmAllocateMemory(4096);
 	printf("MemPtr5: 0x%x\n", (int)MemPtr5);
-	getch();
+	MachConsGetCh();
 }
 #endif // DEBUG
 

freeldr/freeldr/reactos
setupldr.c 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- setupldr.c	8 Nov 2004 22:02:48 -0000	1.16
+++ setupldr.c	14 Nov 2004 22:04:39 -0000	1.17
@@ -285,7 +285,7 @@
 #if 0
   printf("low_mem = %d\n", mb_info.mem_lower);
   printf("high_mem = %d\n", mb_info.mem_upper);
-  getch();
+  MachConsGetCh();
 #endif
 
 #ifdef USE_UI
@@ -401,7 +401,7 @@
       UiMessageBox("Please insert \"ReactOS Boot Disk 2\" and press ENTER");
 #else
       printf("\n\n Please insert \"ReactOS Boot Disk 2\" and press ENTER\n");
-      getch();
+      MachConsGetCh();
 #endif
 
       /* Open boot drive */

freeldr/freeldr/rtl
print.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- print.c	8 Nov 2004 22:02:48 -0000	1.8
+++ print.c	14 Nov 2004 22:04:39 -0000	1.9
@@ -29,7 +29,7 @@
 	int	i;
 
 	for (i = 0; i < strlen(str); i++)
-		MachPutChar(str[i]);
+		MachConsPutChar(str[i]);
 }
 
 /*
@@ -48,7 +48,7 @@
 	{
 		if (c != '%')
 		{
-			MachPutChar(c);
+			MachConsPutChar(c);
 		}
 		else
 		{
@@ -77,22 +77,22 @@
 
 				while (*ptr)
 				{
-					MachPutChar(*(ptr++));
+					MachConsPutChar(*(ptr++));
 				}
 				break;
 
-			case 'c': MachPutChar((*(dataptr++))&0xff); break;
+			case 'c': MachConsPutChar((*(dataptr++))&0xff); break;
 
 			case 's':
 				ptr = (char *)(*(dataptr++));
 
 				while ((c = *(ptr++)))
 				{
-					MachPutChar(c);
+					MachConsPutChar(c);
 				}
 				break;
 			case '%':
-				MachPutChar(c);
+				MachConsPutChar(c);
 				break;
 			default:
 				printf("\nprintf() invalid format specifier - %%%c\n", c);

freeldr/freeldr/ui
tui.c 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- tui.c	19 Jan 2003 01:04:01 -0000	1.12
+++ tui.c	14 Nov 2004 22:04:39 -0000	1.13
@@ -27,15 +27,15 @@
 #include <inifile.h>
 #include <version.h>
 #include <video.h>
+#include <machine.h>
 
 
 PVOID	TextVideoBuffer = NULL;
 
 BOOL TuiInitialize(VOID)
 {
-	VideoClearScreen();
-	VideoHideTextCursor();
-	BiosVideoDisableBlinkBit();
+	MachVideoClearScreen(ATTR(COLOR_WHITE, COLOR_BLACK));
+	MachVideoHideShowTextCursor(FALSE);
 
 	TextVideoBuffer = VideoAllocateOffScreenBuffer();
 	if (TextVideoBuffer == NULL)
@@ -54,13 +54,11 @@
 	}
 	else
 	{
-		VideoSetMode(VIDEOMODE_NORMAL_TEXT);
+		MachVideoSetDisplayMode(NULL, FALSE);
 	}
 
 	//VideoClearScreen();
-	VideoSetMode(VIDEOMODE_NORMAL_TEXT);
-	VideoShowTextCursor();
-	BiosVideoEnableBlinkBit();
+	MachVideoHideShowTextCursor(TRUE);
 }
 
 VOID TuiDrawBackdrop(VOID)
@@ -397,26 +395,28 @@
 
 VOID TuiUpdateDateTime(VOID)
 {
+	U32	Year, Month, Day;
+	U32	Hour, Minute, Second;
 	UCHAR	DateString[40];
 	UCHAR	TimeString[40];
 	UCHAR	TempString[20];
-	U32		Hour, Minute, Second;
 	BOOL	PMHour = FALSE;
 
+	MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
 	// Get the month name
-	strcpy(DateString, UiMonthNames[getmonth()-1]);
+	strcpy(DateString, UiMonthNames[Month - 1]);
 	// Get the day
-	itoa(getday(), TempString, 10);
+	itoa(Day, TempString, 10);
 	// Get the day postfix
-	if ((getday() == 1) || (getday() == 21) || (getday() == 31))
+	if (1 == Day || 21 == Day || 31 == Day)
 	{
 		strcat(TempString, "st");
 	}
-	else if ((getday() == 2) || (getday() == 22))
+	else if (2 == Day || 22 == Day)
 	{
 		strcat(TempString, "nd");
 	}
-	else if ((getday() == 3) || (getday() == 23))
+	else if (3 == Day || 23 == Day)
 	{
 		strcat(TempString, "rd");
 	}
@@ -430,14 +430,13 @@
 	strcat(DateString, " ");
 
 	// Get the year and add it to the date
-	itoa(getyear(), TempString, 10);
+	itoa(Year, TempString, 10);
 	strcat(DateString, TempString);
 
 	// Draw the date
 	TuiDrawText(UiScreenWidth-strlen(DateString)-2, 1, DateString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
 
 	// Get the hour and change from 24-hour mode to 12-hour
-	Hour = gethour();
 	if (Hour > 12)
 	{
 		Hour -= 12;
@@ -447,8 +446,6 @@
 	{
 		Hour = 12;
 	}
-	Minute = getminute();
-	Second = getsecond();
 	itoa(Hour, TempString, 10);
 	strcpy(TimeString, "    ");
 	strcat(TimeString, TempString);
@@ -584,11 +581,11 @@
 
 	for (;;)
 	{
-		if (kbhit())
+		if (MachConsKbHit())
 		{
-			key = getch();
+			key = MachConsGetCh();
 			if(key == KEY_EXTENDED)
-				key = getch();
+				key = MachConsGetCh();
 
 			if(key == KEY_ENTER)
 				break;
@@ -718,7 +715,7 @@
 {
 	PPALETTE_ENTRY TuiFadePalette = NULL;
 
-	if (UiUseSpecialEffects)
+	if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
 	{
 		TuiFadePalette = (PPALETTE_ENTRY)MmAllocateMemory(sizeof(PALETTE_ENTRY) * 64);
 
@@ -732,7 +729,7 @@
 	// Draw the backdrop and title box
 	TuiDrawBackdrop();
 
-	if (UiUseSpecialEffects && TuiFadePalette != NULL)
+	if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
 	{
 		VideoFadeIn(TuiFadePalette, 64);
 		MmFreeMemory(TuiFadePalette);
@@ -743,7 +740,7 @@
 {
 	PPALETTE_ENTRY TuiFadePalette = NULL;
 
-	if (UiUseSpecialEffects)
+	if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
 	{
 		TuiFadePalette = (PPALETTE_ENTRY)MmAllocateMemory(sizeof(PALETTE_ENTRY) * 64);
 
@@ -753,14 +750,14 @@
 		}
 	}
 
-	if (UiUseSpecialEffects && TuiFadePalette != NULL)
+	if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
 	{
 		VideoFadeOut(64);
 	}
 
-	VideoSetMode(VIDEOMODE_NORMAL_TEXT);
+	MachVideoSetDisplayMode(NULL, FALSE);
 
-	if (UiUseSpecialEffects && TuiFadePalette != NULL)
+	if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
 	{
 		VideoRestorePaletteState(TuiFadePalette, 64);
 		MmFreeMemory(TuiFadePalette);
@@ -843,8 +840,8 @@
 
 	// Show the cursor
 	EditBoxCursorX = EditBoxStartX;
-	VideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
-	VideoShowTextCursor();
+	MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
+	MachVideoHideShowTextCursor(TRUE);
 
 	// Draw status text
 	UiDrawStatusText("Press ENTER to continue, or ESC to cancel");
@@ -853,12 +850,12 @@
 
 	for (;;)
 	{
-		if (kbhit())
+		if (MachConsKbHit())
 		{
-			key = getch();
+			key = MachConsGetCh();
 			if(key == KEY_EXTENDED)
 			{
-				key = getch();
+				key = MachConsGetCh();
 			}
 
 			if(key == KEY_ENTER)
@@ -915,7 +912,7 @@
 		UiDrawText(EditBoxStartX, EditBoxLine, &EditTextBuffer[EditBoxTextDisplayIndex], ATTR(UiEditBoxTextColor, UiEditBoxBgColor));
 
 		// Move the cursor
-		VideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
+		MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine);
 
 		TuiUpdateDateTime();
 
@@ -923,7 +920,7 @@
 	}
 
 	// Hide the cursor again
-	VideoHideTextCursor();
+	MachVideoHideShowTextCursor(FALSE);
 
 	// Restore the screen contents
 	TuiRestoreScreen(ScreenBuffer);

freeldr/freeldr/ui
tuimenu.c 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- tuimenu.c	19 Jan 2003 01:04:01 -0000	1.4
+++ tuimenu.c	14 Nov 2004 22:04:39 -0000	1.5
@@ -24,14 +24,16 @@
 #include "keycodes.h"
 #include <options.h>
 #include <mm.h>
+#include <machine.h>
 #include <video.h>
 
 
 BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
 {
 	TUI_MENU_INFO	MenuInformation;
-	U32				CurrentClockSecond;
-	U32				KeyPress;
+	U32		LastClockSecond;
+	U32		CurrentClockSecond;
+	U32		KeyPress;
 
 	//
 	// The first thing we need to check is the timeout
@@ -69,7 +71,7 @@
 	//
 	// Get the current second of time
 	//
-	CurrentClockSecond = getsecond();
+	MachRTCGetCurrentDateTime(NULL, NULL, NULL, NULL, NULL, &LastClockSecond);
 
 	//
 	// Process keys
@@ -104,12 +106,13 @@
 
 		if (MenuInformation.MenuTimeRemaining > 0)
 		{
-			if (getsecond() != CurrentClockSecond)
+			MachRTCGetCurrentDateTime(NULL, NULL, NULL, NULL, NULL, &CurrentClockSecond);
+			if (CurrentClockSecond != LastClockSecond)
 			{
 				//
 				// Update the time information
 				//
-				CurrentClockSecond = getsecond();
+				LastClockSecond = CurrentClockSecond;
 				MenuInformation.MenuTimeRemaining--;
 
 				//
@@ -339,7 +342,7 @@
 	//
 	// Check for a keypress
 	//
-	if (kbhit())
+	if (MachConsKbHit())
 	{
 		//
 		// Cancel the timeout
@@ -353,13 +356,13 @@
 		//
 		// Get the key
 		//
-		KeyEvent = getch();
+		KeyEvent = MachConsGetCh();
 
 		//
 		// Is it extended?
 		//
 		if (KeyEvent == 0)
-			KeyEvent = getch(); // Yes - so get the extended key
+			KeyEvent = MachConsGetCh(); // Yes - so get the extended key
 
 		//
 		// Call the supplied key filter callback function to see

freeldr/freeldr/ui
ui.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- ui.c	25 Apr 2003 19:32:51 -0000	1.8
+++ ui.c	14 Nov 2004 22:04:39 -0000	1.9
@@ -22,17 +22,14 @@
 #include "tui.h"
 #include <rtl.h>
 #include <mm.h>
+#include <machine.h>
 #include <debug.h>
 #include <inifile.h>
 #include <version.h>
 #include <video.h>
 
-
-#define DISPLAYMODE_TEXT		0
-#define DISPLAYMODE_GRAPHICS	1
-
-U32		UiScreenWidth = 80;									// Screen Width
-U32		UiScreenHeight = 25;								// Screen Height
+U32	UiScreenWidth = 80;							// Screen Width
+U32	UiScreenHeight = 25;							// Screen Height
 
 UCHAR	UiStatusBarFgColor			= COLOR_BLACK;			// Status bar foreground color
 UCHAR	UiStatusBarBgColor			= COLOR_CYAN;			// Status bar background color
@@ -55,7 +52,7 @@
 
 BOOL	UserInterfaceUp				= FALSE;				// Tells us if the user interface is displayed
 
-BOOL	UiDisplayMode				= DISPLAYMODE_TEXT;		// Tells us if we are in text or graphics mode
+VIDEODISPLAYMODE	UiDisplayMode		= VideoTextMode;		// Tells us if we are in text or graphics mode
 
 BOOL	UiUseSpecialEffects			= FALSE;				// Tells us if we should use fade effects
 
@@ -64,65 +61,23 @@
 
 BOOL UiInitialize(VOID)
 {
-	U32		SectionId;
+	U32	SectionId;
+	UCHAR	DisplayModeText[260];
 	UCHAR	SettingText[260];
-	U32		VideoMode = VIDEOMODE_NORMAL_TEXT;
+	U32	Depth;
 
 	DbgPrint((DPRINT_UI, "Initializing User Interface.\n"));
 
 	DbgPrint((DPRINT_UI, "Reading in UI settings from [Display] section.\n"));
 
+	DisplayModeText[0] = '\0';
 	if (IniOpenSection("Display", &SectionId))
 	{
-		if (IniReadSettingByName(SectionId, "DisplayMode", SettingText, 260))
+		if (! IniReadSettingByName(SectionId, "DisplayMode", DisplayModeText, 260))
 		{
-			if (BiosDetectVideoCard() == VIDEOCARD_CGA_OR_OTHER)
-			{
-				DbgPrint((DPRINT_UI, "CGA or other display adapter detected.\n"));
-				printf("CGA or other display adapter detected.\n");
-				printf("Using 80x25 text mode.\n");
-				VideoMode = VIDEOMODE_NORMAL_TEXT;
-			}
-			else if (BiosDetectVideoCard() == VIDEOCARD_EGA)
-			{
-				DbgPrint((DPRINT_UI, "EGA display adapter detected.\n"));
-				printf("EGA display adapter detected.\n");
-				printf("Using 80x25 text mode.\n");
-				VideoMode = VIDEOMODE_NORMAL_TEXT;
-			}
-			else //if (BiosDetectVideoCard() == VIDEOCARD_VGA)
-			{
-				DbgPrint((DPRINT_UI, "VGA display adapter detected.\n"));
-
-				if (stricmp(SettingText, "NORMAL_VGA") == 0)
-				{
-					VideoMode = VIDEOMODE_NORMAL_TEXT;
-				}
-				else if (stricmp(SettingText, "EXTENDED_VGA") == 0)
-				{
-					VideoMode = VIDEOMODE_EXTENDED_TEXT;
-				}
-				else
-				{
-					VideoMode = atoi(SettingText);
-				}
-			}
-
-			if (!VideoSetMode(VideoMode))
-			{
-				printf("Error: unable to set video display mode 0x%x\n", (int) VideoMode);
-				printf("Defaulting to 80x25 text mode.\n");
-				printf("Press any key to continue.\n");
-				getch();
-
-				VideoMode = VIDEOMODE_NORMAL_TEXT;
-				VideoSetMode(VIDEOMODE_NORMAL_TEXT);
-			}
-
-			UiScreenWidth = VideoGetCurrentModeResolutionX();
-			UiScreenHeight = VideoGetCurrentModeResolutionY();
-			UiDisplayMode = VideoGetCurrentModeType();
+			DisplayModeText[0] = '\0';
 		}
+
 		if (IniReadSettingByName(SectionId, "TitleText", SettingText, 260))
 		{
 			strcpy(UiTitleBoxTitleText, SettingText);
@@ -204,11 +159,15 @@
 		}
 	}
 
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE);
+	MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth);
+
+
+	if (VideoTextMode == UiDisplayMode)
 	{
 		if (!TuiInitialize())
 		{
-			VideoSetMode(VIDEOMODE_NORMAL_TEXT);
+			MachVideoSetDisplayMode(NULL, FALSE);
 			return FALSE;
 		}
 	}
@@ -217,7 +176,7 @@
 		UNIMPLEMENTED();
 		//if (!GuiInitialize())
 		//{
-		//	VideoSetMode(VIDEOMODE_NORMAL_TEXT);
+		//	MachSetDisplayMode(NULL, FALSE);
 		//	return FALSE;
 		//}
 	}
@@ -238,7 +197,7 @@
 	UiDrawStatusText("Booting...");
 	UiInfoBox(BootText);
 
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiUnInitialize();
 	}
@@ -251,7 +210,7 @@
 
 VOID UiDrawBackdrop(VOID)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawBackdrop();
 	}
@@ -264,7 +223,7 @@
 
 VOID UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR Attr /* Color Attributes */)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiFillArea(Left, Top, Right, Bottom, FillChar, Attr);
 	}
@@ -277,7 +236,7 @@
 
 VOID UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawShadow(Left, Top, Right, Bottom);
 	}
@@ -290,7 +249,7 @@
 
 VOID UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR HorzStyle, BOOL Fill, BOOL Shadow, UCHAR Attr)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawBox(Left, Top, Right, Bottom, VertStyle, HorzStyle, Fill, Shadow, Attr);
 	}
@@ -303,7 +262,7 @@
 
 VOID UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawText(X, Y, Text, Attr);
 	}
@@ -316,7 +275,7 @@
 
 VOID UiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextString, UCHAR Attr)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawCenteredText(Left, Top, Right, Bottom, TextString, Attr);
 	}
@@ -329,7 +288,7 @@
 
 VOID UiDrawStatusText(PUCHAR StatusText)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawStatusText(StatusText);
 	}
@@ -342,7 +301,7 @@
 
 VOID UiUpdateDateTime(VOID)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiUpdateDateTime();
 	}
@@ -424,11 +383,11 @@
 	{
 		printf("%s\n", MessageText);
 		printf("Press any key\n");
-		getch();
+		MachConsGetCh();
 		return;
 	}
 
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiMessageBox(MessageText);
 	}
@@ -449,11 +408,11 @@
 	{
 		printf("%s\n", MessageText);
 		printf("Press any key\n");
-		getch();
+		MachConsGetCh();
 		return;
 	}
 
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiMessageBoxCritical(MessageText);
 	}
@@ -466,7 +425,7 @@
 
 UCHAR UiTextToColor(PUCHAR ColorText)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		return TuiTextToColor(ColorText);
 	}
@@ -480,7 +439,7 @@
 
 UCHAR UiTextToFillStyle(PUCHAR FillStyleText)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		return TuiTextToFillStyle(FillStyleText);
 	}
@@ -494,7 +453,7 @@
 
 VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawProgressBarCenter(Position, Range, ProgressText);
 	}
@@ -507,7 +466,7 @@
 
 VOID UiDrawProgressBar(U32 Left, U32 Top, U32 Right, U32 Bottom, U32 Position, U32 Range, PUCHAR ProgressText)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiDrawProgressBar(Left, Top, Right, Bottom, Position, Range, ProgressText);
 	}
@@ -598,7 +557,7 @@
 
 BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		return TuiDisplayMenu(MenuItemList, MenuItemCount, DefaultMenuItem, MenuTimeOut, SelectedMenuItem, CanEscape, KeyPressFilter);
 	}
@@ -612,7 +571,7 @@
 
 VOID UiFadeInBackdrop(VOID)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiFadeInBackdrop();
 	}
@@ -625,7 +584,7 @@
 
 VOID UiFadeOut(VOID)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		TuiFadeOut();
 	}
@@ -638,7 +597,7 @@
 
 BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length)
 {
-	if (UiDisplayMode == DISPLAYMODE_TEXT)
+	if (VideoTextMode == UiDisplayMode)
 	{
 		return TuiEditBox(MessageText, EditTextBuffer, Length);
 	}

freeldr/freeldr/video
bank.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- bank.c	19 Jan 2003 01:04:01 -0000	1.2
+++ bank.c	14 Nov 2004 22:04:39 -0000	1.3
@@ -22,8 +22,10 @@
 #include <comm.h>
 #include <rtl.h>
 #include <debug.h>
+#include <machine.h>
 
 
+#if 0 /* This stuff isn't used and as far as I'm concerned it can go - GvG */
 U32		CurrentMemoryBank = 0;
 
 VOID VideoSetMemoryBank(U16 BankNumber)
@@ -108,45 +110,9 @@
 
 	return MemoryPos;
 }
+#endif
 
 VOID VideoCopyOffScreenBufferToVRAM(VOID)
 {
-	U32		BanksToCopy;
-	U32		BytesInLastBank;
-	U32		CurrentBank;
-	U32		BankSize;
-	U32		BufferSize;
-
-	//VideoWaitForVerticalRetrace();
-
-	// Text mode (BIOS or VESA)
-	if (VideoGetCurrentModeType() == MODETYPE_TEXT)
-	{
-		BufferSize = VideoGetCurrentModeResolutionX() * VideoGetBytesPerScanLine();
-		RtlCopyMemory((PVOID)VIDEOTEXT_MEM_ADDRESS, VideoOffScreenBuffer, BufferSize);
-	}
-	// VESA graphics mode
-	else if (VideoGetCurrentModeType() == MODETYPE_GRAPHICS && VideoIsCurrentModeVesa())
-	{
-		BankSize = VesaVideoModeInformation.WindowGranularity << 10;
-		BanksToCopy = (VesaVideoModeInformation.HeightInPixels * VesaVideoModeInformation.BytesPerScanLine) / BankSize;
-		BytesInLastBank = (VesaVideoModeInformation.HeightInPixels * VesaVideoModeInformation.BytesPerScanLine) % BankSize;
-
-		// Copy all the banks but the last one because
-		// it is probably a partial bank
-		for (CurrentBank=0; CurrentBank<BanksToCopy; CurrentBank++)
-		{
-			VideoSetMemoryBank(CurrentBank);
-			RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, VideoOffScreenBuffer, BankSize);
-		}
-
-		// Copy the remaining bytes into the last bank
-		VideoSetMemoryBank(CurrentBank);
-		RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, VideoOffScreenBuffer, BytesInLastBank);
-	}
-	// BIOS graphics mode
-	else
-	{
-		UNIMPLEMENTED();
-	}
+	MachVideoCopyOffScreenBufferToVRAM(VideoOffScreenBuffer);
 }

freeldr/freeldr/video
fade.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- fade.c	19 Jan 2003 01:04:01 -0000	1.2
+++ fade.c	14 Nov 2004 22:04:39 -0000	1.3
@@ -19,7 +19,7 @@
 	
 #include <freeldr.h>
 #include <video.h>
-#include <portio.h>
+#include <machine.h>
 
 
 #define RGB_MAX						64
@@ -29,11 +29,11 @@
 {
 	U32		Color;
 
-	VideoWaitForVerticalRetrace();
+	MachVideoSync();
 
 	for (Color=0; Color<ColorCount; Color++)
 	{
-		VideoSetPaletteColor(Color, 0, 0, 0);
+		MachVideoSetPaletteColor(Color, 0, 0, 0);
 	}
 }
 
@@ -48,7 +48,7 @@
 
 		for (Color=0; Color<ColorCount; Color++)
 		{
-			VideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
+			MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
 
 			// Increment each color so it approaches its real value
 			if (PaletteColors[Color].Red < Palette[Color].Red)
@@ -84,10 +84,10 @@
 		{
 			if ((Color % RGB_MAX_PER_ITERATION) == 0)
 			{
-				VideoWaitForVerticalRetrace();
+				MachVideoSync();
 			}
 
-			VideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
+			MachVideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
 		}
 	}
 }
@@ -106,10 +106,10 @@
 		{
 			if ((Color % RGB_MAX_PER_ITERATION) == 0)
 			{
-				VideoWaitForVerticalRetrace();
+				MachVideoSync();
 			}
 
-			VideoGetPaletteColor(Color, &Red, &Green, &Blue);
+			MachVideoGetPaletteColor(Color, &Red, &Green, &Blue);
 
 			if (Red > 0)
 			{
@@ -124,7 +124,7 @@
 				Blue--;
 			}
 
-			VideoSetPaletteColor(Color, Red, Green, Blue);
+			MachVideoSetPaletteColor(Color, Red, Green, Blue);
 		}
 	}
 }

freeldr/freeldr/video
palette.c 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- palette.c	19 Jan 2003 01:04:01 -0000	1.2
+++ palette.c	14 Nov 2004 22:04:39 -0000	1.3
@@ -19,24 +19,7 @@
 	
 #include <freeldr.h>
 #include <video.h>
-#include <portio.h>
-
-
-VOID VideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
-{
-	WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_WRITE, Color);
-	WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA, Red);
-	WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA, Green);
-	WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA, Blue);
-}
-
-VOID VideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
-{
-	WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_READ, Color);
-	*Red = READ_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA);
-	*Green = READ_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA);
-	*Blue = READ_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA);
-}
+#include <machine.h>
 
 VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
 {
@@ -44,7 +27,7 @@
 
 	for (Color=0; Color<ColorCount; Color++)
 	{
-		VideoGetPaletteColor(Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
+		MachVideoGetPaletteColor(Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
 	}
 }
 
@@ -52,10 +35,10 @@
 {
 	U32		Color;
 
-	VideoWaitForVerticalRetrace();
+	MachVideoSync();
 
 	for (Color=0; Color<ColorCount; Color++)
 	{
-		VideoSetPaletteColor(Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
+		MachVideoSetPaletteColor(Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
 	}
 }

freeldr/freeldr/video
pixel.c 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- pixel.c	25 Apr 2003 19:32:51 -0000	1.4
+++ pixel.c	14 Nov 2004 22:04:39 -0000	1.5
@@ -21,11 +21,11 @@
 #include <video.h>
 #include <portio.h>
 #include <debug.h>
+#include <machine.h>
 
 
 
-
-
+#if 0 /* This stuff isn't used and as far as I'm concerned it can go - GvG */
 //
 // Arrrggh!
 // I really really hate 16 color bit plane modes.
@@ -230,26 +230,24 @@
 
 VOID VideoSetPixelRGB(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue)
 {
-	if (VesaVideoModeInformation.BitsPerPixel >= 24)
+	U32 Width, Height, Depth;
+
+	MachVideoGetDisplaySize(&Width, &Height, &Depth);
+	if (Depth >= 24)
 	{
 		VideoSetPixelRGB_24Bit(X, Y, Red, Green, Blue);
 	}
-	else if (VesaVideoModeInformation.BitsPerPixel >= 16)
+	else if (Depth >= 16)
+	{
+		VideoSetPixelRGB_16Bit(X, Y, Red, Green, Blue);
+	}
+	else if (Depth == 15)
 	{
-		// 16-bit color modes give green an extra bit (5:6:5)
-		// 15-bit color modes have just 5:5:5 for R:G:B
-		if (VesaVideoModeInformation.GreenMaskSize == 6)
-		{
-			VideoSetPixelRGB_16Bit(X, Y, Red, Green, Blue);
-		}
-		else
-		{
-			VideoSetPixelRGB_15Bit(X, Y, Red, Green, Blue);
-		}
+		VideoSetPixelRGB_15Bit(X, Y, Red, Green, Blue);
 	}
 	else
 	{
-		BugCheck((DPRINT_UI, "This function does not support %d bits per pixel!", VesaVideoModeInformation.BitsPerPixel));
+		BugCheck((DPRINT_UI, "This function does not support %d bits per pixel!", Depth));
 	}
 }
 
@@ -319,25 +317,25 @@
 
 VOID VideoSetPixelRGB_OffScreen(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue)
 {
-	if (VesaVideoModeInformation.BitsPerPixel >= 24)
+	U32 Width, Height, Depth;
+
+	MachVideoGetDisplaySize(&Width, &Height, &Depth);
+	if (Depth >= 24)
 	{
 		VideoSetPixelRGB_24Bit_OffScreen(X, Y, Red, Green, Blue);
 	}
-	else if (VesaVideoModeInformation.BitsPerPixel >= 16)
+	else if (Depth >= 16)
+	{
+		VideoSetPixelRGB_16Bit_OffScreen(X, Y, Red, Green, Blue);
+	}
+	else if (Depth == 15)
 	{
-		// 16-bit color modes give green an extra bit (5:6:5)
-		// 15-bit color modes have just 5:5:5 for R:G:B
-		if (VesaVideoModeInformation.GreenMaskSize == 6)
-		{
-			VideoSetPixelRGB_16Bit_OffScreen(X, Y, Red, Green, Blue);
-		}
-		else
-		{
-			VideoSetPixelRGB_15Bit_OffScreen(X, Y, Red, Green, Blue);
-		}
+		VideoSetPixelRGB_15Bit_OffScreen(X, Y, Red, Green, Blue);
 	}
 	else
 	{
-		BugCheck((DPRINT_UI, "This function does not support %d bits per pixel!", VesaVideoModeInformation.BitsPerPixel));
+		BugCheck((DPRINT_UI, "This function does not support %d bits per pixel!", Depth));
 	}
 }
+
+#endif

freeldr/freeldr/video
video.c 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- video.c	19 Jan 2003 01:04:01 -0000	1.3
+++ video.c	14 Nov 2004 22:04:39 -0000	1.4
@@ -21,34 +21,11 @@
 #include <video.h>
 #include <portio.h>
 #include <mm.h>
+#include <machine.h>
 
 
 PVOID	VideoOffScreenBuffer = NULL;
 
-VOID VideoClearScreen(VOID)
-{
-	VideoSetMode(VideoGetCurrentMode());
-}
-
-VOID VideoWaitForVerticalRetrace(VOID)
-{
-
-	while ((READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08) == 1)
-	{
-		// Keep reading the port until bit 3 is clear
-		// This waits for the current retrace to end and
-		// we can catch the next one so we know we are
-		// getting a full retrace.
-	}
-
-	while ((READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08) == 0)
-	{
-		// Keep reading the port until bit 3 is set
-		// Now that we know we aren't doing a vertical
-		// retrace we need to wait for the next one.
-	}
-}
-
 PVOID VideoAllocateOffScreenBuffer(VOID)
 {
 	U32		BufferSize;
@@ -59,7 +36,7 @@
 		VideoOffScreenBuffer = NULL;
 	}
 
-	BufferSize = VideoGetCurrentModeResolutionX() * VideoGetBytesPerScanLine();
+	BufferSize = MachVideoGetBufferSize();
 
 	VideoOffScreenBuffer = MmAllocateMemory(BufferSize);
 

freeldr/freeldr/video
vidmode.c removed after 1.4
diff -N vidmode.c
--- vidmode.c	19 Jan 2003 01:04:01 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,313 +0,0 @@
-/*
- *  FreeLoader
- *  Copyright (C) 1998-2003  Brian Palmer  <brianp@sginet.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-	
-#include <freeldr.h>
-#include <video.h>
-#include <debug.h>
-#include <portio.h>
-
-U32						CurrentVideoMode		= VIDEOMODE_NORMAL_TEXT;
-U32						VideoResolutionX		= 80;
-U32						VideoResolutionY		= 25;
-U32						VideoBytesPerScanLine	= 0;	// Number of bytes per scan line
-U32						CurrentModeType			= MODETYPE_TEXT;
-BOOL					VesaVideoMode			= FALSE;
-
-SVGA_MODE_INFORMATION	VesaVideoModeInformation;
-
-BOOL VideoSetMode(U32 VideoMode)
-{
-	CurrentMemoryBank = 0;
-
-	// Set the values for the default text modes
-	// If they are setting a graphics mode then
-	// these values will be changed.
-	CurrentVideoMode = VideoMode;
-	VideoResolutionX = 80;
-	VideoResolutionY = 25;
-	VideoBytesPerScanLine = 160;
-	CurrentModeType = MODETYPE_TEXT;
-	VesaVideoMode = FALSE;
-
-	switch (VideoMode)
-	{
-	case VIDEOMODE_NORMAL_TEXT:
-	case 0x03: /* BIOS 80x25 text mode number */
-		return VideoSetMode80x25();
-	case VIDEOMODE_EXTENDED_TEXT:
-		return VideoSetMode80x50_80x43();
-	case VIDEOMODE_80X28:
-		return VideoSetMode80x28();
-	case VIDEOMODE_80X30:
-		return VideoSetMode80x30();
-	case VIDEOMODE_80X34:
-		return VideoSetMode80x34();
-	case VIDEOMODE_80X43:
-		return VideoSetMode80x43();
-	case VIDEOMODE_80X60:
-		return VideoSetMode80x60();
-	}
-
-	if (VideoMode == 0x12)
-	{
-		// 640x480x16
-		BiosSetVideoMode(VideoMode);
-		//WRITE_PORT_USHORT((U16*)0x03CE, 0x0205); // For some reason this is necessary?
-		WRITE_PORT_USHORT((U16*)0x03CE, 0x0F01); // For some reason this is necessary?
-		VideoResolutionX = 640;
-		VideoResolutionY = 480;
-		VideoBytesPerScanLine = 80;
-		CurrentVideoMode = 0x12;
-		CurrentModeType = MODETYPE_GRAPHICS;
-
-		return TRUE;
-	}
-	else if (VideoMode == 0x13)
-	{
-		// 320x200x256
-		BiosSetVideoMode(VideoMode);
-		VideoResolutionX = 320;
-		VideoResolutionY = 200;
-		VideoBytesPerScanLine = 320;
-		CurrentVideoMode = 0x13;
-		CurrentModeType = MODETYPE_GRAPHICS;
-
-		return TRUE;
-	}
-	else if (VideoMode >= 0x0108 && VideoMode <= 0x010C)
-	{
-		// VESA Text Mode
-		if (!BiosVesaGetSVGAModeInformation(VideoMode, &VesaVideoModeInformation))
-		{
-			return FALSE;
-		}
-
-		if (!BiosVesaSetVideoMode(VideoMode))
-		{
-			return FALSE;
-		}
-
-		VideoResolutionX = VesaVideoModeInformation.WidthInPixels;
-		VideoResolutionY = VesaVideoModeInformation.HeightInPixels;
-		VideoBytesPerScanLine = VesaVideoModeInformation.BytesPerScanLine;
-		CurrentVideoMode = VideoMode;
-		CurrentModeType = MODETYPE_TEXT;
-		VesaVideoMode = TRUE;
-
-		return TRUE;
-	}
-	else
-	{
-		// VESA Graphics Mode
-		if (!BiosVesaGetSVGAModeInformation(VideoMode, &VesaVideoModeInformation))
-		{
-			return FALSE;
-		}
-
-		if (!BiosVesaSetVideoMode(VideoMode))
-		{
-			return FALSE;
-		}
-
-		VideoResolutionX = VesaVideoModeInformation.WidthInPixels;
-		VideoResolutionY = VesaVideoModeInformation.HeightInPixels;
-		VideoBytesPerScanLine = VesaVideoModeInformation.BytesPerScanLine;
-		CurrentVideoMode = VideoMode;
-		CurrentModeType = MODETYPE_GRAPHICS;
-		VesaVideoMode = TRUE;
-
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
-BOOL VideoSetMode80x25(VOID)
-{
-	BiosSetVideoMode(0x03);
-	VideoResolutionX = 80;
-	VideoResolutionY = 25;
-
-	return TRUE;
-}
-
-BOOL VideoSetMode80x50_80x43(VOID)
-{
-	if (BiosDetectVideoCard() == VIDEOCARD_VGA)
-	{
-		BiosSetVideoMode(0x03);
-		BiosSetVideoFont8x8();
-		BiosSelectAlternatePrintScreen();
-		BiosDisableCursorEmulation();
-		BiosDefineCursor(6, 7);
-		VideoResolutionX = 80;
-		VideoResolutionY = 50;
-	}
-	else if (BiosDetectVideoCard() == VIDEOCARD_EGA)
-	{
-		BiosSetVideoMode(0x03);
-		BiosSetVideoFont8x8();
-		BiosSelectAlternatePrintScreen();
-		BiosDisableCursorEmulation();
-		BiosDefineCursor(6, 7);
-		VideoResolutionX = 80;
-		VideoResolutionY = 43;
-	}
-	else // VIDEOCARD_CGA_OR_OTHER
-	{
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-BOOL VideoSetMode80x28(VOID)
-{
-	// FIXME: Is this VGA-only?
-	VideoSetMode80x25();
-	BiosSetVideoFont8x14();
-	BiosDefineCursor(11, 12);
-	VideoResolutionX = 80;
-	VideoResolutionY = 28;
-
-	return TRUE;
-}
-
-BOOL VideoSetMode80x43(VOID)
-{
-	// FIXME: Is this VGA-only?
-	BiosSetVerticalResolution(VERTRES_350_SCANLINES);
-	VideoSetMode80x25();
-	BiosSetVideoFont8x8();
-	BiosSelectAlternatePrintScreen();
-	BiosDisableCursorEmulation();
-	BiosDefineCursor(6, 7);
-	VideoResolutionX = 80;
-	VideoResolutionY = 43;
-
-	return TRUE;
-}
-
-BOOL VideoSetMode80x30(VOID)
-{
-	// FIXME: Is this VGA-only?
-	VideoSetMode80x25();
-	BiosSet480ScanLines();
-	VideoResolutionX = 80;
-	VideoResolutionY = 30;
-
-	return TRUE;
-}
-
-BOOL VideoSetMode80x34(VOID)
-{
-	// FIXME: Is this VGA-only?
-	VideoSetMode80x25();
-	BiosSet480ScanLines();
-	BiosSetVideoFont8x14();
-	BiosDefineCursor(11, 12);
-	BiosSetVideoDisplayEnd();
-	VideoResolutionX = 80;
-	VideoResolutionY = 34;
-
-	return TRUE;
-}
-
-BOOL VideoSetMode80x60(VOID)
-{
-	// FIXME: Is this VGA-only?
-	VideoSetMode80x25();
-	BiosSet480ScanLines();
-	BiosSetVideoFont8x8();
-	BiosSelectAlternatePrintScreen();
-	BiosDisableCursorEmulation();
-	BiosDefineCursor(6, 7);
-	BiosSetVideoDisplayEnd();
-	VideoResolutionX = 80;
-	VideoResolutionY = 60;
-
-	return TRUE;
-}
-
-U32 VideoGetCurrentModeResolutionX(VOID)
-{
-	return VideoResolutionX;
-}
-
-U32 VideoGetCurrentModeResolutionY(VOID)
-{
-	return VideoResolutionY;
-}
-
-U32 VideoGetBytesPerScanLine(VOID)
-{
-	return VideoBytesPerScanLine;
-}
-
-U32 VideoGetCurrentMode(VOID)
-{
-	return CurrentVideoMode;
-}
-
-U32 VideoGetCurrentModeType(VOID)
-{
-	return CurrentModeType;
-}
-
-BOOL VideoIsCurrentModeVesa(VOID)
-{
-	return VesaVideoMode;
-}
-
-U32 VideoGetCurrentModeColorDepth(VOID)
-{
-	U32	ColorDepth = 2;
-	U32	i;
-
-	if (CurrentModeType == MODETYPE_TEXT)
-	{
-		return 0;
-	}
-	else // CurrentModeType == MODETYPE_GRAPHICS
-	{
-		// Calculate 2^BitsPerPixel'th power
-		for (i=0; i<(VesaVideoModeInformation.BitsPerPixel-1); i++)
-		{
-			ColorDepth *= 2;
-		}
-
-		// This algorithm works great for 24-bit & 8-bit color modes
-		// but 15-bit color modes really use 16 bits per pixel.
-		// So check to see if green has an extra bit, if so then
-		// it is 16-bit, if not it is 15-bit
-		if (ColorDepth == 65536)
-		{
-			if (VesaVideoModeInformation.GreenMaskSize == 6)
-			{
-				return ColorDepth;
-			}
-			else
-			{
-				return 32768;
-			}
-		}
-
-		return ColorDepth;
-	}
-}
CVSspam 0.2.8