1984 |
|
} |
1985 |
|
} |
1986 |
|
|
1987 |
+ |
// Static display update (fixed frame rate, bounding boxes based) |
1988 |
+ |
// XXX use NQD bounding boxes to help detect dirty areas? |
1989 |
+ |
static void update_display_static_bbox(driver_window *drv) |
1990 |
+ |
{ |
1991 |
+ |
const VIDEO_MODE &mode = drv->mode; |
1992 |
+ |
|
1993 |
+ |
// Allocate bounding boxes for SDL_UpdateRects() |
1994 |
+ |
const int N_PIXELS = 64; |
1995 |
+ |
const int n_x_boxes = (VIDEO_MODE_X + N_PIXELS - 1) / N_PIXELS; |
1996 |
+ |
const int n_y_boxes = (VIDEO_MODE_Y + N_PIXELS - 1) / N_PIXELS; |
1997 |
+ |
SDL_Rect *boxes = (SDL_Rect *)alloca(sizeof(SDL_Rect) * n_x_boxes * n_y_boxes); |
1998 |
+ |
int nr_boxes = 0; |
1999 |
+ |
|
2000 |
+ |
// Lock surface, if required |
2001 |
+ |
if (SDL_MUSTLOCK(drv->s)) |
2002 |
+ |
SDL_LockSurface(drv->s); |
2003 |
+ |
|
2004 |
+ |
// Update the surface from Mac screen |
2005 |
+ |
const int bytes_per_row = VIDEO_MODE_ROW_BYTES; |
2006 |
+ |
const int bytes_per_pixel = bytes_per_row / VIDEO_MODE_X; |
2007 |
+ |
int x, y; |
2008 |
+ |
for (y = 0; y < VIDEO_MODE_Y; y += N_PIXELS) { |
2009 |
+ |
int h = N_PIXELS; |
2010 |
+ |
if (h > VIDEO_MODE_Y - y) |
2011 |
+ |
h = VIDEO_MODE_Y - y; |
2012 |
+ |
for (x = 0; x < VIDEO_MODE_X; x += N_PIXELS) { |
2013 |
+ |
int w = N_PIXELS; |
2014 |
+ |
if (w > VIDEO_MODE_X - x) |
2015 |
+ |
w = VIDEO_MODE_X - x; |
2016 |
+ |
const int xs = w * bytes_per_pixel; |
2017 |
+ |
const int xb = x * bytes_per_pixel; |
2018 |
+ |
bool dirty = false; |
2019 |
+ |
for (int j = y; j < (y + h); j++) { |
2020 |
+ |
const int yb = j * bytes_per_row; |
2021 |
+ |
if (memcmp(&the_buffer[yb + xb], &the_buffer_copy[yb + xb], xs) != 0) { |
2022 |
+ |
memcpy(&the_buffer_copy[yb + xb], &the_buffer[yb + xb], xs); |
2023 |
+ |
Screen_blit((uint8 *)drv->s->pixels + yb + xb, the_buffer + yb + xb, xs); |
2024 |
+ |
dirty = true; |
2025 |
+ |
} |
2026 |
+ |
} |
2027 |
+ |
if (dirty) { |
2028 |
+ |
boxes[nr_boxes].x = x; |
2029 |
+ |
boxes[nr_boxes].y = y; |
2030 |
+ |
boxes[nr_boxes].w = w; |
2031 |
+ |
boxes[nr_boxes].h = h; |
2032 |
+ |
nr_boxes++; |
2033 |
+ |
} |
2034 |
+ |
} |
2035 |
+ |
} |
2036 |
+ |
|
2037 |
+ |
// Unlock surface, if required |
2038 |
+ |
if (SDL_MUSTLOCK(drv->s)) |
2039 |
+ |
SDL_UnlockSurface(drv->s); |
2040 |
+ |
|
2041 |
+ |
// Refresh display |
2042 |
+ |
if (nr_boxes) |
2043 |
+ |
SDL_UpdateRects(drv->s, nr_boxes, boxes); |
2044 |
+ |
} |
2045 |
+ |
|
2046 |
|
|
2047 |
|
// We suggest the compiler to inline the next two functions so that it |
2048 |
|
// may specialise the code according to the current screen depth and |
2137 |
|
static int tick_counter = 0; |
2138 |
|
if (++tick_counter >= frame_skip) { |
2139 |
|
tick_counter = 0; |
2140 |
< |
update_display_static(static_cast<driver_window *>(drv)); |
2140 |
> |
const VIDEO_MODE &mode = drv->mode; |
2141 |
> |
if ((int)VIDEO_MODE_DEPTH >= VIDEO_DEPTH_8BIT) |
2142 |
> |
update_display_static_bbox(static_cast<driver_window *>(drv)); |
2143 |
> |
else |
2144 |
> |
update_display_static(static_cast<driver_window *>(drv)); |
2145 |
|
} |
2146 |
|
} |
2147 |
|
|
2246 |
|
return 0; |
2247 |
|
} |
2248 |
|
#endif |
2249 |
+ |
|
2250 |
+ |
|
2251 |
+ |
/* |
2252 |
+ |
* Record dirty area from NQD |
2253 |
+ |
*/ |
2254 |
+ |
|
2255 |
+ |
#ifdef SHEEPSHAVER |
2256 |
+ |
void video_set_dirty_area(int x, int y, int w, int h) |
2257 |
+ |
{ |
2258 |
+ |
const VIDEO_MODE &mode = drv->mode; |
2259 |
+ |
const int screen_width = VIDEO_MODE_X; |
2260 |
+ |
const int screen_height = VIDEO_MODE_Y; |
2261 |
+ |
const int bytes_per_row = VIDEO_MODE_ROW_BYTES; |
2262 |
+ |
|
2263 |
+ |
#ifdef ENABLE_VOSF |
2264 |
+ |
if (use_vosf) { |
2265 |
+ |
vosf_set_dirty_area(x, y, w, h, screen_width, screen_height, bytes_per_row); |
2266 |
+ |
return; |
2267 |
+ |
} |
2268 |
+ |
#endif |
2269 |
+ |
|
2270 |
+ |
// XXX handle dirty bounding boxes for non-VOSF modes |
2271 |
+ |
} |
2272 |
+ |
#endif |