Difference between revisions of "Coding Conventions"

Jump to navigation Jump to search
m
→‎Endianess issues: typo, change thoughtless edit n stuff
m (→‎Endianess issues: typo, change thoughtless edit n stuff)
Line 17: Line 17:


ScummVM engine authors have to keep endianess issues in mind for two reasons:
ScummVM engine authors have to keep endianess issues in mind for two reasons:
* ScummVM runs on both little endian (Windows, Intel Mac OS X, Intel Linux, ...) and big end hosts (PowerPC Mac OS X, ...). So when writing data (think savegames) to files and reading it back again, you need to compensate for this. This is easily done by using the READ_ and WRITE_ macros from common/endian.h (like READ_LE_UINT32 or WRITE_BE_UINT16.) resp. the corresponding Stream class methods (like readUint32LE or writeUint16BE)
* ScummVM runs on both little endian (Windows, x86 Mac OS X, x86 Linux...) and big end hosts (PowerPC Mac OS X, PlayStation 3 Linux...). So when writing data (think savegames) to files and reading it back again, you need to compensate for this. This is easily done by using the READ_ and WRITE_ macros from common/endian.h (like READ_LE_UINT32 or WRITE_BE_UINT16.) respectively the corresponding Stream class methods (like readUint32LE or writeUint16BE).
* Furthermore, some games existed in multiple versions, e.g. one for Windows and one for Mac OS X. In that case, you may have to detect and distinguish these versions and employ differnt reading calls, to compensate for endian differences in the game data files.
* Furthermore, some games existed in multiple versions, e.g. one for Windows and one for Mac OS. In that case, you may have to detect and distinguish these versions and employ different reading calls, to compensate for endian differences in the game data files.


== Struct packing ==
== Struct packing ==
736

edits

Navigation menu