Add UI support on the Xbox

svn path=/trunk/; revision=11661
This commit is contained in:
Gé van Geldorp
2004-11-14 22:04:39 +00:00
parent b055a01bc8
commit 4e5131fd86
35 changed files with 1923 additions and 1672 deletions
+10 -6
View File
@@ -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
-267
View File
@@ -22,273 +22,6 @@
#include <rtl.h>
#include <portio.h>
int kbhit(void)
{
REGS Regs;
// Int 16h AH=01h
// KEYBOARD - CHECK FOR KEYSTROKE
//
// AH = 01h
// Return:
// ZF set if no keystroke available
// ZF clear if keystroke available
// AH = BIOS scan code
// AL = ASCII character
Regs.b.ah = 0x01;
Int386(0x16, &Regs, &Regs);
if (Regs.x.eflags & I386FLAG_ZF)
{
return 0;
}
return 1;
}
int getch(void)
{
REGS Regs;
static BOOL ExtendedKey = FALSE;
static char ExtendedScanCode = 0;
// If the last time we were called an
// extended key was pressed then return
// that keys scan code.
if (ExtendedKey)
{
ExtendedKey = FALSE;
return ExtendedScanCode;
}
// Int 16h AH=00h
// KEYBOARD - GET KEYSTROKE
//
// AH = 00h
// Return:
// AH = BIOS scan code
// AL = ASCII character
Regs.b.ah = 0x00;
Int386(0x16, &Regs, &Regs);
// Check for an extended keystroke
if (Regs.b.al == 0)
{
ExtendedKey = TRUE;
ExtendedScanCode = Regs.b.ah;
}
// Return keystroke
return Regs.b.al;
}
int getyear(void)
{
REGS Regs;
U16 Digit1;
U16 Digit2;
U16 Cent1;
U16 Cent2;
U16 Year;
// Some BIOSes, such es the 1998/07/25 system ROM
// in the Compaq Deskpro EP/SB, leave CF unchanged
// if successful, so CF should be cleared before
// calling this function.
__asm__ ("clc");
// Int 1Ah AH=04h
// TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
//
// AH = 04h
// CF clear to avoid bug
// Return:
// CF clear if successful
// CH = century (BCD)
// CL = year (BCD)
// DH = month (BCD)
// DL = day (BCD)
// CF set on error
Regs.b.ah = 0x04;
Int386(0x1A, &Regs, &Regs);
/* Convert from BCD to normal */
Digit1 = Regs.b.cl & 0x0F;
Digit2 = ((Regs.b.cl >> 4) & 0x0F) * 10;
Cent1 = Regs.b.ch & 0x0F;
Cent2 = ((Regs.b.ch >> 4) & 0x0F) * 10;
Year = Cent1 + Cent2;
Year *= 100;
Year += Digit1 + Digit2;
return Year;
}
int getday(void)
{
REGS Regs;
U16 Digit1;
U16 Digit2;
// Some BIOSes, such es the 1998/07/25 system ROM
// in the Compaq Deskpro EP/SB, leave CF unchanged
// if successful, so CF should be cleared before
// calling this function.
__asm__ ("clc");
// Int 1Ah AH=04h
// TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
//
// AH = 04h
// CF clear to avoid bug
// Return:
// CF clear if successful
// CH = century (BCD)
// CL = year (BCD)
// DH = month (BCD)
// DL = day (BCD)
// CF set on error
Regs.b.ah = 0x04;
Int386(0x1A, &Regs, &Regs);
/* Convert from BCD to normal */
Digit1 = Regs.b.dl & 0x0F;
Digit2 = ((Regs.b.dl >> 4) & 0x0F) * 10;
return (Digit1 + Digit2);
}
int getmonth(void)
{
REGS Regs;
U16 Digit1;
U16 Digit2;
// Some BIOSes, such es the 1998/07/25 system ROM
// in the Compaq Deskpro EP/SB, leave CF unchanged
// if successful, so CF should be cleared before
// calling this function.
__asm__ ("clc");
// Int 1Ah AH=04h
// TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
//
// AH = 04h
// CF clear to avoid bug
// Return:
// CF clear if successful
// CH = century (BCD)
// CL = year (BCD)
// DH = month (BCD)
// DL = day (BCD)
// CF set on error
Regs.b.ah = 0x04;
Int386(0x1A, &Regs, &Regs);
/* Convert from BCD to normal */
Digit1 = Regs.b.dh & 0x0F;
Digit2 = ((Regs.b.dh >> 4) & 0x0F) * 10;
return (Digit1 + Digit2);
}
int gethour(void)
{
REGS Regs;
U16 Digit1;
U16 Digit2;
// Some BIOSes leave CF unchanged if successful,
// so CF should be cleared before calling this function.
__asm__ ("clc");
// Int 1Ah AH=02h
// TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
//
// AH = 02h
// CF clear to avoid bug
// Return:
// CF clear if successful
// CH = hour (BCD)
// CL = minutes (BCD)
// DH = seconds (BCD)
// DL = daylight savings flag (00h standard time, 01h daylight time)
// CF set on error (i.e. clock not running or in middle of update)
Regs.b.ah = 0x02;
Int386(0x1A, &Regs, &Regs);
/* Convert from BCD to normal */
Digit1 = Regs.b.ch & 0x0F;
Digit2 = ((Regs.b.ch >> 4) & 0x0F) * 10;
return (Digit1 + Digit2);
}
int getminute(void)
{
REGS Regs;
U16 Digit1;
U16 Digit2;
// Some BIOSes leave CF unchanged if successful,
// so CF should be cleared before calling this function.
__asm__ ("clc");
// Int 1Ah AH=02h
// TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
//
// AH = 02h
// CF clear to avoid bug
// Return:
// CF clear if successful
// CH = hour (BCD)
// CL = minutes (BCD)
// DH = seconds (BCD)
// DL = daylight savings flag (00h standard time, 01h daylight time)
// CF set on error (i.e. clock not running or in middle of update)
Regs.b.ah = 0x02;
Int386(0x1A, &Regs, &Regs);
/* Convert from BCD to normal */
Digit1 = Regs.b.cl & 0x0F;
Digit2 = ((Regs.b.cl >> 4) & 0x0F) * 10;
return (Digit1 + Digit2);
}
int getsecond(void)
{
REGS Regs;
U16 Digit1;
U16 Digit2;
// Some BIOSes leave CF unchanged if successful,
// so CF should be cleared before calling this function.
__asm__ ("clc");
// Int 1Ah AH=02h
// TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
//
// AH = 02h
// CF clear to avoid bug
// Return:
// CF clear if successful
// CH = hour (BCD)
// CL = minutes (BCD)
// DH = seconds (BCD)
// DL = daylight savings flag (00h standard time, 01h daylight time)
// CF set on error (i.e. clock not running or in middle of update)
Regs.b.ah = 0x02;
Int386(0x1A, &Regs, &Regs);
/* Convert from BCD to normal */
Digit1 = Regs.b.dh & 0x0F;
Digit2 = ((Regs.b.dh >> 4) & 0x0F) * 10;
return (Digit1 + Digit2);
}
void beep(void)
{
sound(700);
+2 -2
View File
@@ -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
-556
View File
@@ -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;
}
+18 -4
View File
@@ -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 */
+18 -3
View File
@@ -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 */
+16 -4
View File
@@ -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;
}
+18 -4
View File
@@ -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 */
+56 -21
View File
@@ -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 */
+107
View File
@@ -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 */
File diff suppressed because it is too large Load Diff
+78
View File
@@ -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 */
+85
View File
@@ -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 */
+79 -44
View File
@@ -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 */
+4 -3
View File
@@ -35,6 +35,7 @@
#include <drivemap.h>
#include <keycodes.h>
#include <cmdline.h>
#include <machine.h>
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;
}
+21 -10
View File
@@ -29,6 +29,7 @@
#include <linux.h>
#include <reactos.h>
#include <drivemap.h>
#include <machine.h>
UCHAR BootDrivePrompt[] = "Enter the boot drive.\n\nExamples:\nfd0 - first floppy drive\nhd0 - first hard drive\nhd1 - second hard drive\ncd0 - first CD-ROM drive.\n\nBIOS drive numbers may also be used:\n0 - first floppy drive\n0x80 - first hard drive\n0x81 - second hard drive";
@@ -78,7 +79,8 @@ 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))
+1 -1
View File
@@ -95,7 +95,7 @@ VOID DebugPrintChar(UCHAR Character)
}
else
{
MachPutChar(Character);
MachConsPutChar(Character);
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ VOID BootMain(char *CmdLine)
if (!MmInitializeMemoryManager())
{
printf("Press any key to reboot.\n");
getch();
MachConsGetCh();
return;
}
+41 -7
View File
@@ -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_ */
-9
View File
@@ -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);
+13 -147
View File
@@ -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);
+2 -1
View File
@@ -22,6 +22,7 @@
#include <rtl.h>
#include <mm.h>
#include <debug.h>
#include <machine.h>
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;
}
+104 -13
View File
@@ -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 */
+7 -6
View File
@@ -23,6 +23,7 @@
#include <rtl.h>
#include <debug.h>
#include <ui.h>
#include <machine.h>
#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
+2 -2
View File
@@ -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 */
+6 -6
View File
@@ -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);
+30 -33
View File
@@ -27,15 +27,15 @@
#include <inifile.h>
#include <version.h>
#include <video.h>
#include <machine.h>
PVOID TextVideoBuffer = NULL;
BOOL TuiInitialize(VOID)
{
VideoClearScreen();
VideoHideTextCursor();
BiosVideoDisableBlinkBit();
MachVideoClearScreen(ATTR(COLOR_WHITE, COLOR_BLACK));
MachVideoHideShowTextCursor(FALSE);
TextVideoBuffer = VideoAllocateOffScreenBuffer();
if (TextVideoBuffer == NULL)
@@ -54,13 +54,11 @@ 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);
+11 -8
View File
@@ -24,14 +24,16 @@
#include "keycodes.h"
#include <options.h>
#include <mm.h>
#include <machine.h>
#include <video.h>
BOOL TuiDisplayMenu(PUCHAR MenuItemList[], U32 MenuItemCount, U32 DefaultMenuItem, S32 MenuTimeOut, U32* SelectedMenuItem, BOOL CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter)
{
TUI_MENU_INFO MenuInformation;
U32 CurrentClockSecond;
U32 KeyPress;
U32 LastClockSecond;
U32 CurrentClockSecond;
U32 KeyPress;
//
// The first thing we need to check is the timeout
@@ -69,7 +71,7 @@ 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
+39 -80
View File
@@ -22,17 +22,14 @@
#include "tui.h"
#include <rtl.h>
#include <mm.h>
#include <machine.h>
#include <debug.h>
#include <inifile.h>
#include <version.h>
#include <video.h>
#define DISPLAYMODE_TEXT 0
#define DISPLAYMODE_GRAPHICS 1
U32 UiScreenWidth = 80; // Screen Width
U32 UiScreenHeight = 25; // Screen Height
U32 UiScreenWidth = 80; // Screen Width
U32 UiScreenHeight = 25; // Screen Height
UCHAR UiStatusBarFgColor = COLOR_BLACK; // Status bar foreground color
UCHAR UiStatusBarBgColor = COLOR_CYAN; // Status bar background color
@@ -55,7 +52,7 @@ 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);
}
+4 -38
View File
@@ -22,8 +22,10 @@
#include <comm.h>
#include <rtl.h>
#include <debug.h>
#include <machine.h>
#if 0 /* This stuff isn't used and as far as I'm concerned it can go - GvG */
U32 CurrentMemoryBank = 0;
VOID VideoSetMemoryBank(U16 BankNumber)
@@ -108,45 +110,9 @@ 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<BanksToCopy; CurrentBank++)
{
VideoSetMemoryBank(CurrentBank);
RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, VideoOffScreenBuffer, BankSize);
}
// Copy the remaining bytes into the last bank
VideoSetMemoryBank(CurrentBank);
RtlCopyMemory((PVOID)VIDEOVGA_MEM_ADDRESS, VideoOffScreenBuffer, BytesInLastBank);
}
// BIOS graphics mode
else
{
UNIMPLEMENTED();
}
MachVideoCopyOffScreenBufferToVRAM(VideoOffScreenBuffer);
}
+9 -9
View File
@@ -19,7 +19,7 @@
#include <freeldr.h>
#include <video.h>
#include <portio.h>
#include <machine.h>
#define RGB_MAX 64
@@ -29,11 +29,11 @@ VOID VideoSetAllColorsToBlack(U32 ColorCount)
{
U32 Color;
VideoWaitForVerticalRetrace();
MachVideoSync();
for (Color=0; Color<ColorCount; Color++)
{
VideoSetPaletteColor(Color, 0, 0, 0);
MachVideoSetPaletteColor(Color, 0, 0, 0);
}
}
@@ -48,7 +48,7 @@ VOID VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount)
for (Color=0; Color<ColorCount; Color++)
{
VideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
MachVideoGetPaletteColor(Color, &PaletteColors[Color].Red, &PaletteColors[Color].Green, &PaletteColors[Color].Blue);
// Increment each color so it approaches its real value
if (PaletteColors[Color].Red < Palette[Color].Red)
@@ -84,10 +84,10 @@ VOID VideoFadeIn(PPALETTE_ENTRY Palette, U32 ColorCount)
{
if ((Color % RGB_MAX_PER_ITERATION) == 0)
{
VideoWaitForVerticalRetrace();
MachVideoSync();
}
VideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
MachVideoSetPaletteColor(Color, PaletteColors[Color].Red, PaletteColors[Color].Green, PaletteColors[Color].Blue);
}
}
}
@@ -106,10 +106,10 @@ VOID VideoFadeOut(U32 ColorCount)
{
if ((Color % RGB_MAX_PER_ITERATION) == 0)
{
VideoWaitForVerticalRetrace();
MachVideoSync();
}
VideoGetPaletteColor(Color, &Red, &Green, &Blue);
MachVideoGetPaletteColor(Color, &Red, &Green, &Blue);
if (Red > 0)
{
@@ -124,7 +124,7 @@ VOID VideoFadeOut(U32 ColorCount)
Blue--;
}
VideoSetPaletteColor(Color, Red, Green, Blue);
MachVideoSetPaletteColor(Color, Red, Green, Blue);
}
}
}
+4 -21
View File
@@ -19,24 +19,7 @@
#include <freeldr.h>
#include <video.h>
#include <portio.h>
VOID VideoSetPaletteColor(U8 Color, U8 Red, U8 Green, U8 Blue)
{
WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_WRITE, Color);
WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA, Red);
WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA, Green);
WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA, Blue);
}
VOID VideoGetPaletteColor(U8 Color, U8* Red, U8* Green, U8* Blue)
{
WRITE_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_READ, Color);
*Red = READ_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA);
*Green = READ_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA);
*Blue = READ_PORT_UCHAR((U8*)VIDEOPORT_PALETTE_DATA);
}
#include <machine.h>
VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
{
@@ -44,7 +27,7 @@ VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
for (Color=0; Color<ColorCount; Color++)
{
VideoGetPaletteColor(Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
MachVideoGetPaletteColor(Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue);
}
}
@@ -52,10 +35,10 @@ VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, U32 ColorCount)
{
U32 Color;
VideoWaitForVerticalRetrace();
MachVideoSync();
for (Color=0; Color<ColorCount; Color++)
{
VideoSetPaletteColor(Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
MachVideoSetPaletteColor(Color, Palette[Color].Red, Palette[Color].Green, Palette[Color].Blue);
}
}
+26 -28
View File
@@ -21,11 +21,11 @@
#include <video.h>
#include <portio.h>
#include <debug.h>
#include <machine.h>
#if 0 /* This stuff isn't used and as far as I'm concerned it can go - GvG */
//
// Arrrggh!
// I really really hate 16 color bit plane modes.
@@ -230,26 +230,24 @@ VOID VideoSetPixelRGB_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
+2 -25
View File
@@ -21,34 +21,11 @@
#include <video.h>
#include <portio.h>
#include <mm.h>
#include <machine.h>
PVOID VideoOffScreenBuffer = NULL;
VOID VideoClearScreen(VOID)
{
VideoSetMode(VideoGetCurrentMode());
}
VOID VideoWaitForVerticalRetrace(VOID)
{
while ((READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08) == 1)
{
// Keep reading the port until bit 3 is clear
// This waits for the current retrace to end and
// we can catch the next one so we know we are
// getting a full retrace.
}
while ((READ_PORT_UCHAR((U8*)VIDEOPORT_VERTICAL_RETRACE) & 0x08) == 0)
{
// Keep reading the port until bit 3 is set
// Now that we know we aren't doing a vertical
// retrace we need to wait for the next one.
}
}
PVOID VideoAllocateOffScreenBuffer(VOID)
{
U32 BufferSize;
@@ -59,7 +36,7 @@ PVOID VideoAllocateOffScreenBuffer(VOID)
VideoOffScreenBuffer = NULL;
}
BufferSize = VideoGetCurrentModeResolutionX() * VideoGetBytesPerScanLine();
BufferSize = MachVideoGetBufferSize();
VideoOffScreenBuffer = MmAllocateMemory(BufferSize);
-313
View File
@@ -1,313 +0,0 @@
/*
* FreeLoader
* Copyright (C) 1998-2003 Brian Palmer <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <freeldr.h>
#include <video.h>
#include <debug.h>
#include <portio.h>
U32 CurrentVideoMode = VIDEOMODE_NORMAL_TEXT;
U32 VideoResolutionX = 80;
U32 VideoResolutionY = 25;
U32 VideoBytesPerScanLine = 0; // Number of bytes per scan line
U32 CurrentModeType = MODETYPE_TEXT;
BOOL VesaVideoMode = FALSE;
SVGA_MODE_INFORMATION VesaVideoModeInformation;
BOOL VideoSetMode(U32 VideoMode)
{
CurrentMemoryBank = 0;
// Set the values for the default text modes
// If they are setting a graphics mode then
// these values will be changed.
CurrentVideoMode = VideoMode;
VideoResolutionX = 80;
VideoResolutionY = 25;
VideoBytesPerScanLine = 160;
CurrentModeType = MODETYPE_TEXT;
VesaVideoMode = FALSE;
switch (VideoMode)
{
case VIDEOMODE_NORMAL_TEXT:
case 0x03: /* BIOS 80x25 text mode number */
return VideoSetMode80x25();
case VIDEOMODE_EXTENDED_TEXT:
return VideoSetMode80x50_80x43();
case VIDEOMODE_80X28:
return VideoSetMode80x28();
case VIDEOMODE_80X30:
return VideoSetMode80x30();
case VIDEOMODE_80X34:
return VideoSetMode80x34();
case VIDEOMODE_80X43:
return VideoSetMode80x43();
case VIDEOMODE_80X60:
return VideoSetMode80x60();
}
if (VideoMode == 0x12)
{
// 640x480x16
BiosSetVideoMode(VideoMode);
//WRITE_PORT_USHORT((U16*)0x03CE, 0x0205); // For some reason this is necessary?
WRITE_PORT_USHORT((U16*)0x03CE, 0x0F01); // For some reason this is necessary?
VideoResolutionX = 640;
VideoResolutionY = 480;
VideoBytesPerScanLine = 80;
CurrentVideoMode = 0x12;
CurrentModeType = MODETYPE_GRAPHICS;
return TRUE;
}
else if (VideoMode == 0x13)
{
// 320x200x256
BiosSetVideoMode(VideoMode);
VideoResolutionX = 320;
VideoResolutionY = 200;
VideoBytesPerScanLine = 320;
CurrentVideoMode = 0x13;
CurrentModeType = MODETYPE_GRAPHICS;
return TRUE;
}
else if (VideoMode >= 0x0108 && VideoMode <= 0x010C)
{
// VESA Text Mode
if (!BiosVesaGetSVGAModeInformation(VideoMode, &VesaVideoModeInformation))
{
return FALSE;
}
if (!BiosVesaSetVideoMode(VideoMode))
{
return FALSE;
}
VideoResolutionX = VesaVideoModeInformation.WidthInPixels;
VideoResolutionY = VesaVideoModeInformation.HeightInPixels;
VideoBytesPerScanLine = VesaVideoModeInformation.BytesPerScanLine;
CurrentVideoMode = VideoMode;
CurrentModeType = MODETYPE_TEXT;
VesaVideoMode = TRUE;
return TRUE;
}
else
{
// VESA Graphics Mode
if (!BiosVesaGetSVGAModeInformation(VideoMode, &VesaVideoModeInformation))
{
return FALSE;
}
if (!BiosVesaSetVideoMode(VideoMode))
{
return FALSE;
}
VideoResolutionX = VesaVideoModeInformation.WidthInPixels;
VideoResolutionY = VesaVideoModeInformation.HeightInPixels;
VideoBytesPerScanLine = VesaVideoModeInformation.BytesPerScanLine;
CurrentVideoMode = VideoMode;
CurrentModeType = MODETYPE_GRAPHICS;
VesaVideoMode = TRUE;
return TRUE;
}
return FALSE;
}
BOOL VideoSetMode80x25(VOID)
{
BiosSetVideoMode(0x03);
VideoResolutionX = 80;
VideoResolutionY = 25;
return TRUE;
}
BOOL VideoSetMode80x50_80x43(VOID)
{
if (BiosDetectVideoCard() == VIDEOCARD_VGA)
{
BiosSetVideoMode(0x03);
BiosSetVideoFont8x8();
BiosSelectAlternatePrintScreen();
BiosDisableCursorEmulation();
BiosDefineCursor(6, 7);
VideoResolutionX = 80;
VideoResolutionY = 50;
}
else if (BiosDetectVideoCard() == VIDEOCARD_EGA)
{
BiosSetVideoMode(0x03);
BiosSetVideoFont8x8();
BiosSelectAlternatePrintScreen();
BiosDisableCursorEmulation();
BiosDefineCursor(6, 7);
VideoResolutionX = 80;
VideoResolutionY = 43;
}
else // VIDEOCARD_CGA_OR_OTHER
{
return FALSE;
}
return TRUE;
}
BOOL VideoSetMode80x28(VOID)
{
// FIXME: Is this VGA-only?
VideoSetMode80x25();
BiosSetVideoFont8x14();
BiosDefineCursor(11, 12);
VideoResolutionX = 80;
VideoResolutionY = 28;
return TRUE;
}
BOOL VideoSetMode80x43(VOID)
{
// FIXME: Is this VGA-only?
BiosSetVerticalResolution(VERTRES_350_SCANLINES);
VideoSetMode80x25();
BiosSetVideoFont8x8();
BiosSelectAlternatePrintScreen();
BiosDisableCursorEmulation();
BiosDefineCursor(6, 7);
VideoResolutionX = 80;
VideoResolutionY = 43;
return TRUE;
}
BOOL VideoSetMode80x30(VOID)
{
// FIXME: Is this VGA-only?
VideoSetMode80x25();
BiosSet480ScanLines();
VideoResolutionX = 80;
VideoResolutionY = 30;
return TRUE;
}
BOOL VideoSetMode80x34(VOID)
{
// FIXME: Is this VGA-only?
VideoSetMode80x25();
BiosSet480ScanLines();
BiosSetVideoFont8x14();
BiosDefineCursor(11, 12);
BiosSetVideoDisplayEnd();
VideoResolutionX = 80;
VideoResolutionY = 34;
return TRUE;
}
BOOL VideoSetMode80x60(VOID)
{
// FIXME: Is this VGA-only?
VideoSetMode80x25();
BiosSet480ScanLines();
BiosSetVideoFont8x8();
BiosSelectAlternatePrintScreen();
BiosDisableCursorEmulation();
BiosDefineCursor(6, 7);
BiosSetVideoDisplayEnd();
VideoResolutionX = 80;
VideoResolutionY = 60;
return TRUE;
}
U32 VideoGetCurrentModeResolutionX(VOID)
{
return VideoResolutionX;
}
U32 VideoGetCurrentModeResolutionY(VOID)
{
return VideoResolutionY;
}
U32 VideoGetBytesPerScanLine(VOID)
{
return VideoBytesPerScanLine;
}
U32 VideoGetCurrentMode(VOID)
{
return CurrentVideoMode;
}
U32 VideoGetCurrentModeType(VOID)
{
return CurrentModeType;
}
BOOL VideoIsCurrentModeVesa(VOID)
{
return VesaVideoMode;
}
U32 VideoGetCurrentModeColorDepth(VOID)
{
U32 ColorDepth = 2;
U32 i;
if (CurrentModeType == MODETYPE_TEXT)
{
return 0;
}
else // CurrentModeType == MODETYPE_GRAPHICS
{
// Calculate 2^BitsPerPixel'th power
for (i=0; i<(VesaVideoModeInformation.BitsPerPixel-1); i++)
{
ColorDepth *= 2;
}
// This algorithm works great for 24-bit & 8-bit color modes
// but 15-bit color modes really use 16 bits per pixel.
// So check to see if green has an extra bit, if so then
// it is 16-bit, if not it is 15-bit
if (ColorDepth == 65536)
{
if (VesaVideoModeInformation.GreenMaskSize == 6)
{
return ColorDepth;
}
else
{
return 32768;
}
}
return ColorDepth;
}
}