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.36 by asvitkine, 2008-06-25T02:52:52Z vs.
Revision 1.42 by asvitkine, 2011-12-28T22:15:10Z

# Line 66 | Line 66
66   #define DEBUG 0
67   #include "debug.h"
68  
69 + #if (defined(__APPLE__) && defined(__MACH__))
70 + extern "C" {
71 +        void NSAutoReleasePool_wrap(void (*fn)(void));
72 + }
73 + #endif
74  
75   // Supported video modes
76   using std::vector;
# Line 625 | Line 630 | public:
630   class driver_window;
631   static void update_display_window_vosf(driver_window *drv);
632   static void update_display_dynamic(int ticker, driver_window *drv);
633 < static void update_display_static(driver_window *drv);
633 > static void update_display_static(driver_base *drv);
634  
635   class driver_window : public driver_base {
636          friend void update_display_window_vosf(driver_window *drv);
637          friend void update_display_dynamic(int ticker, driver_window *drv);
638 <        friend void update_display_static(driver_window *drv);
638 >        friend void update_display_static(driver_base *drv);
639  
640   public:
641          driver_window(SDL_monitor_desc &monitor);
# Line 1238 | Line 1243 | bool VideoInit(bool classic)
1243                                  continue;
1244                          if (w == 512 && h == 384)
1245                                  continue;
1241 #ifdef ENABLE_VOSF
1246                          for (int d = VIDEO_DEPTH_1BIT; d <= default_depth; d++)
1247                                  add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)d), d);
1244 #else
1245                        add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)default_depth), default_depth);
1246 #endif
1248                  }
1249          }
1250  
# Line 1770 | Line 1771 | static void handle_events(void)
1771                          // Mouse button
1772                          case SDL_MOUSEBUTTONDOWN: {
1773                                  unsigned int button = event.button.button;
1774 <                                if (button < 4)
1775 <                                        ADBMouseDown(button - 1);
1774 >                                if (button == SDL_BUTTON_LEFT)
1775 >                                        ADBMouseDown(0);
1776 >                                else if (button == SDL_BUTTON_RIGHT)
1777 >                                        ADBMouseDown(1);
1778 >                                else if (button == SDL_BUTTON_MIDDLE)
1779 >                                        ADBMouseDown(2);
1780                                  else if (button < 6) {  // Wheel mouse
1781                                          if (mouse_wheel_mode == 0) {
1782                                                  int key = (button == 5) ? 0x79 : 0x74;  // Page up/down
# Line 1789 | Line 1794 | static void handle_events(void)
1794                          }
1795                          case SDL_MOUSEBUTTONUP: {
1796                                  unsigned int button = event.button.button;
1797 <                                if (button < 4)
1798 <                                        ADBMouseUp(button - 1);
1797 >                                if (button == SDL_BUTTON_LEFT)
1798 >                                        ADBMouseUp(0);
1799 >                                else if (button == SDL_BUTTON_RIGHT)
1800 >                                        ADBMouseUp(1);
1801 >                                else if (button == SDL_BUTTON_MIDDLE)
1802 >                                        ADBMouseUp(2);
1803                                  break;
1804                          }
1805  
# Line 1889 | Line 1898 | static void handle_events(void)
1898   */
1899  
1900   // Static display update (fixed frame rate, but incremental)
1901 < static void update_display_static(driver_window *drv)
1901 > static void update_display_static(driver_base *drv)
1902   {
1903          // Incremental update code
1904          int wide = 0, high = 0, x1, x2, y1, y2, i, j;
# Line 1978 | Line 1987 | static void update_display_static(driver
1987  
1988                  } else {
1989                          const int bytes_per_pixel = VIDEO_MODE_ROW_BYTES / VIDEO_MODE_X;
1990 +                        const int dst_bytes_per_row = drv->s->pitch;
1991  
1992                          x1 = VIDEO_MODE_X;
1993                          for (j=y1; j<=y2; j++) {
# Line 2018 | Line 2028 | static void update_display_static(driver
2028                                  // Blit to screen surface
2029                                  for (j=y1; j<=y2; j++) {
2030                                          i = j * bytes_per_row + x1 * bytes_per_pixel;
2031 +                                        int dst_i = j * dst_bytes_per_row + x1 * bytes_per_pixel;
2032                                          memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * wide);
2033 <                                        Screen_blit((uint8 *)drv->s->pixels + i, the_buffer + i, bytes_per_pixel * wide);
2033 >                                        Screen_blit((uint8 *)drv->s->pixels + dst_i, the_buffer + i, bytes_per_pixel * wide);
2034                                  }
2035  
2036                                  // Unlock surface, if required
# Line 2035 | Line 2046 | static void update_display_static(driver
2046  
2047   // Static display update (fixed frame rate, bounding boxes based)
2048   // XXX use NQD bounding boxes to help detect dirty areas?
2049 < static void update_display_static_bbox(driver_window *drv)
2049 > static void update_display_static_bbox(driver_base *drv)
2050   {
2051          const VIDEO_MODE &mode = drv->mode;
2052  
# Line 2053 | Line 2064 | static void update_display_static_bbox(d
2064          // Update the surface from Mac screen
2065          const int bytes_per_row = VIDEO_MODE_ROW_BYTES;
2066          const int bytes_per_pixel = bytes_per_row / VIDEO_MODE_X;
2067 +        const int dst_bytes_per_row = drv->s->pitch;
2068          int x, y;
2069          for (y = 0; y < VIDEO_MODE_Y; y += N_PIXELS) {
2070                  int h = N_PIXELS;
# Line 2067 | Line 2079 | static void update_display_static_bbox(d
2079                          bool dirty = false;
2080                          for (int j = y; j < (y + h); j++) {
2081                                  const int yb = j * bytes_per_row;
2082 +                                const int dst_yb = j * dst_bytes_per_row;
2083                                  if (memcmp(&the_buffer[yb + xb], &the_buffer_copy[yb + xb], xs) != 0) {
2084                                          memcpy(&the_buffer_copy[yb + xb], &the_buffer[yb + xb], xs);
2085 <                                        Screen_blit((uint8 *)drv->s->pixels + yb + xb, the_buffer + yb + xb, xs);
2085 >                                        Screen_blit((uint8 *)drv->s->pixels + dst_yb + xb, the_buffer + yb + xb, xs);
2086                                          dirty = true;
2087                                  }
2088                          }
# Line 2133 | Line 2146 | static inline void handle_palette_change
2146          UNLOCK_PALETTE;
2147   }
2148  
2149 + static void video_refresh_window_static(void);
2150 +
2151   static void video_refresh_dga(void)
2152   {
2153          // Quit DGA mode if requested
2154          possibly_quit_dga_mode();
2155 +        video_refresh_window_static();
2156   }
2157  
2158   #ifdef ENABLE_VOSF
# Line 2188 | Line 2204 | static void video_refresh_window_static(
2204                  tick_counter = 0;
2205                  const VIDEO_MODE &mode = drv->mode;
2206                  if ((int)VIDEO_MODE_DEPTH >= VIDEO_DEPTH_8BIT)
2207 <                        update_display_static_bbox(static_cast<driver_window *>(drv));
2207 >                        update_display_static_bbox(drv);
2208                  else
2209 <                        update_display_static(static_cast<driver_window *>(drv));
2209 >                        update_display_static(drv);
2210          }
2211   }
2212  
# Line 2226 | Line 2242 | static inline void do_video_refresh(void
2242          handle_events();
2243  
2244          // Update display
2245 + #if (defined(__APPLE__) && defined(__MACH__))
2246 +        // SDL expects an auto-release pool to be present.
2247 +        NSAutoReleasePool_wrap(video_refresh);
2248 + #else
2249          video_refresh();
2250 + #endif
2251  
2252   #ifdef SHEEPSHAVER
2253          // Set new cursor image if it was changed
# Line 2316 | Line 2337 | static int redraw_func(void *arg)
2337   #ifdef SHEEPSHAVER
2338   void video_set_dirty_area(int x, int y, int w, int h)
2339   {
2340 + #ifdef ENABLE_VOSF
2341          const VIDEO_MODE &mode = drv->mode;
2342          const int screen_width = VIDEO_MODE_X;
2343          const int screen_height = VIDEO_MODE_Y;
2344          const int bytes_per_row = VIDEO_MODE_ROW_BYTES;
2345  
2324 #ifdef ENABLE_VOSF
2346          if (use_vosf) {
2347                  vosf_set_dirty_area(x, y, w, h, screen_width, screen_height, bytes_per_row);
2348                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines