doom

a minimalistic implementation of doom
git clone git://ssnf.xyz/doom
Log | Files | Refs

commit a6a242a3ee0286eb47cdbe5bce3d80eaa870c39f
parent 4fbdc92f7a6bcb94bd6525d8280426affa389e88
Author: ssnf <ssnf@ssnf.xyz>
Date:   Mon, 21 Jun 2021 00:45:49 +0000

make it 24-bit truecolor

Diffstat:
Msrc/d_main.c | 1-
Msrc/i_video.c | 1176++++++++++++++++++++++++++++++++-----------------------------------------------
Msrc/v_video.c | 80+------------------------------------------------------------------------------
3 files changed, 479 insertions(+), 778 deletions(-)

diff --git a/src/d_main.c b/src/d_main.c @@ -211,7 +211,6 @@ void D_DoomLoop (void) I_InitGraphics (); while (1) { - I_StartFrame (); if (singletics) { I_StartTic (); diff --git a/src/i_video.c b/src/i_video.c @@ -6,9 +6,9 @@ #include <X11/Xutil.h> #include <X11/keysym.h> #include <X11/extensions/XShm.h> -#ifdef LINUX + int XShmGetEventBase( Display* dpy ); -#endif + #include <stdarg.h> #include <sys/time.h> #include <sys/types.h> @@ -22,736 +22,516 @@ int XShmGetEventBase( Display* dpy ); #include "m_argv.h" #include "d_main.h" #include "doomdef.h" + #define POINTER_WARP_COUNTDOWN 1 -Display* X_display=0; -Window X_mainWindow; -Colormap X_cmap; -Visual* X_visual; -GC X_gc; -XEvent X_event; -int X_screen; -XVisualInfo X_visualinfo; -XImage* image; -int X_width; -int X_height; -boolean doShm; -XShmSegmentInfo X_shminfo; -int X_shmeventtype; -boolean grabMouse; -int doPointerWarp = POINTER_WARP_COUNTDOWN; -static int multiply=1; -int xlatekey(void) -{ - int rc; - switch(rc = XKeycodeToKeysym(X_display, X_event.xkey.keycode, 0)) - { - case XK_Left: rc = KEY_LEFTARROW; break; - case XK_Right: rc = KEY_RIGHTARROW; break; - case XK_Down: rc = KEY_DOWNARROW; break; - case XK_Up: rc = KEY_UPARROW; break; - case XK_Escape: rc = KEY_ESCAPE; break; - case XK_Return: rc = KEY_ENTER; break; - case XK_Tab: rc = KEY_TAB; break; - case XK_F1: rc = KEY_F1; break; - case XK_F2: rc = KEY_F2; break; - case XK_F3: rc = KEY_F3; break; - case XK_F4: rc = KEY_F4; break; - case XK_F5: rc = KEY_F5; break; - case XK_F6: rc = KEY_F6; break; - case XK_F7: rc = KEY_F7; break; - case XK_F8: rc = KEY_F8; break; - case XK_F9: rc = KEY_F9; break; - case XK_F10: rc = KEY_F10; break; - case XK_F11: rc = KEY_F11; break; - case XK_F12: rc = KEY_F12; break; - case XK_BackSpace: - case XK_Delete: rc = KEY_BACKSPACE; break; - case XK_Pause: rc = KEY_PAUSE; break; - case XK_KP_Equal: - case XK_equal: rc = KEY_EQUALS; break; - case XK_KP_Subtract: - case XK_minus: rc = KEY_MINUS; break; - case XK_Shift_L: - case XK_Shift_R: - rc = KEY_RSHIFT; - break; - case XK_Control_L: - case XK_Control_R: - rc = KEY_RCTRL; - break; - case XK_Alt_L: - case XK_Meta_L: - case XK_Alt_R: - case XK_Meta_R: - rc = KEY_RALT; - break; - default: - if (rc >= XK_space && rc <= XK_asciitilde) - rc = rc - XK_space + ' '; - if (rc >= 'A' && rc <= 'Z') - rc = rc - 'A' + 'a'; - break; - } - return rc; -} -void I_ShutdownGraphics(void) + +byte gammatable[5][256] = { + {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, + 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, + 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48, + 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64, + 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80, + 81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96, + 97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112, + 113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128, + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, + 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, + 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, + 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, + 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255}, + + {2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31, + 32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55, + 56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77, + 78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98, + 99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114, + 115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,129, + 130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145, + 146,147,148,148,149,150,151,152,153,154,155,156,157,158,159,160, + 161,162,163,163,164,165,166,167,168,169,170,171,172,173,174,175, + 175,176,177,178,179,180,181,182,183,184,185,186,186,187,188,189, + 190,191,192,193,194,195,196,196,197,198,199,200,201,202,203,204, + 205,205,206,207,208,209,210,211,212,213,214,214,215,216,217,218, + 219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232, + 233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246, + 247,248,249,250,251,252,252,253,254,255}, + + {4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42, + 43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69, + 70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93, + 94,95,96,97,98,100,101,102,103,104,105,106,107,108,109,110,111,112, + 113,114,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128, + 129,130,131,132,133,133,134,135,136,137,138,139,140,141,142,143,144, + 144,145,146,147,148,149,150,151,152,153,153,154,155,156,157,158,159, + 160,160,161,162,163,164,165,166,166,167,168,169,170,171,172,172,173, + 174,175,176,177,178,178,179,180,181,182,183,183,184,185,186,187,188, + 188,189,190,191,192,193,193,194,195,196,197,197,198,199,200,201,201, + 202,203,204,205,206,206,207,208,209,210,210,211,212,213,213,214,215, + 216,217,217,218,219,220,221,221,222,223,224,224,225,226,227,228,228, + 229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241, + 242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254, + 255}, + + {8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55, + 57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85, + 86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107, + 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124, + 125,126,127,128,129,130,131,132,133,134,135,135,136,137,138,139,140, + 141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155, + 155,156,157,158,159,160,160,161,162,163,164,165,165,166,167,168,169, + 169,170,171,172,173,173,174,175,176,176,177,178,179,180,180,181,182, + 183,183,184,185,186,186,187,188,189,189,190,191,192,192,193,194,195, + 195,196,197,197,198,199,200,200,201,202,202,203,204,205,205,206,207, + 207,208,209,210,210,211,212,212,213,214,214,215,216,216,217,218,219, + 219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230, + 231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241, + 242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252, + 253,253,254,254,255}, + + {16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76, + 78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106, + 107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124, + 125,126,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141, + 142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155, + 156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169, + 169,170,171,172,172,173,174,175,175,176,177,177,178,179,180,180,181, + 182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193, + 193,194,195,195,196,196,197,198,198,199,200,200,201,202,202,203,203, + 204,205,205,206,207,207,208,208,209,210,210,211,211,212,213,213,214, + 214,215,216,216,217,217,218,219,219,220,220,221,221,222,223,223,224, + 224,225,225,226,227,227,228,228,229,229,230,230,231,232,232,233,233, + 234,234,235,235,236,236,237,237,238,239,239,240,240,241,241,242,242, + 243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251, + 251,252,252,253,254,254,255,255} +}; + +Display* X_display = 0; +Window X_mainWindow; +Colormap X_cmap; +Visual* X_visual; +GC X_gc; +XEvent X_event; +int X_screen; +XVisualInfo X_visualinfo; +XImage* image; +int X_width; +int X_height; +boolean doShm; +XShmSegmentInfo X_shminfo; +int X_shmeventtype; +boolean grabMouse; +int doPointerWarp = POINTER_WARP_COUNTDOWN; +static int multiply = 1; + +int +xlatekey() { - if (!XShmDetach(X_display, &X_shminfo)) - I_Error("XShmDetach() failed in I_ShutdownGraphics()"); - shmdt(X_shminfo.shmaddr); - shmctl(X_shminfo.shmid, IPC_RMID, 0); - image->data = NULL; + int rc; + + switch (rc = XKeycodeToKeysym(X_display, X_event.xkey.keycode, 0)) { + case XK_Left: rc = KEY_LEFTARROW; break; + case XK_Right: rc = KEY_RIGHTARROW; break; + case XK_Down: rc = KEY_DOWNARROW; break; + case XK_Up: rc = KEY_UPARROW; break; + case XK_Escape: rc = KEY_ESCAPE; break; + case XK_Return: rc = KEY_ENTER; break; + case XK_Tab: rc = KEY_TAB; break; + case XK_F1: rc = KEY_F1; break; + case XK_F2: rc = KEY_F2; break; + case XK_F3: rc = KEY_F3; break; + case XK_F4: rc = KEY_F4; break; + case XK_F5: rc = KEY_F5; break; + case XK_F6: rc = KEY_F6; break; + case XK_F7: rc = KEY_F7; break; + case XK_F8: rc = KEY_F8; break; + case XK_F9: rc = KEY_F9; break; + case XK_F10: rc = KEY_F10; break; + case XK_F11: rc = KEY_F11; break; + case XK_F12: rc = KEY_F12; break; + case XK_BackSpace: + case XK_Delete: rc = KEY_BACKSPACE; break; + case XK_Pause: rc = KEY_PAUSE; break; + case XK_KP_Equal: + case XK_equal: rc = KEY_EQUALS; break; + case XK_KP_Subtract: + case XK_minus: rc = KEY_MINUS; break; + case XK_Shift_L: + case XK_Shift_R: rc = KEY_RSHIFT; break; + case XK_Control_L: + case XK_Control_R: rc = KEY_RCTRL; break; + case XK_Alt_L: + case XK_Meta_L: + case XK_Alt_R: + case XK_Meta_R: rc = KEY_RALT; break; + default: + if (rc >= XK_space && rc <= XK_asciitilde) + rc = rc - XK_space + 0x20; + if (rc >= 'A' && rc <= 'Z') + rc = rc - 0x41 + 0x61; + break; + } + return rc; } -void I_StartFrame (void) + +void +I_ShutdownGraphics() { + if (!XShmDetach(X_display, &X_shminfo)) + I_Error("XShmDetach() failed in I_ShutdownGraphics()"); + shmdt(X_shminfo.shmaddr); + shmctl(X_shminfo.shmid, IPC_RMID, 0); + image->data = NULL; } -static int lastmousex = 0; -static int lastmousey = 0; -boolean mousemoved = false; -boolean shmFinished; -void I_GetEvent(void) + +static int lastmousex = 0; +static int lastmousey = 0; +boolean mousemoved = false; +boolean shmFinished; + +void +I_GetEvent() { - event_t event; - XNextEvent(X_display, &X_event); - switch (X_event.type) - { - case KeyPress: - event.type = ev_keydown; - event.data1 = xlatekey(); - D_PostEvent(&event); - break; - case KeyRelease: - event.type = ev_keyup; - event.data1 = xlatekey(); - D_PostEvent(&event); - break; - case ButtonPress: - event.type = ev_mouse; - event.data1 = - (X_event.xbutton.state & Button1Mask) - | (X_event.xbutton.state & Button2Mask ? 2 : 0) - | (X_event.xbutton.state & Button3Mask ? 4 : 0) - | (X_event.xbutton.button == Button1) - | (X_event.xbutton.button == Button2 ? 2 : 0) - | (X_event.xbutton.button == Button3 ? 4 : 0); - event.data2 = event.data3 = 0; - D_PostEvent(&event); - break; - case ButtonRelease: - event.type = ev_mouse; - event.data1 = - (X_event.xbutton.state & Button1Mask) - | (X_event.xbutton.state & Button2Mask ? 2 : 0) - | (X_event.xbutton.state & Button3Mask ? 4 : 0); - event.data1 = - event.data1 - ^ (X_event.xbutton.button == Button1 ? 1 : 0) - ^ (X_event.xbutton.button == Button2 ? 2 : 0) - ^ (X_event.xbutton.button == Button3 ? 4 : 0); - event.data2 = event.data3 = 0; - D_PostEvent(&event); - break; - case MotionNotify: - event.type = ev_mouse; - event.data1 = - (X_event.xmotion.state & Button1Mask) - | (X_event.xmotion.state & Button2Mask ? 2 : 0) - | (X_event.xmotion.state & Button3Mask ? 4 : 0); - event.data2 = (X_event.xmotion.x - lastmousex) << 2; - event.data3 = (lastmousey - X_event.xmotion.y) << 2; - if (event.data2 || event.data3) - { - lastmousex = X_event.xmotion.x; - lastmousey = X_event.xmotion.y; - if (X_event.xmotion.x != X_width/2 && - X_event.xmotion.y != X_height/2) - { - D_PostEvent(&event); - mousemoved = false; - } else - { - mousemoved = true; - } + event_t event; + + XNextEvent(X_display, &X_event); + switch (X_event.type) { + case KeyPress: + event.type = ev_keydown; + event.data1 = xlatekey(); + D_PostEvent(&event); + break; + case KeyRelease: + event.type = ev_keyup; + event.data1 = xlatekey(); + D_PostEvent(&event); + break; + case ButtonPress: + event.type = ev_mouse; + event.data1 = + (X_event.xbutton.state & Button1Mask) + | (X_event.xbutton.state & Button2Mask ? 2 : 0) + | (X_event.xbutton.state & Button3Mask ? 4 : 0) + | (X_event.xbutton.button == Button1) + | (X_event.xbutton.button == Button2 ? 2 : 0) + | (X_event.xbutton.button == Button3 ? 4 : 0); + event.data2 = event.data3 = 0; + D_PostEvent(&event); + break; + case ButtonRelease: + event.type = ev_mouse; + event.data1 = + (X_event.xbutton.state & Button1Mask) + | (X_event.xbutton.state & Button2Mask ? 2 : 0) + | (X_event.xbutton.state & Button3Mask ? 4 : 0); + event.data1 = + event.data1 + ^ (X_event.xbutton.button == Button1 ? 1 : 0) + ^ (X_event.xbutton.button == Button2 ? 2 : 0) + ^ (X_event.xbutton.button == Button3 ? 4 : 0); + event.data2 = event.data3 = 0; + D_PostEvent(&event); + break; + case MotionNotify: + event.type = ev_mouse; + event.data1 = + (X_event.xmotion.state & Button1Mask) + | (X_event.xmotion.state & Button2Mask ? 2 : 0) + | (X_event.xmotion.state & Button3Mask ? 4 : 0); + event.data2 = (X_event.xmotion.x - lastmousex) << 2; + event.data3 = (lastmousey - X_event.xmotion.y) << 2; + if (event.data2 || event.data3) { + lastmousex = X_event.xmotion.x; + lastmousey = X_event.xmotion.y; + if (X_event.xmotion.x != X_width/2 && X_event.xmotion.y != X_height/2) { + D_PostEvent(&event); + mousemoved = false; + } else + mousemoved = true; + } + break; + case Expose: + case ConfigureNotify: + break; + default: + if (doShm && X_event.type == X_shmeventtype) + shmFinished = true; + break; } - break; - case Expose: - case ConfigureNotify: - break; - default: - if (doShm && X_event.type == X_shmeventtype) shmFinished = true; - break; - } } + Cursor -createnullcursor -( Display* display, - Window root ) +createnullcursor(Display* display, Window root) { - Pixmap cursormask; - XGCValues xgc; - GC gc; - XColor dummycolour; - Cursor cursor; - cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/); - xgc.function = GXclear; - gc = XCreateGC(display, cursormask, GCFunction, &xgc); - XFillRectangle(display, cursormask, gc, 0, 0, 1, 1); - dummycolour.pixel = 0; - dummycolour.red = 0; - dummycolour.flags = 04; - cursor = XCreatePixmapCursor(display, cursormask, cursormask, - &dummycolour,&dummycolour, 0,0); - XFreePixmap(display,cursormask); - XFreeGC(display,gc); - return cursor; + Pixmap cursormask; + XGCValues xgc; + GC gc; + XColor dummycolour; + Cursor cursor; + + cursormask = XCreatePixmap(display, root, 1, 1, 1); + xgc.function = GXclear; + gc = XCreateGC(display, cursormask, GCFunction, &xgc); + XFillRectangle(display, cursormask, gc, 0, 0, 1, 1); + dummycolour.pixel = 0; + dummycolour.red = 0; + dummycolour.flags = 04; + cursor = XCreatePixmapCursor(display, cursormask, cursormask, &dummycolour,&dummycolour, 0,0); + XFreePixmap(display,cursormask); + XFreeGC(display,gc); + return cursor; } -void I_StartTic (void) + +void +I_StartTic() { - if (!X_display) - return; - while (XPending(X_display)) - I_GetEvent(); - if (grabMouse) - { - if (!--doPointerWarp) - { - XWarpPointer( X_display, - None, - X_mainWindow, - 0, 0, - 0, 0, - X_width/2, X_height/2); - doPointerWarp = POINTER_WARP_COUNTDOWN; + if (!X_display) + return; + while (XPending(X_display)) + I_GetEvent(); + if (grabMouse) { + if (!--doPointerWarp) { + XWarpPointer(X_display, None, X_mainWindow, 0, 0, 0, 0, X_width/2, X_height/2); + doPointerWarp = POINTER_WARP_COUNTDOWN; + } } - } - mousemoved = false; + mousemoved = false; } -void I_UpdateNoBlit (void) + +void +I_UpdateNoBlit() { } -void I_FinishUpdate (void) + +double exptable2[256*256]; + +void +InitExpand2() { - static int lasttic; - int tics; - int i; - if (devparm) - { - i = I_GetTime(); - tics = i - lasttic; - lasttic = i; - if (tics > 20) tics = 20; - for (i=0 ; i<tics*2 ; i+=2) - screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff; - for ( ; i<20*2 ; i+=2) - screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0; - } - if (multiply == 2) - { - unsigned int *olineptrs[2]; - unsigned int *ilineptr; - int x, y, i; - unsigned int twoopixels; - unsigned int twomoreopixels; - unsigned int fouripixels; - ilineptr = (unsigned int *) (screens[0]); - for (i=0 ; i<2 ; i++) - olineptrs[i] = (unsigned int *) &image->data[i*X_width]; - y = SCREENHEIGHT; - while (y--) - { - x = SCREENWIDTH; - do - { - fouripixels = *ilineptr++; - twoopixels = (fouripixels & 0xff000000) - | ((fouripixels>>8) & 0xffff00) - | ((fouripixels>>16) & 0xff); - twomoreopixels = ((fouripixels<<16) & 0xff000000) - | ((fouripixels<<8) & 0xffff00) - | (fouripixels & 0xff); -#ifdef __BIG_ENDIAN__ - *olineptrs[0]++ = twoopixels; - *olineptrs[1]++ = twoopixels; - *olineptrs[0]++ = twomoreopixels; - *olineptrs[1]++ = twomoreopixels; -#else - *olineptrs[0]++ = twomoreopixels; - *olineptrs[1]++ = twomoreopixels; - *olineptrs[0]++ = twoopixels; - *olineptrs[1]++ = twoopixels; -#endif - } while (x-=4); - olineptrs[0] += X_width/4; - olineptrs[1] += X_width/4; - } - } - else if (multiply == 3) - { - unsigned int *olineptrs[3]; - unsigned int *ilineptr; - int x, y, i; - unsigned int fouropixels[3]; - unsigned int fouripixels; - ilineptr = (unsigned int *) (screens[0]); - for (i=0 ; i<3 ; i++) - olineptrs[i] = (unsigned int *) &image->data[i*X_width]; - y = SCREENHEIGHT; - while (y--) - { - x = SCREENWIDTH; - do - { - fouripixels = *ilineptr++; - fouropixels[0] = (fouripixels & 0xff000000) - | ((fouripixels>>8) & 0xff0000) - | ((fouripixels>>16) & 0xffff); - fouropixels[1] = ((fouripixels<<8) & 0xff000000) - | (fouripixels & 0xffff00) - | ((fouripixels>>8) & 0xff); - fouropixels[2] = ((fouripixels<<16) & 0xffff0000) - | ((fouripixels<<8) & 0xff00) - | (fouripixels & 0xff); -#ifdef __BIG_ENDIAN__ - *olineptrs[0]++ = fouropixels[0]; - *olineptrs[1]++ = fouropixels[0]; - *olineptrs[2]++ = fouropixels[0]; - *olineptrs[0]++ = fouropixels[1]; - *olineptrs[1]++ = fouropixels[1]; - *olineptrs[2]++ = fouropixels[1]; - *olineptrs[0]++ = fouropixels[2]; - *olineptrs[1]++ = fouropixels[2]; - *olineptrs[2]++ = fouropixels[2]; -#else - *olineptrs[0]++ = fouropixels[2]; - *olineptrs[1]++ = fouropixels[2]; - *olineptrs[2]++ = fouropixels[2]; - *olineptrs[0]++ = fouropixels[1]; - *olineptrs[1]++ = fouropixels[1]; - *olineptrs[2]++ = fouropixels[1]; - *olineptrs[0]++ = fouropixels[0]; - *olineptrs[1]++ = fouropixels[0]; - *olineptrs[2]++ = fouropixels[0]; -#endif - } while (x-=4); - olineptrs[0] += 2*X_width/4; - olineptrs[1] += 2*X_width/4; - olineptrs[2] += 2*X_width/4; + double* exp; + int i, j; + union { + unsigned u[2]; + double d; + } pixel; + printf("building exptable2...\n"); + exp = exptable2; + for (i = 0; i < 256; ++i) { + pixel.u[0] = i | (i << 8) | (i << 16) | (i << 24); + for (j = 0; j < 256; ++j) { + pixel.u[1] = j | (j << 8) | (j << 16) | (j << 24); + *exp++ = pixel.d; + } } - } - else if (multiply == 4) - { - void Expand4(unsigned *, double *); - Expand4 ((unsigned *)(screens[0]), (double *) (image->data)); - } - if (doShm) - { - if (!XShmPutImage( X_display, - X_mainWindow, - X_gc, - image, - 0, 0, - 0, 0, - X_width, X_height, - True )) - I_Error("XShmPutImage() failed\n"); - shmFinished = false; - do - { - I_GetEvent(); - } while (!shmFinished); - } - else - { - XPutImage( X_display, - X_mainWindow, - X_gc, - image, - 0, 0, - 0, 0, - X_width, X_height ); - XSync(X_display, False); - } -} -void I_ReadScreen (byte* scr) -{ - memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT); + printf ("done.\n"); } -static XColor colors[256]; -void UploadNewPalette(Colormap cmap, byte *palette) + +static XColor colors[256]; + +void +I_FinishUpdate() { - register int i; - register int c; - static boolean firstcall = true; -#ifdef __cplusplus - if (X_visualinfo.c_class == PseudoColor && X_visualinfo.depth == 8) -#else - if (X_visualinfo.class == PseudoColor && X_visualinfo.depth == 8) -#endif - { - if (firstcall) - { - firstcall = false; - for (i=0 ; i<256 ; i++) - { - colors[i].pixel = i; - colors[i].flags = DoRed|DoGreen|DoBlue; + XColor* color; + uchar* screen, *p; + uint x, y; + + screen = screens[0]; + p = (uchar*)image->data; + for (y = 0; y < SCREENHEIGHT * multiply; ++y) { + for (x = 0; x < SCREENWIDTH * multiply; ++x) { + color = &colors[screen[x/multiply + (y/multiply) * SCREENWIDTH]]; + *p++ = (uchar)color->blue; + *p++ = (uchar)color->green; + *p++ = (uchar)color->red; + ++p; /*alpha*/ } - } - for (i=0 ; i<256 ; i++) - { - c = gammatable[usegamma][*palette++]; - colors[i].red = (c<<8) + c; - c = gammatable[usegamma][*palette++]; - colors[i].green = (c<<8) + c; - c = gammatable[usegamma][*palette++]; - colors[i].blue = (c<<8) + c; - } - XStoreColors(X_display, cmap, colors, 256); + } + if (doShm) { + if (!XShmPutImage(X_display, X_mainWindow, X_gc, image, 0, 0, 0, 0, X_width, X_height, True)) + I_Error("XShmPutImage() failed\n"); + shmFinished = false; + for (I_GetEvent(); !shmFinished; + I_GetEvent()); + } else { + XPutImage(X_display, X_mainWindow, X_gc, image, 0, 0, 0, 0, X_width, X_height); + XSync(X_display, False); } } -void I_SetPalette (byte* palette) + +void +I_ReadScreen(byte* scr) { - UploadNewPalette(X_cmap, palette); + memcpy(scr, screens[0], SCREENWIDTH * SCREENHEIGHT); } -void grabsharedmemory(int size) + + +void +I_SetPalette(byte* palette) { - int key = ('d'<<24) | ('o'<<16) | ('o'<<8) | 'm'; - struct shmid_ds shminfo; - int minsize = 320*200; - int id; - int rc; - int pollution=5; - do - { - id = shmget((key_t) key, minsize, 0777); - if (id != -1) - { - rc=shmctl(id, IPC_STAT, &shminfo); - if (!rc) - { - if (shminfo.shm_nattch) - { - fprintf(stderr, "User %d appears to be running " - "DOOM. Is that wise?\n", shminfo.shm_cpid); - key++; - } - else - { - if (getuid() == shminfo.shm_perm.cuid) - { - rc = shmctl(id, IPC_RMID, 0); - if (!rc) - fprintf(stderr, - "Was able to kill my old shared memory\n"); - else - I_Error("Was NOT able to kill my old shared memory"); - id = shmget((key_t)key, size, IPC_CREAT|0777); - if (id==-1) - I_Error("Could not get shared memory"); - rc=shmctl(id, IPC_STAT, &shminfo); - break; - } - if (size >= shminfo.shm_segsz) - { - fprintf(stderr, - "will use %d's stale shared memory\n", - shminfo.shm_cpid); - break; - } - else - { - fprintf(stderr, - "warning: can't use stale " - "shared memory belonging to id %d, " - "key=0x%x\n", - shminfo.shm_cpid, key); - key++; - } + static boolean firstcall = true; + int i, c; + + /* + if (X_visualinfo.class == PseudoColor && X_visualinfo.depth == 8) { + */ + if (firstcall) { + firstcall = false; + for (i = 0; i < 256; ++i) { + colors[i].pixel = i; + colors[i].flags = DoRed|DoGreen|DoBlue; + } + } + for (i = 0; i < 256; ++i) { + c = gammatable[usegamma][*palette++]; + colors[i].red = (c<<8) + c; + c = gammatable[usegamma][*palette++]; + colors[i].green = (c<<8) + c; + c = gammatable[usegamma][*palette++]; + colors[i].blue = (c<<8) + c; + } + /* + XStoreColors(X_display, X_cmap, colors, 256); } - } - else - { - I_Error("could not get stats on key=%d", key); - } - } - else - { - id = shmget((key_t)key, size, IPC_CREAT|0777); - if (id==-1) - { - extern int errno; - fprintf(stderr, "errno=%d\n", errno); - I_Error("Could not get any shared memory"); - } - break; - } - } while (--pollution); - if (!pollution) - { - I_Error("Sorry, system too polluted with stale " - "shared memory segments.\n"); - } - X_shminfo.shmid = id; - image->data = X_shminfo.shmaddr = shmat(id, 0, 0); + */ +} + +void +grabsharedmemory(int size) +{ + struct shmid_ds shminfo; + int key, minsize, id, rc, pollution; + + key = ('d'<<24) | ('o'<<16) | ('o'<<8) | 'm'; + minsize = 320 * 200; + pollution = 5; + do { + id = shmget((key_t) key, minsize, 0777); + if (id != -1) { + rc = shmctl(id, IPC_STAT, &shminfo); + if (!rc) { + if (shminfo.shm_nattch) { + fprintf(stderr, "User %d appears to be running DOOM. Is that wise?\n", shminfo.shm_cpid); + ++key; + } else { + if (getuid() == shminfo.shm_perm.cuid) { + rc = shmctl(id, IPC_RMID, 0); + if (!rc) + fprintf(stderr, "Was able to kill my old shared memory\n"); + else + I_Error("Was NOT able to kill my old shared memory"); + id = shmget((key_t)key, size, IPC_CREAT|0777); + if (id == -1) + I_Error("Could not get shared memory"); + rc = shmctl(id, IPC_STAT, &shminfo); + break; + } + if (size >= shminfo.shm_segsz) { + fprintf(stderr, "will use %d's stale shared memory\n", shminfo.shm_cpid); + break; + } else { + fprintf(stderr, "warning: can't use stale shared memory belonging to id %d, key=0x%x\n", shminfo.shm_cpid, key); + ++key; + } + } + } else + I_Error("could not get stats on key=%d", key); + } else { + id = shmget((key_t)key, size, IPC_CREAT|0777); + if (id == -1) { + fprintf(stderr, "errno=%d\n", errno); + I_Error("Could not get any shared memory"); + } + break; + } + } while (--pollution); + if (!pollution) + I_Error("Sorry, system too polluted with stale shared memory segments.\n"); + X_shminfo.shmid = id; + image->data = X_shminfo.shmaddr = shmat(id, 0, 0); + fprintf(stderr, "shared memory id=%d, addr=%p\n", id, image->data); } void I_InitGraphics() { - char* displayname; - char* d; - int n; - int pnum; - int x=0; - int y=0; - char xsign=' '; - char ysign=' '; - int oktodraw; - unsigned long attribmask; - XSetWindowAttributes attribs; - XGCValues xgcvalues; - int valuemask; - static int firsttime=1; - if (!firsttime) - return; - firsttime = 0; - signal(SIGINT, (void (*)(int)) I_Quit); - if (M_CheckParm("-2")) - multiply = 2; - if (M_CheckParm("-3")) - multiply = 3; - if (M_CheckParm("-4")) - multiply = 4; - X_width = SCREENWIDTH * multiply; - X_height = SCREENHEIGHT * multiply; - if ( (pnum=M_CheckParm("-disp")) ) - displayname = myargv[pnum+1]; - else - displayname = 0; - grabMouse = !!M_CheckParm("-grabmouse"); - if ( (pnum=M_CheckParm("-geom")) ) - { - n = sscanf(myargv[pnum+1], "%c%d%c%d", &xsign, &x, &ysign, &y); - if (n==2) - x = y = 0; - else if (n==6) - { - if (xsign == '-') - x = -x; - if (ysign == '-') - y = -y; - } - else - I_Error("bad -geom parameter"); - } - X_display = XOpenDisplay(displayname); - if (!X_display) - { - if (displayname) - I_Error("Could not open display [%s]", displayname); + XSetWindowAttributes attribs; + XGCValues xgcvalues; + char *displayname, *d; + ulong attribmask; + int pnum, oktodraw, valuemask; + + signal(SIGINT, (void(*)(int))I_Quit); + if (M_CheckParm("-2")) + multiply = 2; + if (M_CheckParm("-3")) + multiply = 3; + if (M_CheckParm("-4")) + multiply = 4; + X_width = SCREENWIDTH * multiply; + X_height = SCREENHEIGHT * multiply; + if ((pnum = M_CheckParm("-disp"))) + displayname = myargv[pnum+1]; else - I_Error("Could not open display (DISPLAY=[%s])", getenv("DISPLAY")); - } - X_screen = DefaultScreen(X_display); - if (!XMatchVisualInfo(X_display, X_screen, 8, PseudoColor, &X_visualinfo)) - I_Error("xdoom currently only supports 256-color PseudoColor screens"); - X_visual = X_visualinfo.visual; - doShm = XShmQueryExtension(X_display); - if (doShm) - { - if (!displayname) displayname = (char *) getenv("DISPLAY"); - if (displayname) - { - d = displayname; - while (*d && (*d != ':')) d++; - if (*d) *d = 0; - if (!(!strcasecmp(displayname, "unix") || !*displayname)) doShm = false; + displayname = 0; + grabMouse = !!M_CheckParm("-grabmouse"); + X_display = XOpenDisplay(displayname); + if (!X_display) { + if (displayname) + I_Error("Could not open display [%s]", displayname); + else + I_Error("Could not open display (DISPLAY=[%s])", getenv("DISPLAY")); } - } - fprintf(stderr, "Using MITSHM extension\n"); - X_cmap = XCreateColormap(X_display, RootWindow(X_display, - X_screen), X_visual, AllocAll); - attribmask = CWEventMask | CWColormap | CWBorderPixel; - attribs.event_mask = - KeyPressMask - | KeyReleaseMask - | ExposureMask; - attribs.colormap = X_cmap; - attribs.border_pixel = 0; - X_mainWindow = XCreateWindow( X_display, - RootWindow(X_display, X_screen), - x, y, - X_width, X_height, - 0, - 8, - InputOutput, - X_visual, - attribmask, - &attribs ); - XDefineCursor(X_display, X_mainWindow, - createnullcursor( X_display, X_mainWindow ) ); - valuemask = GCGraphicsExposures; - xgcvalues.graphics_exposures = False; - X_gc = XCreateGC( X_display, - X_mainWindow, - valuemask, - &xgcvalues ); - XMapWindow(X_display, X_mainWindow); - oktodraw = 0; - while (!oktodraw) - { - XNextEvent(X_display, &X_event); - if (X_event.type == Expose - && !X_event.xexpose.count) - { - oktodraw = 1; + X_screen = DefaultScreen(X_display); + if (!XMatchVisualInfo(X_display, X_screen, 24, TrueColor, &X_visualinfo)) + I_Error("xdoom currently only supports 256-color PseudoColor screens"); + X_visual = X_visualinfo.visual; + doShm = XShmQueryExtension(X_display); + if (doShm) { + if (!displayname) + displayname = (char*)getenv("DISPLAY"); + if (displayname) { + d = displayname; + while (*d && (*d != ':')) + ++d; + if (*d) + *d = 0; + if (!(!strcasecmp(displayname, "unix") || !*displayname)) + doShm = false; + } } - } - if (grabMouse) - XGrabPointer(X_display, X_mainWindow, True, - ButtonPressMask|ButtonReleaseMask|PointerMotionMask, - GrabModeAsync, GrabModeAsync, - X_mainWindow, None, CurrentTime); - if (doShm) - { - X_shmeventtype = XShmGetEventBase(X_display) + ShmCompletion; - image = XShmCreateImage( X_display, - X_visual, - 8, - ZPixmap, - 0, - &X_shminfo, - X_width, - X_height ); - grabsharedmemory(image->bytes_per_line * image->height); - if (!image->data) - { - perror(""); - I_Error("shmat() failed in InitGraphics()"); + fprintf(stderr, "Using MITSHM extension\n"); + X_cmap = XCreateColormap(X_display, RootWindow(X_display, X_screen), X_visual, AllocNone); + attribmask = CWEventMask | CWColormap | CWBorderPixel; + attribs.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask; + attribs.colormap = X_cmap; + attribs.border_pixel = 0; + X_mainWindow = XCreateWindow(X_display, RootWindow(X_display, X_screen), 0, 0, X_width, X_height, 0, 24, InputOutput, X_visual, attribmask, &attribs); + XDefineCursor(X_display, X_mainWindow, createnullcursor(X_display, X_mainWindow)); + valuemask = GCGraphicsExposures; + xgcvalues.graphics_exposures = False; + X_gc = XCreateGC(X_display, X_mainWindow, valuemask, &xgcvalues); + XMapWindow(X_display, X_mainWindow); + oktodraw = 0; + while (!oktodraw) { + XNextEvent(X_display, &X_event); + if (X_event.type == Expose && !X_event.xexpose.count) + oktodraw = 1; } - if (!XShmAttach(X_display, &X_shminfo)) - I_Error("XShmAttach() failed in InitGraphics()"); - } - else - { - image = XCreateImage( X_display, - X_visual, - 8, - ZPixmap, - 0, - (char*)malloc(X_width * X_height), - X_width, X_height, - 8, - X_width ); - } - if (multiply == 1) - screens[0] = (unsigned char *) (image->data); - else - screens[0] = (unsigned char *) malloc (SCREENWIDTH * SCREENHEIGHT); -} -unsigned exptable[256]; -void InitExpand (void) -{ - int i; - for (i=0 ; i<256 ; i++) - exptable[i] = i | (i<<8) | (i<<16) | (i<<24); -} -double exptable2[256*256]; -void InitExpand2 (void) -{ - int i; - int j; - double* exp; - union - { - double d; - unsigned u[2]; - } pixel; - printf ("building exptable2...\n"); - exp = exptable2; - for (i=0 ; i<256 ; i++) - { - pixel.u[0] = i | (i<<8) | (i<<16) | (i<<24); - for (j=0 ; j<256 ; j++) - { - pixel.u[1] = j | (j<<8) | (j<<16) | (j<<24); - *exp++ = pixel.d; - } - } - printf ("done.\n"); -} -int inited; -void -Expand4 -( unsigned* lineptr, - double* xline ) -{ - double dpixel; - unsigned x; - unsigned y; - unsigned fourpixels; - unsigned step; - double* exp; - exp = exptable2; - if (!inited) - { - inited = 1; - InitExpand2 (); - } - step = 3*SCREENWIDTH/2; - y = SCREENHEIGHT-1; - do - { - x = SCREENWIDTH; - do - { - fourpixels = lineptr[0]; - dpixel = *(double*)((long)exp + ( (fourpixels&0xffff0000)>>13) ); - xline[0] = dpixel; - xline[160] = dpixel; - xline[320] = dpixel; - xline[480] = dpixel; - dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) ); - xline[1] = dpixel; - xline[161] = dpixel; - xline[321] = dpixel; - xline[481] = dpixel; - fourpixels = lineptr[1]; - dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff0000)>>13) ); - xline[2] = dpixel; - xline[162] = dpixel; - xline[322] = dpixel; - xline[482] = dpixel; - dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) ); - xline[3] = dpixel; - xline[163] = dpixel; - xline[323] = dpixel; - xline[483] = dpixel; - fourpixels = lineptr[2]; - dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff0000)>>13) ); - xline[4] = dpixel; - xline[164] = dpixel; - xline[324] = dpixel; - xline[484] = dpixel; - dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) ); - xline[5] = dpixel; - xline[165] = dpixel; - xline[325] = dpixel; - xline[485] = dpixel; - fourpixels = lineptr[3]; - dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff0000)>>13) ); - xline[6] = dpixel; - xline[166] = dpixel; - xline[326] = dpixel; - xline[486] = dpixel; - dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) ); - xline[7] = dpixel; - xline[167] = dpixel; - xline[327] = dpixel; - xline[487] = dpixel; - lineptr+=4; - xline+=8; - } while (x-=16); - xline += step; - } while (y--); + if (grabMouse) + XGrabPointer(X_display, X_mainWindow, True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, X_mainWindow, None, CurrentTime); + if (doShm) { + X_shmeventtype = XShmGetEventBase(X_display) + ShmCompletion; + image = XShmCreateImage(X_display, X_visual, 24, ZPixmap, 0, &X_shminfo, X_width, X_height); + grabsharedmemory(image->bytes_per_line * image->height); + if (!image->data) { + perror(""); + I_Error("shmat() failed in InitGraphics()"); + } + if (!XShmAttach(X_display, &X_shminfo)) + I_Error("XShmAttach() failed in InitGraphics()"); + } else + image = XCreateImage(X_display, X_visual, 24, ZPixmap, 0, (char*)malloc(4 * X_width * X_height), X_width, X_height, 8, X_width); + screens[0] = (uchar*)malloc(SCREENWIDTH * SCREENHEIGHT); } diff --git a/src/v_video.c b/src/v_video.c @@ -7,86 +7,8 @@ #include "v_video.h" byte* screens[5]; int dirtybox[4]; -byte gammatable[5][256] = -{ - {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, - 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, - 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48, - 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64, - 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80, - 81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96, - 97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112, - 113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128, - 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, - 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, - 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, - 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, - 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, - 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255}, - {2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31, - 32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55, - 56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77, - 78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98, - 99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114, - 115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,129, - 130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145, - 146,147,148,148,149,150,151,152,153,154,155,156,157,158,159,160, - 161,162,163,163,164,165,166,167,168,169,170,171,172,173,174,175, - 175,176,177,178,179,180,181,182,183,184,185,186,186,187,188,189, - 190,191,192,193,194,195,196,196,197,198,199,200,201,202,203,204, - 205,205,206,207,208,209,210,211,212,213,214,214,215,216,217,218, - 219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232, - 233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246, - 247,248,249,250,251,252,252,253,254,255}, - {4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42, - 43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69, - 70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93, - 94,95,96,97,98,100,101,102,103,104,105,106,107,108,109,110,111,112, - 113,114,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128, - 129,130,131,132,133,133,134,135,136,137,138,139,140,141,142,143,144, - 144,145,146,147,148,149,150,151,152,153,153,154,155,156,157,158,159, - 160,160,161,162,163,164,165,166,166,167,168,169,170,171,172,172,173, - 174,175,176,177,178,178,179,180,181,182,183,183,184,185,186,187,188, - 188,189,190,191,192,193,193,194,195,196,197,197,198,199,200,201,201, - 202,203,204,205,206,206,207,208,209,210,210,211,212,213,213,214,215, - 216,217,217,218,219,220,221,221,222,223,224,224,225,226,227,228,228, - 229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241, - 242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254, - 255}, - {8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55, - 57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85, - 86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107, - 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124, - 125,126,127,128,129,130,131,132,133,134,135,135,136,137,138,139,140, - 141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155, - 155,156,157,158,159,160,160,161,162,163,164,165,165,166,167,168,169, - 169,170,171,172,173,173,174,175,176,176,177,178,179,180,180,181,182, - 183,183,184,185,186,186,187,188,189,189,190,191,192,192,193,194,195, - 195,196,197,197,198,199,200,200,201,202,202,203,204,205,205,206,207, - 207,208,209,210,210,211,212,212,213,214,214,215,216,216,217,218,219, - 219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230, - 231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241, - 242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252, - 253,253,254,254,255}, - {16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76, - 78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106, - 107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124, - 125,126,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141, - 142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155, - 156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169, - 169,170,171,172,172,173,174,175,175,176,177,177,178,179,180,180,181, - 182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193, - 193,194,195,195,196,196,197,198,198,199,200,200,201,202,202,203,203, - 204,205,205,206,207,207,208,208,209,210,210,211,211,212,213,213,214, - 214,215,216,216,217,217,218,219,219,220,220,221,221,222,223,223,224, - 224,225,225,226,227,227,228,228,229,229,230,230,231,232,232,233,233, - 234,234,235,235,236,236,237,237,238,239,239,240,240,241,241,242,242, - 243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251, - 251,252,252,253,254,254,255,255} -}; int usegamma; + void V_MarkRect ( int x,