1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-30 10:38:37 +00:00
freebsd-ports/games/fuhquake/files/patch-vid_x11.c
Sergey A. Osokin aaba25b6be Update port:
- Fixes build on 5.x with XMMS support enabled;
- Fixes path where to look for XMMS binary;
- Allows fuhquake to be run from any directory per kris' suggestion;
- Adds WITH_SHAREWARE_DATA knob.  Coupled with previous, this
  makes fuhquake playable right after install, yet allows it to be
  distributed on CDROM (since shareware data cannot be included,
  one must explicitly define this knob);
- Properly utilizes EXTRACT_ONLY in Makefile and DOCSDIR in pkg-plist;
- Removes EXTRACT_BEFORE_ARGS from Makefile since it's no longer needed;
- Tells user about WITHOUT_XMMS knob, when XMMS bits are found;
- Fixes palette problems on 24-bit depth with x11-renderer;
- Fixes DGA mouse behavior on higher mouse rates when GLX-rendered.

Submitted by:	Alexey Dokuchaev <danfe@regency.nsu.ru>
PR:		56085
2003-09-01 11:52:06 +00:00

132 lines
3.4 KiB
C

--- vid_x11.c.orig Mon Aug 25 21:01:40 2003
+++ vid_x11.c Mon Aug 25 21:10:09 2003
@@ -21,7 +21,8 @@
#define _BSD
-typedef unsigned short PIXEL;
+typedef unsigned short PIXEL16;
+typedef unsigned PIXEL24;
#include <ctype.h>
#include <sys/time.h>
@@ -111,7 +112,8 @@
void (*vid_menukeyfn)(int key);
void VID_MenuKey (int key);
-static PIXEL st2d_8to16table[256];
+static PIXEL16 st2d_8to16table[256];
+static PIXEL24 st2d_8to24table[256];
static int shiftmask_fl=0;
static long r_shift,g_shift,b_shift;
static unsigned long r_mask,g_mask,b_mask;
@@ -132,8 +134,42 @@
shiftmask_fl = 1;
}
-PIXEL xlib_rgb(int r,int g,int b) {
- PIXEL p;
+PIXEL16 xlib_rgb16(int r,int g,int b) {
+ PIXEL16 p;
+
+ if (shiftmask_fl == 0)
+ shiftmask_init();
+ p = 0;
+
+ if (r_shift > 0) {
+ p = (r << (r_shift)) &r_mask;
+ } else if(r_shift<0) {
+ p = (r >> (-r_shift)) &r_mask;
+ } else {
+ p |= (r & r_mask);
+ }
+
+ if(g_shift>0) {
+ p |= (g << (g_shift)) &g_mask;
+ } else if(g_shift<0) {
+ p |= (g >> (-g_shift)) &g_mask;
+ } else {
+ p|=(g & g_mask);
+ }
+
+ if(b_shift > 0) {
+ p |= (b << (b_shift)) &b_mask;
+ } else if (b_shift < 0) {
+ p |= (b >> (-b_shift)) &b_mask;
+ } else {
+ p|=(b & b_mask);
+ }
+
+ return p;
+}
+
+PIXEL24 xlib_rgb24(int r,int g,int b) {
+ PIXEL24 p;
if (shiftmask_fl == 0)
shiftmask_init();
@@ -169,20 +205,37 @@
void st2_fixup( XImage *framebuf, int x, int y, int width, int height) {
int xi,yi;
unsigned char *src;
- PIXEL *dest;
+ PIXEL16 *dest;
if(x < 0 || y < 0)
return;
for (yi = y; yi < y + height; yi++) {
src = &framebuf->data [yi * framebuf->bytes_per_line];
- dest = (PIXEL*)src;
+ dest = (PIXEL16 *)src;
for(xi = (x + width - 1); xi >= x; xi--) {
dest[xi] = st2d_8to16table[src[xi]];
}
}
}
+void st3_fixup( XImage *framebuf, int x, int y, int width, int height) {
+ int xi,yi;
+ unsigned char *src;
+ PIXEL24 *dest;
+
+ if(x < 0 || y < 0)
+ return;
+
+ for (yi = y; yi < y + height; yi++) {
+ src = &framebuf->data [yi * framebuf->bytes_per_line];
+ dest = (PIXEL24 *)src;
+ for(xi = (x + width - 1); xi >= x; xi--) {
+ dest[xi] = st2d_8to24table[src[xi]];
+ }
+ }
+}
+
// ========================================================================
// Tragic death handler
// ========================================================================
@@ -564,8 +617,10 @@
int i;
XColor colors[256];
- for (i = 0; i < 256; i++)
- st2d_8to16table[i]= xlib_rgb(palette[i * 3], palette[i * 3 + 1], palette[i * 3 + 2]);
+ for (i = 0; i < 256; i++) {
+ st2d_8to24table[i]= xlib_rgb24(palette[i * 3], palette[i * 3 + 1], palette[i * 3 + 2]);
+ st2d_8to16table[i]= xlib_rgb16(palette[i * 3], palette[i * 3 + 1], palette[i * 3 + 2]);
+ }
if (x_visinfo->class == PseudoColor && x_visinfo->depth == 8) {
if (palette != current_palette)
@@ -821,7 +876,9 @@
if (doShm) {
while (rects){
- if (x_visinfo->depth != 8)
+ if (x_visinfo->depth == 24)
+ st3_fixup( x_framebuffer[current_framebuffer], rects->x, rects->y, rects->width, rects->height);
+ else if (x_visinfo->depth == 16)
st2_fixup( x_framebuffer[current_framebuffer], rects->x, rects->y, rects->width, rects->height);
if (!XShmPutImage(x_disp, x_win, x_gc,
x_framebuffer[current_framebuffer], rects->x, rects->y, rects->x, rects->y, rects->width, rects->height, True))