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.4 by gbeauche, 2004-06-24T15:25:57Z vs.
Revision 1.6 by gbeauche, 2004-06-24T22:38:42Z

# Line 35 | Line 35
35   *  - Events processing is bound to the general emulation thread as SDL requires
36   *    to PumpEvents() within the same thread as the one that called SetVideoMode().
37   *    Besides, there can't seem to be a way to call SetVideoMode() from a child thread.
38 + *  - Refresh performance is still slow. Use SDL_CreateRGBSurface()?
39 + *  - Backport hw cursor acceleration to Basilisk II?
40 + *  - Move generic Native QuickDraw acceleration routines to gfxaccel.cpp
41   */
42  
43   #include "sysdeps.h"
# Line 114 | Line 117 | static int keycode_table[256];                                         // X
117  
118   // SDL variables
119   static int screen_depth;                                                        // Depth of current screen
120 + static SDL_Cursor *sdl_cursor;                                          // Copy of Mac cursor
121 + static volatile bool cursor_changed = false;            // Flag: cursor changed, redraw_func must update the cursor
122   static SDL_Color sdl_palette[256];                                      // Color palette to be used as CLUT and gamma table
123   static bool sdl_palette_changed = false;                        // Flag: Palette changed, redraw thread must set new colors
124   static const int sdl_eventmask = SDL_MOUSEBUTTONDOWNMASK | SDL_MOUSEBUTTONUPMASK | SDL_MOUSEMOTIONMASK | SDL_KEYUPMASK | SDL_KEYDOWNMASK | SDL_VIDEOEXPOSEMASK | SDL_QUITMASK;
# Line 342 | Line 347 | static int sdl_depth_of_video_depth(int
347          return depth;
348   }
349  
350 < // Add mode to list of supported modes
351 < static void add_mode(int type, int width, int height, int resolution_id, int bytes_per_row, int depth)
350 > // Check wether specified mode is available
351 > static bool has_mode(int type, int width, int height)
352   {
353 <        VIDEO_MODE mode;
353 >        // FIXME: no fullscreen support yet
354 >        if (type == DISPLAY_SCREEN)
355 >                return false;
356 >
357   #ifdef SHEEPSHAVER
358 <        // Don't add 512x384 modes
358 >        // Filter out Classic resolutiosn
359          if (width == 512 && height == 384)
360 +                return false;
361 +
362 +        // Read window modes prefs
363 +        static uint32 window_modes = 0;
364 +        static uint32 screen_modes = 0;
365 +        if (window_modes == 0 || screen_modes == 0) {
366 +                window_modes = PrefsFindInt32("windowmodes");
367 +                screen_modes = PrefsFindInt32("screenmodes");
368 +                if (window_modes == 0 || screen_modes == 0)
369 +                        window_modes |= 3;                      // Allow at least 640x480 and 800x600 window modes
370 +        }
371 +
372 +        if (type == DISPLAY_WINDOW) {
373 +                int apple_mask, apple_id = find_apple_resolution(width, height);
374 +                switch (apple_id) {
375 +                case APPLE_640x480:             apple_mask = 0x01; break;
376 +                case APPLE_800x600:             apple_mask = 0x02; break;
377 +                case APPLE_1024x768:    apple_mask = 0x04; break;
378 +                case APPLE_1152x768:    apple_mask = 0x40; break;
379 +                case APPLE_1152x900:    apple_mask = 0x08; break;
380 +                case APPLE_1280x1024:   apple_mask = 0x10; break;
381 +                case APPLE_1600x1200:   apple_mask = 0x20; break;
382 +                default:                                apple_mask = 0x00; break;
383 +                }
384 +                return (window_modes & apple_mask);
385 +        }
386 + #else
387 +        return true;
388 + #endif
389 +        return false;
390 + }
391 +
392 + // Add mode to list of supported modes
393 + static void add_mode(int type, int width, int height, int resolution_id, int bytes_per_row, int depth)
394 + {
395 +        // Filter out unsupported modes
396 +        if (!has_mode(type, width, height))
397                  return;
398  
399 +        // Fill in VideoMode entry
400 +        VIDEO_MODE mode;
401 + #ifdef SHEEPSHAVER
402          // Recalculate dimensions to fit Apple modes
403          resolution_id = match_apple_resolution(width, height);
404          mode.viType = type;
# Line 584 | Line 632 | driver_window::driver_window(SDL_monitor
632          D(bug("the_buffer = %p, the_buffer_copy = %p\n", the_buffer, the_buffer_copy));
633   #endif
634  
635 <        // Set window name/class
636 <        set_window_name(STR_WINDOW_TITLE);
637 <
635 > #ifdef SHEEPSHAVER
636 >        // Create cursor
637 >        if ((sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, 0, 0)) != NULL) {
638 >                SDL_SetCursor(sdl_cursor);
639 >                cursor_changed = false;
640 >        }
641 > #else
642          // Hide cursor
643          SDL_ShowCursor(0);
644 + #endif
645 +
646 +        // Set window name/class
647 +        set_window_name(STR_WINDOW_TITLE);
648  
649          // Init blitting routines
650          SDL_PixelFormat *f = s->format;
# Line 748 | Line 804 | bool SDL_monitor_desc::video_open(void)
804   {
805          D(bug("video_open()\n"));
806          const VIDEO_MODE &mode = get_current_mode();
807 + #if DEBUG
808 +        D(bug("Current video mode:\n"));
809 +        D(bug(" %dx%d (ID %02x), %d bpp\n", VIDEO_MODE_X, VIDEO_MODE_Y, VIDEO_MODE_RESOLUTION, 1 << (VIDEO_MODE_DEPTH & 0x0f)));
810 + #endif
811  
812          // Create display driver object of requested type
813          switch (display_type) {
# Line 820 | Line 880 | bool VideoInit(bool classic)
880          mouse_wheel_lines = PrefsFindInt32("mousewheellines");
881  
882          // Get screen mode from preferences
883 <        const char *mode_str;
883 >        const char *mode_str = NULL;
884 > #ifndef SHEEPSHAVER
885          if (classic_mode)
886                  mode_str = "win/512/342";
887          else
888                  mode_str = PrefsFindString("screen");
889 + #endif
890  
891          // Determine display type and default dimensions
892          int default_width, default_height;
# Line 842 | Line 904 | bool VideoInit(bool classic)
904                          display_type = DISPLAY_WINDOW;
905          }
906          int max_width = 640, max_height = 480;
907 <        if (display_type == DISPLAY_SCREEN) {
908 <                SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
909 <                if (modes && modes != (SDL_Rect **)-1) {
910 <                        max_width = modes[0]->w;
911 <                        max_height = modes[0]->h;
912 <                }
907 >        SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
908 >        if (modes && modes != (SDL_Rect **)-1) {
909 >                max_width = modes[0]->w;
910 >                max_height = modes[0]->h;
911 >                if (default_width > max_width)
912 >                        default_width = max_width;
913 >                if (default_height > max_height)
914 >                        default_height = max_height;
915          }
916          if (default_width <= 0)
917                  default_width = max_width;
# Line 914 | Line 978 | bool VideoInit(bool classic)
978          }
979  
980   #ifdef SHEEPSHAVER
981 <        for (int i = 0; i < VideoModes.size(); ++i)
981 >        for (int i = 0; i < VideoModes.size(); i++)
982                  VModes[i] = VideoModes[i];
983 <
984 <        const VIDEO_MODE & mode = VideoModes[cur_mode];
985 <        D(bug("Current video mode\n"));
986 <        D(bug(" %dx%d (ID %02x), %d bpp\n", VIDEO_MODE_X, VIDEO_MODE_Y, VIDEO_MODE_RESOLUTION, 1 << (VIDEO_MODE_DEPTH - 0x80)));
983 >        VideoInfo *p = &VModes[VideoModes.size()];
984 >        p->viType = DIS_INVALID;        // End marker
985 >        p->viRowBytes = 0;
986 >        p->viXsize = p->viYsize = 0;
987 >        p->viAppleMode = 0;
988 >        p->viAppleID = 0;
989   #endif
990  
991   #if DEBUG
# Line 1168 | Line 1234 | void SDL_monitor_desc::switch_to_current
1234   #ifdef SHEEPSHAVER
1235   bool video_can_change_cursor(void)
1236   {
1237 < //      return hw_mac_cursor_accl && (display_type != DISPLAY_SCREEN);
1172 <        return false;
1237 >        return (display_type == DISPLAY_WINDOW);
1238   }
1239   #endif
1240  
# Line 1181 | Line 1246 | bool video_can_change_cursor(void)
1246   #ifdef SHEEPSHAVER
1247   void video_set_cursor(void)
1248   {
1249 < //      cursor_changed = true;
1249 >        cursor_changed = true;
1250   }
1251   #endif
1252  
# Line 2105 | Line 2170 | static int redraw_func(void *arg)
2170                  // Refresh display
2171                  video_refresh();
2172  
2173 + #ifdef SHEEPSHAVER
2174 +                // Set new cursor image if it was changed
2175 +                if (cursor_changed && sdl_cursor) {
2176 +                        cursor_changed = false;
2177 +                        SDL_FreeCursor(sdl_cursor);
2178 +                        sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]);
2179 +                        if (sdl_cursor)
2180 +                                SDL_SetCursor(sdl_cursor);
2181 +                }
2182 + #endif
2183 +
2184                  // Set new palette if it was changed
2185                  handle_palette_changes();
2186          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines