Commit 1b487c9d authored by Steven Fuller's avatar Steven Fuller

Supported changing X res. via XF86VidMode extension

parent 2f85d531
......@@ -19,7 +19,7 @@ GOBJS = $(OBJS) vi_ogl.o vi_glx.o
LFLAGS = -lm -L/home/relnev/cvs/oal/linux/src -lopenal -lpthread -ldl
SLFLAGS = $(LFLAGS) -lvga
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga
GLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lGL
NASM = nasm
......
......@@ -24,12 +24,10 @@ work the same, let the input handler do it all instead
i think its safe for now to go with the scancodes as being the "universal"
key type, and for everything not scancode-based, have a function to
translate
* when viewsize is around 20, sprites end up being drawn over the border.
maybe there are clipping bugs that will cause it to fill over the top, left,
and right (happens at any view basically, except this version of source does
not leave any artifacts after a few screen redraws)
* remove GOODTIMES (the piracy message is somewhat worthless)
* then consider removing the SOD manual check
* maybe there are sprite drawing/clipping bugs that will cause it to draw
outside the viewarea, leaving artifacts
* remove GOODTIMES?
* Consider removing the SOD manual check
* perhaps rename UPLOAD
* TOO MANY #IFDEFs
* and upload builds with lots of wl6 code anyway (sound references were just
......@@ -38,15 +36,14 @@ ifndefed out)
* add a ViewMap?
* remove the #else at the end of each header since nothing is being doubly
included now (if ever)
* especially with the video functions, there are functions/defines which
just call a different function (most are left from the update block code)
rename/remove them
* find and remove any function stubs (functions which just call another
function with same parameters, only difference is the name)
* fix wl_debug.c, lots of junk code..
* change the current parameter handling code to something like getopt
* rename goobers to debugmode, then remove debugmode for things...
* for some reason, it feels sluggish, maybe its from having mikmod playing
at the same time... especially when you pick up items
or the pallete ops calling waitvbl
at the same time... especially when you pick up items.. probably due to
calling wait vbl when doing palette stuffs
* look for places where gfx needs to be redrawn, like back to game etc
* wl_menu uses specific scancodes for names, config file will have to use
metaname like sc_Left etc or something
......@@ -54,6 +51,7 @@ metaname like sc_Left etc or something
update once per frame or such.. hm
and where is that stray pixel coming from (when using end game with largest
window size) in svgalib
no idea how to do fizzlefade in 16bit.
* change id_sd to sd_oss, sd_win, sd_dos, sd_oal, etc
idea is that different <outputs> can share some drivers, unlike video
although glx and x11 share a lot of code (i guess since gl will be a great
......@@ -65,20 +63,18 @@ PlayDemoFromFile specifically
on the border
same with the spear of destiny animation part of ending
* move all references to gfxbuf to vi_* only (gl will need this anyway,
since it deprecates: id_vh, wl_draw, wl_scale)
since it deprecates: id_vh, (parts of) wl_draw, wl_scale)
by putting in code from id_vh (either by using Plot or just copying it in)
we can stop the large conversion before each UpdateScreen
but palette fades will still need it!
* pause key
but palette fades will still need it! damnit
* what are special keys... ?
* no fizzlefade in 15-24bit
also, the higher bitrates are a hack since a palette lookup has to be done
* 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
* dga 1 and 2
* make sure none of the code tries to handle gfx/sound data directly
* GL_shared_texture_palette for opengl
* if window looses focus, should it clear the keys ?
* add DGA, clean up vi_xlib.c, fix vid mode changing
Specific:
* memory/sound intro screen goes
......
......@@ -14,6 +14,8 @@
#include <X11/keysymdef.h>
#include <X11/Xatom.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/xf86vmode.h>
#include <X11/extensions/xf86dga.h>
byte *gfxbuf = NULL;
byte *disbuf = NULL;
......@@ -28,13 +30,28 @@ Colormap cmap;
Atom wmDeleteWindow;
XShmSegmentInfo shminfo;
XF86VidModeModeInfo vidmode;
XF86VidModeModeInfo **vmmi;
XColor clr[256];
int indexmode;
int shmmode;
int fullscreen;
unsigned char mypal[768];
int main(int argc, char *argv[])
{
return WolfMain(argc, argv);
}
/*
=======================
=
= VL_Startup
=
=======================
*/
void GetVisual()
{
XVisualInfo vitemp;
......@@ -141,10 +158,27 @@ void GetVisual()
Quit("No usable visual found!");
}
int main(int argc, char *argv[])
int BPP(int d)
{
/* TODO: move these to proper functions */
switch(d) {
case 8:
return 1;
case 15:
case 16:
return 2;
case 24: /* TODO: ??? the nvidia xserver really gave me AGBR? */
/* need to check what the image says */
return 4;
case 32:
return 4;
default:
Quit("Sorry, BPP doesn't like that...");
return 0; /* heh */
}
}
void VL_Startup()
{
XSetWindowAttributes attr;
XSizeHints sizehints;
XGCValues gcvalues;
......@@ -155,7 +189,7 @@ int main(int argc, char *argv[])
char data[8] = { 0x01 };
char *disp;
int attrmask;
int attrmask, eventn, errorn, i, vmc;
disp = getenv("DISPLAY");
dpy = XOpenDisplay(disp);
......@@ -180,6 +214,29 @@ int main(int argc, char *argv[])
Quit("Unable to create window!");
}
fullscreen = 0;
if (MS_CheckParm("fullscreen") && XF86VidModeQueryExtension(dpy, &eventn, &errorn)) {
XF86VidModeGetAllModeLines(dpy, screen, &vmc, (XF86VidModeModeInfo ***)&vmmi);
printf("VidMode: eventn = %d, error = %d, vmc = %d\n", eventn, errorn, vmc);
for (i = 0; i < vmc; i++) {
if ( (vmmi[i]->hdisplay == 320) && (vmmi[i]->vdisplay == 200) ) {
//XF86VidModeGetModeLine(dpy, screen, &errorn, (XF86VidModeModeLine *)&vidmode); /* TODO: 3rd parm? */
//memcpy(&vidmode, vmmi[0], sizeof(XF86VidModeModeInfo)); /* TODO: bah, why doesn't above work? */
//printf("%d, %d, %d\n", vidmode.hdisplay, vidmode.vdisplay, errorn);
if (XF86VidModeSwitchToMode(dpy, screen, vmmi[i]) == True) {
XF86VidModeLockModeSwitch(dpy, screen, True);
printf("Using VidMode!\n");
fullscreen = 1;
break;
}
}
}
}
gcvalues.foreground = BlackPixel(dpy, screen);
gcvalues.background = WhitePixel(dpy, screen);
gc = XCreateGC(dpy, win, GCForeground | GCBackground, &gcvalues);
......@@ -192,7 +249,7 @@ int main(int argc, char *argv[])
sizehints.base_height = 200;
sizehints.flags = PMinSize | PMaxSize | PBaseSize;
XSetWMProperties(dpy, win, NULL, NULL, argv, argc, &sizehints, None, None);
XSetWMProperties(dpy, win, NULL, NULL, _argv, _argc, &sizehints, None, None);
XStoreName(dpy, win, GAMENAME);
XSetIconName(dpy, win, GAMENAME);
......@@ -203,94 +260,7 @@ int main(int argc, char *argv[])
bitmap = XCreateBitmapFromData(dpy, win, data, 8, 8);
cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0);
XDefineCursor(dpy, win, cursor);
XFlush(dpy);
return WolfMain(argc, argv);
}
void VL_WaitVBL(int vbls)
{
/* hack - but it works for me */
long last = get_TimeCount() + 1;
while (last > get_TimeCount()) ;
}
void VW_UpdateScreen()
{
word *ptrs;
byte *ptrb;
int i;
if (indexmode == 0) {
switch(vi->depth) {
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;
}
}
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);
}
/*
=======================
=
= VL_Startup
=
=======================
*/
int BPP(int d)
{
switch(d) {
case 8:
return 1;
case 15:
case 16:
return 2;
case 24: /* TODO: ??? the nvidia xserver really gave me AGBR? */
/* need to check what the image says */
return 4;
case 32:
return 4;
default:
Quit("Sorry, BPP doesn't like that...");
return 0; /* heh */
}
}
void VL_Startup()
{
shmmode = 0;
if (XShmQueryExtension(dpy) == True) {
......@@ -318,7 +288,6 @@ void VL_Startup()
}
}
}
if (img == NULL) {
printf("Falling back on XImage...\n");
......@@ -338,7 +307,14 @@ void VL_Startup()
}
}
XMapWindow(dpy, win);
if (fullscreen) {
XMoveWindow(dpy, win, 0, 0);
XRaiseWindow(dpy, win);
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
XF86VidModeSetViewPort(dpy, screen, 0, 0);
}
XFlush(dpy);
}
......@@ -350,8 +326,15 @@ void VL_Startup()
=======================
*/
void VL_Shutdown (void)
void VL_Shutdown()
{
if (fullscreen) {
XF86VidModeLockModeSwitch(dpy, screen, False);
//printf("%d, %d\n", vidmode.hdisplay, vidmode.vdisplay);
//XF86VidModeSwitchToMode(dpy, screen, &vidmode);
XF86VidModeSwitchToMode(dpy, screen, vmmi[0]);
}
if ( !shmmode && (gfxbuf != NULL) ) {
free(gfxbuf);
gfxbuf = NULL;
......@@ -373,21 +356,56 @@ void VL_Shutdown (void)
}
}
//===========================================================================
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void VL_WaitVBL(int vbls)
{
/* hack - but it works for me */
long last = get_TimeCount() + 1;
while (last > get_TimeCount()) ;
}
void VL_ClearVideo(byte color)
void VW_UpdateScreen()
{
memset(gfxbuf, color, 64000);
word *ptrs;
byte *ptrb;
int i;
if (indexmode == 0) {
switch(vi->depth) {
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;
}
}
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);
}
/*
......@@ -495,6 +513,21 @@ void VL_GetPalette(byte *palette)
=============================================================================
*/
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void VL_ClearVideo(byte color)
{
memset(gfxbuf, color, 64000);
}
/*
=================
=
......@@ -722,8 +755,6 @@ static Direction DirTable[] = // Quick lookup for total direction
dir_SouthWest, dir_South, dir_SouthEast
};
// Internal routines
int XKeysymToScancode(unsigned int keysym)
{
switch (keysym) {
......@@ -766,7 +797,6 @@ int XKeysymToScancode(unsigned int keysym)
return sc_None;
}
}
void keyboard_handler(int code, int press)
{
......
......@@ -751,7 +751,7 @@ int MS_CheckParm(char *check)
while ( !isalpha(*parm) ) // skip - / \ etc.. in front of parm
if (!*parm++)
break; // hit end of string without an alphanum
break; // hit end of string without an alphanum
if ( !strcasecmp(check,parm) )
return i;
......
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