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

Comparing BasiliskII/src/Unix/video_x.cpp (file contents):
Revision 1.8 by cebix, 1999-10-21T16:07:36Z vs.
Revision 1.12 by cebix, 1999-11-03T21:04:23Z

# Line 52 | Line 52
52   #include <X11/extensions/xf86dga.h>
53   #endif
54  
55 + #if ENABLE_XF86_VIDMODE
56 + #include <X11/extensions/xf86vmode.h>
57 + #endif
58 +
59   #if ENABLE_FBDEV_DGA
60   #include <sys/mman.h>
61   #endif
# Line 71 | Line 75 | const char FBDEVICES_FILE_NAME[] = DATAD
75  
76  
77   // Global variables
78 < static int32 frame_skip;
78 > static int32 frame_skip;                                                        // Prefs items
79 > static int16 mouse_wheel_mode = 1;
80 > static int16 mouse_wheel_lines = 3;
81 >
82   static int display_type = DISPLAY_WINDOW;                       // See enum above
83   static uint8 *the_buffer;                                                       // Mac frame buffer
84   static bool redraw_thread_active = false;                       // Flag: Redraw thread installed
# Line 79 | Line 86 | static volatile bool redraw_thread_cance
86   static pthread_t redraw_thread;                                         // Redraw thread
87  
88   static bool has_dga = false;                                            // Flag: Video DGA capable
89 + static bool has_vidmode = false;                                        // Flag: VidMode extension available
90  
91   static bool ctrl_down = false;                                          // Flag: Ctrl key pressed
92   static bool caps_on = false;                                            // Flag: Caps Lock on
# Line 131 | Line 139 | static pthread_mutex_t frame_buffer_lock
139   const char FBDEVICE_FILE_NAME[] = "/dev/fb";
140   static int fbdev_fd;
141  
142 + #if ENABLE_XF86_VIDMODE
143 + // Variables for XF86 VidMode support
144 + static XF86VidModeModeInfo **x_video_modes;                     // Array of all available modes
145 + static int num_x_video_modes;
146 + #endif
147 +
148  
149   // Prototypes
150   static void *redraw_func(void *arg);
# Line 340 | Line 354 | static bool init_fbdev_dga(char *in_fb_n
354          int ndepths, max_depth(0);
355          int *depths = XListDepths(x_display, screen, &ndepths);
356          if (depths == NULL) {
357 <                fprintf(stderr, "Error: could not determine the maximal depth available\n");
357 >                printf("FATAL: Could not determine the maximal depth available\n");
358                  return false;
359          } else {
360                  while (ndepths-- > 0) {
# Line 429 | Line 443 | static bool init_fbdev_dga(char *in_fb_n
443          
444          // Set colormap
445          if (depth == 8) {
446 <                XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap = 0]);
446 >                XSetWindowColormap(x_display, the_win, cmap[0]);
447                  XSetWMColormapWindows(x_display, the_win, &the_win, 1);
448          }
449          
# Line 465 | Line 479 | static bool init_fbdev_dga(char *in_fb_n
479   #else
480          VideoMonitor.mac_frame_base = MacFrameBaseMac;
481   #endif
468        
469        printf("FbDev DGA with %s in %d-bit mode enabled\n", fb_name, fb_depth);
482          return true;
483   #else
484          ErrorAlert("Basilisk II has been compiled with fbdev DGA support disabled.");
# Line 481 | Line 493 | static bool init_xf86_dga(int width, int
493          // Set relative mouse mode
494          ADBSetRelMouseMode(true);
495  
496 + #if ENABLE_XF86_VIDMODE
497 +        // Switch to best mode
498 +        if (has_vidmode) {
499 +                int best = 0;
500 +                for (int i=1; i<num_x_video_modes; i++) {
501 +                        if (x_video_modes[i]->hdisplay >= width && x_video_modes[i]->vdisplay >= height &&
502 +                                x_video_modes[i]->hdisplay <= x_video_modes[best]->hdisplay && x_video_modes[i]->vdisplay <= x_video_modes[best]->vdisplay) {
503 +                                best = i;
504 +                        }
505 +                }
506 +                XF86VidModeSwitchToMode(x_display, screen, x_video_modes[best]);
507 +                XF86VidModeSetViewPort(x_display, screen, 0, 0);
508 +        }
509 + #endif
510 +
511          // Create window
512          XSetWindowAttributes wattr;
513          wattr.event_mask = eventmask = dga_eventmask;
# Line 613 | Line 640 | bool VideoInit(bool classic)
640          // Init keycode translation
641          keycode_init();
642  
643 +        // Read prefs
644 +        mouse_wheel_mode = PrefsFindInt16("mousewheelmode");
645 +        mouse_wheel_lines = PrefsFindInt16("mousewheellines");
646 +
647          // Find screen and root window
648          screen = XDefaultScreen(x_display);
649          rootwin = XRootWindow(x_display, screen);
# Line 630 | Line 661 | bool VideoInit(bool classic)
661          else
662                  has_dga = false;
663   #endif
664 <        
664 >
665   #if ENABLE_XF86_DGA
666          // DGA available?
667 <        int event_base, error_base;
668 <        if (XF86DGAQueryExtension(x_display, &event_base, &error_base)) {
667 >        int dga_event_base, dga_error_base;
668 >        if (XF86DGAQueryExtension(x_display, &dga_event_base, &dga_error_base)) {
669                  int dga_flags = 0;
670                  XF86DGAQueryDirectVideo(x_display, screen, &dga_flags);
671                  has_dga = dga_flags & XF86DGADirectPresent;
# Line 642 | Line 673 | bool VideoInit(bool classic)
673                  has_dga = false;
674   #endif
675  
676 + #if ENABLE_XF86_VIDMODE
677 +        // VidMode available?
678 +        int vm_event_base, vm_error_base;
679 +        has_vidmode = XF86VidModeQueryExtension(x_display, &vm_event_base, &vm_error_base);
680 +        if (has_vidmode)
681 +                XF86VidModeGetAllModeLines(x_display, screen, &num_x_video_modes, &x_video_modes);
682 + #endif
683 +        
684          // Find black and white colors
685          XParseColor(x_display, DefaultColormap(x_display, screen), "rgb:00/00/00", &black);
686          XAllocColor(x_display, DefaultColormap(x_display, screen), &black);
# Line 793 | Line 832 | void VideoExit(void)
832                  }
833   #endif
834  
835 + #if ENABLE_XF86_VIDMODE
836 +                if (has_vidmode && display_type == DISPLAY_DGA)
837 +                        XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]);
838 + #endif
839 +
840   #if ENABLE_FBDEV_DGA
841                  if (display_type == DISPLAY_DGA) {
842                          XUngrabPointer(x_display, CurrentTime);
# Line 948 | Line 992 | static void resume_emul(void)
992   #if ENABLE_XF86_DGA
993                  XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]);
994   #endif
951 #if ENABLE_FBDEV_DGA
952                XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap]);
953 #endif
995  
996          // Unlock frame buffer (and continue MacOS thread)
997          pthread_mutex_unlock(&frame_buffer_lock);
# Line 1142 | Line 1183 | static void handle_events(void)
1183                                  unsigned int button = ((XButtonEvent *)&event)->button;
1184                                  if (button < 4)
1185                                          ADBMouseDown(button - 1);
1186 +                                else if (button < 6) {  // Wheel mouse
1187 +                                        if (mouse_wheel_mode == 0) {
1188 +                                                int key = (button == 5) ? 0x79 : 0x74;  // Page up/down
1189 +                                                ADBKeyDown(key);
1190 +                                                ADBKeyUp(key);
1191 +                                        } else {
1192 +                                                int key = (button == 5) ? 0x3d : 0x3e;  // Cursor up/down
1193 +                                                for(int i=0; i<mouse_wheel_lines; i++) {
1194 +                                                        ADBKeyDown(key);
1195 +                                                        ADBKeyUp(key);
1196 +                                                }
1197 +                                        }
1198 +                                }
1199                                  break;
1200                          }
1201                          case ButtonRelease: {
# Line 1223 | Line 1277 | static void update_display(void)
1277   {
1278          // In classic mode, copy the frame buffer from Mac RAM
1279          if (classic_mode)
1280 <                memcpy(the_buffer, Mac2HostAddr(0x3fa700), VideoMonitor.bytes_per_row * VideoMonitor.y);
1280 >                Mac2Host_memcpy(the_buffer, 0x3fa700, VideoMonitor.bytes_per_row * VideoMonitor.y);
1281          
1282          // Incremental update code
1283          int wide = 0, high = 0, x1, x2, y1, y2, i, j;
# Line 1343 | Line 1397 | static void update_display(void)
1397  
1398                  // Set new cursor image if it was changed
1399                  if (memcmp(the_cursor, Mac2HostAddr(0x844), 64)) {
1400 <                        memcpy(the_cursor, Mac2HostAddr(0x844), 64);
1400 >                        Mac2Host_memcpy(the_cursor, 0x844, 64);
1401                          memcpy(cursor_image->data, the_cursor, 32);
1402                          memcpy(cursor_mask_image->data, the_cursor+32, 32);
1403                          XFreeCursor(x_display, mac_cursor);
# Line 1417 | Line 1471 | static void *redraw_func(void *arg)
1471                                          XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]);
1472                                  }
1473   #endif
1420                                
1421 #if ENABLE_FBDEV_DGA
1422                                if (display_type == DISPLAY_DGA)
1423                                        XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap]);
1424 #endif
1474                          }
1475                  }
1476                  pthread_mutex_unlock(&palette_lock);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines