ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/SDL/video_sdl.cpp
(Generate patch)

Comparing BasiliskII/src/SDL/video_sdl.cpp (file contents):
Revision 1.24 by gbeauche, 2006-05-09T21:41:02Z vs.
Revision 1.28 by gbeauche, 2006-05-14T13:49:53Z

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines