mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Correctly configure palette registers
svn path=/trunk/; revision=1857
This commit is contained in:
parent
4167bc8912
commit
6be44d6e81
2 changed files with 119 additions and 21 deletions
|
@ -2,28 +2,93 @@
|
|||
#include <debug.h>
|
||||
#include "vgavideo.h"
|
||||
|
||||
void outxay(USHORT ad, UCHAR x, UCHAR y)
|
||||
{
|
||||
USHORT xy = (x << 8) + y;
|
||||
|
||||
VideoPortWritePortUshort((PUSHORT)ad, xy);
|
||||
}
|
||||
|
||||
void setMode(VideoMode mode)
|
||||
{
|
||||
unsigned char x;
|
||||
unsigned int y, c, a, m, n;
|
||||
|
||||
VideoPortWritePortUchar((PUCHAR)MISC, mode.Misc);
|
||||
VideoPortWritePortUchar((PUCHAR)STATUS, 0);
|
||||
VideoPortWritePortUchar((PUCHAR)FEATURE, mode.Feature);
|
||||
|
||||
for(x=0; x<5; x++)
|
||||
{
|
||||
outxay(SEQ, mode.Seq[x], x);
|
||||
}
|
||||
|
||||
VideoPortWritePortUshort((PUSHORT)CRTC, 0x11);
|
||||
VideoPortWritePortUshort((PUSHORT)CRTC, (mode.Crtc[0x11] & 0x7f));
|
||||
|
||||
for(x=0; x<25; x++)
|
||||
{
|
||||
outxay(CRTC, mode.Crtc[x], x);
|
||||
}
|
||||
|
||||
for(x=0; x<9; x++)
|
||||
{
|
||||
outxay(GRAPHICS, mode.Gfx[x], x);
|
||||
}
|
||||
|
||||
x=VideoPortReadPortUchar((PUCHAR)FEATURE);
|
||||
|
||||
for(x=0; x<21; x++)
|
||||
{
|
||||
VideoPortWritePortUchar((PUCHAR)ATTRIB, x);
|
||||
VideoPortWritePortUchar((PUCHAR)ATTRIB, mode.Attrib[x]);
|
||||
}
|
||||
|
||||
x=VideoPortReadPortUchar((PUCHAR)STATUS);
|
||||
|
||||
VideoPortWritePortUchar((PUCHAR)ATTRIB, 0x20);
|
||||
}
|
||||
|
||||
VideoMode Mode12 = {
|
||||
0xa000, 0xe3, 0x00,
|
||||
|
||||
{0x03, 0x01, 0x0f, 0x00, 0x06 },
|
||||
|
||||
{0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x59, 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
|
||||
0xff},
|
||||
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff},
|
||||
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
|
||||
0x0c, 0x0d, 0x0e, 0x0f, 0x81, 0x00, 0x0f, 0x00, 0x00}
|
||||
};
|
||||
|
||||
void InitVGAMode()
|
||||
{
|
||||
int i;
|
||||
VIDEO_X86_BIOS_ARGUMENTS vxba;
|
||||
VP_STATUS vps;
|
||||
int i;
|
||||
VIDEO_X86_BIOS_ARGUMENTS vxba;
|
||||
VP_STATUS vps;
|
||||
|
||||
// FIXME: Use Vidport to map the memory properly
|
||||
vidmem = (char *)(0xd0000000 + 0xa0000);
|
||||
memset(&vxba, 0, sizeof(vxba));
|
||||
vxba.Eax = 0x0012;
|
||||
vps = VideoPortInt10(NULL, &vxba);
|
||||
// FIXME: Use Vidport to map the memory properly
|
||||
vidmem = (char *)(0xd0000000 + 0xa0000);
|
||||
memset(&vxba, 0, sizeof(vxba));
|
||||
vxba.Eax = 0x0012;
|
||||
vps = VideoPortInt10(NULL, &vxba);
|
||||
|
||||
// Get the VGA into the mode we want to work with
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // Set
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3cf,0); // the MASK
|
||||
WRITE_PORT_USHORT((PUSHORT)0x3ce,0x0205); // write mode = 2 (bits 0,1) read mode = 0 (bit 3)
|
||||
i = READ_REGISTER_UCHAR(vidmem); // Update bit buffer
|
||||
WRITE_REGISTER_UCHAR(vidmem, 0); // Write the pixel
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08);
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3cf,0xff);
|
||||
// Get VGA registers into the correct state (mainly for setting up the palette registers correctly)
|
||||
setMode(Mode12);
|
||||
|
||||
vgaPreCalc();
|
||||
// Get the VGA into the mode we want to work with
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08); // Set
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3cf,0); // the MASK
|
||||
WRITE_PORT_USHORT((PUSHORT)0x3ce,0x0205); // write mode = 2 (bits 0,1) read mode = 0 (bit 3)
|
||||
i = READ_REGISTER_UCHAR(vidmem); // Update bit buffer
|
||||
WRITE_REGISTER_UCHAR(vidmem, 0); // Write the pixel
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3ce,0x08);
|
||||
WRITE_PORT_UCHAR((PUCHAR)0x3cf,0xff);
|
||||
|
||||
vgaPreCalc();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ VOID VGAQueryNumAvailModes(OUT PVIDEO_NUM_MODES NumberOfModes,
|
|||
VOID VGAResetDevice(OUT PSTATUS_BLOCK StatusBlock);
|
||||
VOID VGASetColorRegisters(IN PVIDEO_CLUT ColorLookUpTable,
|
||||
OUT PSTATUS_BLOCK StatusBlock);
|
||||
VOID VGASetPaletteRegisters(IN PWORD PaletteRegisters,
|
||||
OUT PSTATUS_BLOCK StatusBlock);
|
||||
VOID VGASetCurrentMode(IN PVIDEO_MODE RequestedMode,
|
||||
OUT PSTATUS_BLOCK StatusBlock);
|
||||
VOID VGAShareVideoMemory(IN PVIDEO_SHARE_MEMORY RequestedMemory,
|
||||
|
@ -125,6 +127,7 @@ VGAFindAdapter(PVOID DeviceExtension,
|
|||
{
|
||||
/* FIXME: Determine if the adapter is present */
|
||||
*Again = FALSE;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* FIXME: Claim any necessary memory/IO resources for the adapter */
|
||||
|
@ -261,6 +264,10 @@ VGAStartIO(PVOID DeviceExtension,
|
|||
VGAUnshareVideoMemory((PVIDEO_MEMORY) RequestPacket->InputBuffer,
|
||||
&RequestPacket->StatusBlock);
|
||||
break;
|
||||
case IOCTL_VIDEO_SET_PALETTE_REGISTERS:
|
||||
VGASetPaletteRegisters((PVIDEO_CLUT) RequestPacket->InputBuffer,
|
||||
&RequestPacket->StatusBlock);
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case IOCTL_VIDEO_DISABLE_CURSOR:
|
||||
|
@ -294,7 +301,6 @@ VGAStartIO(PVOID DeviceExtension,
|
|||
case IOCTL_VIDEO_SAVE_HARDWARE_STATE:
|
||||
case IOCTL_VIDEO_SET_CURSOR_ATTR:
|
||||
case IOCTL_VIDEO_SET_CURSOR_POSITION:
|
||||
case IOCTL_VIDEO_SET_PALETTE_REGISTERS:
|
||||
case IOCTL_VIDEO_SET_POINTER_ATTR:
|
||||
case IOCTL_VIDEO_SET_POINTER_POSITION:
|
||||
case IOCTL_VIDEO_SET_POWER_MANAGEMENT:
|
||||
|
@ -389,15 +395,42 @@ VOID VGAQueryNumAvailModes(OUT PVIDEO_NUM_MODES NumberOfModes,
|
|||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
VOID VGASetPaletteRegisters(IN PWORD PaletteRegisters,
|
||||
OUT PSTATUS_BLOCK StatusBlock)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
||||
/*
|
||||
We don't need the following code because the palette registers are set correctly on VGA initialization.
|
||||
Still, we may include\test this is in the future.
|
||||
|
||||
int i, j = 2;
|
||||
char tmp, v;
|
||||
|
||||
tmp = VideoPortReadPortUchar(0x03da);
|
||||
v = VideoPortReadPortUchar(0x03c0);
|
||||
|
||||
// Set the first 16 palette registers to map to the first 16 palette colors
|
||||
for (i=PaletteRegisters[1]; i<PaletteRegisters[0]; i++)
|
||||
{
|
||||
tmp = VideoPortReadPortUchar(0x03da);
|
||||
VideoPortWritePortUchar(0x03c0, i);
|
||||
VideoPortWritePortUchar(0x03c0, PaletteRegisters[j++]);
|
||||
}
|
||||
|
||||
tmp = VideoPortReadPortUchar(0x03da);
|
||||
VideoPortWritePortUchar(0x03d0, v | 0x20);
|
||||
*/
|
||||
}
|
||||
|
||||
VOID VGASetColorRegisters(IN PVIDEO_CLUT ColorLookUpTable,
|
||||
OUT PSTATUS_BLOCK StatusBlock)
|
||||
{
|
||||
int i;
|
||||
|
||||
VideoPortWritePortUchar(0x03c8, ColorLookUpTable->FirstEntry);
|
||||
|
||||
for (i=0; i<ColorLookUpTable->NumEntries; i++)
|
||||
for (i=ColorLookUpTable->FirstEntry; i<ColorLookUpTable->NumEntries; i++)
|
||||
{
|
||||
VideoPortWritePortUchar(0x03c8, i);
|
||||
VideoPortWritePortUchar(0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Red);
|
||||
VideoPortWritePortUchar(0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Green);
|
||||
VideoPortWritePortUchar(0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Blue);
|
||||
|
|
Loading…
Reference in a new issue