]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_vl.c
XCROLL broken
[16.git] / src / lib / 16_vl.c
index 2e5fa42e184eb9d6ed18da64adc0fc4a1abe8503..2078def23a770eaa6b92ec95fb614e946df96462 100755 (executable)
@@ -43,12 +43,18 @@ void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
        {\r
                case 0: // deinit the video\r
                        // change to the video mode we were in before we switched to mode 13h\r
-                       modexLeave();\r
-                       in.h.ah = 0x00;\r
-                       in.h.al = gv->video.old_mode;\r
-                       int86(0x10, &in, &out);\r
+                       if(gv->video.VL_Started)\r
+                       {\r
+                               modexLeave();\r
+                               in.h.ah = 0x00;\r
+                               in.h.al = gv->video.old_mode;\r
+                               int86(0x10, &in, &out);\r
+                       }\r
+                       gv->video.VL_Started=0;\r
                break;\r
                default: // init the video\r
+                       if(gv->video.VL_Started)\r
+                               return;\r
                        // get old video mode\r
                        //in.h.ah = 0xf;\r
                        //int86(0x10, &in, &out);\r
@@ -163,6 +169,8 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv)
                }\r
                break;\r
        }\r
+//     VL_SetLineWidth (cm.offset, &gv->video.ofs);\r
+       gv->video.VL_Started=1;\r
 }\r
 \r
 void\r
@@ -274,7 +282,7 @@ void modexCalcVmemRemain(video_t *video)
 \r
 void VL_Initofs(video_t *video)\r
 {\r
-       if(!video->bgps)\r
+       if(!video->vga_state.bgps)\r
        {\r
                video->ofs.offscreen_ofs =      video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height);\r
                video->ofs.pattern_ofs =        (uint16_t)video->page[2].data;\r
@@ -304,12 +312,12 @@ void modexHiganbanaPageSetup(video_t *video)
 \r
        VL_Initofs(video);\r
        //doslib origi var\r
-       video->omemptr=                 vga_state.vga_graphics_ram;\r
-       video->vga_draw_stride= vga_state.vga_draw_stride;\r
-       video->vga_draw_stride_limit=   vga_state.vga_draw_stride_limit;\r
+       video->vga_state.omemptr=                       vga_state.vga_graphics_ram;\r
+       video->vga_state.vga_draw_stride=       vga_state.vga_draw_stride;\r
+       video->vga_state.vga_draw_stride_limit= vga_state.vga_draw_stride_limit;\r
        //sprite render switch and bgpreservation switch\r
-       video->rss=             1;\r
-       video->bgps=    1;\r
+       video->vga_state.rss=           1;\r
+       video->vga_state.bgps=  1;\r
 \r
        //setup the buffersize\r
        video->page[0].dx=video->page[0].dy=\r
@@ -409,20 +417,20 @@ modexSelectPlane(byte plane) {
 }\r
 \r
 void\r
-modexClearRegion(page_t *page, int x, int y, int w, int h, byte  color) {\r
+modexClearRegion(page_t *page, int x, int y, int w, int h, byte color)\r
+{\r
        word pageOff = (word) page->data;\r
-       word xoff=x/4;     /* xoffset that begins each row */\r
-       word scanCount=w/4;  /* number of iterations per row (excluding right clip)*/\r
-       word poffset = pageOff + y*(page->stridew) + xoff; /* starting offset */\r
-       word nextRow = page->stridew-scanCount-1;  /* loc of next row */\r
-       byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08};  /* clips for rectangles not on 4s */\r
-       byte rclip[] = {0x00, 0x01, 0x03, 0x07};\r
+       word xoff=(x>>2);                                                       // xoffset that begins each row\r
+       word poffset = pageOff + y*(page->stridew) + xoff;      // starting offset\r
+       word scanCount=w>>2;                                            // number of iterations per row (excluding right clip)\r
+       word nextRow = page->stridew-scanCount-1;               // loc of next row\r
+       LRCLIPDEF\r
        byte left = lclip[x&0x03];\r
        byte right = rclip[(x+w)&0x03];\r
 \r
-       /* handle the case which requires an extra group */\r
+       // handle the case which requires an extra group\r
        if((x & 0x03) && !((x+w) & 0x03)) {\r
-         right=0x0f;\r
+               right=0x0f;\r
        }\r
 \r
        //printf("modexClearRegion(x=%u, y=%u, w=%u, h=%u, left=%u, right=%u)\n", x, y, w, h, left, right);\r
@@ -492,17 +500,16 @@ modexCopyPageRegion(page_t *dest, page_t *src,
                        word dx, word dy,\r
                        word width, word height)\r
 {\r
-       word doffset = (word)dest->data + dy*(dest->stridew) + dx/4;\r
-       word soffset = (word)src->data + sy*(src->stridew) + sx/4;\r
-       word scans   = vga_state.vga_stride;                            //++++0000 the quick and dirty fix of the major issue with p16 video display wwww\r
+       word doffset = (word)dest->data + dy*(dest->stridew) + (dx>>2);\r
+       word soffset = (word)src->data + sy*(src->stridew) + (sx>>2);\r
+       word scans      = vga_state.vga_stride+8;                               //++++0000 the quick and dirty fix of the major issue with p16 video display wwww\r
        word nextSrcRow = src->stridew - scans - 1;\r
        word nextDestRow = dest->stridew - scans - 1;\r
-       byte lclip[] = {0x0f, 0x0e, 0x0c, 0x08};  /* clips for rectangles not on 4s */\r
-       byte rclip[] = {0x00, 0x01, 0x03, 0x07};\r
+       LRCLIPDEF\r
        byte left = lclip[sx&0x03];\r
        byte right = rclip[(sx+width)&0x03];\r
 \r
-       /* handle the case which requires an extra group */\r
+       // handle the case which requires an extra group\r
        if((sx & 0x03) && !((sx+width) & 0x03)) {\r
                right=0x0f;\r
        }\r
@@ -579,6 +586,7 @@ modexCopyPageRegion(page_t *dest, page_t *src,
        }\r
 }\r
 \r
+//check 16_vl_1.c\r
 \r
 /* fade and flash */\r
 void\r
@@ -781,14 +789,16 @@ modexPalUpdate0(byte *p)
        }\r
 }\r
 \r
