Difference between revisions of "Coding Conventions"

Jump to navigation Jump to search
825 bytes added ,  18:04, 1 July 2007
no edit summary
(Added an initial simple porting guide)
 
Line 17: Line 17:
* Furthermore, some games existed in multiple versions, e.g. one for Windows and one for MacOS. 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 MacOS. 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.


== Struct packing ==
Do *not* assume that structs are stored in a certain way in memory -- the layout of a struct in memory can vary a lot between platforms, and on most modern systems it will almost never be "packed". If you absolutely must use packed structs, do not just use some #pragma or __attribute__ (as that is not portable either). Instead, do the following:
* Before the struct(s) you need to be packed, insert
  #include "common/pack-start.h" // START STRUCT PACKING
* After the struct(s) you need to be packed, insert
  #include "common/pack-end.h" // END STRUCT PACKING
* At the "end" of each struct you need to be packed, insert the following between the closing } and the ; after it:
  PACKED_STRUCT
You may want to look at some files which already do that, e.g. look at <code>engines/scumm/boxes.cpp</code>


== File access ==
== File access ==
TODO: Talk about file reading/writing, SaveFile vs. File, FSNodes vs. Paths, etc. -- maybe wait until the SoC, though? *g*
TODO: Talk about file reading/writing, SaveFile vs. File, FSNodes vs. Paths, etc. -- maybe wait until the SoC, though? *g*
1,079

edits

Navigation menu