From 0ba5341e4e39c0ba42c709f311f9139901f71a19 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 23 Jul 2007 11:00:26 +0000 Subject: [PATCH] Fixed sw renderer's console background when the input image is not 320*200. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2533 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/sw/sw_draw.c | 65 ++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/engine/sw/sw_draw.c b/engine/sw/sw_draw.c index 4cd769e1a..aa9a819a3 100644 --- a/engine/sw/sw_draw.c +++ b/engine/sw/sw_draw.c @@ -2016,15 +2016,15 @@ Draw_ConsoleBackground */ void SWDraw_ConsoleBackground (int lines) { - int x, y, v; + int x, y, v, w, h; qbyte *src; qbyte *dest; int f, fstep; mpic_t *conback; char ver[100]; - static char saveback[320*8]; +// static char saveback[320*8]; - if (!scr_con_forcedraw && !scr_conalpha.value) + if ((!scr_con_forcedraw && !scr_conalpha.value) || !lines) return; conback = (mpic_t *)SWDraw_SafeCachePic ("gfx/conback.lmp"); @@ -2032,7 +2032,7 @@ void SWDraw_ConsoleBackground (int lines) conback = (mpic_t *)SWDraw_SafeCachePic("pics/conback.pcx"); if (!conback) conback = (mpic_t *)SWDraw_SafeCachePic ("gfx/menu/conback.lmp"); - if (!conback) + if (!conback || conback->width < 320 || conback->height < 200) { swcachepic_t *cp; @@ -2046,6 +2046,9 @@ void SWDraw_ConsoleBackground (int lines) conback->flags = 0; } + w = conback->width; + h = conback->height; + if (lines > vid.conheight) lines = vid.conheight; @@ -2054,9 +2057,9 @@ void SWDraw_ConsoleBackground (int lines) //sprintf (ver, "start commands with a \\ character %4.2f", VERSION); sprintf (ver, "%i", build_number()); - dest = conback->data + 320 + 320*186 - 11 - 8*strlen(ver); + dest = conback->data + w + w*186 - 11 - 8*strlen(ver); - memcpy(saveback, conback->data + 320*186, 320*8); +// memcpy(saveback, conback->data + w*186, w*8); for (x=0 ; xdata + v*320; + v = (vid.conheight - lines + y)*h/vid.conheight; + src = conback->data + v*w; f = 0; - fstep = 320*0x10000/vid.conwidth; + fstep = w*0x10000/vid.conwidth; for (x=0 ; x>16]); @@ -2093,14 +2096,14 @@ void SWDraw_ConsoleBackground (int lines) for (y=0 ; ydata + v*320; - if (vid.conwidth == 320) + v = (vid.conheight - lines + y)*h/vid.conheight; + src = conback->data + v*w; + if (vid.conwidth == w) memcpy (dest, src, vid.conwidth); else { f = 0; - fstep = 320*0x10000/vid.conwidth; + fstep = w*0x10000/vid.conwidth; for (x=0 ; x>16]; @@ -2124,14 +2127,14 @@ void SWDraw_ConsoleBackground (int lines) for (y=0 ; ydata + v*320; -// if (vid.conwidth == 320) + v = (vid.conheight - lines + y)*h/vid.conheight; + src = conback->data + v*w; +// if (vid.conwidth == w) // memcpy (dest16, src, vid.conwidth); // else { f = 0; - fstep = 320*0x10000/vid.conwidth; + fstep = w*0x10000/vid.conwidth; for (x=0 ; x>16]]; @@ -2166,16 +2169,16 @@ void SWDraw_ConsoleBackground (int lines) int vf, hf; for (y=0 ; ydata + v*320; - v = (vid.conheight - lines + y)*199/vid.conheight+1; - src2 = conback->data + v*320; + v = (vid.conheight - lines + y)*(h-1)/vid.conheight; + src = conback->data + v*w; + v = (vid.conheight - lines + y)*(h-1)/vid.conheight+1; + src2 = conback->data + v*w; - v = (vid.conheight - lines + y)*199/vid.conheight; - vf = (((vid.conheight - lines + y)*199.0/vid.conheight) - v) * 255; + v = (vid.conheight - lines + y)*(h-1)/vid.conheight; + vf = (((vid.conheight - lines + y)*(h-1.0)/vid.conheight) - v) * 255; f = 0; - fstep = 319*0x10000/vid.conwidth; + fstep = (w-1)*0x10000/vid.conwidth; for (x=0 ; x>16)*65536) / 256; @@ -2208,11 +2211,11 @@ void SWDraw_ConsoleBackground (int lines) { for (y=0 ; ydata + v*320; + v = (vid.conheight - lines + y)*h/vid.conheight; + src = conback->data + v*w; f = 0; - fstep = 320*0x10000/vid.conwidth; + fstep = w*0x10000/vid.conwidth; for (x=0 ; x>16]<<2) + 0])/255; @@ -2227,11 +2230,11 @@ void SWDraw_ConsoleBackground (int lines) { for (y=0 ; ydata + v*320; + v = (vid.conheight - lines + y)*h/vid.conheight; + src = conback->data + v*w; f = 0; - fstep = 320*0x10000/vid.conwidth; + fstep = w*0x10000/vid.conwidth; for (x=0 ; x>16]]; @@ -2247,7 +2250,7 @@ void SWDraw_ConsoleBackground (int lines) } } // put it back - memcpy(conback->data + 320*186, saveback, 320*8); +// memcpy(conback->data + 320*186, saveback, 320*8); } void SWDraw_EditorBackground (int lines)