OSDN Git Service

updated copyleft and need to test and fix newer version of open watcom
[proj16/16.git] / src / lib / 16_vl_1.c
index 7332d5f..519c984 100755 (executable)
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~\r
- * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ * Copyright (C) 2012-2022 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
  * This file is part of Project 16.\r
  *\r
@@ -26,6 +26,8 @@
 #include "src/lib/16_vl.h"\r
 \r
 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
+//#define VGASTRIDEVARIABLE    vga_state.vga_stride\r
+#define VGASTRIDEVARIABLE      gvar->video.page[0].stridew\r
 \r
 //===========================================================================\r
 \r
@@ -168,8 +170,8 @@ SetScreen_done:
 =\r
 ====================\r
 */\r
-\r
-void VL_SetLineWidth (unsigned width, ofs_t *ofs)\r
+#if 0\r
+void VL_SetLineWidth (unsigned width, global_game_variables_t *gvar)\r
 {\r
        int i,offset;\r
 \r
@@ -181,17 +183,17 @@ void VL_SetLineWidth (unsigned width, ofs_t *ofs)
 //\r
 // set up lookup tables\r
 //\r
-       ofs->linewidth = width*2;\r
+       gvar->video.ofs.linewidth = width*2;\r
 \r
        offset = 0;\r
 \r
        for     (i=0;i<MAXSCANLINES;i++)\r
        {\r
-               ofs->ylookup[i]=offset;\r
-               offset += ofs->linewidth;\r
+               gvar->video.ofs.ylookup[i]=offset;\r
+               offset += gvar->video.ofs.linewidth;\r
        }\r
 }\r
-\r
+#endif\r
 /*\r
 =============================================================================\r
 \r
@@ -483,6 +485,25 @@ void VL_TestPaletteSet (video_t *v)
                v->fastpalette = false;\r
 }\r
 \r
+/*\r
+==================\r
+=\r
+= VL_ColorBorder\r
+=\r
+==================\r
+*/\r
+\r
+void VL_ColorBorder (int color, video_t *v)\r
+{\r
+       union REGS in, out;\r
+\r
+       in.h.ah = 0x10;\r
+       in.h.al = 0x01;\r
+       in.h.bh = color;\r
+       int86(0x10, &in, &out);\r
+       v->bordercolor = color;\r
+}\r
+\r
 \r
 /*\r
 =============================================================================\r
@@ -502,14 +523,18 @@ void VL_TestPaletteSet (video_t *v)
 =================\r
 */\r
 \r
-void VL_Plot (int x, int y, int color, ofs_t *ofs)\r
+void VL_Plot (int x, int y, int color, global_game_variables_t *gvar)\r
 {\r
        byte mask;\r
        VCLIPDEF\r
 \r
+       if(!gvar->video.VL_Started) return;\r
+\r
        mask = pclip[x&3];\r
        VGAMAPMASK(mask);\r
-       *(byte far *)MK_FP(SCREENSEG,ofs->bufferofs+(ofs->ylookup[y]+(x>>2))) = color;\r
+       //*(byte far *)MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+(gvar->video.ofs.ylookup[y]+(x>>2))) = color;\r
+       //*(byte far *)MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+((y*VGASTRIDEVARIABLE)+(x>>2))) = color;\r
+       *(byte far *)MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+((y*VGASTRIDEVARIABLE)+(x>>2))) = color;\r
        VGAMAPMASK(15);\r
 }\r
 \r
@@ -522,7 +547,7 @@ void VL_Plot (int x, int y, int color, ofs_t *ofs)
 =================\r
 */\r
 \r
