Logo Search packages:      
Sourcecode: scummvm version File versions  Download package

uint16 Agi::WagFileParser::convertToAgiVersionNumber ( const WagProperty version )

Convert property's data to an AGI interpreter version number.

versionThe property to be converted (Property code should be PC_INTVERSION).
AGI interpreter version number if successful, 0 otherwise.

Definition at line 131 of file wagparser.cpp.

References checkAgiVersionProperty(), Agi::WagProperty::getData(), and Agi::WagProperty::getSize().

Referenced by AgiMetaEngine::fallbackDetect().

      // Examples of the conversion: "2.44" -> 0x2440, "2.917" -> 0x2917, "3.002086" -> 0x3086.
      if (checkAgiVersionProperty(version)) { // Check that the string is a valid AGI interpreter version string
            // Convert first ascii digit to an integer and put it in the fourth nibble (Bits 12...15) of the version number
            // and at the same time set all other nibbles to zero.
            uint16 agiVerNum = ((uint16) (version.getData()[0] - '0')) << (3 * 4);

            // Convert at most three least significant digits of the version number's minor part
            // (i.e. the part after the decimal point) and put them in order to the third, second
            // and the first nibble of the version number. Just to clarify version.getSize() - 2
            // is the number of digits after the decimal point.
            int32 digitCount = MIN<int32>(3, ((int32) version.getSize()) - 2); // How many digits left to convert
            for (int i = 0; i < digitCount; i++)
                  agiVerNum |= ((uint16) (version.getData()[version.getSize() - digitCount + i] - '0')) << ((2 - i) * 4);

            debug(3, "WagFileParser: Converted AGI version from string %s to number 0x%x", version.getData(), agiVerNum);
            return agiVerNum;
      } else // Not a valid AGI interpreter version string
            return 0; // Can't convert, so failure

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index