DEFINITION MODULE input; (**************************************************************************) (* *) (* This module deals with all the input of the program, Ataxx. It must *) (* be linked with the graphics module, because the IDCMP events are *) (* linked to the window. Therefore, some of the structures that should *) (* be hidden in the ataxxgraphics module are visible so that this module *) (* can use them. *) (* *) (**************************************************************************) FROM header IMPORT movetype, playertype, boardtype; TYPE eventtype = (MOVE, (* Indicates that a move was attempted *) ABOUT, (* Request to display "About" info. *) OOPS, (* A meaningless event (aborted menu) *) NEWGAME, (* Signals that they want a new game. *) EDIT, (* The user wants to edit the board *) BACKUP, (* The user wants to back up a move *) REDO, (* " " redo a move. *) FORCE, (* Force the computer to move now. *) QUIT); (* Quit the program. *) VAR moveAttempted : movetype; (* This global is where an attempted *) (* move is stored while it is deter- *) (* mined if the move is valid or not. *) (**************************************************************************) PROCEDURE InitMenus; (* This initializes the menus for the program. Simple. *) (* *) (* INPUT *) (* n/a *) (* *) (* OUTPUT *) (* The menus for the program now should work. *) (* *) (**************************************************************************) PROCEDURE ChangeToEditMenu; (* Clears the current menu and makes the Edit menu. *) (* *) (* INPUT *) (* n/a *) (* *) (* OUTPUT *) (* Remakes the menu bar. *) (**************************************************************************) PROCEDURE ChangeToComputerMenu; (* Clears the current menu and makes the menu to be displayed during *) (* the time the computer is moving. *) (* *) (* INPUT *) (* n/a *) (* *) (* OUTPUT *) (* Remakes the menu bar. *) (**************************************************************************) PROCEDURE ChangeToMainMenu; (* Clears the current menu and makes the regular Main menu. *) (* *) (* INPUT *) (* n/a *) (* *) (* OUTPUT *) (* Remakes the menu bar. *) (* *) (**************************************************************************) PROCEDURE CloseMenus; (* This closes and deallocates the memory for the menus. *) (* *) (* INPUT *) (* n/a *) (* *) (* OUTPUT *) (* Kills the menus. *) (* *) (**************************************************************************) PROCEDURE EditBoard (VAR board : boardtype; VAR player : playertype) : BOOLEAN; (* This procedure controls all the necessary input and outputs for mod- *) (* ifying the board and returns whether or not any changes were made. *) (* *) (* INPUT *) (* board The current board. *) (* *) (* player The current player to move. This is *) (* needed to return the pointer to the old *) (* state. *) (* *) (* OUTPUT *) (* board This is returned reflecting the modified *) (* state. *) (* *) (* The function returns TRUE only if the board was actually *) (* altered. A return of FALSE signifies that no changes were *) (* made to the board. *) (**************************************************************************) PROCEDURE WaitForMouseUp; (* This simple procedure just waits until the left mouse button is re- *) (* leased. *) (**************************************************************************) PROCEDURE GetEvent(player : playertype) : eventtype; (* This procedure returns a code indicating a specific input event. *) (* Such events are like a menu selection, or a player's move. If the *) (* event is a move, then the specific move will be specified in the var- *) (* iable, moveAttempted. It is expected that this routine will be called *) (* and then waited for until the user(s) makes some sort of imput. It *) (* is the responsibility of this and subordinate procedures to do the *) (* waiting in a proper fashion. *) (* *) (* INPUT *) (* n/a *) (* *) (* OUTPUT *) (* Returns a variable of eventtype that indicates the high- *) (* level input event. If the event is a move by a player, *) (* then the variable moveAttempted will hold the move. *) (********************************************) END input.