1 |
|
/* |
2 |
|
* video_vosf.h - Video/graphics emulation, video on SEGV signals support |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2002 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2004 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 |
31 |
|
|
32 |
|
// Glue for SheepShaver and BasiliskII |
33 |
|
#if POWERPC_ROM |
34 |
< |
#define X11_MONITOR_INIT /* nothing */ |
34 |
> |
enum { |
35 |
> |
VIDEO_DEPTH_1BIT = APPLE_1_BIT, |
36 |
> |
VIDEO_DEPTH_2BIT = APPLE_2_BIT, |
37 |
> |
VIDEO_DEPTH_4BIT = APPLE_4_BIT, |
38 |
> |
VIDEO_DEPTH_8BIT = APPLE_8_BIT, |
39 |
> |
VIDEO_DEPTH_16BIT = APPLE_16_BIT, |
40 |
> |
VIDEO_DEPTH_32BIT = APPLE_32_BIT |
41 |
> |
}; |
42 |
> |
#else |
43 |
> |
enum { |
44 |
> |
VIDEO_DEPTH_1BIT = VDEPTH_1BIT, |
45 |
> |
VIDEO_DEPTH_2BIT = VDEPTH_2BIT, |
46 |
> |
VIDEO_DEPTH_4BIT = VDEPTH_4BIT, |
47 |
> |
VIDEO_DEPTH_8BIT = VDEPTH_8BIT, |
48 |
> |
VIDEO_DEPTH_16BIT = VDEPTH_16BIT, |
49 |
> |
VIDEO_DEPTH_32BIT = VDEPTH_32BIT |
50 |
> |
}; |
51 |
> |
#endif |
52 |
> |
#ifdef USE_SDL_VIDEO |
53 |
> |
#define MONITOR_INIT SDL_monitor_desc &monitor |
54 |
> |
#define VIDEO_DRV_INIT driver_window *drv |
55 |
> |
#define VIDEO_DRV_ROW_BYTES drv->s->pitch |
56 |
> |
#define VIDEO_DRV_LOCK_PIXELS if (SDL_MUSTLOCK(drv->s)) SDL_LockSurface(drv->s) |
57 |
> |
#define VIDEO_DRV_UNLOCK_PIXELS if (SDL_MUSTLOCK(drv->s)) SDL_UnlockSurface(drv->s) |
58 |
> |
#define VIDEO_MODE_INIT video_mode const & mode = drv->mode |
59 |
> |
#define VIDEO_MODE_ROW_BYTES mode.bytes_per_row |
60 |
> |
#define VIDEO_MODE_X mode.x |
61 |
> |
#define VIDEO_MODE_Y mode.y |
62 |
> |
#define VIDEO_MODE_DEPTH (int)mode.depth |
63 |
> |
#else |
64 |
> |
#if POWERPC_ROM |
65 |
> |
#define MONITOR_INIT /* nothing */ |
66 |
|
#define VIDEO_DRV_INIT /* nothing */ |
67 |
|
#define VIDEO_DRV_WINDOW the_win |
68 |
|
#define VIDEO_DRV_GC the_gc |
73 |
|
#define VIDEO_MODE_X mode.viXsize |
74 |
|
#define VIDEO_MODE_Y mode.viYsize |
75 |
|
#define VIDEO_MODE_DEPTH mode.viAppleMode |
45 |
– |
enum { |
46 |
– |
VIDEO_DEPTH_1BIT = APPLE_1_BIT, |
47 |
– |
VIDEO_DEPTH_2BIT = APPLE_2_BIT, |
48 |
– |
VIDEO_DEPTH_4BIT = APPLE_4_BIT, |
49 |
– |
VIDEO_DEPTH_8BIT = APPLE_8_BIT, |
50 |
– |
VIDEO_DEPTH_16BIT = APPLE_16_BIT, |
51 |
– |
VIDEO_DEPTH_32BIT = APPLE_32_BIT |
52 |
– |
}; |
76 |
|
#else |
77 |
< |
#define X11_MONITOR_INIT X11_monitor_desc &monitor |
77 |
> |
#define MONITOR_INIT X11_monitor_desc &monitor |
78 |
|
#define VIDEO_DRV_INIT driver_window *drv |
79 |
|
#define VIDEO_DRV_WINDOW drv->w |
80 |
|
#define VIDEO_DRV_GC drv->gc |
81 |
|
#define VIDEO_DRV_IMAGE drv->img |
82 |
|
#define VIDEO_DRV_HAVE_SHM drv->have_shm |
83 |
< |
#define VIDEO_MODE_INIT video_mode const & mode = drv->monitor.get_current_mode(); |
83 |
> |
#define VIDEO_MODE_INIT video_mode const & mode = drv->mode |
84 |
|
#define VIDEO_MODE_ROW_BYTES mode.bytes_per_row |
85 |
|
#define VIDEO_MODE_X mode.x |
86 |
|
#define VIDEO_MODE_Y mode.y |
87 |
|
#define VIDEO_MODE_DEPTH (int)mode.depth |
88 |
< |
enum { |
89 |
< |
VIDEO_DEPTH_1BIT = VDEPTH_1BIT, |
90 |
< |
VIDEO_DEPTH_2BIT = VDEPTH_2BIT, |
91 |
< |
VIDEO_DEPTH_4BIT = VDEPTH_4BIT, |
69 |
< |
VIDEO_DEPTH_8BIT = VDEPTH_8BIT, |
70 |
< |
VIDEO_DEPTH_16BIT = VDEPTH_16BIT, |
71 |
< |
VIDEO_DEPTH_32BIT = VDEPTH_32BIT |
72 |
< |
}; |
88 |
> |
#endif |
89 |
> |
#define VIDEO_DRV_LOCK_PIXELS /* nothing */ |
90 |
> |
#define VIDEO_DRV_UNLOCK_PIXELS /* nothing */ |
91 |
> |
#define VIDEO_DRV_ROW_BYTES VIDEO_DRV_IMAGE->bytes_per_line |
92 |
|
#endif |
93 |
|
|
94 |
|
// Variables for Video on SEGV support |
223 |
|
* Initialize the VOSF system (mainBuffer structure, SIGSEGV handler) |
224 |
|
*/ |
225 |
|
|
226 |
< |
static bool video_vosf_init(X11_MONITOR_INIT) |
226 |
> |
static bool video_vosf_init(MONITOR_INIT) |
227 |
|
{ |
228 |
|
VIDEO_MODE_INIT; |
229 |
|
|
332 |
|
* Update display for Windowed mode and VOSF |
333 |
|
*/ |
334 |
|
|
316 |
– |
// From video_blit.cpp |
317 |
– |
extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length); |
318 |
– |
extern bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order, int mac_depth); |
319 |
– |
extern uint32 ExpandMap[256]; |
320 |
– |
|
335 |
|
/* How can we deal with array overrun conditions ? |
336 |
|
|
337 |
|
The state of the framebuffer pages that have been touched are maintained |
387 |
|
const int y1 = mainBuffer.pageInfo[first_page].top; |
388 |
|
const int y2 = mainBuffer.pageInfo[page - 1].bottom; |
389 |
|
const int height = y2 - y1 + 1; |
390 |
< |
|
390 |
> |
|
391 |
> |
VIDEO_DRV_LOCK_PIXELS; |
392 |
> |
|
393 |
|
if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) { |
394 |
|
|
395 |
|
// Update the_host_buffer and copy of the_buffer |
396 |
|
const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES; |
397 |
< |
const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line; |
397 |
> |
const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES; |
398 |
|
const int pixels_per_byte = VIDEO_MODE_X / src_bytes_per_row; |
399 |
|
int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j; |
400 |
|
for (j = y1; j <= y2; j++) { |
407 |
|
|
408 |
|
// Update the_host_buffer and copy of the_buffer |
409 |
|
const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES; |
410 |
< |
const int dst_bytes_per_row = VIDEO_DRV_IMAGE->bytes_per_line; |
410 |
> |
const int dst_bytes_per_row = VIDEO_DRV_ROW_BYTES; |
411 |
|
const int bytes_per_pixel = src_bytes_per_row / VIDEO_MODE_X; |
412 |
|
int i1 = y1 * src_bytes_per_row, i2 = y1 * dst_bytes_per_row, j; |
413 |
|
for (j = y1; j <= y2; j++) { |
417 |
|
} |
418 |
|
} |
419 |
|
|
420 |
+ |
VIDEO_DRV_UNLOCK_PIXELS; |
421 |
+ |
|
422 |
+ |
#ifdef USE_SDL_VIDEO |
423 |
+ |
SDL_UpdateRect(drv->s, 0, y1, VIDEO_MODE_X, height); |
424 |
+ |
#else |
425 |
|
if (VIDEO_DRV_HAVE_SHM) |
426 |
|
XShmPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height, 0); |
427 |
|
else |
428 |
|
XPutImage(x_display, VIDEO_DRV_WINDOW, VIDEO_DRV_GC, VIDEO_DRV_IMAGE, 0, y1, 0, y1, VIDEO_MODE_X, height); |
429 |
+ |
#endif |
430 |
|
} |
431 |
|
mainBuffer.dirty = false; |
432 |
|
} |
494 |
|
|
495 |
|
// Update the_host_buffer and copy of the_buffer |
496 |
|
// There should be at least one pixel to copy |
497 |
+ |
VIDEO_DRV_LOCK_PIXELS; |
498 |
|
const int width = x2 - x1 + 1; |
499 |
|
i = y1 * bytes_per_row + x1 * bytes_per_pixel; |
500 |
|
for (j = y1; j <= y2; j++) { |
502 |
|
memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width); |
503 |
|
i += bytes_per_row; |
504 |
|
} |
505 |
+ |
VIDEO_DRV_UNLOCK_PIXELS; |
506 |
|
} |
507 |
|
mainBuffer.dirty = false; |
508 |
|
} |