1 |
|
/* |
2 |
|
* video_vosf.h - Video/graphics emulation, video on SEGV signals support |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
163 |
|
|
164 |
|
static bool screen_fault_handler(sigsegv_address_t fault_address, sigsegv_address_t fault_instruction); |
165 |
|
|
166 |
< |
static bool video_vosf_init(void) |
166 |
> |
static bool video_vosf_init(X11_monitor_desc &monitor) |
167 |
|
{ |
168 |
+ |
const video_mode &mode = monitor.get_current_mode(); |
169 |
+ |
|
170 |
|
const uintptr page_size = getpagesize(); |
171 |
|
const uintptr page_mask = page_size - 1; |
172 |
|
|
198 |
|
|
199 |
|
uint32 a = 0; |
200 |
|
for (unsigned i = 0; i < mainBuffer.pageCount; i++) { |
201 |
< |
unsigned y1 = a / VideoMonitor.mode.bytes_per_row; |
202 |
< |
if (y1 >= VideoMonitor.mode.y) |
203 |
< |
y1 = VideoMonitor.mode.y - 1; |
204 |
< |
|
205 |
< |
unsigned y2 = (a + mainBuffer.pageSize) / VideoMonitor.mode.bytes_per_row; |
206 |
< |
if (y2 >= VideoMonitor.mode.y) |
207 |
< |
y2 = VideoMonitor.mode.y - 1; |
201 |
> |
unsigned y1 = a / mode.bytes_per_row; |
202 |
> |
if (y1 >= mode.y) |
203 |
> |
y1 = mode.y - 1; |
204 |
> |
|
205 |
> |
unsigned y2 = (a + mainBuffer.pageSize) / mode.bytes_per_row; |
206 |
> |
if (y2 >= mode.y) |
207 |
> |
y2 = mode.y - 1; |
208 |
|
|
209 |
|
mainBuffer.pageInfo[i].top = y1; |
210 |
|
mainBuffer.pageInfo[i].bottom = y2; |
332 |
|
|
333 |
|
static inline void update_display_window_vosf(driver_window *drv) |
334 |
|
{ |
335 |
+ |
const video_mode &mode = drv->monitor.get_current_mode(); |
336 |
+ |
|
337 |
|
int page = 0; |
338 |
|
for (;;) { |
339 |
|
const unsigned first_page = find_next_page_set(page); |
353 |
|
const int y2 = mainBuffer.pageInfo[page - 1].bottom; |
354 |
|
const int height = y2 - y1 + 1; |
355 |
|
|
356 |
< |
if (VideoMonitor.mode.depth < VDEPTH_8BIT) { |
356 |
> |
if (mode.depth < VDEPTH_8BIT) { |
357 |
|
|
358 |
|
// Update the_host_buffer and copy of the_buffer |
359 |
< |
const int src_bytes_per_row = VideoMonitor.mode.bytes_per_row; |
359 |
> |
const int src_bytes_per_row = mode.bytes_per_row; |
360 |
|
const int dst_bytes_per_row = drv->img->bytes_per_line; |
361 |
< |
const int pixels_per_byte = VideoMonitor.mode.x / src_bytes_per_row; |
361 |
> |
const int pixels_per_byte = mode.x / src_bytes_per_row; |
362 |
|
int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j; |
363 |
|
for (j = y1; j <= y2; j++) { |
364 |
< |
Screen_blit(the_host_buffer + i2, the_buffer + i1, VideoMonitor.mode.x / pixels_per_byte); |
364 |
> |
Screen_blit(the_host_buffer + i2, the_buffer + i1, mode.x / pixels_per_byte); |
365 |
|
i1 += src_bytes_per_row; |
366 |
|
i2 += dst_bytes_per_row; |
367 |
|
} |
369 |
|
} else { |
370 |
|
|
371 |
|
// Update the_host_buffer and copy of the_buffer |
372 |
< |
const int src_bytes_per_row = VideoMonitor.mode.bytes_per_row; |
372 |
> |
const int src_bytes_per_row = mode.bytes_per_row; |
373 |
|
const int dst_bytes_per_row = drv->img->bytes_per_line; |
374 |
< |
const int bytes_per_pixel = src_bytes_per_row / VideoMonitor.mode.x; |
374 |
> |
const int bytes_per_pixel = src_bytes_per_row / mode.x; |
375 |
|
int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j; |
376 |
|
for (j = y1; j <= y2; j++) { |
377 |
< |
Screen_blit(the_host_buffer + i2, the_buffer + i1, bytes_per_pixel * VideoMonitor.mode.x); |
377 |
> |
Screen_blit(the_host_buffer + i2, the_buffer + i1, bytes_per_pixel * mode.x); |
378 |
|
i1 += src_bytes_per_row; |
379 |
|
i2 += dst_bytes_per_row; |
380 |
|
} |
381 |
|
} |
382 |
|
|
383 |
|
if (drv->have_shm) |
384 |
< |
XShmPutImage(x_display, drv->w, drv->gc, drv->img, 0, y1, 0, y1, VideoMonitor.mode.x, height, 0); |
384 |
> |
XShmPutImage(x_display, drv->w, drv->gc, drv->img, 0, y1, 0, y1, mode.x, height, 0); |
385 |
|
else |
386 |
< |
XPutImage(x_display, drv->w, drv->gc, drv->img, 0, y1, 0, y1, VideoMonitor.mode.x, height); |
386 |
> |
XPutImage(x_display, drv->w, drv->gc, drv->img, 0, y1, 0, y1, mode.x, height); |
387 |
|
} |
388 |
|
mainBuffer.dirty = false; |
389 |
|
} |
397 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
398 |
|
static inline void update_display_dga_vosf(void) |
399 |
|
{ |
400 |
+ |
const video_mode &mode = drv->monitor.get_current_mode(); |
401 |
+ |
|
402 |
|
int page = 0; |
403 |
|
for (;;) { |
404 |
|
const unsigned first_page = find_next_page_set(page); |
417 |
|
const int y1 = mainBuffer.pageInfo[first_page].top; |
418 |
|
const int y2 = mainBuffer.pageInfo[page - 1].bottom; |
419 |
|
|
420 |
< |
const int bytes_per_row = VideoMonitor.mode.bytes_per_row; |
421 |
< |
const int bytes_per_pixel = VideoMonitor.mode.bytes_per_row / VideoMonitor.mode.x; |
420 |
> |
const int bytes_per_row = mode.bytes_per_row; |
421 |
> |
const int bytes_per_pixel = mode.bytes_per_row / mode.x; |
422 |
|
int i, j; |
423 |
|
|
424 |
|
// Check for first column from left and first column |
425 |
|
// from right that have changed |
426 |
< |
int x1 = VideoMonitor.mode.x * bytes_per_pixel - 1; |
426 |
> |
int x1 = mode.x * bytes_per_pixel - 1; |
427 |
|
for (j = y1; j <= y2; j++) { |
428 |
|
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
429 |
|
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
440 |
|
for (j = y2; j >= y1; j--) { |
441 |
|
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
442 |
|
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
443 |
< |
for (i = VideoMonitor.mode.x * bytes_per_pixel - 1; i > x2; i--) { |
443 |
> |
for (i = mode.x * bytes_per_pixel - 1; i > x2; i--) { |
444 |
|
if (p1[i] != p2[i]) { |
445 |
|
x2 = i; |
446 |
|
break; |