|##########|
|#MAGIC   #|CLABLMLL
|#PROJECT #|""
|#PATHS   #|"StdProject"
|#FLAGS   #|xx-x-x-xxx----x-----------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x-xx------------
|##########|
DEFINITION MODULE GamePort;

$$LongAllign:= FALSE      | Absolutely essential

FROM T_Exec       IMPORT IOCommand, nonstdVAL, IOStdReq;
FROM Resources    IMPORT ContextPtr;

CONST
  readEvent    = IOCommand( nonstdVAL + 0 );
  askCType     = IOCommand( nonstdVAL + 1 );
  setCType     = IOCommand( nonstdVAL + 2 );
  askTrigger   = IOCommand( nonstdVAL + 3 );
  setTrigger   = IOCommand( nonstdVAL + 4 );

|Errors
  errSetCType  = 1;

  portOne      = 0;
  portTwo      = 1;

TYPE
  Keys            = ( downKeys, upKeys, makemeword = 15 );
  KeySet          = SET OF Keys;

  GamePortTrigger = RECORD
		      keys    : KeySet;
		      timeout : CARDINAL;
		      xDelta  : CARDINAL;
		      yDelta  : CARDINAL
		    END;

   Controller     = (allocated=-1,noController,mouse,relJoystick,
		     absJoystick);

   GameReqPtr     = POINTER TO GameReq;
   GameReq        = RECORD OF IOStdReq END;

PROCEDURE OpenGamePort( port : INTEGER;
			context : ContextPtr:=NIL ): GameReqPtr;

PROCEDURE CloseGamePort( VAR request : GameReqPtr );

GROUP
  All   = T_Exec.ExecIOGrp,askCType,askTrigger,errSetCType,portOne,
	  portTwo,readEvent,setCType,setTrigger,Keys,GamePortTrigger,
	  GameReq,GameReqPtr,Controller,OpenGamePort,CloseGamePort;

END GamePort.

