diff --git a/BasiliskII/TODO b/BasiliskII/TODO index 35abe34f..c1f05aa2 100644 --- a/BasiliskII/TODO +++ b/BasiliskII/TODO @@ -16,6 +16,8 @@ General: - Classic ROM: mouse button/movement is broken with ROM mouse handler - Classic ROM: sound output - Write a nice User's Manual with linuxdoc or something similar +- Fix video mode switch to cope with different mac_frame_base + (CrsrBase is overriden with the previous base after the mode switch) AmigaOS: - "Create Hardfile..." button diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp index 5d9d3f4d..a527609b 100644 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -197,7 +197,19 @@ extern void SysMountFirstFloppy(void); static void *vm_acquire_framebuffer(uint32 size) { - return vm_acquire(size); + // always try to reallocate framebuffer at the same address + static void *fb = VM_MAP_FAILED; + if (fb != VM_MAP_FAILED) { + if (vm_acquire_fixed(fb, size) < 0) { +#ifndef SHEEPSHAVER + printf("FATAL: Could not reallocate framebuffer at previous address\n"); +#endif + fb = VM_MAP_FAILED; + } + } + if (fb == VM_MAP_FAILED) + fb = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_32BIT); + return fb; } static inline void vm_release_framebuffer(void *fb, uint32 size) @@ -719,7 +731,7 @@ void driver_base::restore_mouse_accel(void) * Windowed display driver */ -static int SDL_display_opened = FALSE; +static bool SDL_display_opened = false; // Open display driver_window::driver_window(SDL_monitor_desc &m) @@ -747,7 +759,7 @@ driver_window::driver_window(SDL_monitor_desc &m) if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE)) == NULL) return; - SDL_display_opened = TRUE; + SDL_display_opened = true; #ifdef ENABLE_VOSF use_vosf = true; diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index f2371a9f..9e4a9b1d 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -194,7 +194,6 @@ static void *redraw_func(void *arg); // From main_unix.cpp extern char *x_display_name; extern Display *x_display; -extern void *vm_acquire_mac(size_t size); // From sys_unix.cpp extern void SysMountFirstFloppy(void); @@ -497,6 +496,33 @@ static int error_handler(Display *d, XErrorEvent *e) } +/* + * Framebuffer allocation routines + */ + +#ifdef ENABLE_VOSF +#include "vm_alloc.h" + +static void *vm_acquire_framebuffer(uint32 size) +{ + // always try to allocate framebuffer at the same address + static void *fb = VM_MAP_FAILED; + if (fb != VM_MAP_FAILED) { + if (vm_acquire_fixed(fb, size) < 0) + fb = VM_MAP_FAILED; + } + if (fb == VM_MAP_FAILED) + fb = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_32BIT); + return fb; +} + +static inline void vm_release_framebuffer(void *fb, uint32 size) +{ + vm_release(fb, size); +} +#endif + + /* * Display "driver" classes */ @@ -632,7 +658,7 @@ driver_base::~driver_base() // the_buffer shall always be mapped through vm_acquire() so that we can vm_protect() it at will if (the_buffer != VM_MAP_FAILED) { D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size)); - vm_release(the_buffer, the_buffer_size); + vm_release_framebuffer(the_buffer, the_buffer_size); the_buffer = NULL; } if (the_host_buffer) { @@ -782,7 +808,7 @@ driver_window::driver_window(X11_monitor_desc &m) // Allocate memory for frame buffer (SIZE is extended to page-boundary) the_host_buffer = the_buffer_copy; the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line); - the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size); + the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); the_buffer_copy = (uint8 *)malloc(the_buffer_size); D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer)); #else @@ -1162,7 +1188,7 @@ driver_fbdev::driver_fbdev(X11_monitor_desc &m) : driver_dga(m) the_host_buffer = the_buffer; the_buffer_size = page_extend((height + 2) * bytes_per_row); the_buffer_copy = (uint8 *)malloc(the_buffer_size); - the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size); + the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); // Fake image for DGA/VOSF mode to know about display bounds img = new FakeXImage(width, height, depth_of_video_mode(mode)); @@ -1299,7 +1325,7 @@ driver_xf86dga::driver_xf86dga(X11_monitor_desc &m) the_host_buffer = the_buffer; the_buffer_size = page_extend((height + 2) * bytes_per_row); the_buffer_copy = (uint8 *)malloc(the_buffer_size); - the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size); + the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); // Fake image for DGA/VOSF mode to know about display bounds img = new FakeXImage((v_width + 7) & ~7, height, depth_of_video_mode(mode));