mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-24 15:55:14 +00:00
Per common recommedations, DJGPP now uses __dpmi_int() instead of
int86() or _go32_etc. This breaks compatibility with DJGPP 1.x; but then, DJGPP 2.x is ten years old, and free.
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
RCSID("$Id: pdcdisp.c,v 1.52 2006/09/22 15:39:30 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcdisp.c,v 1.53 2006/09/30 15:45:04 wmcbrine Exp $");
|
||||
|
||||
#ifdef __PACIFIC__
|
||||
void movedata(unsigned sseg, unsigned soff, unsigned dseg,
|
||||
@@ -51,7 +51,7 @@ void movedata(unsigned sseg, unsigned soff, unsigned dseg,
|
||||
|
||||
void PDC_gotoyx(int row, int col)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
|
||||
|
||||
@@ -59,7 +59,7 @@ void PDC_gotoyx(int row, int col)
|
||||
regs.h.bh = 0;
|
||||
regs.h.dh = (unsigned char) row;
|
||||
regs.h.dl = (unsigned char) col;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
}
|
||||
|
||||
/*man-start**************************************************************
|
||||
@@ -78,7 +78,7 @@ void PDC_gotoyx(int row, int col)
|
||||
|
||||
static void PDC_putc(chtype ch, unsigned short count)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
PDC_LOG(("PDC_putc() - called\n"));
|
||||
|
||||
@@ -91,7 +91,7 @@ static void PDC_putc(chtype ch, unsigned short count)
|
||||
#else
|
||||
regs.x.cx = count;
|
||||
#endif
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
}
|
||||
|
||||
/*man-start**************************************************************
|
||||
@@ -113,7 +113,7 @@ static void PDC_putc(chtype ch, unsigned short count)
|
||||
|
||||
void PDC_putctty(chtype ch)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
PDC_LOG(("PDC_putctty() - called\n"));
|
||||
|
||||
@@ -121,7 +121,7 @@ void PDC_putctty(chtype ch)
|
||||
regs.h.al = (unsigned char) (ch & 0xff);
|
||||
regs.h.bh = 0;
|
||||
regs.h.bl = chtype_attr(ch);
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
}
|
||||
|
||||
/*man-start**************************************************************
|
||||
|
||||
21
dos/pdcdos.h
21
dos/pdcdos.h
@@ -15,7 +15,7 @@
|
||||
* See the file maintain.er for details of the current maintainer. *
|
||||
************************************************************************/
|
||||
|
||||
/* $Id: pdcdos.h,v 1.15 2006/09/21 16:09:34 wmcbrine Exp $ */
|
||||
/* $Id: pdcdos.h,v 1.16 2006/09/30 15:45:04 wmcbrine Exp $ */
|
||||
|
||||
#define CURSES_LIBRARY 1
|
||||
#include <curses.h>
|
||||
@@ -70,7 +70,6 @@ extern unsigned pdc_video_seg;
|
||||
extern unsigned pdc_video_ofs;
|
||||
|
||||
#ifdef __DJGPP__ /* Note: works only in plain DOS... */
|
||||
# define _NAIVE_DOS_REGS
|
||||
# if DJGPP == 2
|
||||
# define _FAR_POINTER(s,o) ((((int)(s)) << 4) + ((int)(o)))
|
||||
# else
|
||||
@@ -91,11 +90,6 @@ extern unsigned pdc_video_ofs;
|
||||
#endif
|
||||
#define _FP_OFFSET(p) ((unsigned short)p & 0x000f)
|
||||
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
# define int86 int386
|
||||
# define int86x int386x
|
||||
#endif
|
||||
|
||||
#ifdef __DJGPP__
|
||||
unsigned char getdosmembyte(int offs);
|
||||
unsigned short getdosmemword(int offs);
|
||||
@@ -117,6 +111,19 @@ void setdosmemword(int offs, unsigned short w);
|
||||
(*((unsigned short PDC_FAR *) _FAR_POINTER(0,offs)) = (x))
|
||||
#endif
|
||||
|
||||
#ifdef __DJGPP__
|
||||
# include <dpmi.h>
|
||||
# define PDCREGS __dpmi_regs
|
||||
# define PDCINT(vector, regs) __dpmi_int(vector, ®s)
|
||||
#else
|
||||
# define PDCREGS union REGS
|
||||
# if defined(__WATCOMC__) && defined(__386__)
|
||||
# define PDCINT(vector, regs) int386(vector, ®s, ®s)
|
||||
# else
|
||||
# define PDCINT(vector, regs) int86(vector, ®s, ®s)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Monitor (terminal) type information */
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
RCSID("$Id: pdcgetsc.c,v 1.32 2006/08/13 06:32:29 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcgetsc.c,v 1.33 2006/09/30 15:45:04 wmcbrine Exp $");
|
||||
|
||||
/*man-start**************************************************************
|
||||
|
||||
@@ -46,13 +46,13 @@ RCSID("$Id: pdcgetsc.c,v 1.32 2006/08/13 06:32:29 wmcbrine Exp $");
|
||||
|
||||
int PDC_get_cursor_pos(int *row, int *col)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
PDC_LOG(("PDC_get_cursor_pos() - called\n"));
|
||||
|
||||
regs.h.ah = 0x03;
|
||||
regs.h.bh = 0;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
*row = regs.h.dh;
|
||||
*col = regs.h.dl;
|
||||
|
||||
@@ -82,7 +82,7 @@ int PDC_get_cursor_pos(int *row, int *col)
|
||||
|
||||
int PDC_get_columns(void)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
int cols;
|
||||
const char *env_cols;
|
||||
|
||||
@@ -92,7 +92,7 @@ int PDC_get_columns(void)
|
||||
/* and use the minimum of COLS and return from int10h MH 18-Jun-92 */
|
||||
|
||||
regs.h.ah = 0x0f;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
cols = (int)regs.h.ah;
|
||||
|
||||
env_cols = getenv("COLS");
|
||||
|
||||
22
dos/pdckbd.c
22
dos/pdckbd.c
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "pdcdos.h"
|
||||
|
||||
RCSID("$Id: pdckbd.c,v 1.39 2006/09/10 20:26:28 wmcbrine Exp $");
|
||||
RCSID("$Id: pdckbd.c,v 1.40 2006/09/30 15:45:04 wmcbrine Exp $");
|
||||
|
||||
/************************************************************************
|
||||
* Table for key code translation of function keys in keypad mode *
|
||||
@@ -188,7 +188,7 @@ bool PDC_check_bios_key(void)
|
||||
|
||||
int PDC_get_bios_key(void)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
int ascii, scan;
|
||||
static unsigned char keyboard_function = 0xFF;
|
||||
|
||||
@@ -199,13 +199,13 @@ int PDC_get_bios_key(void)
|
||||
/* get shift status for all keyboards */
|
||||
|
||||
regs.h.ah = 0x02;
|
||||
int86(0x16, ®s, ®s);
|
||||
PDCINT(0x16, regs);
|
||||
scan = regs.h.al;
|
||||
|
||||
/* get shift status for enhanced keyboards */
|
||||
|
||||
regs.h.ah = 0x12;
|
||||
int86(0x16, ®s, ®s);
|
||||
regs.h.ah = 0x12;
|
||||
PDCINT(0x16, regs);
|
||||
|
||||
if (scan == regs.h.al && getdosmembyte(0x496) == 0x10)
|
||||
keyboard_function = 0x10;
|
||||
@@ -214,7 +214,7 @@ int PDC_get_bios_key(void)
|
||||
}
|
||||
|
||||
regs.h.ah = keyboard_function;
|
||||
int86(0x16, ®s, ®s);
|
||||
PDCINT(0x16, regs);
|
||||
ascii = regs.h.al;
|
||||
scan = regs.h.ah;
|
||||
|
||||
@@ -225,7 +225,7 @@ int PDC_get_bios_key(void)
|
||||
/* get shift status for all keyboards */
|
||||
|
||||
regs.h.ah = 0x02;
|
||||
int86(0x16, ®s, ®s);
|
||||
PDCINT(0x16, regs);
|
||||
|
||||
if (regs.h.al & 0x03)
|
||||
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
|
||||
@@ -316,13 +316,13 @@ int PDC_get_bios_key(void)
|
||||
|
||||
bool PDC_get_ctrl_break(void)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
PDC_LOG(("PDC_get_ctrl_break() - called\n"));
|
||||
|
||||
regs.h.ah = 0x33;
|
||||
regs.h.al = 0x00;
|
||||
int86(0x21, ®s, ®s);
|
||||
PDCINT(0x21, regs);
|
||||
|
||||
return (bool)regs.h.dl;
|
||||
}
|
||||
@@ -349,7 +349,7 @@ bool PDC_get_ctrl_break(void)
|
||||
int PDC_set_ctrl_break(bool setting)
|
||||
{
|
||||
#ifndef __DJGPP__
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
#endif
|
||||
PDC_LOG(("PDC_set_ctrl_break() - called\n"));
|
||||
|
||||
@@ -361,7 +361,7 @@ int PDC_set_ctrl_break(bool setting)
|
||||
regs.h.ah = 0x33;
|
||||
regs.h.al = 0x00;
|
||||
regs.h.dl = (unsigned char) (setting ? 1 : 0);
|
||||
int86(0x21, ®s, ®s);
|
||||
PDCINT(0x21, regs);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
104
dos/pdcscrn.c
104
dos/pdcscrn.c
@@ -21,11 +21,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __DJGPP__
|
||||
# include <dpmi.h>
|
||||
# include <sys/movedata.h>
|
||||
#endif
|
||||
|
||||
RCSID("$Id: pdcscrn.c,v 1.56 2006/09/29 13:47:21 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcscrn.c,v 1.57 2006/09/30 15:45:04 wmcbrine Exp $");
|
||||
|
||||
int pdc_adapter; /* screen type */
|
||||
int pdc_scrnmode; /* default screen mode */
|
||||
@@ -95,7 +94,7 @@ static int get_font(void)
|
||||
|
||||
static void set_font(int size)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
if (pdc_bogus_adapter)
|
||||
return;
|
||||
@@ -119,13 +118,13 @@ static void set_font(int size)
|
||||
regs.h.ah = 0x11;
|
||||
regs.h.al = 0x12;
|
||||
regs.h.bl = 0x00;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
break;
|
||||
case _FONT14:
|
||||
regs.h.ah = 0x11;
|
||||
regs.h.al = 0x11;
|
||||
regs.h.bl = 0x00;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -140,19 +139,19 @@ static void set_font(int size)
|
||||
regs.h.ah = 0x11;
|
||||
regs.h.al = 0x12;
|
||||
regs.h.bl = 0x00;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
break;
|
||||
case _FONT14:
|
||||
regs.h.ah = 0x11;
|
||||
regs.h.al = 0x11;
|
||||
regs.h.bl = 0x00;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
break;
|
||||
case _FONT16:
|
||||
regs.h.ah = 0x11;
|
||||
regs.h.al = 0x14;
|
||||
regs.h.bl = 0x00;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +166,7 @@ static void set_font(int size)
|
||||
|
||||
static void set_80x25(void)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
switch (pdc_adapter)
|
||||
{
|
||||
@@ -180,12 +179,12 @@ static void set_80x25(void)
|
||||
case _MCGAMONO:
|
||||
regs.h.ah = 0x00;
|
||||
regs.h.al = 0x03;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
break;
|
||||
case _MDA:
|
||||
regs.h.ah = 0x00;
|
||||
regs.h.al = 0x07;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,10 +192,10 @@ static void set_80x25(void)
|
||||
|
||||
static int get_scrn_mode(void)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
regs.h.ah = 0x0f;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
return (int)regs.h.al;
|
||||
}
|
||||
@@ -206,13 +205,13 @@ static int get_scrn_mode(void)
|
||||
|
||||
static void set_scrn_mode(int new_mode)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
if (get_scrn_mode() != new_mode)
|
||||
{
|
||||
regs.h.ah = 0;
|
||||
regs.h.al = (unsigned char) new_mode;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
}
|
||||
|
||||
pdc_font = get_font();
|
||||
@@ -288,16 +287,11 @@ static int sanity_check(int adapter)
|
||||
|
||||
static int query_adapter_type(void)
|
||||
{
|
||||
union REGS regs;
|
||||
int equip;
|
||||
PDCREGS regs;
|
||||
int retval = _NONE;
|
||||
|
||||
/* thanks to paganini@ax.apc.org for the GO32 fix */
|
||||
|
||||
#ifdef __DJGPP__
|
||||
_go32_dpmi_registers dpmi_regs;
|
||||
#endif
|
||||
|
||||
#if !defined(__DJGPP__) && !defined(__WATCOMC__)
|
||||
struct SREGS segs;
|
||||
#endif
|
||||
@@ -309,7 +303,7 @@ static int query_adapter_type(void)
|
||||
|
||||
regs.h.ah = 0x1a;
|
||||
regs.h.al = 0;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
if ((regs.h.al == 0x1a) && (retval == _NONE))
|
||||
{
|
||||
@@ -365,7 +359,7 @@ static int query_adapter_type(void)
|
||||
# else
|
||||
regs.x.bx = 0x10;
|
||||
# endif
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
if ((regs.h.bl != 0x10) && (retval == _NONE))
|
||||
{
|
||||
@@ -373,7 +367,7 @@ static int query_adapter_type(void)
|
||||
|
||||
regs.h.ah = 0x12;
|
||||
regs.h.bl = 0x10;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
if (regs.h.bh == 0)
|
||||
retval = _EGACOLOR;
|
||||
@@ -384,16 +378,15 @@ static int query_adapter_type(void)
|
||||
{
|
||||
/* Now we know we only have CGA or MDA */
|
||||
|
||||
int86(0x11, ®s, ®s);
|
||||
equip = (regs.h.al & 0x30) >> 4;
|
||||
PDCINT(0x11, regs);
|
||||
|
||||
switch (equip)
|
||||
switch (regs.h.al & 0x30)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 0x10:
|
||||
case 0x20:
|
||||
retval = _CGA;
|
||||
break;
|
||||
case 3:
|
||||
case 0x30:
|
||||
retval = _MDA;
|
||||
break;
|
||||
default:
|
||||
@@ -443,25 +436,20 @@ static int query_adapter_type(void)
|
||||
/* Check for DESQview shadow buffer
|
||||
thanks to paganini@ax.apc.org for the GO32 fix */
|
||||
|
||||
#ifdef __DJGPP__
|
||||
memset(&dpmi_regs, 0, sizeof(dpmi_regs));
|
||||
dpmi_regs.h.ah = 0xfe;
|
||||
dpmi_regs.h.al = 0;
|
||||
dpmi_regs.x.di = pdc_video_ofs;
|
||||
dpmi_regs.x.es = pdc_video_seg;
|
||||
_go32_dpmi_simulate_int(0x10, &dpmi_regs);
|
||||
pdc_video_ofs = dpmi_regs.x.di;
|
||||
pdc_video_seg = dpmi_regs.x.es;
|
||||
#endif
|
||||
|
||||
#if !defined(__DJGPP__) && !defined(__WATCOMC__)
|
||||
#ifndef __WATCOMC__
|
||||
regs.h.ah = 0xfe;
|
||||
regs.h.al = 0;
|
||||
regs.x.di = pdc_video_ofs;
|
||||
# ifdef __DJGPP__
|
||||
regs.x.es = pdc_video_seg;
|
||||
__dpmi_int(0x10, ®s);
|
||||
pdc_video_seg = regs.x.es;
|
||||
# else
|
||||
segs.es = pdc_video_seg;
|
||||
int86x(0x10, ®s, ®s, &segs);
|
||||
pdc_video_ofs = regs.x.di;
|
||||
pdc_video_seg = segs.es;
|
||||
# endif
|
||||
pdc_video_ofs = regs.x.di;
|
||||
#endif
|
||||
if (!pdc_adapter)
|
||||
pdc_adapter = retval;
|
||||
@@ -732,36 +720,22 @@ bool PDC_can_change_color(void)
|
||||
|
||||
int PDC_color_content(short color, short *red, short *green, short *blue)
|
||||
{
|
||||
/* With int86(), DJGPP fails to report the red register; hence
|
||||
the _dpmi_ stuff */
|
||||
|
||||
if (pdc_adapter == _VGACOLOR)
|
||||
{
|
||||
#ifdef __DJGPP__
|
||||
_go32_dpmi_registers regs;
|
||||
PDCREGS regs;
|
||||
|
||||
memset(®s, 0, sizeof(regs));
|
||||
#else
|
||||
union REGS regs;
|
||||
#endif
|
||||
regs.h.ah = 0x10;
|
||||
regs.h.al = 0x07;
|
||||
regs.h.bl = color;
|
||||
|
||||
#ifdef __DJGPP__
|
||||
_go32_dpmi_simulate_int(0x10, ®s);
|
||||
#else
|
||||
int86(0x10, ®s, ®s);
|
||||
#endif
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
regs.h.ah = 0x10;
|
||||
regs.h.al = 0x15;
|
||||
regs.h.bl = regs.h.bh;
|
||||
|
||||
#ifdef __DJGPP__
|
||||
_go32_dpmi_simulate_int(0x10, ®s);
|
||||
#else
|
||||
int86(0x10, ®s, ®s);
|
||||
#endif
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
*red = DIVROUND((unsigned)(regs.h.dh) * 1000, 63);
|
||||
*green = DIVROUND((unsigned)(regs.h.ch) * 1000, 63);
|
||||
*blue = DIVROUND((unsigned)(regs.h.cl) * 1000, 63);
|
||||
@@ -776,13 +750,13 @@ int PDC_init_color(short color, short red, short green, short blue)
|
||||
{
|
||||
if (pdc_adapter == _VGACOLOR)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
|
||||
regs.h.ah = 0x10;
|
||||
regs.h.al = 0x07;
|
||||
regs.h.bl = color;
|
||||
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
regs.h.ah = 0x10;
|
||||
regs.h.al = 0x10;
|
||||
@@ -793,7 +767,7 @@ int PDC_init_color(short color, short red, short green, short blue)
|
||||
regs.h.ch = DIVROUND((unsigned)green * 63, 1000);
|
||||
regs.h.cl = DIVROUND((unsigned)blue * 63, 1000);
|
||||
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
#include "pdcdos.h"
|
||||
|
||||
RCSID("$Id: pdcsetsc.c,v 1.28 2006/08/17 22:05:41 wmcbrine Exp $");
|
||||
RCSID("$Id: pdcsetsc.c,v 1.29 2006/09/30 15:45:04 wmcbrine Exp $");
|
||||
|
||||
int PDC_curs_set(int visibility)
|
||||
{
|
||||
union REGS regs;
|
||||
PDCREGS regs;
|
||||
int ret_vis, start, end;
|
||||
|
||||
PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
|
||||
@@ -50,7 +50,7 @@ int PDC_curs_set(int visibility)
|
||||
regs.h.al = (unsigned char)pdc_scrnmode;
|
||||
regs.h.ch = (unsigned char)start;
|
||||
regs.h.cl = (unsigned char)end;
|
||||
int86(0x10, ®s, ®s);
|
||||
PDCINT(0x10, regs);
|
||||
|
||||
return ret_vis;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user