mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
signed int viddef_t members
The attached patch (against quakeforge git) changes the [con]width, [con]height, and most importantly the rowbytes members of viddef_t from unsigned to signed int, like in q2. This allows for a properly negative vid.rowbytes which may be needed in, e.g. a DIB sections windows driver if needed. Along with it, I changed a few places where unsigned int is used along with comparisons against the relevant vid.* members. One thing I am not 100% sure is the signedness requirements of d_zrowbytes and d_zwidth: q2 has them as unsigned but I am not sure whether that is because they are needed as unsigned or it was just an oversight of the id developers. They do look like they should be OK as signed int to me, though: comments? == Note from Bill Currie: I had to do some extra changes as many signed/unsigned comparisons were somehow missed.
This commit is contained in:
parent
eccc1b5b51
commit
6e04fd5ff6
18 changed files with 63 additions and 67 deletions
|
@ -47,9 +47,9 @@ typedef struct {
|
|||
unsigned short *colormap16; // 256 * VID_GRADES size
|
||||
unsigned int *colormap32; // 256 * VID_GRADES size
|
||||
int fullbright; // index of first fullbright color
|
||||
unsigned int rowbytes; // may be > width if displayed in a window
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
int rowbytes; // may be > width if displayed in a window
|
||||
int width;
|
||||
int height;
|
||||
float aspect; // width / height -- < 1 is taller than wide
|
||||
int numpages;
|
||||
qboolean recalc_refdef; // if true, recalc vid-based stuff
|
||||
|
@ -57,8 +57,8 @@ typedef struct {
|
|||
quat_t cshift_color;
|
||||
void *conbuffer;
|
||||
int conrowbytes;
|
||||
unsigned int conwidth;
|
||||
unsigned int conheight;
|
||||
int conwidth;
|
||||
int conheight;
|
||||
int maxwarpwidth;
|
||||
int maxwarpheight;
|
||||
byte *direct; // direct drawing to framebuffer, if not
|
||||
|
|
|
@ -102,7 +102,7 @@ extern void D_PolysetAff8End (void);
|
|||
#endif
|
||||
|
||||
extern short *d_pzbuffer;
|
||||
extern unsigned int d_zrowbytes, d_zwidth;
|
||||
extern int d_zrowbytes, d_zwidth;
|
||||
|
||||
extern int *d_pscantable;
|
||||
extern int d_scantable[];
|
||||
|
|
|
@ -93,10 +93,8 @@ gl_SCR_ScreenShot (int width, int height)
|
|||
qfglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE,
|
||||
snap);
|
||||
|
||||
w = (vid.width < (unsigned int) width) ? vid.width
|
||||
: (unsigned int) width;
|
||||
h = (vid.height < (unsigned int) height) ? vid.height
|
||||
: (unsigned int) height;
|
||||
w = (vid.width < width) ? vid.width : width;
|
||||
h = (vid.height < height) ? vid.height : height;
|
||||
|
||||
fracw = (float) vid.width / (float) w;
|
||||
frach = (float) vid.height / (float) h;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
void
|
||||
D_FillRect (vrect_t *rect, int color)
|
||||
{
|
||||
unsigned int rx, ry, rwidth, rheight;
|
||||
int rx, ry, rwidth, rheight;
|
||||
unsigned char *dest;
|
||||
unsigned int *ldest;
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ D_ViewChanged (void)
|
|||
r_refdef.vrectbottom - (d_pix_max << d_y_aspect_shift);
|
||||
|
||||
{
|
||||
unsigned int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < vid.height; i++) {
|
||||
d_scantable[i] = i * rowpixels;
|
||||
|
|
|
@ -48,8 +48,8 @@ D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
|
|||
else
|
||||
temp = (float) r_refdef.vrect.height;
|
||||
|
||||
wu = 8192.0 * (float) (u - ((int) vid.width >> 1)) / temp;
|
||||
wv = 8192.0 * (float) (((int) vid.height >> 1) - v) / temp;
|
||||
wu = 8192.0 * (float) (u - (vid.width >> 1)) / temp;
|
||||
wv = 8192.0 * (float) ((vid.height >> 1) - v) / temp;
|
||||
|
||||
end[0] = 4096 * vpn[0] + wu * vright[0] + wv * vup[0];
|
||||
end[1] = 4096 * vpn[1] + wu * vright[1] + wv * vup[1];
|
||||
|
|
|
@ -54,7 +54,7 @@ byte *cacheblock;
|
|||
int cachewidth;
|
||||
byte *d_viewbuffer;
|
||||
short *d_pzbuffer;
|
||||
unsigned int d_zrowbytes;
|
||||
unsigned int d_zwidth;
|
||||
int d_zrowbytes;
|
||||
int d_zwidth;
|
||||
|
||||
#endif // !USE_INTEL_ASM
|
||||
|
|
|
@ -263,7 +263,7 @@ Draw_Character (int x, int y, unsigned int chr)
|
|||
if (y <= -8)
|
||||
return; // totally off screen
|
||||
|
||||
if (y > (int) vid.conheight - 8 || x < 0 || x > (int) vid.conwidth - 8)
|
||||
if (y > vid.conheight - 8 || x < 0 || x > vid.conwidth - 8)
|
||||
return;
|
||||
if (chr < 0 || chr > 255)
|
||||
return;
|
||||
|
@ -418,8 +418,8 @@ 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.conwidth || y < 0 ||
|
||||
(unsigned int) (y + pic->height) > vid.conheight) {
|
||||
if (x < 0 || (x + pic->width) > vid.conwidth
|
||||
|| y < 0 || (y + pic->height) > vid.conheight) {
|
||||
Sys_MaskPrintf (SYS_VID, "Draw_Pic: bad coordinates");
|
||||
Draw_SubPic (x, y, pic, 0, 0, pic->width, pic->height);
|
||||
return;
|
||||
|
@ -477,8 +477,8 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
byte *dest, *source, tbyte;
|
||||
int u, v;
|
||||
|
||||
if ((x < 0) || (x + width > (int) vid.conwidth)
|
||||
|| (y < 0) || (y + height > (int) vid.conheight)) {
|
||||
if ((x < 0) || (x + width > vid.conwidth)
|
||||
|| (y < 0) || (y + height > vid.conheight)) {
|
||||
Sys_MaskPrintf (SYS_VID, "Draw_SubPic: bad coordinates");
|
||||
}
|
||||
// first, clip to screen
|
||||
|
@ -487,7 +487,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
width += x;
|
||||
x = 0;
|
||||
}
|
||||
if (x + width > (int) vid.width)
|
||||
if (x + width > vid.width)
|
||||
width = vid.width - x;
|
||||
if (width <= 0)
|
||||
return;
|
||||
|
@ -496,7 +496,7 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
height += y;
|
||||
y = 0;
|
||||
}
|
||||
if (y + height > (int) vid.height)
|
||||
if (y + height > vid.height)
|
||||
height = vid.height - y;
|
||||
if (height <= 0)
|
||||
return;
|
||||
|
@ -564,7 +564,7 @@ Draw_ConsoleBackground (int lines, byte alpha)
|
|||
else {
|
||||
f = 0;
|
||||
fstep = 320 * 0x10000 / vid.conwidth;
|
||||
for (x = 0; x < (int) vid.conwidth; x += 4) {
|
||||
for (x = 0; x < vid.conwidth; x += 4) {
|
||||
dest[x] = src[f >> 16];
|
||||
f += fstep;
|
||||
dest[x + 1] = src[f >> 16];
|
||||
|
@ -630,7 +630,7 @@ Draw_TileClear (int x, int y, int w, int h)
|
|||
byte *psrc;
|
||||
vrect_t vr;
|
||||
|
||||
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
|
||||
CLIP (x, y, w, h, vid.width, vid.height);
|
||||
|
||||
r_rectdesc.rect.x = x;
|
||||
r_rectdesc.rect.y = y;
|
||||
|
@ -693,12 +693,12 @@ Draw_Fill (int x, int y, int w, int h, int c)
|
|||
byte *dest;
|
||||
int u, v;
|
||||
|
||||
if (x < 0 || x + w > (int) vid.conwidth
|
||||
|| y < 0 || y + h > (int) vid.conheight) {
|
||||
if (x < 0 || x + w > vid.conwidth
|
||||
|| y < 0 || y + h > vid.conheight) {
|
||||
Sys_MaskPrintf (SYS_VID, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
|
||||
x, y, w, h, c);
|
||||
}
|
||||
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
|
||||
CLIP (x, y, w, h, vid.width, vid.height);
|
||||
|
||||
dest = ((byte*)vid.buffer) + y * vid.rowbytes + x;
|
||||
for (v = 0; v < h; v++, dest += vid.rowbytes)
|
||||
|
@ -710,7 +710,7 @@ Draw_Fill (int x, int y, int w, int h, int c)
|
|||
void
|
||||
Draw_FadeScreen (void)
|
||||
{
|
||||
unsigned int x, y;
|
||||
int x, y;
|
||||
byte *pbuf;
|
||||
|
||||
VID_UnlockBuffer ();
|
||||
|
|
|
@ -95,10 +95,8 @@ SCR_ScreenShot (int width, int height)
|
|||
// enable direct drawing of console to back buffer
|
||||
D_EnableBackBufferAccess ();
|
||||
|
||||
w = (vid.width < (unsigned int) width) ? vid.width
|
||||
: (unsigned int) width;
|
||||
h = (vid.height < (unsigned int) height) ? vid.height
|
||||
: (unsigned int) height;
|
||||
w = (vid.width < width) ? vid.width : width;
|
||||
h = (vid.height < height) ? vid.height : height;
|
||||
|
||||
fracw = (float) vid.width / (float) w;
|
||||
frach = (float) vid.height / (float) h;
|
||||
|
|
|
@ -1083,8 +1083,8 @@ renderside (byte* bufs, double yaw, double pitch, double roll, int side)
|
|||
static void
|
||||
renderlookup (byte **offs, byte* bufs)
|
||||
{
|
||||
byte *p = (byte*)vid.buffer;
|
||||
unsigned int x, y;
|
||||
byte *p = (byte*)vid.buffer;
|
||||
int x, y;
|
||||
for (y = 0; y < vid.height; y++) {
|
||||
for (x = 0; x < vid.width; x++, offs++)
|
||||
p[x] = **offs;
|
||||
|
|
|
@ -45,7 +45,7 @@ sw32_D_FillRect (vrect_t *rect, int color)
|
|||
{
|
||||
case 1:
|
||||
{
|
||||
unsigned int rx, ry, rwidth, rheight;
|
||||
int rx, ry, rwidth, rheight;
|
||||
byte *dest, pix;
|
||||
|
||||
pix = color;
|
||||
|
@ -83,7 +83,7 @@ sw32_D_FillRect (vrect_t *rect, int color)
|
|||
break;
|
||||
case 2:
|
||||
{
|
||||
unsigned int rx, ry, rwidth, rheight;
|
||||
int rx, ry, rwidth, rheight;
|
||||
unsigned short *dest, pix;
|
||||
|
||||
pix = sw32_8to16table[color];
|
||||
|
@ -122,7 +122,7 @@ sw32_D_FillRect (vrect_t *rect, int color)
|
|||
break;
|
||||
case 4:
|
||||
{
|
||||
unsigned int rx, ry, rwidth, rheight;
|
||||
int rx, ry, rwidth, rheight;
|
||||
unsigned int *dest, pix;
|
||||
|
||||
pix = d_8to24table[color];
|
||||
|
|
|
@ -87,7 +87,7 @@ sw32_D_ViewChanged (void)
|
|||
r_refdef.vrectbottom - (sw32_d_pix_max << sw32_d_y_aspect_shift);
|
||||
|
||||
{
|
||||
unsigned int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < vid.height; i++) {
|
||||
sw32_d_scantable[i] = i * rowpixels;
|
||||
|
|
|
@ -52,8 +52,8 @@ D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
|
|||
else
|
||||
temp = (float) r_refdef.vrect.height;
|
||||
|
||||
wu = 8192.0 * (float) (u - ((int) vid.width >> 1)) / temp;
|
||||
wv = 8192.0 * (float) (((int) vid.height >> 1) - v) / temp;
|
||||
wu = 8192.0 * (float) (u - (vid.width >> 1)) / temp;
|
||||
wv = 8192.0 * (float) ((vid.height >> 1) - v) / temp;
|
||||
|
||||
end[0] = 4096 * vpn[0] + wu * vright[0] + wv * vup[0];
|
||||
end[1] = 4096 * vpn[1] + wu * vright[1] + wv * vup[1];
|
||||
|
|
|
@ -51,5 +51,5 @@ byte *sw32_cacheblock;
|
|||
int sw32_cachewidth;
|
||||
byte *sw32_d_viewbuffer;
|
||||
short *sw32_d_pzbuffer;
|
||||
unsigned int sw32_d_zrowbytes;
|
||||
unsigned int sw32_d_zwidth;
|
||||
int sw32_d_zrowbytes;
|
||||
int sw32_d_zwidth;
|
||||
|
|
|
@ -265,7 +265,7 @@ sw32_Draw_Character (int x, int y, unsigned int chr)
|
|||
if (y <= -8)
|
||||
return; // totally off screen
|
||||
|
||||
if (y > (int) vid.conheight - 8 || x < 0 || x > (int) vid.conwidth - 8)
|
||||
if (y > vid.conheight - 8 || x < 0 || x > vid.conwidth - 8)
|
||||
return;
|
||||
if (chr < 0 || chr > 255)
|
||||
return;
|
||||
|
@ -494,8 +494,8 @@ sw32_Draw_Pic (int x, int y, qpic_t *pic)
|
|||
byte *source, tbyte;
|
||||
int v, u;
|
||||
|
||||
if (x < 0 || (unsigned int) (x + pic->width) > vid.conwidth || y < 0 ||
|
||||
(unsigned int) (y + pic->height) > vid.conheight) {
|
||||
if (x < 0 || (x + pic->width) > vid.conwidth
|
||||
|| y < 0 || (y + pic->height) > vid.conheight) {
|
||||
Sys_MaskPrintf (SYS_VID, "Draw_Pic: bad coordinates");
|
||||
sw32_Draw_SubPic (x, y, pic, 0, 0, pic->width, pic->height);
|
||||
return;
|
||||
|
@ -593,8 +593,8 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
byte *source, tbyte;
|
||||
int v, u;
|
||||
|
||||
if ((x < 0) || (x + width > (int) vid.conwidth)
|
||||
|| (y < 0) || (y + height > (int) vid.conheight)) {
|
||||
if ((x < 0) || (x + width > vid.conwidth)
|
||||
|| (y < 0) || (y + height > vid.conheight)) {
|
||||
Sys_MaskPrintf (SYS_VID, "Draw_SubPic: bad coordinates");
|
||||
}
|
||||
// first, clip to screen
|
||||
|
@ -603,7 +603,7 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
width += x;
|
||||
x = 0;
|
||||
}
|
||||
if (x + width > (int) vid.width)
|
||||
if (x + width > vid.width)
|
||||
width = vid.width - x;
|
||||
if (width <= 0)
|
||||
return;
|
||||
|
@ -612,7 +612,7 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
height += y;
|
||||
y = 0;
|
||||
}
|
||||
if (y + height > (int) vid.height)
|
||||
if (y + height > vid.height)
|
||||
height = vid.height - y;
|
||||
if (height <= 0)
|
||||
return;
|
||||
|
@ -687,7 +687,7 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
|
|||
else {
|
||||
f = 0;
|
||||
fstep = 320 * 0x10000 / vid.conwidth;
|
||||
for (x = 0; x < (int) vid.conwidth; x += 4) {
|
||||
for (x = 0; x < vid.conwidth; x += 4) {
|
||||
dest[x] = src[f >> 16];
|
||||
f += fstep;
|
||||
dest[x + 1] = src[f >> 16];
|
||||
|
@ -712,7 +712,7 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
|
|||
src = conback->data + v * 320;
|
||||
f = 0;
|
||||
fstep = 320 * 0x10000 / vid.conwidth;
|
||||
for (x = 0; x < (int) vid.conwidth; x += 4) {
|
||||
for (x = 0; x < vid.conwidth; x += 4) {
|
||||
dest[x] = sw32_8to16table[src[f >> 16]];
|
||||
f += fstep;
|
||||
dest[x + 1] = sw32_8to16table[src[f >> 16]];
|
||||
|
@ -733,7 +733,7 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
|
|||
src = conback->data + v * 320;
|
||||
f = 0;
|
||||
fstep = 320 * 0x10000 / vid.conwidth;
|
||||
for (x = 0; x < (int) vid.conwidth; x += 4) {
|
||||
for (x = 0; x < vid.conwidth; x += 4) {
|
||||
dest[x ] = d_8to24table[src[f >> 16]];f += fstep;
|
||||
dest[x + 1] = d_8to24table[src[f >> 16]];f += fstep;
|
||||
dest[x + 2] = d_8to24table[src[f >> 16]];f += fstep;
|
||||
|
@ -1046,7 +1046,7 @@ sw32_Draw_TileClear (int x, int y, int w, int h)
|
|||
byte *psrc;
|
||||
vrect_t vr;
|
||||
|
||||
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
|
||||
CLIP (x, y, w, h, vid.width, vid.height);
|
||||
|
||||
r_rectdesc.rect.x = x;
|
||||
r_rectdesc.rect.y = y;
|
||||
|
@ -1108,12 +1108,12 @@ sw32_Draw_Fill (int x, int y, int w, int h, int c)
|
|||
{
|
||||
int u, v;
|
||||
|
||||
if (x < 0 || x + w > (int) vid.conwidth
|
||||
|| y < 0 || y + h > (int) vid.conheight) {
|
||||
if (x < 0 || x + w > vid.conwidth
|
||||
|| y < 0 || y + h > vid.conheight) {
|
||||
Sys_MaskPrintf (SYS_VID, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n",
|
||||
x, y, w, h, c);
|
||||
}
|
||||
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
|
||||
CLIP (x, y, w, h, vid.width, vid.height);
|
||||
|
||||
switch (sw32_r_pixbytes) {
|
||||
case 1:
|
||||
|
@ -1153,7 +1153,7 @@ sw32_Draw_Fill (int x, int y, int w, int h, int c)
|
|||
void
|
||||
sw32_Draw_FadeScreen (void)
|
||||
{
|
||||
unsigned int x, y;
|
||||
int x, y;
|
||||
|
||||
VID_UnlockBuffer ();
|
||||
S_ExtraUpdate ();
|
||||
|
@ -1237,7 +1237,7 @@ sw32_Draw_BlendScreen (quat_t color)
|
|||
break;
|
||||
case 2:
|
||||
{
|
||||
unsigned int g1, g2, x, y;
|
||||
int g1, g2, x, y;
|
||||
unsigned short rramp[32], gramp[64], bramp[32], *temp;
|
||||
for (i = 0; i < 32; i++) {
|
||||
r = i << 3;
|
||||
|
@ -1264,7 +1264,8 @@ sw32_Draw_BlendScreen (quat_t color)
|
|||
break;
|
||||
case 4:
|
||||
{
|
||||
unsigned int x, y;
|
||||
int x, y;
|
||||
|
||||
byte ramp[256][4], *temp;
|
||||
for (i = 0; i < 256; i++) {
|
||||
r = i;
|
||||
|
@ -1281,7 +1282,7 @@ sw32_Draw_BlendScreen (quat_t color)
|
|||
ramp[i][3] = 0;
|
||||
}
|
||||
temp = vid.buffer;
|
||||
for (y = 0;y < vid.height;y++, temp += vid.rowbytes)
|
||||
for (y = 0; y < vid.height; y++, temp += vid.rowbytes)
|
||||
{
|
||||
for (x = 0;x < vid.width;x++)
|
||||
{
|
||||
|
|
|
@ -248,8 +248,8 @@ sw32_R_SetupFrame (void)
|
|||
|
||||
if ((sw32_r_dowarp != sw32_r_dowarpold) || sw32_r_viewchanged) {
|
||||
if (sw32_r_dowarp) {
|
||||
if ((vid.width <= (unsigned int) vid.maxwarpwidth) &&
|
||||
(vid.height <= (unsigned int) vid.maxwarpheight)) {
|
||||
if ((vid.width <= vid.maxwarpwidth)
|
||||
&& (vid.height <= vid.maxwarpheight)) {
|
||||
vrect.x = 0;
|
||||
vrect.y = 0;
|
||||
vrect.width = vid.width;
|
||||
|
|
|
@ -339,8 +339,7 @@ check_mouse_event (Display *disp, XEvent *ev, XPointer arg)
|
|||
XMotionEvent *me = &ev->xmotion;
|
||||
if (ev->type != MotionNotify)
|
||||
return False;
|
||||
if ((unsigned) me->x != viddef.width / 2
|
||||
|| (unsigned) me->y != viddef.height / 2)
|
||||
if (me->x != viddef.width / 2 || me->y != viddef.height / 2)
|
||||
return False;
|
||||
return True;
|
||||
}
|
||||
|
|
|
@ -700,8 +700,8 @@ event_motion (XEvent *event)
|
|||
} else {
|
||||
if (vid_fullscreen->int_val || input_grabbed) {
|
||||
if (!event->xmotion.send_event) {
|
||||
unsigned dist_x = abs (viddef.width / 2 - event->xmotion.x);
|
||||
unsigned dist_y = abs (viddef.height / 2 - event->xmotion.y);
|
||||
int dist_x = abs (viddef.width / 2 - event->xmotion.x);
|
||||
int dist_y = abs (viddef.height / 2 - event->xmotion.y);
|
||||
in_mouse_x += (event->xmotion.x - p_mouse_x);
|
||||
in_mouse_y += (event->xmotion.y - p_mouse_y);
|
||||
if (dist_x > viddef.width / 4 || dist_y > viddef.height / 4) {
|
||||
|
|
Loading…
Reference in a new issue