From 19494038b3f19991598a9d7762b721f39150dd0c Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Wed, 23 Jun 2004 14:30:48 +0000 Subject: [PATCH] Initial SDL/video support. Fix VOSF code could lead to a crash on run-time resolution/depth switching. Rearrange blitter lookup code, aka make it cleaner. --- BasiliskII/src/Unix/Makefile.in | 2 +- BasiliskII/src/Unix/clip_unix.cpp | 10 +-- BasiliskII/src/Unix/configure.ac | 55 +++++++++++++--- BasiliskII/src/Unix/main_unix.cpp | 45 +++++++++++-- BasiliskII/src/Unix/sysdeps.h | 4 +- BasiliskII/src/Unix/video_blit.cpp | 100 +++++++++++++++-------------- BasiliskII/src/Unix/video_blit.h | 22 +++++++ BasiliskII/src/Unix/video_vosf.h | 80 +++++++++++++++-------- BasiliskII/src/Unix/video_x.cpp | 16 ++++- 9 files changed, 235 insertions(+), 99 deletions(-) diff --git a/BasiliskII/src/Unix/Makefile.in b/BasiliskII/src/Unix/Makefile.in index 51649770..97311a9d 100644 --- a/BasiliskII/src/Unix/Makefile.in +++ b/BasiliskII/src/Unix/Makefile.in @@ -34,7 +34,7 @@ SRCS = ../main.cpp main_unix.cpp ../prefs.cpp ../prefs_items.cpp prefs_unix.cpp ../emul_op.cpp ../macos_util.cpp ../xpram.cpp xpram_unix.cpp ../timer.cpp \ timer_unix.cpp clip_unix.cpp ../adb.cpp ../serial.cpp ../ether.cpp \ ../sony.cpp ../disk.cpp ../cdrom.cpp ../scsi.cpp ../video.cpp video_blit.cpp \ - video_x.cpp vm_alloc.cpp sigsegv.cpp ../audio.cpp ../extfs.cpp extfs_unix.cpp \ + vm_alloc.cpp sigsegv.cpp ../audio.cpp ../extfs.cpp extfs_unix.cpp \ ../user_strings.cpp user_strings_unix.cpp sshpty.c strlcpy.c \ $(SYSSRCS) $(CPUSRCS) APP = BasiliskII diff --git a/BasiliskII/src/Unix/clip_unix.cpp b/BasiliskII/src/Unix/clip_unix.cpp index ad977db1..4b7a69e9 100644 --- a/BasiliskII/src/Unix/clip_unix.cpp +++ b/BasiliskII/src/Unix/clip_unix.cpp @@ -19,9 +19,6 @@ */ #include "sysdeps.h" - -#include - #include "clip.h" #include "macos_util.h" #include "prefs.h" @@ -30,8 +27,11 @@ #include "debug.h" -// From main_unix.cpp +// From video_x.cpp +#ifndef USE_SDL_VIDEO +#include extern Display *x_display; +#endif // Conversion tables @@ -87,6 +87,7 @@ void PutScrap(uint32 type, void *scrap, int32 length) if (length <= 0) return; +#ifndef USE_SDL_VIDEO switch (type) { case FOURCC('T','E','X','T'): D(bug(" clipping TEXT\n")); @@ -110,4 +111,5 @@ void PutScrap(uint32 type, void *scrap, int32 length) delete[] buf; break; } +#endif } diff --git a/BasiliskII/src/Unix/configure.ac b/BasiliskII/src/Unix/configure.ac index 4d151931..6f5cd6a6 100644 --- a/BasiliskII/src/Unix/configure.ac +++ b/BasiliskII/src/Unix/configure.ac @@ -20,6 +20,9 @@ AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes]) AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes]) +dnl SDL options. +AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no]) + dnl JIT compiler options. AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no]) AC_ARG_ENABLE(jit-debug, [ --enable-jit-debug activate native code disassemblers [default=no]], [WANT_JIT_DEBUG=$enableval], [WANT_JIT_DEBUG=no]) @@ -123,14 +126,39 @@ dnl Checks for libraries. AC_CHECK_LIB(posix4, sem_init) AC_CHECK_LIB(rt, timer_create) -dnl We need X11. -AC_PATH_XTRA -if [[ "x$no_x" = "xyes" ]]; then - AC_MSG_ERROR([You need X11 to run Basilisk II.]) +dnl Do we need SDL? +WANT_SDL=no +SDL_SUPPORT="none" +if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then + WANT_SDL=yes + WANT_XF86_DGA=no + WANT_XF86_VIDMODE=no + WANT_FBDEV_DGA=no + SDL_SUPPORT="video" +fi +if [[ "x$WANT_SDL" = "xyes" ]]; then + AC_PATH_PROG(sdl_config, "sdl-config") + if [[ -n "$sdl_config" ]]; then + sdl_cflags=`$sdl_config --cflags` + sdl_libs=`$sdl_config --libs` + CFLAGS="$CFLAGS $sdl_cflags" + CXXFLAGS="$CXXFLAGS $sdl_cflags" + LIBS="$LIBS $sdl_libs" + else + WANT_SDL=no + fi +fi + +dnl We need X11, if not using SDL. +if [[ "x$WANT_SDL" = "xno" ]]; then + AC_PATH_XTRA + if [[ "x$no_x" = "xyes" ]]; then + AC_MSG_ERROR([You need X11 to run Basilisk II.]) + fi + CFLAGS="$CFLAGS $X_CFLAGS" + CXXFLAGS="$CXXFLAGS $X_CFLAGS" + LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS" fi -CFLAGS="$CFLAGS $X_CFLAGS" -CXXFLAGS="$CXXFLAGS $X_CFLAGS" -LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS" dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL. HAVE_PTHREADS=yes @@ -385,6 +413,16 @@ irix*) ;; esac +dnl SDL overrides +if [[ "x$WANT_SDL" = "xyes" ]]; then + AC_DEFINE(USE_SDL, 1, [Define to enble SDL support]) +fi +if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then + VIDEOSRC="../SDL/video_sdl.cpp" + AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support]) +else + VIDEOSRC="video_x.cpp" +fi dnl Use 68k CPU natively? WANT_NATIVE_M68K=no @@ -400,7 +438,7 @@ if [[ "x$HAVE_PTHREADS" = "xno" ]]; then ETHERSRC=../dummy/ether_dummy.cpp AUDIOSRC=../dummy/audio_dummy.cpp fi -SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS" +SYSSRCS="$VIDEOSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS" dnl Define a macro that translates a yesno-variable into a C macro definition dnl to be put into the config.h file @@ -1204,6 +1242,7 @@ dnl Print summary. echo echo Basilisk II configuration summary: echo +echo SDL support ............................ : $SDL_SUPPORT echo XFree86 DGA support .................... : $WANT_XF86_DGA echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE echo fbdev DGA support ...................... : $WANT_FBDEV_DGA diff --git a/BasiliskII/src/Unix/main_unix.cpp b/BasiliskII/src/Unix/main_unix.cpp index 267b0755..878a48d6 100644 --- a/BasiliskII/src/Unix/main_unix.cpp +++ b/BasiliskII/src/Unix/main_unix.cpp @@ -24,7 +24,14 @@ #include #include #include -#include + +#ifdef USE_SDL +# include +#endif + +#ifndef USE_SDL_VIDEO +# include +#endif #ifdef HAVE_PTHREADS # include @@ -119,8 +126,10 @@ bool TwentyFourBitAddressing; // Global variables -char *x_display_name = NULL; // X11 display name -Display *x_display = NULL; // X11 display handle +#ifndef USE_SDL_VIDEO +extern char *x_display_name; // X11 display name +extern Display *x_display; // X11 display handle +#endif static uint8 last_xpram[XPRAM_SIZE]; // Buffer for monitoring XPRAM changes @@ -300,10 +309,12 @@ int main(int argc, char **argv) for (int i=1; i #include -#include -#include -#ifdef ENABLE_VOSF // Format of the target visual -struct VisualFormat { - int depth; // Screen depth - uint32 Rmask, Gmask, Bmask; // RGB mask values - uint32 Rshift, Gshift, Bshift; // RGB shift values -}; static VisualFormat visualFormat; // This holds the pixels values of the palette colors for 8->16/32-bit expansion uint32 ExpandMap[256]; +// Mark video_blit.h for specialization +#define DEFINE_VIDEO_BLITTERS 1 + /* -------------------------------------------------------------------------- */ /* --- Raw Copy / No conversion required --- */ /* -------------------------------------------------------------------------- */ @@ -306,9 +302,25 @@ static void Blit_Copy_Raw(uint8 * dest, const uint8 * source, uint32 length) #include "video_blit.h" /* -------------------------------------------------------------------------- */ -/* --- 2/4-bit indexed to 8-bit mode conversion --- */ +/* --- 1/2/4-bit indexed to 8-bit mode conversion --- */ /* -------------------------------------------------------------------------- */ +static void Blit_Expand_1_To_8(uint8 * dest, const uint8 * p, uint32 length) +{ + uint8 *q = (uint8 *)dest; + for (uint32 i=0; i> 7; + *q++ = (c >> 6) & 1; + *q++ = (c >> 5) & 1; + *q++ = (c >> 4) & 1; + *q++ = (c >> 3) & 1; + *q++ = (c >> 2) & 1; + *q++ = (c >> 1) & 1; + *q++ = c & 1; + } +} + static void Blit_Expand_2_To_8(uint8 * dest, const uint8 * p, uint32 length) { uint8 *q = (uint8 *)dest; @@ -444,22 +456,23 @@ static Screen_blit_func_info Screen_blitters[] = { // Initialize the framebuffer update function // Returns FALSE, if the function was to be reduced to a simple memcpy() // --> In that case, VOSF is not necessary -bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int mac_depth) +bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_order, int mac_depth) { +#if USE_SDL_VIDEO + const bool use_sdl_video = true; +#else + const bool use_sdl_video = false; +#endif #if REAL_ADDRESSING || DIRECT_ADDRESSING - if (mac_depth == 1) { + if (!use_sdl_video && mac_depth == 1) { // 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines Screen_blit = Blit_Copy_Raw; } else { - visualFormat.depth = visual_info->depth; - visualFormat.Rmask = visual_info->red_mask; - visualFormat.Gmask = visual_info->green_mask; - visualFormat.Bmask = visual_info->blue_mask; - // Compute RGB shift values + visualFormat = visual_format; visualFormat.Rshift = 0; for (uint32 Rmask = visualFormat.Rmask; Rmask && ((Rmask & 1) != 1); Rmask >>= 1) ++visualFormat.Rshift; @@ -470,40 +483,34 @@ bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int for (uint32 Bmask = visualFormat.Bmask; Bmask && ((Bmask & 1) != 1); Bmask >>= 1) ++visualFormat.Bshift; - bool blitter_found = false; - - // 2/4/8-bit mode on 8/16/32-bit screen? - if (visualFormat.depth == 8) { - if (mac_depth == 2) { - Screen_blit = Blit_Expand_2_To_8; - blitter_found = true; - } else if (mac_depth == 4) { - Screen_blit = Blit_Expand_4_To_8; - blitter_found = true; + // 1/2/4/8-bit mode on 8/16/32-bit screen? + Screen_blit = NULL; + switch (visualFormat.depth) { + case 8: + switch (mac_depth) { + case 1: Screen_blit = Blit_Expand_1_To_8; break; + case 2: Screen_blit = Blit_Expand_2_To_8; break; + case 4: Screen_blit = Blit_Expand_4_To_8; break; } - } else if (visualFormat.depth == 15 || visualFormat.depth == 16) { - if (mac_depth == 2) { - Screen_blit = Blit_Expand_2_To_16; - blitter_found = true; - } else if (mac_depth == 4) { - Screen_blit = Blit_Expand_4_To_16; - blitter_found = true; - } else if (mac_depth == 8) { - Screen_blit = Blit_Expand_8_To_16; - blitter_found = true; + break; + case 15: + case 16: + switch (mac_depth) { + case 2: Screen_blit = Blit_Expand_2_To_16; break; + case 4: Screen_blit = Blit_Expand_4_To_16; break; + case 8: Screen_blit = Blit_Expand_8_To_16; break; } - } else if (visualFormat.depth == 24 || visualFormat.depth == 32) { - if (mac_depth == 2) { - Screen_blit = Blit_Expand_2_To_32; - blitter_found = true; - } else if (mac_depth == 4) { - Screen_blit = Blit_Expand_4_To_32; - blitter_found = true; - } else if (mac_depth == 8) { - Screen_blit = Blit_Expand_8_To_32; - blitter_found = true; + break; + case 24: + case 32: + switch (mac_depth) { + case 2: Screen_blit = Blit_Expand_2_To_32; break; + case 4: Screen_blit = Blit_Expand_4_To_32; break; + case 8: Screen_blit = Blit_Expand_8_To_32; break; } + break; } + bool blitter_found = (Screen_blit != NULL); // Search for an adequate blit function const int blitters_count = sizeof(Screen_blitters)/sizeof(Screen_blitters[0]); @@ -542,4 +549,3 @@ bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int // --> In that case, we return FALSE return (Screen_blit != Blit_Copy_Raw); } -#endif /* ENABLE_VOSF */ diff --git a/BasiliskII/src/Unix/video_blit.h b/BasiliskII/src/Unix/video_blit.h index b715ae56..1e6199fa 100644 --- a/BasiliskII/src/Unix/video_blit.h +++ b/BasiliskII/src/Unix/video_blit.h @@ -18,6 +18,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef DEFINE_VIDEO_BLITTERS + +#ifndef VIDEO_BLIT_H +#define VIDEO_BLIT_H + +// Format of the target visual +struct VisualFormat { + int depth; // Screen depth + uint32 Rmask, Gmask, Bmask; // RGB mask values + uint32 Rshift, Gshift, Bshift; // RGB shift values +}; + +extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length); +extern bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_order, int mac_depth); +extern uint32 ExpandMap[256]; + +#endif /* VIDEO_BLIT_H */ + +#else + #ifndef FB_DEPTH # error "Undefined screen depth" #endif @@ -128,3 +148,5 @@ static void FB_FUNC_NAME(uint8 * dest, const uint8 * source, uint32 length) #ifdef FB_DEPTH #undef FB_DEPTH #endif + +#endif /* DEFINE_VIDEO_BLITTERS */ diff --git a/BasiliskII/src/Unix/video_vosf.h b/BasiliskII/src/Unix/video_vosf.h index 5e324a65..fe4f3974 100644 --- a/BasiliskII/src/Unix/video_vosf.h +++ b/BasiliskII/src/Unix/video_vosf.h @@ -31,7 +31,38 @@ // Glue for SheepShaver and BasiliskII #if POWERPC_ROM -#define X11_MONITOR_INIT /* nothing */ +enum { + VIDEO_DEPTH_1BIT = APPLE_1_BIT, + VIDEO_DEPTH_2BIT = APPLE_2_BIT, + VIDEO_DEPTH_4BIT = APPLE_4_BIT, + VIDEO_DEPTH_8BIT = APPLE_8_BIT, + VIDEO_DEPTH_16BIT = APPLE_16_BIT, + VIDEO_DEPTH_32BIT = APPLE_32_BIT +}; +#else +enum { + VIDEO_DEPTH_1BIT = VDEPTH_1BIT, + VIDEO_DEPTH_2BIT = VDEPTH_2BIT, + VIDEO_DEPTH_4BIT = VDEPTH_4BIT, + VIDEO_DEPTH_8BIT = VDEPTH_8BIT, + VIDEO_DEPTH_16BIT = VDEPTH_16BIT, + VIDEO_DEPTH_32BIT = VDEPTH_32BIT +}; +#endif +#ifdef USE_SDL_VIDEO +#define MONITOR_INIT SDL_monitor_desc &monitor +#define VIDEO_DRV_INIT driver_window *drv +#define VIDEO_DRV_ROW_BYTES drv->s->pitch +#define VIDEO_DRV_LOCK_PIXELS if (SDL_MUSTLOCK(drv->s)) SDL_LockSurface(drv->s) +#define VIDEO_DRV_UNLOCK_PIXELS if (SDL_MUSTLOCK(drv->s)) SDL_UnlockSurface(drv->s) +#define VIDEO_MODE_INIT video_mode const & mode = drv->mode +#define VIDEO_MODE_ROW_BYTES mode.bytes_per_row +#define VIDEO_MODE_X mode.x +#define VIDEO_MODE_Y mode.y +#define VIDEO_MODE_DEPTH (int)mode.depth +#else +#if POWERPC_ROM +#define MONITOR_INIT /* nothing */ #define VIDEO_DRV_INIT /* nothing */ #define VIDEO_DRV_WINDOW the_win #define VIDEO_DRV_GC the_gc @@ -42,34 +73,22 @@ #define VIDEO_MODE_X mode.viXsize #define VIDEO_MODE_Y mode.viYsize #define VIDEO_MODE_DEPTH mode.viAppleMode -enum { - VIDEO_DEPTH_1BIT = APPLE_1_BIT, - VIDEO_DEPTH_2BIT = APPLE_2_BIT, - VIDEO_DEPTH_4BIT = APPLE_4_BIT, - VIDEO_DEPTH_8BIT = APPLE_8_BIT, - VIDEO_DEPTH_16BIT = APPLE_16_BIT, - VIDEO_DEPTH_32BIT = APPLE_32_BIT -}; #else -#define X11_MONITOR_INIT X11_monitor_desc &monitor +#define MONITOR_INIT X11_monitor_desc &monitor #define VIDEO_DRV_INIT driver_window *drv #define VIDEO_DRV_WINDOW drv->w #define VIDEO_DRV_GC drv->gc #define VIDEO_DRV_IMAGE drv->img #define VIDEO_DRV_HAVE_SHM drv->have_shm -#define VIDEO_MODE_INIT video_mode const & mode = drv->monitor.get_current_mode(); +#define VIDEO_MODE_INIT video_mode const & mode = drv->mode #define VIDEO_MODE_ROW_BYTES mode.bytes_per_row #define VIDEO_MODE_X mode.x #define VIDEO_MODE_Y mode.y #define VIDEO_MODE_DEPTH (int)mode.depth -enum { - VIDEO_DEPTH_1BIT = VDEPTH_1BIT, - VIDEO_DEPTH_2BIT = VDEPTH_2BIT, - VIDEO_DEPTH_4BIT = VDEPTH_4BIT, - VIDEO_DEPTH_8BIT = VDEPTH_8BIT, - VIDEO_DEPTH_16BIT = VDEPTH_16BIT, - VIDEO_DEPTH_32BIT = VDEPTH_32BIT -}; +#endif +#define VIDEO_DRV_LOCK_PIXELS /* nothing */ +#define VIDEO_DRV_UNLOCK_PIXELS /* nothing */ +#define VIDEO_DRV_ROW_BYTES VIDEO_DRV_IMAGE->bytes_per_line #endif // Variables for Video on SEGV support @@ -204,7 +223,7 @@ static uint32 page_extend(uint32 size) * Initialize the VOSF system (mainBuffer structure, SIGSEGV handler) */ -static bool video_vosf_init(X11_MONITOR_INIT) +static bool video_vosf_init(MONITOR_INIT) { VIDEO_MODE_INIT; @@ -313,11 +332,6 @@ bool Screen_fault_handler(sigsegv_address_t fault_address, sigsegv_address_t fau * Update display for Windowed mode and VOSF */ -// From video_blit.cpp -extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length); -extern bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int mac_depth); -extern uint32 ExpandMap[256]; - /* How can we deal with array overrun conditions ? The state of the framebuffer pages that have been touched are maintained @@ -373,12 +387,14 @@ static inline void update_display_window_vosf(VIDEO_DRV_INIT) const int y1 = mainBuffer.pageInfo[first_page].top; const int y2 = mainBuffer.pageInfo[page - 1].bottom; const int height = y2 - y1 + 1; - + + VIDEO_DRV_LOCK_PIXELS; + if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) { // Update the_host_buffer and copy of the_buffer const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES; - const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line; + const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES; const int pixels_per_byte = VIDEO_MODE_X / src_bytes_per_row; int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j; for (j = y1; j <= y2; j++) { @@ -391,7 +407,7 @@ static inline void update_display_window_vosf(VIDEO_DRV_INIT) // Update the_host_buffer and copy of the_buffer const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES; - const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line; + const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES; const int bytes_per_pixel = src_bytes_per_row / VIDEO_MODE_X; int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j; for (j = y1; j <= y2; j++) { @@ -401,10 +417,16 @@ static inline void update_display_window_vosf(VIDEO_DRV_INIT) } } + VIDEO_DRV_UNLOCK_PIXELS; + +#ifdef USE_SDL_VIDEO + SDL_UpdateRect(drv->s, 0, y1, VIDEO_MODE_X, height); +#else if (VIDEO_DRV_HAVE_SHM) XShmPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height, 0); else XPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height); +#endif } mainBuffer.dirty = false; } @@ -472,6 +494,7 @@ static inline void update_display_dga_vosf(void) // Update the_host_buffer and copy of the_buffer // There should be at least one pixel to copy + VIDEO_DRV_LOCK_PIXELS; const int width = x2 - x1 + 1; i = y1 * bytes_per_row + x1 * bytes_per_pixel; for (j = y1; j <= y2; j++) { @@ -479,6 +502,7 @@ static inline void update_display_dga_vosf(void) memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width); i += bytes_per_row; } + VIDEO_DRV_UNLOCK_PIXELS; } mainBuffer.dirty = false; } diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index 1a77e87c..53dea727 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -62,6 +62,7 @@ #include "prefs.h" #include "user_strings.h" #include "video.h" +#include "video_blit.h" #define DEBUG 0 #include "debug.h" @@ -122,6 +123,8 @@ static bool use_keycodes = false; // Flag: Use keycodes rather than keysyms static int keycode_table[256]; // X keycode -> Mac keycode translation table // X11 variables +char *x_display_name = NULL; // X11 display name +Display *x_display = NULL; // X11 display handle static int screen; // Screen number static Window rootwin; // Root window and our window static int num_depths = 0; // Number of available X depths @@ -131,6 +134,7 @@ static unsigned long black_pixel, white_pixel; static int eventmask; static int xdepth; // Depth of X screen +static VisualFormat visualFormat; static XVisualInfo visualInfo; static Visual *vis; static int color_class; @@ -754,7 +758,7 @@ driver_window::driver_window(X11_monitor_desc &m) native_byte_order = (XImageByteOrder(x_display) == LSBFirst); #endif #ifdef ENABLE_VOSF - Screen_blitter_init(&visualInfo, native_byte_order, depth_of_video_mode(mode)); + Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode)); #endif // Set frame buffer base @@ -1115,7 +1119,7 @@ driver_fbdev::driver_fbdev(X11_monitor_desc &m) : driver_dga(m) #if REAL_ADDRESSING || DIRECT_ADDRESSING // Screen_blitter_init() returns TRUE if VOSF is mandatory // i.e. the framebuffer update function is not Blit_Copy_Raw - use_vosf = Screen_blitter_init(&visualInfo, true, mode.depth); + use_vosf = Screen_blitter_init(visualFormat, true, mode.depth); if (use_vosf) { // Allocate memory for frame buffer (SIZE is extended to page-boundary) @@ -1255,7 +1259,7 @@ driver_xf86dga::driver_xf86dga(X11_monitor_desc &m) #if REAL_ADDRESSING || DIRECT_ADDRESSING // Screen_blitter_init() returns TRUE if VOSF is mandatory // i.e. the framebuffer update function is not Blit_Copy_Raw - use_vosf = Screen_blitter_init(&visualInfo, native_byte_order, depth_of_video_mode(mode)); + use_vosf = Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode)); if (use_vosf) { // Allocate memory for frame buffer (SIZE is extended to page-boundary) @@ -1397,6 +1401,12 @@ bool X11_monitor_desc::video_open(void) return false; } + // Build up visualFormat structure + visualFormat.depth = visualInfo.depth; + visualFormat.Rmask = visualInfo.red_mask; + visualFormat.Gmask = visualInfo.green_mask; + visualFormat.Bmask = visualInfo.blue_mask; + // Create color maps if (color_class == PseudoColor || color_class == DirectColor) { cmap[0] = XCreateColormap(x_display, rootwin, vis, AllocAll);