[AD] some additions to DGA driver |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
This patch includes two features for DGA driver: centering and
clearing video memory. Centering works with linear DGA modes only and
can be disabled by setting "XDGA_DONT_CENTER_SCREEN" environment
variable. Video memory is cleared with zeros, but it can be disabled
by setting "XDGA_DONT_CLEAR_MEMORY" env.var.
I don't like using environment variables for disabling these features,
if anyone can find better alternative it should replace environment
variables.
diff -ruN old/allegro-3.9.32/src/x/xwin.c new/allegro-3.9.32/src/x/xwin.c
--- old/allegro-3.9.32/src/x/xwin.c Mon Mar 13 06:23:53 2000
+++ new/allegro-3.9.32/src/x/xwin.c Sun Mar 19 17:48:56 2000
@@ -2592,6 +2592,7 @@
int vid_major_version, vid_minor_version;
int fb_width, banksize, memsize;
int s_w, s_h, v_w, v_h;
+ int offset_x, offset_y;
XF86VidModeModeLine modeline;
char *fb_addr;
struct passwd *pass;
@@ -2751,6 +2752,16 @@
return 0;
}
+ /* Center Allegro screen inside display. */
+ if ((getenv ("XDGA_DONT_CENTER_SCREEN") == 0) && (banksize >= memsize)) {
+ offset_x = (s_w - w) / 2;
+ offset_y = (s_h - h) / 2;
+ }
+ else {
+ offset_x = 0;
+ offset_y = 0;
+ }
+
_xwin.screen_width = w;
_xwin.screen_height = h;
_xwin.screen_depth = depth;
@@ -2792,6 +2803,16 @@
return 0;
}
+ /* Clear video memory. */
+ if (getenv ("XDGA_DONT_CLEAR_MEMORY") == 0) {
+ int offset;
+ for (offset = 0; offset < memsize; offset++) {
+ if ((offset % banksize) == 0)
+ XF86DGASetVidPage(_xwin.display, _xwin.screen, offset / banksize);
+ *(fb_addr + (offset % banksize)) = 0;
+ }
+ }
+
/* Switch to first bank. */
XF86DGASetVidPage(_xwin.display, _xwin.screen, 0);
@@ -2799,7 +2820,7 @@
XF86DGASetViewPort(_xwin.display, _xwin.screen, 0, 0);
/* Create screen bitmap from frame buffer. */
- return _xwin_private_create_screen_bitmap(drv, 1, fb_addr, fb_width);
+ return _xwin_private_create_screen_bitmap(drv, 1, fb_addr + offset_y * fb_width + offset_x * (_xwin.fast_visual_depth / 8), fb_width);
}
BITMAP *_xdga_create_screen(GFX_DRIVER *drv, int w, int h, int vw, int vh, int depth, int fullscr)
--
Michael Bukin