2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
draw.c
|
|
|
|
|
|
|
|
this is the only file outside the refresh that touches the vid buffer
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program 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 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program 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, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
|
|
|
static __attribute__ ((unused)) const char rcsid[] =
|
|
|
|
"$Id$";
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-05-09 22:40:51 +00:00
|
|
|
#include "QF/draw.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2001-04-10 21:45:42 +00:00
|
|
|
#include "QF/sound.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
#include "d_iface.h"
|
2001-05-18 20:52:15 +00:00
|
|
|
#include "r_cvar.h"
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct {
|
|
|
|
vrect_t rect;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
byte *ptexbytes;
|
|
|
|
int rowbytes;
|
|
|
|
} rectdesc_t;
|
|
|
|
|
|
|
|
static rectdesc_t r_rectdesc;
|
|
|
|
|
|
|
|
byte *draw_chars; // 8*8 graphic characters
|
|
|
|
qpic_t *draw_disc;
|
|
|
|
qpic_t *draw_backtile;
|
|
|
|
|
|
|
|
|
|
|
|
/* Support Routines */
|
|
|
|
|
|
|
|
typedef struct cachepic_s {
|
|
|
|
char name[MAX_QPATH];
|
|
|
|
cache_user_t cache;
|
|
|
|
} cachepic_t;
|
|
|
|
|
|
|
|
#define MAX_CACHED_PICS 128
|
2001-05-22 09:24:56 +00:00
|
|
|
cachepic_t cachepics[MAX_CACHED_PICS];
|
|
|
|
int numcachepics;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
qpic_t *
|
2001-07-15 07:04:17 +00:00
|
|
|
Draw_PicFromWad (const char *name)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
return W_GetLumpName (name);
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
Draw_ClearCache (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
|
|
|
qpic_t *
|
2001-07-15 07:04:17 +00:00
|
|
|
Draw_CachePic (const char *path, qboolean alpha)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
cachepic_t *pic;
|
|
|
|
int i;
|
|
|
|
qpic_t *dat;
|
|
|
|
|
2001-05-22 09:24:56 +00:00
|
|
|
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++)
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!strcmp (path, pic->name))
|
|
|
|
break;
|
|
|
|
|
2001-05-22 09:24:56 +00:00
|
|
|
if (i == numcachepics) {
|
|
|
|
if (numcachepics == MAX_CACHED_PICS)
|
|
|
|
Sys_Error ("numcachepics == MAX_CACHED_PICS");
|
|
|
|
numcachepics++;
|
2001-02-19 21:15:25 +00:00
|
|
|
strcpy (pic->name, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
dat = Cache_Check (&pic->cache);
|
|
|
|
|
|
|
|
if (dat)
|
|
|
|
return dat;
|
|
|
|
|
2001-05-18 20:52:15 +00:00
|
|
|
// load the pic from disk
|
2003-02-14 19:46:07 +00:00
|
|
|
QFS_LoadCacheFile (path, &pic->cache);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
dat = (qpic_t *) pic->cache.data;
|
|
|
|
if (!dat) {
|
|
|
|
Sys_Error ("Draw_CachePic: failed to load %s", path);
|
|
|
|
}
|
|
|
|
|
|
|
|
SwapPic (dat);
|
|
|
|
|
|
|
|
return dat;
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2001-11-30 03:51:43 +00:00
|
|
|
Draw_TextBox (int x, int y, int width, int lines, byte alpha)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
qpic_t *p;
|
|
|
|
int cx, cy;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
// draw left side
|
|
|
|
cx = x;
|
|
|
|
cy = y;
|
|
|
|
p = Draw_CachePic ("gfx/box_tl.lmp", true);
|
|
|
|
Draw_Pic (cx, cy, p);
|
|
|
|
p = Draw_CachePic ("gfx/box_ml.lmp", true);
|
|
|
|
for (n = 0; n < lines; n++) {
|
|
|
|
cy += 8;
|
|
|
|
Draw_Pic (cx, cy, p);
|
|
|
|
}
|
|
|
|
p = Draw_CachePic ("gfx/box_bl.lmp", true);
|
|
|
|
Draw_Pic (cx, cy + 8, p);
|
|
|
|
|
|
|
|
// draw middle
|
|
|
|
cx += 8;
|
|
|
|
while (width > 0) {
|
|
|
|
cy = y;
|
|
|
|
p = Draw_CachePic ("gfx/box_tm.lmp", true);
|
|
|
|
Draw_Pic (cx, cy, p);
|
|
|
|
p = Draw_CachePic ("gfx/box_mm.lmp", true);
|
|
|
|
for (n = 0; n < lines; n++) {
|
|
|
|
cy += 8;
|
|
|
|
if (n == 1)
|
|
|
|
p = Draw_CachePic ("gfx/box_mm2.lmp", true);
|
|
|
|
Draw_Pic (cx, cy, p);
|
|
|
|
}
|
|
|
|
p = Draw_CachePic ("gfx/box_bm.lmp", true);
|
|
|
|
Draw_Pic (cx, cy + 8, p);
|
|
|
|
width -= 2;
|
|
|
|
cx += 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw right side
|
|
|
|
cy = y;
|
|
|
|
p = Draw_CachePic ("gfx/box_tr.lmp", true);
|
|
|
|
Draw_Pic (cx, cy, p);
|
|
|
|
p = Draw_CachePic ("gfx/box_mr.lmp", true);
|
|
|
|
for (n = 0; n < lines; n++) {
|
|
|
|
cy += 8;
|
|
|
|
Draw_Pic (cx, cy, p);
|
|
|
|
}
|
|
|
|
p = Draw_CachePic ("gfx/box_br.lmp", true);
|
|
|
|
Draw_Pic (cx, cy + 8, p);
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
Draw_Init (void)
|
|
|
|
{
|
|
|
|
draw_chars = W_GetLumpName ("conchars");
|
|
|
|
draw_disc = W_GetLumpName ("disc");
|
|
|
|
draw_backtile = W_GetLumpName ("backtile");
|
|
|
|
|
|
|
|
r_rectdesc.width = draw_backtile->width;
|
|
|
|
r_rectdesc.height = draw_backtile->height;
|
|
|
|
r_rectdesc.ptexbytes = draw_backtile->data;
|
|
|
|
r_rectdesc.rowbytes = draw_backtile->width;
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-08-25 02:47:11 +00:00
|
|
|
Draw_Character
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Draws one 8*8 graphics character with 0 being transparent.
|
|
|
|
It can be clipped to the top of the screen to allow the console to be
|
|
|
|
smoothly scrolled off.
|
|
|
|
*/
|
2002-01-10 20:19:22 +00:00
|
|
|
inline void
|
2001-12-17 23:41:58 +00:00
|
|
|
Draw_Character (int x, int y, unsigned int num)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
byte *dest;
|
|
|
|
byte *source;
|
|
|
|
int drawline;
|
|
|
|
int row, col;
|
|
|
|
|
|
|
|
num &= 255;
|
|
|
|
|
|
|
|
if (y <= -8)
|
|
|
|
return; // totally off screen
|
|
|
|
|
2003-04-17 00:01:48 +00:00
|
|
|
if (y > (int) vid.height - 8 || x < 0 || x > (int) vid.width - 8)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
if (num < 0 || num > 255)
|
|
|
|
return;
|
|
|
|
|
|
|
|
row = num >> 4;
|
|
|
|
col = num & 15;
|
|
|
|
source = draw_chars + (row << 10) + (col << 3);
|
|
|
|
|
|
|
|
if (y < 0) { // clipped
|
|
|
|
drawline = 8 + y;
|
|
|
|
source -= 128 * y;
|
|
|
|
y = 0;
|
|
|
|
} else
|
|
|
|
drawline = 8;
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest = vid.conbuffer + y * vid.conrowbytes + x;
|
|
|
|
|
|
|
|
while (drawline--) {
|
|
|
|
if (source[0])
|
|
|
|
dest[0] = source[0];
|
|
|
|
if (source[1])
|
|
|
|
dest[1] = source[1];
|
|
|
|
if (source[2])
|
|
|
|
dest[2] = source[2];
|
|
|
|
if (source[3])
|
|
|
|
dest[3] = source[3];
|
|
|
|
if (source[4])
|
|
|
|
dest[4] = source[4];
|
|
|
|
if (source[5])
|
|
|
|
dest[5] = source[5];
|
|
|
|
if (source[6])
|
|
|
|
dest[6] = source[6];
|
|
|
|
if (source[7])
|
|
|
|
dest[7] = source[7];
|
|
|
|
source += 128;
|
|
|
|
dest += vid.conrowbytes;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2001-08-25 02:47:11 +00:00
|
|
|
Draw_String (int x, int y, const char *str)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
while (*str) {
|
2001-08-29 02:16:17 +00:00
|
|
|
Draw_Character (x, y, *str++);
|
2001-02-19 21:15:25 +00:00
|
|
|
x += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2002-01-09 21:20:22 +00:00
|
|
|
void
|
|
|
|
Draw_nString (int x, int y, const char *str, int count)
|
|
|
|
{
|
2002-01-10 20:19:22 +00:00
|
|
|
while (count-- && *str) {
|
2002-01-09 21:20:22 +00:00
|
|
|
Draw_Character (x, y, *str++);
|
2002-01-10 20:19:22 +00:00
|
|
|
x += 8;
|
2002-01-09 21:20:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2001-08-25 02:47:11 +00:00
|
|
|
Draw_AltString (int x, int y, const char *str)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
while (*str) {
|
2001-08-29 02:16:17 +00:00
|
|
|
Draw_Character (x, y, (*str++) | 0x80);
|
2001-02-19 21:15:25 +00:00
|
|
|
x += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
Draw_Pixel (int x, int y, byte color)
|
|
|
|
{
|
|
|
|
byte *dest;
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest = vid.conbuffer + y * vid.conrowbytes + x;
|
|
|
|
*dest = color;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2001-12-09 14:05:30 +00:00
|
|
|
Draw_Crosshair (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
byte c = crosshaircolor->int_val;
|
|
|
|
|
|
|
|
if (crosshair->int_val == 2) {
|
|
|
|
x = scr_vrect.x + scr_vrect.width / 2 + cl_crossx->int_val;
|
|
|
|
y = scr_vrect.y + scr_vrect.height / 2 + cl_crossy->int_val;
|
|
|
|
Draw_Pixel (x - 1, y, c);
|
|
|
|
Draw_Pixel (x - 3, y, c);
|
|
|
|
Draw_Pixel (x + 1, y, c);
|
|
|
|
Draw_Pixel (x + 3, y, c);
|
|
|
|
Draw_Pixel (x, y - 1, c);
|
|
|
|
Draw_Pixel (x, y - 3, c);
|
|
|
|
Draw_Pixel (x, y + 1, c);
|
|
|
|
Draw_Pixel (x, y + 3, c);
|
|
|
|
} else if (crosshair->int_val)
|
2001-08-25 02:47:11 +00:00
|
|
|
Draw_Character (scr_vrect.x + scr_vrect.width / 2 - 4 +
|
|
|
|
cl_crossx->int_val,
|
|
|
|
scr_vrect.y + scr_vrect.height / 2 - 4 +
|
|
|
|
cl_crossy->int_val, '+');
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
Draw_Pic (int x, int y, qpic_t *pic)
|
|
|
|
{
|
|
|
|
byte *dest, *source, tbyte;
|
|
|
|
int v, u;
|
|
|
|
|
|
|
|
if (x < 0 || (unsigned int) (x + pic->width) > vid.width || y < 0 ||
|
|
|
|
(unsigned int) (y + pic->height) > vid.height) {
|
|
|
|
Sys_Error ("Draw_Pic: bad coordinates");
|
|
|
|
}
|
|
|
|
|
|
|
|
source = pic->data;
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest = vid.buffer + y * vid.rowbytes + x;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
if (pic->width & 7) { // general
|
|
|
|
for (v = 0; v < pic->height; v++) {
|
|
|
|
for (u = 0; u < pic->width; u++)
|
|
|
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u] = tbyte;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest += vid.rowbytes;
|
|
|
|
source += pic->width;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-11-21 19:13:53 +00:00
|
|
|
} else { // unwound
|
2001-02-19 21:15:25 +00:00
|
|
|
for (v = 0; v < pic->height; v++) {
|
2001-11-21 19:13:53 +00:00
|
|
|
for (u = 0; u < pic->width; u += 8) {
|
|
|
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u] = tbyte;
|
|
|
|
if ((tbyte = source[u + 1]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 1] = tbyte;
|
|
|
|
if ((tbyte = source[u + 2]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 2] = tbyte;
|
|
|
|
if ((tbyte = source[u + 3]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 3] = tbyte;
|
|
|
|
if ((tbyte = source[u + 4]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 4] = tbyte;
|
|
|
|
if ((tbyte = source[u + 5]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 5] = tbyte;
|
|
|
|
if ((tbyte = source[u + 6]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 6] = tbyte;
|
|
|
|
if ((tbyte = source[u + 7]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 7] = tbyte;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-11-21 19:13:53 +00:00
|
|
|
dest += vid.rowbytes;
|
2001-02-19 21:15:25 +00:00
|
|
|
source += pic->width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|
|
|
int height)
|
|
|
|
{
|
2002-07-25 04:30:50 +00:00
|
|
|
byte *dest, *source, tbyte;
|
|
|
|
int u, v;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-04-17 00:01:48 +00:00
|
|
|
if ((x < 0) || (x + width > (int) vid.width)
|
|
|
|
|| (y < 0) || (y + height > (int) vid.height)) {
|
2001-08-29 02:16:17 +00:00
|
|
|
Sys_Error ("Draw_SubPic: bad coordinates");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source = pic->data + srcy * pic->width + srcx;
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest = vid.buffer + y * vid.rowbytes + x;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-25 04:30:50 +00:00
|
|
|
if (width & 7) { // general
|
|
|
|
for (v = 0; v < height; v++) {
|
|
|
|
for (u = 0; u < width; u++)
|
|
|
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u] = tbyte;
|
|
|
|
|
|
|
|
dest += vid.rowbytes;
|
|
|
|
source += pic->width;
|
|
|
|
}
|
|
|
|
} else { // unwound
|
|
|
|
for (v = 0; v < height; v++) {
|
|
|
|
for (u = 0; u < width; u += 8) {
|
|
|
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u] = tbyte;
|
|
|
|
if ((tbyte = source[u + 1]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 1] = tbyte;
|
|
|
|
if ((tbyte = source[u + 2]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 2] = tbyte;
|
|
|
|
if ((tbyte = source[u + 3]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 3] = tbyte;
|
|
|
|
if ((tbyte = source[u + 4]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 4] = tbyte;
|
|
|
|
if ((tbyte = source[u + 5]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 5] = tbyte;
|
|
|
|
if ((tbyte = source[u + 6]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 6] = tbyte;
|
|
|
|
if ((tbyte = source[u + 7]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 7] = tbyte;
|
|
|
|
}
|
|
|
|
dest += vid.rowbytes;
|
|
|
|
source += pic->width;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
|
|
|
|
{
|
|
|
|
byte *dest, *source, tbyte;
|
|
|
|
int v, u;
|
|
|
|
|
|
|
|
if (x < 0 || (unsigned int) (x + pic->width) > vid.width || y < 0 ||
|
|
|
|
(unsigned int) (y + pic->height) > vid.height) {
|
|
|
|
Sys_Error ("Draw_TransPic: bad coordinates");
|
|
|
|
}
|
|
|
|
|
|
|
|
source = pic->data;
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest = vid.buffer + y * vid.rowbytes + x;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
if (pic->width & 7) { // general
|
|
|
|
for (v = 0; v < pic->height; v++) {
|
|
|
|
for (u = 0; u < pic->width; u++)
|
|
|
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u] = translation[tbyte];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest += vid.rowbytes;
|
|
|
|
source += pic->width;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-11-21 19:13:53 +00:00
|
|
|
} else { // unwound
|
2001-02-19 21:15:25 +00:00
|
|
|
for (v = 0; v < pic->height; v++) {
|
2001-11-21 19:13:53 +00:00
|
|
|
for (u = 0; u < pic->width; u += 8) {
|
|
|
|
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u] = translation[tbyte];
|
|
|
|
if ((tbyte = source[u + 1]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 1] = translation[tbyte];
|
|
|
|
if ((tbyte = source[u + 2]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 2] = translation[tbyte];
|
|
|
|
if ((tbyte = source[u + 3]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 3] = translation[tbyte];
|
|
|
|
if ((tbyte = source[u + 4]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 4] = translation[tbyte];
|
|
|
|
if ((tbyte = source[u + 5]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 5] = translation[tbyte];
|
|
|
|
if ((tbyte = source[u + 6]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 6] = translation[tbyte];
|
|
|
|
if ((tbyte = source[u + 7]) != TRANSPARENT_COLOR)
|
|
|
|
dest[u + 7] = translation[tbyte];
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-11-21 19:13:53 +00:00
|
|
|
dest += vid.rowbytes;
|
2001-02-19 21:15:25 +00:00
|
|
|
source += pic->width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Draw_ConsoleBackground (int lines)
|
|
|
|
{
|
|
|
|
int x, y, v;
|
|
|
|
byte *src, *dest;
|
|
|
|
int f, fstep;
|
|
|
|
qpic_t *conback;
|
|
|
|
|
|
|
|
conback = Draw_CachePic ("gfx/conback.lmp", false);
|
|
|
|
|
2001-05-18 20:52:15 +00:00
|
|
|
// draw the pic
|
2001-11-21 19:13:53 +00:00
|
|
|
dest = vid.conbuffer;
|
|
|
|
|
|
|
|
for (y = 0; y < lines; y++, dest += vid.conrowbytes) {
|
|
|
|
v = (vid.conheight - lines + y) * 200 / vid.conheight;
|
|
|
|
src = conback->data + v * 320;
|
|
|
|
if (vid.conwidth == 320)
|
|
|
|
memcpy (dest, src, vid.conwidth);
|
|
|
|
else {
|
2001-02-19 21:15:25 +00:00
|
|
|
f = 0;
|
|
|
|
fstep = 320 * 0x10000 / vid.conwidth;
|
2003-04-17 00:01:48 +00:00
|
|
|
for (x = 0; x < (int) vid.conwidth; x += 4) {
|
2001-11-21 19:13:53 +00:00
|
|
|
dest[x] = src[f >> 16];
|
2001-02-19 21:15:25 +00:00
|
|
|
f += fstep;
|
2001-11-21 19:13:53 +00:00
|
|
|
dest[x + 1] = src[f >> 16];
|
2001-02-19 21:15:25 +00:00
|
|
|
f += fstep;
|
2001-11-21 19:13:53 +00:00
|
|
|
dest[x + 2] = src[f >> 16];
|
2001-02-19 21:15:25 +00:00
|
|
|
f += fstep;
|
2001-11-21 19:13:53 +00:00
|
|
|
dest[x + 3] = src[f >> 16];
|
2001-02-19 21:15:25 +00:00
|
|
|
f += fstep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
Draw_AltString (vid.conwidth - strlen (cl_verstring->string) * 8 - 11,
|
|
|
|
lines - 14, cl_verstring->string);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-11-21 19:13:53 +00:00
|
|
|
R_DrawRect (vrect_t *prect, int rowbytes, byte * psrc, int transparent)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
byte t;
|
|
|
|
int i, j, srcdelta, destdelta;
|
|
|
|
byte *pdest;
|
|
|
|
|
|
|
|
pdest = vid.buffer + (prect->y * vid.rowbytes) + prect->x;
|
|
|
|
|
|
|
|
srcdelta = rowbytes - prect->width;
|
|
|
|
destdelta = vid.rowbytes - prect->width;
|
|
|
|
|
|
|
|
if (transparent) {
|
|
|
|
for (i = 0; i < prect->height; i++) {
|
|
|
|
for (j = 0; j < prect->width; j++) {
|
|
|
|
t = *psrc;
|
|
|
|
if (t != TRANSPARENT_COLOR) {
|
|
|
|
*pdest = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
psrc++;
|
|
|
|
pdest++;
|
|
|
|
}
|
|
|
|
|
|
|
|
psrc += srcdelta;
|
|
|
|
pdest += destdelta;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < prect->height; i++) {
|
|
|
|
memcpy (pdest, psrc, prect->width);
|
|
|
|
psrc += rowbytes;
|
|
|
|
pdest += vid.rowbytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Draw_TileClear
|
|
|
|
|
|
|
|
This repeats a 64*64 tile graphic to fill the screen around a sized down
|
|
|
|
refresh window.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Draw_TileClear (int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
int width, height, tileoffsetx, tileoffsety;
|
|
|
|
byte *psrc;
|
|
|
|
vrect_t vr;
|
|
|
|
|
|
|
|
r_rectdesc.rect.x = x;
|
|
|
|
r_rectdesc.rect.y = y;
|
|
|
|
r_rectdesc.rect.width = w;
|
|
|
|
r_rectdesc.rect.height = h;
|
|
|
|
|
|
|
|
vr.y = r_rectdesc.rect.y;
|
|
|
|
height = r_rectdesc.rect.height;
|
|
|
|
|
|
|
|
tileoffsety = vr.y % r_rectdesc.height;
|
|
|
|
|
|
|
|
while (height > 0) {
|
|
|
|
vr.x = r_rectdesc.rect.x;
|
|
|
|
width = r_rectdesc.rect.width;
|
|
|
|
|
|
|
|
if (tileoffsety != 0)
|
|
|
|
vr.height = r_rectdesc.height - tileoffsety;
|
|
|
|
else
|
|
|
|
vr.height = r_rectdesc.height;
|
|
|
|
|
|
|
|
if (vr.height > height)
|
|
|
|
vr.height = height;
|
|
|
|
|
|
|
|
tileoffsetx = vr.x % r_rectdesc.width;
|
|
|
|
|
|
|
|
while (width > 0) {
|
|
|
|
if (tileoffsetx != 0)
|
|
|
|
vr.width = r_rectdesc.width - tileoffsetx;
|
|
|
|
else
|
|
|
|
vr.width = r_rectdesc.width;
|
|
|
|
|
|
|
|
if (vr.width > width)
|
|
|
|
vr.width = width;
|
|
|
|
|
|
|
|
psrc = r_rectdesc.ptexbytes +
|
|
|
|
(tileoffsety * r_rectdesc.rowbytes) + tileoffsetx;
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
R_DrawRect (&vr, r_rectdesc.rowbytes, psrc, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
vr.x += vr.width;
|
|
|
|
width -= vr.width;
|
2001-05-18 20:52:15 +00:00
|
|
|
tileoffsetx = 0; // only the left tile can be left-clipped
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vr.y += vr.height;
|
|
|
|
height -= vr.height;
|
2001-05-18 20:52:15 +00:00
|
|
|
tileoffsety = 0; // only the top tile can be top-clipped
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Draw_Fill
|
|
|
|
|
|
|
|
Fills a box of pixels with a single color
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Draw_Fill (int x, int y, int w, int h, int c)
|
|
|
|
{
|
|
|
|
byte *dest;
|
|
|
|
int u, v;
|
|
|
|
|
2003-04-17 00:01:48 +00:00
|
|
|
if (x < 0 || x + w > (int) vid.width
|
|
|
|
|| y < 0 || y + h > (int) vid.height) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("Bad Draw_Fill(%d, %d, %d, %d, %c)\n", x, y, w, h, c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
dest = vid.buffer + y * vid.rowbytes + x;
|
|
|
|
for (v = 0; v < h; v++, dest += vid.rowbytes)
|
|
|
|
for (u = 0; u < w; u++)
|
|
|
|
dest[u] = c;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
Draw_FadeScreen (void)
|
|
|
|
{
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int x, y;
|
2001-02-19 21:15:25 +00:00
|
|
|
byte *pbuf;
|
|
|
|
|
|
|
|
VID_UnlockBuffer ();
|
|
|
|
S_ExtraUpdate ();
|
|
|
|
VID_LockBuffer ();
|
|
|
|
|
|
|
|
for (y = 0; y < vid.height; y++) {
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
pbuf = (byte *) (vid.buffer + vid.rowbytes * y);
|
|
|
|
t = (y & 1) << 1;
|
|
|
|
|
|
|
|
for (x = 0; x < vid.width; x++) {
|
|
|
|
if ((x & 3) != t)
|
|
|
|
pbuf[x] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VID_UnlockBuffer ();
|
|
|
|
S_ExtraUpdate ();
|
|
|
|
VID_LockBuffer ();
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
Draw_BeginDisc
|
|
|
|
|
|
|
|
Draws the little blue disc in the corner of the screen.
|
|
|
|
Call before beginning any disc IO.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Draw_BeginDisc (void)
|
|
|
|
{
|
|
|
|
D_BeginDirectRect (vid.width - 24, 0, draw_disc->data, 24, 24);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Draw_EndDisc
|
|
|
|
|
|
|
|
Erases the disc icon.
|
|
|
|
Call after completing any disc IO
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Draw_EndDisc (void)
|
|
|
|
{
|
|
|
|
D_EndDirectRect (vid.width - 24, 0, 24, 24);
|
|
|
|
}
|