X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Flib%2F16_vl_1.c;h=a1257fdc772f6f671475c260381081ad5139ef26;hb=2f706222157c9d186db8adf361542bb76ba259c6;hp=31c9f38e73a80f50735bac2612278ec9428c3389;hpb=6c9e6f3b81c3daae1085654eeb822d1fb6c1db74;p=16.git
diff --git a/src/lib/16_vl_1.c b/src/lib/16_vl_1.c
index 31c9f38e..a1257fdc 100755
--- a/src/lib/16_vl_1.c
+++ b/src/lib/16_vl_1.c
@@ -3,19 +3,19 @@
*
* This file is part of Project 16.
*
- * Project 16 is free software; you can redistribute it and/or modify
+ * Project 16 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
- * Project 16 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Project 16 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see , or
- * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
@@ -46,7 +46,7 @@ void VL_SetScreen (unsigned int crtc, int pelpan)
mov dx,STATUS_REGISTER_1
- // wait for a display signal to make sure the raster isn't in the middle
+ // wait for a display signal to make sure the raster isn't in the middle
// of a sync
#ifdef __BORLANDC__
@@ -121,7 +121,7 @@ SetScreen_setcrtc:
__asm {
#endif
// set CRTC start
- // for some reason, my XT's EGA card doesn't like word outs to the CRTC index...
+ // for some reason, my XT's EGA card doesn't like word outs to the CRTC index...
mov cx,[crtc]
mov dx,CRTC_INDEX
@@ -141,7 +141,7 @@ SetScreen_setcrtc:
// set horizontal panning
mov dx,ATR_INDEX
-// mov al,ATR_PELPAN or 20h
+// mov al,ATR_PELPAN or 20h
out dx,al
jmp SetScreen_done
mov al,[BYTE PTR pelpan] //pel pan value
@@ -164,12 +164,12 @@ SetScreen_done:
=
= VL_SetLineWidth
=
-= Line witdh is in WORDS, 40 words is normal width for vgaplanegr
+= Line witdh is in WORDS, 40 words is normal width for vgaplanegr
=
====================
*/
-
-void VL_SetLineWidth (unsigned width, ofs_t *ofs)
+#if 0
+void VL_SetLineWidth (unsigned width, global_game_variables_t *gvar)
{
int i,offset;
@@ -181,17 +181,17 @@ void VL_SetLineWidth (unsigned width, ofs_t *ofs)
//
// set up lookup tables
//
- ofs->linewidth = width*2;
+ gvar->video.ofs.linewidth = width*2;
offset = 0;
- for (i=0;iylookup[i]=offset;
- offset += ofs->linewidth;
+ gvar->video.ofs.ylookup[i]=offset;
+ offset += gvar->video.ofs.linewidth;
}
}
-
+#endif
/*
=============================================================================
@@ -216,7 +216,7 @@ void VL_FillPalette (int red, int green, int blue)
int i;
outportb (PAL_WRITE_REG,0);
- for (i=0;i<256;i++)
+ for (i=0;i<256;i++)
{
outportb (PAL_DATA_REG,red);
outportb (PAL_DATA_REG,green);
@@ -280,7 +280,7 @@ void VL_SetPalette (byte far *palette, video_t *v)
fastpalette=v->fastpalette;
// outportb (PAL_WRITE_REG,0);
-// for (i=0;i<768;i++)
+// for (i=0;i<768;i++)
// outportb(PAL_DATA_REG,*palette++);
__asm {
@@ -293,14 +293,14 @@ void VL_SetPalette (byte far *palette, video_t *v)
test [ss:fastpalette],1
jz slowset
//
-// set palette fast for cards that can take it
+// set palette fast for cards that can take it
//
//mov cx,768
//rep outsb
//jmp done
//
-// set palette slowly for some video cards
+// set palette slowly for some video cards
//
#ifdef __BORLANDC__
}
@@ -356,7 +356,7 @@ void VL_GetPalette (byte far *palette)
int i;
outportb (PAL_READ_REG,0);
- for (i=0;i<768;i++)
+ for (i=0;i<768;i++)
*palette++ = inportb(PAL_DATA_REG);
}
@@ -368,7 +368,7 @@ void VL_GetPalette (byte far *palette)
=
= VL_FadeOut
=
-= Fades the current palette to the given color in the given number of steps
+= Fades the current palette to the given color in the given number of steps
=
=================
*/
@@ -385,11 +385,11 @@ void VL_FadeOut (int start, int end, int red, int green, int blue, int steps, vi
//
// fade through intermediate frames
//
- for (i=0;ipalette1[start][0];
newptr = &v->palette2[start][0];
- for (j=start;j<=end;j++)
+ for (j=start;j<=end;j++)
{
orig = *origptr++;
delta = red-orig;
@@ -437,9 +437,9 @@ void VL_FadeIn (int start, int end, byte far *palette, int steps, video_t *v)
//
// fade through intermediate frames
//
- for (i=0;ipalette1[0][j];
v->palette2[0][j] = v->palette1[0][j] + delta * i / steps;
@@ -463,7 +463,7 @@ void VL_FadeIn (int start, int end, byte far *palette, int steps, video_t *v)
=
= VL_TestPaletteSet
=
-= Sets the palette with outsb, then reads it in and compares
+= Sets the palette with outsb, then reads it in and compares
= If it compares ok, fastpalette is set to true.
=
=================
@@ -473,7 +473,7 @@ void VL_TestPaletteSet (video_t *v)
{
int i;
- for (i=0;i<768;i++)
+ for (i=0;i<768;i++)
v->palette1[0][i] = i;
v->fastpalette = true;
@@ -483,6 +483,25 @@ void VL_TestPaletteSet (video_t *v)
v->fastpalette = false;
}
+/*
+==================
+=
+= VL_ColorBorder
+=
+==================
+*/
+
+void VL_ColorBorder (int color, video_t *v)
+{
+ union REGS in, out;
+
+ in.h.ah = 0x10;
+ in.h.al = 0x01;
+ in.h.bh = color;
+ int86(0x10, &in, &out);
+ v->bordercolor = color;
+}
+
/*
=============================================================================
@@ -502,14 +521,18 @@ void VL_TestPaletteSet (video_t *v)
=================
*/
-void VL_Plot (int x, int y, int color, ofs_t *ofs)
+void VL_Plot (int x, int y, int color, global_game_variables_t *gvar)
{
byte mask;
VCLIPDEF
+ if(!gvar->video.VL_Started) return;
+
mask = pclip[x&3];
VGAMAPMASK(mask);
- *(byte far *)MK_FP(SCREENSEG,ofs->bufferofs+(ofs->ylookup[y]+(x>>2))) = color;
+ //*(byte far *)MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+(gvar->video.ofs.ylookup[y]+(x>>2))) = color;
+ //*(byte far *)MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+((y*gvar->video.page[0].stridew)+(x>>2))) = color;
+ *(byte far *)MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+((y*gvar->video.page[0].stridew)+(x>>2))) = color;
VGAMAPMASK(15);
}
@@ -522,7 +545,7 @@ void VL_Plot (int x, int y, int color, ofs_t *ofs)
=================
*/
-void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs)
+void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, global_game_variables_t *gvar)
{
unsigned xbyte;
byte far *dest;
@@ -531,16 +554,19 @@ void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs
LRCLIPDEF
+ if(!gvar->video.VL_Started) return;
+
xbyte = x>>2;
leftmask = lclip[x&3];
rightmask = rclip[(x+width-1)&3];
midbytes = ((x+width+3)>>2) - xbyte - 2;
- dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+xbyte);
+ //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+xbyte);
+ dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*gvar->video.page[0].stridew)+xbyte);
if (midbytes<0)
{
- // all in one byte
+ // all in one byte
VGAMAPMASK(leftmask&rightmask);
*dest = color;
VGAMAPMASK(15);
@@ -569,20 +595,24 @@ void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color, ofs_t *ofs
=================
*/
-void VL_Vlin (int x, int y, int height, int color, ofs_t *ofs)
+void VL_Vlin (int x, int y, int height, int color, global_game_variables_t *gvar)
{
byte far *dest,mask;
VCLIPDEF
+ if(!gvar->video.VL_Started) return;
+
mask = pclip[x&3];
VGAMAPMASK(mask);
- dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+(x>>2));
+ //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+(x>>2));
+ dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*gvar->video.page[0].stridew)+(x>>2));
while (height--)
{
*dest = color;
- dest += ofs->linewidth;
+ //dest += gvar->video.ofs.linewidth;
+ dest += gvar->video.page[0].stridew;
}
VGAMAPMASK(15);
@@ -597,7 +627,7 @@ void VL_Vlin (int x, int y, int height, int color, ofs_t *ofs)
=================
*/
-void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
+void VL_Bar (int x, int y, int width, int height, int color, global_game_variables_t *gvar)
{
byte far *dest;
byte leftmask,rightmask;
@@ -605,21 +635,26 @@ void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
LRCLIPDEF
+ if(!gvar->video.VL_Started) return;
+
leftmask = lclip[x&3];
rightmask = rclip[(x+width-1)&3];
midbytes = ((x+width+3)>>2) - (x>>2) - 2;
- linedelta = ofs->linewidth-(midbytes+1);
+ //linedelta = gvar->video.ofs.linewidth-(midbytes+1);
+ linedelta = gvar->video.page[0].stridew-(midbytes+1);
- dest = MK_FP(SCREENSEG,ofs->bufferofs+ofs->ylookup[y]+(x>>2));
+ //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+(x>>2));
+ dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*gvar->video.page[0].stridew)+(x>>2));
if (midbytes<0)
{
- // all in one byte
+ // all in one byte
VGAMAPMASK(leftmask&rightmask);
while (height--)
{
*dest = color;
- dest += ofs->linewidth;
+ //dest += gvar->video.ofs.linewidth;
+ dest += gvar->video.page[0].stridew;
}
VGAMAPMASK(15);
return;
@@ -643,13 +678,50 @@ void VL_Bar (int x, int y, int width, int height, int color, ofs_t *ofs)
VGAMAPMASK(15);
}
+//==========================================================================
+
+/*
+=================
+=
+= VL_MemToScreen
+=
+= Draws a block of data to the screen.
+=
+=================
+*/
+
+void VL_MemToScreen (byte far *source, int width, int height, int x, int y, global_game_variables_t *gvar)
+{
+ byte far *screen,far *dest,mask;
+ int plane;
+
+ width>>=2;
+ //dest = MK_FP(SCREENSEG,gvar->video.ofs.bufferofs+gvar->video.ofs.ylookup[y]+(x>>2));
+ dest = MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+(y*gvar->video.page[0].stridew)+(x>>2));
+ mask = 1 << (x&3);
+
+ for (plane = 0; plane<4; plane++)
+ {
+ VGAMAPMASK(mask);
+ mask <<= 1;
+ if (mask == 16)
+ mask = 1;
+
+ screen = dest;
+ //for (y=0;yvideo.ofs.linewidth,source+=width)
+ for (y=0;yvideo.page[0].stridew,source+=width)
+ _fmemcpy (screen,source,width);
+ }
+}
+
+//==========================================================================
/*
==============
VL_WaitVBL ******** NEW *********
- Wait for the vertical retrace (returns before the actual vertical sync)
+ Wait for the vertical retrace (returns before the actual vertical sync)
==============
*/
@@ -670,7 +742,7 @@ void VL_WaitVBL(word num)
mov cx,[num]
//
- // wait for a display signal to make sure the raster isn't in the middle
+ // wait for a display signal to make sure the raster isn't in the middle
// of a sync
//
#ifdef __BORLANDC__
@@ -703,23 +775,49 @@ void VL_WaitVBL(word num)
}
//===========================================================================
+#if 0
+#define VGAWRITEMODE(x) asm{
+ cli
+ mov dx,GC_INDEX
+ mov al,GC_MODE
+ out dx,al
+ inc dx
+ in al,dx
+ and al,252
+ or al,x
+ out dx,al
+ sti
+}
-void VGAMAPMASK(byte x)
-{
- __asm {
-// cli
+#define VGAMAPMASK(x) asm{
+ cli
mov dx,SC_INDEX
mov al,SC_MAPMASK
mov ah,x
out dx,ax
-// sti
- }
+ sti
+}
+
+#define VGAREADMAP(x) asm{
+ cli
+ mov dx,GC_INDEX
+ mov al,GC_READMAP
+ mov ah,x
+ out dx,ax
+ sti
}
+#define EGABITMASK(x) asm{
+ mov dx,GC_INDEX
+ mov ax,GC_BITMASK+256*x
+ out dx,ax
+ sti
+}
+#endif
void VGAWRITEMODE(byte x)
{
__asm {
-// cli
+ cli
mov dx,GC_INDEX
mov al,GC_MODE
out dx,al
@@ -728,19 +826,42 @@ void VGAWRITEMODE(byte x)
and al,252
or al,x
out dx,al
-// sti
+ sti
+ }
+}
+
+void VGAMAPMASK(byte x)
+{
+ __asm {
+ cli
+ mov dx,SC_INDEX
+ mov al,SC_MAPMASK
+ mov ah,x
+ out dx,ax
+ sti
}
}
void VGAREADMAP(byte x)
{
__asm {
-// cli
+ cli
mov dx,GC_INDEX
mov al,GC_READMAP
mov ah,x
out dx,ax
-// sti
+ sti
+ }
+}
+
+void VGABITMASK(byte x)
+{
+ word q = 256*x;
+ __asm {
+ mov dx,GC_INDEX
+ mov ax,GC_BITMASK+q
+ out dx,ax
+ sti
}
}