-void\r
+word\r
 modexPalOverscan(word col)\r
 {\r
        //modexWaitBorder();\r
        vga_wait_for_vsync();\r
        outp(PAL_WRITE_REG, 0);  /* start at the beginning of palette */\r
        outp(PAL_DATA_REG, col);\r
+       return col;\r
 }\r
+//check 16_vl_1.c\r
 \r
 void modexputPixel(page_t *page, int x, int y, byte color)\r
 {\r
@@ -857,7 +867,7 @@ void modexDrawChar(page_t *page, int x/*for planar selection only*/, word t, wor
        }\r
 }\r
 \r
-void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, const byte *str)\r
+void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col, word bgcol, boolean sw, const byte *str)\r
 {\r
        word s, o, w;\r
        word x_draw;\r
@@ -866,38 +876,46 @@ void modexprint(page_t *page, sword x, sword y, word t, boolean tlsw, word col,
        word addrr;\r
        byte c;\r
 \r
-       if(tlsw){ x-=page->tlx; y-=page->tly; }\r
-       x_draw = x/4;\r
-       addrq = (page->stridew) * y + (word)(x_draw) +\r
-               ((word)page->data);\r
-       addrr = addrq;\r
-       s=romFonts[t].seg;\r
-       o=romFonts[t].off;\r
-       w=romFonts[t].charSize;\r
-       romFontsData.chw=0;\r
-\r
-       for(; *str != '\0'; str++)\r
+       switch(sw)\r
        {\r
-               c = (*str);\r
-               if(c=='\n')\r
-               {\r
-                       x = x_draw;\r
-                       romFontsData.chw = 0;\r
-                       addrq += (page->stridew) * 8;\r
+               case 0:\r
+                       printf("%s\n", str);\r
+               break;\r
+               case 1:\r
+                       if(tlsw){ x-=page->tlx; y-=page->tly; }\r
+                       x_draw = x/4;\r
+                       addrq = (page->stridew) * y + (word)(x_draw) +\r
+                               ((word)page->data);\r
                        addrr = addrq;\r
-                       y += 8;\r
-                       continue;\r
-               }\r
+                       s=romFonts[t].seg;\r
+                       o=romFonts[t].off;\r
+                       w=romFonts[t].charSize;\r
+                       romFontsData.chw=0;\r
 \r
-       // load the character into romFontsData.l\r
-       // no need for inline assembly!\r
-       // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C.\r
-               _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/);\r
-               modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr);\r
-               x_draw += 8; /* track X for edge of screen */\r
-               addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */\r
+                       for(; *str != '\0'; str++)\r
+                       {\r
+                               c = (*str);\r
+                               if(c=='\n')\r
+                               {\r
+                                       x = x_draw;\r
+                                       romFontsData.chw = 0;\r
+                                       addrq += (page->stridew) * 8;\r
+                                       addrr = addrq;\r
+                                       y += 8;\r
+                                       continue;\r
+                               }\r
+\r
+                       // load the character into romFontsData.l\r
+                       // no need for inline assembly!\r
+                       // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C.\r
+                               _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/);\r
+                               modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr);\r
+                               x_draw += 8; /* track X for edge of screen */\r
+                               addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */\r
+                       }\r
+                       //printf("print xy:%dx%d        tlxy:%dx%d\n", x, y, page->tlx, page->tly);\r
+               break;\r
        }\r
-       //printf("print xy:%dx%d        tlxy:%dx%d\n", x, y, page->tlx, page->tly);\r
 }\r
 \r
 void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str)\r
@@ -1102,6 +1120,8 @@ modexWaitBorder_end()
 \r
 }\r
 \r
+//===========================================================================\r
+\r
 //\r
 // printings of video memory information\r
 //\r