]> 4ch.mooo.com Git - 16.git/blobdiff - 16/dos_gfx.cpp
modified: 16/DOS_GFX.EXE
[16.git] / 16 / dos_gfx.cpp
index cd45ae844c027764f7d62e89d2339b2b91b62139..4fe962e6028317c54b5356889eb92898dde62134 100644 (file)
@@ -57,7 +57,8 @@
 //code from old library!\r
 /*src\lib\*/\r
 #include "dos_gfx.h"\r
-#include "lib\x\modex.h"\r
+//#include "lib\x\modex.h"\r
+//#include "XPRIM.HPP"\r
 \r
 int old_mode;\r
 //color \82Ä\82·\82Æ\r
@@ -65,7 +66,7 @@ int gq = LGQ;
 //\82Ä\82·\82Æ\r
 int q = 0;\r
 int bakax = 0, bakay = 0;\r
-int xx = rand()&0%320, yy = rand()&0%240, sx = 0, sy = 0;\r
+cord xx = rand()&0%320, yy = rand()&0%240, sx = 0, sy = 0;\r
 byte coor;\r
 \r
 /*\r
@@ -81,6 +82,14 @@ byte coor;
 \r
 #define SEQU_ADDR         0x3c4   /* Base port of the Sequencer */\r
 #define GRAC_ADDR         0x3ce   /* Base port of the Graphics Controller */\r
+#define STATUS_ADDR     0x3DA\r
+\r
+unsigned char *RowsX[600];\r
+unsigned char write_plane, read_plane;\r
+unsigned short text_mask[16] = { 0x0002, 0x0102, 0x0202, 0x0302,\r
+                                 0x0402, 0x0502, 0x0602, 0x0702,\r
+                                 0x0802, 0x0902, 0x0A02, 0x0B02,\r
+                                 0x0C02, 0x0D02, 0x0E02, 0x0F02 };\r
 \r
 \r
 /*\r
@@ -89,7 +98,6 @@ byte coor;
  */\r
 byte *vga = (byte *) MK_FP(0xA000, 0);\r
 \r
-//fontAddr = getFont();\r
 \r
 /*\r
  * width and height should specify the mode dimensions.  widthBytes\r
@@ -184,10 +192,8 @@ OUT value TO PORT 3C0H (where "value" is the
   number of pixels to offset)\r
 -----------------------------------------------\r
 */\r
-//\r
-//     inp(0x3DA);\r
-//     outp(0x3C0, 0x13);\r
 \r
+//mxSetVirtualScreen(480,360);\r
                }\r
 \r
 /*\r
@@ -287,32 +293,18 @@ void set320x240x256_X(void)
                }\r
 \r
 \r
-/*-----------XXXX-------------*/
-
+/*-----------XXXX-------------*/\r
+\r
 /////////////////////////////////////////////////////////////////////////////\r
 //                                                                         //\r
 // WaitRetrace() - This waits until you are in a Verticle Retrace.         //\r
 //                                                                         //\r
 /////////////////////////////////////////////////////////////////////////////\r
+void wait_for_retrace(void)\r
+{\r
+    while (!(inp(STATUS_ADDR) & 0x08));\r
+}\r
 \r
-void WaitRetrace() {\r
-\r
-//  register char qy;\r
-\r
-       in.h.dx = 0x03DA;\r
-       in.h.al = in.h.dx;\r
-       \r
-       in.h.al &= 0x08;\r
-       int86(0x10, &in, &out);\r
-\r
-\r
-  /*l1: asm {\r
-       in  al,0x03DA;\r
-       and al,0x08;\r
-       jnz  l2;\r
-      }*/\r
-}
-
 /////////////////////////////////////////////////////////////////////////////\r
 //                                                                         //\r
 // MoveTo() - This moves to position X*4 on a chain 4 screen.              //\r
