Source code for /engineering/bos/rewrite/BINST.HOriginal file BINST.H
   1 /*
   2 	BattleOS : Engage battling programs.
   3 
   4 	Copyright (C) 1993 Erich P Gatejen    ALL RIGHTS RESERVED
   5 
   6 
   7 	File     : BINST.H
   8 	Purpose  : Header file for the BattleOS Instruction class and
   9 			 supporting stuff
  10 
  11 */
  12 
  13 #ifndef __BINST_H
  14 #define __BINST_H
  15 
  16 /* Include standard definitions */
  17 #include "defines.h"
  18 
  19 /* Define the 'instruction' class.  */
  20 class Instr {
  21 
  22    unsigned  Token     : 5;    // Token of instruction
  23    unsigned  OpTokenL  : 3;    // Token of left operand type
  24    unsigned  OpTokenR  : 3;    // Token of left operand type
  25    unsigned  	       : 1;    // Filler
  26 
  27    unsigned  TauntFlag : 1;    // Taunt flag
  28    unsigned  Taunt     : 3;    // Taunt embed field
  29 
  30    signed    OperandL  : 16;   // Left operand.  Full word
  31    signed    OperandR  : 16;   // Left operand.  Full word
  32 
  33    /* Used by BOS */
  34    unsigned  Owner     : 8;    // Owner handle
  35    unsigned  	       : 7;    // Filler
  36    unsigned  TrapSet   : 1;    // Wait flag
  37 
  38  public:
  39 
  40    /* BOOLEAN value access 			  */
  41    BOOLEAN   HasTaunt( void ) { return TauntFlag; };
  42    BOOLEAN   HasWait(  void ) { return TrapSet;   };
  43 
  44    /* Value access routines.  All inline  */
  45    unsigned  TokenIs(  void )       { return Token;	 };
  46    unsigned  LeftOpTokenIs(  void ) { return OpTokenL;  };
  47    unsigned  RightOpTokenIs( void ) { return OpTokenR;  };
  48    unsigned  TauntIs(  void )       { return Taunt;	 };
  49    signed int  LeftOperandIs(  void ) { return OperandL;  };
  50    signed int  RightOperandIs( void ) { return OperandR;  };
  51    unsigned  OwnerIs(  void )       { return Owner;	 };
  52 
  53    /* BOOLEAN set access				  */
  54    void  DoesHaveTaunt( void )     { TauntFlag = TRUE;  };
  55    void  DoesHaveWait( void )      { TrapSet   = TRUE;  };
  56    void  DoesNotHaveTaunt( void )  { TauntFlag = FALSE; };
  57    void  DoesNotHaveWait(  void )  { TrapSet   = FALSE; };
  58 
  59    /* Value set routines.  All inline and overloading the value access  */
  60    void  TokenIs( unsigned  InToken  ) { Token    = InToken;  };
  61    void  LeftOpTokenIs(  unsigned Op ) { OpTokenL = Op;       };
  62    void  RightOpTokenIs( unsigned Op ) { OpTokenR = Op;       };
  63    void  TauntIs( unsigned  InTaunt  ) { Taunt    = InTaunt;  };
  64    void  LeftOperandIs(  signed   Op ) { OperandL = Op;       };
  65    void  RightOperandIs( signed   Op ) { OperandR = Op;       };
  66    void  OwnerIs( unsigned  InOwner  ) { Owner    = InOwner;  };
  67 
  68    // Constructor
  69    Instr( void ) {  TokenIs( 0 );
  70 		    LeftOpTokenIs(  0 );
  71 		    RightOpTokenIs( 0 );
  72 		    TauntIs( 0 );
  73 		    LeftOperandIs(  0 );
  74 		    RightOperandIs( 0 );
  75 		    OwnerIs( 0 );
  76 
  77    };
  78 
  79    unsigned int FirstWord( void ) {
  80 
  81       unsigned int	Word;
  82 
  83       Word = Token << 11;
  84       Word = Word | ( OpTokenL  << 8 );
  85       Word = Word | ( OpTokenR  << 5 );
  86       Word = Word | ( TauntFlag << 3 );
  87       Word = Word | Taunt;
  88 
  89       return Word;
  90 
  91    };
  92 
  93 }; // end Instr
  94 
  95 #endif