@elfish_rider: k.A. frag joachim_neu ^^
@all:
ich habe nun mein treiber soweit, dass ich rechtecke malen kann etc. sogar mit den richtigen farben ^^
hier meine video.c:
/*
;
;---------------------------------------------------------------+
; .__ __ ¦
;______ |__|___________ _/ |_ ____ ______ ¦
;\____ \| \_ __ \__ \\ __\ ______ / _ \/ ___/ ¦
;| |_> > || | \// __ \| | /_____/ ( <_> )___ \ ¦
;| __/|__||__| (____ /__| \____/____ > ¦
;|__| \/ \/ ¦
;---------------------------------------------------------------+
;
;[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();
DrawRectangle(50, 50, 500, 300, 0x00FFFFFF, 0x00000000);
DrawRectangle(100, 100, 300, 500, 0x00FFFFFF, 0x00000000);
};
/********************************************/
/* 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] = B;
VideoMem[++pos] = G;
VideoMem[++pos] = R;
break;
case 32:
VideoMem[pos] = A;
VideoMem[++pos] = B;
VideoMem[++pos] = G;
VideoMem[++pos] = R;
break;
};
};
void DrawLine (unsigned long _x1, unsigned long _y1, unsigned long _x2, unsigned long _y2, unsigned long _RGB)
{
unsigned long tmpWidth = (_x2 > _x1)?(_x2 - _x1):(_x1 - _x2);
unsigned long tmpHeight = (_y2 > _y1)?(_y2 - _y1):(_y1 - _y2);
unsigned long i = 0;
if (tmpHeight == 0)
{
for (;i<=tmpWidth; i++)
{
DrawPixel(_x1+i, _y1, _RGB);
}
return;
}
if (tmpWidth == 0)
{
for (;i<=tmpHeight; i++)
{
DrawPixel(_x1, _y1+i, _RGB);
}
return;
}
};
void DrawRectangle (unsigned long _x1, unsigned long _y1, unsigned long _x2, unsigned long _y2, unsigned long _LineRGB, unsigned long _FillRGB)
{
DrawLine(_x1, _y1, _x2, _y1, _LineRGB); //left to right; up
DrawLine(_x1, _y2, _x2, _y2, _LineRGB); //left to right; down
DrawLine(_x1, _y1, _x1, _y2, _LineRGB); //up to down; left
DrawLine(_x2, _y1, _x2, _y2, _LineRGB); //up to down; right
unsigned tmpHeight = _y2-_y1;
unsigned tmpWidth = _x2-_x1;
unsigned i = 1, u = 1;
for (;i < tmpHeight; i++)
{
for (u = 1; u < tmpWidth; u++)
{
DrawPixel (_x1+u, _y1+i, _FillRGB);
}
}
};
hoffe es hilft jemandem...