From 4e5131fd86f219078de0da997017622ca2846c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Sun, 14 Nov 2004 22:04:39 +0000 Subject: [PATCH] Add UI support on the Xbox svn path=/trunk/; revision=11661 --- freeldr/freeldr/Makefile | 16 +- freeldr/freeldr/arch/i386/i386rtl.c | 267 ------ freeldr/freeldr/arch/i386/i386trap.S | 4 +- freeldr/freeldr/arch/i386/i386vid.c | 556 ------------- freeldr/freeldr/arch/i386/machpc.c | 22 +- freeldr/freeldr/arch/i386/machpc.h | 21 +- freeldr/freeldr/arch/i386/machxbox.c | 20 +- freeldr/freeldr/arch/i386/machxbox.h | 22 +- freeldr/freeldr/arch/i386/pccons.c | 77 +- freeldr/freeldr/arch/i386/pcrtc.c | 107 +++ freeldr/freeldr/arch/i386/pcvideo.c | 1109 +++++++++++++++++++++++++ freeldr/freeldr/arch/i386/xboxcons.c | 78 ++ freeldr/freeldr/arch/i386/xboxrtc.c | 85 ++ freeldr/freeldr/arch/i386/xboxvideo.c | 123 ++- freeldr/freeldr/bootmgr.c | 7 +- freeldr/freeldr/custom.c | 31 +- freeldr/freeldr/debug.c | 2 +- freeldr/freeldr/freeldr.c | 2 +- freeldr/freeldr/include/machine.h | 48 +- freeldr/freeldr/include/rtl.h | 9 - freeldr/freeldr/include/video.h | 160 +--- freeldr/freeldr/inifile/parse.c | 3 +- freeldr/freeldr/machine.c | 117 ++- freeldr/freeldr/mm/mm.c | 13 +- freeldr/freeldr/reactos/setupldr.c | 4 +- freeldr/freeldr/rtl/print.c | 12 +- freeldr/freeldr/ui/tui.c | 63 +- freeldr/freeldr/ui/tuimenu.c | 19 +- freeldr/freeldr/ui/ui.c | 119 +-- freeldr/freeldr/video/bank.c | 42 +- freeldr/freeldr/video/fade.c | 18 +- freeldr/freeldr/video/palette.c | 25 +- freeldr/freeldr/video/pixel.c | 54 +- freeldr/freeldr/video/video.c | 27 +- freeldr/freeldr/video/vidmode.c | 313 ------- 35 files changed, 1923 insertions(+), 1672 deletions(-) create mode 100644 freeldr/freeldr/arch/i386/pcrtc.c create mode 100644 freeldr/freeldr/arch/i386/pcvideo.c create mode 100644 freeldr/freeldr/arch/i386/xboxcons.c create mode 100644 freeldr/freeldr/arch/i386/xboxrtc.c delete mode 100644 freeldr/freeldr/video/vidmode.c diff --git a/freeldr/freeldr/Makefile b/freeldr/freeldr/Makefile index f6adc2783b2..aefd1ab6dc4 100644 --- a/freeldr/freeldr/Makefile +++ b/freeldr/freeldr/Makefile @@ -135,7 +135,7 @@ else ############################################# # 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 @@ ARCH_OBJS = fathelp.o \ 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 @@ INIFILE_OBJS= inifile.o \ 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 diff --git a/freeldr/freeldr/arch/i386/i386rtl.c b/freeldr/freeldr/arch/i386/i386rtl.c index 661554ba638..281ffa37901 100644 --- a/freeldr/freeldr/arch/i386/i386rtl.c +++ b/freeldr/freeldr/arch/i386/i386rtl.c @@ -22,273 +22,6 @@ #include #include -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); diff --git a/freeldr/freeldr/arch/i386/i386trap.S b/freeldr/freeldr/arch/i386/i386trap.S index 1a0ebe1f9d2..c8b132b647a 100644 --- a/freeldr/freeldr/arch/i386/i386trap.S +++ b/freeldr/freeldr/arch/i386/i386trap.S @@ -273,7 +273,7 @@ i386CommonExceptionHandler: SAVE_CPU_REGS pushl $SCREEN_ATTR - call _MachClearScreenAttr + call _MachVideoClearScreen add $4,%esp movl $i386ExceptionHandlerText,%esi @@ -485,7 +485,7 @@ i386PrintChar: pushl $SCREEN_ATTR andl $0xff,%eax pushl %eax - call _MachPutCharAttrAtLoc + call _MachVideoPutChar addl $16,%esp ret diff --git a/freeldr/freeldr/arch/i386/i386vid.c b/freeldr/freeldr/arch/i386/i386vid.c index 5586d2c9dad..59f5af2652f 100644 --- a/freeldr/freeldr/arch/i386/i386vid.c +++ b/freeldr/freeldr/arch/i386/i386vid.c @@ -90,59 +90,6 @@ typedef struct // 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 @@ VOID BiosSetVideoFont8x16(VOID) 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 @@ U32 VideoGetTextCursorPositionY(VOID) 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 @@ U16 BiosIsVesaSupported(VOID) 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; -} diff --git a/freeldr/freeldr/arch/i386/machpc.c b/freeldr/freeldr/arch/i386/machpc.c index c7a57f3faef..624a6e12b8f 100644 --- a/freeldr/freeldr/arch/i386/machpc.c +++ b/freeldr/freeldr/arch/i386/machpc.c @@ -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 @@ PcMachInit(VOID) 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 */ diff --git a/freeldr/freeldr/arch/i386/machpc.h b/freeldr/freeldr/arch/i386/machpc.h index 4c4c280ee52..5be6d435399 100644 --- a/freeldr/freeldr/arch/i386/machpc.h +++ b/freeldr/freeldr/arch/i386/machpc.h @@ -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 PcDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_TA 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 */ diff --git a/freeldr/freeldr/arch/i386/machxbox.c b/freeldr/freeldr/arch/i386/machxbox.c index 45276b3505b..6f584ab250f 100644 --- a/freeldr/freeldr/arch/i386/machxbox.c +++ b/freeldr/freeldr/arch/i386/machxbox.c @@ -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 @@ XboxMachInit(VOID) 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; } diff --git a/freeldr/freeldr/arch/i386/machxbox.h b/freeldr/freeldr/arch/i386/machxbox.h index 68a6167ce35..d570f2f54a7 100644 --- a/freeldr/freeldr/arch/i386/machxbox.h +++ b/freeldr/freeldr/arch/i386/machxbox.h @@ -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 @@ U8 XboxFont8x16[256 * 16]; 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 XboxDiskGetPartitionEntry(U32 DriveNumber, U32 PartitionNumber, PPARTITION_ 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 */ diff --git a/freeldr/freeldr/arch/i386/pccons.c b/freeldr/freeldr/arch/i386/pccons.c index 201ef29bd61..6ae015a7a69 100644 --- a/freeldr/freeldr/arch/i386/pccons.c +++ b/freeldr/freeldr/arch/i386/pccons.c @@ -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 * @@ -30,21 +30,6 @@ #define TEXT_COLS 80 #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) { @@ -86,13 +71,63 @@ PcConsPutChar(int Ch) Int386(0x10, &Regs, &Regs); } -VOID -PcConsPutCharAttrAtLoc(int Ch, U8 Attr, unsigned X, unsigned Y) +BOOL +PcConsKbHit(VOID) { - U16 *BufPtr; + REGS Regs; - BufPtr = (U16 *) (TEXTMODE_BUFFER + (Y * TEXT_COLS + X) * 2); - *BufPtr = ((U16) Attr << 8) | (Ch & 0xff); + /* 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) +{ + 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; + } + + /* Return keystroke */ + return Regs.b.al; } /* EOF */ diff --git a/freeldr/freeldr/arch/i386/pcrtc.c b/freeldr/freeldr/arch/i386/pcrtc.c new file mode 100644 index 00000000000..56808247ead --- /dev/null +++ b/freeldr/freeldr/arch/i386/pcrtc.c @@ -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 */ diff --git a/freeldr/freeldr/arch/i386/pcvideo.c b/freeldr/freeldr/arch/i386/pcvideo.c new file mode 100644 index 00000000000..2b10daf68b8 --- /dev/null +++ b/freeldr/freeldr/arch/i386/pcvideo.c @@ -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); + } +} + +VOID +PcVideoCopyOffScreenBufferToVRAM(PVOID Buffer) +{ + U32 BanksToCopy; + U32 BytesInLastBank; + U32 CurrentBank; + U32 BankSize; + + /* PcVideoWaitForVerticalRetrace(); */ + + /* Text mode (BIOS or VESA) */ + if (VideoTextMode == DisplayMode) + { + RtlCopyMemory((PVOID) VIDEOTEXT_MEM_ADDRESS, Buffer, PcVideoGetBufferSize()); + } + /* VESA graphics mode */ + else if (VideoGraphicsMode == DisplayMode && VesaVideoMode) + { + 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++) + { + PcVideoSetMemoryBank(CurrentBank); + RtlCopyMemory((PVOID) VIDEOVGA_MEM_ADDRESS, (char *) Buffer + CurrentBank * BankSize, BankSize); + } + + /* Copy the remaining bytes into the last bank */ + PcVideoSetMemoryBank(CurrentBank); + RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, (char *) Buffer + CurrentBank * BankSize, BytesInLastBank); + } + /* BIOS graphics mode */ + else + { + UNIMPLEMENTED(); + } +} + +VOID +PcVideoClearScreen(U8 Attr) +{ + U16 AttrChar; + U16 *BufPtr; + + AttrChar = ((U16) Attr << 8) | ' '; + for (BufPtr = (U16 *) VIDEOTEXT_MEM_ADDRESS; + BufPtr < (U16 *) (VIDEOTEXT_MEM_ADDRESS + VIDEOTEXT_MEM_SIZE); + BufPtr++) + { + *BufPtr = AttrChar; + } +} + +VOID +PcVideoPutChar(int Ch, U8 Attr, unsigned X, unsigned Y) +{ + U16 *BufPtr; + + BufPtr = (U16 *) (VIDEOTEXT_MEM_ADDRESS + (Y * BytesPerScanLine + X) * 2); + *BufPtr = ((U16) Attr << 8) | (Ch & 0xff); +} + +BOOL +PcVideoIsPaletteFixed(VOID) +{ + return FALSE; +} + +VOID +PcVideoSetPaletteColor(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 +PcVideoGetPaletteColor(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); +} + +VOID +PcVideoSync(VOID) +{ + while (1 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08)) + { + /* + * 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 (0 == (READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08)) + { + /* + * 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. + */ + } +} + +/* EOF */ diff --git a/freeldr/freeldr/arch/i386/xboxcons.c b/freeldr/freeldr/arch/i386/xboxcons.c new file mode 100644 index 00000000000..fbacc60e092 --- /dev/null +++ b/freeldr/freeldr/arch/i386/xboxcons.c @@ -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 */ diff --git a/freeldr/freeldr/arch/i386/xboxrtc.c b/freeldr/freeldr/arch/i386/xboxrtc.c new file mode 100644 index 00000000000..a1149982c83 --- /dev/null +++ b/freeldr/freeldr/arch/i386/xboxrtc.c @@ -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 */ diff --git a/freeldr/freeldr/arch/i386/xboxvideo.c b/freeldr/freeldr/arch/i386/xboxvideo.c index 542091e599e..ad1278cdaea 100644 --- a/freeldr/freeldr/arch/i386/xboxvideo.c +++ b/freeldr/freeldr/arch/i386/xboxvideo.c @@ -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 ScreenHeight; 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 @@ XboxVideoAttrToColors(U8 Attr, U32 *FgColor, U32 *BgColor) } static VOID -XboxVideoClearScreen(U32 Color, BOOL FullScreen) +XboxVideoClearScreenColor(U32 Color, BOOL FullScreen) { U32 Line, Col; PU32 p; @@ -107,45 +102,17 @@ XboxVideoClearScreen(U32 Color, BOOL FullScreen) } VOID -XboxVideoClearScreenAttr(U8 Attr) +XboxVideoClearScreen(U8 Attr) { U32 FgColor, BgColor; XboxVideoAttrToColors(Attr, &FgColor, &BgColor); - XboxVideoClearScreen(BgColor, FALSE); + XboxVideoClearScreenColor(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++; - } -} - -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 @@ XboxVideoInit(VOID) 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 */ diff --git a/freeldr/freeldr/bootmgr.c b/freeldr/freeldr/bootmgr.c index 764a4edc4a4..ffdbde98932 100644 --- a/freeldr/freeldr/bootmgr.c +++ b/freeldr/freeldr/bootmgr.c @@ -35,6 +35,7 @@ #include #include #include +#include VOID RunLoader(VOID) @@ -52,21 +53,21 @@ VOID RunLoader(VOID) 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; } diff --git a/freeldr/freeldr/custom.c b/freeldr/freeldr/custom.c index 9fef01311e3..f3899ba86a7 100644 --- a/freeldr/freeldr/custom.c +++ b/freeldr/freeldr/custom.c @@ -29,6 +29,7 @@ #include #include #include +#include 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 @@ VOID OptionMenuCustomBootDisk(VOID) { 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 @@ VOID OptionMenuCustomBootDisk(VOID) } // 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 @@ VOID OptionMenuCustomBootPartition(VOID) 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 @@ VOID OptionMenuCustomBootPartition(VOID) } // 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 @@ VOID OptionMenuCustomBootBootSectorFile(VOID) 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 @@ VOID OptionMenuCustomBootBootSectorFile(VOID) } // 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 @@ VOID OptionMenuCustomBootReactOS(VOID) 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 @@ VOID OptionMenuCustomBootReactOS(VOID) } // 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 @@ VOID OptionMenuCustomBootLinux(VOID) 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 @@ VOID OptionMenuCustomBootLinux(VOID) } // 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)) diff --git a/freeldr/freeldr/debug.c b/freeldr/freeldr/debug.c index 88017ab79d9..abd8ec38aab 100644 --- a/freeldr/freeldr/debug.c +++ b/freeldr/freeldr/debug.c @@ -95,7 +95,7 @@ VOID DebugPrintChar(UCHAR Character) } else { - MachPutChar(Character); + MachConsPutChar(Character); } } diff --git a/freeldr/freeldr/freeldr.c b/freeldr/freeldr/freeldr.c index 91529e1bde5..d1a6b5675de 100644 --- a/freeldr/freeldr/freeldr.c +++ b/freeldr/freeldr/freeldr.c @@ -40,7 +40,7 @@ VOID BootMain(char *CmdLine) if (!MmInitializeMemoryManager()) { printf("Press any key to reboot.\n"); - getch(); + MachConsGetCh(); return; } diff --git a/freeldr/freeldr/include/machine.h b/freeldr/freeldr/include/machine.h index 20df83c1960..97ab8ddd91e 100644 --- a/freeldr/freeldr/include/machine.h +++ b/freeldr/freeldr/include/machine.h @@ -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 @@ typedef struct tagMACHVTBL 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_ */ diff --git a/freeldr/freeldr/include/rtl.h b/freeldr/freeldr/include/rtl.h index 4c23daf1259..8fd5384b5af 100644 --- a/freeldr/freeldr/include/rtl.h +++ b/freeldr/freeldr/include/rtl.h @@ -72,15 +72,6 @@ int isxdigit(int c); 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); diff --git a/freeldr/freeldr/include/video.h b/freeldr/freeldr/include/video.h index dfc2fe19d18..f269c2530db 100644 --- a/freeldr/freeldr/include/video.h +++ b/freeldr/freeldr/include/video.h @@ -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); diff --git a/freeldr/freeldr/inifile/parse.c b/freeldr/freeldr/inifile/parse.c index 329b197893e..f490b1d733c 100644 --- a/freeldr/freeldr/inifile/parse.c +++ b/freeldr/freeldr/inifile/parse.c @@ -22,6 +22,7 @@ #include #include #include +#include PINI_SECTION IniFileSectionListHead = NULL; @@ -125,7 +126,7 @@ BOOL IniParseFile(PUCHAR IniFileData, U32 IniFileSize) { 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; } diff --git a/freeldr/freeldr/machine.c b/freeldr/freeldr/machine.c index af6b2092d48..4b155050cce 100644 --- a/freeldr/freeldr/machine.c +++ b/freeldr/freeldr/machine.c @@ -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() { - MachVtbl.PutChar(Ch); + return MachVtbl.ConsKbHit(); } -void -MachPutCharAttrAtLoc(int Ch, U8 Attr, unsigned X, unsigned Y) +int +MachConsGetCh() { - MachVtbl.PutCharAttrAtLoc(Ch, Attr, X, Y); + 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.VideoPutChar(Ch, Attr, X, Y); +} + +VOID +MachVideoCopyOffScreenBufferToVRAM(PVOID Buffer) +{ + 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 @@ MachDiskGetCacheableBlockCount(U32 DriveNumber) 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 */ diff --git a/freeldr/freeldr/mm/mm.c b/freeldr/freeldr/mm/mm.c index a087b6e425e..1eb5bfdd971 100644 --- a/freeldr/freeldr/mm/mm.c +++ b/freeldr/freeldr/mm/mm.c @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef DEBUG @@ -377,25 +378,25 @@ VOID MemAllocTest(VOID) 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 diff --git a/freeldr/freeldr/reactos/setupldr.c b/freeldr/freeldr/reactos/setupldr.c index 05e8cca6417..fcb488ed0bc 100644 --- a/freeldr/freeldr/reactos/setupldr.c +++ b/freeldr/freeldr/reactos/setupldr.c @@ -285,7 +285,7 @@ VOID RunLoader(VOID) #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 @@ for(;;); 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 */ diff --git a/freeldr/freeldr/rtl/print.c b/freeldr/freeldr/rtl/print.c index 0b73a68b5a0..da31d665ba4 100644 --- a/freeldr/freeldr/rtl/print.c +++ b/freeldr/freeldr/rtl/print.c @@ -29,7 +29,7 @@ void print(char *str) int i; for (i = 0; i < strlen(str); i++) - MachPutChar(str[i]); + MachConsPutChar(str[i]); } /* @@ -48,7 +48,7 @@ void printf(char *format, ... ) { if (c != '%') { - MachPutChar(c); + MachConsPutChar(c); } else { @@ -77,22 +77,22 @@ void printf(char *format, ... ) 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); diff --git a/freeldr/freeldr/ui/tui.c b/freeldr/freeldr/ui/tui.c index 6a8d7eb926e..68bae1c99c9 100644 --- a/freeldr/freeldr/ui/tui.c +++ b/freeldr/freeldr/ui/tui.c @@ -27,15 +27,15 @@ #include #include #include +#include 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 @@ VOID TuiUnInitialize(VOID) } 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 TuiDrawStatusText(PUCHAR StatusText) 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 @@ VOID TuiUpdateDateTime(VOID) 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 @@ VOID TuiUpdateDateTime(VOID) { Hour = 12; } - Minute = getminute(); - Second = getsecond(); itoa(Hour, TempString, 10); strcpy(TimeString, " "); strcat(TimeString, TempString); @@ -584,11 +581,11 @@ VOID TuiMessageBoxCritical(PUCHAR MessageText) 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 @@ VOID TuiFadeInBackdrop(VOID) { PPALETTE_ENTRY TuiFadePalette = NULL; - if (UiUseSpecialEffects) + if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed()) { TuiFadePalette = (PPALETTE_ENTRY)MmAllocateMemory(sizeof(PALETTE_ENTRY) * 64); @@ -732,7 +729,7 @@ VOID TuiFadeInBackdrop(VOID) // 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 @@ VOID TuiFadeOut(VOID) { PPALETTE_ENTRY TuiFadePalette = NULL; - if (UiUseSpecialEffects) + if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed()) { TuiFadePalette = (PPALETTE_ENTRY)MmAllocateMemory(sizeof(PALETTE_ENTRY) * 64); @@ -753,14 +750,14 @@ VOID TuiFadeOut(VOID) } } - 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 @@ BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length) // 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 @@ BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length) 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 @@ BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length) UiDrawText(EditBoxStartX, EditBoxLine, &EditTextBuffer[EditBoxTextDisplayIndex], ATTR(UiEditBoxTextColor, UiEditBoxBgColor)); // Move the cursor - VideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine); + MachVideoSetTextCursorPosition(EditBoxCursorX, EditBoxLine); TuiUpdateDateTime(); @@ -923,7 +920,7 @@ BOOL TuiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length) } // Hide the cursor again - VideoHideTextCursor(); + MachVideoHideShowTextCursor(FALSE); // Restore the screen contents TuiRestoreScreen(ScreenBuffer); diff --git a/freeldr/freeldr/ui/tuimenu.c b/freeldr/freeldr/ui/tuimenu.c index d0d971b3b85..b7ab4debcfa 100644 --- a/freeldr/freeldr/ui/tuimenu.c +++ b/freeldr/freeldr/ui/tuimenu.c @@ -24,14 +24,16 @@ #include "keycodes.h" #include #include +#include #include 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 @@ BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuIte // // Get the current second of time // - CurrentClockSecond = getsecond(); + MachRTCGetCurrentDateTime(NULL, NULL, NULL, NULL, NULL, &LastClockSecond); // // Process keys @@ -104,12 +106,13 @@ BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuIte 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 @@ U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCal // // Check for a keypress // - if (kbhit()) + if (MachConsKbHit()) { // // Cancel the timeout @@ -353,13 +356,13 @@ U32 TuiProcessMenuKeyboardEvent(PTUI_MENU_INFO MenuInfo, UiMenuKeyPressFilterCal // // 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 diff --git a/freeldr/freeldr/ui/ui.c b/freeldr/freeldr/ui/ui.c index f8e17da13c2..8767d04bf9a 100644 --- a/freeldr/freeldr/ui/ui.c +++ b/freeldr/freeldr/ui/ui.c @@ -22,17 +22,14 @@ #include "tui.h" #include #include +#include #include #include #include #include - -#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 @@ UCHAR UiTitleBoxTitleText[260] = "Boot Menu"; // Title box's title text 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 @@ UCHAR UiMonthNames[12][15] = { "January ", "February ", "March ", "April ", "May 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 @@ BOOL UiInitialize(VOID) } } - 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 @@ BOOL UiInitialize(VOID) UNIMPLEMENTED(); //if (!GuiInitialize()) //{ - // VideoSetMode(VIDEOMODE_NORMAL_TEXT); + // MachSetDisplayMode(NULL, FALSE); // return FALSE; //} } @@ -238,7 +197,7 @@ VOID UiUnInitialize(PUCHAR BootText) UiDrawStatusText("Booting..."); UiInfoBox(BootText); - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { TuiUnInitialize(); } @@ -251,7 +210,7 @@ VOID UiUnInitialize(PUCHAR BootText) VOID UiDrawBackdrop(VOID) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { TuiDrawBackdrop(); } @@ -264,7 +223,7 @@ VOID UiDrawBackdrop(VOID) 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 UiFillArea(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR FillChar, UCHAR 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 UiDrawShadow(U32 Left, U32 Top, U32 Right, U32 Bottom) 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 UiDrawBox(U32 Left, U32 Top, U32 Right, U32 Bottom, UCHAR VertStyle, UCHAR 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 UiDrawText(U32 X, U32 Y, PUCHAR Text, UCHAR Attr) 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 UiDrawCenteredText(U32 Left, U32 Top, U32 Right, U32 Bottom, PUCHAR TextStr VOID UiDrawStatusText(PUCHAR StatusText) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { TuiDrawStatusText(StatusText); } @@ -342,7 +301,7 @@ VOID UiDrawStatusText(PUCHAR StatusText) VOID UiUpdateDateTime(VOID) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { TuiUpdateDateTime(); } @@ -424,11 +383,11 @@ VOID UiMessageBox(PUCHAR MessageText) { 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 @@ VOID UiMessageBoxCritical(PUCHAR MessageText) { 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 @@ VOID UiMessageBoxCritical(PUCHAR MessageText) UCHAR UiTextToColor(PUCHAR ColorText) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { return TuiTextToColor(ColorText); } @@ -480,7 +439,7 @@ UCHAR UiTextToColor(PUCHAR ColorText) UCHAR UiTextToFillStyle(PUCHAR FillStyleText) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { return TuiTextToFillStyle(FillStyleText); } @@ -494,7 +453,7 @@ UCHAR UiTextToFillStyle(PUCHAR FillStyleText) VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { TuiDrawProgressBarCenter(Position, Range, ProgressText); } @@ -507,7 +466,7 @@ VOID UiDrawProgressBarCenter(U32 Position, U32 Range, PUCHAR ProgressText) 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 @@ VOID UiTruncateStringEllipsis(PUCHAR StringText, U32 MaxChars) 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 @@ BOOL UiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem VOID UiFadeInBackdrop(VOID) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { TuiFadeInBackdrop(); } @@ -625,7 +584,7 @@ VOID UiFadeInBackdrop(VOID) VOID UiFadeOut(VOID) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { TuiFadeOut(); } @@ -638,7 +597,7 @@ VOID UiFadeOut(VOID) BOOL UiEditBox(PUCHAR MessageText, PUCHAR EditTextBuffer, U32 Length) { - if (UiDisplayMode == DISPLAYMODE_TEXT) + if (VideoTextMode == UiDisplayMode) { return TuiEditBox(MessageText, EditTextBuffer, Length); } diff --git a/freeldr/freeldr/video/bank.c b/freeldr/freeldr/video/bank.c index 91859f4b4dc..70bff1bf156 100644 --- a/freeldr/freeldr/video/bank.c +++ b/freeldr/freeldr/video/bank.c @@ -22,8 +22,10 @@ #include #include #include +#include +#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 @@ U32 VideoGetOffScreenMemoryOffsetForPixel(U32 X, U32 Y) 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 #include -#include +#include #define RGB_MAX 64 @@ -29,11 +29,11 @@ VOID VideoSetAllColorsToBlack(U32 ColorCount) { U32 Color; - VideoWaitForVerticalRetrace(); + MachVideoSync(); for (Color=0; Color 0) { @@ -124,7 +124,7 @@ VOID VideoFadeOut(U32 ColorCount) Blue--; } - VideoSetPaletteColor(Color, Red, Green, Blue); + MachVideoSetPaletteColor(Color, Red, Green, Blue); } } } diff --git a/freeldr/freeldr/video/palette.c b/freeldr/freeldr/video/palette.c index 1d077b4e1ed..0f8f9d66ead 100644 --- a/freeldr/freeldr/video/palette.c +++ b/freeldr/freeldr/video/palette.c @@ -19,24 +19,7 @@ #include #include -#include - - -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 VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount) { @@ -44,7 +27,7 @@ VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount) for (Color=0; Color #include #include +#include - - +#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_24Bit(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue) 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) { - // 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_16Bit(X, Y, Red, Green, Blue); + } + else if (Depth == 15) + { + 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_24Bit_OffScreen(U32 X, U32 Y, U8 Red, U8 Green, U8 Blue) 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) { - // 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_16Bit_OffScreen(X, Y, Red, Green, Blue); + } + else if (Depth == 15) + { + 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 diff --git a/freeldr/freeldr/video/video.c b/freeldr/freeldr/video/video.c index 6747a552ecd..aba38c7b212 100644 --- a/freeldr/freeldr/video/video.c +++ b/freeldr/freeldr/video/video.c @@ -21,34 +21,11 @@ #include #include #include +#include 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 @@ PVOID VideoAllocateOffScreenBuffer(VOID) VideoOffScreenBuffer = NULL; } - BufferSize = VideoGetCurrentModeResolutionX() * VideoGetBytesPerScanLine(); + BufferSize = MachVideoGetBufferSize(); VideoOffScreenBuffer = MmAllocateMemory(BufferSize); diff --git a/freeldr/freeldr/video/vidmode.c b/freeldr/freeldr/video/vidmode.c deleted file mode 100644 index b87934a5213..00000000000 --- a/freeldr/freeldr/video/vidmode.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer - * - * 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 -#include -#include -#include - -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; - } -}