From: kunst AT prl DOT philips DOT nl (Pieter Kunst) Subject: DJGPP, PDCurses and DPMI To: djgpp AT sun DOT soe DOT clarkson DOT edu (DJGPP users list) Date: Fri, 4 Jun 93 10:46:15 METDST Mailer: Elm [revision: 70.85] To all users of DJGPP (1.10) and the (PD-)curses library, A public domain 'curses' library, PDCurses, exists for usage with DJGPP. This library has various advantages to the 'curses' library distributed with DJGPP (aecur101.zip): SysV compatibility, color support etc. To obtain the PDCurses library via anonymous ftp: site: ftp.gu.edu.au (132.234.1.1) files: /src/PDCurses/pdcurs21.zip To compile the PDCurses library you also need DMAKE.EXE: site: watmsg.uwaterloo.ca (129.97.141.9) files: pub/dmake/dmake38-msdos-exe.zip However, the latest version of PDCurses, version 2.1, doesn't work with DJGPP in a Windows 3.x DOS-box. The purpose of this posting is to supply the patches to PDCurses 2.1 to make it work inside a Windows 3.x DOS-box. A complete overview of the patches follows: Patched files: makefile curspriv.h portable/flushinp.c private/_clrupda.c private/_fixcurs.c private/_gbiosky.c private/_getcrsr.c private/_getfont.c private/_getrows.c private/_queryad.c private/_scropen.c private/_xfrmlin.c Added file: private/_dosmem.c -- .^^^^^^^^ _____________________________________ | | / Pieter Kunst (P.J.) \ | _ _| / Philips Research Laboratories, \ .--(o)(o) / Building WY3, Prof. Holstlaan 4, \ |@ _) / 5656 AA Eindhoven, The Netherlands. | | ,___| / e-mail: kunst AT prl DOT philips DOT nl / | / \_______________________________________________/ /____\ ------------------------------------------------------------------------------- >>> *** diffs to PDCurses 2.1 follow after this line: *** <<< ------------------------------------------------------------------------------- *** makefile.org Fri Jun 4 09:19:39 1993 --- makefile Fri Jun 4 09:17:45 1993 *************** *** 721,727 **** $(OBJ_DIR)_splitpl$(OBJ) $(OBJ_DIR)_sysgetc$(OBJ) $(OBJ_DIR)_validch$(OBJ) PRIV5 = $(OBJ_DIR)_xfrmlin$(OBJ) $(OBJ_DIR)_vsscanf$(OBJ) $(OBJ_DIR)_usleep$(OBJ) \ ! $(OBJ_DIR)_debug$(OBJ) $(OBJ_DIR)_copywin$(OBJ) $(OBJ_DIR)_memmove$(OBJ) PRIVATE = $(PRIV1) $(PRIV2) $(PRIV3) $(PRIV4) $(PRIV5) --- 721,728 ---- $(OBJ_DIR)_splitpl$(OBJ) $(OBJ_DIR)_sysgetc$(OBJ) $(OBJ_DIR)_validch$(OBJ) PRIV5 = $(OBJ_DIR)_xfrmlin$(OBJ) $(OBJ_DIR)_vsscanf$(OBJ) $(OBJ_DIR)_usleep$(OBJ) \ ! $(OBJ_DIR)_debug$(OBJ) $(OBJ_DIR)_copywin$(OBJ) $(OBJ_DIR)_memmove$(OBJ) \ ! $(OBJ_DIR)_dosmem$(OBJ) PRIVATE = $(PRIV1) $(PRIV2) $(PRIV3) $(PRIV4) $(PRIV5) *** curspriv.org Thu Jun 3 20:22:09 1993 --- curspriv.h Fri Jun 4 09:16:13 1993 *************** *** 69,74 **** --- 69,93 ---- # define _FP_SEGMENT(p) (unsigned short)(((long)fp) >> 4) # define _FP_OFFSET(p) ((unsigned short)fp & 0x000f) # endif + + # ifdef GO32 + unsigned char getdosmembyte (int offs); /* see: private\_dosmem.c */ + unsigned short getdosmemword (int offs); + void setdosmembyte (int offs, unsigned char b); + void setdosmemword (int offs, unsigned short w); + # else + # if SMALL || MEDIUM || MSC + # define getdosmembyte(offs) (*((unsigned char far *) _FAR_POINTER(0,offs))) + # define getdosmemword(offs) (*((unsigned short far *) _FAR_POINTER(0,offs))) + # define setdosmembyte(offs,x) (*((unsigned char far *) _FAR_POINTER(0,offs)) = (x)) + # define setdosmemword(offs,x) (*((unsigned short far *) _FAR_POINTER(0,offs)) = (x)) + # else + # define getdosmembyte(offs) (*((unsigned char *) _FAR_POINTER(0,offs))) + # define getdosmemword(offs) (*((unsigned short *) _FAR_POINTER(0,offs))) + # define setdosmembyte(offs,x) (*((unsigned char *) _FAR_POINTER(0,offs)) = (x)) + # define setdosmemword(offs,x) (*((unsigned short *) _FAR_POINTER(0,offs)) = (x)) + # endif + # endif #endif /*----------------------------------------*/ *** portable/flushinp.org Thu Jun 3 20:31:34 1993 --- portable/flushinp.c Thu Jun 3 20:33:32 1993 *************** *** 45,61 **** extern int c_gindex; /* getter index */ extern int c_ungind; /* wungetch() push index */ - #if defined(DOS) && defined(FAST_VIDEO) - short *KB_HEAD = (short *) _FAR_POINTER(0,0x41a); /* 40:1A BIOS KB head */ - short *KB_TAIL = (short *) _FAR_POINTER(0,0x41c); /* 40:1C BIOS KB tail */ - #endif - #ifdef PDCDEBUG if (trace_on) PDC_debug("flushinp() - called\n"); #endif #if defined(DOS) && defined(FAST_VIDEO) ! *KB_HEAD = *KB_TAIL; /* Force the BIOS kbd buf */ /* head/tail pointers to be the */ /* same... Real nasty trick... */ #endif --- 45,56 ---- extern int c_gindex; /* getter index */ extern int c_ungind; /* wungetch() push index */ #ifdef PDCDEBUG if (trace_on) PDC_debug("flushinp() - called\n"); #endif #if defined(DOS) && defined(FAST_VIDEO) ! setdosmemword (0x41a, getdosmemword (0x41c)); /* Force the BIOS kbd buf */ /* head/tail pointers to be the */ /* same... Real nasty trick... */ #endif *** private/_clrupda.org Thu Jun 3 20:35:24 1993 --- private/_clrupda.c Thu Jun 3 20:43:37 1993 *************** *** 117,123 **** #endif #ifdef DOS ! # if (SMALL || MEDIUM) segread(&segregs); ds = segregs.ds; movedata(ds, (int)ch, --- 117,128 ---- #endif #ifdef DOS ! # ifdef GO32 ! dosmemput (ch, COLS * sizeof(chtype), ! (void *)_FAR_POINTER(_cursvar.video_seg, ! _cursvar.video_ofs + (i * COLS * sizeof(chtype)))); ! # else ! # if (SMALL || MEDIUM) segread(&segregs); ds = segregs.ds; movedata(ds, (int)ch, *************** *** 124,133 **** _cursvar.video_seg, _cursvar.video_ofs + (i*COLS*sizeof(chtype)), (COLS * sizeof(chtype))); ! # else memcpy((void *)_FAR_POINTER(_cursvar.video_seg, _cursvar.video_ofs + (i * COLS * sizeof(chtype))), ch, (COLS * sizeof(chtype))); # endif #endif --- 129,139 ---- _cursvar.video_seg, _cursvar.video_ofs + (i*COLS*sizeof(chtype)), (COLS * sizeof(chtype))); ! # else memcpy((void *)_FAR_POINTER(_cursvar.video_seg, _cursvar.video_ofs + (i * COLS * sizeof(chtype))), ch, (COLS * sizeof(chtype))); + # endif # endif #endif *** private/_fixcurs.org Thu Jun 3 20:44:01 1993 --- private/_fixcurs.c Thu Jun 3 20:47:52 1993 *************** *** 39,49 **** int PDC_fix_cursor(int flag) { #ifdef DOS - # if SMALL || MEDIUM || MSC - char far* INFO = (char far *)_FAR_POINTER(0,0x0487); - # else - char * INFO = (char *)_FAR_POINTER(0,0x0487); - # endif #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_fix_cursor() - called\n"); --- 39,44 ---- *************** *** 62,70 **** case _EGAMONO: case _MDS_GENIUS: /* Some clones look like a Genius;-) */ if (flag & 0x01) ! *INFO |= 0x01; /* Enable emnulation */ else ! *INFO &= (*INFO & ~0x01); /* Disable emnulation */ break; case _VGACOLOR: --- 57,65 ---- case _EGAMONO: case _MDS_GENIUS: /* Some clones look like a Genius;-) */ if (flag & 0x01) ! setdosmembyte (0x487, getdosmembyte (0x487) | 0x01); /* Enable emulation */ else ! setdosmembyte (0x487, getdosmembyte (0x487) & ~0x01); /* Disable emulation */ break; case _VGACOLOR: *** private/_gbiosky.org Thu Jun 3 20:48:11 1993 --- private/_gbiosky.c Thu Jun 3 20:49:31 1993 *************** *** 39,49 **** #if defined (DOS) int ascii,scan; static unsigned char keyboard_function=0xFF; - # if SMALL || MEDIUM || MSC - unsigned char far *enhanced_keyboard; - # else - unsigned char *enhanced_keyboard; - # endif #endif #if defined (OS2) --- 39,44 ---- *************** *** 63,73 **** #if defined (DOS) if (keyboard_function == 0xFF) { - # if SMALL || MEDIUM || MSC - enhanced_keyboard = (unsigned char far *) _FAR_POINTER(0,0x496); - # else - enhanced_keyboard = (unsigned char *) _FAR_POINTER(0,0x496); - # endif regs.h.ah = 0x02; /* get shift status for all keyboards */ int86(0x16, ®s, ®s); scan = regs.h.al; --- 58,63 ---- *************** *** 74,80 **** regs.h.ah = 0x12; /* get shift status for enhanced keyboards */ int86(0x16, ®s, ®s); if (scan == regs.h.al ! && *enhanced_keyboard == 0x10) keyboard_function = 0x10; else keyboard_function = 0x0; --- 64,70 ---- regs.h.ah = 0x12; /* get shift status for enhanced keyboards */ int86(0x16, ®s, ®s); if (scan == regs.h.al ! && getdosmembyte(0x496) == 0x10) keyboard_function = 0x10; else keyboard_function = 0x0; *** private/_getcrsr.org Thu Jun 3 20:49:57 1993 --- private/_getcrsr.c Thu Jun 3 20:51:11 1993 *************** *** 31,41 **** { #ifdef DOS - # if SMALL || MEDIUM - short far* CURSOR_MODE = (short far *) _FAR_POINTER(0,0x0460); - # else - short * CURSOR_MODE = (short *) _FAR_POINTER(0,0x0460); - # endif short cmode; #endif --- 31,36 ---- *************** *** 63,69 **** #endif #ifdef DOS ! cmode = *CURSOR_MODE; return (cmode); #endif --- 58,64 ---- #endif #ifdef DOS ! cmode = getdosmemword (0x460); return (cmode); #endif *** private/_getfont.org Thu Jun 3 20:51:24 1993 --- private/_getfont.c Thu Jun 3 20:52:32 1993 *************** *** 33,43 **** { #if defined (DOS) && defined (FAST_VIDEO) int retval; - # if SMALL || MEDIUM - short far *POINTS = (short far *) _FAR_POINTER (0,0x485); - # else - short *POINTS = (short *) _FAR_POINTER (0,0x485); - # endif #endif #ifdef OS2 --- 33,38 ---- *************** *** 49,55 **** #endif #if defined (DOS) && defined (FAST_VIDEO) ! retval = *POINTS; if ((retval == 0) && (_cursvar.adapter == _MDS_GENIUS)) { retval = _FONT15; /* Assume the MDS Genius is in 66 line mode. */ --- 44,50 ---- #endif #if defined (DOS) && defined (FAST_VIDEO) ! retval = getdosmemword (0x485); if ((retval == 0) && (_cursvar.adapter == _MDS_GENIUS)) { retval = _FONT15; /* Assume the MDS Genius is in 66 line mode. */ *** private/_getrows.org Thu Jun 3 20:52:43 1993 --- private/_getrows.c Thu Jun 3 20:53:44 1993 *************** *** 36,46 **** int PDC_get_rows(void) { #ifdef DOS - # if SMALL || MEDIUM - char far* ROWS = (char far *) _FAR_POINTER(0,0x484); - # else - char * ROWS = (char *) _FAR_POINTER(0,0x484); - # endif int rows; char *env_rows; #endif --- 36,41 ---- *************** *** 62,68 **** #ifdef DOS /* use the value from LINES environment variable, if set. MH 10-Jun-92 */ /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */ ! rows = *ROWS + 1; env_rows = (char *)getenv("LINES"); if (env_rows != (char *)NULL) rows = min(atoi(env_rows),rows); --- 57,63 ---- #ifdef DOS /* use the value from LINES environment variable, if set. MH 10-Jun-92 */ /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */ ! rows = getdosmembyte(0x484) + 1; env_rows = (char *)getenv("LINES"); if (env_rows != (char *)NULL) rows = min(atoi(env_rows),rows); *** private/_queryad.org Thu Jun 3 20:54:01 1993 --- private/_queryad.c Thu Jun 3 20:55:44 1993 *************** *** 47,57 **** #ifdef DOS int equip; struct SREGS segs; ! # if SMALL || MEDIUM ! short far *VIDEO_BASE = (void far *) _FAR_POINTER(0,0x0463); ! # else ! short *VIDEO_BASE = (void *) _FAR_POINTER(0,0x0463); ! # endif #endif #ifdef OS2 --- 47,53 ---- #ifdef DOS int equip; struct SREGS segs; ! short video_base = getdosmemword (0x463); #endif #ifdef OS2 *************** *** 164,170 **** } } } ! if (*VIDEO_BASE == 0x3d4) { _cursvar.video_seg = 0xb800; switch (retval) --- 160,166 ---- } } } ! if (video_base == 0x3d4) { _cursvar.video_seg = 0xb800; switch (retval) *************** *** 179,185 **** break; } } ! if (*VIDEO_BASE == 0x3b4) { _cursvar.video_seg = 0xb000; switch (retval) --- 175,181 ---- break; } } ! if (video_base == 0x3b4) { _cursvar.video_seg = 0xb000; switch (retval) *** private/_scropen.org Thu Jun 3 20:56:00 1993 --- private/_scropen.c Thu Jun 3 20:56:55 1993 *************** *** 40,53 **** int PDC_scr_open(SCREEN *internal, bool echo) { - #ifdef DOS - # if SMALL || MEDIUM - char far *INFO = (char far *) _FAR_POINTER(0,0x487); - # else - char *INFO = (char *) _FAR_POINTER(0,0x487); - # endif - #endif - #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_scr_open() - called\n"); #endif --- 40,45 ---- *************** *** 78,84 **** #ifdef DOS internal->orig_attr = 0; ! internal->orig_emulation = *INFO; #endif #ifdef OS2 --- 70,76 ---- #ifdef DOS internal->orig_attr = 0; ! internal->orig_emulation = getdosmembyte (0x487); #endif #ifdef OS2 *** private/_xfrmlin.org Thu Jun 3 20:57:08 1993 --- private/_xfrmlin.c Thu Jun 3 21:02:32 1993 *************** *** 134,140 **** #endif #ifdef DOS ! # if SMALL || MEDIUM segread(&segregs); ds = segregs.ds; movedata(ds,(int)ch, --- 134,145 ---- #endif #ifdef DOS ! # ifdef GO32 ! dosmemput (ch, len * sizeof(chtype), ! (void *)_FAR_POINTER(_cursvar.video_seg, ! _cursvar.video_ofs + (((lineno * curscr->_maxx) + x) * sizeof(chtype)))); ! # else ! # if SMALL || MEDIUM segread(&segregs); ds = segregs.ds; movedata(ds,(int)ch, *************** *** 141,150 **** _cursvar.video_seg, _cursvar.video_ofs+(((lineno*curscr->_maxx)+x)*sizeof(chtype)), len * sizeof(chtype)); ! # else memcpy((void *)_FAR_POINTER(_cursvar.video_seg, _cursvar.video_ofs + (((lineno * curscr->_maxx) + x) * sizeof(chtype))), ch, len * sizeof(chtype)); # endif #endif --- 146,156 ---- _cursvar.video_seg, _cursvar.video_ofs+(((lineno*curscr->_maxx)+x)*sizeof(chtype)), len * sizeof(chtype)); ! # else memcpy((void *)_FAR_POINTER(_cursvar.video_seg, _cursvar.video_ofs + (((lineno * curscr->_maxx) + x) * sizeof(chtype))), ch, len * sizeof(chtype)); + # endif # endif #endif -------------------- new file: private/_dosmem.c ------------------------------ #define CURSES_LIBRARY 1 #include #ifdef PDCDEBUG char *rcsid_PDC_dosmem = "$Header: c:/curses/private/RCS/_dosmem.c%v 2.0 1992/11/15 03:29:35 MH Rel $"; #endif #ifdef GO32 #include /* prototypes of dosmemget() and dosmemput() */ unsigned char getdosmembyte (int offset) { unsigned char b; dosmemget (offset, sizeof(unsigned char), &b); return b; } unsigned short getdosmemword (int offset) { unsigned short w; dosmemget (offset, sizeof(unsigned short), &w); return w; } void setdosmembyte (int offset, unsigned char b) { dosmemput (&b, sizeof(unsigned char), offset); } void setdosmemword (int offset, unsigned short w) { dosmemput (&w, sizeof(unsigned short), offset); } #endif -------------------- end of PDCurses patches ---------------------------------