[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
A couple of patches and a couple of other notes
From: Steven Stadnicki ####@####.#### Date: 4 Apr 2000 21:10:07 -0000 Message-Id: <38EA57C3.66422D6D@equator.com> Hey! I suppose I should introduce myself to the list first. I'm working on porting Microwindows to our hardware (NTSC display output) and I've run into a few minor issues. Some of them are fairly hardware-specific, but there are a couple that seem to be just bugs in the mwin engine/build process: --The null mouse and keyboard drivers need to have function pointers to a 'Null_Poll' function in their driver structures rather than just pointing to NULL (which breaks the code that calls through them) -- the 'debug path' in drivers/Makefile needs to include both genfont.o and genmem.o -- the MSDOS version of the GsSelect function in winmain.c should still call MwHandleTimers after polling the mouse and keyboard drivers -- not everyone has perror() or printf() available to them, especially on embedded devices; we changed all uses of perror() to PRINT_ERROR and set up a config option HAVE_PERROR which defines PRINT_ERROR as 'perror' if it's Y and otherwise defines PRINT_ERROR as 'printf'. (We _do_ have a printf, so didn't try doing the same thing there; but strictly speaking that should probably be extracted too) -- PF_TRUECOLOR* wasn't quite redefined to MWPF_TRUECOLOR* everywhere in device.h I've included a couple of patches that should fix all of the above: 'patch -p1 < microwin_fixes.diff' and then 'patch -p1 < microwin_morefixes.diff', starting from the top-level microwindows directory, should handle that stuff. There are a couple of other things that we haven't tried to patch yet that also need to be fixed, though; the most notable is that FLOAT is defined to be float in windef.h (which is good; this is preferrable to defining it as double), but the floating-point constants in graph3d.h (pi and epsilon) will default to being doubles (they should be suffixed with an 'f' to make it clear that they're float constants) and cos(), sin(), etc. take double arguments, not float, so they should be changed to cosf(), sinf(), sqrtf() and atanf(). (Also, the 'atan' call in angle() should probably be an 'atan2', which obviates most of the need for that entire function). I can try and put together a patch for that if it would be helpful, but it'd be a bit more effort. Steven Stadnicki ####@####.#### Another satisfied microwindows 'customer'... diff -u -r microwin/src/drivers/Makefile microwindows-0.88pre6/src/drivers/Makefile --- microwin/src/drivers/Makefile Thu Mar 23 20:46:25 2000 +++ microwindows-0.88pre6/src/drivers/Makefile Mon Apr 3 19:20:55 2000 @@ -166,7 +166,7 @@ endif ifeq ($(DBGDRIVER), Y) -OBJS += scr_debug.o +OBJS += scr_debug.o genfont.o genmem.o endif ifeq ($(SERMOUSE), Y) diff -u -r microwin/src/drivers/kbd_null.c microwindows-0.88pre6/src/drivers/kbd_null.c --- microwin/src/drivers/kbd_null.c Sun Apr 2 11:43:15 2000 +++ microwindows-0.88pre6/src/drivers/kbd_null.c Mon Apr 3 19:15:09 2000 @@ -10,14 +10,24 @@ static void NUL_Close(void); static void NUL_GetModifierInfo(int *modifiers); static int NUL_Read(MWUCHAR *buf, int *modifiers); +static int NUL_Poll(void); KBDDEVICE kbddev = { NUL_Open, NUL_Close, NUL_GetModifierInfo, NUL_Read, - NULL + NUL_Poll }; + +/* + * Poll for keyboard events + */ +static int +NUL_Poll(void) +{ + return 0; +} /* * Open the keyboard. diff -u -r microwin/src/drivers/mou_null.c microwindows-0.88pre6/src/drivers/mou_null.c --- microwin/src/drivers/mou_null.c Sun Apr 2 12:31:13 2000 +++ microwindows-0.88pre6/src/drivers/mou_null.c Mon Apr 3 19:25:30 2000 @@ -14,6 +14,7 @@ static int NUL_GetButtonInfo(void); static void NUL_GetDefaultAccel(int *pscale,int *pthresh); static int NUL_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz, int *bp); +static int NUL_Poll(void); MOUSEDEVICE mousedev = { NUL_Open, @@ -21,8 +22,18 @@ NUL_GetButtonInfo, NUL_GetDefaultAccel, NUL_Read, - NULL + NUL_Poll }; + +/* + * Poll for events + */ + +static int +NUL_Poll(void) +{ + return 0; +} /* * Open up the mouse device. diff -u -r microwin/src/mwin/winmain.c microwindows-0.88pre6/src/mwin/winmain.c --- microwin/src/mwin/winmain.c Sun Apr 2 18:05:08 2000 +++ microwindows-0.88pre6/src/mwin/winmain.c Mon Apr 3 19:17:05 2000 @@ -228,6 +228,7 @@ if(kbddev.Poll()) MwCheckKeyboardEvent(); + MwHandleTimers(); } #endif diff -u -r microwindows-0.88pre6/src/Makefile.rules microwin/src/Makefile.rules --- microwindows-0.88pre6/src/Makefile.rules Sun Apr 2 16:25:53 2000 +++ microwin/src/Makefile.rules Mon Apr 3 20:51:08 2000 @@ -37,6 +37,12 @@ LDFLAGS += -lvga endif +ifeq ($(HAVE_PERROR), Y) +DEFINES += -DPRINT_ERROR=perror +else +DEFINES += -DPRINT_ERROR=printf +endif + ifeq ($(HAVE_FILEIO), Y) DEFINES += -DHAVE_FILEIO diff -u -r microwindows-0.88pre6/src/config microwin/src/config --- microwindows-0.88pre6/src/config Sun Apr 2 19:34:39 2000 +++ microwin/src/config Mon Apr 3 20:07:23 2000 @@ -99,6 +100,16 @@ HAVE_FILEIO = Y #################################################################### +# +# perror() support +# Some embedded platforms don't support perror() so we may not want +# to define it for now. (Currently translates to PRINT_ERROR being +# a mere 'printf'.) +# +#################################################################### +HAVE_PERROR = Y + +#################################################################### # BMP reading support #################################################################### HAVE_BMP_SUPPORT = Y diff -u -r microwindows-0.88pre6/src/demos/nanox/npanel.c microwin/src/demos/nanox/npanel.c --- microwindows-0.88pre6/src/demos/nanox/npanel.c Sun Apr 2 13:09:39 2000 +++ microwin/src/demos/nanox/npanel.c Mon Apr 3 19:58:27 2000 @@ -200,7 +200,7 @@ if (ep->utype != GR_UPDATE_MAP) return; printf("Decorating the new window\n"); if ((mwp = NewWindow(ep->wid)) == NULL) { - perror("malloc"); + PRINT_ERROR("malloc"); return; } mwp->x = ep->x; diff -u -r microwindows-0.88pre6/src/demos/test/test.c microwin/src/demos/test/test.c --- microwindows-0.88pre6/src/demos/test/test.c Tue Feb 8 11:07:04 2000 +++ microwin/src/demos/test/test.c Mon Apr 3 19:58:27 2000 @@ -29,12 +29,12 @@ main(int ac,char **av) { if ((keyb_fd = GdOpenKeyboard()) < 0) { - perror("Cannot initialise keyboard"); + PRINT_ERROR("Cannot initialise keyboard"); return -1; } if ((mouse_fd = GdOpenMouse()) < 0) { - perror("Cannot initialise mouse"); + PRINT_ERROR("Cannot initialise mouse"); GdCloseKeyboard(); return -1; } @@ -111,7 +111,7 @@ printf("select() timeout\n"); } else if(errno != EINTR) - perror("Select() call in main failed"); + PRINT_ERROR("Select() call in main failed"); } #endif diff -u -r microwindows-0.88pre6/src/include/device.h microwin/src/include/device.h --- microwindows-0.88pre6/src/include/device.h Sun Apr 2 19:08:09 2000 +++ microwin/src/include/device.h Mon Apr 3 20:14:21 2000 @@ -301,21 +301,21 @@ #define PIXELVAL332TOCOLORVAL(c) \ ((((c) & 0xe0) >> 5) | (((c) & 0x18) << 5) | (((c) & 0x03) << 16)) -#if (MWPIXEL_FORMAT == PF_TRUECOLOR888) || (MWPIXEL_FORMAT == PF_TRUECOLOR0888) +#if (MWPIXEL_FORMAT == MWPF_TRUECOLOR888) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR0888) #define RGB2PIXEL(r,g,b) RGB2PIXEL888(r,g,b) #define PIXEL2RED(p) PIXEL888RED(p) #define PIXEL2GREEN(p) PIXEL888GREEN(p) #define PIXEL2BLUE(p) PIXEL888BLUE(p) #endif -#if MWPIXEL_FORMAT == PF_TRUECOLOR565 +#if MWPIXEL_FORMAT == MWPF_TRUECOLOR565 #define RGB2PIXEL(r,g,b) RGB2PIXEL565(r,g,b) #define PIXEL2RED(p) PIXEL565RED(p) #define PIXEL2GREEN(p) PIXEL565GREEN(p) #define PIXEL2BLUE(p) PIXEL565BLUE(p) #endif -#if MWPIXEL_FORMAT == PF_TRUECOLOR332 +#if MWPIXEL_FORMAT == MWPF_TRUECOLOR332 #define RGB2PIXEL(r,g,b) RGB2PIXEL332(r,g,b) #define PIXEL2RED(p) PIXEL332RED(p) #define PIXEL2GREEN(p) PIXEL332GREEN(p) diff -u -r microwindows-0.88pre6/src/mwin/winmain.c microwin/src/mwin/winmain.c --- microwindows-0.88pre6/src/mwin/winmain.c Mon Apr 3 19:17:05 2000 +++ microwin/src/mwin/winmain.c Mon Apr 3 19:58:27 2000 @@ -341,7 +341,7 @@ MwHandleTimers(); } else if(errno != EINTR) - perror("Select() call in main failed"); + PRINT_ERROR("Select() call in main failed"); } #endif @@ -384,18 +384,18 @@ startTicks = GetTickCount(); if ((keyb_fd = GdOpenKeyboard()) == -1) { - perror("Cannot initialise keyboard"); + PRINT_ERROR("Cannot initialise keyboard"); return -1; } if ((psd = GdOpenScreen()) == NULL) { - perror("Cannot initialise screen"); + PRINT_ERROR("Cannot initialise screen"); GdCloseKeyboard(); return -1; } if ((mouse_fd = GdOpenMouse()) == -1) { - perror("Cannot initialise mouse"); + PRINT_ERROR("Cannot initialise mouse"); GdCloseScreen(psd); GdCloseKeyboard(); return -1; @@ -425,7 +425,7 @@ wp = GdItemNew(struct hwnd); if (!wp) { - perror("No memory for root window"); + PRINT_ERROR("No memory for root window"); GdCloseMouse(); GdCloseScreen(psd); GdCloseKeyboard(); diff -u -r microwindows-0.88pre6/src/nanox/srvevent.c microwin/src/nanox/srvevent.c --- microwindows-0.88pre6/src/nanox/srvevent.c Sun Apr 2 12:14:19 2000 +++ microwin/src/nanox/srvevent.c Mon Apr 3 19:58:27 2000 @@ -23,7 +23,7 @@ { GR_EVENT_ERROR *ep; /* event to describe error */ -printf("GsError %d, %d\r\n", code, id); + printf("GsError %d, %d\n", code, id); /* * If there is already an outstanding error, then forget this one. */ diff -u -r microwindows-0.88pre6/src/nanox/srvmain.c microwin/src/nanox/srvmain.c --- microwindows-0.88pre6/src/nanox/srvmain.c Sun Apr 2 18:05:56 2000 +++ microwin/src/nanox/srvmain.c Mon Apr 3 19:58:27 2000 @@ -321,7 +320,7 @@ #endif } else if(errno != EINTR) - perror("Select() call in main failed"); + PRINT_ERROR("Select() call in main failed"); } #endif @@ -358,21 +357,21 @@ signal(SIGPIPE, SIG_IGN); if (GsOpenSocket() < 0) { - perror("Cannot bind to named socket"); + PRINT_ERROR("Cannot bind to named socket"); free(wp); return -1; } #endif if ((keyb_fd = GdOpenKeyboard()) == -1) { - perror("Cannot initialise keyboard"); + PRINT_ERROR("Cannot initialise keyboard"); /*GsCloseSocket();*/ free(wp); return -1; } if ((psd = GdOpenScreen()) == NULL) { - perror("Cannot initialise screen"); + PRINT_ERROR("Cannot initialise screen"); /*GsCloseSocket();*/ GdCloseKeyboard(); free(wp); @@ -380,7 +379,7 @@ } if ((mouse_fd = GdOpenMouse()) == -1) { - perror("Cannot initialise mouse"); + PRINT_ERROR("Cannot initialise mouse"); /*GsCloseSocket();*/ GdCloseScreen(psd); GdCloseKeyboard(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: A couple of patches and a couple of other notes
From: "Greg Haerr" ####@####.#### Date: 5 Apr 2000 01:35:12 -0000 Message-Id: <0e5101bf9e9d$c014b5a0$15320cd0@gregh> but there are a couple that : seem to be just bugs in the mwin engine/build process: [snip] Steven - Great job with the fixes, and their diff'd with pre6 to boot! I'll add all of them immediately, they look fine. Are you using Microwindows for DOS? I was wondering if anyone used that non-select method of polling for input... In regards to the printf/perror thing, Al made a suggestion about a month ago that perhaps we eliminate printf() entirely for systems that are small or don't have anywhere to printf to. I'm trying to think of the proper config option for both perror, printf, fprintf, and that sort of thing. I commented that perhaps a config option to not use libc stdio might be good. (We already have HAVE_FILEIO_SUPPORT to remove fopen/fclose etc.) There are a : couple of other things that we haven't tried to patch yet that also need : to be fixed, though; the most notable is that FLOAT is defined to be : float in windef.h (which is good; this is preferrable to defining it as : double), but the floating-point constants in graph3d.h (pi and epsilon) : will default to being doubles (they should be suffixed with an 'f' to make : it clear that they're float constants) and cos(), sin(), etc. take double : arguments, not float, so they should be changed to cosf(), sinf(), sqrtf() : and atanf(). (Also, the 'atan' call in angle() should probably be an 'atan2', I'm open for input as to whether the math functions should all be defined for FLOAT or DOUBLE, or either. I thought most math libs converted float to double and performed all math in double precision, so that actually it was MORE costly to use floats. Also, is cosf() etc available in all math libs? Regards, Greg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |