newtree/source/draw.c

909 lines
19 KiB
C
Raw Normal View History

/*
draw.c
2000-05-22 06:58:14 +00:00
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:
2000-05-10 11:29:38 +00:00
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
2000-05-10 11:29:38 +00:00
2000-05-17 10:03:19 +00:00
#ifdef HAVE_CONFIG_H
# include "config.h"
2000-05-17 10:03:19 +00:00
#endif
2000-12-30 02:16:36 +00:00
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "client.h"
#include "console.h"
2000-12-30 02:16:36 +00:00
#include "d_iface.h"
#include "draw.h"
#include "quakefs.h"
#include "sound.h"
2000-12-30 02:16:36 +00:00
#include "sys.h"
2000-05-31 22:49:53 +00:00
2000-05-10 11:29:38 +00:00
typedef struct {
vrect_t rect;
int width;
int height;
byte *ptexbytes;
int rowbytes;
2000-05-10 11:29:38 +00:00
} rectdesc_t;
static rectdesc_t r_rectdesc;
2000-05-10 11:29:38 +00:00
byte *draw_chars; // 8*8 graphic characters
qpic_t *draw_disc;
qpic_t *draw_backtile;
2000-05-10 11:29:38 +00:00
cvar_t *cl_verstring;
2000-05-10 11:29:38 +00:00
//=============================================================================
/* Support Routines */
typedef struct cachepic_s {
char name[MAX_QPATH];
cache_user_t cache;
2000-05-10 11:29:38 +00:00
} cachepic_t;
#define MAX_CACHED_PICS 128
cachepic_t menu_cachepics[MAX_CACHED_PICS];
int menu_numcachepics;
2000-05-10 11:29:38 +00:00
qpic_t *
Draw_PicFromWad (char *name)
2000-05-10 11:29:38 +00:00
{
return W_GetLumpName (name);
}
/*
Draw_ClearCache
This is a no-op in software targets
*/
void
Draw_ClearCache (void)
{
}
2000-05-10 11:29:38 +00:00
/*
================
Draw_CachePic
================
*/
qpic_t *
Draw_CachePic (char *path)
2000-05-10 11:29:38 +00:00
{
cachepic_t *pic;
int i;
qpic_t *dat;
for (pic = menu_cachepics, i = 0; i < menu_numcachepics; pic++, i++)
2000-05-10 11:29:38 +00:00
if (!strcmp (path, pic->name))
break;
if (i == menu_numcachepics) {
2000-05-10 11:29:38 +00:00
if (menu_numcachepics == MAX_CACHED_PICS)
Sys_Error ("menu_numcachepics == MAX_CACHED_PICS");
menu_numcachepics++;
strcpy (pic->name, path);
}
dat = Cache_Check (&pic->cache);
if (dat)
return dat;
//
// load the pic from disk
//
COM_LoadCacheFile (path, &pic->cache);
dat = (qpic_t *) pic->cache.data;
if (!dat) {
2000-05-10 11:29:38 +00:00
Sys_Error ("Draw_CachePic: failed to load %s", path);
}
SwapPic (dat);
return dat;
}
void
Draw_TextBox (int x, int y, int width, int lines)
{
qpic_t *p;
int cx, cy;
int n;
// draw left side
cx = x;
cy = y;
p = Draw_CachePic ("gfx/box_tl.lmp");
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_ml.lmp");
for (n = 0; n < lines; n++) {
cy += 8;
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bl.lmp");
Draw_Pic (cx, cy + 8, p);
// draw middle
cx += 8;
while (width > 0) {
cy = y;
p = Draw_CachePic ("gfx/box_tm.lmp");
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_mm.lmp");
for (n = 0; n < lines; n++) {
cy += 8;
if (n == 1)
p = Draw_CachePic ("gfx/box_mm2.lmp");
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_bm.lmp");
Draw_Pic (cx, cy + 8, p);
width -= 2;
cx += 16;
}
2000-05-10 11:29:38 +00:00
// draw right side
cy = y;
p = Draw_CachePic ("gfx/box_tr.lmp");
Draw_Pic (cx, cy, p);
p = Draw_CachePic ("gfx/box_mr.lmp");
for (n = 0; n < lines; n++) {
cy += 8;
Draw_Pic (cx, cy, p);
}
p = Draw_CachePic ("gfx/box_br.lmp");
Draw_Pic (cx, cy + 8, p);
}
2000-05-10 11:29:38 +00:00
/*
===============
Draw_Init
===============
*/
void
Draw_Init (void)
2000-05-10 11:29:38 +00:00
{
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;
cl_verstring =
2000-12-31 04:46:04 +00:00
Cvar_Get ("cl_verstring", PROGRAM " " VERSION, CVAR_NONE, "Client version string");
2000-05-10 11:29:38 +00:00
}
void
Draw_Init_Cvars (void)
{
}
2000-05-10 11:29:38 +00:00
/*
================
Draw_Character8
2000-05-10 11:29:38 +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.
================
*/
void
Draw_Character8 (int x, int y, int num)
2000-05-10 11:29:38 +00:00
{
byte *dest;
byte *source;
unsigned short *pusdest;
int drawline;
int row, col;
2000-05-10 11:29:38 +00:00
num &= 255;
2000-05-10 11:29:38 +00:00
if (y <= -8)
return; // totally off screen
2000-05-10 11:29:38 +00:00
if (y > vid.height - 8 || x < 0 || x > vid.width - 8)
return;
if (num < 0 || num > 255)
return;
row = num >> 4;
col = num & 15;
source = draw_chars + (row << 10) + (col << 3);
2000-05-10 11:29:38 +00:00
if (y < 0) { // clipped
2000-05-10 11:29:38 +00:00
drawline = 8 + y;
source -= 128 * y;
2000-05-10 11:29:38 +00:00
y = 0;
} else
2000-05-10 11:29:38 +00:00
drawline = 8;
if (r_pixbytes == 1) {
dest = vid.conbuffer + y * vid.conrowbytes + x;
while (drawline--) {
2000-05-10 11:29:38 +00:00
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;
}
} else {
// FIXME: pre-expand to native format?
2000-05-10 11:29:38 +00:00
pusdest = (unsigned short *)
((byte *) vid.conbuffer + y * vid.conrowbytes + (x << 1));
2000-05-10 11:29:38 +00:00
while (drawline--) {
2000-05-10 11:29:38 +00:00
if (source[0])
pusdest[0] = d_8to16table[source[0]];
if (source[1])
pusdest[1] = d_8to16table[source[1]];
if (source[2])
pusdest[2] = d_8to16table[source[2]];
if (source[3])
pusdest[3] = d_8to16table[source[3]];
if (source[4])
pusdest[4] = d_8to16table[source[4]];
if (source[5])
pusdest[5] = d_8to16table[source[5]];
if (source[6])
pusdest[6] = d_8to16table[source[6]];
if (source[7])
pusdest[7] = d_8to16table[source[7]];
source += 128;
pusdest += (vid.conrowbytes >> 1);
}
}
}
/*
================
Draw_String8
2000-05-10 11:29:38 +00:00
================
*/
void
Draw_String8 (int x, int y, char *str)
2000-05-10 11:29:38 +00:00
{
while (*str) {
Draw_Character8 (x, y, *str);
2000-05-10 11:29:38 +00:00
str++;
x += 8;
}
}
/*
================
Draw_AltString8
2000-05-10 11:29:38 +00:00
================
*/
void
Draw_AltString8 (int x, int y, char *str)
2000-05-10 11:29:38 +00:00
{
while (*str) {
Draw_Character8 (x, y, (*str) | 0x80);
2000-05-10 11:29:38 +00:00
str++;
x += 8;
}
}
void
Draw_Pixel (int x, int y, byte color)
2000-05-10 11:29:38 +00:00
{
byte *dest;
unsigned short *pusdest;
2000-05-10 11:29:38 +00:00
if (r_pixbytes == 1) {
dest = vid.conbuffer + y * vid.conrowbytes + x;
2000-05-10 11:29:38 +00:00
*dest = color;
} else {
// FIXME: pre-expand to native format?
2000-05-10 11:29:38 +00:00
pusdest = (unsigned short *)
((byte *) vid.conbuffer + y * vid.conrowbytes + (x << 1));
2000-05-10 11:29:38 +00:00
*pusdest = d_8to16table[color];
}
}
void
Draw_Crosshair (void)
2000-05-10 11:29:38 +00:00
{
int x, y;
extern cvar_t *crosshair, *cl_crossx, *cl_crossy, *crosshaircolor;
extern vrect_t scr_vrect;
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)
Draw_Character8 (scr_vrect.x + scr_vrect.width / 2 - 4 +
cl_crossx->int_val,
scr_vrect.y + scr_vrect.height / 2 - 4 +
cl_crossy->int_val, '+');
2000-05-10 11:29:38 +00:00
}
/*
=============
Draw_Pic
=============
*/
void
Draw_Pic (int x, int y, qpic_t *pic)
2000-05-10 11:29:38 +00:00
{
byte *dest, *source, tbyte;
unsigned short *pusdest;
int v, u;
2000-05-10 11:29:38 +00:00
if (x < 0 || (unsigned int) (x + pic->width) > vid.width || y < 0 ||
(unsigned int) (y + pic->height) > vid.height) {
2000-05-10 11:29:38 +00:00
Sys_Error ("Draw_Pic: bad coordinates");
}
source = pic->data;
if (r_pixbytes == 1) {
2000-05-10 11:29:38 +00:00
dest = vid.buffer + y * vid.rowbytes + x;
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)
2000-11-19 21:34:27 +00:00
dest[u] = tbyte;
2000-11-19 21:34:27 +00:00
dest += vid.rowbytes;
source += pic->width;
}
} else { // unwound
for (v = 0; v < pic->height; v++) {
for (u = 0; u < pic->width; u += 8) {
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
2000-11-19 21:34:27 +00:00
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;
2000-11-19 21:34:27 +00:00
}
dest += vid.rowbytes;
source += pic->width;
}
2000-05-10 11:29:38 +00:00
}
} else {
// FIXME: pretranslate at load time?
pusdest = (unsigned short *) vid.buffer + y * (vid.rowbytes >> 1) + x;
for (v = 0; v < pic->height; v++) {
for (u = 0; u < pic->width; u++) {
2000-11-19 21:34:27 +00:00
tbyte = source[u];
if (tbyte != TRANSPARENT_COLOR) {
2000-11-19 21:34:27 +00:00
pusdest[u] = d_8to16table[tbyte];
}
2000-05-10 11:29:38 +00:00
}
pusdest += vid.rowbytes >> 1;
source += pic->width;
}
}
}
/*
=============
Draw_SubPic
=============
*/
void
Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
int height)
2000-05-10 11:29:38 +00:00
{
byte *dest, *source;
unsigned short *pusdest;
int v, u;
2000-05-10 11:29:38 +00:00
if ((x < 0) ||
(x + width > vid.width) || (y < 0) || (y + height > vid.height)) {
2000-05-10 11:29:38 +00:00
Sys_Error ("Draw_Pic: bad coordinates");
}
source = pic->data + srcy * pic->width + srcx;
if (r_pixbytes == 1) {
2000-05-10 11:29:38 +00:00
dest = vid.buffer + y * vid.rowbytes + x;
for (v = 0; v < height; v++) {
memcpy (dest, source, width);
2000-05-10 11:29:38 +00:00
dest += vid.rowbytes;
source += pic->width;
}
} else {
// FIXME: pretranslate at load time?
pusdest = (unsigned short *) vid.buffer + y * (vid.rowbytes >> 1) + x;
for (v = 0; v < height; v++) {
for (u = srcx; u < (srcx + width); u++) {
2000-05-10 11:29:38 +00:00
pusdest[u] = d_8to16table[source[u]];
}
pusdest += vid.rowbytes >> 1;
source += pic->width;
}
}
}
/*
=============
Draw_TransPicTranslate
=============
*/
void
Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
2000-05-10 11:29:38 +00:00
{
byte *dest, *source, tbyte;
unsigned short *pusdest;
int v, u;
2000-05-10 11:29:38 +00:00
if (x < 0 || (unsigned int) (x + pic->width) > vid.width || y < 0 ||
(unsigned int) (y + pic->height) > vid.height) {
2000-05-10 11:29:38 +00:00
Sys_Error ("Draw_TransPic: bad coordinates");
}
2000-05-10 11:29:38 +00:00
source = pic->data;
if (r_pixbytes == 1) {
2000-05-10 11:29:38 +00:00
dest = vid.buffer + y * vid.rowbytes + x;
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)
2000-05-10 11:29:38 +00:00
dest[u] = translation[tbyte];
dest += vid.rowbytes;
source += pic->width;
}
} else { // unwound
for (v = 0; v < pic->height; v++) {
for (u = 0; u < pic->width; u += 8) {
if ((tbyte = source[u]) != TRANSPARENT_COLOR)
2000-05-10 11:29:38 +00:00
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];
2000-05-10 11:29:38 +00:00
}
dest += vid.rowbytes;
source += pic->width;
}
}
} else {
// FIXME: pretranslate at load time?
pusdest = (unsigned short *) vid.buffer + y * (vid.rowbytes >> 1) + x;
for (v = 0; v < pic->height; v++) {
for (u = 0; u < pic->width; u++) {
2000-05-10 11:29:38 +00:00
tbyte = source[u];
if (tbyte != TRANSPARENT_COLOR) {
2000-05-10 11:29:38 +00:00
pusdest[u] = d_8to16table[tbyte];
}
}
pusdest += vid.rowbytes >> 1;
source += pic->width;
}
}
}
/*
================
Draw_ConsoleBackground
================
*/
void
Draw_ConsoleBackground (int lines)
2000-05-10 11:29:38 +00:00
{
int x, y, v;
byte *src, *dest;
unsigned short *pusdest;
int f, fstep;
qpic_t *conback;
2000-05-10 11:29:38 +00:00
conback = Draw_CachePic ("gfx/conback.lmp");
// draw the pic
if (r_pixbytes == 1) {
2000-05-10 11:29:38 +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;
2000-05-10 11:29:38 +00:00
if (vid.conwidth == 320)
memcpy (dest, src, vid.conwidth);
else {
2000-05-10 11:29:38 +00:00
f = 0;
fstep = 320 * 0x10000 / vid.conwidth;
for (x = 0; x < vid.conwidth; x += 4) {
dest[x] = src[f >> 16];
2000-05-10 11:29:38 +00:00
f += fstep;
dest[x + 1] = src[f >> 16];
2000-05-10 11:29:38 +00:00
f += fstep;
dest[x + 2] = src[f >> 16];
2000-05-10 11:29:38 +00:00
f += fstep;
dest[x + 3] = src[f >> 16];
2000-05-10 11:29:38 +00:00
f += fstep;
}
}
}
} else {
pusdest = (unsigned short *) vid.conbuffer;
for (y = 0; y < lines; y++, pusdest += (vid.conrowbytes >> 1)) {
// FIXME: pre-expand to native format?
// FIXME: does the endian switching go away in production?
v = (vid.conheight - lines + y) * 200 / vid.conheight;
src = conback->data + v * 320;
2000-05-10 11:29:38 +00:00
f = 0;
fstep = 320 * 0x10000 / vid.conwidth;
for (x = 0; x < vid.conwidth; x += 4) {
pusdest[x] = d_8to16table[src[f >> 16]];
2000-05-10 11:29:38 +00:00
f += fstep;
pusdest[x + 1] = d_8to16table[src[f >> 16]];
2000-05-10 11:29:38 +00:00
f += fstep;
pusdest[x + 2] = d_8to16table[src[f >> 16]];
2000-05-10 11:29:38 +00:00
f += fstep;
pusdest[x + 3] = d_8to16table[src[f >> 16]];
2000-05-10 11:29:38 +00:00
f += fstep;
}
}
}
if (!cls.download)
Draw_AltString8 (vid.conwidth - strlen (cl_verstring->string)
* 8 - 11, lines - 14, cl_verstring->string);
2000-05-10 11:29:38 +00:00
}
/*
==============
R_DrawRect8
==============
*/
void
R_DrawRect8 (vrect_t *prect, int rowbytes, byte * psrc, int transparent)
2000-05-10 11:29:38 +00:00
{
byte t;
int i, j, srcdelta, destdelta;
byte *pdest;
2000-05-10 11:29:38 +00:00
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++) {
2000-05-10 11:29:38 +00:00
t = *psrc;
if (t != TRANSPARENT_COLOR) {
2000-05-10 11:29:38 +00:00
*pdest = t;
}
psrc++;
pdest++;
}
psrc += srcdelta;
pdest += destdelta;
}
} else {
for (i = 0; i < prect->height; i++) {
2000-05-10 11:29:38 +00:00
memcpy (pdest, psrc, prect->width);
psrc += rowbytes;
pdest += vid.rowbytes;
}
}
}
/*
==============
R_DrawRect16
==============
*/
void
R_DrawRect16 (vrect_t *prect, int rowbytes, byte * psrc, int transparent)
2000-05-10 11:29:38 +00:00
{
byte t;
int i, j, srcdelta, destdelta;
unsigned short *pdest;
2000-05-10 11:29:38 +00:00
// FIXME: would it be better to pre-expand native-format versions?
pdest = (unsigned short *) vid.buffer +
(prect->y * (vid.rowbytes >> 1)) + prect->x;
2000-05-10 11:29:38 +00:00
srcdelta = rowbytes - prect->width;
destdelta = (vid.rowbytes >> 1) - prect->width;
if (transparent) {
for (i = 0; i < prect->height; i++) {
for (j = 0; j < prect->width; j++) {
2000-05-10 11:29:38 +00:00
t = *psrc;
if (t != TRANSPARENT_COLOR) {
2000-05-10 11:29:38 +00:00
*pdest = d_8to16table[t];
}
psrc++;
pdest++;
}
psrc += srcdelta;
pdest += destdelta;
}
} else {
for (i = 0; i < prect->height; i++) {
for (j = 0; j < prect->width; j++) {
2000-05-10 11:29:38 +00:00
*pdest = d_8to16table[*psrc];
psrc++;
pdest++;
}
psrc += srcdelta;
pdest += destdelta;
}
}
}
/*
=============
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)
2000-05-10 11:29:38 +00:00
{
int width, height, tileoffsetx, tileoffsety;
byte *psrc;
vrect_t vr;
2000-05-10 11:29:38 +00:00
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) {
2000-05-10 11:29:38 +00:00
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) {
2000-05-10 11:29:38 +00:00
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;
2000-05-10 11:29:38 +00:00
if (r_pixbytes == 1) {
2000-05-10 11:29:38 +00:00
R_DrawRect8 (&vr, r_rectdesc.rowbytes, psrc, 0);
} else {
2000-05-10 11:29:38 +00:00
R_DrawRect16 (&vr, r_rectdesc.rowbytes, psrc, 0);
}
vr.x += vr.width;
width -= vr.width;
tileoffsetx = 0; // only the left tile can be
// left-clipped
2000-05-10 11:29:38 +00:00
}
vr.y += vr.height;
height -= vr.height;
tileoffsety = 0; // only the top tile can be
// top-clipped
2000-05-10 11:29:38 +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)
2000-05-10 11:29:38 +00:00
{
byte *dest;
unsigned short *pusdest;
unsigned int uc;
int u, v;
if (x < 0 || x + w > vid.width || y < 0 || y + h > vid.height) {
Con_Printf ("Bad Draw_Fill(%d, %d, %d, %d, %c)\n", x, y, w, h, c);
2000-05-10 11:29:38 +00:00
return;
}
if (r_pixbytes == 1) {
dest = vid.buffer + y * vid.rowbytes + x;
for (v = 0; v < h; v++, dest += vid.rowbytes)
for (u = 0; u < w; u++)
2000-05-10 11:29:38 +00:00
dest[u] = c;
} else {
2000-05-10 11:29:38 +00:00
uc = d_8to16table[c];
pusdest = (unsigned short *) vid.buffer + y * (vid.rowbytes >> 1) + x;
for (v = 0; v < h; v++, pusdest += (vid.rowbytes >> 1))
for (u = 0; u < w; u++)
2000-05-10 11:29:38 +00:00
pusdest[u] = uc;
}
}
2000-05-10 11:29:38 +00:00
//=============================================================================
/*
================
Draw_FadeScreen
================
*/
void
Draw_FadeScreen (void)
2000-05-10 11:29:38 +00:00
{
int x, y;
byte *pbuf;
2000-05-10 11:29:38 +00:00
VID_UnlockBuffer ();
S_ExtraUpdate ();
VID_LockBuffer ();
for (y = 0; y < vid.height; y++) {
int t;
2000-05-10 11:29:38 +00:00
pbuf = (byte *) (vid.buffer + vid.rowbytes * y);
2000-05-10 11:29:38 +00:00
t = (y & 1) << 1;
for (x = 0; x < vid.width; x++) {
2000-05-10 11:29:38 +00:00
if ((x & 3) != t)
pbuf[x] = 0;
}
}
VID_UnlockBuffer ();
S_ExtraUpdate ();
VID_LockBuffer ();
}
//=============================================================================
/*
================
Draw_BeginDisc
Draws the little blue disc in the corner of the screen.
Call before beginning any disc IO.
================
*/
void
Draw_BeginDisc (void)
2000-05-10 11:29:38 +00:00
{
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)
2000-05-10 11:29:38 +00:00
{
D_EndDirectRect (vid.width - 24, 0, 24, 24);
}