260 |
|
} |
261 |
|
|
262 |
|
#if defined(HAVE_SIGINFO_T) |
263 |
+ |
|
264 |
|
static void Screen_fault_handler(int, siginfo_t * sip, void *) |
265 |
|
{ |
266 |
|
D(bug("Screen_fault_handler: ADDR=0x%08X\n", sip->si_addr)); |
267 |
|
do_handle_screen_fault((uintptr)sip->si_addr); |
268 |
|
} |
269 |
+ |
|
270 |
|
#elif defined(HAVE_SIGCONTEXT_SUBTERFUGE) |
271 |
+ |
|
272 |
|
# if defined(__i386__) && defined(__linux__) |
273 |
|
static void Screen_fault_handler(int, struct sigcontext scs) |
274 |
|
{ |
275 |
|
D(bug("Screen_fault_handler: ADDR=0x%08X from IP=0x%08X\n", scs.cr2, scs.eip)); |
276 |
|
do_handle_screen_fault((uintptr)scs.cr2); |
277 |
|
} |
278 |
+ |
|
279 |
+ |
# elif defined(__m68k__) && defined(__NetBSD__) |
280 |
+ |
|
281 |
+ |
# include <m68k/frame.h> |
282 |
+ |
static void Screen_fault_handler(int, int code, struct sigcontext *scp) |
283 |
+ |
{ |
284 |
+ |
D(bug("Screen_fault_handler: ADDR=0x%08X\n", code)); |
285 |
+ |
struct sigstate { |
286 |
+ |
int ss_flags; |
287 |
+ |
struct frame ss_frame; |
288 |
+ |
}; |
289 |
+ |
struct sigstate *state = (struct sigstate *)scp->sc_ap; |
290 |
+ |
uintptr fault_addr; |
291 |
+ |
switch (state->ss_frame.f_format) { |
292 |
+ |
case 7: // 68040 access error |
293 |
+ |
// "code" is sometimes unreliable (i.e. contains NULL or a bogus address), reason unknown |
294 |
+ |
fault_addr = state->ss_frame.f_fmt7.f_fa; |
295 |
+ |
break; |
296 |
+ |
default: |
297 |
+ |
fault_addr = (uintptr)code; |
298 |
+ |
break; |
299 |
+ |
} |
300 |
+ |
do_handle_screen_fault(fault_addr); |
301 |
+ |
} |
302 |
+ |
|
303 |
|
# else |
304 |
|
# error "No suitable subterfuge for Video on SEGV signals" |
305 |
|
# endif |
372 |
|
|
373 |
|
// Check for first column from left and first column |
374 |
|
// from right that have changed |
375 |
< |
int x1 = VideoMonitor.x * bytes_per_pixel - 1; |
376 |
< |
for (j = y1; j <= y2; j++) { |
377 |
< |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
378 |
< |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
379 |
< |
for (i = 0; i < x1; i++) { |
380 |
< |
if (p1[i] != p2[i]) { |
381 |
< |
x1 = i; |
382 |
< |
break; |
375 |
> |
int x1, x2, width; |
376 |
> |
if (depth == 1) { |
377 |
> |
|
378 |
> |
x1 = VideoMonitor.x - 1; |
379 |
> |
for (j = y1; j <= y2; j++) { |
380 |
> |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
381 |
> |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
382 |
> |
for (i = 0; i < (x1>>3); i++) { |
383 |
> |
if (p1[i] != p2[i]) { |
384 |
> |
x1 = i << 3; |
385 |
> |
break; |
386 |
> |
} |
387 |
|
} |
388 |
|
} |
389 |
< |
} |
390 |
< |
x1 /= bytes_per_pixel; |
391 |
< |
|
392 |
< |
int x2 = x1 * bytes_per_pixel; |
393 |
< |
for (j = y2; j >= y1; j--) { |
394 |
< |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
395 |
< |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
396 |
< |
for (i = VideoMonitor.x * bytes_per_pixel - 1; i > x2; i--) { |
397 |
< |
if (p1[i] != p2[i]) { |
398 |
< |
x2 = i; |
367 |
< |
break; |
389 |
> |
|
390 |
> |
x2 = x1; |
391 |
> |
for (j = y2; j >= y1; j--) { |
392 |
> |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
393 |
> |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
394 |
> |
for (i = (VideoMonitor.x>>3) - 1; i > (x2>>3); i--) { |
395 |
> |
if (p1[i] != p2[i]) { |
396 |
> |
x2 = i << 3; |
397 |
> |
break; |
398 |
> |
} |
399 |
|
} |
400 |
|
} |
401 |
< |
} |
402 |
< |
x2 /= bytes_per_pixel; |
401 |
> |
width = x2 - x1 + 1; |
402 |
> |
|
403 |
> |
// Update the_host_buffer and copy of the_buffer |
404 |
> |
i = y1 * bytes_per_row + (x1 >> 3); |
405 |
> |
for (j = y1; j <= y2; j++) { |
406 |
> |
do_update_framebuffer(the_host_buffer + i, the_buffer + i, width >> 3); |
407 |
> |
memcpy(the_buffer_copy + i, the_buffer + i, width >> 3); |
408 |
> |
i += bytes_per_row; |
409 |
> |
} |
410 |
> |
|
411 |
> |
} else { |
412 |
> |
|
413 |
> |
x1 = VideoMonitor.x * bytes_per_pixel - 1; |
414 |
> |
for (j = y1; j <= y2; j++) { |
415 |
> |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
416 |
> |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
417 |
> |
for (i = 0; i < x1; i++) { |
418 |
> |
if (p1[i] != p2[i]) { |
419 |
> |
x1 = i; |
420 |
> |
break; |
421 |
> |
} |
422 |
> |
} |
423 |
> |
} |
424 |
> |
x1 /= bytes_per_pixel; |
425 |
|
|
426 |
< |
// Update the_host_buffer and copy of the_buffer |
427 |
< |
// There is at least one pixel to copy |
428 |
< |
const int width = x2 - x1 + 1; |
429 |
< |
i = y1 * bytes_per_row + x1 * bytes_per_pixel; |
430 |
< |
for (j = y1; j <= y2; j++) { |
431 |
< |
do_update_framebuffer(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width); |
432 |
< |
memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width); |
433 |
< |
i += bytes_per_row; |
426 |
> |
x2 = x1 * bytes_per_pixel; |
427 |
> |
for (j = y2; j >= y1; j--) { |
428 |
> |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
429 |
> |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
430 |
> |
for (i = VideoMonitor.x * bytes_per_pixel - 1; i > x2; i--) { |
431 |
> |
if (p1[i] != p2[i]) { |
432 |
> |
x2 = i; |
433 |
> |
break; |
434 |
> |
} |
435 |
> |
} |
436 |
> |
} |
437 |
> |
x2 /= bytes_per_pixel; |
438 |
> |
width = x2 - x1 + 1; |
439 |
> |
|
440 |
> |
// Update the_host_buffer and copy of the_buffer |
441 |
> |
i = y1 * bytes_per_row + x1 * bytes_per_pixel; |
442 |
> |
for (j = y1; j <= y2; j++) { |
443 |
> |
do_update_framebuffer(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width); |
444 |
> |
memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width); |
445 |
> |
i += bytes_per_row; |
446 |
> |
} |
447 |
|
} |
448 |
|
|
449 |
|
if (have_shm) |