Files
nethack/sys/msdos/pckeys.c
T
Ray Chason 7889eedfa5 MS-DOS: Support no-tiles and no-graphics builds
In previous versions of NetHack, setting -DUSE_TILES enabled the tile
support, while setting -DSUPPRESS_GRAPHICS produced a NetHack that
would write its TTY output to standard output, and rely on ANSI.SYS or
similar to do screen control. (USE_TILES is now TILES_IN_GLYPHMAP.)

This change ensures that the current NetHack can be built the same
ways.

One twist is that previous NetHacks would drop all support for graphical
modes when tiles were not supported. Thus sys/msdos/vid{vga,vesa}.c have
very disordered use of TILES_IN_GLYPHMAP. There was no need to check
this. But now, the graphical modes also support Unicode. A non-tiled
build should have the graphical modes, with only the text functions
present, provided that ENHANCED_SYMBOLS is defined.

Some unused and locally used symbols were cleaned up along the way.
2026-07-09 23:48:14 -04:00

157 lines
3.8 KiB
C

/* NetHack 5.0 pckeys.c $NHDT-Date: 1596498270 2020/08/03 23:44:30 $ $NHDT-Branch: NetHack-5.0 $:$NHDT-Revision: 1.14 $ */
/* Copyright (c) NetHack PC Development Team 1996 */
/* NetHack may be freely redistributed. See license for details. */
/*
* MSDOS tile-specific key handling.
*/
#include "hack.h"
#if defined(MSDOS) && defined(NO_TERMS)
#include "wintty.h"
#include "pcvideo.h"
boolean pckeys(unsigned char, unsigned char);
#ifdef TILES_IN_GLYPHMAP
static void userpan(enum vga_pan_direction pan);
static void overview(boolean);
static void traditional(boolean);
static void refresh(void);
#endif
extern struct WinDesc *wins[MAXWIN]; /* from wintty.c */
extern boolean inmap; /* from video.c */
#define SHIFT (0x1 | 0x2)
#define CTRL 0x4
#define ALT 0x8
/*
* Check for special interface manipulation keys.
* Returns TRUE if the scan code triggered something.
*
*/
boolean
pckeys(unsigned char scancode, unsigned char shift)
{
#ifdef TILES_IN_GLYPHMAP
boolean opening_dialog;
opening_dialog = svp.pl_character[0] ? FALSE : TRUE;
#endif
#ifndef TILES_IN_GLYPHMAP
nhUse(shift);
#endif
switch (scancode) {
#ifdef SIMULATE_CURSOR
case 0x3d: /* F3 = toggle cursor type */
HideCursor();
cursor_type += 1;
if (cursor_type >= NUM_CURSOR_TYPES)
cursor_type = 0;
DrawCursor();
break;
#endif
#ifdef TILES_IN_GLYPHMAP
case 0x74: /* Control-right_arrow = scroll horizontal to right */
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
userpan(pan_right);
break;
case 0x73: /* Control-left_arrow = scroll horizontal to left */
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
userpan(pan_left);
break;
/* Dosbox reports control-up and down arrows, but VirtualBox and QEMU
don't; accept home, end, page up and page down also */
case 0x77: /* control-home */
case 0x8D: /* control-up_arrow */
case 0x84: /* control-page_up */
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
userpan(pan_up);
break;
case 0x75: /* control-end */
case 0x91: /* control-down_arrow */
case 0x76: /* control-page_down */
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
userpan(pan_down);
break;
case 0x3E: /* F4 = toggle overview mode */
if (iflags.tile_view && !opening_dialog && !Is_rogue_level(&u.uz)) {
iflags.traditional_view = FALSE;
overview(iflags.over_view ? FALSE : TRUE);
refresh();
}
break;
case 0x3F: /* F5 = toggle traditional mode */
if (iflags.tile_view && !opening_dialog && !Is_rogue_level(&u.uz)) {
iflags.over_view = FALSE;
traditional(iflags.traditional_view ? FALSE : TRUE);
refresh();
}
break;
#endif /* TILES_IN_GLYPHMAP */
default:
return FALSE;
}
return TRUE;
}
#ifdef TILES_IN_GLYPHMAP
static void
userpan(enum vga_pan_direction pan)
{
#ifdef SCREEN_VGA
if (iflags.usevga)
vga_userpan(pan);
#endif
#ifdef SCREEN_VESA
if (iflags.usevesa)
vesa_userpan(pan);
#endif
}
static void
overview(boolean on)
{
#ifdef SCREEN_VGA
if (iflags.usevga)
vga_overview(on);
#endif
#ifdef SCREEN_VESA
if (iflags.usevesa)
vesa_overview(on);
#endif
}
static void
traditional(boolean on)
{
#ifdef SCREEN_VGA
if (iflags.usevga)
vga_traditional(on);
#endif
#ifdef SCREEN_VESA
if (iflags.usevesa)
vesa_traditional(on);
#endif
}
static void
refresh(void)
{
#ifdef SCREEN_VGA
if (iflags.usevga)
vga_refresh();
#endif
#ifdef SCREEN_VESA
if (iflags.usevesa)
vesa_refresh();
#endif
}
#endif /* TILES_IN_GLYPHMAP */
#endif /* MSDOS && NO_TERMS */
/*pckeys.c*/