@@ -320,10 +312,10 @@ void WaitRetrace() {
 //                will be better documented.  - Snowman                    //\r
 //                                                                         //\r
 /////////////////////////////////////////////////////////////////////////////\r
-\r
+/*\r
 void MoveTo (word X, word Y) {\r
 \r
-//     word O = Y*SIZE*2+X;
+//     word O = Y*SIZE*2+X;\r
        word O = Y*widthBytes*2+X;\r
 \r
   asm {\r
@@ -338,8 +330,8 @@ void MoveTo (word X, word Y) {
     mov    al, 0x0D\r
     mov    dx, 0x3D4\r
     out    dx, ax\r
-  }
-
+  }\r
+\r
 ;-----------------------------------------------------------\r
 ;\r
 ; MXPN.ASM - Panning function\r
@@ -400,10 +392,10 @@ mxPan           ENDP
 \r
 MX_TEXT         ENDS\r
 END\r
-
 \r
-}
-
+\r
+}\r
+\r
 //Procedure Play;\r
 void Play()\r
 {\r
@@ -415,15 +407,15 @@ void Play()
 \r
    moveto(0,0,Size); // { This moves the view to the top left hand corner }\r
 \r
-/*   for(loop1=0;loop1<=3;loop1++)\r
-     for(loop2=0;loop2<=5;loop2++)\r
-       Putpic (loop1*160,loop2*66); // { This places the picture all over the\r
+//   for(loop1=0;loop1<=3;loop1++)\r
+//     for(loop2=0;loop2<=5;loop2++)\r
+//       Putpic (loop1*160,loop2*66); // { This places the picture all over the\r
                                     //  chain-4 screen }\r
-   getch();\r
-   ch=0x0;*/\r
+//   getch();\r
+//   ch=0x0;\r
 //   xpos=rand (78)+1;\r
-//   ypos=rand (198)+1; // { Random start positions for the view }
-       xpos=0;
+//   ypos=rand (198)+1; // { Random start positions for the view }\r
+       xpos=0;\r
        ypos=0;\r
    xdir=1;\r
    ydir=1;\r
@@ -440,8 +432,8 @@ void Play()
 //      if(ch==0x71)break; // 'q'\r
 //      if(ch==0x1b)break; // 'ESC'\r
 //   }\r
-}
-\r
+}\r
+*/\r
 /*tile*/\r
 //king_crimson's code\r
 void putColorBox_X(int x, int y, int w, int h, byte color) {\r
@@ -482,11 +474,12 @@ void scrolly(int bongy)
 \r
 //king_crimson's code\r
 void hScroll(int Cols) {\r
-       inp(0x3DA);\r
+       wait_for_retrace();\r
        outp(0x3C0, 0x13);\r
        outp(0x3C0, Cols & 3);\r
        outp(0x3D4, 0x13);\r
-       outp(0x3D5, Cols/* >> 2*/);\r
+       outp(0x3D5, Cols >> 2);\r
+       outp(0x3D4, Cols);\r
        //setVisibleStart(visStart + (Cols * height));\r
        setVisibleStart(visStart + (Cols * width));\r
 }\r
@@ -586,63 +579,77 @@ I'm sorry about this being so confusing but it's a bit difficult to explain.
 \r
 \r
 */\r
-//---------------------------------------------------\r
-//\r
-// Use the bios to get the address of the 8x8 font\r
-//\r
-// You need a font if you are going to draw text.\r
-//\r
-/*\r
-int far *\r
-getFont()\r
+int loadfontX(char *fname)\r
 {\r
-       union REGPACK rg;\r
-       int seg;\r
-       int off;\r
-       memset(&rg, 0, sizeof(rg));\r
-\r
-       rg.w.ax = 0x1130;\r
-       rg.h.bh = 0x03;\r
-       intr(0x10, &rg);\r
-       seg = rg.w.es;\r
-       off = rg.w.bp;\r
-       \r
-\r
-       return (int far *)MK_FP(seg, off);\r
+       FILE *fp;\r
+\r
+       fp = fopen(fname, "rb");\r
+\r
+       if (fp == NULL) {\r
+               return 0;\r
+       } else {\r
+               fread(Xfont, 8, 256, fp);\r
+               fclose(fp);\r
+               return 1;\r
+       }\r
 }\r
 \r
-void drawChar(int x, int y, int color, byte c)\r
+void putchX(cord x, cord y, char c, byte color)\r
 {\r
-               int i, j;\r
-               int mask;\r
-               int far *font = getFont() + (c * 8);\r
-\r
-               for (i = 0; i < 8; i++)\r
-               {\r
-                               mask = *font;\r
-                               for (j = 0; j < 8; j++)\r
-                               {\r
-                                               if (mask & 0x80)\r
-                                               {\r
-                                                               //pixel(x + j, y + i, color);\r
-                                                               putPixel_X(x + j, y + i, color);\r
-                                               }\r
-                                               mask <<= 1;\r
-                               }\r
-                               font++;\r
-               }\r
+       int i;\r
+       byte *vga_ptr;\r
+       byte *font_ptr;\r
+       byte temp;\r
+\r
+       // 8x8 font\r
+       vga_ptr = RowsX[y << 3] + (x << 1) + actStart;\r
+       write_plane = -1;\r
+\r
+       font_ptr = Xfont + (c << 3);\r
+\r
+       i=8;\r
+       while (i--) {\r
+               temp = *font_ptr++;\r
+               outpw(SEQU_ADDR, text_mask[temp & 0x0F]);\r
+               *vga_ptr++ = color;\r
+\r
+               outpw(SEQU_ADDR, text_mask[temp >> 4]);\r
+               *vga_ptr-- = color;\r
+               vga_ptr += widthBytes;\r
+       }\r
 }\r
 \r
-void drawText(int x, int y, int color, byte string)\r
+void putstringX(cord x, cord y, char *str, byte color)\r
 {\r
-               while (string)\r
-               {\r
-                               drawChar(x, y, color, string);\r
-                               x += 8;\r
-                               string++;\r
+       int i, skip;\r
+       byte *vga_ptr;\r
+       byte *font_ptr;\r
+       byte c, temp;\r
+\r
+       // 8x8 font\r
+       vga_ptr = RowsX[y << 3] + (x << 1) + actStart;\r
+       write_plane = -1;\r
+\r
+       skip = 2 - (widthBytes << 3);\r
+\r
+       while (c = *str++) {\r
+               font_ptr = Xfont + (c << 3);\r
+\r
+               i=8;\r
+               while (i--) {\r
+                       temp = *font_ptr++;\r
+                       outpw(SEQU_ADDR, text_mask[temp & 0x0F]);\r
+                       *vga_ptr++ = color;\r
+\r
+                       outpw(SEQU_ADDR, text_mask[temp >> 4]);\r
+                       *vga_ptr-- = color;\r
+                       vga_ptr += widthBytes;\r
                }\r
+\r
+               vga_ptr += skip;\r
+       }\r
 }\r
-*/\r
+\r
 /////////////////////////////////////////////////////////////////////////////\r
 //                                                                         //\r
 // setvideo() - This function Manages the video modes                                    //\r
@@ -936,6 +943,7 @@ void doTest(void)
 int main(void)\r
                {\r
                int key,d;\r
+               //short int temp;\r
                // main variables\r
                d=1; // switch variable\r
                key=4; // default screensaver number\r
@@ -953,7 +961,12 @@ int main(void)
 \r
 //++++0000\r
                setvideo(1);\r
-//mxInit();\r
+               /*temp = loadfontX("vga8x8.fnt");\r
+\r
+               if (temp) {\r
+                       putstringX(0, 0, "bakapi!", 2);\r
+               }\r
+               getch();*/\r
 // screen savers\r
 \r
 /*while(d!=0){ // on!\r
@@ -970,7 +983,7 @@ int main(void)
                                }\r
                }*/ // else off\r
                while(!kbhit()){ // conditions of screen saver\r
-                       ding(4);\r
+                       ding(2);\r
                }\r
                //end of screen savers\r
 //             doTest();\r
@@ -978,9 +991,9 @@ int main(void)
 \r
                while(!kbhit()){ // conditions of screen saver\r
 //                     hScroll(1);\r
-//                     scrolly(1);\r
-//                     delay(100);
-                       Play();\r
+                       scrolly(1);\r
+                       delay(100);\r
+//                     Play();\r
                }\r
 //++++0000\r
                setvideo(0);\r