X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_vl_1.c;h=b92bdd14cebc255a279a648e7d182b3c43ca8650;hb=a565be31ce92d6168ae6983042da75b0b683e52b;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..b92bdd14 100755 --- a/src/lib/16_vl_1.c +++ b/src/lib/16_vl_1.c @@ -1,21 +1,21 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover + * Copyright (C) 2012-2019 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * 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. * */ @@ -26,6 +26,8 @@ #include "src/lib/16_vl.h" static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ +//#define VGASTRIDEVARIABLE vga_state.vga_stride +#define VGASTRIDEVARIABLE gvar->video.page[0].stridew //=========================================================================== @@ -46,7 +48,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 +123,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 +143,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 +166,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 +183,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 +218,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 +282,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 +295,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 +358,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 +370,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 +387,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 +439,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 +465,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 +475,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 +485,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 +523,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*VGASTRIDEVARIABLE)+(x>>2))) = color; + *(byte far *)MK_FP(SCREENSEG,BDOFSCONV gvar->video.BOFS+((y*VGASTRIDEVARIABLE)+(x>>2))) = color; VGAMAPMASK(15); } @@ -522,7 +547,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 +556,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*VGASTRIDEVARIABLE)+xbyte); if (midbytes<0) { - // all in one byte + // all in one byte VGAMAPMASK(leftmask&rightmask); *dest = color; VGAMAPMASK(15); @@ -569,20 +597,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*VGASTRIDEVARIABLE)+(x>>2)); while (height--) { *dest = color; - dest += ofs->linewidth; + //dest += gvar->video.ofs.linewidth; + dest += VGASTRIDEVARIABLE; } VGAMAPMASK(15); @@ -597,7 +629,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 +637,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 = VGASTRIDEVARIABLE-(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*VGASTRIDEVARIABLE)+(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 += VGASTRIDEVARIABLE; } VGAMAPMASK(15); return; @@ -643,13 +680,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*VGASTRIDEVARIABLE)+(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;y