Import backup from 2003-08-18_2

This commit is contained in:
Josh Holtrop 2003-08-18 22:01:00 -04:00
parent b0c1c492b2
commit 82cf9a9de4
5 changed files with 178 additions and 58 deletions

BIN
flop.img

Binary file not shown.

View File

@ -28,14 +28,13 @@
#define YELLOW_TXT 0x0E #define YELLOW_TXT 0x0E
#define BRWHITE_TXT 0x0F #define BRWHITE_TXT 0x0F
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned int dword;
#define UCHAR unsigned char #define UCHAR unsigned char
#define USHORT unsigned short #define USHORT unsigned short
#define UINT unsigned int #define UINT unsigned int
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned int dword;

View File

@ -4,54 +4,13 @@
#include "k_defines.h" #include "k_defines.h"
#include "functions.h" #include "functions.h"
#include "video.h"
void isr(int num); void isr(dword num);
void k_init(); void k_init();
#include "functions.c" #include "functions.c"
#include "video.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;
void k_init() void k_init()
@ -62,20 +21,16 @@ void k_init()
outportb(0x40, 0x9c); //lsb outportb(0x40, 0x9c); //lsb
outportb(0x40, 0x2e); //msb outportb(0x40, 0x2e); //msb
enable_ints(); enable_ints();
ModeInfoBlock *mib = (ModeInfoBlock *) 0x90306; video_init((ModeInfoBlock *) 0x90306);
UINT *vid = (UINT *) (mib->PhysBasePtr); int a;
UINT a; for (a=0;a<768;a+=10)
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++)
{ {
vid[a] = color; video_horiz(a, 2, 1021, 0);
color += step; video_vert(a, 2, 765, 0x0000FFFF);
} }
} }
void isr(int num) void isr(dword num)
{ {
if (num == 0x20) if (num == 0x20)
{ {
@ -83,5 +38,11 @@ void isr(int num)
*(char*)0xB8001 = 7; *(char*)0xB8001 = 7;
eoi(); eoi();
} }
//if (num == 0x21)
// restart();
} }

104
video.c Normal file
View 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
View 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;