-void VL_Hlin   (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs)\r
+void VL_Hlin   (unsigned x, unsigned y, unsigned width, unsigned color, global_game_variables_t *gvar)\r
 {\r
        unsigned                xbyte;\r
        byte                    far *dest;\r
@@ -531,12 +556,15 @@ void VL_Hlin      (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs
 \r
        LRCLIPDEF\r
 \r
+       if(!gvar->video.VL_Started) return;\r
+\r
        xbyte = x>>2;\r
        leftmask = lclip[x&3];\r
        rightmask = rclip[(x+width-1)&3];\r
        midbytes = ((x+width+3)>>2) - xbyte - 2;\r
 \r
-       dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+xbyte);\r
+       //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+xbyte);\r
+       dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*VGASTRIDEVARIABLE)+xbyte);\r
 \r
        if (midbytes<0)\r
        {\r
@@ -569,20 +597,24 @@ void VL_Hlin      (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs
 =================\r
 */\r
 \r
-void VL_Vlin   (int x, int y, int height, int color, ofs_t *ofs)\r
+void VL_Vlin   (int x, int y, int height, int color, global_game_variables_t *gvar)\r
 {\r
        byte    far *dest,mask;\r
        VCLIPDEF\r
 \r
+       if(!gvar->video.VL_Started) return;\r
+\r
        mask = pclip[x&3];\r
        VGAMAPMASK(mask);\r
 \r
-       dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+(x>>2));\r
+       //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+(x>>2));\r
+       dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*VGASTRIDEVARIABLE)+(x>>2));\r
 \r
        while (height--)\r
        {\r
                *dest = color;\r
-               dest += ofs->linewidth;\r
+               //dest += gvar->video.ofs.linewidth;\r
+               dest += VGASTRIDEVARIABLE;\r
        }\r
 \r
        VGAMAPMASK(15);\r
@@ -597,7 +629,7 @@ void VL_Vlin        (int x, int y, int height, int color, ofs_t *ofs)
 =================\r
 */\r
 \r
-void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)\r
+void VL_Bar (int x, int y, int width, int height, int color, global_game_variables_t *gvar)\r
 {\r
        byte    far *dest;\r
        byte    leftmask,rightmask;\r
@@ -605,12 +637,16 @@ void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
 \r
        LRCLIPDEF\r
 \r
+       if(!gvar->video.VL_Started) return;\r
+\r
        leftmask = lclip[x&3];\r
        rightmask = rclip[(x+width-1)&3];\r
        midbytes = ((x+width+3)>>2) - (x>>2) - 2;\r
-       linedelta = ofs->linewidth-(midbytes+1);\r
+       //linedelta = gvar->video.ofs.linewidth-(midbytes+1);\r
+       linedelta = VGASTRIDEVARIABLE-(midbytes+1);\r
 \r
-       dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+(x>>2));\r
+       //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+(x>>2));\r
+       dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*VGASTRIDEVARIABLE)+(x>>2));\r
 \r
        if (midbytes<0)\r
        {\r
@@ -619,7 +655,8 @@ void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
                while (height--)\r
                {\r
                        *dest = color;\r
-                       dest += ofs->linewidth;\r
+                       //dest += gvar->video.ofs.linewidth;\r
+                       dest += VGASTRIDEVARIABLE;\r
                }\r
                VGAMAPMASK(15);\r
                return;\r
@@ -655,13 +692,14 @@ void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
 =================\r
 */\r
 \r
-void VL_MemToScreen (byte far *source, int width, int height, int x, int y, ofs_t *ofs)\r
+void VL_MemToScreen (byte far *source, int width, int height, int x, int y, global_game_variables_t *gvar)\r
 {\r
        byte    far *screen,far *dest,mask;\r
        int             plane;\r
 \r
        width>>=2;\r
-       dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+(x>>2) );\r
+       //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+(x>>2));\r
+       dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*VGASTRIDEVARIABLE)+(x>>2));\r
        mask = 1 << (x&3);\r
 \r
        for     (plane = 0; plane<4; plane++)\r
@@ -672,7 +710,8 @@ void VL_MemToScreen (byte far *source, int width, int height, int x, int y, ofs_
                        mask = 1;\r
 \r
                screen = dest;\r
-               for     (y=0;y<height;y++,screen+=ofs->linewidth,source+=width)\r
+               //for   (y=0;y<height;y++,screen+=gvar->video.ofs.linewidth,source+=width)\r
+               for     (y=0;y<height;y++,screen+=VGASTRIDEVARIABLE,source+=width)\r
                        _fmemcpy (screen,source,width);\r
        }\r
 }\r