--- uae/src/xwin.c 2018/04/24 16:38:39 1.1 +++ uae/src/xwin.c 2018/04/24 16:39:54 1.1.1.3 @@ -1,10 +1,11 @@ - /* + /* * UAE - The Un*x Amiga Emulator - * + * * X interface - * + * * Copyright 1995, 1996 Bernd Schmidt * Copyright 1996 Ed Hanway, Andre Beck, Samuel Devulder, Bruno Coste + * DGA support by Kai Kollmorgen */ #include "sysconfig.h" @@ -15,25 +16,59 @@ #include #include -#ifndef DONT_WANT_SHM -#include -#include -#include -#endif - #include #include #include "config.h" #include "options.h" +#include "threaddep/penguin.h" +#include "uae.h" #include "memory.h" #include "custom.h" +#include "readcpu.h" #include "newcpu.h" #include "xwin.h" #include "keyboard.h" #include "keybuf.h" #include "gui.h" #include "debug.h" +#include "picasso96.h" + +#ifdef __cplusplus +#define VI_CLASS c_class +#else +#define VI_CLASS class +#endif + +#ifdef USE_DGA_EXTENSION + +#ifdef USE_VIDMODE_EXTENSION +#include +#define VidMode_MINMAJOR 0 +#define VidMode_MINMINOR 0 +#endif + +#include +#define DGA_MINMAJOR 0 +#define DGA_MINMINOR 0 + +#elif SHM_SUPPORT_LINKS == 1 + +#include +#include +#include + +#define DO_PUTIMAGE(IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT) \ + do { \ + if (currprefs.use_mitshm) \ + XShmPutImage (display, mywin, blackgc, IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT, 0); \ + else \ + XPutImage (display, mywin, blackgc, IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT); \ + } while (0) +#else +#define DO_PUTIMAGE(IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT) \ + XPutImage (display, mywin, blackgc, IMG, SRCX, SRCY, DSTX, DSTY, WIDTH, HEIGHT) +#endif #ifdef __cplusplus static RETSIGTYPE sigbrkhandler(...) @@ -61,183 +96,292 @@ void setup_brkhandler(void) sigaction(SIGINT, &sa, NULL); #else signal(SIGINT, sigbrkhandler); -#endif +#endif } static Display *display; static int screen; static Window rootwin, mywin; -static GC whitegc,blackgc; +static GC whitegc,blackgc,picassogc; static XColor black,white; -static Colormap cmap; +static Colormap cmap, cmap2; + +/* Kludge-O-Matic */ +static int dga_colormap_installed; static int need_dither; +static int screen_is_picasso; +static char picasso_invalid_lines[1201]; + static int autorepeatoff = 0; static char *image_mem; -static XImage *img; +static XImage *img, *picasso_img; static Visual *vis; static XVisualInfo visualInfo; static int bitdepth, bit_unit; -#ifndef DONT_WANT_SHM -static int use_shm = 1; -static XShmSegmentInfo shminfo; -#endif static Cursor blankCursor, xhairCursor; static int cursorOn; +static int inverse_byte_order = 0; -#ifdef LOW_BANDWIDTH -static int use_low_bandwidth = 1; -#else -static int use_low_bandwidth = 0; -#endif +static int current_width, current_height; -xcolnr xcolors[4096]; +static int x11_init_ok; /* Keyboard and mouse */ static int keystate[256]; -int buttonstate[3]; -int lastmx, lastmy; -int newmousecounters; - static int inwindow; const long int eventmask = (KeyPressMask|KeyReleaseMask|ButtonPressMask |ButtonReleaseMask|PointerMotionMask +#ifndef USE_DGA_EXTENSION |FocusChangeMask|EnterWindowMask |ExposureMask - |LeaveWindowMask); + |LeaveWindowMask +#endif + ); -static int vsize, hsize, hpixels; -static char *oldpixbuf; +static XImage *get_image (int w, int h, char **mem_p) +{ + XImage *new_img; + char *p; + +#if SHM_SUPPORT_LINKS == 1 + if (currprefs.use_mitshm) { + XShmSegmentInfo *shminfo = xmalloc (sizeof (XShmSegmentInfo)); + + printf ("Using MIT-SHM extension.\n"); + new_img = XShmCreateImage (display, vis, bitdepth, ZPixmap, 0, shminfo, w, h); + + shminfo->shmid = shmget (IPC_PRIVATE, h * new_img->bytes_per_line, + IPC_CREAT | 0777); + shminfo->shmaddr = new_img->data = (char *)shmat (shminfo->shmid, 0, 0); + if (mem_p != 0) + *mem_p = new_img->data; + shminfo->readOnly = False; + /* let the xserver attach */ + XShmAttach (display, shminfo); + XSync (display,0); + /* now deleting means making it temporary */ + shmctl (shminfo->shmid, IPC_RMID, 0); + return new_img; + } +#endif + + /* Question for people who know about X: Could we allocate the buffer + * after creating the image and then do new_img->data = buffer, as above in + * the SHM case? + */ + printf ("Using normal image buffer.\n"); + p = (char *)xmalloc (h * w * ((bit_unit + 7) / 8)); /* ??? */ + if (mem_p != 0) + *mem_p = p; + new_img = XCreateImage (display, vis, bitdepth, ZPixmap, 0, p, + w, h, 32, 0); + if (new_img->bytes_per_line != w * ((bit_unit + 7) / 8)) + fprintf (stderr, "Possible bug here... graphics may look strange.\n"); + + return new_img; +} -struct vidbuf_description gfxvidinfo; +#ifdef USE_DGA_EXTENSION + +static int fb_bank, fb_banks, fb_mem; +static char *fb_addr; +static int fb_width; + +static void switch_to_dga_mode (void) +{ + XF86DGADirectVideo(display, screen, XF86DGADirectGraphics | XF86DGADirectMouse | XF86DGADirectKeyb); + XF86DGASetViewPort (display, screen, 0, 0); + memset (fb_addr, 0, fb_mem * 1024); +} + + +#ifdef USE_VIDMODE_EXTENSION +static XF86VidModeModeInfo **allmodes; +static int vidmodecount; + +static int get_vidmodes (void) +{ + return XF86VidModeGetAllModeLines (display, screen, &vidmodecount, &allmodes); +} + +static void switch_to_best_mode (void) +{ + int i, best; + best = 0; + for (i = 1; i < vidmodecount; i++) { + if (allmodes[i]->hdisplay >= current_width + && allmodes[i]->vdisplay >= current_height + && allmodes[i]->hdisplay <= allmodes[best]->hdisplay + && allmodes[i]->vdisplay <= allmodes[best]->vdisplay) + best = i; + } + printf ("entering DGA mode: %dx%d (%d, %d)\n", + allmodes[best]->hdisplay, allmodes[best]->vdisplay, + current_width, current_height); + XF86VidModeSwitchToMode (display, screen, allmodes[best]); + XF86VidModeSetViewPort (display, screen, 0, 0); + XMoveWindow (display, mywin, 0, 0); + XWarpPointer (display, None, rootwin, 0, 0, 0, 0, 0, 0); + switch_to_dga_mode (); +} +#else + +#endif + +static void enter_dga_mode (void) +{ + Screen *scr = ScreenOfDisplay (display, screen); + int w = WidthOfScreen (scr); + int h = HeightOfScreen (scr); + + XRaiseWindow (display, mywin); + + /* We want all the key presses */ + XGrabKeyboard (display, rootwin, 1, GrabModeAsync, + GrabModeAsync, CurrentTime); + + /* and all the mouse moves */ + XGrabPointer (display, rootwin, 1, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, None, CurrentTime); + + XF86DGAGetVideo (display, screen, &fb_addr, &fb_width, &fb_bank, &fb_mem); + fprintf (stderr, "addr:%X, width %d, bank size %d mem size %d\n", + fb_addr, fb_width, fb_bank,fb_mem); + + if (fb_bank < fb_mem) + fprintf (stderr, "banksize < memsize, must use XF86DGASetVidPage !\n"); + + switch_to_best_mode (); + + gfxvidinfo.rowbytes = fb_width*gfxvidinfo.pixbytes; + gfxvidinfo.bufmem = fb_addr; +} + +static void leave_dga_mode (void) +{ +#ifdef USE_VIDMODE_EXTENSION + XF86VidModeSwitchToMode (display, screen, allmodes[0]); +#endif + XF86DGADirectVideo (display, screen, 0); + XUngrabPointer (display, CurrentTime); + XUngrabKeyboard (display, CurrentTime); +} + +#endif +static char *oldpixbuf; void flush_line(int y) { +#ifdef USE_DGA_EXTENSION + if (need_dither) { + char *addr = gfxvidinfo.linemem; + if (addr == NULL) + addr = y*gfxvidinfo.rowbytes + gfxvidinfo.bufmem; + + DitherLine((unsigned char *)(fb_addr + fb_width*y), (uae_u16 *)addr, 0, y, + gfxvidinfo.width, bit_unit); + } +#else + char *linebuf; int xs = 0, xe; - int len, factor; - char *linebuf = y*gfxvidinfo.rowbytes + gfxvidinfo.bufmem; - char *src, *dst; - if (gfxvidinfo.maxlinetoscr) - xe = gfxvidinfo.maxlinetoscr-1; - else - xe = hsize-1; + int len; - if (!use_low_bandwidth) - fprintf(stderr, "Bug!\n"); - - switch(gfxvidinfo.pixbytes) { - case 4: - { - int *newp = (int *)linebuf; - int *oldp = (int *)(oldpixbuf + y*gfxvidinfo.rowbytes); - while (newp[xs] == oldp[xs]) { - if (xs == xe) - return; - xs++; + linebuf = gfxvidinfo.linemem; + if (linebuf == NULL) + linebuf = y*gfxvidinfo.rowbytes + gfxvidinfo.bufmem; + + xe = gfxvidinfo.width-1; + + if (currprefs.use_low_bandwidth) { + char *src, *dst; + switch(gfxvidinfo.pixbytes) { + case 4: + { + uae_u32 *newp = (uae_u32 *)linebuf; + uae_u32 *oldp = (uae_u32 *)((uae_u8 *)image_mem + y*img->bytes_per_line); + while (newp[xs] == oldp[xs]) { + if (xs == xe) + return; + xs++; + } + while (newp[xe] == oldp[xe]) xe--; + + dst = (char *)(oldp + xs); src = (char *)(newp + xs); } - while (newp[xe] == oldp[xe]) xe--; - - dst = (char *)(oldp + xs); src = (char *)(newp + xs); - } - break; - case 2: - { - short *newp = (short *)linebuf; - short *oldp = (short *)(oldpixbuf + y*gfxvidinfo.rowbytes); - while (newp[xs] == oldp[xs]) { - if (xs == xe) - return; - xs++; + break; + case 2: + { + uae_u16 *newp = (uae_u16 *)linebuf; + uae_u16 *oldp = (uae_u16 *)((uae_u8 *)image_mem + y*img->bytes_per_line); + while (newp[xs] == oldp[xs]) { + if (xs == xe) + return; + xs++; + } + while (newp[xe] == oldp[xe]) xe--; + + dst = (char *)(oldp + xs); src = (char *)(newp + xs); } - while (newp[xe] == oldp[xe]) xe--; + break; + case 1: + { + uae_u8 *newp = (uae_u8 *)linebuf; + uae_u8 *oldp = (uae_u8 *)((uae_u8 *)image_mem + y*img->bytes_per_line); + while (newp[xs] == oldp[xs]) { + if (xs == xe) + return; + xs++; + } + while (newp[xe] == oldp[xe]) xe--; - dst = (char *)(oldp + xs); src = (char *)(newp + xs); - } - break; - case 1: - { - char *newp = (char *)linebuf; - char *oldp = (char *)(oldpixbuf + y*gfxvidinfo.rowbytes); - while (newp[xs] == oldp[xs]) { - if (xs == xe) - return; - xs++; + dst = (char *)(oldp + xs); src = (char *)(newp + xs); } - while (newp[xe] == oldp[xe]) xe--; + break; - dst = (char *)(oldp + xs); src = (char *)(newp + xs); + default: + abort(); + break; } - break; - default: + len = xe - xs + 1; + memcpy (dst, src, len * gfxvidinfo.pixbytes); + } else if (need_dither) { + uae_u8 *target = (uae_u8 *)image_mem + img->bytes_per_line * y; + len = currprefs.gfx_width; + DitherLine(target, (uae_u16 *)linebuf, 0, y, gfxvidinfo.width, bit_unit); + } else { + fprintf(stderr, "Bug!\n"); abort(); - break; } - len = xe - xs + 1; - memcpy (dst, src, len * gfxvidinfo.pixbytes); - - if (need_dither) { - UBYTE *target = (UBYTE *)image_mem + img->bytes_per_line * y; - xs &= ~(8/bit_unit - 1); - len = xe - xs + 1; - len += 3; len &= ~3; - len += (8/bit_unit - 1); len &= ~(8/bit_unit-1); - if (len & 3) - printf("%d\n",len); - DitherLine(target + xs*bit_unit/8, (UWORD *)linebuf + xs, xs, y, len, bit_unit); - } -#ifndef DONT_WANT_SHM - if (use_shm) - XShmPutImage(display, mywin, blackgc, img, xs, y, xs, y, len, 1, 0); - else + DO_PUTIMAGE (img, xs, y, xs, y, len, 1); #endif - XPutImage(display, mywin, blackgc, img, xs, y, xs, y, len, 1); } void flush_block (int ystart, int ystop) { +#ifdef USE_DGA_EXTENSION +#else int len, xs = 0; - - if (gfxvidinfo.maxlinetoscr) - len = gfxvidinfo.maxlinetoscr; - else - len = hsize; -#ifndef DONT_WANT_SHM - if (use_shm) - XShmPutImage(display, mywin, blackgc, img, xs, ystart, 0, ystart, len, - ystop - ystart + 1, 0); - else + + len = gfxvidinfo.width; + DO_PUTIMAGE (img, xs, ystart, 0, ystart, len, ystop - ystart + 1); #endif - XPutImage(display, mywin, blackgc, img, xs, ystart, 0, ystart, len, - ystop - ystart + 1); } void flush_screen (int ystart, int ystop) { -#ifndef DONT_WANT_SHM - if (use_shm) XSync(display, 0); +#ifdef USE_DGA_EXTENSION +#else +#if SHM_SUPPORT_LINKS == 1 + if (currprefs.use_mitshm) XSync(display, 0); +#endif #endif -} - -void calc_adjustment(void) -{ - switch (screen_res) { - case 0: case 1: case 2: /* LoRes, 320x300 */ - gfxvidinfo.x_adjust = prev_max_diwstop - 320; - break; - - case 3: /* 640x480 */ - gfxvidinfo.x_adjust = prev_max_diwstop - 640; - break; - default: - gfxvidinfo.x_adjust = 0; - break; - } } static __inline__ int bitsInMask(unsigned long mask) @@ -262,92 +406,232 @@ static __inline__ int maskShift(unsigned return n; } +static unsigned long pixel_return[256]; +static XColor parsed_xcolors[256]; +static int ncolors = 0; + +static int blackval = 32767; +static int whiteval = 0; + static int get_color(int r, int g, int b, xcolnr *cnp) { - XColor col; + XColor *col = parsed_xcolors + ncolors; char str[10]; + sprintf(str, "rgb:%x/%x/%x", r, g, b); - XParseColor(display, cmap, str, &col); - if (XAllocColor(display, cmap, &col)) { - *cnp = col.pixel; - return 1; - } - return 0; + XParseColor(display, cmap, str, col); + *cnp = col->pixel = pixel_return[ncolors]; + XStoreColor (display, cmap, col); + XStoreColor (display, cmap2, col); + + if (r + g + b < blackval) + blackval = r + g + b, black = *col; + if (r + g + b > whiteval) + whiteval = r + g + b, white = *col; + + ncolors++; + return 1; } static int init_colors(void) { + int i; + if (need_dither) { + XAllocColorCells (display, cmap, 0, 0, 0, pixel_return, 256); + XAllocColorCells (display, cmap2, 0, 0, 0, pixel_return, 256); if (bitdepth == 1) setup_greydither (1, get_color); else setup_dither (bitdepth, get_color); - return 1; - } - - if (bitdepth != 8 && bitdepth != 12 - && bitdepth != 16 && bitdepth != 24) { - fprintf(stderr, "Unsupported bit depth (%d)\n", bitdepth); - return 0; - } - -#ifdef __cplusplus - switch(visualInfo.c_class) -#else - switch(visualInfo.class) -#endif - { - case TrueColor: - { - int red_bits = bitsInMask(visualInfo.red_mask); - int green_bits = bitsInMask(visualInfo.green_mask); - int blue_bits = bitsInMask(visualInfo.blue_mask); - int red_shift = maskShift(visualInfo.red_mask); - int green_shift = maskShift(visualInfo.green_mask); - int blue_shift = maskShift(visualInfo.blue_mask); - alloc_colors64k(red_bits, green_bits, blue_bits, red_shift, - green_shift, blue_shift); + } else { + if (bitdepth != 8 && bitdepth != 12 && bitdepth != 15 + && bitdepth != 16 && bitdepth != 24) { + fprintf(stderr, "Unsupported bit depth (%d)\n", bitdepth); + return 0; } - break; - case GrayScale: - case PseudoColor: - alloc_colors256(get_color); + switch (visualInfo.VI_CLASS) { + case TrueColor: + { + int red_bits = bitsInMask(visualInfo.red_mask); + int green_bits = bitsInMask(visualInfo.green_mask); + int blue_bits = bitsInMask(visualInfo.blue_mask); + int red_shift = maskShift(visualInfo.red_mask); + int green_shift = maskShift(visualInfo.green_mask); + int blue_shift = maskShift(visualInfo.blue_mask); + alloc_colors64k(red_bits, green_bits, blue_bits, red_shift, + green_shift, blue_shift); + } + XParseColor(display, cmap, "#000000", &black); + if (!XAllocColor(display, cmap, &black)) + fprintf(stderr, "Whoops??\n"); + XParseColor(display, cmap, "#ffffff", &white); + if (!XAllocColor(display, cmap, &white)) + fprintf(stderr, "Whoops??\n"); + break; + + case GrayScale: + case PseudoColor: + XAllocColorCells (display, cmap, 0, 0, 0, pixel_return, 256); + XAllocColorCells (display, cmap2, 0, 0, 0, pixel_return, 256); + alloc_colors256(get_color); + break; + + default: + fprintf (stderr, "Unsupported visual class (%d)\n", visualInfo.VI_CLASS); + return 0; + } + } + switch (gfxvidinfo.pixbytes) { + case 2: + for (i = 0; i < 4096; i++) + xcolors[i] = xcolors[i] * 0x00010001; + gfxvidinfo.can_double = 1; + break; + case 1: + for (i = 0; i < 4096; i++) + xcolors[i] = xcolors[i] * 0x01010101; + gfxvidinfo.can_double = 1; break; - default: -#ifdef __cplusplus - fprintf(stderr, "Unsupported visual class (%d)\n", visualInfo.c_class); -#else - fprintf(stderr, "Unsupported visual class (%d)\n", visualInfo.class); -#endif - return 0; + gfxvidinfo.can_double = 0; + break; } + if(inverse_byte_order) + switch(gfxvidinfo.pixbytes) { + case 4: + for(i = 0; i < 4096; i++) + xcolors[i] = ((((xcolors[i]>>0)&255) << 24) + | (((xcolors[i]>>8)&255) << 16) + | (((xcolors[i]>>16)&255) << 8) + | (((xcolors[i]>>24)&255) << 0)); + break; + case 2: + for (i = 0; i < 4096; i++) + xcolors[i] = (xcolors[i]>>8) | ((xcolors[i]&255)<<8); + break; + default: + break; + } return 1; } -int graphics_init(void) +int graphics_setup(void) { - int i,j; char *display_name = 0; - XSetWindowAttributes wattr; - XPixmapFormatValues *xpfvs; - need_dither = 0; - - if (screen_res < 3) { - fprintf(stderr, "Low resolution mode selected. Forcing 320x300.\n"); +#ifdef USE_DGA_EXTENSION + int MajorVersion, MinorVersion; + int EventBase, ErrorBase; + if (geteuid()) { + fprintf(stderr, "You must be root to use UAE with the DGA extensions.\n"); + return 0; } - +#endif + display = XOpenDisplay(display_name); if (display == 0) { fprintf(stderr, "Can't connect to X server %s\n", XDisplayName(display_name)); return 0; } + +#ifdef USE_DGA_EXTENSION + if (!XF86DGAQueryVersion (display, &MajorVersion, &MinorVersion)) { + fprintf(stderr, "Unable to query video extension version\n"); + return 0; + } + + if (!XF86DGAQueryExtension (display, &EventBase, &ErrorBase)) { + fprintf(stderr, "Unable to query video extension information\n"); + return 0; + } + + /* Fail if the extension version in the server is too old */ + if (MajorVersion < DGA_MINMAJOR || + (MajorVersion == DGA_MINMAJOR && MinorVersion < DGA_MINMINOR)) { + fprintf (stderr, + "Xserver is running an old XFree86-DGA version" + " (%d.%d)\n", MajorVersion, MinorVersion); + fprintf (stderr, "Minimum required version is %d.%d\n", + DGA_MINMAJOR, DGA_MINMINOR); + return 0; + } +#ifdef USE_VIDMODE_EXTENSION + if (!XF86VidModeQueryVersion (display, &MajorVersion, &MinorVersion)) { + fprintf (stderr, "Unable to query video extension version\n"); + return 0; + } + + if (!XF86VidModeQueryExtension (display, &EventBase, &ErrorBase)) { + fprintf (stderr, "Unable to query video extension information\n"); + return 0; + } + + /* Fail if the extension version in the server is too old */ + if (MajorVersion < VidMode_MINMAJOR || + (MajorVersion == VidMode_MINMAJOR && MinorVersion < VidMode_MINMINOR)) { + fprintf (stderr, + "Xserver is running an old XFree86-VidMode version" + " (%d.%d)\n", MajorVersion, MinorVersion); + fprintf (stderr, "Minimum required version is %d.%d\n", + VidMode_MINMAJOR, VidMode_MINMINOR); + return 0; + } + if (!get_vidmodes ()) { + fprintf (stderr, "Error getting video mode information\n"); + return 0; + } +#endif + +#endif + + { + int local_byte_order; + int x = 0x04030201; + char *y=(char*)&x; + + local_byte_order = y[0] == 0x04 ? MSBFirst : LSBFirst; + if (ImageByteOrder(display) != local_byte_order) + inverse_byte_order = 1; + } + + return 1; +} + +static void fixup_prefs_dimensions (void) +{ + if (currprefs.gfx_width < 320) + currprefs.gfx_width = 320; + if (currprefs.gfx_height < 200) + currprefs.gfx_height = 200; + if (currprefs.gfx_height > 300 && ! currprefs.gfx_linedbl) + currprefs.gfx_height = 300; + if (currprefs.gfx_height > 600) + currprefs.gfx_height = 600; + + currprefs.gfx_width += 7; /* X86.S wants multiples of 4 bytes, might be 8 in the future. */ + currprefs.gfx_width &= ~7; +} + +int graphics_init(void) +{ + int i,j; + XSetWindowAttributes wattr; + XPixmapFormatValues *xpfvs; + + if (currprefs.color_mode > 5) + fprintf(stderr, "Bad color mode selected. Using default.\n"), currprefs.color_mode = 0; + + x11_init_ok = 0; + need_dither = 0; + screen_is_picasso = 0; + screen = XDefaultScreen(display); rootwin = XRootWindow(display,screen); - + /* try for a 12 bit visual first, then a 16 bit, then a 24 bit, then 8 bit */ if (XMatchVisualInfo(display, screen, 12, TrueColor, &visualInfo)) { + } else if (XMatchVisualInfo(display, screen, 15, TrueColor, &visualInfo)) { } else if (XMatchVisualInfo(display, screen, 16, TrueColor, &visualInfo)) { } else if (XMatchVisualInfo(display, screen, 24, TrueColor, &visualInfo)) { } else if (XMatchVisualInfo(display, screen, 8, PseudoColor, &visualInfo)) { @@ -363,7 +647,7 @@ int graphics_init(void) } vis = visualInfo.visual; bitdepth = visualInfo.depth; - + /* We now have the bitdepth of the display, but that doesn't tell us yet * how many bits to use per pixel. The VGA16 server has a bitdepth of 4, * but uses 1 byte per pixel. */ @@ -374,147 +658,140 @@ int graphics_init(void) fprintf(stderr, "Your X server is feeling ill.\n"); return 0; } - + bit_unit = xpfvs->bits_per_pixel; fprintf(stderr, "Using %d bit visual, %d bits per pixel\n", bitdepth, bit_unit); - switch (screen_res) { - case 0: case 1: case 2: - hsize = hpixels = 320; - correct_aspect = 0; - break; - case 3: - hsize = hpixels = 640; - break; - case 4: - hpixels = 796; hsize = 800; /* ??? */ - break; - } - vsize = correct_aspect ? 2*numscrlines : numscrlines; + fixup_prefs_dimensions (); - cmap = XCreateColormap(display, rootwin, vis, AllocNone); - XParseColor(display, cmap, "#000000", &black); - if (!XAllocColor(display, cmap, &black)) - fprintf(stderr, "Whoops??\n"); - XParseColor(display, cmap, "#ffffff", &white); - if (!XAllocColor(display, cmap, &white)) - fprintf(stderr, "Whoops??\n"); + gfxvidinfo.width = currprefs.gfx_width; + gfxvidinfo.height = currprefs.gfx_height; + cmap = XCreateColormap(display, rootwin, vis, AllocNone); + cmap2 = XCreateColormap(display, rootwin, vis, AllocNone); +#ifdef USE_DGA_EXTENSION + wattr.override_redirect = 1; +#endif wattr.event_mask = eventmask; - wattr.background_pixel = black.pixel; + wattr.background_pixel = /*black.pixel*/0; wattr.backing_store = Always; wattr.backing_planes = bitdepth; wattr.border_pixmap = None; - wattr.border_pixel = black.pixel; + wattr.border_pixel = /*black.pixel*/0; wattr.colormap = cmap; - mywin = XCreateWindow(display, rootwin, 0, 0, hpixels, vsize, 0, + mywin = XCreateWindow(display, rootwin, 0, 0, currprefs.gfx_width, currprefs.gfx_height, 0, bitdepth, InputOutput, vis, CWEventMask|CWBackPixel|CWBorderPixel|CWBackingStore - |CWBackingPlanes|CWColormap, - &wattr); - XMapWindow(display,mywin); - XStoreName(display, mywin, "UAE"); - - blankCursor = XCreatePixmapCursor(display, - XCreatePixmap(display, mywin, 1, 1, 1), - XCreatePixmap(display, mywin, 1, 1, 1), - &black, &white, 0, 0); - xhairCursor = XCreateFontCursor(display, XC_crosshair); + |CWBackingPlanes|CWColormap +#ifdef USE_DGA_EXTENSION + |CWOverrideRedirect +#endif + ,&wattr); - whitegc = XCreateGC(display,mywin,0,0); - blackgc = XCreateGC(display,mywin,0,0); - - XSetForeground(display,blackgc,black.pixel); - XSetForeground(display,whitegc,white.pixel); + current_width = currprefs.gfx_width; + current_height = currprefs.gfx_height; - if (bitdepth < 8 || (bitdepth == 8 && color_mode == 3)) { + XMapWindow(display, mywin); +#ifdef USE_DGA_EXTENSION + XRaiseWindow(display, mywin); +#else + XStoreName(display, mywin, "UAE"); +#endif + + if (bitdepth < 8 || (bitdepth == 8 && currprefs.color_mode == 3)) { gfxvidinfo.pixbytes = 2; - use_low_bandwidth = 1; + currprefs.use_low_bandwidth = 0; need_dither = 1; -#ifndef DONT_WANT_SHM - use_shm = 0; -#endif } else { - gfxvidinfo.pixbytes = (bitdepth == 24 || bitdepth == 32 ? 4 - : bitdepth == 12 || bitdepth == 16 ? 2 - : 1); + gfxvidinfo.pixbytes = bit_unit >> 3; } - -#ifndef DONT_WANT_SHM - if (use_shm) { - img = XShmCreateImage(display, vis, bitdepth, ZPixmap, 0, &shminfo, hsize, vsize); - - shminfo.shmid = shmget(IPC_PRIVATE, vsize * img->bytes_per_line, - IPC_CREAT | 0777); - shminfo.shmaddr = img->data = image_mem = (char *)shmat(shminfo.shmid, 0, 0); - shminfo.readOnly = False; - /* let the xserver attach */ - XShmAttach(display, &shminfo); - XSync(display,0); - /* now deleting means making it temporary */ - shmctl(shminfo.shmid, IPC_RMID, 0); - } else + +#ifdef USE_DGA_EXTENSION + enter_dga_mode (); + /*setuid(getuid());*/ +#else + + img = get_image (currprefs.gfx_width, currprefs.gfx_height, &image_mem); #endif - { - /* Question for people who know about X: Could we allocate the buffer - * after creating the image and then do img->data = buffer, as above in - * the SHM case? - */ - image_mem = (char *)malloc(vsize * hsize * bit_unit / 8); /* ??? */ - img = XCreateImage(display, vis, bitdepth, ZPixmap, 0, image_mem, - hsize, vsize, 32, 0); - if (img->bytes_per_line != hsize * bit_unit / 8) - fprintf (stderr, "Possible bug here... graphics may look strange.\n"); - } - - if (need_dither) { - gfxvidinfo.rowbytes = gfxvidinfo.pixbytes * hsize; - gfxvidinfo.bufmem = (char *)malloc(gfxvidinfo.rowbytes * vsize); - } else { - gfxvidinfo.rowbytes = img->bytes_per_line; - gfxvidinfo.bufmem = image_mem; - } - - gfxvidinfo.maxline = 100000; /* no limit */ - if (use_low_bandwidth) { + if (need_dither) { + gfxvidinfo.maxblocklines = 0; + gfxvidinfo.rowbytes = gfxvidinfo.pixbytes * currprefs.gfx_width; + gfxvidinfo.linemem = (char *)malloc(gfxvidinfo.rowbytes); + } else if (currprefs.use_low_bandwidth) { gfxvidinfo.maxblocklines = 0; - oldpixbuf = (char *)malloc(gfxvidinfo.rowbytes * vsize); + gfxvidinfo.rowbytes = img->bytes_per_line; + gfxvidinfo.linemem = gfxvidinfo.bufmem = (char *)malloc(gfxvidinfo.rowbytes); } else { gfxvidinfo.maxblocklines = 100; /* whatever... */ +#ifndef USE_DGA_EXTENSION + gfxvidinfo.rowbytes = img->bytes_per_line; + gfxvidinfo.bufmem = image_mem; +#endif + gfxvidinfo.linemem = NULL; } if (!init_colors()) return 0; +#ifndef USE_DGA_EXTENSION + blankCursor = XCreatePixmapCursor(display, + XCreatePixmap(display, mywin, 1, 1, 1), + XCreatePixmap(display, mywin, 1, 1, 1), + &black, &white, 0, 0); + xhairCursor = XCreateFontCursor(display, XC_crosshair); + + whitegc = XCreateGC(display,mywin,0,0); + blackgc = XCreateGC(display,mywin,0,0); + picassogc = XCreateGC (display,mywin,0,0); + + XSetForeground(display, blackgc, black.pixel); + XSetForeground(display, whitegc, white.pixel); +#endif + buttonstate[0] = buttonstate[1] = buttonstate[2] = 0; for(i=0; i<256; i++) keystate[i] = 0; - - lastmx = lastmy = 0; + + lastmx = lastmy = 0; newmousecounters = 0; inwindow = 0; - - if (!no_xhair) + +#ifndef USE_DGA_EXTENSION + if (!currprefs.no_xhair) XDefineCursor(display, mywin, xhairCursor); else XDefineCursor(display, mywin, blankCursor); cursorOn = 1; - return 1; +#else + dga_colormap_installed = 0; + XF86DGAInstallColormap (display, screen, cmap); +#endif + + return x11_init_ok = 1; } void graphics_leave(void) { + if (!x11_init_ok) + return; + if (autorepeatoff) XAutoRepeatOn(display); + XFlush(display); + XSync(display, 0); +#ifdef USE_DGA_EXTENSION + leave_dga_mode (); + dumpcustom(); +#endif } -/* Decode KeySyms. This function knows about all keys that are common +/* Decode KeySyms. This function knows about all keys that are common * between different keyboard languages. */ static int kc_decode (KeySym ks) { - switch (ks) { + switch (ks) { case XK_B: case XK_b: return AK_B; case XK_C: case XK_c: return AK_C; case XK_D: case XK_d: return AK_D; @@ -534,9 +811,8 @@ static int kc_decode (KeySym ks) case XK_T: case XK_t: return AK_T; case XK_U: case XK_u: return AK_U; case XK_V: case XK_v: return AK_V; - case XK_W: case XK_w: return AK_W; case XK_X: case XK_x: return AK_X; - + case XK_0: return AK_0; case XK_1: return AK_1; case XK_2: return AK_2; @@ -547,7 +823,7 @@ static int kc_decode (KeySym ks) case XK_7: return AK_7; case XK_8: return AK_8; case XK_9: return AK_9; - + /* You never know which Keysyms might be missing on some workstation * This #ifdef should be enough. */ #if defined(XK_KP_Prior) && defined(XK_KP_Left) && defined(XK_KP_Insert) && defined (XK_KP_End) @@ -590,10 +866,11 @@ static int kc_decode (KeySym ks) case XK_F8: return AK_F8; case XK_F9: return AK_F9; case XK_F10: return AK_F10; - + case XK_BackSpace: return AK_BS; case XK_Delete: return AK_DEL; - case XK_Control_L: case XK_Control_R: return AK_CTRL; + case XK_Control_L: return AK_CTRL; + case XK_Control_R: return AK_RCTRL; case XK_Tab: return AK_TAB; case XK_Alt_L: return AK_LALT; case XK_Alt_R: return AK_RALT; @@ -605,17 +882,24 @@ static int kc_decode (KeySym ks) case XK_Shift_R: return AK_RSH; case XK_Escape: return AK_ESC; - case XK_Insert: return AK_BACKSLASH; - case XK_End: return AK_HELP; + case XK_Insert: return AK_HELP; + case XK_Home: return AK_NPLPAREN; + case XK_End: return AK_NPRPAREN; case XK_Caps_Lock: return AK_CAPSLOCK; - + case XK_Up: return AK_UP; case XK_Down: return AK_DN; case XK_Left: return AK_LF; case XK_Right: return AK_RT; - + case XK_F11: return AK_BACKSLASH; +#ifdef USE_DGA_EXTENSION + case XK_F12: + uae_quit(); + return -1; +#else case XK_F12: return AK_mousestuff; +#endif #ifdef XK_F14 case XK_F14: #endif @@ -633,10 +917,11 @@ static int decode_fr(KeySym ks) { switch(ks) { /* FR specific */ case XK_A: case XK_a: return AK_Q; - case XK_M: case XK_m: return AK_SEMICOLON; - case XK_Q: case XK_q: return AK_A; + case XK_M: case XK_m: return AK_SEMICOLON; + case XK_Q: case XK_q: return AK_A; case XK_Y: case XK_y: return AK_Y; - case XK_Z: case XK_z: return AK_Z; + case XK_W: case XK_w: return AK_Z; + case XK_Z: case XK_z: return AK_W; case XK_bracketleft: return AK_LBRACKET; case XK_bracketright: return AK_RBRACKET; case XK_comma: return AK_M; @@ -655,11 +940,12 @@ static int decode_fr(KeySym ks) static int decode_us(KeySym ks) { - switch(ks) { /* US specific */ + switch(ks) { /* US specific */ case XK_A: case XK_a: return AK_A; case XK_M: case XK_m: return AK_M; case XK_Q: case XK_q: return AK_Q; case XK_Y: case XK_y: return AK_Y; + case XK_W: case XK_w: return AK_W; case XK_Z: case XK_z: return AK_Z; case XK_bracketleft: return AK_LBRACKET; case XK_bracketright: return AK_RBRACKET; @@ -685,6 +971,7 @@ static int decode_de(KeySym ks) case XK_A: case XK_a: return AK_A; case XK_M: case XK_m: return AK_M; case XK_Q: case XK_q: return AK_Q; + case XK_W: case XK_w: return AK_W; case XK_Y: case XK_y: return AK_Z; case XK_Z: case XK_z: return AK_Y; case XK_Odiaeresis: case XK_odiaeresis: return AK_SEMICOLON; @@ -711,6 +998,7 @@ static int decode_se(KeySym ks) case XK_A: case XK_a: return AK_A; case XK_M: case XK_m: return AK_M; case XK_Q: case XK_q: return AK_Q; + case XK_W: case XK_w: return AK_W; case XK_Y: case XK_y: return AK_Y; case XK_Z: case XK_z: return AK_Z; case XK_Odiaeresis: case XK_odiaeresis: return AK_SEMICOLON; @@ -724,7 +1012,7 @@ static int decode_se(KeySym ks) case XK_at: case XK_onehalf: return AK_BACKQUOTE; case XK_asciitilde: case XK_asciicircum: return AK_RBRACKET; case XK_backslash: case XK_bar: return AK_MINUS; - + case XK_numbersign: return AK_NUMBERSIGN; } @@ -738,6 +1026,7 @@ static int decode_it(KeySym ks) case XK_A: case XK_a: return AK_A; case XK_M: case XK_m: return AK_M; case XK_Q: case XK_q: return AK_Q; + case XK_W: case XK_w: return AK_W; case XK_Y: case XK_y: return AK_Y; case XK_Z: case XK_z: return AK_Z; case XK_Ograve: case XK_ograve: return AK_SEMICOLON; @@ -747,8 +1036,37 @@ static int decode_it(KeySym ks) case XK_comma: return AK_COMMA; case XK_period: return AK_PERIOD; case XK_less: case XK_greater: return AK_LTGT; - case XK_backslash: case XK_bar: return AK_BACKQUOTE; - case XK_apostrophe: return AK_MINUS; + case XK_backslash: case XK_bar: return AK_BACKQUOTE; + case XK_apostrophe: return AK_MINUS; + case XK_Igrave: case XK_igrave: return AK_EQUAL; + case XK_minus: return AK_SLASH; + case XK_numbersign: return AK_NUMBERSIGN; + } + + return -1; +} + +static int decode_es(KeySym ks) +{ + switch(ks) { + /* ES specific */ + case XK_A: case XK_a: return AK_A; + case XK_M: case XK_m: return AK_M; + case XK_Q: case XK_q: return AK_Q; + case XK_W: case XK_w: return AK_W; + case XK_Y: case XK_y: return AK_Y; + case XK_Z: case XK_z: return AK_Z; + case XK_ntilde: case XK_Ntilde: return AK_SEMICOLON; +#ifdef XK_dead_acute + case XK_dead_acute: case XK_dead_diaeresis: return AK_QUOTE; + case XK_dead_grave: case XK_dead_circumflex: return AK_LBRACKET; +#endif + case XK_plus: case XK_asterisk: return AK_RBRACKET; + case XK_comma: return AK_COMMA; + case XK_period: return AK_PERIOD; + case XK_less: case XK_greater: return AK_LTGT; + case XK_backslash: case XK_bar: return AK_BACKQUOTE; + case XK_apostrophe: return AK_MINUS; case XK_Igrave: case XK_igrave: return AK_EQUAL; case XK_minus: return AK_SLASH; case XK_numbersign: return AK_NUMBERSIGN; @@ -762,34 +1080,38 @@ static int keycode2amiga(XKeyEvent *even KeySym ks; int as; int index = 0; - + do { ks = XLookupKeysym(event, index); as = kc_decode (ks); - - if (as == -1) { - switch(keyboard_lang) { + + if (as == -1) { + switch(currprefs.keyboard_lang) { case KBD_LANG_FR: as = decode_fr(ks); break; - case KBD_LANG_US: + case KBD_LANG_US: as = decode_us(ks); break; - + case KBD_LANG_DE: as = decode_de(ks); break; - + case KBD_LANG_SE: as = decode_se(ks); break; - + case KBD_LANG_IT: as = decode_it(ks); break; + case KBD_LANG_ES: + as = decode_es(ks); + break; + default: as = -1; break; @@ -804,12 +1126,13 @@ static int keycode2amiga(XKeyEvent *even static struct timeval lastMotionTime; +static int refresh_necessary = 0; + void handle_events(void) { - int refresh = 0; newmousecounters = 0; gui_handle_events(); - + for (;;) { XEvent event; #if 0 @@ -817,9 +1140,9 @@ void handle_events(void) #endif if (!XPending(display)) break; XNextEvent(display, &event); - + switch(event.type) { - case KeyPress: { + case KeyPress: { int kc = keycode2amiga((XKeyEvent *)&event); if (kc == -1) break; switch (kc) { @@ -828,11 +1151,11 @@ void handle_events(void) break; case AK_inhibit: - inhibit_frame ^= 1; + toggle_inhibit_frame (0); break; default: - if (!keystate[kc]) { + if (!keystate[kc]) { keystate[kc] = 1; record_key (kc << 1); } @@ -840,7 +1163,7 @@ void handle_events(void) } break; } - case KeyRelease: { + case KeyRelease: { int kc = keycode2amiga((XKeyEvent *)&event); if (kc == -1) break; keystate[kc] = 0; @@ -853,6 +1176,7 @@ void handle_events(void) case ButtonRelease: buttonstate[((XButtonEvent *)&event)->button-1] = 0; break; +#ifndef USE_DGA_EXTENSION case EnterNotify: newmousecounters = 1; lastmx = ((XCrossingEvent *)&event)->x; @@ -873,10 +1197,10 @@ void handle_events(void) autorepeatoff = 0; break; case MotionNotify: - if (inwindow) { + if (inwindow) { lastmx = ((XMotionEvent *)&event)->x; lastmy = ((XMotionEvent *)&event)->y; - if(!cursorOn && !no_xhair) { + if(!cursorOn && !currprefs.no_xhair) { XDefineCursor(display, mywin, xhairCursor); cursorOn = 1; } @@ -884,34 +1208,62 @@ void handle_events(void) } break; case Expose: - refresh = 1; + refresh_necessary = 1; break; +#else + case MotionNotify: + newmousecounters = 0; + lastmx += ((XMotionEvent *)&event)->x_root; + lastmy += ((XMotionEvent *)&event)->y_root; +#endif + } + } +#if defined PICASSO96 && !defined USE_DGA_EXTENSION + if (screen_is_picasso && refresh_necessary) { + DO_PUTIMAGE (picasso_img, 0, 0, 0, 0, + picasso_vidinfo.width, picasso_vidinfo.height); + refresh_necessary = 0; + } else if (screen_is_picasso) { + int i; + int strt = -1, stop = -1; + picasso_invalid_lines[picasso_vidinfo.height] = 0; + for (i = 0; i < picasso_vidinfo.height + 1; i++) { + if (picasso_invalid_lines[i]) { + picasso_invalid_lines[i] = 0; + if (strt != -1) + continue; + strt = i; + } else { + if (strt == -1) + continue; + DO_PUTIMAGE (picasso_img, 0, strt, 0, strt, + picasso_vidinfo.width, i-strt); + strt = -1; + } } } - - if(refresh) { -#ifndef DONT_WANT_SHM - if (use_shm) - XShmPutImage(display, mywin, blackgc, img, 0, 0, 0, 0, hpixels, vsize, 0); - else #endif - XPutImage(display, mywin, blackgc, img, 0, 0, 0, 0, hpixels, vsize); + +#ifndef USE_DGA_EXTENSION + if (!screen_is_picasso && refresh_necessary) { + DO_PUTIMAGE (img, 0, 0, 0, 0, currprefs.gfx_width, currprefs.gfx_height); + refresh_necessary = 0; } - if(cursorOn && !no_xhair) { + if(cursorOn && !currprefs.no_xhair) { struct timeval now; int diff; gettimeofday(&now, NULL); - diff = (now.tv_sec - lastMotionTime.tv_sec) * 1000000 + + diff = (now.tv_sec - lastMotionTime.tv_sec) * 1000000 + (now.tv_usec - lastMotionTime.tv_usec); if(diff > 1000000) { XDefineCursor(display, mywin, blankCursor); cursorOn = 0; } } - +#endif /* "Affengriff" */ if(keystate[AK_CTRL] && keystate[AK_LAMI] && keystate[AK_RAMI]) - m68k_reset(); + uae_reset(); } int debuggable(void) @@ -921,11 +1273,16 @@ int debuggable(void) int needmousehack(void) { +#ifdef USE_DGA_EXTENSION + return 0; +#else return 1; +#endif } void LED(int on) { +#if 0 /* Maybe that is responsible for the joystick emulation problems on SunOS? */ static int last_on = -1; XKeyboardControl control; @@ -934,20 +1291,194 @@ void LED(int on) control.led = 1; /* implementation defined */ control.led_mode = on ? LedModeOn : LedModeOff; XChangeKeyboardControl(display, KBLed | KBLedMode, &control); +#endif +} + +void write_log (const char *buf) +{ + fprintf (stderr, buf); +} + +#ifdef PICASSO96 + +void DX_Invalidate (int first, int last) +{ + do { + picasso_invalid_lines[first] = 1; + first++; + } while (first <= last); +} + +int DX_BitsPerCannon (void) +{ + return 8; +} + +void DX_SetPalette(int start, int count) +{ + if (!screen_is_picasso || picasso_vidinfo.pixbytes != 1) + return; + + while (count-- > 0) { + XColor col = parsed_xcolors[start]; + col.red = picasso96_state.CLUT[start].Red * 0x0101; + col.green = picasso96_state.CLUT[start].Green * 0x0101; + col.blue = picasso96_state.CLUT[start].Blue * 0x0101; + XStoreColor (display, cmap, &col); + XStoreColor (display, cmap2, &col); + start++; + } +#ifdef USE_DGA_EXTENSION + dga_colormap_installed ^= 1; + if (dga_colormap_installed == 1) + XF86DGAInstallColormap(display, screen, cmap2); + else + XF86DGAInstallColormap(display, screen, cmap); +#endif +} + +#define MAX_SCREEN_MODES 11 + +static int x_size_table[MAX_SCREEN_MODES] = { 320, 320, 320, 320, 640, 640, 640, 800, 1024, 1152, 1280 }; +static int y_size_table[MAX_SCREEN_MODES] = { 200, 240, 256, 400, 350, 480, 512, 600, 768, 864, 1024 }; + +int DX_FillResolutions (uae_u16 *ppixel_format) +{ + Screen *scr = ScreenOfDisplay (display, screen); + int i, count = 0; + int w = WidthOfScreen (scr); + int h = HeightOfScreen (scr); + int maxw = 0, maxh = 0; + + *ppixel_format = (bit_unit == 8 ? RGBFF_CHUNKY + : bitdepth == 15 && bit_unit == 16 ? RGBFF_R5G5B5PC + : bitdepth == 16 && bit_unit == 16 ? RGBFF_R5G6B5PC + : bit_unit == 24 ? RGBFF_B8G8R8 + : bit_unit == 32 ? RGBFF_B8G8R8A8 + : 0); + +#if defined USE_DGA_EXTENSION && defined USE_VIDMODE_EXTENSION + for (i = 0; i < vidmodecount && i < MAX_PICASSO_MODES ; i++) { + DisplayModes[i].res.width = allmodes[i]->hdisplay; + DisplayModes[i].res.height = allmodes[i]->vdisplay; + DisplayModes[i].depth = bit_unit >> 3; + DisplayModes[i].refresh = 75; + } + count = i; +#else + for (i = 0; i < MAX_SCREEN_MODES && count < MAX_PICASSO_MODES ; i++) { + if (x_size_table[i] <= w && y_size_table[i] <= h) { + if (x_size_table[i] > maxw) + maxw = x_size_table[i]; + if (y_size_table[i] > maxh) + maxh = y_size_table[i]; + DisplayModes[count].res.width = x_size_table[i]; + DisplayModes[count].res.height = y_size_table[i]; + DisplayModes[count].depth = bit_unit >> 3; + DisplayModes[count].refresh = 75; + count++; + } + } +#endif + +#ifndef USE_DGA_EXTENSION + picasso_img = get_image (maxw, maxh, 0); +#endif + + return count; +} + +static void set_window_for_picasso (void) +{ + if (current_width != picasso_vidinfo.width || current_height != picasso_vidinfo.height) { + current_width = picasso_vidinfo.width; + current_height = picasso_vidinfo.height; + XResizeWindow (display, mywin, picasso_vidinfo.width, + picasso_vidinfo.height); +#if defined USE_DGA_EXTENSION && defined USE_VIDMODE_EXTENSION + switch_to_best_mode (); +#endif + } + DX_SetPalette (0, 256); } -void target_specific_usage(void) +static void set_window_for_amiga (void) { - printf(" -S n : Sound emulation accuracy (n = 0, 1, 2 or 3)\n" - " For sound emulation, n = 2 is recommended\n"); - printf(" -b n : Use n bits for sound output (8 or 16)\n"); - printf(" -R n : Use n Hz to output sound. Common values are\n" - " 22050 Hz or 44100 Hz\n"); - printf(" -B n : Use a sound buffer of n bytes (use small\n" - " values on fast machines)\n"); - printf(" -x : Use visible cross-hair cursor\n"); - printf(" -l lang : Set keyboard language to lang, where lang is\n" - " DE, SE, US, FR or IT\n"); - printf(" -p command : Use command to pipe printer output to.\n"); - printf(" -I device : Name of the used serial device (i.e. /dev/ttyS1\n"); + int i; + + if (current_width != currprefs.gfx_width || current_height != currprefs.gfx_height) { + current_width = currprefs.gfx_width; + current_height = currprefs.gfx_height; + XResizeWindow (display, mywin, currprefs.gfx_width, + currprefs.gfx_height); +#if defined USE_DGA_EXTENSION && defined USE_VIDMODE_EXTENSION + switch_to_best_mode (); +#endif + } + + if (gfxvidinfo.pixbytes == 1) + for (i = 0; i < 256; i++) { + XStoreColor (display, cmap, parsed_xcolors + i); + XStoreColor (display, cmap2, parsed_xcolors + i); + } +#ifdef USE_DGA_EXTENSION + dga_colormap_installed ^= 1; + if (dga_colormap_installed == 1) + XF86DGAInstallColormap(display, screen, cmap2); + else + XF86DGAInstallColormap(display, screen, cmap); +#endif } + +void gfx_set_picasso_modeinfo (int w, int h, int depth) +{ + picasso_vidinfo.width = w; + picasso_vidinfo.height = h; + picasso_vidinfo.depth = depth; + picasso_vidinfo.pixbytes = gfxvidinfo.pixbytes; +#ifdef USE_DGA_EXTENSION + picasso_vidinfo.rowbytes = fb_width * gfxvidinfo.pixbytes; +#else + picasso_vidinfo.rowbytes = picasso_img->bytes_per_line; +#endif + picasso_vidinfo.extra_mem = 1; + + if (screen_is_picasso) + set_window_for_picasso (); +} + +void gfx_set_picasso_baseaddr (uaecptr a) +{ +} + +void gfx_set_picasso_state (int on) +{ + if (on == screen_is_picasso) + return; + screen_is_picasso = on; + if (on) + set_window_for_picasso (); + else + set_window_for_amiga (); +} + +void begindrawing (void) +{ +} + +void enddrawing (void) +{ +} + +uae_u8 *lockscr (void) +{ +#ifdef USE_DGA_EXTENSION + return fb_addr; +#else + return picasso_img->data; +#endif +} +void unlockscr (void) +{ +} +#endif