protected void ReadCommand ( ) { key = null ; boolean gotKey = false ; // Until a key is found while ( ! gotKey ) { // Read the first Char char b0 = getCard8 ( ) ; // decode according to the type1/type2 format if ( b0 == 28 ) // the two next bytes represent a short int; { int first = getCard8 ( ) ; int second = getCard8 ( ) ; args [ arg_count ] = Integer . valueOf ( first << 8 | second ) ; arg_count ++ ; continue ; } if ( b0 >= 32 && b0 <= 246 ) // The byte read is the byte; { args [ arg_count ] = Integer . valueOf ( b0 - 139 ) ; arg_count ++ ; continue ; } if ( b0 >= 247 && b0 <= 250 ) // The byte read and the next byte constitute a short int { int w = getCard8 ( ) ; args [ arg_count ] = Integer . valueOf ( ( b0 - 247 ) * 256 + w + 108 ) ; arg_count ++ ; continue ; } if ( b0 >= 251 && b0 <= 254 ) // Same as above except negative { int w = getCard8 ( ) ; args [ arg_count ] = Integer . valueOf ( - ( b0 - 251 ) * 256 - w - 108 ) ; arg_count ++ ; continue ; } if ( b0 == 255 ) // The next for bytes represent a double. { int first = getCard8 ( ) ; int second = getCard8 ( ) ; int third = getCard8 ( ) ; int fourth = getCard8 ( ) ; args [ arg_count ] = Integer . valueOf ( first << 24 | second << 16 | third << 8 | fourth ) ; arg_count ++ ; continue ; } if ( b0 <= 31 && b0 != 28 ) // An operator was found.. Set Key. { gotKey = true ; // 12 is an escape command therefore the next byte is a part // of this command if ( b0 == 12 ) { int b1 = getCard8 ( ) ; if ( b1 > SubrsEscapeFuncs . length - 1 ) b1 = SubrsEscapeFuncs . length - 1 ; key = SubrsEscapeFuncs [ b1 ] ; } else key = SubrsFunctions [ b0 ] ; continue ; } } }
The function reads the next command after the file pointer is set