/* _xdga2_scroll_screen: * Scrolls DGA viewport. */ static int _xdga2_scroll_screen(int x, int y) { if (x < 0) x = 0; else if (x > dga_device->mode.maxViewportX) x = dga_device->mode.maxViewportX; if (y < 0) y = 0; else if (y > dga_device->mode.maxViewportY) y = dga_device->mode.maxViewportY; if ((_xwin.scroll_x == x) && (_xwin.scroll_y == y)) return 0; XLOCK(); _xwin.scroll_x = x; _xwin.scroll_y = y; if (_wait_for_vsync) while (XDGAGetViewportStatus(_xwin.display, _xwin.screen)) ; XDGASetViewport(_xwin.display, _xwin.screen, x, y, XDGAFlipRetrace); XUNLOCK(); return 0; }
/* _xdga2_poll_scroll: * Returns true if there are pending scrolling requests left. */ static int _xdga2_poll_scroll(void) { int result; XLOCK(); result = XDGAGetViewportStatus(_xwin.display, _xwin.screen); XUNLOCK(); return result; }
const char *xf86_dga2_update_display(mame_bitmap *bitmap, rectangle *vis_area, rectangle *dirty_area, struct sysdep_palette_struct *palette, int flags) { rectangle my_dirty_area = *dirty_area; if (xf86ctx.max_page) { /* force a full screen update */ if (xf86ctx.page_dirty) { my_dirty_area = *vis_area; xf86ctx.page_dirty--; } while(XDGAGetViewportStatus(display, xf86ctx.screen) & (0x01 << (xf86ctx.max_page - 1))) { } } xf86ctx.page = (xf86ctx.page + 1) % (xf86ctx.max_page + 1); xf86ctx.update_display_func(bitmap, vis_area, &my_dirty_area, palette, xf86ctx.addr + xf86ctx.aligned_viewport_height * xf86ctx.page * xf86ctx.device->mode.bytesPerScanline, xf86ctx.width); if (xf86ctx.max_page) { XDGASetViewport(display, xf86ctx. screen, 0, xf86ctx.page * xf86ctx.aligned_viewport_height, XDGAFlipRetrace); /* If the dirty area has changed force a fullscreen update the next max_page updates, so that it gets updated in all pages */ if (memcmp(&xf86ctx.old_dirty_area, dirty_area, sizeof(xf86ctx.old_dirty_area))) { xf86ctx.old_dirty_area = *dirty_area; xf86ctx.page_dirty = xf86ctx.max_page; } } XDGASync(display,xf86ctx.screen); return NULL; }
static int xf86_dga2_set_mode(void) { int bestmode = xf86_dga_vidmode_find_best_vidmode(); if (bestmode == -1) { fprintf(stderr,"no suitable mode found\n"); return 1; } if (bestmode != xf86ctx.current_mode) { if(xf86ctx.device) XFree(xf86ctx.device); xf86ctx.device = XDGASetMode(display,xf86ctx.screen,bestmode); if (xf86ctx.device == NULL) { fprintf(stderr,"XDGASetMode failed\n"); return 1; } xf86ctx.width = xf86ctx.device->mode.bytesPerScanline * 8 / xf86ctx.device->mode.bitsPerPixel; xf86ctx.current_mode = bestmode; #if 0 /* DEBUG */ fprintf(stderr, "Debug: bitmap_depth =%d mode.bitsPerPixel = %d" " mode.depth = %d\n", bitmap_depth, xf86ctx.device->mode.bitsPerPixel, xf86ctx.device->mode.depth); #endif fprintf(stderr,"XF86DGA2 switched To Mode: %d x %d\n", xf86ctx.device->mode.viewportWidth, xf86ctx.device->mode.viewportHeight); mode_set_aspect_ratio((double)xf86ctx.device->mode.viewportWidth/ xf86ctx.device->mode.viewportHeight); /* setup the viewport */ XDGASetViewport(display,xf86ctx.screen,0,0,0); while(XDGAGetViewportStatus(display, xf86ctx.screen)) ; /* setup page flipping */ if(xf86ctx.device->mode.viewportFlags & XDGAFlipRetrace) { xf86ctx.aligned_viewport_height = (xf86ctx.device->mode.viewportHeight+ xf86ctx.device->mode.yViewportStep-1) & ~(xf86ctx.device->mode.yViewportStep-1); xf86ctx.page = 0; xf86ctx.max_page = xf86ctx.device->mode.maxViewportY / xf86ctx.aligned_viewport_height; if (xf86ctx.max_page > xf86ctx.max_page_limit) xf86ctx.max_page = xf86ctx.max_page_limit; if (xf86ctx.max_page) fprintf(stderr, "DGA using vsynced page flipping, hw-buffering max %d frames\n", xf86ctx.max_page); } else xf86ctx.max_page = 0; /* fill the sysdep_display_properties struct */ memset(&sysdep_display_properties.palette_info, 0, sizeof(struct sysdep_palette_info)); sysdep_display_properties.palette_info.red_mask = xf86ctx.device->mode.redMask; sysdep_display_properties.palette_info.green_mask = xf86ctx.device->mode.greenMask; sysdep_display_properties.palette_info.blue_mask = xf86ctx.device->mode.blueMask; sysdep_display_properties.palette_info.depth = xf86ctx.device->mode.depth; sysdep_display_properties.palette_info.bpp = xf86ctx.device->mode.bitsPerPixel; sysdep_display_properties.vector_renderer = NULL; } if(xf86_dga_setup_graphics(xf86ctx.device->mode)) return 1; /* get a blit function */ return !(xf86ctx.update_display_func=sysdep_display_effect_open()); }