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
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2012-02-01 08:46:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2021-07-10 09:04:34 +00:00
|
|
|
#include "QF/ui/view.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
#include "d_iface.h"
|
2022-03-24 03:22:27 +00:00
|
|
|
#include "d_local.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2012-02-17 07:13:56 +00:00
|
|
|
#include "vid_internal.h"
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
byte *ptexbytes;
|
|
|
|
int rowbytes;
|
|
|
|
} rectdesc_t;
|
|
|
|
|
|
|
|
static rectdesc_t r_rectdesc;
|
|
|
|
|
2012-02-18 05:34:14 +00:00
|
|
|
static qpic_t *draw_disc;
|
|
|
|
static qpic_t *draw_backtile;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Support Routines */
|
|
|
|
|
|
|
|
typedef struct cachepic_s {
|
|
|
|
char name[MAX_QPATH];
|
|
|
|
cache_user_t cache;
|
|
|
|
} cachepic_t;
|
|
|
|
|
|
|
|
#define MAX_CACHED_PICS 128
|
2012-02-18 05:34:14 +00:00
|
|
|
static cachepic_t cachepics[MAX_CACHED_PICS];
|
|
|
|
static int numcachepics;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-12-28 10:17:15 +00:00
|
|
|
#define CLIP(x,y,w,h,mw,mh) \
|
|
|
|
do { \
|
|
|
|
if (y < 0) { \
|
|
|
|
h += y; \
|
|
|
|
y = 0; \
|
|
|
|
} \
|
|
|
|
if (y + h > mh) \
|
|
|
|
h = mh - y; \
|
|
|
|
if (h <= 0) \
|
|
|
|
return; \
|
|
|
|
if (x < 0) { \
|
|
|
|
w += x; \
|
|
|
|
x = 0; \
|
|
|
|
} \
|
|
|
|
if (x + w > mw) \
|
|
|
|
w = mw - x; \
|
|
|
|
if (w <= 0) \
|
|
|
|
return; \
|
|
|
|
} while (0)
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
qpic_t *
|
2012-02-01 08:46:15 +00:00
|
|
|
Draw_MakePic (int width, int height, const byte *data)
|
|
|
|
{
|
|
|
|
qpic_t *pic;
|
|
|
|
int size = width * height;
|
|
|
|
|
|
|
|
pic = malloc (field_offset (qpic_t, data[size]));
|
|
|
|
pic->width = width;
|
|
|
|
pic->height = height;
|
|
|
|
memcpy (pic->data, data, size);
|
|
|
|
return pic;
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-01 08:46:15 +00:00
|
|
|
Draw_DestroyPic (qpic_t *pic)
|
|
|
|
{
|
|
|
|
free (pic);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +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
|
|
|
|
2012-02-18 13:28:42 +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) {
|
2012-02-01 07:55:35 +00:00
|
|
|
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++)
|
|
|
|
if (!pic->name[0])
|
|
|
|
break;
|
|
|
|
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
|
2014-01-23 02:57:57 +00:00
|
|
|
QFS_LoadCacheFile (QFS_FOpenFile (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;
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-01 07:55:35 +00:00
|
|
|
Draw_UncachePic (const char *path)
|
|
|
|
{
|
|
|
|
cachepic_t *pic;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (pic = cachepics, i = 0; i < numcachepics; pic++, i++) {
|
|
|
|
if (!strcmp (path, pic->name)) {
|
|
|
|
Cache_Release (&pic->cache);
|
|
|
|
pic->name[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2012-02-18 13:28:42 +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");
|
|
|
|
|
2022-05-09 07:30:05 +00:00
|
|
|
if (!draw_chars) {
|
|
|
|
qpic_t *pic = Draw_Font8x8Pic ();
|
|
|
|
draw_chars = pic->data; // FIXME indirect hold on the memory
|
|
|
|
}
|
|
|
|
if (draw_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-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.
|
|
|
|
*/
|
2012-02-18 13:28:42 +00:00
|
|
|
inline void
|
2006-12-03 06:25:57 +00:00
|
|
|
Draw_Character (int x, int y, unsigned int chr)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-03-09 11:19:14 +00:00
|
|
|
byte *dest;
|
2001-02-19 21:15:25 +00:00
|
|
|
byte *source;
|
|
|
|
int drawline;
|
|
|
|
int row, col;
|
|
|
|
|
2006-12-03 06:25:57 +00:00
|
|
|
chr &= 255;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (y <= -8)
|
|
|
|
return; // totally off screen
|
|
|
|
|
2021-07-10 09:04:34 +00:00
|
|
|
if (y > vid.conview->ylen - 8 || x < 0 || x > vid.conview->xlen - 8)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2012-12-21 12:53:13 +00:00
|
|
|
if (chr > 255)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2006-12-03 06:25:57 +00:00
|
|
|
row = chr >> 4;
|
|
|
|
col = chr & 15;
|
2001-02-19 21:15:25 +00:00
|
|
|
source = draw_chars + (row << 10) + (col << 3);
|
|
|
|
|
|
|
|
if (y < 0) { // clipped
|
|
|
|
drawline = 8 + y;
|
|
|
|
source -= 128 * y;
|
|
|
|
y = 0;
|
|
|
|
} else
|
|
|
|
drawline = 8;
|
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
dest = d_viewbuffer + y * d_rowbytes + x;
|
2022-03-09 11:19:14 +00:00
|
|
|
|
|
|
|
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;
|
2022-03-24 03:22:27 +00:00
|
|
|
dest += d_rowbytes;
|
2022-03-09 11:19:14 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-09-15 05:24:33 +00:00
|
|
|
void
|
|
|
|
sw_Draw_CharBuffer (int x, int y, draw_charbuffer_t *buffer)
|
|
|
|
{
|
|
|
|
const byte *line = (byte *) buffer->chars;
|
|
|
|
int width = buffer->width;
|
|
|
|
int height = buffer->height;
|
|
|
|
while (height-- > 0) {
|
|
|
|
for (int i = 0; i < width; i++) {
|
|
|
|
Draw_Character (x + i * 8, y, line[i]);
|
|
|
|
}
|
|
|
|
line += width;
|
|
|
|
y += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2012-02-18 13:28:42 +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
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2002-01-09 21:20:22 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-18 13:28:42 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
Draw_Pixel (int x, int y, byte color)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
byte *dest;
|
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
dest = d_viewbuffer + y * d_rowbytes + x;
|
2001-11-21 19:13:53 +00:00
|
|
|
*dest = color;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 22:16:53 +00:00
|
|
|
static void
|
|
|
|
crosshair_1 (int x, int y)
|
|
|
|
{
|
|
|
|
Draw_Character (x - 4, y - 4, '+');
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
crosshair_2 (int x, int y)
|
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
byte c = crosshaircolor;
|
2004-02-13 22:16:53 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
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);
|
2004-02-13 22:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
crosshair_3 (int x, int y)
|
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
byte c = crosshaircolor;
|
2004-02-13 22:16:53 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 3, y - 3, c);
|
|
|
|
Draw_Pixel (x + 3, y - 3, c);
|
|
|
|
Draw_Pixel (x - 2, y - 2, c);
|
|
|
|
Draw_Pixel (x + 2, y - 2, c);
|
|
|
|
Draw_Pixel (x - 3, y + 3, c);
|
|
|
|
Draw_Pixel (x + 2, y + 2, c);
|
|
|
|
Draw_Pixel (x - 2, y + 2, c);
|
|
|
|
Draw_Pixel (x + 3, y + 3, c);
|
2004-02-13 22:16:53 +00:00
|
|
|
}
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2012-12-12 10:36:18 +00:00
|
|
|
static void
|
|
|
|
crosshair_4 (int x, int y)
|
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
//byte c = crosshaircolor;
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x, y - 2, 8);
|
|
|
|
Draw_Pixel (x + 1, y - 2, 9);
|
|
|
|
|
|
|
|
Draw_Pixel (x, y - 1, 6);
|
|
|
|
Draw_Pixel (x + 1, y - 1, 8);
|
|
|
|
Draw_Pixel (x + 2, y - 1, 2);
|
|
|
|
|
|
|
|
Draw_Pixel (x - 2, y, 6);
|
|
|
|
Draw_Pixel (x - 1, y, 8);
|
|
|
|
Draw_Pixel (x, y, 8);
|
|
|
|
Draw_Pixel (x + 1, y, 6);
|
|
|
|
Draw_Pixel (x + 2, y, 8);
|
|
|
|
Draw_Pixel (x + 3, y, 8);
|
|
|
|
|
|
|
|
Draw_Pixel (x - 1, y + 1, 2);
|
|
|
|
Draw_Pixel (x, y + 1, 8);
|
|
|
|
Draw_Pixel (x + 1, y + 1, 8);
|
|
|
|
Draw_Pixel (x + 2, y + 1, 2);
|
|
|
|
Draw_Pixel (x + 3, y + 1, 2);
|
|
|
|
Draw_Pixel (x + 4, y + 1, 2);
|
|
|
|
|
|
|
|
Draw_Pixel (x, y + 2, 7);
|
|
|
|
Draw_Pixel (x + 1, y + 2, 8);
|
|
|
|
Draw_Pixel (x + 2, y + 2, 2);
|
|
|
|
|
|
|
|
Draw_Pixel (x + 1, y + 3, 2);
|
|
|
|
Draw_Pixel (x + 2, y + 3, 2);
|
2012-12-12 10:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
crosshair_5 (int x, int y)
|
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
byte c = crosshaircolor;
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 1, y - 3, c);
|
|
|
|
Draw_Pixel (x + 0, y - 3, c);
|
|
|
|
Draw_Pixel (x + 1, y - 3, c);
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 2, y - 2, c);
|
|
|
|
Draw_Pixel (x + 2, y - 2, c);
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 3, y - 1, c);
|
|
|
|
Draw_Pixel (x + 3, y - 1, c);
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 3, y, c);
|
|
|
|
Draw_Pixel (x, y, c);
|
|
|
|
Draw_Pixel (x + 3, y, c);
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 3, y + 1, c);
|
|
|
|
Draw_Pixel (x + 3, y + 1, c);
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 2, y + 2, c);
|
|
|
|
Draw_Pixel (x + 2, y + 2, c);
|
2012-12-12 10:36:18 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pixel (x - 1, y + 3, c);
|
|
|
|
Draw_Pixel (x + 0, y + 3, c);
|
|
|
|
Draw_Pixel (x + 1, y + 3, c);
|
2012-12-12 10:36:18 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 23:16:33 +00:00
|
|
|
static void (*crosshair_func[]) (int x, int y) = {
|
|
|
|
crosshair_1,
|
|
|
|
crosshair_2,
|
|
|
|
crosshair_3,
|
2012-12-12 10:36:18 +00:00
|
|
|
crosshair_4,
|
|
|
|
crosshair_5,
|
2004-02-13 23:16:33 +00:00
|
|
|
};
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2001-12-09 14:05:30 +00:00
|
|
|
Draw_Crosshair (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2004-02-13 23:16:33 +00:00
|
|
|
int x, y;
|
|
|
|
int ch;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
ch = crosshair - 1;
|
2004-02-13 23:16:33 +00:00
|
|
|
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
|
2004-02-13 22:16:53 +00:00
|
|
|
return;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
x = vid.conview->xlen / 2 + cl_crossx;
|
|
|
|
y = vid.conview->ylen / 2 + cl_crossy;
|
2004-02-13 23:16:33 +00:00
|
|
|
|
|
|
|
crosshair_func[ch] (x, y);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2004-02-13 23:16:33 +00:00
|
|
|
Draw_CrosshairAt (int ch, int x, int y)
|
|
|
|
{
|
|
|
|
ch -= 1;
|
|
|
|
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
|
|
|
|
return;
|
|
|
|
|
|
|
|
crosshair_func[ch] (x, y);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2001-02-19 21:15:25 +00:00
|
|
|
Draw_Pic (int x, int y, qpic_t *pic)
|
|
|
|
{
|
2022-03-09 11:19:14 +00:00
|
|
|
byte *dest, *source, tbyte;
|
|
|
|
int v, u;
|
|
|
|
|
2021-07-10 09:04:34 +00:00
|
|
|
if (x < 0 || (x + pic->width) > vid.conview->xlen
|
|
|
|
|| y < 0 || (y + pic->height) > vid.conview->ylen) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "Draw_Pic: bad coordinates");
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_SubPic (x, y, pic, 0, 0, pic->width, pic->height);
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
source = pic->data;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
dest = d_viewbuffer + y * d_rowbytes + x;
|
2022-03-09 05:26:16 +00:00
|
|
|
|
2022-03-09 11:19:14 +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;
|
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
dest += d_rowbytes;
|
2022-03-09 11:19:14 +00:00
|
|
|
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)
|
|
|
|
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
|
|
|
}
|
2022-03-24 03:22:27 +00:00
|
|
|
dest += d_rowbytes;
|
2022-03-09 11:19:14 +00:00
|
|
|
source += pic->width;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Picf (float x, float y, qpic_t *pic)
|
2012-02-06 10:32:30 +00:00
|
|
|
{
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_Pic (x, y, pic);
|
2012-02-06 10:32:30 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2001-02-19 21:15:25 +00:00
|
|
|
Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|
|
|
int height)
|
|
|
|
{
|
2022-03-09 11:19:14 +00:00
|
|
|
byte *dest, *source, tbyte;
|
|
|
|
int u, v;
|
|
|
|
|
2021-07-10 09:04:34 +00:00
|
|
|
if ((x < 0) || (x + width > vid.conview->xlen)
|
|
|
|
|| (y < 0) || (y + height > vid.conview->ylen)) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "Draw_SubPic: bad coordinates");
|
2011-12-28 10:17:15 +00:00
|
|
|
}
|
|
|
|
// first, clip to screen
|
|
|
|
if (x < 0) {
|
|
|
|
srcx += x;
|
|
|
|
width += x;
|
|
|
|
x = 0;
|
|
|
|
}
|
2013-01-24 02:25:30 +00:00
|
|
|
if ((unsigned) (x + width) > vid.width)
|
2011-12-28 10:17:15 +00:00
|
|
|
width = vid.width - x;
|
|
|
|
if (width <= 0)
|
|
|
|
return;
|
|
|
|
if (y < 0) {
|
|
|
|
srcy += y;
|
|
|
|
height += y;
|
|
|
|
y = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2013-01-24 02:25:30 +00:00
|
|
|
if ((unsigned) (y + height) > vid.height)
|
2011-12-28 10:17:15 +00:00
|
|
|
height = vid.height - y;
|
|
|
|
if (height <= 0)
|
|
|
|
return;
|
|
|
|
// next, clip to pic
|
|
|
|
CLIP (srcx, srcy, width, height, pic->width, pic->height);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
source = pic->data + srcy * pic->width + srcx;
|
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
dest = d_viewbuffer + y * d_rowbytes + x;
|
2022-03-09 11:19:14 +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;
|
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
dest += d_rowbytes;
|
2022-03-09 11:19:14 +00:00
|
|
|
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;
|
|
|
|
}
|
2022-03-24 03:22:27 +00:00
|
|
|
dest += d_rowbytes;
|
2022-03-09 11:19:14 +00:00
|
|
|
source += pic->width;
|
|
|
|
}
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_ConsoleBackground (int lines, byte alpha)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-03-09 11:19:14 +00:00
|
|
|
int x, y, v;
|
|
|
|
byte *src, *dest;
|
|
|
|
int f, fstep;
|
|
|
|
qpic_t *conback;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
conback = Draw_CachePic ("gfx/conback.lmp", false);
|
|
|
|
|
|
|
|
// draw the pic
|
2022-03-24 03:22:27 +00:00
|
|
|
dest = d_viewbuffer;
|
2022-03-09 11:19:14 +00:00
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
for (y = 0; y < lines; y++, dest += d_rowbytes) {
|
2022-03-09 11:19:14 +00:00
|
|
|
v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen;
|
|
|
|
src = conback->data + v * 320;
|
2021-07-10 09:04:34 +00:00
|
|
|
if (vid.conview->xlen == 320)
|
|
|
|
memcpy (dest, src, vid.conview->xlen);
|
2001-11-21 19:13:53 +00:00
|
|
|
else {
|
2022-03-09 11:19:14 +00:00
|
|
|
f = 0;
|
|
|
|
fstep = 320 * 0x10000 / vid.conview->xlen;
|
|
|
|
for (x = 0; x < vid.conview->xlen; 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Draw_AltString (vid.conview->xlen - strlen (cl_verstring) * 8 - 11,
|
|
|
|
lines - 14, cl_verstring);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
static void
|
|
|
|
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;
|
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
pdest = d_viewbuffer + (prect->y * d_rowbytes) + prect->x;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
srcdelta = rowbytes - prect->width;
|
2022-03-24 03:22:27 +00:00
|
|
|
destdelta = d_rowbytes - prect->width;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
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;
|
2022-03-24 03:22:27 +00:00
|
|
|
pdest += d_rowbytes;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Draw_TileClear
|
|
|
|
|
|
|
|
This repeats a 64*64 tile graphic to fill the screen around a sized down
|
|
|
|
refresh window.
|
|
|
|
*/
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2001-02-19 21:15:25 +00:00
|
|
|
Draw_TileClear (int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
int width, height, tileoffsetx, tileoffsety;
|
|
|
|
byte *psrc;
|
|
|
|
vrect_t vr;
|
|
|
|
|
2022-05-09 07:30:05 +00:00
|
|
|
if (!r_rectdesc.height) {
|
|
|
|
return;
|
|
|
|
}
|
2013-01-24 02:25:30 +00:00
|
|
|
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
|
2011-12-28 10:17:15 +00:00
|
|
|
|
2022-03-07 07:57:22 +00:00
|
|
|
vr.y = y;
|
|
|
|
height = h;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
tileoffsety = vr.y % r_rectdesc.height;
|
|
|
|
|
|
|
|
while (height > 0) {
|
2022-03-07 07:57:22 +00:00
|
|
|
vr.x = x;
|
|
|
|
width = w;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-08 09:41:09 +00:00
|
|
|
vr.height = r_rectdesc.height - tileoffsety;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (vr.height > height)
|
|
|
|
vr.height = height;
|
|
|
|
|
|
|
|
tileoffsetx = vr.x % r_rectdesc.width;
|
|
|
|
|
|
|
|
while (width > 0) {
|
2022-03-08 09:41:09 +00:00
|
|
|
vr.width = r_rectdesc.width - tileoffsetx;
|
2001-02-19 21:15:25 +00:00
|
|
|
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
|
|
|
|
*/
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2001-02-19 21:15:25 +00:00
|
|
|
Draw_Fill (int x, int y, int w, int h, int c)
|
|
|
|
{
|
2022-03-09 11:19:14 +00:00
|
|
|
byte *dest;
|
|
|
|
int u, v;
|
|
|
|
|
2021-07-10 09:04:34 +00:00
|
|
|
if (x < 0 || x + w > vid.conview->xlen
|
|
|
|
|| y < 0 || y + h > vid.conview->ylen) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
|
2011-12-28 10:17:15 +00:00
|
|
|
x, y, w, h, c);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2013-01-24 02:25:30 +00:00
|
|
|
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
dest = d_viewbuffer + y * d_rowbytes + x;
|
|
|
|
for (v = 0; v < h; v++, dest += d_rowbytes)
|
2022-03-09 11:19:14 +00:00
|
|
|
for (u = 0; u < w; u++)
|
|
|
|
dest[u] = c;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 09:14:26 +00:00
|
|
|
static inline byte *
|
|
|
|
draw_horizontal (byte *dest, int xs, int len, int c)
|
|
|
|
{
|
|
|
|
while (len-- > 0) {
|
|
|
|
*dest = c;
|
|
|
|
dest += xs;
|
|
|
|
}
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline byte *
|
|
|
|
draw_vertical (byte *dest, int len, int c)
|
|
|
|
{
|
|
|
|
while (len-- > 0) {
|
|
|
|
*dest = c;
|
|
|
|
dest += d_rowbytes;
|
|
|
|
}
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
draw_line (int x0, int y0, int x1, int y1, int c)
|
|
|
|
{
|
|
|
|
// Bresenham's line slice algorith (ala Michael Abrash)
|
|
|
|
int dx, dy, sx;
|
|
|
|
// always go top to bottom
|
|
|
|
if (y1 < y0) {
|
|
|
|
int t;
|
|
|
|
t = y1; y1 = y0; y0 = t;
|
|
|
|
t = x1; x1 = x0; x0 = t;
|
|
|
|
}
|
|
|
|
dy = y1 - y0;
|
|
|
|
|
|
|
|
if ((dx = x1 - x0) < 0) {
|
|
|
|
sx = -1;
|
|
|
|
dx = -dx;
|
|
|
|
} else {
|
|
|
|
sx = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *dest = d_viewbuffer + y0 * d_rowbytes + x0;
|
|
|
|
|
|
|
|
if (!dx) {
|
|
|
|
draw_vertical (dest, dy, c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!dy) {
|
|
|
|
draw_horizontal (dest, sx, dx, c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dx == dy) {
|
|
|
|
while (dy-- > 0) {
|
|
|
|
*dest = c;
|
|
|
|
dest += d_rowbytes + sx;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dx > dy) {
|
|
|
|
int step = dx / dy;
|
|
|
|
int adj_up = (dx % dy) * 2;
|
|
|
|
int adj_down = dy * 2;
|
|
|
|
int error = (dx % dy) - adj_down;
|
|
|
|
int initial = step / 2 + 1;
|
|
|
|
int final = initial;
|
|
|
|
|
|
|
|
if (!adj_up && !(step & 1)) {
|
|
|
|
initial--;
|
|
|
|
}
|
|
|
|
if (step & 1) {
|
|
|
|
error += dy;
|
|
|
|
}
|
|
|
|
dest = draw_horizontal (dest, sx, initial, c);
|
|
|
|
dest += d_rowbytes;
|
|
|
|
while (dy-- > 1) {
|
|
|
|
int run = step;
|
|
|
|
if ((error += adj_up) > 0) {
|
|
|
|
run++;
|
|
|
|
error -= adj_down;
|
|
|
|
}
|
|
|
|
dest = draw_horizontal (dest, sx, run, c);
|
|
|
|
dest += d_rowbytes;
|
|
|
|
}
|
|
|
|
dest = draw_horizontal (dest, sx, final, c);
|
|
|
|
} else {
|
|
|
|
int step = dy / dx;
|
|
|
|
int adj_up = (dy % dx) * 2;
|
|
|
|
int adj_down = dx * 2;
|
|
|
|
int error = (dy % dx) - adj_down;
|
|
|
|
int initial = step / 2 + 1;
|
|
|
|
int final = initial;
|
|
|
|
|
|
|
|
if (!adj_up && !(step & 1)) {
|
|
|
|
initial--;
|
|
|
|
}
|
|
|
|
if (step & 1) {
|
|
|
|
error += dx;
|
|
|
|
}
|
|
|
|
dest = draw_vertical (dest, initial, c);
|
|
|
|
dest += sx;
|
|
|
|
while (dx-- > 1) {
|
|
|
|
int run = step;
|
|
|
|
if ((error += adj_up) > 0) {
|
|
|
|
run++;
|
|
|
|
error -= adj_down;
|
|
|
|
}
|
|
|
|
dest = draw_vertical (dest, run, c);
|
|
|
|
dest += sx;
|
|
|
|
}
|
|
|
|
dest = draw_vertical (dest, final, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline byte
|
|
|
|
test_point (int x, int y)
|
|
|
|
{
|
|
|
|
byte c = 0;
|
|
|
|
|
|
|
|
if (x < 0) {
|
|
|
|
c |= 1;
|
|
|
|
} else if (x >= vid.conview->xlen) {
|
|
|
|
c |= 2;
|
|
|
|
}
|
|
|
|
if (y < 0) {
|
|
|
|
c |= 4;
|
|
|
|
} else if (y >= vid.conview->ylen) {
|
|
|
|
c |= 8;
|
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Draw_Line (int x0, int y0, int x1, int y1, int c)
|
|
|
|
{
|
|
|
|
byte c0 = test_point (x0, y0);
|
|
|
|
byte c1 = test_point (x1, y1);
|
|
|
|
int xmax = vid.conview->xlen - 1;
|
|
|
|
int ymax = vid.conview->ylen - 1;
|
|
|
|
|
|
|
|
while (c0 | c1) {
|
|
|
|
// Cohen-Sutherland line clipping
|
|
|
|
if (c0 & c1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int dx = x1 - x0;
|
|
|
|
int dy = y1 - y0;
|
|
|
|
if (c0 & 1) { y0 = (( 0 - x0) * dy + dx * y0) / dx; x0 = 0; }
|
|
|
|
if (c0 & 2) { y0 = ((xmax - x0) * dy + dx * y0) / dx; x0 = xmax; }
|
|
|
|
if (c1 & 1) { y1 = (( 0 - x1) * dy + dx * y1) / dx; x1 = 0; }
|
|
|
|
if (c1 & 2) { y1 = ((xmax - x1) * dy + dx * y1) / dx; x1 = xmax; }
|
|
|
|
|
|
|
|
if (c0 & 4) { x0 = (( 0 - y0) * dx + dy * x0) / dy; y0 = 0; }
|
|
|
|
if (c0 & 8) { x0 = ((ymax - y0) * dx + dy * x0) / dy; y0 = ymax; }
|
|
|
|
if (c1 & 4) { x1 = (( 0 - y1) * dx + dy * x1) / dy; y1 = 0; }
|
|
|
|
if (c1 & 8) { x1 = ((ymax - y1) * dx + dy * x1) / dy; y1 = ymax; }
|
|
|
|
c0 = test_point (x0, y0);
|
|
|
|
c1 = test_point (x1, y1);
|
|
|
|
}
|
|
|
|
draw_line (x0, y0, x1, y1, c);
|
|
|
|
}
|
2022-03-09 11:19:14 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_FadeScreen (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-03-09 11:19:14 +00:00
|
|
|
int x, y;
|
2021-07-10 09:04:34 +00:00
|
|
|
int height = vid.conview->ylen;
|
|
|
|
int width = vid.conview->xlen / 4;
|
2021-07-08 05:18:06 +00:00
|
|
|
uint32_t *pbuf;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
for (y = 0; y < height; y++) {
|
2021-07-08 05:18:06 +00:00
|
|
|
uint32_t mask;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-24 03:22:27 +00:00
|
|
|
pbuf = (uint32_t *) (d_viewbuffer + d_rowbytes * y);
|
2021-07-08 05:18:06 +00:00
|
|
|
mask = 0xff << ((y & 1) << 4);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-09 11:19:14 +00:00
|
|
|
for (x = 0; x < width; x++) {
|
2021-07-08 05:18:06 +00:00
|
|
|
*pbuf++ &= mask;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-13 11:34:39 +00:00
|
|
|
vr_data.scr_copyeverything = 1;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2012-01-28 11:45:14 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2022-03-09 11:19:14 +00:00
|
|
|
Draw_BlendScreen (quat_t color)
|
2012-01-28 11:45:14 +00:00
|
|
|
{
|
|
|
|
int r, g, b, i;
|
2013-01-27 10:57:40 +00:00
|
|
|
const byte *basepal;
|
|
|
|
byte *newpal;
|
2012-01-28 11:45:14 +00:00
|
|
|
byte pal[768];
|
|
|
|
basepal = vid.basepal;
|
|
|
|
newpal = pal;
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
r = basepal[0];
|
|
|
|
g = basepal[1];
|
|
|
|
b = basepal[2];
|
|
|
|
basepal += 3;
|
|
|
|
|
|
|
|
r += (int) (color[3] * (color[0] * 256 - r));
|
|
|
|
g += (int) (color[3] * (color[1] * 256 - g));
|
|
|
|
b += (int) (color[3] * (color[2] * 256 - b));
|
|
|
|
|
2012-02-17 07:13:56 +00:00
|
|
|
newpal[0] = vid.gammatable[r];
|
|
|
|
newpal[1] = vid.gammatable[g];
|
|
|
|
newpal[2] = vid.gammatable[b];
|
2012-01-28 11:45:14 +00:00
|
|
|
newpal += 3;
|
|
|
|
}
|
2021-07-10 15:09:41 +00:00
|
|
|
vid.vid_internal->set_palette (vid.vid_internal->data, pal);
|
2012-01-28 11:45:14 +00:00
|
|
|
}
|
2022-08-31 10:23:30 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Draw_AddFont (struct rfont_s *font)
|
|
|
|
{
|
|
|
|
}
|
2022-09-02 02:38:09 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Draw_FontString (int x, int y, const char *str)
|
|
|
|
{
|
|
|
|
}
|