Index: xc/config/cf/Imake.cf
===================================================================
RCS file: /cvsroot/xsrc/xc/config/cf/Imake.cf,v
retrieving revision 1.33
diff -u -r1.33 Imake.cf
--- xc/config/cf/Imake.cf	2002/07/22 21:04:06	1.33
+++ xc/config/cf/Imake.cf	2003/12/08 14:33:38
@@ -253,6 +253,14 @@
 #  define playstation2Architecture
 #  undef playstation2
 # endif
+# if defined(__sh__) || defined(sh)
+#  define shArchitecture
+#  undef sh
+# endif
+# if defined(__dreamcast__) || defined(dreamcast)
+#  define dreamcastArchitecture
+#  undef dreamcast
+# endif
 #endif /* NetBSD */
 
 #ifdef __FreeBSD__
Index: xc/config/cf/NetBSD.cf
===================================================================
RCS file: /cvsroot/xsrc/xc/config/cf/NetBSD.cf,v
retrieving revision 1.108
diff -u -r1.108 NetBSD.cf
--- xc/config/cf/NetBSD.cf	2003/10/05 15:53:22	1.108
+++ xc/config/cf/NetBSD.cf	2003/12/08 14:33:38
@@ -39,6 +39,7 @@
 XCOMM		NetBSD/mipsco	client
 XCOMM		NetBSD/algor	client
 XCOMM		NetBSD/playstation2	client
+XCOMM		NetBSD/dreamcast	client/server
 XCOMM
 
 #ifndef OSName
@@ -292,12 +293,23 @@
 				s3_savage s3_svga neo chips cyrix rendition p9x00 \
 				spc8110 i740 tdfx smi generic
 # endif
-#else
-# if defined(m68kArchitecture) && OSMajorVersion == 1 && OSMinorVersion <= 3
-#  define OptimizedCDebugFlags 	-O
-# else
-#  define OptimizedCDebugFlags 	-O2
-# endif
+#endif
+
+#if defined(m68kArchitecture) && OSMajorVersion == 1 && OSMinorVersion <= 3
+# define OptimizedCDebugFlags 	-O
+#endif
+
+#if defined(shArchitecture)
+# define OptimizedCDebugFlags   -O
+# define HasSharedLibraries     NO
+# undef BuildDynamicLoading
+# define BuildDynamicLoading    NO
+# undef HasPosixThreads
+# define HasPosixThreads        NO
+# undef ThreadedX
+# define ThreadedX              NO
+# undef HasThreadSafeAPI
+# define HasThreadSafeAPI       NO
 #endif
 
 /*
@@ -521,6 +533,15 @@
 # define XieDynamicModule	NO
 #endif
 
+#if defined(dreamcastArchitecture)
+# define ServerExtraDefines    GccGasOption -D__dreamcast__
+# define HasSharedLibraries    NO      /**/
+# define PexDynamicModule      NO
+# define XieDynamicModule      NO
+# define XserverNeedsSetUID    YES
+#endif
+
+
 #ifndef OptimizedCDebugFlags
 # define OptimizedCDebugFlags 	-O2
 #endif
@@ -908,6 +929,13 @@
  */
 #if defined(hpcarmArchitecture)
 # define XhpcServer		YES
+#endif
+
+/*
+ * Definitions for the NetBSD/dreamcast X server.
+ */
+#if defined(dreamcastArchitecture)
+# define XdreamcastServer      YES
 #endif
 
 
Index: xc/programs/Xserver/Imakefile
===================================================================
RCS file: /cvsroot/xsrc/xc/programs/Xserver/Imakefile,v
retrieving revision 1.29
diff -u -r1.29 Imakefile
--- xc/programs/Xserver/Imakefile	2002/09/13 16:52:22	1.29
+++ xc/programs/Xserver/Imakefile	2003/12/08 14:33:51
@@ -262,6 +262,23 @@
 #endif
 #endif /* XhpcServer */
 
