From 82cf9a9de463d650fb74c3e85b4572c2089e7dd2 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 18 Aug 2003 22:01:00 -0400 Subject: [PATCH] Import backup from 2003-08-18_2 --- flop.img | Bin 1474560 -> 1474560 bytes k_defines.h | 7 ++-- kernel.c | 69 ++++++++-------------------------- video.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++ video.h | 56 ++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 58 deletions(-) create mode 100644 video.c create mode 100644 video.h diff --git a/flop.img b/flop.img index 4c3dbd6359c593261cb7b23a6ca51e5d3b5fe92f..35a29b54b1c6387cba2370aadac4a3229dd0f7d0 100644 GIT binary patch delta 1380 zcma)5&ubGw6n?w;(M__NX_^)*h(T!a2Ut)qp$986s23?{6)P$|SV|BSO$EicsauEc zgn%OA#Y2neRiPr@Bxz~&ru_?wC~Vvu0tN}Xy1v<6w-H-#4>R+=`R2`j-@I2Wjuwlf zFH-#-T>}7P&^6!Nf99n6sRN*C{W<~w=?6o{dgmYA9FXOG(fPNxZb;hcQ+l10sPYB~ z0b|L2J%l`?^7ZL!oMERa+V#HcAal6>6SjdLcy)!H$)6FE6s*4o~tBTJQA$+q~YL6NPxZ1oRYc;Kqe zQdO|sSQ9oNUDXT3rIU5&B%u3jd@yy8lG~{gB?h%IGALp;=JE4-?ouTrw(Mov5^0fF z8X>#TlPqoBmaT1iT~nONv@>a&2PN0oGPNBj)0P9)%DaUPbhjySbqDdfx`WsDbqBGK zt^K1r*v?W{cMv1}zjdo2s%)%#4?d;f9e*m)ro zL^FIZ{m|+9q}%mLTBqx~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(); } + + + + diff --git a/video.c b/video.c new file mode 100644 index 0000000..2bc1013 --- /dev/null +++ b/video.c @@ -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; + } +} + + + diff --git a/video.h b/video.h new file mode 100644 index 0000000..aeecfce --- /dev/null +++ b/video.h @@ -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; + + + + + +