[AD] 3.9.26 patch for Linux fbcon driver |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Here is a patch to make the fbcon driver save the palette and
restore it on exit. I assume the vesafb device has no problem
with this, but on the Matrox one without this code the palette
is left unchanged until you switch consoles; since most of my
games tend to fade out on exit, you use to just get a blank
screen. :)
Perhaps the palette saving code shoul just grab a copy into an
Allegro's default palette.
As a separate patch, I tried to disable the hardware cursor, but
it had no effect; I'm assuming that the matroxfb driver doesn't
support the ioctl (which is marked as something similar to
`preliminary' in the fb.h file).
George
This patch makes the fbcon driver reset the palette on exit.
diff -urN allegro-3.9.26-0/src/linux/fbcon.c allegro-3.9.26-1/src/linux/fbcon.c
--- allegro-3.9.26-0/src/linux/fbcon.c Sun Oct 3 17:03:52 1999
+++ allegro-3.9.26-1/src/linux/fbcon.c Wed Oct 27 17:31:05 1999
@@ -45,6 +45,8 @@
static int fb_scroll(int x, int y);
static void fb_vsync(void);
static void fb_set_palette(RGB *p, int from, int to, int vsync);
+static void fb_save_cmap(void);
+static void fb_restore_cmap(void);
@@ -91,7 +93,6 @@
-
static int update_timings(struct fb_var_screeninfo *mode);
@@ -375,6 +376,7 @@
if (fb_approx)
memset(fbaddr, 0, gfx_fbcon.vid_mem);
+ fb_save_cmap(); /* Maybe we should fill in our default palette too... */
return b;
}
@@ -386,6 +388,7 @@
static void fb_exit(BITMAP *b)
{
ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_mode);
+ fb_restore_cmap();
munmap(fbaddr, fix_info.smem_len);
close(fbfd);
@@ -526,6 +529,45 @@
fb_vsync();
ioctl(fbfd, FBIOPUTCMAP, &cmap);
+}
+
+
+
+static unsigned short *orig_cmap_data; /* original palette data */
+
+/* fb_do_cmap:
+ * Helper for fb_{save|restore}_cmap.
+ */
+static void fb_do_cmap (int ioctlno)
+{
+ struct fb_cmap cmap;
+ cmap.start = 0;
+ cmap.len = 256;
+ cmap.red = orig_cmap_data;
+ cmap.green = orig_cmap_data+256;
+ cmap.blue = orig_cmap_data+512;
+ cmap.transp = NULL;
+ ioctl(fbfd, ioctlno, &cmap);
+}
+
+/* fb_{save|restore}_cmap:
+ * Routines to save and restore the whole palette.
+ */
+static void fb_save_cmap (void)
+{
+ if (orig_cmap_data) free (orig_cmap_data); /* can't happen */
+ orig_cmap_data = malloc (sizeof *orig_cmap_data* 768);
+ if (orig_cmap_data)
+ fb_do_cmap (FBIOGETCMAP);
+}
+
+static void fb_restore_cmap (void)
+{
+ if (orig_cmap_data) {
+ fb_do_cmap (FBIOPUTCMAP);
+ free (orig_cmap_data);
+ orig_cmap_data = NULL;
+ }
}