Files
nethack/sys/msdos/pckeys.c
nhmall 02a48aa8cf split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.

It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.

Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.

To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.

A global variable named 'amulets', would be found in ga.
    ga.amulets
     ^ ^
A global varable named 'move', would be found in gm.
    gm.moves
     ^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
    gv.val_for_n_or_more
     ^ ^
A global variable named 'youmonst' would be found in gy.
    gy.youmonst
     ^ ^
2022-11-29 21:53:21 -05:00

133 lines
3.0 KiB
C

/* NetHack 3.7 pckeys.c $NHDT-Date: 1596498270 2020/08/03 23:44:30 $ $NHDT-Branch: NetHack-3.7 $:$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"
#ifdef MSDOS
#ifdef USE_TILES
#include "wintty.h"
#include "pcvideo.h"
boolean pckeys(unsigned char, unsigned char);
static void userpan(boolean);
static void overview(boolean);
static void traditional(boolean);
static void refresh(void);
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)
{
boolean opening_dialog;
opening_dialog = gp.pl_character[0] ? FALSE : TRUE;
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
case 0x74: /* Control-right_arrow = scroll horizontal to right */
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
userpan(1);
break;
case 0x73: /* Control-left_arrow = scroll horizontal to left */
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
userpan(0);
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;
default:
return FALSE;
}
return TRUE;
}
static void
userpan(boolean on)
{
#ifdef SCREEN_VGA
if (iflags.usevga)
vga_userpan(on);
#endif
#ifdef SCREEN_VESA
if (iflags.usevesa)
vesa_userpan(on);
#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 /* USE_TILES */
#endif /* MSDOS */
/*pckeys.c*/