Vesa Problems
Posted: Mon Mar 14, 2005 12:00 am
Hy
i have a lot of trouble whit my vesa 2.0 driver.
the problem is, that in a real pc the colour are different as those from bochs.
if i try to draw a pixel whit the colour 0x0011A8C6 bochs put the 0x00C6A8 colour out. ...
here is the code:
thx 4 helping
i have a lot of trouble whit my vesa 2.0 driver.
the problem is, that in a real pc the colour are different as those from bochs.
if i try to draw a pixel whit the colour 0x0011A8C6 bochs put the 0x00C6A8 colour out. ...
here is the code:
Code: Select all
/*
;
;---------------------------------------------------------------+
; .__ __ ?
;______ |__|___________ _/ |_ ____ ______ ?
;\____ \| \_ __ \__ \\ __\ ______ / _ \/ ___/ ?
;| |_> > || | \// __ \| | /_____/ ( <_> )___ \ ?
;| __/|__||__| (____ /__| \____/____ > ?
;|__| \/ \/ ?
;---------------------------------------------------------------+
;
;[1] Informations
;
; Last Modified: 25. Januar 2005
; Begin: 15. Juni 2004
; Version: 0.000
; Coder: z4ck
;
;
;[2] Tasks
;
; Task Done Coder
;----------------------------------------------------------------
; - [ 0%] z4ck
;----------------------------------------------------------------
; TOTAL [ 0%] z4ck
;================================================================
*/
#include <video.h>
#define VesaMode 0x118
/********************************************/
/* VbeModeInfoBlock Struktur */
/********************************************/
typedef struct {
unsigned short VbeModeModeAttributes;
unsigned char VbeModeWinAAttributes;
unsigned char VbeModeWinBAttributes;
unsigned short VbeModeWinGranularity;
unsigned short VbeModeWinSize;
unsigned short VbeModeWinASegment;
unsigned short VbeModeWinBSegment;
unsigned long VbeModeWinFuncPtr;
unsigned short VbeModeBytesPerScanLine;
unsigned short VbeModeXResolution;
unsigned short VbeModeYResolution;
unsigned char VbeModeXCharSize;
unsigned char VbeModeYCharSize;
unsigned char VbeModeNumberOfPlanes;
unsigned char VbeModeBitsPerPixel;
unsigned char VbeModeNumberOfBanks;
unsigned char VbeModeMemoryModel;
unsigned char VbeModeBankSize;
unsigned char VbeModeNumberOfImagePages;
unsigned char VbeModeReserved_page;
unsigned char VbeModeRedMaskSize;
unsigned char VbeModeRedMaskPos;
unsigned char VbeModeGreenMaskSize;
unsigned char VbeModeGreenMaskPos;
unsigned char VbeModeBlueMaskSize;
unsigned char VbeModeBlueMaskPos;
unsigned char VbeModeReservedMaskSize;
unsigned char VbeModeReservedMaskPos;
unsigned char VbeModeDirectColorModeInfo;
unsigned long VbeModePhysBasePtr;
unsigned long VbeModeOffScreenMemOffset;
unsigned short VbeModeOffScreenMemSize;
unsigned short VbeModeLinBytesPerScanLine;
unsigned char VbeModeBnkNumberOfPages;
unsigned char VbeModeLinNumberOfPages;
unsigned char VbeModeLinRedMaskSize;
unsigned char VbeModeLinRedFieldPos;
unsigned char VbeModeLinGreenMaskSize;
unsigned char VbeModeLinGreenFieldPos;
unsigned char VbeModeLinBlueMaskSize;
unsigned char VbeModeLinBlueFieldPos;
unsigned char VbeModeLinRsvdMaskSize;
unsigned char VbeModeLinRsvdFieldPos;
unsigned char VbeModeMaxPixelClock;
unsigned char VbeModeReserved[190];
} __attribute__ ((packed)) VbeModeInfoBlock;
/********************************************/
/* Global Vars */
/********************************************/
VbeModeInfoBlock *VbeMIB = (VbeModeInfoBlock *) 0x7e00; // This one ist set in kernel16.asm @ setvesa...
unsigned char *VideoMem; // saved in the VbeModeInfoBlock
/********************************************/
/* Screen Settings */
/********************************************/
unsigned long ScrWidth, ScrHeight;
unsigned char BitsPerPixel;
/********************************************/
/* COLORS */
/********************************************/
unsigned long BGColor = 0x0011A8C6;
unsigned long FontColor = 0x00FFFFFF;
unsigned long FontShadowColor = 0x00EEEEEE;
/********************************************/
/* Init the video */
/********************************************/
void SetupVideo()
{
ScrWidth = VbeMIB->VbeModeXResolution;
ScrHeight = VbeMIB->VbeModeYResolution;
BitsPerPixel = VbeMIB->VbeModeBitsPerPixel;
VideoMem = (unsigned char *)(VbeMIB->VbeModePhysBasePtr);
ClearScreen(); //Result: Color 0x00c6a8
DrawPixel(0, 0, 0x202020); //Result: Color 0x002020
VideoMem[(1*BitsPerPixel/8)]=0x11; //Result: COlor 0xc6a811
VideoMem[(1*BitsPerPixel/8)+1]=0xA8;
VideoMem[(1*BitsPerPixel/8)+2]=0xc6;
};
/********************************************/
/* Clear Screen whit BGColor */
/********************************************/
void ClearScreen ()
{
unsigned long i = 0;
for (;i < ScrHeight; i++)
{
unsigned long u = 0;
for (; u < ScrWidth; u++)
DrawPixel(u, i, BGColor);
};
};
void printf (char *_string, long _color)
{
};
void printc (char _character, long _color)
{
};
void Num2String(int _number)
{
};
/********************************************/
/* Draw a Pixel */
/********************************************/
void DrawPixel (unsigned long _x, unsigned long _y, unsigned long _RGB)
{
unsigned char A = _RGB >> 0x18; //Alpha
unsigned char R = (_RGB & 0x00FF0000) >> 0x10; //Red
unsigned char G = (_RGB & 0x0000FF00) >> 0x08; //Green
unsigned char B = (_RGB & 0x000000FF); //Blue
unsigned long pos = ((_y*ScrWidth)+_x)*(BitsPerPixel/8);
if (pos > (ScrWidth*ScrHeight*BitsPerPixel/8)) return;
switch(BitsPerPixel)
{
case 8:
case 16:
break;
case 24:
VideoMem[pos] = R;
VideoMem[pos++] = G;
VideoMem[pos++] = B;
break;
case 32:
VideoMem[pos] = A;
VideoMem[pos++] = R;
VideoMem[pos++] = G;
VideoMem[pos++] = B;
break;
};
};
/*
void DrawBMP (File *_file, int _x, int _y)
{
};
*/