+#if XdreamcastServer
+XCOMM
+XCOMM NetBSD/dreamcast server
+XCOMM
+MFBDIR  = mfb
+CFB8DIR = cfb
+CFB16DIR = cfb16
+DDXDIR1 = hw/netbsd/dreamcast
+DREAMCASTDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(DDXDIR1) $(DEPDIRS)
+DREAMCASTOBJS = hw/netbsd/dreamcast/dreamcastInit.o
+DREAMCASTLIBS = hw/netbsd/dreamcast/libdreamcast.a CFB8Libs CFB16Libs
+ServerTarget(Xdreamcast,$(DREAMCASTDIRS),$(DREAMCASTOBJS),$(DREAMCASTLIBS),$(SYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xdreamcast
+#endif
+#endif /* XdreamcastServer */
+
 #if XdecServer
 XCOMM
 XCOMM Digital MIPS based WS server (ultrix 4.2 and beyond)
Index: xc/programs/Xserver/cfb/cfbmskbits.h
===================================================================
RCS file: /cvsroot/xsrc/xc/programs/Xserver/cfb/cfbmskbits.h,v
retrieving revision 1.7
diff -u -r1.7 cfbmskbits.h
--- xc/programs/Xserver/cfb/cfbmskbits.h	2002/04/04 01:55:13	1.7
+++ xc/programs/Xserver/cfb/cfbmskbits.h	2003/12/08 14:33:54
@@ -46,7 +46,7 @@
  * XXX something other than Linux.
  */
 #if defined(__NetBSD__) && \
-	(defined(__alpha__) || defined(__vax__) || defined(__mips__) || defined(__arm__))
+	(defined(__alpha__) || defined(__vax__) || defined(__mips__) || defined(__arm__) || defined(__sh__))
 #include	"../hw/xfree86/common/compiler.h"
 #endif
 
Index: xc/programs/Xserver/hw/xfree86/common/compiler.h
===================================================================
RCS file: /cvsroot/xsrc/xc/programs/Xserver/hw/xfree86/common/compiler.h,v
retrieving revision 1.5
diff -u -r1.5 compiler.h
--- xc/programs/Xserver/hw/xfree86/common/compiler.h	2002/02/12 20:20:36	1.5
+++ xc/programs/Xserver/hw/xfree86/common/compiler.h	2003/12/08 14:33:59
@@ -310,7 +310,7 @@
 #endif
 
 #else /* defined(__alpha__) */
-#if defined(__mips__) || defined(__arm__) || defined(__arm32__)
+#if defined(__mips__) || defined(__arm__) || defined(__arm32__) || defined(__sh__)
 
 unsigned int IOPortBase;  /* Memory mapped I/O port area */
 
@@ -407,9 +407,9 @@
 			((unsigned char *)(p)+1) = ((v) >> 8)
 
 #define mem_barrier()   /* NOP */
-#endif /* defined(mips) */
+#endif /* defined(__mips__) */
 
-#if defined(__arm__) || defined(__arm32__)
+#if defined(__arm__) || defined(__arm32__) || defined(__sh__)
 #define ldq_u(p)	(*((unsigned long  *)(p)))
 #define ldl_u(p)	(*((unsigned int   *)(p)))
 #define ldw_u(p)	(*((unsigned short *)(p)))
@@ -418,9 +418,9 @@
 #define stw_u(v,p)	((unsigned short *)(p)) = (v)
 #define mem_barrier()   /* NOP */
 #define write_mem_barrier()   /* NOP */
-#endif /* defined(arm32) */
+#endif /* defined(__arm__) || defined(__arm32__) || defined(__sh__) */
 
-#else /* defined(mips) || defined(arm) || defined(arm32) */
+#else /* defined(mips) || defined(arm) || defined(arm32) || defined(__sh__) */
 
 #define ldq_u(p)	(*((unsigned long  *)(p)))
 #define ldl_u(p)	(*((unsigned int   *)(p)))
Index: xc/programs/Xserver/include/servermd.h
===================================================================
RCS file: /cvsroot/xsrc/xc/programs/Xserver/include/servermd.h,v
retrieving revision 1.14
diff -u -r1.14 servermd.h
--- xc/programs/Xserver/include/servermd.h	2002/02/12 20:20:40	1.14
+++ xc/programs/Xserver/include/servermd.h	2003/12/08 14:34:10
@@ -435,6 +435,25 @@
 
 #endif /* SVR4 / BSD / i386 */
 
+#if defined(__sh__) && defined(__NetBSD__)
+
+#if defined(__LITTLE_ENDIAN__)
+# define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the sh3el only */
+# define BITMAP_BIT_ORDER	LSBFirst
+# define GLYPHPADBYTES		4
+# define GETLEFTBITS_ALIGNMENT	1
+#else
+# define IMAGE_BYTE_ORDER	MSBFirst        /* Values for the sh3eb only */
+# define BITMAP_BIT_ORDER	MSBFirst
+# define GLYPHPADBYTES		4
+# define GETLEFTBITS_ALIGNMENT	1
+#endif
+
+#define AVOID_MEMORY_READ
+#define LARGE_INSTRUCTION_CACHE
+
+#endif /* __NetBSD__ && __sh__ */
+
 #if defined (linux) && defined (__mc68000__)
 
 #define IMAGE_BYTE_ORDER       MSBFirst
--- xc/programs/Xserver/hw/netbsd/dreamcast/Imakefile.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/Imakefile	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,41 @@
+XCOMM $XConsortium: Imakefile,v 5.27 94/07/28 16:44:16 dpw Exp $
+
+#include <Server.tmpl>
+
+SRCS =	dreamcastInit.c \
+	dreamcastScreen.c \
+	dreamcastIo.c \
+	dreamcastKbd.c \
+	dreamcastMouse.c \
+	dreamcastFB.c \
+	dreamcastColormap.c \
+	dreamcastKeymap.c
+
+OBJS =	dreamcastInit.o \
+	dreamcastScreen.o \
+	dreamcastIo.o \
+	dreamcastKbd.o \
+	dreamcastMouse.o \
+	dreamcastFB.o \
+	dreamcastColormap.o \
+	dreamcastKeymap.o
+
+INCLUDES = -I. -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb16 \
+	   -I$(SERVERSRC)/include -I$(SERVERSRC)/os \
+	   -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+	   ../mi/llib-lmi.ln ../cfb/llib-lcfb.ln
+
+NormalLibraryObjectRule()
+
+all::
+
+lintlib:
+
+NormalLibraryTarget(dreamcast,$(OBJS))
+NormalLintTarget($(SRCS1))
+
+InstallManPage(Xdreamcast,$(MANDIR)) 
+
+DependTarget()
--- xc/programs/Xserver/hw/netbsd/dreamcast/Xdreamcast.man.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/Xdreamcast.man	2003-12-08 23:49:11.000000000 +0900
@@ -0,0 +1,50 @@
+.\"
+.Dd Jun 22, 2003
+.Dt Xdreamcast 1
+.Os NetBSD
+.Sh NAME
+.Nm Xdreamcast
+.Nd X Window System Display Server for NetBSD/dreamcast
+.Sh SYNOPSIS
+.Nm
+.Sh DESCRIPTION
+.Nm
+is the server for Version 11 of the X Window System for 
+.Nx dreamcast .
+It will normally be started by the
+.Xr xdm 1
+daemon or by a script that runs the program
+.Xr xinit 1 .
+.Sh SUPPORTED HARDWARE
+.Nm
+supports only 16-bit color server on Dreamcast console.
+.Nm
+supports the maple keyboards.  The
+initial arrangement of the keys on the keyboards is configured
+as the typewriter style ( 
+.So ASCII 
+.Sc arrangement).
+Once it is started, the arrangement is freely configured with
+.Xr xmodmap 1
+or
+.Xr xkbcomp 1
+utility.
+The pointing device can be the maple mouse. 
+.Sh OPTIONS
+In addition to the normal server options described in the
+.Xr Xserver 1
+manual page.
+.Sh SEE ALSO
+.Xr Xserver 1 ,
+.Xr X 1 ,
+.Xr xdm 1 ,
+.Xr xinit 1 ,
+.Xr xmodmap 1 ,
+.Xr xkbcomp 1
+.Sh HISTORY
+.Nm
+is ported from Xhpc.
+.Sh BUGS
+.Nm
+is still experimental.
+
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcast.h.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcast.h	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,216 @@
+/* $XConsortium: sun.h,v 5.39.1.1 95/01/05 19:58:43 kaleb Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.2 1995/02/12 02:36:21 dawes Exp $ */
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+#ifndef _DREAMCAST_H_
+#define _DREAMCAST_H_
+
+#include "Xos.h"
+#include "X.h"
+#include "Xproto.h"
+
+#include <stdlib.h>
+#include <termios.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <memory.h>
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/filio.h>
+#include <sys/ioctl.h>
+#include <sys/resource.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplay_usl_io.h>
+
+extern int gettimeofday();
+
+/*
+ * Server specific headers
+ */
+#include "misc.h"
+#undef abs /* don't munge function prototypes in headers, sigh */
+#include "scrnintstr.h"
+#ifdef NEED_EVENTS
+# include "inputstr.h"
+#endif
+#include "input.h"
+#include "colormapst.h"
+#include "colormap.h"
+#include "cursorstr.h"
+#include "cursor.h"
+#include "dixstruct.h"
+#include "dix.h"
+#include "opaque.h"
+#include "resource.h"
+#include "servermd.h"
+#include "windowstr.h"
+
+#undef __P
+#if NeedFunctionPrototypes
+#   define __P(p) p
+#else
+#   define __P(p) ()
+#endif
+
+/*
+ * ddx specific headers
+ */
+#ifndef PSZ
+#define PSZ 8
+#endif
+
+#include "mipointer.h"
+
+extern int monitorResolution;
+
+/*
+ * MAXEVENTS is the maximum number of events the mouse and keyboard functions
+ * will read on a given call to their GetEvents vectors.
+ */
+#define MAXEVENTS 	32
+
+/* Given a struct timeval, convert its time into milliseconds... */
+#define TVTOMILLI(tv)	(((tv).tv_usec/1000)+((tv).tv_sec*1000))
+#define TSTOMILLI(ts)	(((ts).tv_nsec/1000000)+((ts).tv_sec*1000))
+
+typedef struct wscons_event dreamcastEvent;
+
+typedef struct s_dreamcastPtrPriv * dreamcastPtrPrivPtr;
+
+/*
+ * Data private to any dreamcast keyboard.
+ */
+typedef struct {
+    dreamcastPtrPrivPtr	bedev;		/* button emulation device */
+    int			bkeymask;	/* button key mask */
+    int			bkeynrmask;	/* button key no release mask */
+    int			bkeydown;	/* button trigger key down */
+    int			fd;		/* fd of device */
+    int			devtype;       	/* type of device */
+    int			type;		/* Type of keyboard */
+    int			click;		/* kbd click save state */
+    int			xlatestat;     	/* state machine for key code xlation */
+    Leds		leds;		/* last known LED state */
+    struct termios	kbdtty;		/* previous tty settings */
+} dreamcastKbdPrivRec, *dreamcastKbdPrivPtr;
+extern dreamcastKbdPrivRec dreamcastKbdPriv;
+
+#define DREAMCAST_KBDDEV_RAW		0
+#define DREAMCAST_KBDDEV_WSKBD	1
+#define DREAMCAST_KBDDEV_WSMUX	2
+#define DREAMCAST_KBDXSTAT_INIT	0
+#define DREAMCAST_KBDXSTAT_EXT0	1
+#define DREAMCAST_KBDXSTAT_EXT1	2
+#define DREAMCAST_KBDXSTAT_EXT1_1D	3
+#define DREAMCAST_KBDXSTAT_EXT1_9D	4
+
+/*
+ * Data private to any dreamcast pointer.
+ */
+typedef struct s_dreamcastPtrPriv {
+    dreamcastKbdPrivPtr	bedev;		/* button emulation device */
+    int			brmask;		/* real button state */
+#if 0
+    int			bemask;		/* emulated button state */
+    int			ebdown;		/* emulation button down */
+#endif
+    int			fd;		/* fd of device */
+} dreamcastPtrPrivRec;
+extern dreamcastPtrPrivRec dreamcastPtrPriv;
+
+typedef struct {
+    BYTE	key;
+    CARD8	modifiers;
+} dreamcastModmapRec;
+
+typedef struct {
+    unsigned char*  fb;		/* Frame buffer itself */
+    int		    fd;		/* frame buffer for ioctl()s, */
+    struct wsdisplay_fbinfo info; /* */
+    void	    (*EnterLeave)();/* screen switch */
+    char*           devname;	/* device name (e.g. "/dev/ttyE0") */
+} dreamcastFbRec, *dreamcastFbPtr;
+
+typedef struct {
+    ColormapPtr		installedMap;
+    CloseScreenProcPtr	CloseScreen;
+    void		(*UpdateColormap)();
+    Bool		hasHardwareCursor;
+} dreamcastScreenRec, *dreamcastScreenPtr;
+
+#ifdef XKB
+extern Bool		noXkbExtension;
+#endif
+
+#define dreamcastError(str)	{ \
+	int mode; \
+	dreamcastSetDisplayMode(fileno(stderr), WSDISPLAYIO_MODE_EMUL, &mode); \
+	Error(str); \
+	dreamcastSetDisplayMode(fileno(stderr), mode, NULL); \
+}
+
+#define dreamcastErrorF(a)	{ \
+	int mode; \
+	dreamcastSetDisplayMode(fileno(stderr), WSDISPLAYIO_MODE_EMUL, &mode); \
+	ErrorF a; \
+	dreamcastSetDisplayMode(fileno(stderr), mode, NULL); \
+}
+
+#define dreamcastFatalError(a)	{ \
+	int mode; \
+	dreamcastSetDisplayMode(fileno(stderr), WSDISPLAYIO_MODE_EMUL, &mode); \
+	FatalError a; \
+}
+
+/*
+ * dreamcastInit.c
+ */
+dreamcastFbPtr dreamcastGetScreenFb __P((ScreenPtr	pScreen));
+
+/*
+ * dreamcastIo.c
+ */
+void dreamcastCleanupFd __P((int));
+void dreamcastEnqueueEvents __P((void));
+
+/*
+ * dreamcastKbd.c
+ */
+int dreamcastKbdProc __P((DeviceIntPtr pKeyboard, int what));
+dreamcastEvent* dreamcastKbdGetEvents __P((dreamcastKbdPrivPtr, int*, Bool*));
+void dreamcastKbdEnqueueEvent __P((DeviceIntPtr dev, dreamcastEvent* fe));
+
+/*
+ * dreamcastMouse.c
+ */
+int dreamcastMouseProc __P((DeviceIntPtr pMouse, int what));
+dreamcastEvent* dreamcastMouseGetEvents __P((dreamcastPtrPrivPtr, int*, Bool*));
+void dreamcastMouseEnqueueEvent __P((DeviceIntPtr dev, dreamcastEvent*));
+
+/*
+ * dreamcastScreen.c
+ */
+pointer dreamcastMemoryMap __P((size_t len, off_t off, int fd));
+Bool dreamcastScreenInit __P((ScreenPtr pScreen));
+dreamcastScreenPtr dreamcastGetScreenPrivate __P((ScreenPtr	pScreen));
+
+/*
+ * dreamcastFB.c
+ */
+Bool dreamcastFBInit __P((int scrn, ScreenPtr pScrn, int argc, char** argv));
+int dreamcastSetDisplayMode(int, int, int *);
+
+#endif
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastColormap.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastColormap.c	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,153 @@
+/* $XConsortium: sunCfb.c,v 1.15.1.2 95/01/12 18:54:42 kaleb Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunCfb.c,v 3.2 1995/02/12 02:36:22 dawes Exp $ */
+/*
+Copyright (c) 1990  X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright (c) 1987 by the Regents of the University of California
+ * Copyright (c) 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/*
+ * Modified from  hpcColormap.c of Xhpc
+ */
+
+/****************************************************************/
+/* Modified from  sunCG4C.c for X11R3 by Tom Jarmolowski	*/
+/****************************************************************/
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "dreamcast.h"
+#include "cfb.h"
+
+#include <stdio.h>
+
+static ColormapPtr InstalledMaps[MAXSCREENS];
+
+void
+dreamcastInstallColormap(pmap)
+    ColormapPtr pmap;
+{
+    int index = pmap->pScreen->myNum;
+    ColormapPtr oldpmap = InstalledMaps[index];
+
+    if (pmap != oldpmap)
+    {
+	if (oldpmap != (ColormapPtr)None)
+	    WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
+	InstalledMaps[index] = pmap;
+	WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
+    }
+}
+
+void
+dreamcastUninstallColormap(pmap)
+    ColormapPtr pmap;
+{
+    int index = pmap->pScreen->myNum;
+    ColormapPtr curpmap = InstalledMaps[index];
+    
+    if(pmap == curpmap)
+    {
+        if (pmap->mid != pmap->pScreen->defColormap)
+        {
+            curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
+                                                   RT_COLORMAP);
+            (*pmap->pScreen->InstallColormap)(curpmap);
+        }
+    }
+}
+
+int    
+dreamcastListInstalledColormaps(pScreen, pmaps) 
+    ScreenPtr   pScreen;
+    Colormap    *pmaps;
+{
+    /* By the time we are processing requests, we can guarantee that there
+     * is always a colormap installed */
+    *pmaps = InstalledMaps[pScreen->myNum]->mid;
+    return (1);
+}
+
+void
+dreamcastColormapInit (pScreen)
+    ScreenPtr pScreen;
+{
+	dreamcastScreenPtr pPrivate = dreamcastGetScreenPrivate(pScreen);
+	dreamcastFbPtr pFb = dreamcastGetScreenFb(pScreen);
+
+	pScreen->InstallColormap = dreamcastInstallColormap;
+	pScreen->UninstallColormap = dreamcastUninstallColormap;
+	pScreen->ListInstalledColormaps = dreamcastListInstalledColormaps;
+	pScreen->StoreColors = (void (*)())NoopDDA;
+}
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastFB.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastFB.c	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,220 @@
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to 
+distribution  of  the software  without specific prior 
+written permission. Sun and X Consortium make no 
+representations about the suitability of this software for 
+any purpose. It is provided "as is" without any express or 
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Modified from hpcFB.c of Xhpc
+ */
+
+#include "dreamcast.h"
+
+#define FORCE_SEPARATE_PRIVATE
+#include "cfb.h"
+
+#include <stdio.h>
+
+extern miBSFuncRec cfbBSFuncRec;
+extern int cfb16ScreenPrivateIndex;
+extern Bool cfb16CreateScreenResources(ScreenPtr pScreen);
+
+
+Bool
+dreamcast16ScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+    register ScreenPtr pScreen;
+    pointer pbits;		/* pointer to screen bitmap */
+    int xsize, ysize;		/* in pixels */
+    int dpix, dpiy;		/* dots per inch */
+    int width;			/* pixel width of frame buffer */
+{
+    int	i, j;
+#ifdef CFB_NEED_SCREEN_PRIVATE
+    pointer oldDevPrivate;
+#endif
+    VisualPtr	visuals;
+    DepthPtr	depths;
+    int		nvisuals;
+    int		ndepths;
+    int		rootdepth;
+    VisualID	defaultVisual;
+    dreamcastFbPtr pFb = dreamcastGetScreenFb(pScreen);
+    struct wsdisplay_fbinfo *fbconf = &pFb->info;
+    extern Bool cfb16CloseScreen(int index, ScreenPtr pScreen);
+
+    if (!cfb16SetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
+	return FALSE;
+
+    /*
+     * fbconf->hf_pixel_width == 16 is always true
+     * because here is dreamcast16FinishScreenInit, dreamcast16 !
+     */
+    if (fbconf->depth == 16) {
+        VisualID *vid = NULL;
+
+        ndepths = 1;
+        nvisuals = 1;
+        depths = (DepthPtr)xalloc( sizeof(DepthRec) );
+        visuals = (VisualPtr)xalloc( sizeof(VisualRec) );
+        vid = (VisualID *)xalloc( sizeof(VisualID) );
+        if( !depths || !visuals || !vid ) {
+            xfree( depths );
+            xfree( visuals );
+            xfree( vid );
+            return FALSE;
+        }
+        depths[0].depth = 16;
+        depths[0].numVids = 1;
+        depths[0].vids = vid;
+        visuals[0].class = TrueColor;
+        visuals[0].bitsPerRGBValue = 6;
+        visuals[0].ColormapEntries = 1 << 6;
+        visuals[0].nplanes = 16;
+        visuals[0].vid = *vid = FakeClientID(0);
+        visuals[0].redMask   = 0xf800;
+        visuals[0].greenMask = 0x07e0;
+        visuals[0].blueMask  = 0x001f;
+        visuals[0].offsetRed   = 11;
+        visuals[0].offsetGreen = 6;
+        visuals[0].offsetBlue  = 0;
+        rootdepth = 16;
+        defaultVisual = *vid;
+    }
+
+#ifdef CFB_NEED_SCREEN_PRIVATE
+    oldDevPrivate = pScreen->devPrivate;
+#endif
+    if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+			rootdepth, ndepths, depths,
+			defaultVisual, nvisuals, visuals,
+			(miBSFuncPtr) 0))
+	return FALSE;
+
+    /* overwrite miCloseScreen with our own */
+    pScreen->CloseScreen = cfb16CloseScreen;
+
+    /* init backing store here so we can overwrite CloseScreen without stepping
+     * on the backing store wrapped version */
+    miInitializeBackingStore (pScreen, &cfbBSFuncRec);
+
+#ifdef CFB_NEED_SCREEN_PRIVATE
+    pScreen->CreateScreenResources = cfb16CreateScreenResources;
+    pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr = pScreen->devPrivate;
+    pScreen->devPrivate = oldDevPrivate;
+#endif
+    return TRUE;
+}
+
+int
+dreamcastSetDisplayMode(fd, mode, prevmode)
+	int fd;
+	int mode;
+	int *prevmode;
+{
+    if (prevmode != NULL) {
+	if (ioctl(fd, WSDISPLAYIO_GMODE, prevmode) < 0) {
+	    dreamcastError("ioctl(WSDISPLAYIO_GMODE)");
+	    return (-1);
+	}
+    }
+
+    if (prevmode == NULL || *prevmode != mode) {
+	    if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+		dreamcastError("ioctl(WSDISPLAYIO_SMODE)");
+		return (-1);
+	    }
+    }
+
+    return (0);
+}
+
+Bool
+dreamcastFBInit(screen, pScreen, argc, argv)
+    int	    	  screen;    	/* what screen am I going to be */
+    ScreenPtr	  pScreen;  	/* The Screen to initialize */
+    int	    	  argc;	    	/* The number of the Server's arguments. */
+    char    	  **argv;   	/* The arguments themselves. Don't change! */
+{
+	int res;
+	dreamcastFbPtr pFb = dreamcastGetScreenFb(pScreen);
+	unsigned char *fb = pFb->fb;
+	int rowsize;
+	struct wsdisplay_fbinfo *fbconf = &pFb->info;
+
+	pFb->EnterLeave = (void (*)())NoopDDA;
+
+	if (!dreamcastAllocateScreenPrivate(pScreen))
+	    return FALSE;
+
+	if (!fb) {
+            if (ioctl(pFb->fd, WSDISPLAYIO_GINFO, fbconf) < 0) {
+                dreamcastError("ioctl(WSDISPLAYIO_GINFO)");
+                return FALSE;
+            }
+
+
+	    if (dreamcastSetDisplayMode(pFb->fd, WSDISPLAYIO_MODE_MAPPED, NULL) < 0)
+		return FALSE;
+
+	    fb = dreamcastMemoryMap((size_t)fbconf->width * fbconf->height *fbconf->depth/8,
+			      0, pFb->fd);
+	    if (fb == NULL)
+		return FALSE;
+
+	    pFb->fb = fb;
+	}
+
+	switch (fbconf->depth) {
+	case 16:
+	    res = dreamcast16ScreenInit(pScreen, fb,
+				  fbconf->width,
+				  fbconf->height,
+				  monitorResolution, monitorResolution,
+				  fbconf->width);
+		break;
+	default:
+		dreamcastErrorF(("%dbpp frame buffer is not supported\n",
+		    fbconf->depth));
+		return FALSE;
+	}
+
+	if (!res) return FALSE;
+
+	/*
+	 * It seems that backing store can't work.
+	 */
+	pScreen->backingStoreSupport = NotUseful;
+
+	dreamcastColormapInit(pScreen);
+
+	if (!dreamcastScreenInit(pScreen))
+		return FALSE;
+	(void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+
+	res = cfbCreateDefColormap(pScreen);
+
+	return res;
+}
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastInit.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastInit.c	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,376 @@
+
+/*
+ * Modified from  hpcInit.c of Xhpc 
+ */
+
+#include    "dreamcast.h"
+#include    "gcstruct.h"
+/* #include    "mi.h" */
+#include    "mibstore.h"
+#include    "cfb.h"
+
+#include <stdio.h>
+#include <unistd.h>
+
+static Bool dreamcastDevsInited = FALSE;
+
+dreamcastKbdPrivRec dreamcastKbdPriv = {
+    NULL,	/* button emulation device */
+    0,		/* button key mask */
+    0,		/* button key no release mask */
+    0,		/* button trigger key down */
+    -1,		/* fd */
+    -1,		/* device type */
+    -1,		/* type */
+    0,		/* click */
+    (Leds)0,	/* leds */
+};
+
+dreamcastPtrPrivRec dreamcastPtrPriv = {
+    NULL,	/* button emulation device */
+    0,		/* real button state */
+#if 0
+    0,		/* emulated button state */
+    0,		/* emulation button down */
+#endif
+    -1,		/* fd */
+};
+
+/*
+ * a list of devices to try if there is no environment or command
+ * line list of devices
+ */
+static char *fallbackList[] = {
+    "/dev/ttyE0", "/dev/ttyE1", "/dev/ttyE2", "/dev/ttyE3",
+    "/dev/ttyE4", "/dev/ttyE5", "/dev/ttyE6", "/dev/ttyE7",
+};
+#define FALLBACK_LIST_LEN sizeof fallbackList / sizeof fallbackList[0]
+
+dreamcastFbRec dreamcastFbs[MAXSCREENS];
+
+static PixmapFormatRec	formats[] = {
+    {	1,	1,	BITMAP_SCANLINE_PAD},	/* 1 bit deep */
+    {	8,	8,	BITMAP_SCANLINE_PAD},	/* 8 bit deep */
+    {	16,	16,	BITMAP_SCANLINE_PAD},	/* 16 bit deep */
+};
+#define NUMFORMATS	(sizeof formats)/(sizeof formats[0])
+
+dreamcastFbPtr
+dreamcastGetScreenFb(pScreen)
+    ScreenPtr	pScreen;
+{
+    return (&dreamcastFbs[pScreen->myNum]);
+}
+
+/*
+ * OpenFrameBuffer --
+ *	Open a frame buffer according to several rules.
+ *
+ * Results:
+ *	The fd of the framebuffer.
+ */
+static int
+OpenFrameBuffer(device, screen)
+    char		*device;	/* e.g. "/dev/ttyE0" */
+    int			screen;    	/* what screen am I going to be */
+{
+    int			ret = TRUE;
+
+    dreamcastFbs[screen].fd = -1;
+    dreamcastFbs[screen].devname = device;
+    if (access (device, R_OK | W_OK) == -1)
+	return FALSE;
+    if ((dreamcastFbs[screen].fd = open(device, O_RDWR, 0)) == -1) {
+	dreamcastError(device);
+	ret = FALSE;
+    } else {
+	int mode = WSDISPLAYIO_MODE_MAPPED;
+	if (ioctl(dreamcastFbs[screen].fd, WSDISPLAYIO_SMODE, &mode) == -1) {
+		dreamcastError("unable to set frame buffer mode");
+	}
+	if (ioctl(dreamcastFbs[screen].fd, WSDISPLAYIO_GINFO,
+	    &dreamcastFbs[screen].info) == -1) {
+		dreamcastError("unable to get frame buffer info");
+		(void) close(dreamcastFbs[screen].fd);
+		dreamcastFbs[screen].fd = -1;
+		ret = FALSE;
+	}
+    }
+    if (!ret)
+	dreamcastFbs[screen].fd = -1;
+    return ret;
+}
+
+/*
+ * SigIOHandler --
+ *	Signal handler for SIGIO - input is available.
+ *
+ * Results:
+ *	dreamcastSigIO is set - ProcessInputEvents() will be called soon.
+ *
+ * Side Effects:
+ *	None
+ *
+ */
+static void
+SigIOHandler(sig)
+    int		sig;
+{
+    int olderrno = errno;
+
+    dreamcastEnqueueEvents();
+    errno = olderrno;
+}
+
+static char**
+GetDeviceList (argc, argv)
+    int		argc;
+    char	**argv;
+{
+    int		i;
+    char	*envList = NULL;
+    char	*cmdList = NULL;
+    char	**deviceList = (char **)NULL;
+    char	*ttyn = NULL;
+    char	*p;
+    int		ttyfd = -1;
+    char	ttyE0[] = "/dev/ttyE0";
+
+    for (i = 1; i < argc; i++)
+	if (strcmp (argv[i], "-dev") == 0 && i+1 < argc) {
+	    cmdList = argv[i + 1];
+	    break;
+	}
+
+    if (!cmdList)
+	envList = getenv ("XDEVICE");
+
+    if (!cmdList && !envList) {
+	if (isatty(2))
+	    ttyfd = 2;
+	else if (isatty(0))
+	    ttyfd = 0;
+	else if (isatty(1))
+	    ttyfd = 1;
+
+	if (ttyfd >= 0) {
+	    if ((p = ttyname(ttyfd)) == NULL)
+		ttyn = ttyE0;
+	    else if (strncmp(p, ttyE0, strlen(ttyE0)-1) == 0) 
+		ttyn = p;
+	    else
+		ttyn = ttyE0;
+        } else
+	    ttyn = ttyE0;
+    }
+
+    if (cmdList || envList || ttyn) {
+	char	*_tmpa;
+	char	*_tmpb;
+	int	_i1;
+	deviceList = (char **) xalloc ((MAXSCREENS + 1) * sizeof (char *));
+	_tmpa = (cmdList) ? cmdList : (envList) ? envList : ttyn;
+	for (_i1 = 0; _i1 < MAXSCREENS; _i1++) {
+	    _tmpb = strtok (_tmpa, ":");
+	    if (_tmpb)
+		deviceList[_i1] = strdup(_tmpb);
+	    else
+		deviceList[_i1] = NULL;
+	    _tmpa = NULL;
+	}
+	deviceList[MAXSCREENS] = NULL;
+    }
+    return deviceList;
+}
+
+void 
+OsVendorInit()
+{
+}
+
+void 
+InitKbdMouse(argc, argv)
+    int     	  argc;
+    char    	  **argv;
+{
+	struct rlimit rl;
+	int maxfds, kbdtype;
+	int i;
+	char **devList;
+
+	static int inited;
+
+	if (inited)
+	    return;
+
+	/*
+	 * one per client, one per screen, one per listen endpoint,
+	 * keyboard, mouse, and stderr
+	 */
+	maxfds = MAXCLIENTS + MAXSCREENS + 5;
+
+	if (getrlimit (RLIMIT_NOFILE, &rl) == 0) {
+	    rl.rlim_cur = maxfds < rl.rlim_max ? maxfds : rl.rlim_max;
+	    (void) setrlimit (RLIMIT_NOFILE, &rl);
+	}
+
+	dreamcastKbdPriv.fd = dreamcastPtrPriv.fd = -1;
+
+	/*
+	 * use mouse multiplexer if it's available.
+	 */
+	dreamcastKbdPriv.fd = open("/dev/wskbd", O_RDWR);
+	dreamcastPtrPriv.fd = open("/dev/wsmouse", O_RDWR);
+
+	/*
+	 * try each mouse device
+	 */
+	for (i = 0; i < 8; i++) {
+	    char devname[16];
+
+	    if (dreamcastKbdPriv.fd == -1) {
+		sprintf(devname, "/dev/wskbd%d", i);
+		dreamcastKbdPriv.fd = open(devname, O_RDWR);
+	    }
+
+	    if (dreamcastPtrPriv.fd == -1) {
+		sprintf(devname, "/dev/wsmouse%d", i);
+		if ((dreamcastPtrPriv.fd = open(devname, O_RDWR)) < 0)
+		    dreamcastError(devname);
+	    }
+	}
+
+	if (dreamcastKbdPriv.fd != -1) {
+	    dreamcastKbdPriv.devtype = DREAMCAST_KBDDEV_WSKBD;
+	}
+	if (dreamcastKbdPriv.fd == -1)
+	    dreamcastFatalError(("Can't open keyboard device\n"));
+	if (dreamcastPtrPriv.fd == -1)
+	    dreamcastFatalError(("Can't open pointer device\n"));
+	noXkbExtension = FALSE;		/* XXX for now */
+	inited = 1;
+
+	if (ioctl(dreamcastKbdPriv.fd, WSKBDIO_GTYPE, &kbdtype) == -1) {
+	    dreamcastError("cannot get keyboard type\n");
+	    kbdtype = 0;
+	}
+
+	switch (kbdtype) {
+	case WSKBD_TYPE_USB:
+		break;
+	}
+
+	/* XXX, What does this mean ??? */
+	dreamcastKbdPriv.type = 0;
+}
+
+/*
+ * InitOutput --
+ *	Initialize screenInfo for all actually accessible framebuffers.
+ *	The
+ *
+ * Results:
+ *	screenInfo init proc field set
+ *
+ * Side Effects:
+ *	None
+ */
+void
+InitOutput(pScreenInfo, argc, argv)
+    ScreenInfo 	  *pScreenInfo;
+    int     	  argc;
+    char    	  **argv;
+{
+    int     	i, scr;
+    int		nonBlockConsole = 0;
+    char	**devList;
+    static int	setup_on_exit = 0;
+    extern Bool	RunFromSmartParent;
+    dreamcastScreenPtr pPrivate;
+
+    if (!monitorResolution)
+	monitorResolution = 75;
+    if (RunFromSmartParent)
+	nonBlockConsole = 1;
+    for (i = 1; i < argc; i++) {
+	if (!strcmp(argv[i],"-debug"))
+	    nonBlockConsole = 0;
+    }
+
+    pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+    pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+    pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+    pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+    pScreenInfo->numPixmapFormats = NUMFORMATS;
+    for (i=0; i< NUMFORMATS; i++)
+        pScreenInfo->formats[i] = formats[i];
+    if (!dreamcastDevsInited) {
+	/* first time ever */
+	for (scr = 0; scr < MAXSCREENS; scr++)
+	    dreamcastFbs[scr].fd = -1;
+	devList = GetDeviceList (argc, argv);
+	for (i = 0, scr = 0; devList[i] != NULL && scr < MAXSCREENS; i++) {
+	    if (OpenFrameBuffer (devList[i], scr))
+		scr++;
+	}
+	dreamcastDevsInited = TRUE;
+	xfree (devList);
+    }
+    for (scr = 0; scr < MAXSCREENS; scr++)
+	if (dreamcastFbs[scr].fd != -1)
+	    (void) AddScreen (dreamcastFBInit, argc, argv);
+    (void) OsSignal(SIGWINCH, SIG_IGN);
+}
+
+/*
+ * InitInput --
+ *	Initialize all supported input devices...what else is there
+ *	besides pointer and keyboard?
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	Two DeviceRec's are allocated and registered as the system pointer
+ *	and keyboard devices.
+ */
+void
+InitInput(argc, argv)
+    int     	  argc;
+    char    	  **argv;
+{
+    DeviceIntPtr	p, k;
+    extern Bool mieqInit();
+
+    InitKbdMouse(argc, argv);
+
+    p = AddInputDevice(dreamcastMouseProc, TRUE);
+    k = AddInputDevice(dreamcastKbdProc, TRUE);
+    if (!p || !k)
+	dreamcastFatalError(("failed to create input devices in InitInput"));
+
+    RegisterPointerDevice(p);
+    RegisterKeyboardDevice(k);
+    miRegisterPointerDevice(screenInfo.screens[0], p);
+    (void) mieqInit (k, p);
+#define SET_FLOW(fd) fcntl(fd, F_SETFL, FNDELAY | FASYNC)
+    (void) OsSignal(SIGIO, SigIOHandler);
+#define WANT_SIGNALS(fd) fcntl(fd, F_SETOWN, getpid())
+    if (dreamcastKbdPriv.fd >= 0) {
+	if (SET_FLOW(dreamcastKbdPriv.fd) == -1 ||
+	    WANT_SIGNALS(dreamcastKbdPriv.fd) == -1) {
+	    (void) close (dreamcastKbdPriv.fd);
+	    dreamcastKbdPriv.fd = -1;
+	    dreamcastFatalError(("Async kbd I/O failed in InitInput"));
+	}
+    }
+    if (dreamcastPtrPriv.fd >= 0) {
+	if (SET_FLOW(dreamcastPtrPriv.fd) == -1 ||
+	    WANT_SIGNALS(dreamcastPtrPriv.fd) == -1) {
+	    (void) close (dreamcastPtrPriv.fd);
+	    dreamcastPtrPriv.fd = -1;
+	    dreamcastFatalError(("Async mouse I/O failed in InitInput"));
+	}
+    }
+}
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastIo.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastIo.c	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,257 @@
+/* $XConsortium: sunIo.c,v 5.26.1.3 95/01/25 23:02:33 kaleb Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunIo.c,v 3.1 1995/01/28 15:46:06 dawes Exp $ */
+/*-
+ * sunIo.c --
+ *	Functions to handle input from the keyboard and mouse.
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#include <stdio.h>
+
+#define NEED_EVENTS
+#include "dreamcast.h"
+
+void
+dreamcastCleanupFd(fd)
+    int fd;
+{
+    int n;
+    char buf[100];
+
+    while (0 < (n = read(fd, buf, sizeof(buf)))) {
+	;
+    }
+}
+
+/*
+ * ProcessInputEvents --
+ *	Retrieve all waiting input events and pass them to DIX in their
+ *	correct chronological order. Only reads from the system pointer
+ *	and keyboard.
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	Events are passed to the DIX layer.
+ */
+void
+ProcessInputEvents ()
+{
+    (void) mieqProcessInputEvents ();
+    miPointerUpdate ();
+}
+
+/*
+ * dreamcastEnqueueEvents
+ *	When a SIGIO is received, read device hard events and
+ *	enqueue them using the mi event queue
+ */
+void
+dreamcastEnqueueEvents ()
+{
+    dreamcastEvent	*ptrEvents,    	/* Current pointer event */
+		*kbdEvents;    	/* Current keyboard event */
+    int		numPtrEvents, 	/* Number of remaining pointer events */
+		numKbdEvents;   /* Number of remaining keyboard events */
+    int		nPE,   	    	/* Original number of pointer events */
+		nKE;   	    	/* Original number of keyboard events */
+    Bool	PtrAgain,	/* need to (re)read */
+		KbdAgain;	/* need to (re)read */
+    DeviceIntPtr	pPointer;
+    DeviceIntPtr	pKeyboard;
+    dreamcastKbdPrivPtr       kbdPriv;
+    dreamcastPtrPrivPtr       ptrPriv;
+
+    pPointer = (DeviceIntPtr)LookupPointerDevice();
+    pKeyboard = (DeviceIntPtr)LookupKeyboardDevice();
+    ptrPriv = (dreamcastPtrPrivPtr) pPointer->public.devicePrivate;
+    kbdPriv = (dreamcastKbdPrivPtr) pKeyboard->public.devicePrivate;
+    if (!pPointer->public.on || !pKeyboard->public.on)
+	return;
+
+    numPtrEvents = 0;
+    PtrAgain = TRUE;
+    numKbdEvents = 0;
+    KbdAgain = TRUE;
+
+    /*
+     * So long as one event from either device remains unprocess, we loop:
+     * Take the oldest remaining event and pass it to the proper module
+     * for processing. The DDXEvent will be sent to ProcessInput by the
+     * function called.
+     */
+    while (1) {
+	/*
+	 * Get events from both the pointer and the keyboard, storing the number
+	 * of events gotten in nPE and nKE and keeping the start of both arrays
+	 * in pE and kE
+	 */
+	if ((numPtrEvents == 0) && PtrAgain) {
+	    ptrEvents = dreamcastMouseGetEvents (ptrPriv, &nPE, &PtrAgain);
+	    numPtrEvents = nPE;
+	}
+	if ((numKbdEvents == 0) && KbdAgain) {
+	    kbdEvents = dreamcastKbdGetEvents (kbdPriv, &nKE, &KbdAgain);
+	    numKbdEvents = nKE;
+	}
+	if ((numPtrEvents == 0) && (numKbdEvents == 0))
+	    break;
+	if (numPtrEvents && numKbdEvents) {
+	    if (timespeccmp (&kbdEvents->time, &ptrEvents->time, <)) {
+		dreamcastKbdEnqueueEvent(pKeyboard, kbdEvents);
+		numKbdEvents--;
+		kbdEvents++;
+	    } else {
+		dreamcastMouseEnqueueEvent(pPointer, ptrEvents);
+		numPtrEvents--;
+		ptrEvents++;
+	    }
+	} else if (numKbdEvents) {
+	    dreamcastKbdEnqueueEvent(pKeyboard, kbdEvents);
+	    numKbdEvents--;
+	    kbdEvents++;
+	} else {
+	    dreamcastMouseEnqueueEvent(pPointer, ptrEvents);
+	    numPtrEvents--;
+	    ptrEvents++;
+	}
+    }
+}
+
+/*
+ * DDX - specific abort routine.  Called by AbortServer().
+ */
+void
+AbortDDX()
+{
+    int		i;
+    ScreenPtr	pScreen;
+    dreamcastFbPtr	pFb;
+    DevicePtr	devPtr;
+
+    OsSignal (SIGIO, SIG_IGN);
+    for (i = 0; i < screenInfo.numScreens; i++)
+    {
+	int mode = WSDISPLAYIO_MODE_EMUL;
+	pScreen = screenInfo.screens[i];
+	pFb = dreamcastGetScreenFb(pScreen);
+	(*pScreen->SaveScreen)(pScreen, SCREEN_SAVER_OFF);
+	ioctl(pFb->fd, WSDISPLAYIO_SMODE, &mode);
+    }
+}
+
+/* Called by GiveUp(). */
+void
+ddxGiveUp()
+{
+    AbortDDX ();
+}
+
+int
+ddxProcessArgument (argc, argv, i)
+    int	argc;
+    char *argv[];
+    int	i;
+{
+    extern void UseMsg();
+
+#if 0 /* XXX */
+#ifndef XKB
+    if (strcmp (argv[i], "-ar1") == 0) {	/* -ar1 int */
+	if (++i >= argc) UseMsg ();
+	sunAutoRepeatInitiate = 1000 * (long)atoi(argv[i]);
+	if (sunAutoRepeatInitiate > 1000000)
+	    sunAutoRepeatInitiate =  999000;
+	return 2;
+    }
+    if (strcmp (argv[i], "-ar2") == 0) {	/* -ar2 int */
+	if (++i >= argc) UseMsg ();
+	sunAutoRepeatDelay = 1000 * (long)atoi(argv[i]);
+	if (sunAutoRepeatDelay > 1000000)
+	    sunAutoRepeatDelay =  999000;
+	return 2;
+    }
+#endif
+#endif /* 0 XXX */
+    if (strcmp (argv[i], "-debug") == 0) {	/* -debug */
+	return 1;
+    }
+    if (strcmp (argv[i], "-dev") == 0) {	/* -dev /dev/mumble */
+	if (++i >= argc) UseMsg ();
+	return 2;
+    }
+#if 0 /* XXX */
+    if (strcmp (argv[i], "-mono") == 0) {	/* -mono */
+	return 1;
+    }
+    if (strcmp (argv[i], "-zaphod") == 0) {	/* -zaphod */
+	sunActiveZaphod = FALSE;
+	return 1;
+    }
+    if (strcmp (argv[i], "-flipPixels") == 0) {	/* -flipPixels */
+	sunFlipPixels = TRUE;
+	return 1;
+    }
+    if (strcmp (argv[i], "-fbinfo") == 0) {	/* -fbinfo */
+	sunFbInfo = TRUE;
+	return 1;
+    }
+    if (strcmp (argv[i], "-kbd") == 0) {	/* -kbd */
+	if (++i >= argc) UseMsg();
+	return 2;
+    }
+    if (strcmp (argv[i], "-protect") == 0) {	/* -protect */
+	if (++i >= argc) UseMsg();
+	return 2;
+    }
+#endif /* 0 XXX */
+    return 0;
+}
+
+void
+ddxUseMsg()
+{
+    dreamcastErrorF(("-debug              disable non-blocking console mode\n"));
+    dreamcastErrorF(("-dev fn[:fn][:fn]   name of device[s] to open\n"));
+}
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastKbd.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastKbd.c	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,274 @@
+/* $XConsortium: sunKbd.c,v 5.47 94/08/16 13:45:30 dpw Exp $ */
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Modified from  hpcKbd.c of Xhpc 
+ */
+
+#define NEED_EVENTS
+#include "dreamcast.h"
+#include "keysym.h"
+#include <stdio.h>
+#include <sys/time.h>
+#include "dreamcastKeymap.h"
+
+extern KeySymsRec dreamcastKeySyms[];
+extern dreamcastModmapRec *dreamcastModMaps[];
+
+/*
+ * dreamcastBell --
+ *	Ring the terminal/keyboard bell
+ *
+ * Results:
+ *	Ring the keyboard bell for an amount of time proportional to
+ *	"loudness."
+ *
+ * Side Effects:
+ *	None, really...
+ */
+static void 
+dreamcastBell(percent, device, ctrl, unused)
+    int		    percent;	    /* Percentage of full volume */
+    DeviceIntPtr    device;	    /* Keyboard to ring */
+    pointer	    ctrl;
+    int		    unused;
+{
+	/* None */
+}
+
+/*
+ * dreamcastKbdCtrl --
+ *	Alter some of the keyboard control parameters
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	Some...
+ */
+static void
+dreamcastKbdCtrl(device, ctrl)
+    DeviceIntPtr    device;	    /* Keyboard to alter */
+    KeybdCtrl*	    ctrl;
+{
+    dreamcastKbdPrivPtr pPriv = (dreamcastKbdPrivPtr) device->public.devicePrivate;
+
+    if (pPriv->fd < 0) return;
+
+    /* Bell info change needs nothing done here. */
+}
+
+/*
+ * dreamcastKbdProc --
+ *	Handle the initialization, etc. of a keyboard.
+ *
+ * Results:
+ *	None.
+ */
+int
+dreamcastKbdProc(device, what)
+    DeviceIntPtr  device;	/* Keyboard to manipulate */
+    int	    	  what;	    	/* What to do to it */
+{
+    int i;
+    DevicePtr pKeyboard = (DevicePtr) device;
+    dreamcastKbdPrivPtr pPriv;
+    KeybdCtrl*	ctrl = &device->kbdfeed->ctrl;
+    extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
+    struct termios tkbdtty;
+
+    static CARD8 *workingModMap = NULL;
+    static KeySymsRec *workingKeySyms;
+
+    switch (what) {
+    case DEVICE_INIT:
+	if (pKeyboard != LookupKeyboardDevice()) {
+	    dreamcastErrorF (("Cannot open non-system keyboard\n"));
+	    return (!Success);
+	}
+
+	if (!workingKeySyms) {
+	    workingKeySyms = &dreamcastKeySyms[dreamcastKbdPriv.type];
+
+#if MIN_KEYCODE > 0
+	    if (workingKeySyms->minKeyCode < MIN_KEYCODE) {
+		workingKeySyms->minKeyCode += MIN_KEYCODE;
+		workingKeySyms->maxKeyCode += MIN_KEYCODE;
+	    }
+#endif
+	    if (workingKeySyms->maxKeyCode > MAX_KEYCODE)
+		workingKeySyms->maxKeyCode = MAX_KEYCODE;
+	}
+
+	if (!workingModMap) {
+	    workingModMap=(CARD8 *)xalloc(MAP_LENGTH);
+	    (void) memset(workingModMap, 0, MAP_LENGTH);
+	    for (i = 0; dreamcastModMaps[dreamcastKbdPriv.type][i].key != 0; i++)
+		workingModMap[dreamcastModMaps[dreamcastKbdPriv.type][i].key + MIN_KEYCODE] =
+		    dreamcastModMaps[dreamcastKbdPriv.type][i].modifiers;
+	}
+
+	(void) memset ((void *) defaultKeyboardControl.autoRepeats,
+			~0, sizeof defaultKeyboardControl.autoRepeats);
+
+	pKeyboard->devicePrivate = (pointer)&dreamcastKbdPriv;
+	pKeyboard->on = FALSE;
+
+	InitKeyboardDeviceStruct(pKeyboard,
+				 workingKeySyms, workingModMap,
+				 dreamcastBell, dreamcastKbdCtrl);
+	break;
+
+    case DEVICE_ON:
+	if (!dreamcastKbdPriv.bedev) {
+	    dreamcastKbdPriv.bedev = (dreamcastPtrPrivPtr)(((DeviceIntPtr)
+             LookupPointerDevice())->public.devicePrivate);
+	    if (dreamcastKbdPriv.bedev)
+		dreamcastKbdPriv.bedev->bedev = &dreamcastKbdPriv;
+	}
+
+	dreamcastKbdPriv.bkeydown = 0;
+	dreamcastKbdPriv.bkeymask = 0;
+	dreamcastKbdPriv.bkeynrmask = 0;
+
+	pPriv = (dreamcastKbdPrivPtr)pKeyboard->devicePrivate;
+	dreamcastCleanupFd(pPriv->fd);
+	AddEnabledDevice(pPriv->fd);
+	pKeyboard->on = TRUE;
+	break;
+
+    case DEVICE_CLOSE:
+    case DEVICE_OFF:
+	pPriv = (dreamcastKbdPrivPtr)pKeyboard->devicePrivate;
+	RemoveEnabledDevice(pPriv->fd);
+	pKeyboard->on = FALSE;
+	break;
+    default:
+	dreamcastFatalError(("Unknown keyboard operation\n"));
+    }
+    return Success;
+}
+
+/*
+ * dreamcastKbdGetEvents --
+ *	Return the events waiting in the wings for the given keyboard.
+ *
+ * Results:
+ *	A pointer to an array of dreamcastEvents or (dreamcastEvent *)0 if no events
+ *	The number of events contained in the array.
+ *	A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ *	None.
+ */
+dreamcastEvent*
+dreamcastKbdGetEvents(pPriv, pNumEvents, pAgain)
+    dreamcastKbdPrivPtr pPriv;
+    int*	pNumEvents;
+    Bool*	pAgain;
+{
+    int fd;
+    int	nBytes;	    /* number of bytes of events available. */
+    u_char c, c2;
+    static dreamcastEvent evBuf[MAXEVENTS];   /* Buffer for dreamcastEvents */
+
+    fd = pPriv->fd;
+	if ((nBytes = read(fd, evBuf, sizeof(evBuf))) == -1) {
+	    if (errno == EWOULDBLOCK) {
+		*pNumEvents = 0;
+		*pAgain = FALSE;
+	    } else {
+		dreamcastError ("Reading keyboard");
+		dreamcastFatalError (("Could not read the keyboard"));
+	    }
+	} else {
+	    *pNumEvents = nBytes / sizeof (dreamcastEvent);
+	    *pAgain = (nBytes == sizeof (evBuf));
+	}
+    return evBuf;
+}
+
+/*
+ * dreamcastKbdEnqueueEvent --
+ */
+void
+dreamcastKbdEnqueueEvent (device, fe)
+    DeviceIntPtr  device;
+    dreamcastEvent	  *fe;
+{
+    xEvent		xE;
+    BYTE		keycode;
+    CARD8		keyModifiers;
+    dreamcastKbdPrivPtr	pPriv;
+    dreamcastPtrPrivPtr	ptrPriv;
+    Bool		skipKeyEvent;
+
+    pPriv = (dreamcastKbdPrivPtr)device->public.devicePrivate;
+    ptrPriv = pPriv->bedev;
+    skipKeyEvent = FALSE;
+
+    keycode = (fe->value & 0xff) + MIN_KEYCODE;
+
+    keyModifiers = device->key->modifierMap[keycode];
+    xE.u.keyButtonPointer.time = TSTOMILLI(fe->time);
+    xE.u.u.type = ((fe->type == WSCONS_EVENT_KEY_UP) ? KeyRelease : KeyPress);
+    xE.u.u.detail = keycode;
+
+    if (ptrPriv != NULL) {
+	if (fe->type == WSCONS_EVENT_KEY_UP) {
+	}
+
+	if (skipKeyEvent)
+	    return;
+
+    } /* ptrPriv != NULL */
+
+    mieqEnqueue (&xE);
+}
+
+/*ARGSUSED*/
+Bool LegalModifier(key, pDev)
+    unsigned int key;
+    DevicePtr	pDev;
+{
+    return TRUE;
+}
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastKeymap.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastKeymap.c	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,60 @@
+/* $XConsortium: sunKeyMap.c,v 4.22 94/05/18 11:16:07 kaleb Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to 
+distribution  of  the software  without specific prior 
+written permission. Sun and X Consortium make no 
+representations about the suitability of this software for 
+any purpose. It is provided "as is" without any express or 
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Modified from  hpcKeymap.c of Xhpc 
+ */
+
+#include	"dreamcast.h"
+#include	"keysym.h"
+
+#include	"dreamcastKeymap.h"
+
+KeySymsRec dreamcastKeySyms[] = {
+    /*	map	   minKeyCode	maxKC	width */
+    map,		0,	MAX_STD_KEYCODE,	4,
+};
+
+static dreamcastModmapRec modmap[] = {
+	0xe1,	ShiftMask,
+	0xe5,	ShiftMask,
+	0x39,	LockMask,
+	0xe0,	ControlMask,
+	0xe4,	ControlMask,
+	0xe2,	Mod1Mask,
+	0xe6,	Mod1Mask,
+	0xe3,	Mod2Mask,
+	0xe7,	Mod2Mask,
+	0,	0
+};
+
+dreamcastModmapRec *dreamcastModMaps[] = {
+    modmap,
+};
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastKeymap.h.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastKeymap.h	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,265 @@
+#ifndef _DREAMCASTKEYMAP_H
+#define _DREAMCASTKEYMAP_H
+
+#include "keysym.h"
+
+#define GLYPHS_PER_KEY  4
+#define NUM_KEYCODES    248
+#define NUM_STD_KEYCODES 232
+#define MIN_KEYCODE     8
+#define MAX_KEYCODE     (NUM_KEYCODES + MIN_KEYCODE - 1)
+#define MAX_STD_KEYCODE (NUM_STD_KEYCODES + MIN_KEYCODE - 1)
+
+#define AltMask         Mod1Mask
+#define NumLockMask     Mod2Mask
+#define AltLangMask     Mod3Mask
+#define KanaMask        Mod4Mask
+#define ScrollLockMask  Mod5Mask
+
+
+static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = { 
+    /* 0x00 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x01 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x02 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x03 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x04 */  XK_A,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x05 */  XK_B,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x06 */  XK_C,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x07 */  XK_D,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x08 */  XK_E,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x09 */  XK_F,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0a */  XK_G,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0b */  XK_H,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0c */  XK_I,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0d */  XK_J,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0e */  XK_K,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0f */  XK_L,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x10 */  XK_M,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x11 */  XK_N,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x12 */  XK_O,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x13 */  XK_P,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x14 */  XK_Q,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x15 */  XK_R,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x16 */  XK_S,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x17 */  XK_T,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x18 */  XK_U,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x19 */  XK_V,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1a */  XK_W,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1b */  XK_X,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1c */  XK_Y,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1d */  XK_Z,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1e */  XK_1,           XK_exclam,	NoSymbol,	NoSymbol,
+    /* 0x1f */  XK_2,           XK_at,		NoSymbol,	NoSymbol,
+    /* 0x20 */  XK_3,           XK_numbersign,	NoSymbol,	NoSymbol,
+    /* 0x21 */  XK_4,           XK_dollar,	NoSymbol,	NoSymbol,
+    /* 0x22 */  XK_5,           XK_percent,	NoSymbol,	NoSymbol,
+    /* 0x23 */  XK_6,           XK_asciicircum,	NoSymbol,	NoSymbol,
+    /* 0x24 */  XK_7,           XK_ampersand,	NoSymbol,	NoSymbol,
+    /* 0x25 */  XK_8,           XK_asterisk,	NoSymbol,	NoSymbol,
+    /* 0x26 */  XK_9,           XK_parenleft,	NoSymbol,	NoSymbol,
+    /* 0x27 */  XK_0, 		XK_parenright,	NoSymbol,	NoSymbol,
+    /* 0x28 */  XK_Return,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x29 */  XK_Escape,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2a */  XK_BackSpace,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2b */  XK_Tab,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2c */  XK_space,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2d */  XK_minus,       XK_underscore,	NoSymbol,	NoSymbol,
+    /* 0x2e */  XK_equal,       XK_plus,	NoSymbol,	NoSymbol,
+    /* 0x2f */  XK_bracketleft, XK_braceleft,	NoSymbol,	NoSymbol,
+    /* 0x30 */  XK_bracketright,XK_braceright,	NoSymbol,	NoSymbol,
+    /* 0x31 */  XK_backslash,   XK_bar,		NoSymbol,	NoSymbol,
+    /* 0x32 */  XK_backslash,   XK_bar,		NoSymbol,	NoSymbol,
+    /* 0x33 */  XK_semicolon,   XK_colon,	NoSymbol,	NoSymbol,
+    /* 0x34 */  XK_quoteright,  XK_quotedbl,	NoSymbol,	NoSymbol,
+    /* 0x35 */  XK_quoteleft,	XK_asciitilde,	NoSymbol,	NoSymbol,
+    /* 0x36 */  XK_comma,       XK_less,	NoSymbol,	NoSymbol,
+    /* 0x37 */  XK_period,      XK_greater,	NoSymbol,	NoSymbol,
+    /* 0x38 */  XK_slash,       XK_question,	NoSymbol,	NoSymbol,
+    /* 0x39 */  XK_Caps_Lock,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3a */  XK_F1,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3b */  XK_F2,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3c */  XK_F3,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3d */  XK_F4,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3e */  XK_F5,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3f */  XK_F6,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x40 */  XK_F7,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x41 */  XK_F8,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x42 */  XK_F9,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x43 */  XK_F10,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x44 */  XK_F11,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x45 */  XK_F12,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x46 */  XK_Print,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x47 */  XK_Scroll_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x48 */  XK_Pause,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x49 */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4a */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4b */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4c */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4d */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4e */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4f */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x50 */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x51 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x52 */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* 0x53 */  XK_Num_Lock,    NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x54 */  XK_KP_Divide,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x55 */  XK_KP_Multiply, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x56 */  XK_KP_Subtract, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x57 */  XK_KP_Add,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x58 */  XK_KP_Enter,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x59 */  XK_KP_1,	XK_KP_End,	NoSymbol,	NoSymbol,
+    /* 0x5a */  XK_KP_2,	XK_KP_Down,	NoSymbol,	NoSymbol,
+    /* 0x5b */  XK_KP_3,	XK_KP_Next,	NoSymbol,	NoSymbol,
+    /* 0x5c */  XK_KP_4,	XK_KP_Left,	NoSymbol,	NoSymbol,
+    /* 0x5d */  XK_KP_5,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5e */  XK_KP_6,	XK_KP_Right,	NoSymbol,	NoSymbol,
+    /* 0x5f */  XK_KP_7,	XK_KP_Home,	NoSymbol,	NoSymbol,
+    /* 0x60 */  XK_KP_8,	XK_KP_Up,	NoSymbol,	NoSymbol,
+    /* 0x61 */  XK_KP_9,	XK_KP_Prior,	NoSymbol,	NoSymbol,
+    /* 0x62 */  XK_KP_0,	XK_KP_Insert,	NoSymbol,	NoSymbol,
+    /* 0x63 */  XK_KP_Decimal,	XK_KP_Delete,	NoSymbol,	NoSymbol,
+    /* 0x64 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x65 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x66 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x67 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x68 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x69 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x70 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x71 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x72 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x73 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x74 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x75 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x76 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x77 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x78 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x79 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* 0x80 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x81 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x82 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x83 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x84 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x85 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x86 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x87 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x88 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x89 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x90 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x91 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x92 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x93 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x94 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x95 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x96 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x97 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x98 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x99 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x9a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x9b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x9c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x9d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x9e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x9f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa0 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa1 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa2 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa3 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa4 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa5 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x86 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa7 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa8 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xa9 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xaa */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xab */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xac */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xad */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xae */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xaf */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb0 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb1 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb2 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb3 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb4 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb5 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb6 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb7 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb8 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xb9 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xba */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xbb */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xbc */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xbd */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xbe */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xbf */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc0 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc1 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc2 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc3 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc4 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc5 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc6 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc7 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc8 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xc9 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xca */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xcb */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xcc */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xcd */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xce */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xcf */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd0 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd1 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd2 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd3 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd4 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd5 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd6 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd7 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd8 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xd9 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xda */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xdb */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xdc */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xdd */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xde */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xdf */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe0 */  XK_Control_L,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe1 */  XK_Shift_L,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe2 */  XK_Alt_L,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe3 */  XK_Meta_L,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe4 */  XK_Control_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe5 */  XK_Shift_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe6 */  XK_Alt_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe7 */  XK_Meta_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe8 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xe9 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xea */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xeb */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xec */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xed */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xee */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0xef */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+
+};
+#endif
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastMouse.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastMouse.c	2003-12-07 03:54:11.000000000 +0900
@@ -0,0 +1,437 @@
+/* $XConsortium: sunMouse.c,v 5.21 94/04/17 20:29:47 kaleb Exp $ */
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/*
+ * Modified from  hpcMouse.c of Xhpc 
+ */
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#define NEED_EVENTS
+#include "dreamcast.h"
+#include <stdio.h>
+
+
+static Bool dreamcastCursorOffScreen();
+static void dreamcastCrossScreen();
+static void dreamcastWarpCursor();
+
+miPointerScreenFuncRec dreamcastPointerScreenFuncs = {
+    dreamcastCursorOffScreen,
+    dreamcastCrossScreen,
+    dreamcastWarpCursor,
+};
+
+/*
+ * dreamcastMouseCtrl --
+ *	Alter the control parameters for the mouse. Since acceleration
+ *	etc. is done from the PtrCtrl record in the mouse's device record,
+ *	there's nothing to do here.
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	None.
+ */
+void
+dreamcastMouseCtrl(device, ctrl)
+    DeviceIntPtr    device;
+    PtrCtrl*	    ctrl;
+{
+}
+
+/*
+ * dreamcastMouseProc --
+ *	Handle the initialization, etc. of a mouse
+ *
+ * Results:
+ *	none.
+ *
+ * Side Effects:
+ */
+int
+dreamcastMouseProc(device, what)
+    DeviceIntPtr  device;   	/* Mouse to play with */
+    int	    	  what;	    	/* What to do with it */
+{
+    DevicePtr	  pMouse = (DevicePtr) device;
+    int	    	  format;
+    static int	  oformat;
+    BYTE    	  map[7];
+    char	  *dev;
+
+    switch (what) {
+	case DEVICE_INIT:
+	    if (pMouse != LookupPointerDevice()) {
+		dreamcastErrorF (("Cannot open non-system mouse"));
+		return !Success;
+	    }
+	    if (dreamcastPtrPriv.fd == -1)
+		return !Success;
+	    pMouse->devicePrivate = (pointer) &dreamcastPtrPriv;
+	    pMouse->on = FALSE;
+	    map[1] = 1;
+	    map[2] = 2;
+	    map[3] = 3;
+	    map[4] = 2;
+	    map[5] = 4;
+	    map[6] = 5;
+	    InitPointerDeviceStruct(
+		pMouse, map, 6, miPointerGetMotionEvents,
+ 		dreamcastMouseCtrl, miPointerGetMotionBufferSize());
+	    break;
+
+	case DEVICE_ON:
+
+	    if (!dreamcastPtrPriv.bedev) {
+		dreamcastPtrPriv.bedev = (dreamcastKbdPrivPtr)(((DeviceIntPtr)
+		 LookupKeyboardDevice())->public.devicePrivate);
+		if (dreamcastPtrPriv.bedev)
+		    dreamcastPtrPriv.bedev->bedev = &dreamcastPtrPriv;
+	    }
+#if 0
+	    dreamcastPtrPriv.bemask = 0;
+	    dreamcastPtrPriv.brmask = 0;
+	    dreamcastPtrPriv.ebdown = 0;
+#endif
+	    dreamcastPtrPriv.brmask = 0;
+
+	    AddEnabledDevice (dreamcastPtrPriv.fd);
+	    pMouse->on = TRUE;
+	    break;
+
+	case DEVICE_CLOSE:
+	    break;
+
+	case DEVICE_OFF:
+	    pMouse->on = FALSE;
+	    RemoveEnabledDevice (dreamcastPtrPriv.fd);
+	    break;
+    }
+    return Success;
+}
+
+/*
+ * dreamcastMouseGetEvents --
+ *	Return the events waiting in the wings for the given mouse.
+ *
+ * Results:
+ *	A pointer to an array of dreamcastEvents or (dreamcastEvent *)0 if no events
+ *	The number of events contained in the array.
+ *	A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ *	None.
+ */
+struct wscons_event*
+dreamcastMouseGetEvents (pPriv, pNumEvents, pAgain)
+    dreamcastPtrPrivPtr pPriv;
+    int*	pNumEvents;
+    Bool*	pAgain;
+{
+    int fd;
+    int	nBytes;	    /* number of bytes of events available. */
+    static dreamcastEvent evBuf[MAXEVENTS];   /* Buffer for dreamcastEvents */
+
+    fd = pPriv->fd;
+    if ((nBytes = read (fd, (char *)evBuf, sizeof(evBuf))) == -1) {
+	if (errno == EWOULDBLOCK) {
+	    *pNumEvents = 0;
+	    *pAgain = FALSE;
+	} else {
+	    dreamcastError ("dreamcastMouseGetEvents read");
+	    dreamcastFatalError (("Could not read from mouse"));
+	}
+    } else {
+	*pNumEvents = nBytes / sizeof (dreamcastEvent);
+	*pAgain = (nBytes == sizeof (evBuf));
+    }
+    return evBuf;
+}
+
+
+/*
+ * MouseAccelerate --
+ *	Given a delta and a mouse, return the acceleration of the delta.
+ *
+ * Results:
+ *	The corrected delta
+ *
+ * Side Effects:
+ *	None.
+ */
+static short
+MouseAccelerate (device, delta)
+    DeviceIntPtr  device;
+    int	    	  delta;
+{
+    int  sgn = sign(delta);
+    PtrCtrl *pCtrl;
+    short ret;
+
+    delta = abs(delta);
+    pCtrl = &device->ptrfeed->ctrl;
+    if (delta > pCtrl->threshold) {
+	ret =
+	    (short) sgn *
+		(pCtrl->threshold + ((delta - pCtrl->threshold) * pCtrl->num) /
+		    pCtrl->den);
+    } else {
+	ret = (short) sgn * delta;
+    }
+    return ret;
+}
+
+/*
+ * dreamcastMouseEnqueueEvent --
+ *	Given a dreamcastEvent for a mouse, pass it off the the dix layer
+ *	properly converted...
+ *
+ * Results:
+ *	None.
+ *
+ * Side Effects:
+ *	The cursor may be redrawn...? devPrivate/x/y will be altered.
+ */
+void
+dreamcastMouseEnqueueEvent (device, fe)
+    DeviceIntPtr  device;   	/* Mouse from which the event came */
+    dreamcastEvent	  *fe;	    	/* Event to process */
+{
+    xEvent		xE;
+    dreamcastPtrPrivPtr	pPriv;	/* Private data for pointer */
+    dreamcastKbdPrivPtr	keyPriv;/* Private keyboard data for button emul */
+    unsigned long	time;
+    int			x, y, bmask;
+
+    pPriv = (dreamcastPtrPrivPtr)device->public.devicePrivate;
+
+    time = xE.u.keyButtonPointer.time = TSTOMILLI(fe->time);
+
+    /*
+     * Mouse buttons start at 1.
+     *
+     * Sometimes we will get two events for a single button state change. 
+     * Should we get a button even which reflects the current state of
+     * affairs, that event is discarded.  In the button emulation case, we
+     * may need to generate several events from one real event.
+     *
+     * The button emulation allows WIN-1 through WIN-5 to be used as
+     * buttons one to five when the first real button is down.  If other
+     * real buttons are present, they are accounted for separately so that
+     * lifting an emulated button will not cause a button up event if the
+     * real button is down.  If the WIN button is not down, a button down
+     * event will be sent for the first button.  If the first button is
+     * pressed when just the WIN key is down, the button events will not
+     * be sent.  The allows you to move just the cursor on a touch screen.
+     * Emulated buttons are only released when the keys are released.
+     */
+
+    switch (fe->type) {
+#if 0
+    case WSCONS_EVENT_MOUSE_UP:
+	xE.u.u.type = ButtonRelease;
+	if (fe->value > 0 || pPriv->bedev == NULL) { /* real button */
+	    xE.u.u.detail = fe->value + 1;
+	    bmask = 1 << xE.u.u.detail;
+	    if (pPriv->brmask & bmask || pPriv->bemask & bmask) {
+		pPriv->brmask &= ~bmask;
+		pPriv->bemask &= ~bmask;
+		mieqEnqueue (&xE);
+	    }
+	} else { /* first button, do emulation if needed */
+	    keyPriv = pPriv->bedev;
+	    pPriv->ebdown = 0;
+	    if (keyPriv->bkeydown) {
+		if (keyPriv->bkeymask) {
+		    int button;
+
+		    while ((button = ffs(pPriv->bemask &
+		     ~keyPriv->bkeymask) - 1) > 0) {
+			bmask = 1 << button;
+			pPriv->bemask &= ~bmask;
+			if (!(pPriv->brmask & bmask)) {
+			    xE.u.u.detail = button;
+			    mieqEnqueue (&xE);
+			}
+		    }
+		}
+	    } else {
+		while (pPriv->bemask) {
+		    xE.u.u.detail = ffs(pPriv->bemask) - 1;
+		    bmask = 1 << xE.u.u.detail;
+		    pPriv->bemask &= ~bmask;
+	 	    if (!(pPriv->brmask & bmask))
+			mieqEnqueue (&xE);
+		}
+	    }
+	}
+	break;
+    case WSCONS_EVENT_MOUSE_DOWN:
+	xE.u.u.type = ButtonPress;
+	if (fe->value > 0 || pPriv->bedev == NULL) { /* real button */
+	    xE.u.u.detail = fe->value + 1;
+	    bmask = 1 << xE.u.u.detail;
+	    if (!(pPriv->brmask & bmask)) {
+		pPriv->brmask |= bmask;
+		mieqEnqueue (&xE);
+	    } else if (pPriv->bemask & bmask)
+		pPriv->brmask |= bmask;
+	} else { /* first button, do emulation if needed */
+	    keyPriv = pPriv->bedev;
+	    pPriv->ebdown = 1;
+	    if (keyPriv->bkeydown) {
+		if (keyPriv->bkeymask) {
+		    int button;
+		    while ((button = ffs(keyPriv->bkeymask &
+		     ~pPriv->bemask) - 1) > 0) {
+			bmask = 1 << button;
+			pPriv->bemask |= bmask;
+			if (!(pPriv->brmask & bmask)) {
+			    xE.u.u.detail = button;
+			    mieqEnqueue (&xE);
+			}
+		    }
+		}
+	    } else {
+		xE.u.u.detail = 1;
+		bmask = 1<<1;
+		if (!(pPriv->bemask & bmask)) {
+		    pPriv->bemask |= bmask;
+		    mieqEnqueue (&xE);
+		}
+	    }
+	}
+	break;
+#endif /* XXX */
+    case WSCONS_EVENT_MOUSE_UP:
+    case WSCONS_EVENT_MOUSE_DOWN:
+        xE.u.u.detail = fe->value + 1;
+        bmask = 1 << xE.u.u.detail;
+        if (fe->type == WSCONS_EVENT_MOUSE_UP) {
+            if (pPriv->brmask & bmask) {
+                xE.u.u.type = ButtonRelease;
+                pPriv->brmask &= ~bmask;
+            } else {
+                return;
+            }
+        } else {
+            if ((pPriv->brmask & bmask) == 0) {
+                xE.u.u.type = ButtonPress;
+                pPriv->brmask |= bmask;
+            } else {
+                return;
+            }
+        }
+        mieqEnqueue (&xE);
+        break;
+    case WSCONS_EVENT_MOUSE_DELTA_X:
+	miPointerDeltaCursor (MouseAccelerate(device,fe->value),0,time);
+	break;
+    case WSCONS_EVENT_MOUSE_DELTA_Y:
+	miPointerDeltaCursor (0,-MouseAccelerate(device,fe->value),time);
+	break;
+    case WSCONS_EVENT_MOUSE_DELTA_Z:
+	/* Ignore for now. */
+	break;
+    case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
+	miPointerPosition (&x, &y);
+	miPointerAbsoluteCursor (fe->value, y, time);
+	break;
+    case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
+	miPointerPosition (&x, &y);
+	miPointerAbsoluteCursor (x, fe->value, time);
+	break;
+    case WSCONS_EVENT_MOUSE_ABSOLUTE_Z:
+	break;
+    default:
+	dreamcastFatalError (("dreamcastMouseEnqueueEvent: unrecognized id\n"));
+	break;
+    }
+}
+
+static Bool
+dreamcastCursorOffScreen (pScreen, x, y)
+    ScreenPtr	*pScreen;
+    int		*x, *y;
+{
+    int	    index, ret = FALSE;
+    extern Bool PointerConfinedToScreen();
+
+    if (PointerConfinedToScreen()) return TRUE;
+    return ret;
+}
+
+static void
+dreamcastCrossScreen(pScreen, entering)
+    ScreenPtr	pScreen;
+    Bool	entering;
+{
+    dreamcastFbPtr pFb = dreamcastGetScreenFb(pScreen);
+
+    if (pFb->EnterLeave)
+	(*pFb->EnterLeave) (pScreen, entering ? 0 : 1);
+}
+
+static void
+dreamcastWarpCursor(pScreen, x, y)
+    ScreenPtr	pScreen;
+    int		x, y;
+{
+    sigset_t newsigmask;
+
+    (void) sigemptyset (&newsigmask);
+    (void) sigaddset (&newsigmask, SIGIO);
+    (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+    miPointerWarpCursor (pScreen, x, y);
+    (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+}
--- xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastScreen.c.orig	2003-12-07 03:54:11.000000000 +0900
+++ xc/programs/Xserver/hw/netbsd/dreamcast/dreamcastScreen.c	2003-12-07 03:54:12.000000000 +0900
@@ -0,0 +1,196 @@
+/* $XConsortium: sunFbs.c,v 1.8 94/08/16 13:45:30 dpw Exp $ */
+/*
+Copyright (c) 1990, 1993  X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright (c) 1987 by the Regents of the University of California
+ * Copyright (c) 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/*
+ * Modified from  hpcScreen.c of Xhpc 
+ */
+
+/****************************************************************/
+/* Modified from  sunCG4C.c for X11R3 by Tom Jarmolowski	*/
+/****************************************************************/
+
+#include "dreamcast.h"
+#include <sys/mman.h>
+#include <stdio.h>
+
+static int dreamcastScreenIndex;
+static unsigned long generation = 0;
+
+Bool
+dreamcastAllocateScreenPrivate(pScreen)
+    ScreenPtr	pScreen;
+{
+    dreamcastScreenPtr    pPrivate;
+    extern int AllocateScreenPrivateIndex();
+
+    if (generation != serverGeneration) {
+	dreamcastScreenIndex = AllocateScreenPrivateIndex();
+	if (dreamcastScreenIndex < 0)
+	    return FALSE;
+	generation = serverGeneration;
+    }
+    pPrivate = (dreamcastScreenPtr)xalloc(sizeof(dreamcastScreenRec));
+    if (!pPrivate)
+	return FALSE;
+
+    pScreen->devPrivates[dreamcastScreenIndex].ptr = (pointer) pPrivate;
+    return TRUE;
+}
+
+dreamcastScreenPtr
+dreamcastGetScreenPrivate(pScreen)
+    ScreenPtr	pScreen;
+{
+    return ((dreamcastScreenPtr)((pScreen)->devPrivates[dreamcastScreenIndex].ptr));
+}
+
+pointer
+dreamcastMemoryMap (len, off, fd)
+    size_t	len;
+    off_t	off;
+    int		fd;
+{
+    caddr_t	addr;
+    pointer	mapaddr;
+
+    len += off;
+    addr = 0;
+
+    /*
+     * try and make it private first, that way once we get it, an
+     * interloper, e.g. another server, can't get this frame buffer,
+     * and if another server already has it, this one won't.
+     */
+    mapaddr = (pointer) mmap(addr, len,
+		    PROT_READ | PROT_WRITE, MAP_SHARED,
+		    fd, 0);
+    if (mapaddr == (pointer) -1) {
+	dreamcastError ("mapping frame buffer memory");
+	(void) close (fd);
+	return NULL;
+    }
+    return mapaddr + off;
+}
+
+static Bool
+dreamcastSaveScreen (pScreen, on)
+    ScreenPtr	pScreen;
+    int		on;
+{
+    int state;
+    dreamcastFbPtr pFb = dreamcastGetScreenFb(pScreen);
+
+    if (on != SCREEN_SAVER_FORCER)
+    {
+	if (on == SCREEN_SAVER_ON)
+	    state = WSDISPLAYIO_VIDEO_OFF;
+	else
+	    state = WSDISPLAYIO_VIDEO_ON;
+	ioctl(pFb->fd, WSDISPLAYIO_SVIDEO, &state);
+    }
+
+    return TRUE;
+}
+
+static Bool
+dreamcastCloseScreen (i, pScreen)
+    int		i;
+    ScreenPtr	pScreen;
+{
+    Bool    ret;
+    dreamcastScreenPtr pPrivate = dreamcastGetScreenPrivate(pScreen);
+    dreamcastFbPtr pFb = dreamcastGetScreenFb(pScreen);
+    int mode = WSDISPLAYIO_MODE_EMUL;
+
+    (void) OsSignal (SIGIO, SIG_IGN);
+    pScreen->CloseScreen = pPrivate->CloseScreen;
+    ret = (*pScreen->CloseScreen) (i, pScreen);
+    (void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+    ioctl(pFb->fd, WSDISPLAYIO_SMODE, &mode);
+    xfree ((pointer) pPrivate);
+    return ret;
+}
+
+Bool
+dreamcastScreenInit (pScreen)
+    ScreenPtr	pScreen;
+{
+    dreamcastScreenPtr pPrivate;
+    extern void   dreamcastBlockHandler();
+    extern void   dreamcastWakeupHandler();
+    static ScreenPtr autoRepeatScreen;
+    extern miPointerScreenFuncRec dreamcastPointerScreenFuncs;
+
+    pPrivate = dreamcastGetScreenPrivate(pScreen);
+    pPrivate->installedMap = 0;
+    pPrivate->CloseScreen = pScreen->CloseScreen;
+    pScreen->CloseScreen = dreamcastCloseScreen;
+    pScreen->SaveScreen = dreamcastSaveScreen;
+    miDCInitialize (pScreen, &dreamcastPointerScreenFuncs);
+    return TRUE;
+}