add a macro to ease conditional testing based on active window port
Add WINDOWPORT macro
example:
if (WINDOWPORT("tty"))
pline("Look at me, I'm on tty at the moment!");
This commit is contained in:
@@ -260,6 +260,11 @@ struct wc_Opt {
|
|||||||
unsigned long wc_bit;
|
unsigned long wc_bit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Macro for the currently active Window Port whose function
|
||||||
|
pointers have been loaded */
|
||||||
|
#define WINDOWPORT(wn) \
|
||||||
|
(windowprocs.name && !strncmpi((wn), windowprocs.name, strlen((wn))))
|
||||||
|
|
||||||
/* role selection by player_selection(); this ought to be in the core... */
|
/* role selection by player_selection(); this ought to be in the core... */
|
||||||
#define RS_NAME 0
|
#define RS_NAME 0
|
||||||
#define RS_ROLE 1
|
#define RS_ROLE 1
|
||||||
|
|||||||
+1
-1
@@ -190,7 +190,7 @@ sanitize_name(namebuf)
|
|||||||
char *namebuf;
|
char *namebuf;
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
boolean strip_8th_bit = (!strcmp(windowprocs.name, "tty")
|
boolean strip_8th_bit = (WINDOWPORT("tty")
|
||||||
&& !iflags.wc_eight_bit_input);
|
&& !iflags.wc_eight_bit_input);
|
||||||
|
|
||||||
/* it's tempting to skip this for single-user platforms, since
|
/* it's tempting to skip this for single-user platforms, since
|
||||||
|
|||||||
@@ -1049,7 +1049,7 @@ wiz_show_wmodes(VOID_ARGS)
|
|||||||
int x, y;
|
int x, y;
|
||||||
char row[COLNO + 1];
|
char row[COLNO + 1];
|
||||||
struct rm *lev;
|
struct rm *lev;
|
||||||
boolean istty = !strcmp(windowprocs.name, "tty");
|
boolean istty = WINDOWPORT("tty");
|
||||||
|
|
||||||
win = create_nhwindow(NHW_TEXT);
|
win = create_nhwindow(NHW_TEXT);
|
||||||
if (istty)
|
if (istty)
|
||||||
|
|||||||
+1
-1
@@ -1279,7 +1279,7 @@ boolean uncomp;
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int f;
|
int f;
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
boolean istty = !strncmpi(windowprocs.name, "tty", 3);
|
boolean istty = WINDOWPORT("tty");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Strcpy(cfn, filename);
|
Strcpy(cfn, filename);
|
||||||
|
|||||||
+3
-3
@@ -828,7 +828,7 @@ register int fd;
|
|||||||
#ifdef AMII_GRAPHICS
|
#ifdef AMII_GRAPHICS
|
||||||
{
|
{
|
||||||
extern struct window_procs amii_procs;
|
extern struct window_procs amii_procs;
|
||||||
if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows) {
|
if (WINDOWPORT("amii") {
|
||||||
extern winid WIN_BASE;
|
extern winid WIN_BASE;
|
||||||
clear_nhwindow(WIN_BASE); /* hack until there's a hook for this */
|
clear_nhwindow(WIN_BASE); /* hack until there's a hook for this */
|
||||||
}
|
}
|
||||||
@@ -844,7 +844,7 @@ register int fd;
|
|||||||
curs(WIN_MAP, 1, 1);
|
curs(WIN_MAP, 1, 1);
|
||||||
dotcnt = 0;
|
dotcnt = 0;
|
||||||
dotrow = 2;
|
dotrow = 2;
|
||||||
if (strncmpi("X11", windowprocs.name, 3))
|
if (!WINDOWPORT("X11"))
|
||||||
putstr(WIN_MAP, 0, "Restoring:");
|
putstr(WIN_MAP, 0, "Restoring:");
|
||||||
#endif
|
#endif
|
||||||
restoreprocs.mread_flags = 1; /* return despite error */
|
restoreprocs.mread_flags = 1; /* return despite error */
|
||||||
@@ -859,7 +859,7 @@ register int fd;
|
|||||||
dotrow++;
|
dotrow++;
|
||||||
dotcnt = 0;
|
dotcnt = 0;
|
||||||
}
|
}
|
||||||
if (strncmpi("X11", windowprocs.name, 3)) {
|
if (!WINDOWPORT("X11")) {
|
||||||
putstr(WIN_MAP, 0, ".");
|
putstr(WIN_MAP, 0, ".");
|
||||||
}
|
}
|
||||||
mark_synch();
|
mark_synch();
|
||||||
|
|||||||
+2
-2
@@ -178,7 +178,7 @@ dosave0()
|
|||||||
dotcnt = 0;
|
dotcnt = 0;
|
||||||
dotrow = 2;
|
dotrow = 2;
|
||||||
curs(WIN_MAP, 1, 1);
|
curs(WIN_MAP, 1, 1);
|
||||||
if (strncmpi("X11", windowprocs.name, 3))
|
if (!WINDOWPORT("X11"))
|
||||||
putstr(WIN_MAP, 0, "Saving:");
|
putstr(WIN_MAP, 0, "Saving:");
|
||||||
#endif
|
#endif
|
||||||
#ifdef MFLOPPY
|
#ifdef MFLOPPY
|
||||||
@@ -242,7 +242,7 @@ dosave0()
|
|||||||
dotrow++;
|
dotrow++;
|
||||||
dotcnt = 0;
|
dotcnt = 0;
|
||||||
}
|
}
|
||||||
if (strncmpi("X11", windowprocs.name, 3)) {
|
if (!WINDOWPORT("X11")) {
|
||||||
putstr(WIN_MAP, 0, ".");
|
putstr(WIN_MAP, 0, ".");
|
||||||
}
|
}
|
||||||
mark_synch();
|
mark_synch();
|
||||||
|
|||||||
+2
-2
@@ -499,12 +499,12 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/*
|
/*
|
||||||
if (!strncmpi(windowprocs.name, "mswin", 5))
|
if (WINDOWPORT("mswin"))
|
||||||
NHWinMainInit();
|
NHWinMainInit();
|
||||||
else
|
else
|
||||||
*/
|
*/
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
if (!strncmpi(windowprocs.name, "tty", 3)) {
|
if (WINDOWPORT("tty")) {
|
||||||
iflags.use_background_glyph = FALSE;
|
iflags.use_background_glyph = FALSE;
|
||||||
nttty_open(1);
|
nttty_open(1);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+2
-2
@@ -198,7 +198,7 @@ getlock()
|
|||||||
#ifndef SELF_RECOVER
|
#ifndef SELF_RECOVER
|
||||||
if (eraseoldlocks()) {
|
if (eraseoldlocks()) {
|
||||||
#if defined(WIN32) && defined(TTY_GRAPHICS)
|
#if defined(WIN32) && defined(TTY_GRAPHICS)
|
||||||
if (!strncmpi(windowprocs.name, "tty", 3))
|
if (WINDOWPORT("tty"))
|
||||||
clear_screen(); /* display gets fouled up otherwise */
|
clear_screen(); /* display gets fouled up otherwise */
|
||||||
#endif
|
#endif
|
||||||
goto gotlock;
|
goto gotlock;
|
||||||
@@ -212,7 +212,7 @@ getlock()
|
|||||||
#else /*SELF_RECOVER*/
|
#else /*SELF_RECOVER*/
|
||||||
if (recover_savefile()) {
|
if (recover_savefile()) {
|
||||||
#if defined(WIN32) && defined(TTY_GRAPHICS)
|
#if defined(WIN32) && defined(TTY_GRAPHICS)
|
||||||
if (!strncmpi(windowprocs.name, "tty", 3))
|
if (WINDOWPORT("tty"))
|
||||||
clear_screen(); /* display gets fouled up otherwise */
|
clear_screen(); /* display gets fouled up otherwise */
|
||||||
#endif
|
#endif
|
||||||
goto gotlock;
|
goto gotlock;
|
||||||
|
|||||||
+8
-8
@@ -305,7 +305,7 @@ void intron() /* enable kbd interupts if enabled when game started */
|
|||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
/* Ugly hack to keep from changing tty modes for non-tty games -dlc */
|
/* Ugly hack to keep from changing tty modes for non-tty games -dlc */
|
||||||
if (!strcmp(windowprocs.name, "tty") && intr_char != nonesuch
|
if (WINDOWPORT("tty") && intr_char != nonesuch
|
||||||
&& curttyb2.intr_sym != '\003') {
|
&& curttyb2.intr_sym != '\003') {
|
||||||
curttyb2.intr_sym = '\003';
|
curttyb2.intr_sym = '\003';
|
||||||
setctty();
|
setctty();
|
||||||
@@ -317,7 +317,7 @@ void introff() /* disable kbd interrupts if required*/
|
|||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
/* Ugly hack to keep from changing tty modes for non-tty games -dlc */
|
/* Ugly hack to keep from changing tty modes for non-tty games -dlc */
|
||||||
if (!strcmp(windowprocs.name, "tty") && curttyb2.intr_sym != nonesuch) {
|
if (WINDOWPORT("tty") && curttyb2.intr_sym != nonesuch) {
|
||||||
curttyb2.intr_sym = nonesuch;
|
curttyb2.intr_sym = nonesuch;
|
||||||
setctty();
|
setctty();
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ void
|
|||||||
sco_mapon()
|
sco_mapon()
|
||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
if (!strcmp(windowprocs.name, "tty") && sco_flag_console) {
|
if (WINDOWPORT("tty") && sco_flag_console) {
|
||||||
if (sco_map_valid != -1) {
|
if (sco_map_valid != -1) {
|
||||||
ioctl(0, LDSMAP, sco_chanmap_buf);
|
ioctl(0, LDSMAP, sco_chanmap_buf);
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ void
|
|||||||
sco_mapoff()
|
sco_mapoff()
|
||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
if (!strcmp(windowprocs.name, "tty") && sco_flag_console) {
|
if (WINDOWPORT("tty") && sco_flag_console) {
|
||||||
sco_map_valid = ioctl(0, LDGMAP, sco_chanmap_buf);
|
sco_map_valid = ioctl(0, LDGMAP, sco_chanmap_buf);
|
||||||
if (sco_map_valid != -1) {
|
if (sco_map_valid != -1) {
|
||||||
ioctl(0, LDNMAP, (char *) 0);
|
ioctl(0, LDNMAP, (char *) 0);
|
||||||
@@ -379,7 +379,7 @@ void
|
|||||||
init_sco_cons()
|
init_sco_cons()
|
||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
if (!strcmp(windowprocs.name, "tty") && sco_flag_console) {
|
if (WINDOWPORT("tty") && sco_flag_console) {
|
||||||
atexit(sco_mapon);
|
atexit(sco_mapon);
|
||||||
sco_mapoff();
|
sco_mapoff();
|
||||||
load_symset("IBMGraphics", PRIMARY);
|
load_symset("IBMGraphics", PRIMARY);
|
||||||
@@ -409,7 +409,7 @@ void
|
|||||||
linux_mapon()
|
linux_mapon()
|
||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
if (!strcmp(windowprocs.name, "tty") && linux_flag_console) {
|
if (WINDOWPORT("tty") && linux_flag_console) {
|
||||||
write(1, "\033(B", 3);
|
write(1, "\033(B", 3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -419,7 +419,7 @@ void
|
|||||||
linux_mapoff()
|
linux_mapoff()
|
||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
if (!strcmp(windowprocs.name, "tty") && linux_flag_console) {
|
if (WINDOWPORT("tty") && linux_flag_console) {
|
||||||
write(1, "\033(U", 3);
|
write(1, "\033(U", 3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -439,7 +439,7 @@ void
|
|||||||
init_linux_cons()
|
init_linux_cons()
|
||||||
{
|
{
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
if (!strcmp(windowprocs.name, "tty") && linux_flag_console) {
|
if (WINDOWPORT("tty") && linux_flag_console) {
|
||||||
atexit(linux_mapon);
|
atexit(linux_mapon);
|
||||||
linux_mapoff();
|
linux_mapoff();
|
||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
|
|||||||
+10
-7
@@ -216,7 +216,7 @@ VA_DECL(const char *, s)
|
|||||||
/* error() may get called before tty is initialized */
|
/* error() may get called before tty is initialized */
|
||||||
if (iflags.window_inited)
|
if (iflags.window_inited)
|
||||||
end_screen();
|
end_screen();
|
||||||
if (windowprocs.name != NULL && !strncmpi(windowprocs.name, "tty", 3)) {
|
if (WINDOWPORT("tty")) {
|
||||||
buf[0] = '\n';
|
buf[0] = '\n';
|
||||||
(void) vsprintf(&buf[1], s, VA_ARGS);
|
(void) vsprintf(&buf[1], s, VA_ARGS);
|
||||||
Strcat(buf, "\n");
|
Strcat(buf, "\n");
|
||||||
@@ -239,6 +239,11 @@ Delay(int ms)
|
|||||||
void
|
void
|
||||||
win32_abort()
|
win32_abort()
|
||||||
{
|
{
|
||||||
|
boolean is_tty = FALSE;
|
||||||
|
|
||||||
|
#ifdef TTY_GRAPHICS
|
||||||
|
is_tty = WINDOWPORT("tty");
|
||||||
|
#endif
|
||||||
if (wizard) {
|
if (wizard) {
|
||||||
int c, ci, ct;
|
int c, ci, ct;
|
||||||
|
|
||||||
@@ -248,13 +253,11 @@ win32_abort()
|
|||||||
msmsg("Execute debug breakpoint wizard?");
|
msmsg("Execute debug breakpoint wizard?");
|
||||||
while ((ci = nhgetch()) != '\n') {
|
while ((ci = nhgetch()) != '\n') {
|
||||||
if (ct > 0) {
|
if (ct > 0) {
|
||||||
#ifdef TTY_GRAPHICS
|
if (is_tty)
|
||||||
backsp(); /* \b is visible on NT */
|
backsp(); /* \b is visible on NT console */
|
||||||
#endif
|
|
||||||
(void) putchar(' ');
|
(void) putchar(' ');
|
||||||
#ifdef TTY_GRAPHICS
|
if (is_tty)
|
||||||
backsp();
|
backsp();
|
||||||
#endif
|
|
||||||
ct = 0;
|
ct = 0;
|
||||||
c = 'n';
|
c = 'n';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user