Re: [AD] ModeX fix

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2005-06-18, Evert Glebbeek <eglebbk@xxxxxxxxxx> wrote:
> Two patches attached that address the problem of split_modex_screen not 
> being defined.
> It's a bit ugly and does a bit more than simply making the symbol available 
> on all systems. I'll first repeat why this is nescessary: The Mode-X 
> driver is now defined on all UNIX systems, regardless of wether a VGA card 
> is actually present or not. This means that split_modex_screen must always 
> be defined on those systems as well. The becomes configure hell and even 
> worse, it makes it harder for the user to be able to check if 
> split_modex_screen is available at all. So for that reason, I've exposed 
> the function under all circumstances and simply let it do nothing except 
> when a real Mode-X driver is present. Because split_modex_screen is an 
> inappropriate name for a function that is always defined, I've also 
> renamed it split_screen() and deprecated the split_modex_screen function.
> This is a bit ugly because there's no proper vtable entry for splitting the 
> screen, but it's the best I could think of for the time being.
> Short of removing the functionality alltogether, which we probably could 
> also have done without anyone noticing.
> 
> I can water down the patch to not rename the function if that is going too 
> far, but I vastly prefer the current version (obviously). Tested on my 
> Linux box, but I don't think it has a Mode-X driver enabled anyway, so 
> more testing needed.
> 
> Thoughts, comments?

I don't like it.  The renaming is unnecessary for one; I'd like to just
throw split_modex_screen in the bin later.  Defining
split_modex_screen() for all systems seems unnecessary.

Attached is my proposal.  It adds a new file that defines
split_modex_screen() if GFX_MODEX is defined.  The actual work is done
by the function pointed to by _split_modex_screen_ptr, which is set when
the gfx_modex or gfx_xtended drivers initialise.

I haven't actually tested it yet, and I'd like to deprecate
split_modex_screen() too.  I'll do that early next week if this idea is
okay.

Peter
Index: makefile.lst
===================================================================
RCS file: /cvsroot/alleg/allegro/makefile.lst,v
retrieving revision 1.119
diff -u -r1.119 makefile.lst
--- makefile.lst	7 Jun 2005 11:56:47 -0000	1.119
+++ makefile.lst	18 Jun 2005 10:23:28 -0000
@@ -197,6 +197,7 @@
 	src/dos/ww.c \
 	src/misc/modex.c \
 	src/misc/modexgfx.s \
+	src/misc/modexsms.c \
 	src/misc/pckeys.c \
 	src/misc/vbeaf.c \
 	src/misc/vbeafs.s \
@@ -331,7 +332,8 @@
 	src/unix/ustimer.c \
 	src/unix/usystem.c \
 	src/unix/uthreads.c \
-	src/unix/utimer.c
+	src/unix/utimer.c \
+	src/misc/modexsms.c
 
 ALLEGRO_SRC_X_FILES = \
 	src/x/xgfxdrv.c \
Index: src/misc/modex.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/misc/modex.c,v
retrieving revision 1.33
diff -u -r1.33 modex.c
--- src/misc/modex.c	25 Jan 2005 23:25:54 -0000	1.33
+++ src/misc/modex.c	18 Jun 2005 10:23:28 -0000
@@ -33,6 +33,8 @@
    #include ALLEGRO_INTERNAL_HEADER
 #endif
 
+#include "modexsms.h"
+
 #if (!defined ALLEGRO_LINUX) || ((defined ALLEGRO_LINUX_VGA) && ((!defined ALLEGRO_WITH_MODULES) || (defined ALLEGRO_MODULE)))
 
 
@@ -41,6 +43,8 @@
 void _x_blit_from_memory_end(void);
 void _x_blit_to_memory_end(void);
 
+static void really_split_modex_screen(int line);
+
 
 
 /* table of functions for drawing onto the mode-X screen */
@@ -639,6 +643,8 @@
 
    #endif
    _unset_vga_mode();
+
+   _split_modex_screen_ptr = NULL;
 }
 
 
@@ -654,6 +660,8 @@
    unsigned long addr;
    int c;
 
+   _split_modex_screen_ptr = really_split_modex_screen;
+
    /* check it is a valid resolution */
    if (color_depth != 8) {
       ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Mode-X only supports 8 bit color"));
@@ -799,6 +807,8 @@
    unsigned long addr;
    BITMAP *b;
 
+   _split_modex_screen_ptr = really_split_modex_screen;
+
    /* check it is a valid resolution */
    if (color_depth != 8) {
       ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Xtended mode only supports 8 bit color"));
@@ -1617,16 +1627,12 @@
 
 
 
-/* split_modex_screen:
+/* really_split_modex_screen:
  *  Enables a horizontal split screen at the specified line.
  *  Based on code from Paul Fenwick's XLIBDJ, which was in turn based 
  *  on Michael Abrash's routines in PC Techniques, June 1991.
  */
-#ifdef ALLEGRO_MODULE
-static void module_split_modex_screen(int line)
-#else
-void split_modex_screen(int line)
-#endif
+static void really_split_modex_screen(int line)
 {
    if (gfx_driver != &gfx_modex)
       return;
@@ -1658,18 +1664,6 @@
 #endif      /* (!defined ALLEGRO_LINUX) || ((defined ALLEGRO_LINUX_VGA) && ... */
 
 
-#if (defined ALLEGRO_LINUX_VGA) && (defined ALLEGRO_WITH_MODULES)
-
-void (*_split_modex_screen_ptr)(int);
-
-void (split_modex_screen)(int line)
-{
-   _split_modex_screen_ptr(line);
-}
-
-#endif
-
-
 #if (defined ALLEGRO_LINUX_VGA) && (defined ALLEGRO_MODULE)
 
 /* _module_init:
@@ -1679,17 +1673,9 @@
 {
    if (system_driver == SYSTEM_LINUX)
       _unix_register_gfx_driver(GFX_MODEX, &gfx_modex, TRUE, FALSE);
-
-   _split_modex_screen_ptr = module_split_modex_screen;
 }
 
-#endif
-
+#endif	    /* (defined ALLEGRO_LINUX_VGA) && (defined ALLEGRO_MODULE) */
 
-#else      /* ifdef GFX_HAS_VGA */
 
-void split_modex_screen(int line)
-{
-}
-
-#endif
+#endif	    /* GFX_HAS_VGA */
Index: src/misc/modexsms.c
===================================================================
RCS file: src/misc/modexsms.c
diff -N src/misc/modexsms.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/misc/modexsms.c	18 Jun 2005 10:23:28 -0000
@@ -0,0 +1,34 @@
+/*         ______   ___    ___ 
+ *        /\  _  \ /\_ \  /\_ \ 
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+ *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+ *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+ *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+ *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+ *                                           /\____/
+ *                                           \_/__/
+ *
+ *      Video driver for VGA tweaked modes (aka mode-X).
+ *
+ *      By Shawn Hargreaves.
+ *
+ *      See readme.txt for copyright information.
+ */
+
+
+#include "allegro.h"
+
+#include "modexsms.h"
+
+
+#ifdef GFX_MODEX
+
+void (*_split_modex_screen_ptr)(int);
+
+void split_modex_screen(int line)
+{
+   if (_split_modex_screen_ptr)
+      _split_modex_screen_ptr(line);
+}
+
+#endif
Index: src/misc/modexsms.h
===================================================================
RCS file: src/misc/modexsms.h
diff -N src/misc/modexsms.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/misc/modexsms.h	18 Jun 2005 10:23:28 -0000
@@ -0,0 +1 @@
+extern void (*_split_modex_screen_ptr)(int);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/