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.19 by gbeauche, 2005-06-06T21:20:28Z vs.
Revision 1.20 by gbeauche, 2005-06-14T22:35:42Z

# Line 101 | Line 101 | static uint8 *the_buffer_copy = NULL;
101   static uint32 the_buffer_size;                                          // Size of allocated the_buffer
102  
103   static bool redraw_thread_active = false;                       // Flag: Redraw thread installed
104 + #ifndef USE_CPU_EMUL_SERVICES
105   static volatile bool redraw_thread_cancel;                      // Flag: Cancel Redraw thread
106   static SDL_Thread *redraw_thread = NULL;                        // Redraw thread
107 + #ifdef SHEEPSHAVER
108   static volatile bool thread_stop_req = false;
109   static volatile bool thread_stop_ack = false;           // Acknowledge for thread_stop_req
110 + #endif
111 + #endif
112  
113   #ifdef ENABLE_VOSF
114   static bool use_vosf = false;                                           // Flag: VOSF enabled
# Line 1006 | Line 1010 | bool SDL_monitor_desc::video_open(void)
1010          LOCK_FRAME_BUFFER;
1011  
1012          // Start redraw/input thread
1013 + #ifndef USE_CPU_EMUL_SERVICES
1014          redraw_thread_cancel = false;
1015          redraw_thread_active = ((redraw_thread = SDL_CreateThread(redraw_func, NULL)) != NULL);
1016          if (!redraw_thread_active) {
1017                  printf("FATAL: cannot create redraw thread\n");
1018                  return false;
1019          }
1020 + #else
1021 +        redraw_thread_active = true;
1022 + #endif
1023          return true;
1024   }
1025  
# Line 1228 | Line 1236 | void SDL_monitor_desc::video_close(void)
1236          D(bug("video_close()\n"));
1237  
1238          // Stop redraw thread
1239 + #ifndef USE_CPU_EMUL_SERVICES
1240          if (redraw_thread_active) {
1241                  redraw_thread_cancel = true;
1242                  SDL_WaitThread(redraw_thread, NULL);
1243          }
1244 + #endif
1245          redraw_thread_active = false;
1246  
1247          // Unlock frame buffer
# Line 2035 | Line 2045 | static void VideoRefreshInit(void)
2045          }
2046   }
2047  
2048 + static inline void do_video_refresh(void)
2049 + {
2050 +        // Handle SDL events
2051 +        handle_events();
2052 +
2053 +        // Update display
2054 +        video_refresh();
2055 +
2056 + #ifdef SHEEPSHAVER
2057 +        // Set new cursor image if it was changed
2058 +        if (cursor_changed && sdl_cursor) {
2059 +                cursor_changed = false;
2060 +                SDL_FreeCursor(sdl_cursor);
2061 +                sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]);
2062 +                if (sdl_cursor)
2063 +                        SDL_SetCursor(sdl_cursor);
2064 +        }
2065 + #endif
2066 +
2067 +        // Set new palette if it was changed
2068 +        handle_palette_changes();
2069 + }
2070 +
2071 + // This function is called on non-threaded platforms from a timer interrupt
2072 + void VideoRefresh(void)
2073 + {
2074 +        // We need to check redraw_thread_active to inhibit refreshed during
2075 +        // mode changes on non-threaded platforms
2076 +        if (!redraw_thread_active)
2077 +                return;
2078 +
2079 +        // Process pending events and update display
2080 +        do_video_refresh();
2081 + }
2082 +
2083   const int VIDEO_REFRESH_HZ = 60;
2084   const int VIDEO_REFRESH_DELAY = 1000000 / VIDEO_REFRESH_HZ;
2085  
2086 + #ifndef USE_CPU_EMUL_SERVICES
2087   static int redraw_func(void *arg)
2088   {
2089          uint64 start = GetTicks_usec();
# Line 2063 | Line 2109 | static int redraw_func(void *arg)
2109                  }
2110   #endif
2111  
2112 <                // Handle SDL events
2113 <                handle_events();
2068 <
2069 <                // Refresh display
2070 <                video_refresh();
2071 <
2072 < #ifdef SHEEPSHAVER
2073 <                // Set new cursor image if it was changed
2074 <                if (cursor_changed && sdl_cursor) {
2075 <                        cursor_changed = false;
2076 <                        SDL_FreeCursor(sdl_cursor);
2077 <                        sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]);
2078 <                        if (sdl_cursor)
2079 <                                SDL_SetCursor(sdl_cursor);
2080 <                }
2081 < #endif
2082 <
2083 <                // Set new palette if it was changed
2084 <                handle_palette_changes();
2112 >                // Process pending events and update display
2113 >                do_video_refresh();
2114          }
2115  
2116          uint64 end = GetTicks_usec();
2117          D(bug("%lld refreshes in %lld usec = %f refreshes/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start)));
2118          return 0;
2119   }
2120 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines