From e74dfd3cb7ebc00b89fa4dee2c1f4528ed270664 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 24 Jul 2005 02:14:04 +0000 Subject: Move to SDL for graphics. Translate key scancodes to correct internal format when reading settings from config file - backwards compatible with config files for original exes Subversion-branch: /trunk/chocolate-doom Subversion-revision: 26 --- src/i_video.c | 794 +++++++++++++--------------------------------------------- 1 file changed, 180 insertions(+), 614 deletions(-) (limited to 'src/i_video.c') diff --git a/src/i_video.c b/src/i_video.c index 29eac891..50357883 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_video.c 23 2005-07-23 21:32:47Z fraggle $ +// $Id: i_video.c 26 2005-07-24 02:14:04Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,12 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.6 2005/07/24 02:14:04 fraggle +// Move to SDL for graphics. +// Translate key scancodes to correct internal format when reading +// settings from config file - backwards compatible with config files +// for original exes +// // Revision 1.5 2005/07/23 21:32:47 fraggle // Add missing errno.h, fix crash on startup when no IWAD present // @@ -44,27 +50,10 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_video.c 23 2005-07-23 21:32:47Z fraggle $"; - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include +rcsid[] = "$Id: i_video.c 26 2005-07-24 02:14:04Z fraggle $"; -#include -#include +#include +#include #include "doomstat.h" #include "i_system.h" @@ -74,25 +63,9 @@ rcsid[] = "$Id: i_video.c 23 2005-07-23 21:32:47Z fraggle $"; #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; +SDL_Surface *screen; -// MIT SHared Memory extension. -boolean doShm; - -XShmSegmentInfo X_shminfo; -int X_shmeventtype; +#define POINTER_WARP_COUNTDOWN 1 // Fake mouse handling. // This cannot work properly w/o DGA. @@ -106,92 +79,92 @@ int doPointerWarp = POINTER_WARP_COUNTDOWN; // to use .... static int multiply=1; - // -// Translates the key currently in X_event +// Translates the SDL key // -int xlatekey(void) +int xlatekey(SDL_keysym *sym) { - int rc; - switch(rc = XKeycodeToKeysym(X_display, X_event.xkey.keycode, 0)) + switch(sym->sym) { - 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 SDLK_LEFT: return KEY_LEFTARROW; + case SDLK_RIGHT: return KEY_RIGHTARROW; + case SDLK_DOWN: return KEY_DOWNARROW; + case SDLK_UP: return KEY_UPARROW; + case SDLK_ESCAPE: return KEY_ESCAPE; + case SDLK_RETURN: return KEY_ENTER; + case SDLK_TAB: return KEY_TAB; + case SDLK_F1: return KEY_F1; + case SDLK_F2: return KEY_F2; + case SDLK_F3: return KEY_F3; + case SDLK_F4: return KEY_F4; + case SDLK_F5: return KEY_F5; + case SDLK_F6: return KEY_F6; + case SDLK_F7: return KEY_F7; + case SDLK_F8: return KEY_F8; + case SDLK_F9: return KEY_F9; + case SDLK_F10: return KEY_F10; + case SDLK_F11: return KEY_F11; + case SDLK_F12: return KEY_F12; - case XK_BackSpace: - case XK_Delete: rc = KEY_BACKSPACE; break; + case SDLK_BACKSPACE: return KEY_BACKSPACE; + case SDLK_DELETE: return KEY_DEL; - case XK_Pause: rc = KEY_PAUSE; break; + case SDLK_PAUSE: return KEY_PAUSE; - case XK_KP_Equal: - case XK_equal: rc = KEY_EQUALS; break; + case SDLK_EQUALS: + case SDLK_KP_EQUALS: return KEY_EQUALS; - case XK_KP_Subtract: - case XK_minus: rc = KEY_MINUS; break; + case SDLK_MINUS: return KEY_MINUS; - case XK_Shift_L: - case XK_Shift_R: - rc = KEY_RSHIFT; - break; + case SDLK_LSHIFT: + case SDLK_RSHIFT: + return KEY_RSHIFT; - 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; + case SDLK_LCTRL: + case SDLK_RCTRL: + return KEY_RCTRL; + case SDLK_LALT: + case SDLK_LMETA: + case SDLK_RALT: + case SDLK_RMETA: + return KEY_RALT; + + case SDLK_CAPSLOCK: return KEY_CAPSLOCK; + case SDLK_SCROLLOCK: return KEY_SCRLCK; + + case SDLK_KP0: return KEYP_0; + case SDLK_KP1: return KEYP_1; + case SDLK_KP2: return KEYP_2; + case SDLK_KP3: return KEYP_3; + case SDLK_KP4: return KEYP_4; + case SDLK_KP5: return KEYP_5; + case SDLK_KP6: return KEYP_6; + case SDLK_KP7: return KEYP_7; + case SDLK_KP8: return KEYP_8; + case SDLK_KP9: return KEYP_9; + + case SDLK_HOME: return KEY_HOME; + case SDLK_INSERT: return KEY_INS; + case SDLK_END: return KEY_END; + case SDLK_PAGEUP: return KEY_PGUP; + case SDLK_PAGEDOWN: return KEY_PGDN; + case SDLK_KP_MULTIPLY: return KEYP_MULTIPLY; + case SDLK_KP_PLUS: return KEYP_PLUS; + case SDLK_KP_MINUS: return KEYP_MINUS; + case SDLK_KP_DIVIDE: return KEYP_DIVIDE; + default: - if (rc >= XK_space && rc <= XK_asciitilde) - rc = rc - XK_space + ' '; - if (rc >= 'A' && rc <= 'Z') - rc = rc - 'A' + 'a'; - break; + return tolower(sym->unicode); } - - return rc; - } void I_ShutdownGraphics(void) { - // Detach from X server - if (X_display && !XShmDetach(X_display, &X_shminfo)) - I_Error("XShmDetach() failed in I_ShutdownGraphics()"); - - // Release shared memory. - shmdt(X_shminfo.shmaddr); - shmctl(X_shminfo.shmid, IPC_RMID, 0); - - // Paranoia. - if (image) { - image->data = NULL; - } + SDL_QuitSubSystem(SDL_INIT_VIDEO); } @@ -208,125 +181,102 @@ void I_StartFrame (void) static int lastmousex = 0; static int lastmousey = 0; boolean mousemoved = false; -boolean shmFinished; void I_GetEvent(void) { - + SDL_Event sdlevent; event_t event; // put event-grabbing stuff in here - XNextEvent(X_display, &X_event); - switch (X_event.type) + + while (SDL_PollEvent(&sdlevent)) { - case KeyPress: - event.type = ev_keydown; - event.data1 = xlatekey(); - D_PostEvent(&event); - // fprintf(stderr, "k"); - break; - case KeyRelease: - event.type = ev_keyup; - event.data1 = xlatekey(); - D_PostEvent(&event); - // fprintf(stderr, "ku"); - 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); - // fprintf(stderr, "b"); - 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); - // suggest parentheses around arithmetic in operand of | - 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); - // fprintf(stderr, "bu"); - 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); - // fprintf(stderr, "m"); - mousemoved = false; - } else - { - mousemoved = true; - } - } - break; - - case Expose: - case ConfigureNotify: - break; - - default: - if (doShm && X_event.type == X_shmeventtype) shmFinished = true; - break; + switch (sdlevent.type) + { + case SDL_KEYDOWN: + event.type = ev_keydown; + event.data1 = xlatekey(&sdlevent.key.keysym); + D_PostEvent(&event); + break; + case SDL_KEYUP: + event.type = ev_keyup; + event.data1 = xlatekey(&sdlevent.key.keysym); + D_PostEvent(&event); + break; +#if 0 + 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); + // fprintf(stderr, "b"); + 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); + // suggest parentheses around arithmetic in operand of | + 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); + // fprintf(stderr, "bu"); + 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); + // fprintf(stderr, "m"); + mousemoved = false; + } else + { + mousemoved = true; + } + } + break; + + case Expose: + case ConfigureNotify: + break; + + default: + if (doShm && X_event.type == X_shmeventtype) shmFinished = true; + break; +#endif + } } - -} - -Cursor -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; } - // // I_StartTic // void I_StartTic (void) { + I_GetEvent(); +#if 0 if (!X_display) return; @@ -353,7 +303,7 @@ void I_StartTic (void) } mousemoved = false; - +#endif } @@ -391,7 +341,7 @@ void I_FinishUpdate (void) screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0; } - +#if 0 // scales the screen size before blitting it if (multiply == 2) { @@ -498,45 +448,11 @@ void I_FinishUpdate (void) void Expand4(unsigned *, double *); Expand4 ((unsigned *)(screens[0]), (double *) (image->data)); } +#endif - 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"); - - // wait for it to finish and processes all input events - shmFinished = false; - do - { - I_GetEvent(); - } while (!shmFinished); - - } - else - { - - // draw the image - XPutImage( X_display, - X_mainWindow, - X_gc, - image, - 0, 0, - 0, 0, - X_width, X_height ); - - // sync up with server - XSync(X_display, False); - - } - + // draw to screen + + SDL_UpdateRect(screen, 0, 0, screen->w, screen->h); } @@ -549,388 +465,38 @@ void I_ReadScreen (byte* scr) } -// -// Palette stuff. -// -static XColor colors[256]; - -void UploadNewPalette(Colormap cmap, byte *palette) -{ - - 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 - { - // initialize the colormap - if (firstcall) - { - firstcall = false; - for (i=0 ; i<256 ; i++) - { - colors[i].pixel = i; - colors[i].flags = DoRed|DoGreen|DoBlue; - } - } - - // set the X colormap entries - 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; - } - - // store the colors to the current colormap - XStoreColors(X_display, cmap, colors, 256); - - } -} - // // I_SetPalette // void I_SetPalette (byte* palette) { - UploadNewPalette(X_cmap, palette); -} + SDL_Color sdl_palette[256]; + int i; - -// -// This function is probably redundant, -// if XShmDetach works properly. -// ddt never detached the XShm memory, -// thus there might have been stale -// handles accumulating. -// -void grabsharedmemory(int size) -{ - - int key = ('d'<<24) | ('o'<<16) | ('o'<<8) | 'm'; - struct shmid_ds shminfo; - int minsize = 320*200; - int id; - int rc; - // UNUSED int done=0; - int pollution=5; - - // try to use what was here before - do - { - id = shmget((key_t) key, minsize, 0777); // just get the id - if (id != -1) - { - rc=shmctl(id, IPC_STAT, &shminfo); // get stats on it - 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) - { - 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; - - // attach to the shared memory segment - image->data = X_shminfo.shmaddr = shmat(id, 0, 0); - - fprintf(stderr, "shared memory id=%d, addr=0x%x\n", id, - (int) (image->data)); -} - -void I_InitGraphics(void) -{ - - char* displayname; - char* d; - int n; - int pnum; - int x=0; - int y=0; - - // warning: char format, different type arg - 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; - - // check for command-line display name - if ( (pnum=M_CheckParm("-disp")) ) // suggest parentheses around assignment - displayname = myargv[pnum+1]; - else - displayname = 0; - - // check if the user wants to grab the mouse (quite unnice) - grabMouse = !!M_CheckParm("-grabmouse"); - - // check for command-line geometry - if ( (pnum=M_CheckParm("-geom")) ) // suggest parentheses around assignment - { - // warning: char format, different type arg 3,5 - 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"); - } - - // open the display - 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")); - } - - // use the default visual - 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; - - // check for the MITSHM extension - doShm = XShmQueryExtension(X_display); - - // even if it's available, make sure it's a local connection - 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; - } - } - - fprintf(stderr, "Using MITSHM extension\n"); - - // create the colormap - X_cmap = XCreateColormap(X_display, RootWindow(X_display, - X_screen), X_visual, AllocAll); - - // setup attributes for main window - attribmask = CWEventMask | CWColormap | CWBorderPixel; - attribs.event_mask = - KeyPressMask - | KeyReleaseMask - // | PointerMotionMask | ButtonPressMask | ButtonReleaseMask - | ExposureMask; - - attribs.colormap = X_cmap; - attribs.border_pixel = 0; - - // create the main window - X_mainWindow = XCreateWindow( X_display, - RootWindow(X_display, X_screen), - x, y, - X_width, X_height, - 0, // borderwidth - 8, // depth - InputOutput, - X_visual, - attribmask, - &attribs ); - - XDefineCursor(X_display, X_mainWindow, - createnullcursor( X_display, X_mainWindow ) ); - - // create the GC - valuemask = GCGraphicsExposures; - xgcvalues.graphics_exposures = False; - X_gc = XCreateGC( X_display, - X_mainWindow, - valuemask, - &xgcvalues ); - - // map the window - XMapWindow(X_display, X_mainWindow); - - // wait until it is OK to draw - oktodraw = 0; - while (!oktodraw) + for (i=0; i<256; ++i) { - XNextEvent(X_display, &X_event); - if (X_event.type == Expose - && !X_event.xexpose.count) - { - oktodraw = 1; - } + sdl_palette[i].r = *palette++; + sdl_palette[i].g = *palette++; + sdl_palette[i].b = *palette++; } - // grabs the pointer so it is restricted to this window - 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; - - // create the image - image = XShmCreateImage( X_display, - X_visual, - 8, - ZPixmap, - 0, - &X_shminfo, - X_width, - X_height ); - - grabsharedmemory(image->bytes_per_line * image->height); - - - // UNUSED - // create the shared memory segment - // X_shminfo.shmid = shmget (IPC_PRIVATE, - // image->bytes_per_line * image->height, IPC_CREAT | 0777); - // if (X_shminfo.shmid < 0) - // { - // perror(""); - // I_Error("shmget() failed in InitGraphics()"); - // } - // fprintf(stderr, "shared memory id=%d\n", X_shminfo.shmid); - // attach to the shared memory segment - // image->data = X_shminfo.shmaddr = shmat(X_shminfo.shmid, 0, 0); - + SDL_SetColors(screen, sdl_palette, 0, 256); +} - if (!image->data) - { - perror(""); - I_Error("shmat() failed in InitGraphics()"); - } - // get the X server to attach to it - 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 ); +void I_InitGraphics(void) +{ + SDL_Init(SDL_INIT_VIDEO); - } + screen = SDL_SetVideoMode(SCREENWIDTH, SCREENHEIGHT, 8, 0); if (multiply == 1) - screens[0] = (unsigned char *) (image->data); + screens[0] = (unsigned char *) (screen->pixels); else screens[0] = (unsigned char *) malloc (SCREENWIDTH * SCREENHEIGHT); + SDL_EnableUNICODE(1); } -- cgit v1.2.3