Input refactoring, phase 1

Instead of two structs with many members, these structs are now an array
indexed by an enum.  This makes it easier to take actions on the entirety
of the input state.  The input core itself (input/ and gameinp.c) look a
lot messier at the moment; phase 2 will be to clean them up.  This phase is
mostly to get "typographical" changes across the code out of the way first
to minimize update disruption.

This refactoring has the eventual goal of eliminating the special purpose
input code scattered throught battles, SuperMelee's menus, and IP
exploration.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1312 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2004-01-15 07:52:45 +00:00
parent 702455687a
commit 7b2d5a6427
29 changed files with 375 additions and 350 deletions
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.4: Changes towards version 0.4:
- Input code refactoring, phase 1: Replaced messy structs with an
array indexed by an enum. -Michael
- Thread code refactoring: only the main thread will actually spawn - Thread code refactoring: only the main thread will actually spawn
threads, and thread IDs are properly recycled with SDL_WaitThead () threads, and thread IDs are properly recycled with SDL_WaitThead ()
once they're done. (With luck, this will fix bug #561) -Michael once they're done. (With luck, this will fix bug #561) -Michael
+11 -11
View File
@@ -1355,7 +1355,7 @@ SpewPhrases (COUNT wait_track)
#endif #endif
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
if (CurrentMenuState.cancel) if (PulsedInputState.key[KEY_MENU_CANCEL])
{ {
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 8)); SetSliderImage (SetAbsFrameIndex (ActivityFrame, 8));
JumpTrack (); JumpTrack ();
@@ -1369,13 +1369,13 @@ SpewPhrases (COUNT wait_track)
BOOLEAN left=FALSE, right=FALSE; BOOLEAN left=FALSE, right=FALSE;
if (optSmoothScroll == OPT_PC) if (optSmoothScroll == OPT_PC)
{ {
left = CurrentMenuState.left; left = PulsedInputState.key[KEY_MENU_LEFT];
right = CurrentMenuState.right; right = PulsedInputState.key[KEY_MENU_RIGHT];
} }
else if (optSmoothScroll == OPT_3DO) else if (optSmoothScroll == OPT_3DO)
{ {
left = ImmediateMenuState.left; left = ImmediateInputState.key[KEY_MENU_LEFT];
right = ImmediateMenuState.right; right = ImmediateInputState.key[KEY_MENU_RIGHT];
} }
if (right) if (right)
{ {
@@ -1578,7 +1578,7 @@ DoCommunication (PENCOUNTER_STATE pES)
TimeIn = GetTimeCounter (); TimeIn = GetTimeCounter ();
// Warning! This used to re-gather input data to check for rewind. // Warning! This used to re-gather input data to check for rewind.
UpdateInputState (); UpdateInputState ();
if (CurrentMenuState.left) if (PulsedInputState.key[KEY_MENU_LEFT])
{ {
FadeMusic (BACKGROUND_VOL, ONE_SECOND); FadeMusic (BACKGROUND_VOL, ONE_SECOND);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
@@ -1639,7 +1639,7 @@ DoCommunication (PENCOUNTER_STATE pES)
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
if (CurrentMenuState.select) if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
pES->phrase_buf_index = pES->phrase_buf_index =
pES->response_list[pES->cur_response].response_text.CharCount; pES->response_list[pES->cur_response].response_text.CharCount;
@@ -1661,7 +1661,7 @@ DoCommunication (PENCOUNTER_STATE pES)
(*pES->response_list[pES->cur_response].response_func) (*pES->response_list[pES->cur_response].response_func)
(pES->response_list[pES->cur_response].response_ref); (pES->response_list[pES->cur_response].response_ref);
} }
else if (CurrentMenuState.cancel && else if (PulsedInputState.key[KEY_MENU_CANCEL] &&
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE) LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
{ {
TFB_SoundChain *curr; TFB_SoundChain *curr;
@@ -1809,7 +1809,7 @@ DoCommunication (PENCOUNTER_STATE pES)
else else
{ {
response = pES->cur_response; response = pES->cur_response;
if (CurrentMenuState.left) if (PulsedInputState.key[KEY_MENU_LEFT])
{ {
FadeMusic (BACKGROUND_VOL, ONE_SECOND); FadeMusic (BACKGROUND_VOL, ONE_SECOND);
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
@@ -1857,10 +1857,10 @@ DoCommunication (PENCOUNTER_STATE pES)
TaskSwitch (); TaskSwitch ();
while (CommData.AlienTalkDesc.AnimFlags & PAUSE_TALKING); while (CommData.AlienTalkDesc.AnimFlags & PAUSE_TALKING);
} }
else if (CurrentMenuState.up) else if (PulsedInputState.key[KEY_MENU_UP])
response = (BYTE)((response + (BYTE)(pES->num_responses - 1)) response = (BYTE)((response + (BYTE)(pES->num_responses - 1))
% pES->num_responses); % pES->num_responses);
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
response = (BYTE)((BYTE)(response + 1) response = (BYTE)((BYTE)(response + 1)
% pES->num_responses); % pES->num_responses);
+3 -3
View File
@@ -147,18 +147,18 @@ DoConfirmExit (void)
ExitRequested = FALSE; ExitRequested = FALSE;
GamePaused = FALSE; GamePaused = FALSE;
UpdateInputState (); UpdateInputState ();
if (CurrentMenuState.select) if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
done = TRUE; done = TRUE;
PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1), PlaySoundEffect (SetAbsSoundIndex (MenuSounds, 1),
0, NotPositional (), NULL, GAME_SOUND_PRIORITY); 0, NotPositional (), NULL, GAME_SOUND_PRIORITY);
} }
else if (CurrentMenuState.cancel) else if (PulsedInputState.key[KEY_MENU_CANCEL])
{ {
done = TRUE; done = TRUE;
response = FALSE; response = FALSE;
} }
else if (CurrentMenuState.left || CurrentMenuState.right) else if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT])
{ {
response = !response; response = !response;
DrawConfirmationWindow (response); DrawConfirmationWindow (response);
+40 -14
View File
@@ -22,21 +22,49 @@
#include "starcon.h" #include "starcon.h"
#include "compiler.h" #include "compiler.h"
// This struct controls the various controls available to the player. // Enumerated type for controls
enum {
KEY_P1_THRUST,
KEY_P1_LEFT,
KEY_P1_RIGHT,
KEY_P1_DOWN,
KEY_P1_WEAPON,
KEY_P1_SPECIAL,
KEY_P1_ESCAPE,
KEY_P2_THRUST,
KEY_P2_LEFT,
KEY_P2_RIGHT,
KEY_P2_DOWN,
KEY_P2_WEAPON,
KEY_P2_SPECIAL,
KEY_LANDER_THRUST,
KEY_LANDER_LEFT,
KEY_LANDER_RIGHT,
KEY_LANDER_WEAPON,
KEY_LANDER_ESCAPE,
KEY_PAUSE,
KEY_EXIT,
KEY_ABORT,
KEY_DEBUG,
KEY_MENU_UP,
KEY_MENU_DOWN,
KEY_MENU_LEFT,
KEY_MENU_RIGHT,
KEY_MENU_SELECT,
KEY_MENU_CANCEL,
KEY_MENU_SPECIAL,
KEY_MENU_PAGE_UP,
KEY_MENU_PAGE_DOWN,
KEY_MENU_ZOOM_IN,
KEY_MENU_ZOOM_OUT,
KEY_MENU_DELETE,
NUM_KEYS
};
typedef struct _controller_input_state { typedef struct _controller_input_state {
int p1_thrust, p1_left, p1_right, p1_down, p1_weapon, p1_special, p1_escape; int key[NUM_KEYS];
int p2_thrust, p2_left, p2_right, p2_down, p2_weapon, p2_special;
int lander_thrust, lander_left, lander_right, lander_weapon, lander_escape;
int pause, exit, abort, debug;
} CONTROLLER_INPUT_STATE; } CONTROLLER_INPUT_STATE;
typedef struct _menu_input_state {
int up, down, left, right, select, cancel, special;
int page_up, page_down, zoom_in, zoom_out;
int del;
} MENU_INPUT_STATE;
typedef UBYTE BATTLE_INPUT_STATE; typedef UBYTE BATTLE_INPUT_STATE;
#define BATTLE_LEFT ((BATTLE_INPUT_STATE)(1 << 0)) #define BATTLE_LEFT ((BATTLE_INPUT_STATE)(1 << 0))
#define BATTLE_RIGHT ((BATTLE_INPUT_STATE)(1 << 1)) #define BATTLE_RIGHT ((BATTLE_INPUT_STATE)(1 << 1))
@@ -50,10 +78,8 @@ typedef BATTLE_INPUT_STATE (*battle_summary_func) (void);
extern battle_summary_func ComputerInput, HumanInput[NUM_PLAYERS]; extern battle_summary_func ComputerInput, HumanInput[NUM_PLAYERS];
extern battle_summary_func PlayerInput[NUM_PLAYERS]; extern battle_summary_func PlayerInput[NUM_PLAYERS];
extern CONTROLLER_INPUT_STATE CurrentInputState; extern CONTROLLER_INPUT_STATE CurrentInputState, PulsedInputState;
extern MENU_INPUT_STATE CurrentMenuState;
extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; extern volatile CONTROLLER_INPUT_STATE ImmediateInputState;
extern volatile MENU_INPUT_STATE ImmediateMenuState;
void UpdateInputState (void); void UpdateInputState (void);
void FlushInputState (void); void FlushInputState (void);
+4 -4
View File
@@ -34,7 +34,7 @@ DoSelectAction (PMENU_STATE pMS)
pMS->Initialized = TRUE; pMS->Initialized = TRUE;
pMS->InputFunc = DoSelectAction; pMS->InputFunc = DoSelectAction;
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
switch (pMS->CurState) switch (pMS->CurState)
{ {
@@ -642,10 +642,10 @@ UninitEncounter (void)
while (!(AnyButtonPress (TRUE)) && GetTimeCounter () < Time) while (!(AnyButtonPress (TRUE)) && GetTimeCounter () < Time)
TaskSwitch (); TaskSwitch ();
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
if (!CurrentInputState.p1_escape) if (!CurrentInputState.key[KEY_P1_ESCAPE])
{ {
DrawFadeText (str1, str2, FALSE, &scavenge_r); DrawFadeText (str1, str2, FALSE, &scavenge_r);
if (!CurrentInputState.p1_escape) if (!CurrentInputState.key[KEY_P1_ESCAPE])
{ {
SetContextForeGroundColor (BLACK_COLOR); SetContextForeGroundColor (BLACK_COLOR);
r.corner.x = scavenge_r.corner.x + 10; r.corner.x = scavenge_r.corner.x + 10;
@@ -674,7 +674,7 @@ UninitEncounter (void)
&& GetTimeCounter () < Time) && GetTimeCounter () < Time)
TaskSwitch (); TaskSwitch ();
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
if (!CurrentInputState.p1_escape) if (!CurrentInputState.key[KEY_P1_ESCAPE])
DrawFadeText (str1, str2, FALSE, &scavenge_r); DrawFadeText (str1, str2, FALSE, &scavenge_r);
} }
} }
+134 -137
View File
@@ -35,14 +35,12 @@ typedef INPUT_STATE_DESC *PINPUT_STATE_DESC;
typedef struct typedef struct
{ {
DWORD up, down, left, right, select, cancel, special; DWORD key [NUM_KEYS];
DWORD page_up, page_down, zoom_in, zoom_out, del;
} MENU_ANNOTATIONS; } MENU_ANNOTATIONS;
CONTROLLER_INPUT_STATE CurrentInputState; CONTROLLER_INPUT_STATE CurrentInputState, PulsedInputState;
MENU_INPUT_STATE CurrentMenuState; static CONTROLLER_INPUT_STATE CachedInputState, OldInputState;
static MENU_INPUT_STATE CachedMenuState, OldMenuState;
static MENU_ANNOTATIONS RepeatDelays, Times; static MENU_ANNOTATIONS RepeatDelays, Times;
static DWORD GestaltRepeatDelay, GestaltTime; static DWORD GestaltRepeatDelay, GestaltTime;
static BOOLEAN OldGestalt, CachedGestalt; static BOOLEAN OldGestalt, CachedGestalt;
@@ -53,35 +51,34 @@ int ExitState;
static MENU_SOUND_FLAGS sound_0, sound_1; static MENU_SOUND_FLAGS sound_0, sound_1;
volatile CONTROLLER_INPUT_STATE ImmediateInputState; volatile CONTROLLER_INPUT_STATE ImmediateInputState;
volatile MENU_INPUT_STATE ImmediateMenuState;
static void static void
_clear_menu_state (void) _clear_menu_state (void)
{ {
CurrentMenuState.up = 0; PulsedInputState.key[KEY_MENU_UP] = 0;
CurrentMenuState.down = 0; PulsedInputState.key[KEY_MENU_DOWN] = 0;
CurrentMenuState.left = 0; PulsedInputState.key[KEY_MENU_LEFT] = 0;
CurrentMenuState.right = 0; PulsedInputState.key[KEY_MENU_RIGHT] = 0;
CurrentMenuState.select = 0; PulsedInputState.key[KEY_MENU_SELECT] = 0;
CurrentMenuState.cancel = 0; PulsedInputState.key[KEY_MENU_CANCEL] = 0;
CurrentMenuState.special = 0; PulsedInputState.key[KEY_MENU_SPECIAL] = 0;
CurrentMenuState.page_up = 0; PulsedInputState.key[KEY_MENU_PAGE_UP] = 0;
CurrentMenuState.page_down = 0; PulsedInputState.key[KEY_MENU_PAGE_DOWN] = 0;
CurrentMenuState.zoom_in = 0; PulsedInputState.key[KEY_MENU_ZOOM_IN] = 0;
CurrentMenuState.zoom_out = 0; PulsedInputState.key[KEY_MENU_ZOOM_OUT] = 0;
CurrentMenuState.del = 0; PulsedInputState.key[KEY_MENU_DELETE] = 0;
CachedMenuState.up = 0; CachedInputState.key[KEY_MENU_UP] = 0;
CachedMenuState.down = 0; CachedInputState.key[KEY_MENU_DOWN] = 0;
CachedMenuState.left = 0; CachedInputState.key[KEY_MENU_LEFT] = 0;
CachedMenuState.right = 0; CachedInputState.key[KEY_MENU_RIGHT] = 0;
CachedMenuState.select = 0; CachedInputState.key[KEY_MENU_SELECT] = 0;
CachedMenuState.cancel = 0; CachedInputState.key[KEY_MENU_CANCEL] = 0;
CachedMenuState.special = 0; CachedInputState.key[KEY_MENU_SPECIAL] = 0;
CachedMenuState.page_up = 0; CachedInputState.key[KEY_MENU_PAGE_UP] = 0;
CachedMenuState.page_down = 0; CachedInputState.key[KEY_MENU_PAGE_DOWN] = 0;
CachedMenuState.zoom_in = 0; CachedInputState.key[KEY_MENU_ZOOM_IN] = 0;
CachedMenuState.zoom_out = 0; CachedInputState.key[KEY_MENU_ZOOM_OUT] = 0;
CachedMenuState.del = 0; CachedInputState.key[KEY_MENU_DELETE] = 0;
CachedGestalt = FALSE; CachedGestalt = FALSE;
} }
@@ -89,31 +86,31 @@ void
ResetKeyRepeat (void) ResetKeyRepeat (void)
{ {
DWORD initTime = GetTimeCounter (); DWORD initTime = GetTimeCounter ();
RepeatDelays.up = _max_accel; RepeatDelays.key[KEY_MENU_UP] = _max_accel;
RepeatDelays.down = _max_accel; RepeatDelays.key[KEY_MENU_DOWN] = _max_accel;
RepeatDelays.left = _max_accel; RepeatDelays.key[KEY_MENU_LEFT] = _max_accel;
RepeatDelays.right = _max_accel; RepeatDelays.key[KEY_MENU_RIGHT] = _max_accel;
RepeatDelays.select = _max_accel; RepeatDelays.key[KEY_MENU_SELECT] = _max_accel;
RepeatDelays.cancel = _max_accel; RepeatDelays.key[KEY_MENU_CANCEL] = _max_accel;
RepeatDelays.special = _max_accel; RepeatDelays.key[KEY_MENU_SPECIAL] = _max_accel;
RepeatDelays.page_up = _max_accel; RepeatDelays.key[KEY_MENU_PAGE_UP] = _max_accel;
RepeatDelays.page_down = _max_accel; RepeatDelays.key[KEY_MENU_PAGE_DOWN] = _max_accel;
RepeatDelays.zoom_in = _max_accel; RepeatDelays.key[KEY_MENU_ZOOM_IN] = _max_accel;
RepeatDelays.zoom_out = _max_accel; RepeatDelays.key[KEY_MENU_ZOOM_OUT] = _max_accel;
RepeatDelays.del = _max_accel; RepeatDelays.key[KEY_MENU_DELETE] = _max_accel;
GestaltRepeatDelay = _max_accel; GestaltRepeatDelay = _max_accel;
Times.up = initTime; Times.key[KEY_MENU_UP] = initTime;
Times.down = initTime; Times.key[KEY_MENU_DOWN] = initTime;
Times.left = initTime; Times.key[KEY_MENU_LEFT] = initTime;
Times.right = initTime; Times.key[KEY_MENU_RIGHT] = initTime;
Times.select = initTime; Times.key[KEY_MENU_SELECT] = initTime;
Times.cancel = initTime; Times.key[KEY_MENU_CANCEL] = initTime;
Times.special = initTime; Times.key[KEY_MENU_SPECIAL] = initTime;
Times.page_up = initTime; Times.key[KEY_MENU_PAGE_UP] = initTime;
Times.page_down = initTime; Times.key[KEY_MENU_PAGE_DOWN] = initTime;
Times.zoom_in = initTime; Times.key[KEY_MENU_ZOOM_IN] = initTime;
Times.zoom_out = initTime; Times.key[KEY_MENU_ZOOM_OUT] = initTime;
Times.del = initTime; Times.key[KEY_MENU_DELETE] = initTime;
GestaltTime = initTime; GestaltTime = initTime;
} }
@@ -149,23 +146,23 @@ _check_gestalt (DWORD NewTime)
{ {
BOOLEAN CurrentGestalt; BOOLEAN CurrentGestalt;
OldGestalt = CachedGestalt; OldGestalt = CachedGestalt;
CachedGestalt = ImmediateMenuState.up || ImmediateMenuState.down || ImmediateMenuState.left || ImmediateMenuState.right; CachedGestalt = ImmediateInputState.key[KEY_MENU_UP] || ImmediateInputState.key[KEY_MENU_DOWN] || ImmediateInputState.key[KEY_MENU_LEFT] || ImmediateInputState.key[KEY_MENU_RIGHT];
CurrentGestalt = CurrentMenuState.up || CurrentMenuState.down || CurrentMenuState.left || CurrentMenuState.right; CurrentGestalt = PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN] || PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT];
if (OldGestalt && CachedGestalt) if (OldGestalt && CachedGestalt)
{ {
if (NewTime - GestaltTime < GestaltRepeatDelay) if (NewTime - GestaltTime < GestaltRepeatDelay)
{ {
CurrentMenuState.up = 0; PulsedInputState.key[KEY_MENU_UP] = 0;
CurrentMenuState.down = 0; PulsedInputState.key[KEY_MENU_DOWN] = 0;
CurrentMenuState.left = 0; PulsedInputState.key[KEY_MENU_LEFT] = 0;
CurrentMenuState.right = 0; PulsedInputState.key[KEY_MENU_RIGHT] = 0;
} }
else else
{ {
CurrentMenuState.up = CachedMenuState.up; PulsedInputState.key[KEY_MENU_UP] = CachedInputState.key[KEY_MENU_UP];
CurrentMenuState.down = CachedMenuState.down; PulsedInputState.key[KEY_MENU_DOWN] = CachedInputState.key[KEY_MENU_DOWN];
CurrentMenuState.left = CachedMenuState.left; PulsedInputState.key[KEY_MENU_LEFT] = CachedInputState.key[KEY_MENU_LEFT];
CurrentMenuState.right = CachedMenuState.right; PulsedInputState.key[KEY_MENU_RIGHT] = CachedInputState.key[KEY_MENU_RIGHT];
if (GestaltRepeatDelay > _min_accel) if (GestaltRepeatDelay > _min_accel)
GestaltRepeatDelay -= _step_accel; GestaltRepeatDelay -= _step_accel;
if (GestaltRepeatDelay < _min_accel) if (GestaltRepeatDelay < _min_accel)
@@ -175,10 +172,10 @@ _check_gestalt (DWORD NewTime)
} }
else else
{ {
CurrentMenuState.up = CachedMenuState.up; PulsedInputState.key[KEY_MENU_UP] = CachedInputState.key[KEY_MENU_UP];
CurrentMenuState.down = CachedMenuState.down; PulsedInputState.key[KEY_MENU_DOWN] = CachedInputState.key[KEY_MENU_DOWN];
CurrentMenuState.left = CachedMenuState.left; PulsedInputState.key[KEY_MENU_LEFT] = CachedInputState.key[KEY_MENU_LEFT];
CurrentMenuState.right = CachedMenuState.right; PulsedInputState.key[KEY_MENU_RIGHT] = CachedInputState.key[KEY_MENU_RIGHT];
GestaltTime = NewTime; GestaltTime = NewTime;
GestaltRepeatDelay = _max_accel; GestaltRepeatDelay = _max_accel;
} }
@@ -202,8 +199,8 @@ UpdateInputState (void)
} }
CurrentInputState = ImmediateInputState; CurrentInputState = ImmediateInputState;
OldMenuState = CachedMenuState; OldInputState = CachedInputState;
CachedMenuState = ImmediateMenuState; CachedInputState = ImmediateInputState;
NewTime = GetTimeCounter (); NewTime = GetTimeCounter ();
if (_gestalt_keys) if (_gestalt_keys)
{ {
@@ -211,24 +208,24 @@ UpdateInputState (void)
} }
else else
{ {
_check_for_pulse(&CurrentMenuState.up, &CachedMenuState.up, &OldMenuState.up, &RepeatDelays.up, &NewTime, &Times.up); _check_for_pulse(&PulsedInputState.key[KEY_MENU_UP], &CachedInputState.key[KEY_MENU_UP], &OldInputState.key[KEY_MENU_UP], &RepeatDelays.key[KEY_MENU_UP], &NewTime, &Times.key[KEY_MENU_UP]);
_check_for_pulse(&CurrentMenuState.down, &CachedMenuState.down, &OldMenuState.down, &RepeatDelays.down, &NewTime, &Times.down); _check_for_pulse(&PulsedInputState.key[KEY_MENU_DOWN], &CachedInputState.key[KEY_MENU_DOWN], &OldInputState.key[KEY_MENU_DOWN], &RepeatDelays.key[KEY_MENU_DOWN], &NewTime, &Times.key[KEY_MENU_DOWN]);
_check_for_pulse(&CurrentMenuState.left, &CachedMenuState.left, &OldMenuState.left, &RepeatDelays.left, &NewTime, &Times.left); _check_for_pulse(&PulsedInputState.key[KEY_MENU_LEFT], &CachedInputState.key[KEY_MENU_LEFT], &OldInputState.key[KEY_MENU_LEFT], &RepeatDelays.key[KEY_MENU_LEFT], &NewTime, &Times.key[KEY_MENU_LEFT]);
_check_for_pulse(&CurrentMenuState.right, &CachedMenuState.right, &OldMenuState.right, &RepeatDelays.right, &NewTime, &Times.right); _check_for_pulse(&PulsedInputState.key[KEY_MENU_RIGHT], &CachedInputState.key[KEY_MENU_RIGHT], &OldInputState.key[KEY_MENU_RIGHT], &RepeatDelays.key[KEY_MENU_RIGHT], &NewTime, &Times.key[KEY_MENU_RIGHT]);
} }
_check_for_pulse(&CurrentMenuState.select, &CachedMenuState.select, &OldMenuState.select, &RepeatDelays.select, &NewTime, &Times.select); _check_for_pulse(&PulsedInputState.key[KEY_MENU_SELECT], &CachedInputState.key[KEY_MENU_SELECT], &OldInputState.key[KEY_MENU_SELECT], &RepeatDelays.key[KEY_MENU_SELECT], &NewTime, &Times.key[KEY_MENU_SELECT]);
_check_for_pulse(&CurrentMenuState.cancel, &CachedMenuState.cancel, &OldMenuState.cancel, &RepeatDelays.cancel, &NewTime, &Times.cancel); _check_for_pulse(&PulsedInputState.key[KEY_MENU_CANCEL], &CachedInputState.key[KEY_MENU_CANCEL], &OldInputState.key[KEY_MENU_CANCEL], &RepeatDelays.key[KEY_MENU_CANCEL], &NewTime, &Times.key[KEY_MENU_CANCEL]);
_check_for_pulse(&CurrentMenuState.special, &CachedMenuState.special, &OldMenuState.special, &RepeatDelays.special, &NewTime, &Times.special); _check_for_pulse(&PulsedInputState.key[KEY_MENU_SPECIAL], &CachedInputState.key[KEY_MENU_SPECIAL], &OldInputState.key[KEY_MENU_SPECIAL], &RepeatDelays.key[KEY_MENU_SPECIAL], &NewTime, &Times.key[KEY_MENU_SPECIAL]);
_check_for_pulse(&CurrentMenuState.page_up, &CachedMenuState.page_up, &OldMenuState.page_up, &RepeatDelays.page_up, &NewTime, &Times.page_up); _check_for_pulse(&PulsedInputState.key[KEY_MENU_PAGE_UP], &CachedInputState.key[KEY_MENU_PAGE_UP], &OldInputState.key[KEY_MENU_PAGE_UP], &RepeatDelays.key[KEY_MENU_PAGE_UP], &NewTime, &Times.key[KEY_MENU_PAGE_UP]);
_check_for_pulse(&CurrentMenuState.page_down, &CachedMenuState.page_down, &OldMenuState.page_down, &RepeatDelays.page_down, &NewTime, &Times.page_down); _check_for_pulse(&PulsedInputState.key[KEY_MENU_PAGE_DOWN], &CachedInputState.key[KEY_MENU_PAGE_DOWN], &OldInputState.key[KEY_MENU_PAGE_DOWN], &RepeatDelays.key[KEY_MENU_PAGE_DOWN], &NewTime, &Times.key[KEY_MENU_PAGE_DOWN]);
_check_for_pulse(&CurrentMenuState.zoom_in, &CachedMenuState.zoom_in, &OldMenuState.zoom_in, &RepeatDelays.zoom_in, &NewTime, &Times.zoom_in); _check_for_pulse(&PulsedInputState.key[KEY_MENU_ZOOM_IN], &CachedInputState.key[KEY_MENU_ZOOM_IN], &OldInputState.key[KEY_MENU_ZOOM_IN], &RepeatDelays.key[KEY_MENU_ZOOM_IN], &NewTime, &Times.key[KEY_MENU_ZOOM_IN]);
_check_for_pulse(&CurrentMenuState.zoom_out, &CachedMenuState.zoom_out, &OldMenuState.zoom_out, &RepeatDelays.zoom_out, &NewTime, &Times.zoom_out); _check_for_pulse(&PulsedInputState.key[KEY_MENU_ZOOM_OUT], &CachedInputState.key[KEY_MENU_ZOOM_OUT], &OldInputState.key[KEY_MENU_ZOOM_OUT], &RepeatDelays.key[KEY_MENU_ZOOM_OUT], &NewTime, &Times.key[KEY_MENU_ZOOM_OUT]);
_check_for_pulse(&CurrentMenuState.del, &CachedMenuState.del, &OldMenuState.del, &RepeatDelays.del, &NewTime, &Times.del); _check_for_pulse(&PulsedInputState.key[KEY_MENU_DELETE], &CachedInputState.key[KEY_MENU_DELETE], &OldInputState.key[KEY_MENU_DELETE], &RepeatDelays.key[KEY_MENU_DELETE], &NewTime, &Times.key[KEY_MENU_DELETE]);
if (CurrentInputState.pause) if (CurrentInputState.key[KEY_PAUSE])
GamePaused = TRUE; GamePaused = TRUE;
if (CurrentInputState.exit) if (CurrentInputState.key[KEY_EXIT])
ExitRequested = TRUE; ExitRequested = TRUE;
} }
@@ -285,20 +282,20 @@ DoInput (PVOID pInputState, BOOLEAN resetInput)
#endif /* CREATE_JOURNAL */ #endif /* CREATE_JOURNAL */
} }
if (CurrentInputState.exit) if (CurrentInputState.key[KEY_EXIT])
ExitState = ConfirmExit (); ExitState = ConfirmExit ();
input = MENU_SOUND_NONE; input = MENU_SOUND_NONE;
if (CurrentMenuState.up) input |= MENU_SOUND_UP; if (PulsedInputState.key[KEY_MENU_UP]) input |= MENU_SOUND_UP;
if (CurrentMenuState.down) input |= MENU_SOUND_DOWN; if (PulsedInputState.key[KEY_MENU_DOWN]) input |= MENU_SOUND_DOWN;
if (CurrentMenuState.left) input |= MENU_SOUND_LEFT; if (PulsedInputState.key[KEY_MENU_LEFT]) input |= MENU_SOUND_LEFT;
if (CurrentMenuState.right) input |= MENU_SOUND_RIGHT; if (PulsedInputState.key[KEY_MENU_RIGHT]) input |= MENU_SOUND_RIGHT;
if (CurrentMenuState.select) input |= MENU_SOUND_SELECT; if (PulsedInputState.key[KEY_MENU_SELECT]) input |= MENU_SOUND_SELECT;
if (CurrentMenuState.cancel) input |= MENU_SOUND_CANCEL; if (PulsedInputState.key[KEY_MENU_CANCEL]) input |= MENU_SOUND_CANCEL;
if (CurrentMenuState.special) input |= MENU_SOUND_SPECIAL; if (PulsedInputState.key[KEY_MENU_SPECIAL]) input |= MENU_SOUND_SPECIAL;
if (CurrentMenuState.page_up) input |= MENU_SOUND_PAGEUP; if (PulsedInputState.key[KEY_MENU_PAGE_UP]) input |= MENU_SOUND_PAGEUP;
if (CurrentMenuState.page_down) input |= MENU_SOUND_PAGEDOWN; if (PulsedInputState.key[KEY_MENU_PAGE_DOWN]) input |= MENU_SOUND_PAGEDOWN;
if (CurrentMenuState.del) input |= MENU_SOUND_DELETE; if (PulsedInputState.key[KEY_MENU_DELETE]) input |= MENU_SOUND_DELETE;
if (MenuSounds if (MenuSounds
&& (pSolarSysState == 0 && (pSolarSysState == 0
@@ -347,19 +344,19 @@ BATTLE_INPUT_STATE
p1_combat_summary (void) p1_combat_summary (void)
{ {
BATTLE_INPUT_STATE InputState = 0; BATTLE_INPUT_STATE InputState = 0;
if (CurrentInputState.p1_thrust) if (CurrentInputState.key[KEY_P1_THRUST])
InputState |= BATTLE_THRUST; InputState |= BATTLE_THRUST;
if (CurrentInputState.p1_left) if (CurrentInputState.key[KEY_P1_LEFT])
InputState |= BATTLE_LEFT; InputState |= BATTLE_LEFT;
if (CurrentInputState.p1_right) if (CurrentInputState.key[KEY_P1_RIGHT])
InputState |= BATTLE_RIGHT; InputState |= BATTLE_RIGHT;
if (CurrentInputState.p1_weapon) if (CurrentInputState.key[KEY_P1_WEAPON])
InputState |= BATTLE_WEAPON; InputState |= BATTLE_WEAPON;
if (CurrentInputState.p1_special) if (CurrentInputState.key[KEY_P1_SPECIAL])
InputState |= BATTLE_SPECIAL; InputState |= BATTLE_SPECIAL;
if (CurrentInputState.p1_escape) if (CurrentInputState.key[KEY_P1_ESCAPE])
InputState |= BATTLE_ESCAPE; InputState |= BATTLE_ESCAPE;
if (CurrentInputState.p1_down) if (CurrentInputState.key[KEY_P1_DOWN])
InputState |= BATTLE_DOWN; InputState |= BATTLE_DOWN;
return InputState; return InputState;
} }
@@ -368,17 +365,17 @@ BATTLE_INPUT_STATE
p2_combat_summary (void) p2_combat_summary (void)
{ {
BATTLE_INPUT_STATE InputState = 0; BATTLE_INPUT_STATE InputState = 0;
if (CurrentInputState.p2_thrust) if (CurrentInputState.key[KEY_P2_THRUST])
InputState |= BATTLE_THRUST; InputState |= BATTLE_THRUST;
if (CurrentInputState.p2_left) if (CurrentInputState.key[KEY_P2_LEFT])
InputState |= BATTLE_LEFT; InputState |= BATTLE_LEFT;
if (CurrentInputState.p2_right) if (CurrentInputState.key[KEY_P2_RIGHT])
InputState |= BATTLE_RIGHT; InputState |= BATTLE_RIGHT;
if (CurrentInputState.p2_weapon) if (CurrentInputState.key[KEY_P2_WEAPON])
InputState |= BATTLE_WEAPON; InputState |= BATTLE_WEAPON;
if (CurrentInputState.p2_special) if (CurrentInputState.key[KEY_P2_SPECIAL])
InputState |= BATTLE_SPECIAL; InputState |= BATTLE_SPECIAL;
if (CurrentInputState.p2_down) if (CurrentInputState.key[KEY_P2_DOWN])
InputState |= BATTLE_DOWN; InputState |= BATTLE_DOWN;
return InputState; return InputState;
} }
@@ -388,35 +385,35 @@ AnyButtonPress (BOOLEAN CheckSpecial)
{ {
(void) CheckSpecial; // Ignored (void) CheckSpecial; // Ignored
UpdateInputState (); UpdateInputState ();
return CurrentInputState.p1_thrust return CurrentInputState.key[KEY_P1_THRUST]
||CurrentInputState.p1_left ||CurrentInputState.key[KEY_P1_LEFT]
||CurrentInputState.p1_right ||CurrentInputState.key[KEY_P1_RIGHT]
||CurrentInputState.p1_down ||CurrentInputState.key[KEY_P1_DOWN]
||CurrentInputState.p1_weapon ||CurrentInputState.key[KEY_P1_WEAPON]
||CurrentInputState.p1_special ||CurrentInputState.key[KEY_P1_SPECIAL]
||CurrentInputState.p1_escape ||CurrentInputState.key[KEY_P1_ESCAPE]
||CurrentInputState.p2_thrust ||CurrentInputState.key[KEY_P2_THRUST]
||CurrentInputState.p2_left ||CurrentInputState.key[KEY_P2_LEFT]
||CurrentInputState.p2_right ||CurrentInputState.key[KEY_P2_RIGHT]
||CurrentInputState.p2_down ||CurrentInputState.key[KEY_P2_DOWN]
||CurrentInputState.p2_weapon ||CurrentInputState.key[KEY_P2_WEAPON]
||CurrentInputState.p2_special ||CurrentInputState.key[KEY_P2_SPECIAL]
||CurrentInputState.lander_thrust ||CurrentInputState.key[KEY_LANDER_THRUST]
||CurrentInputState.lander_left ||CurrentInputState.key[KEY_LANDER_LEFT]
||CurrentInputState.lander_right ||CurrentInputState.key[KEY_LANDER_RIGHT]
||CurrentInputState.lander_weapon ||CurrentInputState.key[KEY_LANDER_WEAPON]
||CurrentInputState.lander_escape ||CurrentInputState.key[KEY_LANDER_ESCAPE]
||CurrentMenuState.up ||PulsedInputState.key[KEY_MENU_UP]
||CurrentMenuState.down ||PulsedInputState.key[KEY_MENU_DOWN]
||CurrentMenuState.left ||PulsedInputState.key[KEY_MENU_LEFT]
||CurrentMenuState.right ||PulsedInputState.key[KEY_MENU_RIGHT]
||CurrentMenuState.page_up ||PulsedInputState.key[KEY_MENU_PAGE_UP]
||CurrentMenuState.page_down ||PulsedInputState.key[KEY_MENU_PAGE_DOWN]
||CurrentMenuState.zoom_in ||PulsedInputState.key[KEY_MENU_ZOOM_IN]
||CurrentMenuState.zoom_out ||PulsedInputState.key[KEY_MENU_ZOOM_OUT]
||CurrentMenuState.select ||PulsedInputState.key[KEY_MENU_SELECT]
||CurrentMenuState.cancel ||PulsedInputState.key[KEY_MENU_CANCEL]
||CurrentMenuState.special; ||PulsedInputState.key[KEY_MENU_SPECIAL];
} }
BOOLEAN BOOLEAN
+15 -15
View File
@@ -512,8 +512,8 @@ DoSettings (PMENU_STATE pMS)
pMS->Initialized = TRUE; pMS->Initialized = TRUE;
pMS->InputFunc = DoSettings; pMS->InputFunc = DoSettings;
} }
else if (CurrentMenuState.cancel else if (PulsedInputState.key[KEY_MENU_CANCEL]
|| (CurrentMenuState.select || (PulsedInputState.key[KEY_MENU_SELECT]
&& pMS->CurState == EXIT_MENU_SETTING)) && pMS->CurState == EXIT_MENU_SETTING))
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
@@ -524,7 +524,7 @@ DoSettings (PMENU_STATE pMS)
pMS->InputFunc = DoGameOptions; pMS->InputFunc = DoGameOptions;
pMS->Initialized = 0; pMS->Initialized = 0;
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
switch (pMS->CurState) switch (pMS->CurState)
{ {
@@ -583,8 +583,8 @@ DoQuitMenu (PMENU_STATE pMS)
pMS->Initialized = TRUE; pMS->Initialized = TRUE;
pMS->InputFunc = DoQuitMenu; pMS->InputFunc = DoQuitMenu;
} }
else if (CurrentMenuState.cancel else if (PulsedInputState.key[KEY_MENU_CANCEL]
|| (CurrentMenuState.select || (PulsedInputState.key[KEY_MENU_SELECT]
&& pMS->CurState == NO_QUIT_MENU)) && pMS->CurState == NO_QUIT_MENU))
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
@@ -595,7 +595,7 @@ DoQuitMenu (PMENU_STATE pMS)
pMS->InputFunc = DoGameOptions; pMS->InputFunc = DoGameOptions;
pMS->Initialized = 0; pMS->Initialized = 0;
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
switch (pMS->CurState) switch (pMS->CurState)
{ {
@@ -1018,7 +1018,7 @@ Restart:
pMS->Initialized = TRUE; pMS->Initialized = TRUE;
goto ChangeGameSelection; goto ChangeGameSelection;
} }
else if (CurrentMenuState.cancel) else if (PulsedInputState.key[KEY_MENU_CANCEL])
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
SetFlashRect ((PRECT)~0L, (FRAME)0); SetFlashRect ((PRECT)~0L, (FRAME)0);
@@ -1039,7 +1039,7 @@ Restart:
} }
return (FALSE); return (FALSE);
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
pSD = &((SUMMARY_DESC *)pMS->CurString)[pMS->CurState]; pSD = &((SUMMARY_DESC *)pMS->CurString)[pMS->CurState];
prev_save = pMS->CurState; prev_save = pMS->CurState;
@@ -1106,7 +1106,7 @@ Restart:
else else
{ {
NewState = pMS->CurState; NewState = pMS->CurState;
if (CurrentMenuState.left || CurrentMenuState.page_up) if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_PAGE_UP])
{ {
if (NewState == 0) if (NewState == 0)
NewState = MAX_SAVED_GAMES - 1; NewState = MAX_SAVED_GAMES - 1;
@@ -1115,7 +1115,7 @@ Restart:
else else
NewState = 0; NewState = 0;
} }
else if (CurrentMenuState.right || CurrentMenuState.page_down) else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_PAGE_DOWN])
{ {
if (NewState == MAX_SAVED_GAMES - 1) if (NewState == MAX_SAVED_GAMES - 1)
NewState = 0; NewState = 0;
@@ -1124,14 +1124,14 @@ Restart:
else else
NewState = MAX_SAVED_GAMES - 1; NewState = MAX_SAVED_GAMES - 1;
} }
else if (CurrentMenuState.up) else if (PulsedInputState.key[KEY_MENU_UP])
{ {
if (NewState == 0) if (NewState == 0)
NewState = MAX_SAVED_GAMES - 1; NewState = MAX_SAVED_GAMES - 1;
else else
NewState--; NewState--;
} }
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
{ {
if (NewState == MAX_SAVED_GAMES - 1) if (NewState == MAX_SAVED_GAMES - 1)
NewState = 0; NewState = 0;
@@ -1373,14 +1373,14 @@ DoGameOptions (PMENU_STATE pMS)
pMS->Initialized = 1; pMS->Initialized = 1;
pMS->InputFunc = DoGameOptions; pMS->InputFunc = DoGameOptions;
} }
else if (CurrentMenuState.cancel else if (PulsedInputState.key[KEY_MENU_CANCEL]
|| (CurrentMenuState.select || (PulsedInputState.key[KEY_MENU_SELECT]
&& pMS->CurState == SETTINGS + 1)) && pMS->CurState == SETTINGS + 1))
{ {
pMS->CurState = SETTINGS + 1; pMS->CurState = SETTINGS + 1;
return (FALSE); return (FALSE);
} }
else if (CurrentMenuState.select || force_select) else if (PulsedInputState.key[KEY_MENU_SELECT] || force_select)
{ {
switch (pMS->CurState) switch (pMS->CurState)
{ {
+6 -6
View File
@@ -34,17 +34,17 @@ GetJoystickChar (void)
int dy; int dy;
UWORD old_char; UWORD old_char;
if (CurrentMenuState.select) if (PulsedInputState.key[KEY_MENU_SELECT])
return ('\n'); return ('\n');
else if (CurrentMenuState.cancel) else if (PulsedInputState.key[KEY_MENU_CANCEL])
return (0x1B); return (0x1B);
else if (CurrentMenuState.special) else if (PulsedInputState.key[KEY_MENU_SPECIAL])
return (0x7F); return (0x7F);
old_char = cur_char; old_char = cur_char;
dy = 0; dy = 0;
if (CurrentMenuState.up) dy = -1; if (PulsedInputState.key[KEY_MENU_UP]) dy = -1;
else if (CurrentMenuState.down) dy = 1; else if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1;
if (dy) if (dy)
{ {
if (cur_char == ' ') if (cur_char == ' ')
@@ -72,7 +72,7 @@ GetJoystickChar (void)
} }
} }
if ((CurrentMenuState.page_up || CurrentMenuState.page_down) && isalpha (cur_char)) if ((PulsedInputState.key[KEY_MENU_PAGE_UP] || PulsedInputState.key[KEY_MENU_PAGE_DOWN]) && isalpha (cur_char))
{ {
if (islower (cur_char)) if (islower (cur_char))
cur_char = toupper (cur_char); cur_char = toupper (cur_char);
@@ -149,9 +149,9 @@ TFB_ProcessEvents ()
break; break;
} }
} }
if (ImmediateInputState.abort || abortFlag) if (ImmediateInputState.key[KEY_ABORT] || abortFlag)
exit (0); exit (0);
if (ImmediateInputState.debug) if (ImmediateInputState.key[KEY_DEBUG])
{ {
FlushInput (); FlushInput ();
uio_debugInteractive(stdin, stdout, stderr); uio_debugInteractive(stdin, stdout, stderr);
+34 -34
View File
@@ -40,40 +40,40 @@ static BOOLEAN _in_character_mode = FALSE;
#define VCONTROL_VERSION 1 #define VCONTROL_VERSION 1
static VControl_NameBinding control_names[] = { static VControl_NameBinding control_names[] = {
{ "Menu-Up", (int *)&ImmediateMenuState.up }, { "Menu-Up", (int *)&ImmediateInputState.key[KEY_MENU_UP] },
{ "Menu-Down", (int *)&ImmediateMenuState.down }, { "Menu-Down", (int *)&ImmediateInputState.key[KEY_MENU_DOWN] },
{ "Menu-Left", (int *)&ImmediateMenuState.left }, { "Menu-Left", (int *)&ImmediateInputState.key[KEY_MENU_LEFT] },
{ "Menu-Right", (int *)&ImmediateMenuState.right }, { "Menu-Right", (int *)&ImmediateInputState.key[KEY_MENU_RIGHT] },
{ "Menu-Select", (int *)&ImmediateMenuState.select }, { "Menu-Select", (int *)&ImmediateInputState.key[KEY_MENU_SELECT] },
{ "Menu-Cancel", (int *)&ImmediateMenuState.cancel }, { "Menu-Cancel", (int *)&ImmediateInputState.key[KEY_MENU_CANCEL] },
{ "Menu-Special", (int *)&ImmediateMenuState.special }, { "Menu-Special", (int *)&ImmediateInputState.key[KEY_MENU_SPECIAL] },
{ "Menu-Page-Up", (int *)&ImmediateMenuState.page_up }, { "Menu-Page-Up", (int *)&ImmediateInputState.key[KEY_MENU_PAGE_UP] },
{ "Menu-Page-Down", (int *)&ImmediateMenuState.page_down }, { "Menu-Page-Down", (int *)&ImmediateInputState.key[KEY_MENU_PAGE_DOWN] },
{ "Menu-Zoom-In", (int *)&ImmediateMenuState.zoom_in }, { "Menu-Zoom-In", (int *)&ImmediateInputState.key[KEY_MENU_ZOOM_IN] },
{ "Menu-Zoom-Out", (int *)&ImmediateMenuState.zoom_out }, { "Menu-Zoom-Out", (int *)&ImmediateInputState.key[KEY_MENU_ZOOM_OUT] },
{ "Menu-Delete", (int *)&ImmediateMenuState.del }, { "Menu-Delete", (int *)&ImmediateInputState.key[KEY_MENU_DELETE] },
{ "Player-1-Thrust", (int *)&ImmediateInputState.p1_thrust }, { "Player-1-Thrust", (int *)&ImmediateInputState.key[KEY_P1_THRUST] },
{ "Player-1-Left", (int *)&ImmediateInputState.p1_left }, { "Player-1-Left", (int *)&ImmediateInputState.key[KEY_P1_LEFT] },
{ "Player-1-Right", (int *)&ImmediateInputState.p1_right }, { "Player-1-Right", (int *)&ImmediateInputState.key[KEY_P1_RIGHT] },
{ "Player-1-Down", (int *)&ImmediateInputState.p1_down }, { "Player-1-Down", (int *)&ImmediateInputState.key[KEY_P1_DOWN] },
{ "Player-1-Weapon", (int *)&ImmediateInputState.p1_weapon }, { "Player-1-Weapon", (int *)&ImmediateInputState.key[KEY_P1_WEAPON] },
{ "Player-1-Special", (int *)&ImmediateInputState.p1_special }, { "Player-1-Special", (int *)&ImmediateInputState.key[KEY_P1_SPECIAL] },
{ "Player-1-Escape", (int *)&ImmediateInputState.p1_escape }, { "Player-1-Escape", (int *)&ImmediateInputState.key[KEY_P1_ESCAPE] },
{ "Player-2-Thrust", (int *)&ImmediateInputState.p2_thrust }, { "Player-2-Thrust", (int *)&ImmediateInputState.key[KEY_P2_THRUST] },
{ "Player-2-Left", (int *)&ImmediateInputState.p2_left }, { "Player-2-Left", (int *)&ImmediateInputState.key[KEY_P2_LEFT] },
{ "Player-2-Right", (int *)&ImmediateInputState.p2_right }, { "Player-2-Right", (int *)&ImmediateInputState.key[KEY_P2_RIGHT] },
{ "Player-2-Down", (int *)&ImmediateInputState.p2_down }, { "Player-2-Down", (int *)&ImmediateInputState.key[KEY_P2_DOWN] },
{ "Player-2-Weapon", (int *)&ImmediateInputState.p2_weapon }, { "Player-2-Weapon", (int *)&ImmediateInputState.key[KEY_P2_WEAPON] },
{ "Player-2-Special", (int *)&ImmediateInputState.p2_special }, { "Player-2-Special", (int *)&ImmediateInputState.key[KEY_P2_SPECIAL] },
{ "Lander-Thrust", (int *)&ImmediateInputState.lander_thrust }, { "Lander-Thrust", (int *)&ImmediateInputState.key[KEY_LANDER_THRUST] },
{ "Lander-Left", (int *)&ImmediateInputState.lander_left }, { "Lander-Left", (int *)&ImmediateInputState.key[KEY_LANDER_LEFT] },
{ "Lander-Right", (int *)&ImmediateInputState.lander_right }, { "Lander-Right", (int *)&ImmediateInputState.key[KEY_LANDER_RIGHT] },
{ "Lander-Weapon", (int *)&ImmediateInputState.lander_weapon }, { "Lander-Weapon", (int *)&ImmediateInputState.key[KEY_LANDER_WEAPON] },
{ "Lander-Escape", (int *)&ImmediateInputState.lander_escape }, { "Lander-Escape", (int *)&ImmediateInputState.key[KEY_LANDER_ESCAPE] },
{ "Pause", (int *)&ImmediateInputState.pause }, { "Pause", (int *)&ImmediateInputState.key[KEY_PAUSE] },
{ "Exit", (int *)&ImmediateInputState.exit }, { "Exit", (int *)&ImmediateInputState.key[KEY_EXIT] },
{ "Abort", (int *)&ImmediateInputState.abort }, { "Abort", (int *)&ImmediateInputState.key[KEY_ABORT] },
{ "Debug", (int *)&ImmediateInputState.debug }, { "Debug", (int *)&ImmediateInputState.key[KEY_DEBUG] },
{ "Illegal", NULL}}; { "Illegal", NULL}};
+6 -6
View File
@@ -400,14 +400,14 @@ TFB_DoVideoInput (PVOID pIS)
if (!pVIS->CurVideo || !TFB_VideoPlaying (pVIS->CurVideo)) if (!pVIS->CurVideo || !TFB_VideoPlaying (pVIS->CurVideo))
return FALSE; return FALSE;
if (CurrentMenuState.select if (PulsedInputState.key[KEY_MENU_SELECT]
|| CurrentMenuState.cancel || PulsedInputState.key[KEY_MENU_CANCEL]
|| CurrentMenuState.special) || PulsedInputState.key[KEY_MENU_SPECIAL])
{ // abort movie { // abort movie
TFB_StopVideo (pVIS->CurVideo); TFB_StopVideo (pVIS->CurVideo);
return FALSE; return FALSE;
} }
else if (CurrentMenuState.left || CurrentMenuState.right) else if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT])
{ {
if (vid->decoder->audio_synced) if (vid->decoder->audio_synced)
{ {
@@ -417,9 +417,9 @@ TFB_DoVideoInput (PVOID pIS)
newpos = vid->decoder->pos; newpos = vid->decoder->pos;
UnlockMutex (vid->guard); UnlockMutex (vid->guard);
if (CurrentMenuState.left) if (PulsedInputState.key[KEY_MENU_LEFT])
newpos -= 2; newpos -= 2;
else if (CurrentMenuState.right) else if (PulsedInputState.key[KEY_MENU_RIGHT])
newpos += 1; newpos += 1;
if (newpos < 0) if (newpos < 0)
newpos = 0; newpos = 0;
+28 -28
View File
@@ -862,9 +862,9 @@ DoLoadTeam (PMELEE_STATE pMS)
pMS->InputFunc = DoLoadTeam; pMS->InputFunc = DoLoadTeam;
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
else if (CurrentMenuState.select | CurrentMenuState.cancel) else if (PulsedInputState.key[KEY_MENU_SELECT] | PulsedInputState.key[KEY_MENU_CANCEL])
{ {
if (!CurrentMenuState.cancel) if (!PulsedInputState.key[KEY_MENU_CANCEL])
{ {
pMS->TeamImage[pMS->side] = pMS->FileList[ pMS->TeamImage[pMS->side] = pMS->FileList[
pMS->CurIndex - pMS->TopTeamIndex pMS->CurIndex - pMS->TopTeamIndex
@@ -890,7 +890,7 @@ DoLoadTeam (PMELEE_STATE pMS)
NewTop = pMS->TopTeamIndex; NewTop = pMS->TopTeamIndex;
index = old_index = pMS->CurIndex; index = old_index = pMS->CurIndex;
if (CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_UP])
{ {
if (index-- == 0) if (index-- == 0)
index = 0; index = 0;
@@ -898,7 +898,7 @@ DoLoadTeam (PMELEE_STATE pMS)
if (index < NewTop && (NewTop -= MAX_VIS_TEAMS) < 0) if (index < NewTop && (NewTop -= MAX_VIS_TEAMS) < 0)
NewTop = 0; NewTop = 0;
} }
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
{ {
if ((int)index < (int)GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - 1) if ((int)index < (int)GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT - 1)
++index; ++index;
@@ -906,7 +906,7 @@ DoLoadTeam (PMELEE_STATE pMS)
if ((int)index > (int)pMS->BotTeamIndex) if ((int)index > (int)pMS->BotTeamIndex)
NewTop = index; NewTop = index;
} }
else if (CurrentMenuState.page_up) else if (PulsedInputState.key[KEY_MENU_PAGE_UP])
{ {
if ((index -= MAX_VIS_TEAMS) < 0) if ((index -= MAX_VIS_TEAMS) < 0)
index = NewTop = 0; index = NewTop = 0;
@@ -916,7 +916,7 @@ DoLoadTeam (PMELEE_STATE pMS)
NewTop = 0; NewTop = 0;
} }
} }
else if (CurrentMenuState.page_down) else if (PulsedInputState.key[KEY_MENU_PAGE_DOWN])
{ {
if ((int)(index += MAX_VIS_TEAMS) < if ((int)(index += MAX_VIS_TEAMS) <
(int)(GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT)) (int)(GetDirEntryTableCount (pMS->TeamDE) + NUM_PREBUILT))
@@ -1176,8 +1176,8 @@ DoEdit (PMELEE_STATE pMS)
pMS->InputFunc = DoEdit; pMS->InputFunc = DoEdit;
} }
else if ((pMS->row < NUM_MELEE_ROWS || pMS->CurIndex == (BYTE)~0) else if ((pMS->row < NUM_MELEE_ROWS || pMS->CurIndex == (BYTE)~0)
&& (CurrentMenuState.cancel && (PulsedInputState.key[KEY_MENU_CANCEL]
|| (CurrentMenuState.right || (PulsedInputState.key[KEY_MENU_RIGHT]
&& (pMS->col == NUM_MELEE_COLUMNS - 1 || pMS->row == NUM_MELEE_ROWS)))) && (pMS->col == NUM_MELEE_COLUMNS - 1 || pMS->row == NUM_MELEE_ROWS))))
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
@@ -1189,16 +1189,16 @@ DoEdit (PMELEE_STATE pMS)
InTime = GetTimeCounter (); InTime = GetTimeCounter ();
} }
else if (pMS->row < NUM_MELEE_ROWS else if (pMS->row < NUM_MELEE_ROWS
&& (CurrentMenuState.select || CurrentMenuState.special)) && (PulsedInputState.key[KEY_MENU_SELECT] || PulsedInputState.key[KEY_MENU_SPECIAL]))
{ {
if (CurrentMenuState.select) if (PulsedInputState.key[KEY_MENU_SELECT])
pMS->Initialized = 0; pMS->Initialized = 0;
else else
pMS->Initialized = -1; pMS->Initialized = -1;
TFB_ResetControls (); TFB_ResetControls ();
DoPickShip (pMS); DoPickShip (pMS);
} }
else if (pMS->row < NUM_MELEE_ROWS && CurrentMenuState.del) else if (pMS->row < NUM_MELEE_ROWS && PulsedInputState.key[KEY_MENU_DELETE])
{ {
DeleteCurrentShip (pMS); DeleteCurrentShip (pMS);
AdvanceCursor (pMS); AdvanceCursor (pMS);
@@ -1232,7 +1232,7 @@ DoEdit (PMELEE_STATE pMS)
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
return (TRUE); return (TRUE);
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
pMS->CurIndex = 0; pMS->CurIndex = 0;
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
@@ -1244,18 +1244,18 @@ DoEdit (PMELEE_STATE pMS)
} }
{ {
if (CurrentMenuState.left) if (PulsedInputState.key[KEY_MENU_LEFT])
{ {
if (col-- == 0) if (col-- == 0)
col = 0; col = 0;
} }
else if (CurrentMenuState.right) else if (PulsedInputState.key[KEY_MENU_RIGHT])
{ {
if (++col == NUM_MELEE_COLUMNS) if (++col == NUM_MELEE_COLUMNS)
col = NUM_MELEE_COLUMNS - 1; col = NUM_MELEE_COLUMNS - 1;
} }
if (CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_UP])
{ {
if (row-- == 0) if (row-- == 0)
{ {
@@ -1268,7 +1268,7 @@ DoEdit (PMELEE_STATE pMS)
} }
} }
} }
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
{ {
if (row++ == NUM_MELEE_ROWS) if (row++ == NUM_MELEE_ROWS)
{ {
@@ -1343,11 +1343,11 @@ DoPickShip (PMELEE_STATE pMS)
DrawMeleeShipStrings (pMS, (BYTE)(pMS->CurIndex)); DrawMeleeShipStrings (pMS, (BYTE)(pMS->CurIndex));
} }
} }
else if (CurrentMenuState.select || CurrentMenuState.cancel) else if (PulsedInputState.key[KEY_MENU_SELECT] || PulsedInputState.key[KEY_MENU_CANCEL])
{ {
pMS->InputFunc = 0; /* disable ship flashing */ pMS->InputFunc = 0; /* disable ship flashing */
if (!CurrentMenuState.cancel) if (!PulsedInputState.key[KEY_MENU_CANCEL])
{ {
HSTARSHIP hStarShip; HSTARSHIP hStarShip;
@@ -1381,7 +1381,7 @@ DoPickShip (PMELEE_STATE pMS)
return (TRUE); return (TRUE);
} }
else if (CurrentMenuState.special) else if (PulsedInputState.key[KEY_MENU_SPECIAL])
{ {
DoShipSpin (pMS->CurIndex, (MUSIC_REF)0); DoShipSpin (pMS->CurIndex, (MUSIC_REF)0);
@@ -1393,25 +1393,25 @@ DoPickShip (PMELEE_STATE pMS)
NewStarShip = pMS->CurIndex; NewStarShip = pMS->CurIndex;
if (CurrentMenuState.left) if (PulsedInputState.key[KEY_MENU_LEFT])
{ {
if (NewStarShip-- % NUM_PICK_COLS == 0) if (NewStarShip-- % NUM_PICK_COLS == 0)
NewStarShip += NUM_PICK_COLS; NewStarShip += NUM_PICK_COLS;
} }
else if (CurrentMenuState.right) else if (PulsedInputState.key[KEY_MENU_RIGHT])
{ {
if (++NewStarShip % NUM_PICK_COLS == 0) if (++NewStarShip % NUM_PICK_COLS == 0)
NewStarShip -= NUM_PICK_COLS; NewStarShip -= NUM_PICK_COLS;
} }
if (CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_UP])
{ {
if (NewStarShip >= NUM_PICK_COLS) if (NewStarShip >= NUM_PICK_COLS)
NewStarShip -= NUM_PICK_COLS; NewStarShip -= NUM_PICK_COLS;
else else
NewStarShip += NUM_PICK_COLS * (NUM_PICK_ROWS - 1); NewStarShip += NUM_PICK_COLS * (NUM_PICK_ROWS - 1);
} }
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
{ {
if (NewStarShip < NUM_PICK_COLS * (NUM_PICK_ROWS - 1)) if (NewStarShip < NUM_PICK_COLS * (NUM_PICK_ROWS - 1))
NewStarShip += NUM_PICK_COLS; NewStarShip += NUM_PICK_COLS;
@@ -1605,7 +1605,7 @@ DoMelee (PMELEE_STATE pMS)
} }
InTime = GetTimeCounter (); InTime = GetTimeCounter ();
} }
else if (CurrentMenuState.cancel || CurrentMenuState.left) else if (PulsedInputState.key[KEY_MENU_CANCEL] || PulsedInputState.key[KEY_MENU_LEFT])
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
InTime = GetTimeCounter (); InTime = GetTimeCounter ();
@@ -1613,7 +1613,7 @@ DoMelee (PMELEE_STATE pMS)
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
pMS->MeleeOption = EDIT_MELEE; pMS->MeleeOption = EDIT_MELEE;
pMS->Initialized = FALSE; pMS->Initialized = FALSE;
if (CurrentMenuState.cancel) if (PulsedInputState.key[KEY_MENU_CANCEL])
pMS->side = pMS->row = pMS->col = 0; pMS->side = pMS->row = pMS->col = 0;
else else
pMS->side = 0, pMS->side = 0,
@@ -1626,13 +1626,13 @@ DoMelee (PMELEE_STATE pMS)
MELEE_OPTIONS NewMeleeOption; MELEE_OPTIONS NewMeleeOption;
NewMeleeOption = pMS->MeleeOption; NewMeleeOption = pMS->MeleeOption;
if (CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_UP])
{ {
InTime = GetTimeCounter (); InTime = GetTimeCounter ();
if (NewMeleeOption-- == CONTROLS_TOP) if (NewMeleeOption-- == CONTROLS_TOP)
NewMeleeOption = CONTROLS_TOP; NewMeleeOption = CONTROLS_TOP;
} }
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
{ {
InTime = GetTimeCounter (); InTime = GetTimeCounter ();
if (NewMeleeOption++ == CONTROLS_BOT) if (NewMeleeOption++ == CONTROLS_BOT)
@@ -1655,7 +1655,7 @@ DoMelee (PMELEE_STATE pMS)
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
if (CurrentMenuState.select || force_select) if (PulsedInputState.key[KEY_MENU_SELECT] || force_select)
{ {
switch (pMS->MeleeOption) switch (pMS->MeleeOption)
{ {
+3 -3
View File
@@ -451,11 +451,11 @@ DoMenuChooser (PMENU_STATE pMS, BYTE BaseState)
BOOLEAN useAltMenu = FALSE; BOOLEAN useAltMenu = FALSE;
if (optWhichMenu == OPT_PC) if (optWhichMenu == OPT_PC)
useAltMenu = GetAlternateMenu (&BaseState, &NewState); useAltMenu = GetAlternateMenu (&BaseState, &NewState);
if (CurrentMenuState.left || CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_UP])
NewState = PreviousMenuState (BaseState, NewState); NewState = PreviousMenuState (BaseState, NewState);
else if (CurrentMenuState.right || CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_DOWN])
NewState = NextMenuState (BaseState, NewState); NewState = NextMenuState (BaseState, NewState);
else if (useAltMenu && CurrentMenuState.select) else if (useAltMenu && PulsedInputState.key[KEY_MENU_SELECT])
{ {
NewState = ConvertAlternateMenu (BaseState, NewState); NewState = ConvertAlternateMenu (BaseState, NewState);
if (NewState == ALT_MANIFEST) if (NewState == ALT_MANIFEST)
+13 -13
View File
@@ -177,9 +177,9 @@ DoInstallModule (PMENU_STATE pMS)
return (TRUE); return (TRUE);
} }
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
motion = CurrentMenuState.left || CurrentMenuState.right || CurrentMenuState.up || CurrentMenuState.down; motion = PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN];
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
@@ -373,9 +373,9 @@ DoInstallModule (PMENU_STATE pMS)
NewItem = NewState < EMPTY_SLOT ? pMS->CurState : pMS->delta_item; NewItem = NewState < EMPTY_SLOT ? pMS->CurState : pMS->delta_item;
do do
{ {
if (NewState >= EMPTY_SLOT && (CurrentMenuState.up || CurrentMenuState.down)) if (NewState >= EMPTY_SLOT && (PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN]))
{ {
if (CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_UP])
{ {
if (NewState-- == EMPTY_SLOT) if (NewState-- == EMPTY_SLOT)
NewState = EMPTY_SLOT + 3; NewState = EMPTY_SLOT + 3;
@@ -389,18 +389,18 @@ DoInstallModule (PMENU_STATE pMS)
if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 3) if (GET_GAME_STATE (CHMMR_BOMB_STATE) == 3)
{ {
if (NewState == EMPTY_SLOT + 3) if (NewState == EMPTY_SLOT + 3)
NewState = CurrentMenuState.up ? EMPTY_SLOT + 2 : EMPTY_SLOT; NewState = PulsedInputState.key[KEY_MENU_UP] ? EMPTY_SLOT + 2 : EMPTY_SLOT;
if (NewState == EMPTY_SLOT + 2) if (NewState == EMPTY_SLOT + 2)
NewItem = NUM_BOMB_MODULES; NewItem = NUM_BOMB_MODULES;
} }
pMS->delta_item = NewItem; pMS->delta_item = NewItem;
} }
else if (CurrentMenuState.left || CurrentMenuState.up) else if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_UP])
{ {
if (NewItem-- == FirstItem) if (NewItem-- == FirstItem)
NewItem = LastItem; NewItem = LastItem;
} }
else if (CurrentMenuState.right || CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_DOWN])
{ {
if (NewItem++ == LastItem) if (NewItem++ == LastItem)
NewItem = FirstItem; NewItem = FirstItem;
@@ -519,7 +519,7 @@ ChangeFuelQuantity ()
r.extent.height = 1; r.extent.height = 1;
if (CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_UP])
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
SetContext (SpaceContext); SetContext (SpaceContext);
@@ -545,7 +545,7 @@ ChangeFuelQuantity ()
} }
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
SetContext (SpaceContext); SetContext (SpaceContext);
@@ -690,8 +690,8 @@ DoOutfit (PMENU_STATE pMS)
SetContext (StatusContext); SetContext (StatusContext);
} }
else if (CurrentMenuState.cancel else if (PulsedInputState.key[KEY_MENU_CANCEL]
|| (CurrentMenuState.select || (PulsedInputState.key[KEY_MENU_SELECT]
&& pMS->CurState == OUTFIT_EXIT)) && pMS->CurState == OUTFIT_EXIT))
{ {
if (pMS->CurState == OUTFIT_DOFUEL) if (pMS->CurState == OUTFIT_DOFUEL)
@@ -712,7 +712,7 @@ ExitOutfit:
return (FALSE); return (FALSE);
} }
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
switch (pMS->CurState) switch (pMS->CurState)
{ {
+5 -5
View File
@@ -200,7 +200,7 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player)
OldTime = NewTime; OldTime = NewTime;
} }
if (InputState & BATTLE_WEAPON || CurrentMenuState.select) if (InputState & BATTLE_WEAPON || PulsedInputState.key[KEY_MENU_SELECT])
{ {
if (hBattleShip || (col == NUM_MELEE_COLS_ORIG && ConfirmExit ())) if (hBattleShip || (col == NUM_MELEE_COLS_ORIG && ConfirmExit ()))
{ {
@@ -214,22 +214,22 @@ GetMeleeStarShip (STARSHIPPTR LastStarShipPtr, COUNT which_player)
new_row = row; new_row = row;
new_col = col; new_col = col;
if ((InputState & BATTLE_LEFT) || CurrentMenuState.left) if ((InputState & BATTLE_LEFT) || PulsedInputState.key[KEY_MENU_LEFT])
{ {
if (new_col-- == 0) if (new_col-- == 0)
new_col = NUM_MELEE_COLS_ORIG; new_col = NUM_MELEE_COLS_ORIG;
} }
else if ((InputState & BATTLE_RIGHT) || CurrentMenuState.right) else if ((InputState & BATTLE_RIGHT) || PulsedInputState.key[KEY_MENU_RIGHT])
{ {
if (new_col++ == NUM_MELEE_COLS_ORIG) if (new_col++ == NUM_MELEE_COLS_ORIG)
new_col = 0; new_col = 0;
} }
if ((InputState & BATTLE_THRUST) || CurrentMenuState.up) if ((InputState & BATTLE_THRUST) || PulsedInputState.key[KEY_MENU_UP])
{ {
if (new_row-- == 0) if (new_row-- == 0)
new_row = NUM_MELEE_ROWS - 1; new_row = NUM_MELEE_ROWS - 1;
} }
else if ((InputState & BATTLE_DOWN) || CurrentMenuState.down) else if ((InputState & BATTLE_DOWN) || PulsedInputState.key[KEY_MENU_DOWN])
{ {
if (++new_row == NUM_MELEE_ROWS) if (++new_row == NUM_MELEE_ROWS)
new_row = 0; new_row = 0;
+5 -5
View File
@@ -48,7 +48,7 @@ DoPickBattleShip (PMENU_STATE pMS)
goto ChangeSelection; goto ChangeSelection;
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
if ((HSTARSHIP)pMS->CurFrame) if ((HSTARSHIP)pMS->CurFrame)
return (FALSE); return (FALSE);
@@ -57,10 +57,10 @@ DoPickBattleShip (PMENU_STATE pMS)
{ {
COORD new_row, new_col; COORD new_row, new_col;
int dx = 0, dy = 0; int dx = 0, dy = 0;
if (CurrentMenuState.right) dx = 1; if (PulsedInputState.key[KEY_MENU_RIGHT]) dx = 1;
if (CurrentMenuState.left) dx = -1; if (PulsedInputState.key[KEY_MENU_LEFT]) dx = -1;
if (CurrentMenuState.up) dy = -1; if (PulsedInputState.key[KEY_MENU_UP]) dy = -1;
if (CurrentMenuState.down) dy = 1; if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1;
new_col = pMS->first_item.x + dx; new_col = pMS->first_item.x + dx;
new_row = pMS->first_item.y + dy; new_row = pMS->first_item.y + dy;
+4 -4
View File
@@ -280,10 +280,10 @@ DoDiscardCargo (PMENU_STATE pMS)
{ {
BYTE NewState; BYTE NewState;
BOOLEAN select, cancel, back, forward; BOOLEAN select, cancel, back, forward;
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
back = CurrentMenuState.up || CurrentMenuState.left; back = PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_LEFT];
forward = CurrentMenuState.down || CurrentMenuState.right; forward = PulsedInputState.key[KEY_MENU_DOWN] || PulsedInputState.key[KEY_MENU_RIGHT];
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return (FALSE); return (FALSE);
+4 -4
View File
@@ -425,10 +425,10 @@ DoManipulateDevices (PMENU_STATE pMS)
{ {
BYTE NewState; BYTE NewState;
BOOLEAN select, cancel, back, forward; BOOLEAN select, cancel, back, forward;
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
back = CurrentMenuState.up || CurrentMenuState.left; back = PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_LEFT];
forward = CurrentMenuState.down || CurrentMenuState.right; forward = PulsedInputState.key[KEY_MENU_DOWN] || PulsedInputState.key[KEY_MENU_RIGHT];
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return (FALSE); return (FALSE);
+6 -6
View File
@@ -1592,7 +1592,7 @@ SetVelocityComponents (
} }
else if (pMS->delta_item == 0 else if (pMS->delta_item == 0
|| (HIBYTE (pMS->delta_item) || (HIBYTE (pMS->delta_item)
&& (CurrentInputState.lander_escape && (CurrentInputState.key[KEY_LANDER_ESCAPE]
|| ((PPLANETSIDE_DESC)pMenuState->ModuleFrame)->InTransit))) || ((PPLANETSIDE_DESC)pMenuState->ModuleFrame)->InTransit)))
{ {
if (pMS->delta_item || pMS->CurState > EXPLOSION_LIFE + 60) if (pMS->delta_item || pMS->CurState > EXPLOSION_LIFE + 60)
@@ -1653,9 +1653,9 @@ SetVelocityComponents (
index = GetFrameIndex (LanderFrame[0]); index = GetFrameIndex (LanderFrame[0]);
if (LONIBBLE (pMS->CurState)) if (LONIBBLE (pMS->CurState))
pMS->CurState -= MAKE_BYTE (1, 0); pMS->CurState -= MAKE_BYTE (1, 0);
else if (CurrentInputState.lander_left || CurrentInputState.lander_right) else if (CurrentInputState.key[KEY_LANDER_LEFT] || CurrentInputState.key[KEY_LANDER_RIGHT])
{ {
if (CurrentInputState.lander_left) if (CurrentInputState.key[KEY_LANDER_LEFT])
{ {
dx = -1; dx = -1;
--index; --index;
@@ -1695,7 +1695,7 @@ SetVelocityComponents (
); );
} }
if (!CurrentInputState.lander_thrust) if (!CurrentInputState.key[KEY_LANDER_THRUST])
dx = dy = 0; dx = dy = 0;
else else
GetNextVelocityComponents ( GetNextVelocityComponents (
@@ -1704,7 +1704,7 @@ SetVelocityComponents (
if (HINIBBLE (pMS->CurState)) if (HINIBBLE (pMS->CurState))
pMS->CurState -= MAKE_BYTE (0, 1); pMS->CurState -= MAKE_BYTE (0, 1);
else if (CurrentInputState.lander_weapon) else if (CurrentInputState.key[KEY_LANDER_WEAPON])
{ {
HELEMENT hWeaponElement; HELEMENT hWeaponElement;
@@ -1733,7 +1733,7 @@ SetVelocityComponents (
index + ANGLE_TO_FACING (FULL_CIRCLE) index + ANGLE_TO_FACING (FULL_CIRCLE)
); );
if (!CurrentInputState.lander_thrust) if (!CurrentInputState.key[KEY_LANDER_THRUST])
wdx = wdy = 0; wdx = wdy = 0;
else else
GetCurrentVelocityComponents ( GetCurrentVelocityComponents (
+9 -9
View File
@@ -628,7 +628,7 @@ DoMoveCursor (PMENU_STATE pMS)
buf[0] = '\0'; buf[0] = '\0';
goto UpdateCursorInfo; goto UpdateCursorInfo;
} }
else if (CurrentMenuState.cancel) else if (PulsedInputState.key[KEY_MENU_CANCEL])
{ {
if (pMS->flash_task) if (pMS->flash_task)
{ {
@@ -638,7 +638,7 @@ DoMoveCursor (PMENU_STATE pMS)
return (FALSE); return (FALSE);
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
GLOBAL (autopilot) = pMS->first_item; GLOBAL (autopilot) = pMS->first_item;
@@ -651,18 +651,18 @@ DoMoveCursor (PMENU_STATE pMS)
SIZE ZoomIn, ZoomOut; SIZE ZoomIn, ZoomOut;
ZoomIn = ZoomOut = 0; ZoomIn = ZoomOut = 0;
if (CurrentMenuState.zoom_in) if (PulsedInputState.key[KEY_MENU_ZOOM_IN])
ZoomIn = 1; ZoomIn = 1;
else if (CurrentMenuState.zoom_out) else if (PulsedInputState.key[KEY_MENU_ZOOM_OUT])
ZoomOut = 1; ZoomOut = 1;
ZoomStarMap (ZoomIn - ZoomOut); ZoomStarMap (ZoomIn - ZoomOut);
sx = sy = 0; sx = sy = 0;
if (CurrentMenuState.left) sx = -1; if (PulsedInputState.key[KEY_MENU_LEFT]) sx = -1;
if (CurrentMenuState.right) sx = 1; if (PulsedInputState.key[KEY_MENU_RIGHT]) sx = 1;
if (CurrentMenuState.up) sy = -1; if (PulsedInputState.key[KEY_MENU_UP]) sy = -1;
if (CurrentMenuState.down) sy = 1; if (PulsedInputState.key[KEY_MENU_DOWN]) sy = 1;
if (sx == 0 && sy == 0) if (sx == 0 && sy == 0)
{ {
@@ -1162,7 +1162,7 @@ DoFlagshipCommands (PMENU_STATE pMS)
} }
else else
{ {
BOOLEAN select = CurrentMenuState.select; BOOLEAN select = PulsedInputState.key[KEY_MENU_SELECT];
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
while (*(volatile BYTE *)&pMS->CurState == 0 while (*(volatile BYTE *)&pMS->CurState == 0
&& (*(volatile SIZE *)&pMS->Initialized & 1) && (*(volatile SIZE *)&pMS->Initialized & 1)
+5 -5
View File
@@ -219,11 +219,11 @@ DoModifyRoster (PMENU_STATE pMS)
return (FALSE); return (FALSE);
} }
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
up = CurrentMenuState.up; up = PulsedInputState.key[KEY_MENU_UP];
down = CurrentMenuState.down; down = PulsedInputState.key[KEY_MENU_DOWN];
horiz = CurrentMenuState.left || CurrentMenuState.right; horiz = PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT];
if (pMS->Initialized && (pMS->CurState & SHIP_TOGGLE)) if (pMS->Initialized && (pMS->CurState & SHIP_TOGGLE))
{ {
+8 -8
View File
@@ -653,8 +653,8 @@ static BOOLEAN
PickPlanetSide (PMENU_STATE pMS) PickPlanetSide (PMENU_STATE pMS)
{ {
BOOLEAN select, cancel; BOOLEAN select, cancel;
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
{ {
if (pMenuState->flash_task) if (pMenuState->flash_task)
@@ -809,10 +809,10 @@ ExitPlanetSide:
new_pt = pSolarSysState->MenuState.first_item; new_pt = pSolarSysState->MenuState.first_item;
if (CurrentMenuState.left) dx = -1; if (PulsedInputState.key[KEY_MENU_LEFT]) dx = -1;
if (CurrentMenuState.right) dx = 1; if (PulsedInputState.key[KEY_MENU_RIGHT]) dx = 1;
if (CurrentMenuState.up) dy = -1; if (PulsedInputState.key[KEY_MENU_UP]) dy = -1;
if (CurrentMenuState.down) dy = 1; if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1;
dx = dx << MAG_SHIFT; dx = dx << MAG_SHIFT;
if (dx) if (dx)
@@ -941,8 +941,8 @@ DoScan (PMENU_STATE pMS)
{ {
DWORD TimeIn, WaitTime; DWORD TimeIn, WaitTime;
BOOLEAN select, cancel; BOOLEAN select, cancel;
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return (FALSE); return (FALSE);
+5 -5
View File
@@ -777,15 +777,15 @@ UndrawShip (void)
DrawIPRadar (FALSE); DrawIPRadar (FALSE);
#endif /* SHOW_RADAR */ #endif /* SHOW_RADAR */
if (CurrentInputState.p1_thrust) if (CurrentInputState.key[KEY_P1_THRUST])
delta_y = -1; delta_y = -1;
else else
delta_y = 0; delta_y = 0;
delta_x = 0; delta_x = 0;
if (CurrentInputState.p1_left) if (CurrentInputState.key[KEY_P1_LEFT])
delta_x -= 1; delta_x -= 1;
if (CurrentInputState.p1_right) if (CurrentInputState.key[KEY_P1_RIGHT])
delta_x += 1; delta_x += 1;
if (delta_x || delta_y < 0) if (delta_x || delta_y < 0)
@@ -1180,8 +1180,8 @@ TheMess:
else else
{ {
UpdateInputState (); UpdateInputState ();
cancel = ImmediateMenuState.cancel; cancel = ImmediateInputState.key[KEY_MENU_CANCEL];
select = ImmediateMenuState.select; select = ImmediateInputState.key[KEY_MENU_SELECT];
} }
// JournalInput (InputState); // JournalInput (InputState);
} }
+6 -6
View File
@@ -111,9 +111,9 @@ else if (InputState & DEVICE_EXIT) return (FALSE);
{ {
return (FALSE); return (FALSE);
} }
else if (!(CurrentMenuState.up || CurrentMenuState.down || else if (!(PulsedInputState.key[KEY_MENU_UP] || PulsedInputState.key[KEY_MENU_DOWN] ||
CurrentMenuState.left || CurrentMenuState.right || PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_RIGHT] ||
CurrentMenuState.select)) PulsedInputState.key[KEY_MENU_SELECT]))
{ {
if (GetTimeCounter () - InTime < ONE_SECOND * 15) if (GetTimeCounter () - InTime < ONE_SECOND * 15)
@@ -122,7 +122,7 @@ else if (InputState & DEVICE_EXIT) return (FALSE);
GLOBAL (CurrentActivity) = (ACTIVITY)~0; GLOBAL (CurrentActivity) = (ACTIVITY)~0;
return (FALSE); return (FALSE);
} }
else if (CurrentMenuState.select) else if (PulsedInputState.key[KEY_MENU_SELECT])
{ {
BYTE fade_buf[1]; BYTE fade_buf[1];
@@ -166,12 +166,12 @@ else if (InputState & DEVICE_EXIT) return (FALSE);
BYTE NewState; BYTE NewState;
NewState = pMS->CurState; NewState = pMS->CurState;
if (CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_UP])
{ {
if (NewState-- == START_NEW_GAME) if (NewState-- == START_NEW_GAME)
NewState = QUIT_GAME; NewState = QUIT_GAME;
} }
else if (CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_DOWN])
{ {
if (NewState++ == QUIT_GAME) if (NewState++ == QUIT_GAME)
NewState = START_NEW_GAME; NewState = START_NEW_GAME;
+1 -1
View File
@@ -220,7 +220,7 @@ SaveProblem (void)
{ {
TaskSwitch (); TaskSwitch ();
UpdateInputState (); UpdateInputState ();
} while (!(CurrentMenuState.select || CurrentMenuState.special || } while (!(PulsedInputState.key[KEY_MENU_SELECT] || PulsedInputState.key[KEY_MENU_SPECIAL] ||
(GLOBAL (CurrentActivity) & CHECK_ABORT))); (GLOBAL (CurrentActivity) & CHECK_ABORT)));
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
+1 -1
View File
@@ -276,7 +276,7 @@ sis_hyper_postprocess (PELEMENT ElementPtr)
GLOBAL (velocity) = ElementPtr->velocity; GLOBAL (velocity) = ElementPtr->velocity;
GetElementStarShip (ElementPtr, &StarShipPtr); GetElementStarShip (ElementPtr, &StarShipPtr);
if (((StarShipPtr->cur_status_flags & WEAPON) || CurrentMenuState.cancel) if (((StarShipPtr->cur_status_flags & WEAPON) || PulsedInputState.key[KEY_MENU_CANCEL])
&& StarShipPtr->special_counter == 0) && StarShipPtr->special_counter == 0)
{ {
#define MENU_DELAY 10 #define MENU_DELAY 10
+9 -9
View File
@@ -605,10 +605,10 @@ DoModifyShips (PMENU_STATE pMS)
#ifdef WANT_SHIP_SPINS #ifdef WANT_SHIP_SPINS
BOOLEAN special; BOOLEAN special;
special = CurrentMenuState.special; special = PulsedInputState.key[KEY_MENU_SPECIAL];
#endif /* WANT_SHIP_SPINS */ #endif /* WANT_SHIP_SPINS */
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
{ {
@@ -637,10 +637,10 @@ DoModifyShips (PMENU_STATE pMS)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
} }
if (CurrentMenuState.right) dx = 1; if (PulsedInputState.key[KEY_MENU_RIGHT]) dx = 1;
if (CurrentMenuState.left) dx = -1; if (PulsedInputState.key[KEY_MENU_LEFT]) dx = -1;
if (CurrentMenuState.up) dy = -1; if (PulsedInputState.key[KEY_MENU_UP]) dy = -1;
if (CurrentMenuState.down) dy = 1; if (PulsedInputState.key[KEY_MENU_DOWN]) dy = 1;
NewState = pMS->CurState; NewState = pMS->CurState;
if (pMS->delta_item & MODIFY_CREW_FLAG) if (pMS->delta_item & MODIFY_CREW_FLAG)
{ {
@@ -1207,8 +1207,8 @@ DoShipyard (PMENU_STATE pMS)
if (GLOBAL (CurrentActivity) & CHECK_ABORT) if (GLOBAL (CurrentActivity) & CHECK_ABORT)
goto ExitShipyard; goto ExitShipyard;
select = CurrentMenuState.select; select = PulsedInputState.key[KEY_MENU_SELECT];
cancel = CurrentMenuState.cancel; cancel = PulsedInputState.key[KEY_MENU_CANCEL];
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT); SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
if (!pMS->Initialized) if (!pMS->Initialized)
+3 -3
View File
@@ -337,7 +337,7 @@ s.origin.x = SAFE_X, s.origin.y = SAFE_Y + 4;
"rotate starbase"); "rotate starbase");
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
else if (CurrentMenuState.select else if (PulsedInputState.key[KEY_MENU_SELECT]
|| GET_GAME_STATE (MOONBASE_ON_SHIP) || GET_GAME_STATE (MOONBASE_ON_SHIP)
|| GET_GAME_STATE (CHMMR_BOMB_STATE) == 2) || GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
{ {
@@ -399,12 +399,12 @@ ExitStarBase:
STARBASE_STATE NewState; STARBASE_STATE NewState;
NewState = pMS->CurState; NewState = pMS->CurState;
if (CurrentMenuState.left || CurrentMenuState.up) if (PulsedInputState.key[KEY_MENU_LEFT] || PulsedInputState.key[KEY_MENU_UP])
{ {
if (NewState-- == TALK_COMMANDER) if (NewState-- == TALK_COMMANDER)
NewState = DEPART_BASE; NewState = DEPART_BASE;
} }
else if (CurrentMenuState.right || CurrentMenuState.down) else if (PulsedInputState.key[KEY_MENU_RIGHT] || PulsedInputState.key[KEY_MENU_DOWN])
{ {
if (NewState++ == DEPART_BASE) if (NewState++ == DEPART_BASE)
NewState = TALK_COMMANDER; NewState = TALK_COMMANDER;
+3 -3
View File
@@ -178,13 +178,13 @@ PauseGame (void)
FlushGraphics (); FlushGraphics ();
//LockMutex (GraphicsLock); //LockMutex (GraphicsLock);
while (ImmediateInputState.pause) while (ImmediateInputState.key[KEY_PAUSE])
TaskSwitch (); TaskSwitch ();
while (!ImmediateInputState.pause) while (!ImmediateInputState.key[KEY_PAUSE])
TaskSwitch (); TaskSwitch ();
while (ImmediateInputState.pause) while (ImmediateInputState.key[KEY_PAUSE])
TaskSwitch (); TaskSwitch ();
GamePaused = FALSE; GamePaused = FALSE;