Commit a69bba1d authored by Steven Fuller's avatar Steven Fuller

Added mitshm for vi_xlib and removed Get/SetColor

parent 5f295323
......@@ -15,7 +15,7 @@ GOBJS = $(OBJS) vi_ogl.o vi_glx.o
LFLAGS = -lm
#LFLAGS = -lm -lvga ElectricFence-2.2.2/libefence.a -lpthread
SLFLAGS = $(LFLAGS) -lvga
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext
GLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lGL
NASM = nasm
......
......@@ -83,9 +83,9 @@ we can stop the large conversion before each UpdateScreen
also, the higher bitrates are a hack since a palette lookup has to be done
for every byte when transferring to the pixmap, palette fades require a
screen update
* mitshm
* dga 1 and 2
* make sure none of the code tries to handle gfx/sound data directly
* GL_shared_texture_palette
* GL_shared_texture_palette for opengl
Specific:
* memory/sound intro screen goes
......
......@@ -14,8 +14,6 @@ void VL_WaitVBL(int vbls);
void VW_UpdateScreen();
void VL_FillPalette(int red, int green, int blue);
void VL_SetColor(int color, int red, int green, int blue);
void VL_GetColor(int color, int *red, int *green, int *blue);
void VL_SetPalette(byte *palette);
void VL_GetPalette(byte *palette);
......
......@@ -247,34 +247,6 @@ void VL_FillPalette(int red, int green, int blue)
//===========================================================================
/*
=================
=
= VL_SetColor
=
=================
*/
void VL_SetColor(int color, int red, int green, int blue)
{
}
//===========================================================================
/*
=================
=
= VL_GetColor
=
=================
*/
void VL_GetColor(int color, int *red, int *green, int *blue)
{
}
//===========================================================================
/*
=================
=
......
......@@ -103,36 +103,6 @@ void VL_FillPalette(int red, int green, int blue)
//===========================================================================
/*
=================
=
= VL_SetColor
=
=================
*/
void VL_SetColor(int color, int red, int green, int blue)
{
vga_setpalette(color, red, green, blue);
}
//===========================================================================
/*
=================
=
= VL_GetColor
=
=================
*/
void VL_GetColor(int color, int *red, int *green, int *blue)
{
vga_getpalette(color, red, green, blue);
}
//===========================================================================
/*
=================
=
......
......@@ -2,6 +2,9 @@
#include "id_heads.h"
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xutil.h>
......@@ -24,9 +27,12 @@ XImage *img;
Colormap cmap;
Atom wmDeleteWindow;
XShmSegmentInfo shminfo;
XColor clr[256];
int indexmode;
int shmmode;
unsigned char mypal[768];
Colormap GetVisual()
......@@ -252,7 +258,10 @@ void VW_UpdateScreen()
}
}
XPutImage(dpy, win, gc, img, 0, 0, 0, 0, 320, 200);
if (shmmode)
XShmPutImage(dpy, win, gc, img, 0, 0, 0, 0, 320, 200, False);
else
XPutImage(dpy, win, gc, img, 0, 0, 0, 0, 320, 200);
}
/*
......@@ -283,21 +292,52 @@ int BPP(int d)
void VL_Startup()
{
if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1);
shmmode = 0;
if (indexmode)
disbuf = gfxbuf;
else
disbuf = malloc(320 * 200 * BPP(vi->depth));
if (XShmQueryExtension(dpy) == True) {
img = XShmCreateImage(dpy, vi->visual, vi->depth, ZPixmap,
NULL, &shminfo, 320, 200);
printf("Shm: bpl = %d, h = %d, bp = %d\n", img->bytes_per_line, img->height, img->bitmap_pad);
if ( img->bytes_per_line != (320 * BPP(vi->depth)) ) {
printf("Currently cannot handle irregular shm sizes...\n");
} else {
shminfo.shmid = shmget(IPC_PRIVATE, img->bytes_per_line * img->height, IPC_CREAT | 0777);
shminfo.shmaddr = img->data = shmat(shminfo.shmid, 0, 0);
shminfo.readOnly = False;
disbuf = img->data;
if (indexmode)
gfxbuf = disbuf;
else
gfxbuf = malloc(320 * 200 * 1);
if (XShmAttach(dpy, &shminfo) == True) {
printf("Using XShm Extension...\n");
shmmode = 1;
} else {
printf("Error with XShm...\n");
}
}
}
if (img == NULL) {
printf("Falling back on XImage...\n");
img = XCreateImage(dpy, vi->visual, vi->depth, ZPixmap, 0, (char *)disbuf, 320, 200,
if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1);
if (indexmode)
disbuf = gfxbuf;
else
disbuf = malloc(320 * 200 * BPP(vi->depth));
img = XCreateImage(dpy, vi->visual, vi->depth, ZPixmap, 0, (char *)disbuf, 320, 200,
8, 320 * BPP(vi->depth));
if (img == NULL) {
Quit("XCreateImage returned NULL");
}
if (img == NULL) {
Quit("XCreateImage returned NULL");
}
}
XMapWindow(dpy, win);
XFlush(dpy);
......@@ -313,12 +353,22 @@ void VL_Startup()
void VL_Shutdown (void)
{
if (gfxbuf != NULL) {
if ( !shmmode && (gfxbuf != NULL) ) {
free(gfxbuf);
gfxbuf = NULL;
}
if ( shmmode && !indexmode && (gfxbuf != NULL) ) {
free(gfxbuf);
gfxbuf = NULL;
}
if ( (indexmode == 0) && (disbuf != NULL) ) {
if (shmmode) {
XShmDetach(dpy, &shminfo);
XDestroyImage(img);
shmdt(shminfo.shmaddr);
shmctl(shminfo.shmid, IPC_RMID, 0);
} else if ( (indexmode == 0) && (disbuf != NULL) ) {
free(disbuf);
disbuf = NULL;
}
......@@ -383,54 +433,6 @@ void VL_FillPalette(int red, int green, int blue)
//===========================================================================
/*
=================
=
= VL_SetColor
=
=================
*/
void VL_SetColor(int color, int red, int green, int blue)
{
if (indexmode) {
clr[color].red = red << 10;
clr[color].green = green << 10;
clr[color].blue = blue << 10;
XStoreColors(dpy, cmap, clr, 256);
} else {
mypal[color*3+0] = red;
mypal[color*3+1] = green;
mypal[color*3+2] = blue;
}
}
//===========================================================================
/*
=================
=
= VL_GetColor
=
=================
*/
void VL_GetColor(int color, int *red, int *green, int *blue)
{
if (indexmode) {
*red = clr[color].red >> 10;
*green = clr[color].green >> 10;
*blue = clr[color].blue >> 10;
} else {
*red = mypal[color*3+0];
*green = mypal[color*3+1];
*blue = mypal[color*3+2];
}
}
//===========================================================================
/*
=================
=
......
......@@ -168,14 +168,14 @@ boolean TransformTile (int tx, int ty, int *dispx, int *dispheight)
return false;
}
*dispx = centerx + ny*scale/nx; // DEBUG: use assembly divide
*dispx = centerx + ny*scale/nx;
*dispheight = heightnumerator/(nx>>8);
//
// see if it should be grabbed
//
if (nx<TILEGLOBAL && ny>-TILEGLOBAL/2 && ny<TILEGLOBAL/2)
if ( (nx<TILEGLOBAL) && (ny>-TILEGLOBAL/2) && (ny<TILEGLOBAL/2) )
return true;
else
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment