Commit b9b5ef39 authored by Steven Fuller's avatar Steven Fuller

hacked in dga support (8bit for now)

parent fd76d414
...@@ -2,8 +2,8 @@ CC = gcc ...@@ -2,8 +2,8 @@ CC = gcc
#CFLAGS = -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro #CFLAGS = -Wall -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
#CFLAGS = -g -Wall #CFLAGS = -g -Wall
#CFLAGS = -g CFLAGS = -g
CFLAGS = -Os #CFLAGS = -Os
#CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include #CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
......
* Notes on the OpenGL Port Implementation:
First just draw the world as a display list heh, except doors and pushwalls
then draw everything else
Textures which are not usable will have to be specially drawn
...@@ -75,10 +75,11 @@ screen update ...@@ -75,10 +75,11 @@ screen update
* make sure none of the code tries to handle gfx/sound data directly * make sure none of the code tries to handle gfx/sound data directly
* GL_shared_texture_palette for opengl * GL_shared_texture_palette for opengl
* if window looses focus, should it clear the keys ? * if window looses focus, should it clear the keys ?
* add DGA, clean up vi_xlib.c, fix vid mode changing * clean up vi_xlib.c: fix vid mode changing, fix dga for non8bit modes and
the nonpalette setting stuff... lots of if statements
* fix broken opengl.. argh wolf3d updates lots of stuff used in other parts * fix broken opengl.. argh wolf3d updates lots of stuff used in other parts
of the game (namely stuff used for hit testing when firing weapon) in the of the game (namely stuff used for hit testing when firing weapon) in the
draw loop.. start by cp wl_draw.c vi_ogl.c and just take out the actual draw loop.. start by cp wl_draw.c vi_ogl.c and just take out the actual
drawing bits and replace with opengl. drawing bits and replace with opengl.
* change visable -> visible * rename visable to visible
* fix up windows port * fix up windows port
...@@ -37,6 +37,9 @@ XColor clr[256]; ...@@ -37,6 +37,9 @@ XColor clr[256];
int indexmode; int indexmode;
int shmmode; int shmmode;
int fullscreen; int fullscreen;
int dga;
byte *dgabuf;
int dgawidth, dgabank, dgamem, vwidth, vheight;
unsigned char mypal[768]; unsigned char mypal[768];
int main(int argc, char *argv[]) int main(int argc, char *argv[])
...@@ -239,20 +242,10 @@ void VL_Startup() ...@@ -239,20 +242,10 @@ void VL_Startup()
root = RootWindow(dpy, screen); root = RootWindow(dpy, screen);
GetVisual(); /* GetVisual will quit for us if no visual.. */ GetVisual(); /* GetVisual will quit for us if no visual.. */
attr.colormap = cmap;
attr.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask;
attrmask = CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, CopyFromParent,
InputOutput, vi->visual, attrmask, &attr);
if (win == None) {
Quit("Unable to create window!");
}
fullscreen = 0; fullscreen = 0;
if (MS_CheckParm("fullscreen") && XF86VidModeQueryExtension(dpy, &eventn, &errorn)) { if (MS_CheckParm("fullscreen") && XF86VidModeQueryExtension(dpy, &eventn, &errorn)) {
XF86VidModeGetAllModeLines(dpy, screen, &vmc, (XF86VidModeModeInfo ***)&vmmi); XF86VidModeGetAllModeLines(dpy, screen, &vmc, (XF86VidModeModeInfo ***)&vmmi);
printf("VidMode: eventn = %d, error = %d, vmc = %d\n", eventn, errorn, vmc); printf("VidMode: eventn = %d, error = %d, vmc = %d\n", eventn, errorn, vmc);
...@@ -270,6 +263,54 @@ void VL_Startup() ...@@ -270,6 +263,54 @@ void VL_Startup()
} }
} }
} }
dga = 0;
if (fullscreen && MS_CheckParm("dga") && XF86DGAQueryExtension(dpy, &eventn, &errorn)) {
if (geteuid()) {
fprintf(stderr, "must be root to use dga\n");
} else {
printf("DGA %d %d\n", eventn, errorn);
XF86DGAQueryVersion(dpy, &eventn, &errorn);
printf("DGA Version %d.%d\n", eventn, errorn);
XF86DGAQueryDirectVideo(dpy, screen, &i);
if (i & XF86DGADirectPresent) {
XF86DGAGetVideo(dpy, screen, (char **)&dgabuf, &dgawidth, &dgabank, &dgamem);
printf("addr = %p, width = %d, bank = %d, mem = %d\n", dgabuf, dgawidth, dgabank, dgamem);
gfxbuf = disbuf = dgabuf;
XF86DGAGetViewPortSize(dpy, screen, &vwidth, &vheight);
printf("width = %d, height = %d\n", vwidth, vheight);
gfxbuf = (byte *)malloc(320 * 200);
if (!indexmode)
disbuf = (byte *)malloc(320 * 4);
dga = 1;
}
}
}
}
//attr.colormap = cmap;
attr.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask;
attrmask = /*CWColormap |*/ CWEventMask;
if (dga) {
attrmask |= CWOverrideRedirect;
attr.override_redirect = True;
}
win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, CopyFromParent,
InputOutput, vi->visual, attrmask, &attr);
if (win == None) {
Quit("Unable to create window!");
}
if (dga) {
XMapWindow(dpy, win);
XRaiseWindow(dpy, win);
XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
} }
gcvalues.foreground = BlackPixel(dpy, screen); gcvalues.foreground = BlackPixel(dpy, screen);
...@@ -298,7 +339,7 @@ void VL_Startup() ...@@ -298,7 +339,7 @@ void VL_Startup()
shmmode = 0; shmmode = 0;
if (XShmQueryExtension(dpy) == True) { if ( !dga && (XShmQueryExtension(dpy) == True) ) {
img = XShmCreateImage(dpy, vi->visual, vi->depth, ZPixmap, img = XShmCreateImage(dpy, vi->visual, vi->depth, ZPixmap,
NULL, &shminfo, 320, 200); NULL, &shminfo, 320, 200);
printf("Shm: bpl = %d, h = %d, bp = %d\n", img->bytes_per_line, img->height, img->bitmap_pad); printf("Shm: bpl = %d, h = %d, bp = %d\n", img->bytes_per_line, img->height, img->bitmap_pad);
...@@ -324,7 +365,7 @@ void VL_Startup() ...@@ -324,7 +365,7 @@ void VL_Startup()
} }
} }
if (img == NULL) { if ( !dga && (img == NULL) ) {
printf("Falling back on XImage...\n"); printf("Falling back on XImage...\n");
if (gfxbuf == NULL) if (gfxbuf == NULL)
...@@ -350,6 +391,13 @@ void VL_Startup() ...@@ -350,6 +391,13 @@ void VL_Startup()
XF86VidModeSetViewPort(dpy, screen, 0, 0); XF86VidModeSetViewPort(dpy, screen, 0, 0);
} }
if (dga) {
XF86DGADirectVideo(dpy, screen, XF86DGADirectGraphics | XF86DGADirectKeyb);
XF86DGASetViewPort(dpy, screen, 0, 0);
}
XSetWindowColormap(dpy, win, cmap);
XFlush(dpy); XFlush(dpy);
} }
...@@ -363,6 +411,14 @@ void VL_Startup() ...@@ -363,6 +411,14 @@ void VL_Startup()
void VL_Shutdown() void VL_Shutdown()
{ {
if (dga) {
XF86DGADirectVideo(dpy, screen, 0);
XUngrabKeyboard(dpy, CurrentTime);
free(gfxbuf);
free(disbuf);
gfxbuf = disbuf = NULL;
}
if (fullscreen) { if (fullscreen) {
XF86VidModeLockModeSwitch(dpy, screen, False); XF86VidModeLockModeSwitch(dpy, screen, False);
//printf("%d, %d\n", vidmode.hdisplay, vidmode.vdisplay); //printf("%d, %d\n", vidmode.hdisplay, vidmode.vdisplay);
...@@ -401,10 +457,52 @@ void VL_WaitVBL(int vbls) ...@@ -401,10 +457,52 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen() void VW_UpdateScreen()
{ {
word *ptrs; word *ptrs;
byte *ptrb; byte *ptrb, *ptrbd;
int i; int i, j;
if (dga) {
switch(vi->depth) {
case 8:
ptrb = dgabuf;
ptrbd = gfxbuf;
for(i = 0; i < 200; i++) {
memcpy(ptrb, ptrbd, 320);
ptrb += dgawidth;
ptrbd += 320;
}
return;
#if 0
case 15:
ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrs = (mypal[gfxbuf[i]*3+0] >> 1) << 10 |
(mypal[gfxbuf[i]*3+1] >> 1) << 5 |
(mypal[gfxbuf[i]*3+2] >> 1);
ptrs++;
}
break;
case 16:
ptrs = (word *)disbuf;
for (i = 0; i < 64000; i++) {
*ptrs = (mypal[gfxbuf[i]*3+0] >> 1) << 11 |
(mypal[gfxbuf[i]*3+1] >> 0) << 5 |
(mypal[gfxbuf[i]*3+2] >> 1);
ptrs++;
}
break;
case 24:
ptrb = disbuf;
for (i = 0; i < 64000; i++) {
*ptrb = mypal[gfxbuf[i]*3+2] << 2; ptrb++;
*ptrb = mypal[gfxbuf[i]*3+1] << 2; ptrb++;
*ptrb = mypal[gfxbuf[i]*3+0] << 2; ptrb++;
ptrb++;
}
break;
#endif
}
}
if (indexmode == 0) { if (indexmode == 0) {
switch(vi->depth) { switch(vi->depth) {
case 15: case 15:
...@@ -474,6 +572,7 @@ void VL_FillPalette(int red, int green, int blue) ...@@ -474,6 +572,7 @@ void VL_FillPalette(int red, int green, int blue)
} }
XStoreColors(dpy, cmap, clr, 256); XStoreColors(dpy, cmap, clr, 256);
if (dga) XF86DGAInstallColormap(dpy, screen, cmap);
} else { } else {
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
mypal[i*3+0] = red; mypal[i*3+0] = red;
...@@ -504,13 +603,9 @@ void VL_SetPalette(const byte *palette) ...@@ -504,13 +603,9 @@ void VL_SetPalette(const byte *palette)
clr[i].blue = palette[i*3+2] << 10; clr[i].blue = palette[i*3+2] << 10;
} }
XStoreColors(dpy, cmap, clr, 256); XStoreColors(dpy, cmap, clr, 256);
if (dga) XF86DGAInstallColormap(dpy, screen, cmap);
} else { } else {
/* TODO: memcpy? */ memcpy(mypal, palette, 768);
for (i = 0; i < 256; i++) {
mypal[i*3+0] = palette[i*3+0];
mypal[i*3+1] = palette[i*3+1];
mypal[i*3+2] = palette[i*3+2];
}
VW_UpdateScreen(); VW_UpdateScreen();
} }
} }
...@@ -679,6 +774,14 @@ void VL_DeModeXize(byte *buf, int width, int height) ...@@ -679,6 +774,14 @@ void VL_DeModeXize(byte *buf, int width, int height)
void VL_DirectPlot(int x1, int y1, int x2, int y2) void VL_DirectPlot(int x1, int y1, int x2, int y2)
{ {
if (dga) {
switch(vi->depth) {
case 8:
*(dgabuf + x2 + y2 * dgawidth) = *(gfxbuf + x1 + y1 * 320);
return;
}
return;
}
if (indexmode) { if (indexmode) {
XSetForeground(dpy, gc, *(gfxbuf + x1 + y1 * 320)); XSetForeground(dpy, gc, *(gfxbuf + x1 + y1 * 320));
XDrawPoint(dpy, win, gc, x2, y2); XDrawPoint(dpy, win, gc, x2, y2);
......
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