From 01d43035d5b3227ad7c9fafad82e77a559ecd74a Mon Sep 17 00:00:00 2001 From: cebix <> Date: Fri, 13 Oct 2000 16:47:52 +0000 Subject: [PATCH] - replaced floating-point page shift calculation by integer routine, fixing the VOSF problems under NetBSD/m68k - fixed off-by-7 error in 1-bit window update routines --- BasiliskII/src/Unix/video_vosf.h | 9 +++++++-- BasiliskII/src/Unix/video_x.cpp | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/BasiliskII/src/Unix/video_vosf.h b/BasiliskII/src/Unix/video_vosf.h index f409b10e..f5f5ba44 100644 --- a/BasiliskII/src/Unix/video_vosf.h +++ b/BasiliskII/src/Unix/video_vosf.h @@ -327,7 +327,12 @@ static bool Screen_fault_handler_init() // Setup SIGSEGV handler to process writes to frame buffer sigemptyset(&vosf_sa.sa_mask); vosf_sa.sa_handler = (void (*)(int)) Screen_fault_handler; +#if !EMULATED_68K && defined(__NetBSD__) + sigaddset(&vosf_sa.sa_mask, SIGALRM); + vosf_sa.sa_flags = SA_ONSTACK; +#else vosf_sa.sa_flags = 0; +#endif return (sigaction(SIGSEGV, &vosf_sa, NULL) == 0); } #endif @@ -355,7 +360,7 @@ static inline void update_display_window_vosf(void) PFLAG_CLEAR(page); ++page; } - + // Make the dirty pages read-only again const int32 offset = first_page << mainBuffer.pageBits; const uint32 length = (page - first_page) << mainBuffer.pageBits; @@ -393,7 +398,7 @@ static inline void update_display_window_vosf(void) uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; for (i = (VideoMonitor.x>>3) - 1; i > (x2>>3); i--) { if (p1[i] != p2[i]) { - x2 = i << 3; + x2 = (i << 3) + 7; break; } } diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index 89508a88..9198ced0 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -53,7 +53,6 @@ #endif #ifdef ENABLE_VOSF -# include // log() # include # include # include @@ -219,6 +218,17 @@ static struct sigaction vosf_sa; static pthread_mutex_t Screen_draw_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect frame buffer (dirtyPages in fact) #endif +static int log_base_2(uint32 x) +{ + uint32 mask = 0x80000000; + int l = 31; + while (l >= 0 && (x & mask) == 0) { + mask >>= 1; + l--; + } + return l; +} + #endif // VideoRefresh function @@ -804,7 +814,7 @@ bool VideoInitBuffer() mainBuffer.pageSize = page_size; mainBuffer.pageCount = (mainBuffer.memLength + page_mask)/mainBuffer.pageSize; - mainBuffer.pageBits = int( log(mainBuffer.pageSize) / log(2.0) ); + mainBuffer.pageBits = log_base_2(mainBuffer.pageSize); if (mainBuffer.dirtyPages != 0) free(mainBuffer.dirtyPages); @@ -1766,12 +1776,12 @@ static void update_display_static(void) for (i=(VideoMonitor.x>>3); i>(x2>>3); i--) { p--; p2--; if (*p != *p2) { - x2 = i << 3; + x2 = (i << 3) + 7; break; } } } - wide = x2 - x1; + wide = x2 - x1 + 1; // Update copy of the_buffer if (high && wide) {