2001-04-15 04:18:22 +00:00
|
|
|
/*
|
|
|
|
vid_svgalib.c
|
|
|
|
|
|
|
|
Linux SVGALib video routines
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
Copyright (C) 1999-2000 Marcus Sundberg [mackan@stacken.kth.se]
|
|
|
|
Copyright (C) 1999-2000 David Symonds [xoxus@usa.net]
|
|
|
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
|
|
|
Please see the file "AUTHORS" for a list of contributors
|
|
|
|
|
|
|
|
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-06-19 22:05:13 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-04-15 04:18:22 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2002-12-16 19:26:53 +00:00
|
|
|
#ifdef HAVE_SYS_IO_H
|
2001-04-15 04:18:22 +00:00
|
|
|
# include <sys/io.h>
|
|
|
|
#elif defined(HAVE_ASM_IO_H)
|
|
|
|
# include <asm/io.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <vga.h>
|
|
|
|
|
|
|
|
#include "QF/cmd.h"
|
2007-11-06 12:40:38 +00:00
|
|
|
#include "QF/console.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/input.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/qendian.h"
|
|
|
|
#include "QF/sys.h"
|
2001-04-15 08:04:15 +00:00
|
|
|
#include "QF/vid.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
#include "compat.h"
|
2003-01-06 18:28:13 +00:00
|
|
|
#include "d_iface.h"
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2002-12-16 19:26:53 +00:00
|
|
|
static int num_modes, current_mode;
|
2001-04-15 04:18:22 +00:00
|
|
|
static vga_modeinfo *modes;
|
|
|
|
|
2002-12-16 19:26:53 +00:00
|
|
|
static byte vid_current_palette[768];
|
|
|
|
static byte backingbuf[48 * 24];
|
2005-06-08 06:35:48 +00:00
|
|
|
static byte *framebuffer_ptr;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-12-16 19:26:53 +00:00
|
|
|
static int svgalib_inited = 0;
|
|
|
|
static int svgalib_backgrounded = 0;
|
2001-04-15 04:18:22 +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
|
|
|
static int vid_redrawfull;
|
|
|
|
static cvar_t vid_redrawfull_cvar = {
|
|
|
|
.name = "vid_redrawfull",
|
|
|
|
.description =
|
|
|
|
"Redraw entire screen each frame instead of just dirty areas",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_redrawfull },
|
|
|
|
};
|
|
|
|
static int vid_waitforrefresh;
|
|
|
|
static cvar_t vid_waitforrefresh_cvar = {
|
|
|
|
.name = "vid_waitforrefresh",
|
|
|
|
.description =
|
|
|
|
"Wait for vertical retrace before drawing next frame",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &vid_waitforrefresh },
|
|
|
|
};
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-12-16 19:26:53 +00:00
|
|
|
int VGA_width, VGA_height, VGA_rowbytes, VGA_bufferrowbytes, VGA_planar;
|
|
|
|
byte *VGA_pagebase;
|
|
|
|
int VID_options_items = 0;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height)
|
|
|
|
{
|
2002-12-16 19:26:53 +00:00
|
|
|
int plane, reps, repshift, offset, vidpage, off, i, j, k;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
if (!svgalib_inited || !vid.direct || svgalib_backgrounded
|
2002-12-16 17:59:45 +00:00
|
|
|
|| !vga_oktowrite ())
|
|
|
|
return;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
if (vid.aspect > 1.5) {
|
|
|
|
reps = 2;
|
|
|
|
repshift = 1;
|
|
|
|
} else {
|
|
|
|
reps = 1;
|
|
|
|
repshift = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
vidpage = 0;
|
|
|
|
vga_setpage (0);
|
|
|
|
|
|
|
|
if (VGA_planar) {
|
|
|
|
for (plane = 0; plane < 4; plane++) {
|
|
|
|
/* Select the correct plane for reading and writing */
|
|
|
|
outb (0x02, 0x3C4);
|
|
|
|
outb (1 << plane, 0x3C5);
|
|
|
|
outb (4, 0x3CE);
|
|
|
|
outb (plane, 0x3CF);
|
|
|
|
|
|
|
|
for (i = 0; i < (height << repshift); i += reps) {
|
|
|
|
for (k = 0; k < reps; k++) {
|
|
|
|
for (j = 0; j < (width >> 2); j++) {
|
|
|
|
backingbuf[(i + k) * 24 + (j << 2) + plane] =
|
|
|
|
vid.direct[(y + i + k) * VGA_rowbytes +
|
|
|
|
(x >> 2) + j];
|
|
|
|
vid.direct[(y + i + k) * VGA_rowbytes + (x >> 2) + j] =
|
|
|
|
pbitmap[(i >> repshift) * 24 + (j << 2) + plane];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < (height << repshift); i += reps) {
|
|
|
|
for (j = 0; j < reps; j++) {
|
2002-12-16 17:59:45 +00:00
|
|
|
offset = x + ((y << repshift) + i + j) * vid.rowbytes;
|
2001-04-15 04:18:22 +00:00
|
|
|
off = offset % 0x10000;
|
|
|
|
if ((offset / 0x10000) != vidpage) {
|
|
|
|
vidpage = offset / 0x10000;
|
|
|
|
vga_setpage (vidpage);
|
|
|
|
}
|
|
|
|
memcpy (&backingbuf[(i + j) * 24], vid.direct + off, width);
|
2002-12-16 17:59:45 +00:00
|
|
|
memcpy (vid.direct + off, &pbitmap[(i >> repshift) * width],
|
|
|
|
width);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
D_EndDirectRect (int x, int y, int width, int height)
|
|
|
|
{
|
2002-12-16 19:26:53 +00:00
|
|
|
int plane, reps, repshift, offset, vidpage, off, i, j, k;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
if (!svgalib_inited || !vid.direct || svgalib_backgrounded
|
2002-12-16 17:59:45 +00:00
|
|
|
|| !vga_oktowrite ())
|
|
|
|
return;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
if (vid.aspect > 1.5) {
|
|
|
|
reps = 2;
|
|
|
|
repshift = 1;
|
|
|
|
} else {
|
|
|
|
reps = 1;
|
|
|
|
repshift = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
vidpage = 0;
|
|
|
|
vga_setpage (0);
|
|
|
|
|
|
|
|
if (VGA_planar) {
|
|
|
|
for (plane = 0; plane < 4; plane++) {
|
|
|
|
/* Select the correct plane for writing */
|
|
|
|
outb (2, 0x3C4);
|
|
|
|
outb (1 << plane, 0x3C5);
|
|
|
|
outb (4, 0x3CE);
|
|
|
|
outb (plane, 0x3CF);
|
|
|
|
|
|
|
|
for (i = 0; i < (height << repshift); i += reps) {
|
|
|
|
for (k = 0; k < reps; k++) {
|
|
|
|
for (j = 0; j < (width >> 2); j++) {
|
|
|
|
vid.direct[(y + i + k) * VGA_rowbytes + (x >> 2) + j] =
|
|
|
|
backingbuf[(i + k) * 24 + (j << 2) + plane];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < (height << repshift); i += reps) {
|
|
|
|
for (j = 0; j < reps; j++) {
|
2002-12-16 17:59:45 +00:00
|
|
|
offset = x + ((y << repshift) + i + j) * vid.rowbytes;
|
2001-04-15 04:18:22 +00:00
|
|
|
off = offset % 0x10000;
|
|
|
|
if ((offset / 0x10000) != vidpage) {
|
|
|
|
vidpage = offset / 0x10000;
|
|
|
|
vga_setpage (vidpage);
|
|
|
|
}
|
|
|
|
memcpy (vid.direct + off, &backingbuf[(i + j) * 24], width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
VID_InitModes (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Get complete information on all modes */
|
|
|
|
num_modes = vga_lastmodenumber () + 1;
|
|
|
|
modes = malloc (num_modes * sizeof (vga_modeinfo));
|
2002-05-14 06:37:28 +00:00
|
|
|
SYS_CHECKMEM (modes);
|
2001-04-15 04:18:22 +00:00
|
|
|
for (i = 0; i < num_modes; i++) {
|
|
|
|
if (vga_hasmode (i)) {
|
|
|
|
memcpy (&modes[i], vga_getmodeinfo (i), sizeof (vga_modeinfo));
|
|
|
|
} else {
|
|
|
|
modes[i].width = 0; // means not available
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Filter for modes we don't support */
|
|
|
|
for (i = 0; i < num_modes; i++) {
|
|
|
|
if (modes[i].bytesperpixel != 1 && modes[i].colors != 256) {
|
|
|
|
modes[i].width = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-12-16 18:50:09 +00:00
|
|
|
get_mode (int width, int height, int depth)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
int i, ok, match;
|
|
|
|
|
2002-12-16 19:39:02 +00:00
|
|
|
match = ((!!depth) << 2) + ((!!height) << 1) + (!!width);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-12-16 18:50:09 +00:00
|
|
|
for (i = 0; i < num_modes; i++) {
|
|
|
|
if (modes[i].width) {
|
2002-12-16 19:39:02 +00:00
|
|
|
ok = ((modes[i].bytesperpixel == (depth / 8)) << 2)
|
|
|
|
+ ((modes[i].height == height) << 1)
|
2002-12-16 19:26:53 +00:00
|
|
|
+ (modes[i].width == width);
|
2002-12-16 18:50:09 +00:00
|
|
|
if ((ok & match) == match)
|
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
}
|
2002-12-16 18:50:09 +00:00
|
|
|
if (i == num_modes) {
|
|
|
|
Sys_Printf ("Mode %dx%d (%d bits) not supported\n",
|
|
|
|
width, height, depth);
|
|
|
|
i = G320x200x256;
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2019-07-12 14:15:26 +00:00
|
|
|
static void
|
|
|
|
VID_shutdown (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_vid, "VID_Shutdown\n");
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
if (!svgalib_inited)
|
|
|
|
return;
|
|
|
|
|
2002-12-16 18:50:09 +00:00
|
|
|
vga_setmode (TEXT);
|
2001-04-15 04:18:22 +00:00
|
|
|
svgalib_inited = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VID_SetPalette (byte * palette)
|
|
|
|
{
|
|
|
|
static int tmppal[256 * 3];
|
|
|
|
int *tp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!svgalib_inited || svgalib_backgrounded)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memcpy (vid_current_palette, palette, sizeof (vid_current_palette));
|
|
|
|
|
|
|
|
if (vga_getcolors () == 256) {
|
|
|
|
tp = tmppal;
|
|
|
|
for (i = 256 * 3; i; i--) {
|
|
|
|
*(tp++) = *(palette++) >> 2;
|
|
|
|
}
|
|
|
|
|
2002-12-16 18:50:09 +00:00
|
|
|
if (vga_oktowrite ()) {
|
2001-04-15 04:18:22 +00:00
|
|
|
vga_setpalvec (0, 256, tmppal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static int
|
2001-04-15 04:18:22 +00:00
|
|
|
VID_SetMode (int modenum, unsigned char *palette)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if ((modenum >= num_modes) || (modenum < 0) || !modes[modenum].width) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("No such video mode: %d\n", modenum);
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_mode = modenum;
|
|
|
|
|
|
|
|
vid.width = modes[current_mode].width;
|
|
|
|
vid.height = modes[current_mode].height;
|
|
|
|
|
|
|
|
VGA_width = modes[current_mode].width;
|
|
|
|
VGA_height = modes[current_mode].height;
|
|
|
|
VGA_planar = modes[current_mode].bytesperpixel == 0;
|
|
|
|
VGA_rowbytes = modes[current_mode].linewidth;
|
|
|
|
vid.rowbytes = modes[current_mode].linewidth;
|
|
|
|
if (VGA_planar) {
|
|
|
|
VGA_bufferrowbytes = modes[current_mode].linewidth * 4;
|
|
|
|
vid.rowbytes = modes[current_mode].linewidth * 4;
|
|
|
|
}
|
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
vid.colormap8 = (byte *) vid_colormap;
|
2012-01-02 01:53:57 +00:00
|
|
|
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
|
2001-04-15 04:18:22 +00:00
|
|
|
vid.conrowbytes = vid.rowbytes;
|
|
|
|
vid.numpages = 1;
|
|
|
|
|
|
|
|
// alloc screen buffer, z-buffer, and surface cache
|
|
|
|
VID_InitBuffers ();
|
|
|
|
|
|
|
|
/* get goin' */
|
|
|
|
err = vga_setmode (current_mode);
|
|
|
|
if (err) {
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("Video mode failed: %d", modenum);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
VID_SetPalette (palette);
|
|
|
|
|
2005-06-08 06:35:48 +00:00
|
|
|
VGA_pagebase = vid.direct = framebuffer_ptr = vga_getgraphmem ();
|
2001-04-15 04:18:22 +00:00
|
|
|
#if 0
|
|
|
|
if (vga_setlinearaddressing () > 0) {
|
|
|
|
framebuffer_ptr = (char *) vga_getgraphmem ();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!framebuffer_ptr) {
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("This mode isn't hapnin'");
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vga_setpage (0);
|
|
|
|
|
|
|
|
svgalib_inited = 1;
|
|
|
|
|
|
|
|
/* Force a surface cache flush */
|
|
|
|
vid.recalc_refdef = 1;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
goto_background (void)
|
|
|
|
{
|
|
|
|
svgalib_backgrounded = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
comefrom_background (void)
|
|
|
|
{
|
|
|
|
svgalib_backgrounded = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-01 10:52:13 +00:00
|
|
|
VID_Init (byte *palette, byte *colormap)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
// plugin_load("in_svgalib.so");
|
|
|
|
|
|
|
|
if (svgalib_inited)
|
|
|
|
return;
|
|
|
|
|
2019-07-12 14:15:26 +00:00
|
|
|
Sys_RegisterShutdown (VID_shutdown);
|
|
|
|
|
2002-12-16 18:50:09 +00:00
|
|
|
err = vga_init ();
|
|
|
|
if (err)
|
|
|
|
Sys_Error ("SVGALib failed to allocate a new VC");
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-12-16 18:50:09 +00:00
|
|
|
if (vga_runinbackground_version () == 1) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("SVGALIB background support detected\n");
|
2002-12-16 18:50:09 +00:00
|
|
|
vga_runinbackground (VGA_GOTOBACK, goto_background);
|
|
|
|
vga_runinbackground (VGA_COMEFROMBACK, comefrom_background);
|
|
|
|
vga_runinbackground (1);
|
|
|
|
} else {
|
|
|
|
vga_runinbackground (0);
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-12-16 18:50:09 +00:00
|
|
|
VID_InitModes ();
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2002-12-16 18:50:09 +00:00
|
|
|
/* Interpret command-line params */
|
2013-01-24 06:43:04 +00:00
|
|
|
VID_GetWindowSize (640, 480);
|
2001-05-25 04:03:47 +00:00
|
|
|
|
2002-12-16 19:36:14 +00:00
|
|
|
current_mode = get_mode (vid.width, vid.height, 8);
|
2002-12-16 18:50:09 +00:00
|
|
|
|
|
|
|
/* Set vid parameters */
|
2012-02-01 10:52:13 +00:00
|
|
|
vid_colormap = colormap;
|
2002-12-16 18:50:09 +00:00
|
|
|
VID_SetMode (current_mode, palette);
|
|
|
|
|
|
|
|
VID_InitGamma (palette);
|
|
|
|
VID_SetPalette (vid.palette);
|
|
|
|
|
|
|
|
vid.initialized = true;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VID_Init_Cvars ()
|
|
|
|
{
|
[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
|
|
|
Cvar_Register (&vid_redrawfull_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_waitforrefresh_cvar, 0, 0);
|
|
|
|
Cvar_Register (&vid_system_gamma_cvar, 0, 0);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VID_Update (vrect_t *rects)
|
|
|
|
{
|
|
|
|
if (!svgalib_inited || svgalib_backgrounded)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!vga_oktowrite ()) {
|
|
|
|
/* Can't update screen if it's not active */
|
|
|
|
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
|
|
|
if (vid_waitforrefresh) {
|
2001-04-15 04:18:22 +00:00
|
|
|
vga_waitretrace ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VGA_planar) {
|
|
|
|
VGA_UpdatePlanarScreen (vid.buffer);
|
[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
|
|
|
} else if (vid_redrawfull) {
|
2001-04-15 04:18:22 +00:00
|
|
|
int total = vid.rowbytes * vid.height;
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
for (offset = 0; offset < total; offset += 0x10000) {
|
|
|
|
vga_setpage (offset / 0x10000);
|
|
|
|
memcpy (framebuffer_ptr, vid.buffer + offset,
|
|
|
|
((total - offset > 0x10000) ? 0x10000 : (total - offset)));
|
|
|
|
}
|
|
|
|
} else {
|
2002-12-16 17:59:45 +00:00
|
|
|
int offset, ycount;
|
2001-04-15 04:18:22 +00:00
|
|
|
int vidpage = 0;
|
|
|
|
|
|
|
|
vga_setpage (0);
|
|
|
|
|
|
|
|
while (rects) {
|
|
|
|
ycount = rects->height;
|
|
|
|
offset = rects->y * vid.rowbytes + rects->x;
|
|
|
|
while (ycount--) {
|
|
|
|
register int i = offset % 0x10000;
|
|
|
|
|
|
|
|
if ((offset / 0x10000) != vidpage) {
|
|
|
|
vidpage = offset / 0x10000;
|
|
|
|
vga_setpage (vidpage);
|
|
|
|
}
|
|
|
|
if (rects->width + i > 0x10000) {
|
2002-12-16 17:59:45 +00:00
|
|
|
memcpy (framebuffer_ptr + i, vid.buffer + offset,
|
|
|
|
0x10000 - i);
|
2001-04-15 04:18:22 +00:00
|
|
|
vga_setpage (++vidpage);
|
2002-12-16 17:59:45 +00:00
|
|
|
memcpy (framebuffer_ptr, vid.buffer + offset + 0x10000 - i,
|
2001-04-15 04:18:22 +00:00
|
|
|
rects->width - 0x10000 + i);
|
|
|
|
} else {
|
2002-12-16 17:59:45 +00:00
|
|
|
memcpy (framebuffer_ptr + i, vid.buffer + offset,
|
|
|
|
rects->width);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
offset += vid.rowbytes;
|
|
|
|
}
|
2012-01-06 00:52:14 +00:00
|
|
|
rects = rects->next;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
VID_SetCaption (const char *text)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean
|
|
|
|
VID_SetGamma (double gamma)
|
|
|
|
{
|
2002-01-12 05:32:21 +00:00
|
|
|
return false;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
2001-06-07 16:12:21 +00:00
|
|
|
|
2001-06-07 23:03:10 +00:00
|
|
|
#if defined(i386) && defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2))
|
2001-06-07 16:12:21 +00:00
|
|
|
void
|
|
|
|
outb (unsigned char val, unsigned short port)
|
|
|
|
{
|
|
|
|
asm ("outb %b0, %w1" : :"a"(val), "d"(port));
|
|
|
|
}
|
2003-01-31 18:19:55 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
static inline void
|
|
|
|
outb (unsigned char value, unsigned short port)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "d" (port));
|
|
|
|
}
|
2001-06-07 16:12:21 +00:00
|
|
|
#endif
|