The best way would be to use the stream methods like readSint16LE, readUint16LE, readUint32LE, and so on, to read in values from a stream, specifying a specific size and byte ordering (LE is the most common byte ordering used by PC games, since standard PC systems are LE, or Little Endian).Ī clean way to implement reading game data around this would be to create simple C++ classes to represent data structures from the game data files you're reading, and have a method on the class to read in the data for the structure.However, even then, you'd really need to wrap access to individual fields of the structure using either the FROM_LE and FROM_BE, or READ_LE and READ_BE macros defined in common/endian.h to properly access the fields on all the systems ScummVM can run on. A slightly better, but still bad way to read data would be to use the PACKED_STRUCT macros to create a packed structure that will not have any padding between fields, and is more likely to correctly map to data from a game file.This is bad because different systems may put padding bytes between fields of a structure, and even individual fields that take several bytes to represent them may have the bytes ordered differently (this is called the "endianness" of values). The absolute worst way to read data is read a block and try to cast it directly to a structure pointer.ScummVM runs on different architectures, so take into account byte ordering when reading in data from game files:.Without it, your engine will automatically use up 100% of CPU time, and slow down any other programs running on your computer. Remember to put a g_system->delayMillis call into any loop that does event processing.These aren't in any particular order, and are suggestions or recommendations rather than rules, so it's up to the developer whether to follow them or not. The following is a list of suggestions, tips, and recommendations for people to keep in mind when developing new engines for ScummVM.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |