- 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
This commit is contained in:
cebix 2000-10-13 16:47:52 +00:00
parent 33892da9ef
commit 01d43035d5
2 changed files with 21 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -53,7 +53,6 @@
#endif
#ifdef ENABLE_VOSF
# include <math.h> // log()
# include <unistd.h>
# include <signal.h>
# include <fcntl.h>
@ -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) {