Import backup from 2003-08-18_2
This commit is contained in:
parent
b0c1c492b2
commit
82cf9a9de4
@ -28,14 +28,13 @@
|
||||
#define YELLOW_TXT 0x0E
|
||||
#define BRWHITE_TXT 0x0F
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
|
||||
#define UCHAR unsigned char
|
||||
#define USHORT unsigned short
|
||||
#define UINT unsigned int
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
|
||||
|
||||
|
||||
|
69
kernel.c
69
kernel.c
@ -4,54 +4,13 @@
|
||||
|
||||
#include "k_defines.h"
|
||||
#include "functions.h"
|
||||
#include "video.h"
|
||||
|
||||
void isr(int num);
|
||||
void isr(dword num);
|
||||
void k_init();
|
||||
|
||||
#include "functions.c"
|
||||
|
||||
//9000:306
|
||||
|
||||
typedef struct{
|
||||
USHORT ModeAttributes;
|
||||
UCHAR WinAAttributes;
|
||||
UCHAR WinBAttributes;
|
||||
USHORT WinGranularity;
|
||||
USHORT WinSize;
|
||||
USHORT WinASegment;
|
||||
USHORT WinBSegment;
|
||||
UINT WinFuncPtr;
|
||||
USHORT BytesPerScanLine;
|
||||
|
||||
USHORT XResolution;
|
||||
USHORT YResolution;
|
||||
UCHAR XCharSize;
|
||||
UCHAR YCharSize;
|
||||
UCHAR NumberOfPlanes;
|
||||
UCHAR BitsPerPixel;
|
||||
UCHAR NumberOfBanks;
|
||||
UCHAR MemoryModel;
|
||||
UCHAR BankSize;
|
||||
UCHAR NumberOfImagePages;
|
||||
UCHAR Reserved1;
|
||||
|
||||
UCHAR RedMaskSize;
|
||||
UCHAR RedFieldPosition;
|
||||
UCHAR GreenMaskSize;
|
||||
UCHAR GreenFieldPosition;
|
||||
UCHAR BlueMaskSize;
|
||||
UCHAR BlueFieldPosition;
|
||||
UCHAR RsvdMaskSize;
|
||||
UCHAR RsvdFieldPosition;
|
||||
UCHAR DirectColorModeInfo;
|
||||
|
||||
dword PhysBasePtr;
|
||||
UINT OffScreenMemOffset;
|
||||
USHORT OffScreenMemSize;
|
||||
UCHAR Reserved[206];
|
||||
} ModeInfoBlock;
|
||||
|
||||
|
||||
#include "video.c"
|
||||
|
||||
|
||||
void k_init()
|
||||
@ -62,20 +21,16 @@ void k_init()
|
||||
outportb(0x40, 0x9c); //lsb
|
||||
outportb(0x40, 0x2e); //msb
|
||||
enable_ints();
|
||||
ModeInfoBlock *mib = (ModeInfoBlock *) 0x90306;
|
||||
UINT *vid = (UINT *) (mib->PhysBasePtr);
|
||||
UINT a;
|
||||
UINT tot = ((mib->XResolution) * (mib->YResolution));
|
||||
word step = 0x1000000 / tot; //step to increase color by for each pixel
|
||||
dword color = 0;
|
||||
for (a = 0; a < tot; a++)
|
||||
video_init((ModeInfoBlock *) 0x90306);
|
||||
int a;
|
||||
for (a=0;a<768;a+=10)
|
||||
{
|
||||
vid[a] = color;
|
||||
color += step;
|
||||
video_horiz(a, 2, 1021, 0);
|
||||
video_vert(a, 2, 765, 0x0000FFFF);
|
||||
}
|
||||
}
|
||||
|
||||
void isr(int num)
|
||||
void isr(dword num)
|
||||
{
|
||||
if (num == 0x20)
|
||||
{
|
||||
@ -83,5 +38,11 @@ void isr(int num)
|
||||
*(char*)0xB8001 = 7;
|
||||
eoi();
|
||||
}
|
||||
//if (num == 0x21)
|
||||
// restart();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
104
video.c
Normal file
104
video.c
Normal file
@ -0,0 +1,104 @@
|
||||
//video.c
|
||||
// 08/13/03 Josh Holtrop
|
||||
|
||||
ModeInfoBlock video_mode;
|
||||
byte *vid_ptr24;
|
||||
word *vid_ptr16;
|
||||
dword *vid_ptr32;
|
||||
|
||||
void video_init(ModeInfoBlock *mib)
|
||||
{
|
||||
video_mode = *mib;
|
||||
|
||||
switch(video_mode.BitsPerPixel)
|
||||
{
|
||||
case 16:
|
||||
vid_ptr16 = (word *) video_mode.PhysBasePtr;
|
||||
break;
|
||||
case 24:
|
||||
vid_ptr24 = (byte *) video_mode.PhysBasePtr;
|
||||
break;
|
||||
case 32:
|
||||
vid_ptr32 = (dword *) video_mode.PhysBasePtr;
|
||||
}
|
||||
|
||||
UINT tot = ((video_mode.XResolution) * (video_mode.YResolution));
|
||||
int a;
|
||||
for (a = 0; a < tot; a++)
|
||||
{
|
||||
if (a < (tot / 4))
|
||||
video_psetp(a, 0x00FF0000);
|
||||
else if (a < (tot / 2))
|
||||
video_psetp(a, 0x0000FF00);
|
||||
else if (a < ((tot * 3) / 4))
|
||||
video_psetp(a, 0x000000FF);
|
||||
else
|
||||
video_psetp(a, 0x00FFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
void video_horiz(int y, int x1, int x2, dword color)
|
||||
{
|
||||
checkBoundsy(y);
|
||||
checkBoundsx(x1);
|
||||
checkBoundsx(x2);
|
||||
if (x1 > x2)
|
||||
{
|
||||
int tmp = x2;
|
||||
x2 = x1;
|
||||
x1 = tmp;
|
||||
}
|
||||
int pixel = y*video_mode.XResolution+x1;
|
||||
int a;
|
||||
for (a = 0; a <= (x2-x1); a++)
|
||||
{
|
||||
video_psetp(pixel, color);
|
||||
pixel++;
|
||||
}
|
||||
}
|
||||
|
||||
void video_vert(int x, int y1, int y2, dword color)
|
||||
{
|
||||
checkBoundsx(x);
|
||||
checkBoundsy(y1);
|
||||
checkBoundsy(y2);
|
||||
if (y1 > y2)
|
||||
{
|
||||
int tmp = y2;
|
||||
y2 = y1;
|
||||
y1 = tmp;
|
||||
}
|
||||
int pixel = y1*video_mode.XResolution+x;
|
||||
int a;
|
||||
for (a = 0; a <= (y2-y1); a++)
|
||||
{
|
||||
video_psetp(pixel, color);
|
||||
pixel+=video_mode.XResolution;
|
||||
}
|
||||
}
|
||||
|
||||
inline void video_pset(int x, int y, dword color)
|
||||
{
|
||||
video_psetp(y*video_mode.XResolution+x, color);
|
||||
}
|
||||
|
||||
void video_psetp(int pixel, dword color)
|
||||
{
|
||||
switch(video_mode.BitsPerPixel)
|
||||
{
|
||||
case 16:
|
||||
vid_ptr16[pixel] = ((color&0xFF)>>3) | ((((color>>8)&0xFF)>>2)<<6) | ((((color>>16)&0xFF)>>3)<<11);
|
||||
//vid_ptr16[pixel] = ((color&0xFF)>>3) | ((((color>>8)&0xFF)>>3)<<5) | ((((color>>16)&0xFF)>>3)<<10);
|
||||
break;
|
||||
case 24:
|
||||
vid_ptr24[pixel] = (color>>16) & 0xFF;
|
||||
vid_ptr24[pixel+1] = (color>>8) & 0xFF;
|
||||
vid_ptr24[pixel+2] = color & 0xFF;
|
||||
break;
|
||||
case 32:
|
||||
vid_ptr32[pixel] = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
56
video.h
Normal file
56
video.h
Normal file
@ -0,0 +1,56 @@
|
||||
//video.h
|
||||
// 08/18/03 Josh Holtrop
|
||||
|
||||
void video_init();
|
||||
void video_horiz(int y, int x1, int x2, dword color);
|
||||
void video_vert(int x, int y1, int y2, dword color);
|
||||
inline void video_pset(int x, int y, dword color);
|
||||
void video_psetp(int pixel, dword color);
|
||||
|
||||
#define checkBoundsx(x) (x<0 ? x=0 : (x>=video_mode.XResolution ? x=video_mode.XResolution-1 : 0))
|
||||
#define checkBoundsy(x) (x<0 ? x=0 : (x>=video_mode.YResolution ? x=video_mode.YResolution-1 : 0))
|
||||
|
||||
typedef struct{
|
||||
USHORT ModeAttributes;
|
||||
UCHAR WinAAttributes;
|
||||
UCHAR WinBAttributes;
|
||||
USHORT WinGranularity;
|
||||
USHORT WinSize;
|
||||
USHORT WinASegment;
|
||||
USHORT WinBSegment;
|
||||
UINT WinFuncPtr;
|
||||
USHORT BytesPerScanLine;
|
||||
|
||||
USHORT XResolution;
|
||||
USHORT YResolution;
|
||||
UCHAR XCharSize;
|
||||
UCHAR YCharSize;
|
||||
UCHAR NumberOfPlanes;
|
||||
UCHAR BitsPerPixel;
|
||||
UCHAR NumberOfBanks;
|
||||
UCHAR MemoryModel;
|
||||
UCHAR BankSize;
|
||||
UCHAR NumberOfImagePages;
|
||||
UCHAR Reserved1;
|
||||
|
||||
UCHAR RedMaskSize;
|
||||
UCHAR RedFieldPosition;
|
||||
UCHAR GreenMaskSize;
|
||||
UCHAR GreenFieldPosition;
|
||||
UCHAR BlueMaskSize;
|
||||
UCHAR BlueFieldPosition;
|
||||
UCHAR RsvdMaskSize;
|
||||
UCHAR RsvdFieldPosition;
|
||||
UCHAR DirectColorModeInfo;
|
||||
|
||||
dword PhysBasePtr;
|
||||
UINT OffScreenMemOffset;
|
||||
USHORT OffScreenMemSize;
|
||||
UCHAR Reserved[206];
|
||||
} ModeInfoBlock;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user