]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/modex16.c
the near malloc is messy!! wwww
[16.git] / src / lib / modex16.c
index 986cbc556b5e29154bec405cbc7655d9785d62f6..e5550b4c130f4a969a514d6df63c9f2393d35988 100644 (file)
@@ -20,9 +20,6 @@
  *\r
  */\r
 \r
-#include <dos.h>\r
-#include <string.h>\r
-#include <mem.h>\r
 #include <conio.h>\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
 byte far* VGA=(byte far*) 0xA0000000;   /* this points to video memory. */\r
 \r
 static void fadePalette(sbyte fade, sbyte start, word iter, byte *palette);\r
-static byte tmppal[PAL_SIZE];\r
+static byte tmppal[PAL_SIZE];
+int old_mode;\r
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                                                                                                                                                                                             //
+// setvideo() - This function Manages the video modes                                                                                          //
+//                                                                                                                                                                                                                                             //
+/////////////////////////////////////////////////////////////////////////////
+void VGAmodeX(sword vq)
+{
+       union REGS in, out;
+
+       if(!vq)
+       { // deinit the video
+               // change to the video mode we were in before we switched to mode 13h
+               modexLeave();
+               in.h.ah = 0x00;
+               in.h.al = old_mode;
+               int86(0x10, &in, &out);
+
+       }
+       else if(vq==1)
+       { // init the video
+               // get old video mode
+               in.h.ah = 0xf;
+               int86(0x10, &in, &out);
+               old_mode = out.h.al;
+               // enter mode
+               modexEnter();
+       }
+}
 \r
 static void\r
 vgaSetMode(byte mode)\r
@@ -650,7 +677,7 @@ modexPalWhite() {
 }\r
 \r
 \r
-/* utility */\r
+/* utility */
 void\r
 modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset)\r
 {\r
@@ -957,7 +984,7 @@ void modexputPixel(page_t *page, int x, int y, byte color)
           offset = (width * y + x) / 4, and write the given\r
           color to the plane we selected above.  Heed the active\r
           page start selection. */\r
-       VGA[(unsigned)((SCREEN_WIDTH/4) * y) + (x / 4) + pageOff] = color;\r
+       VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff] = color;\r
 \r
 }\r
 \r
@@ -968,16 +995,20 @@ byte modexgetPixel(page_t *page, int x, int y)
        outpw(GC_INDEX, 0x04);\r
        outpw(GC_INDEX+1, x & 3);\r
 \r
-       return VGA[(unsigned)((SCREEN_WIDTH/4) * y) + (x / 4) + pageOff];\r
+       return VGA[(unsigned)((page->width/4) * y) + (x / 4) + pageOff];\r
 \r
 }
 
 void modexhlin(page_t *page, word xl, word xh, word y, word color)
 {
        word x;
+       word yy=0;
 
        for(x=0;x<xh*4;x+=4)
-       modexClearRegion(page, x+xl, y, 4, 4, color);
+       {
+               if(x+4>=SCREEN_WIDTH-1){ x=0; yy+=4; }
+               modexClearRegion(page, x+xl, y+yy, 4, 4, color);
+       }
        //modexputPixel(page, x+xl, y, color);
 }\r
 \r