developers.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <html><head>
  2. <link rel="icon" href="images/icon.png" type="image/png">
  3. <title>uCON64 - Developers</title></head><body bgcolor="#ffffff"><tt><br>
  4. Q1: <a href="#1">Who develops uCON64?</a><br>
  5. <br>
  6. Q2: <a href="#2">How can I take part?</a><br>
  7. <br>
  8. Q3: <a href="#3">How do I get the source of uCON64, using CVS as an anonymous user?</a><br>
  9. <br>
  10. Q4: <a href="#4">How do I connect to the CVS repository as developer with read/write access?</a><br>
  11. <br>
  12. Q5: <a href="#5">How do I create a patch from the CVS repository?</a><br>
  13. <br>
  14. Q6: <a href="#6">How is the source of uCON64 organized?</a><br>
  15. <br>
  16. Q7: <a href="#7">What coding style is preferred?</a><br>
  17. <br>
  18. <br>
  19. <p><!-- <p> instead of <br> to make lynx display a blank line between questions -->
  20. <a name="1"><b>Q1</b>: Who develops uCON64?</a><br>
  21. <b>A</b>: Written/modified by:<br>
  22. 1999 - 2009 NoisyB<br>
  23. 2001 - 2005, 2015 dbjh<br>
  24. <br>
  25. Additional developers:<br>
  26. 2002 - 2004 John Weidman <a href="mailto:jweidman AT sonic.net">&#60;jweidman AT sonic.net&#62;</a><br>
  27. Contributed several SNES-related features like Game Doctor &amp; Super UFO
  28. support, the second version of the BS (Broadcast Satellaview) detection code,
  29. SNES cracks &amp; NTSC/PAL fixes.<br>
  30. <br>
  31. 2002 - 2004 Jan-Erik Karlsson<br>
  32. Maintainer of the Amiga ports.<br>
  33. <br>
  34. 2003 - 2004 JohnDie<br><!-- It's a nick name, no space between John and Die -->
  35. Also contributed several SNES-related features like Pro Fighter support and
  36. Super Wild Card transfer code improvements.<br>
  37. <br>
  38. <br>
  39. uCON64 uses code (or at least ideas) from:<br>
  40. <br>
  41. <table>
  42. <tr>
  43. <td><tt>Chicken&nbsp;&amp;&nbsp;chp</tt></td>
  44. <td><a href="mailto:ronaldm AT netcom.com"><tt>ronaldm AT netcom.com</tt></a><tt> (chp)</tt></td>
  45. <td><tt>original uCON</tt></td>
  46. </tr>
  47. <tr>
  48. <td><tt>Silo&nbsp;/&nbsp;BlackBag</tt></td>
  49. <td></td>
  50. <td><tt>APS patcher</tt></td>
  51. </tr>
  52. <tr>
  53. <td><tt>madman</tt></td>
  54. <td></td>
  55. <td><tt>IPS patcher</tt></td>
  56. </tr>
  57. <tr>
  58. <td><tt>The&nbsp;White&nbsp;Knight&nbsp;/ ATX</tt></td><!-- yes, breaking space -->
  59. <td></td>
  60. <td><tt>BSL patcher</tt></td>
  61. </tr>
  62. <tr>
  63. <td><tt>Icarus&nbsp;/&nbsp;Paradox</tt></td>
  64. <td></td>
  65. <td><tt>PPF patcher</tt></td>
  66. </tr>
  67. <tr>
  68. <td><tt>WyrmCorp</tt></td>
  69. <td><a href="http://wyrmcorp.com"><tt>http://wyrmcorp.com</tt></a></td>
  70. <td><tt>Game Genie "codec"</tt></td>
  71. </tr>
  72. <tr>
  73. <td><tt>Marat&nbsp;Fayzullin</tt></td>
  74. <td><a href="mailto:fms AT cs.umd.edu"><tt>fms AT cs.umd.edu</tt></a><br>
  75. <a href="http://www.komkon.org/fms/">
  76. <tt>http://www.komkon.org/fms/</tt></a></td>
  77. <td><tt>some Famicom Disk System routines and NESLIST</tt></td>
  78. </tr>
  79. <tr>
  80. <td><tt>Andreas&nbsp;Sterbenz</tt></td>
  81. <td><a href="mailto:stan AT sbox.tu-graz.ac.at"><tt>stan AT sbox.tu-graz.ac.at</tt></a></td>
  82. <td><tt>N64 checksum algorithm</tt></td>
  83. </tr>
  84. <tr>
  85. <td><tt>Kami</tt></td>
  86. <td><a href="mailto:m-kami AT da2.so-net.ne.jp"><tt>m-kami AT da2.so-net.ne.jp</tt></a><br>
  87. <a href="http://www.playoffline.com">
  88. <tt>http://www.playoffline.com</tt></a></td>
  89. <td><tt>NES emulator for Game Boy</tt></td>
  90. </tr>
  91. <tr>
  92. <td><tt>Gilligan&nbsp;/&nbsp;DC-S</tt></td>
  93. <td></td>
  94. <td><tt>show info for Neogeo Pocket</tt></td>
  95. </tr>
  96. <tr>
  97. <td><tt>LaC</tt></td>
  98. <td></td>
  99. <td><tt>N64 makesram</tt></td>
  100. </tr>
  101. <tr>
  102. <td><tt>Jeff&nbsp;Frohwein</tt></td>
  103. <td><a href="mailto:info AT devrs.com"><tt>info AT devrs.com</tt></a><br>
  104. <a href="http://www.devrs.com">
  105. <tt>http://www.devrs.com</tt></a></td>
  106. <td><tt>Flash Advance Linker transfer code</tt></td>
  107. </tr>
  108. <tr>
  109. <td><tt>Omar&nbsp;Kilani</tt></td>
  110. <td><a href="mailto:gbautil AT aurore.net"><tt>gbautil AT aurore.net</tt></a></td>
  111. <td><tt>Game Boy Advance SRAM patching and "crash patching" code</tt></td>
  112. </tr>
  113. <tr>
  114. <td><tt>Richard Davies</tt></td>
  115. <td><a href="mailto:richard AT debaser.force9.co.uk"><tt>richard AT debaser.force9.co.uk</tt></a><br>
  116. <a href="http://www.debaser.force9.co.uk">
  117. <tt>http://www.debaser.force9.co.uk</tt></a></td>
  118. <td><tt>PSX memory card code</tt></td>
  119. </tr>
  120. <tr>
  121. <td><tt>Caz</tt></td>
  122. <td><a href="mailto:turok2 AT currantbun.com"><tt>turok2 AT currantbun.com</tt></a><br>
  123. <a href="http://www.infernal.currantbun.com">
  124. <tt>http://www.infernal.currantbun.com</tt></a></td>
  125. <td><tt>I/O port driver for BeOS, SWC help and Super UFO SRAM header format</tt></td>
  126. </tr>
  127. <tr>
  128. <td><tt>Cowering</tt></td>
  129. <td><a href="mailto:hotemu AT hotmail.com"><tt>hotemu AT hotmail.com</tt></a></td>
  130. <td><tt>old BS ROM detection, BS checksum, some PC-Engine info &amp; code and more</tt></td>
  131. </tr>
  132. <tr>
  133. <td><tt>Jerremy&nbsp;Koot</tt></td>
  134. <td><a href="mailto:jkoot AT snes9x.com"><tt>jkoot AT snes9x.com</tt></a><br>
  135. <a href="http://www.snes9x.com">
  136. <tt>http://www.snes9x.com</tt></a></td>
  137. <td><tt>old interleave detection and old deinterleave code (SNES)</tt></td>
  138. </tr>
  139. <tr>
  140. <td><tt>Gary&nbsp;Henderson</tt></td>
  141. <td><a href="mailto:gary AT snes9x.com"><tt>gary AT snes9x.com</tt></a><br>
  142. <a href="http://www.snes9x.com">
  143. <tt>http://www.snes9x.com</tt></a></td>
  144. <td><tt>old interleave detection and old deinterleave code (SNES)</tt></td>
  145. </tr>
  146. <tr>
  147. <td><tt>Evan&nbsp;Teran</tt></td>
  148. <td><a href="mailto:emt3734 AT ritvax.isc.rit.edu"><tt>emt3734 AT ritvax.isc.rit.edu</tt></a></td>
  149. <td><tt>lib_unif (NES)</tt></td>
  150. </tr>
  151. <tr>
  152. <td><tt>NSRT&nbsp;authors</tt></td>
  153. <td><a href="mailto:joecool22us AT yahoo.com"><tt>joecool22us AT yahoo.com</tt></a><br>
  154. <a href="http://nsrt.edgeemu.com"><tt>http://nsrt.edgeemu.com</tt></a></td>
  155. <td><tt>checksum algorithm for Momotaro Dentetsu Happy, their SNES add-on
  156. chip information page, SNES cracks (thanks to CL), third version of
  157. BS detection code (thanks to Nach) and general help and ideas</tt></td>
  158. </tr>
  159. <tr>
  160. <td><tt>Gilles&nbsp;Vollant</tt></td>
  161. <td><a href="mailto:info AT winimage.com"><tt>info AT winimage.com</tt></a></td>
  162. <td><tt>unzip.c &amp; unzip.h</tt></td>
  163. </tr>
  164. <tr>
  165. <td><tt>Tiptonium</tt></td>
  166. <td><tt><a href="http://www.tiptonium.com">http://www.tiptonium.com</a></td>
  167. <td><tt>donated a Super Magic Drive (SMD)</tt></td>
  168. </tr>
  169. <tr>
  170. <td><tt>FluBBa</tt></td>
  171. <td></td><!-- private -->
  172. <td><tt>maker (publisher) info for SNES, GB, CGB &amp; GBA</tt></td>
  173. </tr>
  174. <tr>
  175. <td><tt>gc-nfo.com</tt></td>
  176. <td></td><!-- private -->
  177. <td><tt>GameCube image specs</tt></td>
  178. </tr>
  179. <tr>
  180. <td><tt>ToToTEK Multi Media</tt></td>
  181. <td><a href="mailto:rayman AT tototek.com"><tt>rayman AT tototek.com</tt></a><br>
  182. <a href="http://www.tototek.com">
  183. <tt>http://www.tototek.com</tt></a></td>
  184. <td><tt>MD-PRO, SMS-PRO/GG-PRO &amp; PCE-PRO transfer code (Delphi) and help
  185. with that code</tt></td>
  186. </tr>
  187. <tr>
  188. <td><tt>timofonic</tt></td>
  189. <td></td><!-- private? -->
  190. <td><tt>uCON64 PR work ;-)</tt></td>
  191. </tr>
  192. <tr>
  193. <td><tt>Felipe&nbsp;XnaK</tt></td>
  194. <td><a href="mailto:felipe AT ComPorts.com"><tt>felipe AT ComPorts.com</tt></a><br>
  195. <a href="http://www.classicgaming.com/launchtool">
  196. <tt>http://www.classicgaming.com/launchtool</tt></a></td>
  197. <td><tt>some info from his Genesis ROM format document</tt></td>
  198. </tr>
  199. <tr>
  200. <td><tt>Ulrich&nbsp;Hecht</tt></td>
  201. <td><a href="mailto:uli AT emulinks.de"><tt>uli AT emulinks.de</tt></a><br>
  202. <a href="http://www.emulinks.de/software.html">
  203. <tt>http://www.emulinks.de/software.html</tt></a></td>
  204. <td><tt>F2A (USB) code</tt></td>
  205. </tr>
  206. <tr>
  207. <td><tt>David&nbsp;Voswinkel</tt></td>
  208. <td><a href="mailto:d.voswinkel AT netcologne.de"><tt>d.voswinkel AT netcologne.de</tt></a></td>
  209. <td><tt>F2A parallel port &amp; Quickdev16 code</tt></td>
  210. </tr>
  211. <tr>
  212. <td><tt>Ryan&nbsp;Underwood</tt></td>
  213. <td></td><!-- private? -->
  214. <td><tt>libcd64</tt></td>
  215. </tr>
  216. <tr>
  217. <td><tt>Mike&nbsp;Pavone</tt></td>
  218. <td><a href="mailto:mask_of_destiny AT hotmail.com"><tt>mask_of_destiny AT hotmail.com</tt></a><br>
  219. <a href="http://www.retrodev.com">
  220. <tt>http://www.retrodev.com</tt></a></td>
  221. <td><tt>Genesis/Sega CD transfer code</tt></td>
  222. </tr>
  223. <tr>
  224. <td><tt>Cyan&nbsp;Helkaraxe</tt></td>
  225. <td><a href="mailto:cyan AT emulationzone.org"><tt>cyan AT emulationzone.org</tt></a><br>
  226. <a href="http://www.emulationzone.org/projects/cyan/docs">
  227. <tt>http://www.emulationzone.org/projects/cyan/docs</tt></a></td>
  228. <td><tt>Cyan's Megadrive ROM copier transfer code</tt></td>
  229. </tr>
  230. <tr>
  231. <td><tt>Parasyte</tt></td>
  232. <td></td><!-- private -->
  233. <td><tt>Support for remaining N64 CIC algorithms (6101, 6103, and 6106)</tt></td>
  234. </tr>
  235. </table><br>
  236. and others...<br>
  237. <br>
  238. <p>
  239. <a name="2"><b>Q2</b>: How can I take part?</a><br>
  240. <b>A</b>: Install <a href="http://www.cvshome.org">CVS</a> and
  241. checkout the latest version from
  242. <a href="http://ucon64.sourceforge.net">http://ucon64.sourceforge.net</a>.
  243. Then make your changes, email
  244. <a href="mailto:ucon64-main AT lists.sourceforge.net">ucon64-main AT lists.sourceforge.net</a>
  245. and you will be named in this file and in the sources of course. Just the
  246. typical way of open source software development.<br>
  247. <br>
  248. <p>
  249. <a name="3"><b>Q3</b>: How do I get the source of uCON64, using CVS as an
  250. anonymous user?</a><br>
  251. <b>A</b>: For read-only access you must have CVS installed. First you have to
  252. login. To login, type:<br>
  253. &nbsp;&nbsp;cvs -d:pserver:anonymous@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 login<br>
  254. Then CVS will ask you for a password. Since you are logged in as anonymous
  255. you do not have a password, so just press the enter key at the password
  256. prompt. To download the uCON64 source, type:<br>
  257. &nbsp;&nbsp;cvs -d:pserver:anonymous@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 checkout -PR ucon64<br>
  258. The uCON64 source will then be downloaded to the directory ./ucon64.<br>
  259. It can be very busy at SourceForge which may result in a message like:<br>
  260. &nbsp;&nbsp;cvs [login aborted]: recv() from server ucon64.cvs.sourceforge.net: EOF<br>
  261. or<br>
  262. &nbsp;&nbsp;cvs [checkout aborted]: recv() from server ucon64.cvs.sourceforge.net: EOF<br>
  263. If you get that message simply try again.<br>
  264. You can speed up the download by using the option -z with a compression level
  265. parameter. For example:<br>
  266. &nbsp;&nbsp;cvs -z 9 -d:pserver:anonymous@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 checkout -PR ucon64<br>
  267. If you want to get up to date with the newest source code later, enter the
  268. directory ucon64 and type:<br>
  269. &nbsp;&nbsp;cvs update -PRd<br>
  270. <br>
  271. <p>
  272. <a name="4"><b>Q4</b>: How do I connect to the CVS repository as developer with
  273. read/write access?</a><br>
  274. <b>A</b>: For read/write access you must have CVS and SSH installed and set the
  275. environment variable CVS_RSH=ssh. To download the source code, type:<br>
  276. &nbsp;&nbsp;cvs -z 9 -d:ext:&#60;username&#62;@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 checkout -PR ucon64<br>
  277. &#60;enter password at prompt&#62;<br>
  278. If you never logged on to ucon64.cvs.sourceforge.net before you may get a message
  279. (from SSH) like:<br>
  280. &nbsp;&nbsp;The authenticity of host 'ucon64.cvs.sourceforge.net (66.35.250.88)' can't be established.<br>
  281. &nbsp;&nbsp;RSA key fingerprint is 13:f1:65:c3:6c:b7:7e:a5:f0:f3:f5:19:f4:42:9c:4a.<br>
  282. &nbsp;&nbsp;Are you sure you want to continue connecting (yes/no)?<br>
  283. Type yes (the whole word). SSH will respond with a message like:<br>
  284. &nbsp;&nbsp;Warning: Permanently added 'ucon64.cvs.sourceforge.net,66.35.250.88' (RSA) to the list of known hosts.<br>
  285. Now all files will be downloaded. Afterwards you can simply cd into the top
  286. level directory and continue by just typing:<br>
  287. &nbsp;&nbsp;cvs update -PRd<br>
  288. &nbsp;&nbsp;cvs commit -R<br>
  289. &nbsp;&nbsp;cvs add &#60;file&#62;<br>
  290. &nbsp;&nbsp;cvs remove -f &#60;file&#62;<br>
  291. You don't need to specify
  292. -d:ext:&#60;username&#62;@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 anymore, because
  293. that information is stored in the CVS directories then.<br>
  294. If you use the update command in combination with (-)d, never forget to also
  295. use the option -P or you will get a lot of crap.<br>
  296. <br>
  297. <p>
  298. <a name="5"><b>Q5</b>: How do I create a patch from the CVS repository?</a><br>
  299. <b>A</b>: As developer:<br>
  300. &nbsp;&nbsp;cvs -d:ext:&#60;username&#62;@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 diff -Nau &#62;mychanges.patch<br>
  301. &#60;enter password at prompt&#62;<br>
  302. As anonymous:<br>
  303. &nbsp;&nbsp;cvs -d:pserver:anonymous@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 login<br>
  304. &#60;just press enter at password prompt&#62;<br>
  305. &nbsp;&nbsp;cvs -d:pserver:anonymous@ucon64.cvs.sourceforge.net:/cvsroot/ucon64 diff -Nau &#62;mychanges.patch<br>
  306. <br>
  307. <p>
  308. <a name="6"><b>Q6</b>: How is the source code of uCON64 organized?</a><br>
  309. <b>A</b>: The heart of uCON64 is ucon64.h/st_ucon64_t. This <i>struct</i> is
  310. designed to hold all workflow relevant informations and it has pointers
  311. to different structs which will be != NULL depending on which type or
  312. format uCON64 did detect for the current ROM. libdiscmage (if compiled)
  313. is involved in this process as well.<br><br>
  314. uCON64 starts with the name of a ROM and possibly some arguments. Then it
  315. checks if a configuration file exists and creates one if that is not the
  316. case. For example the value of
  317. ucon64.parport, the variable that contains the I/O address of the parallel
  318. port, will initially be set to the value that is found in the configuration
  319. file.<br>
  320. After these initial functions every ROM will be processed.<br><br>
  321. Processing a ROM.<br>
  322. The command line will be scanned for switches. Switches are command line
  323. arguments that will not result in an action by themselves, but they
  324. influence the other type of command line arguments, options. <br>
  325. uCON64 sets some other values in ucon64.h/st_ucon64_t, based on the
  326. switches. This code can be found in ucon64_opts.c/ucon64_switches().
  327. This is also the place where ucon64.c/ucon64.quiet is set. This variable
  328. determines whether or not uCON64 displays ROM information.<br>
  329. Then uCON64 starts scanning the command line for options. This code can be
  330. found in ucon64_opts.c/ucon64_options(). From this code almost all
  331. operations of uCON64 are executed. On UNIX this is also the point where root
  332. privileges are given up with a call to misc.c/drop_privileges().<br>
  333. First uCON64 tries to find out what console system the ROM belongs to using
  334. for example the init function for SNES (console/snes.c/snes_init() or
  335. console/nes.c/nes_init() for NES). Each init function tries to determine if the
  336. ROM file belongs to its console type. If that is the case it returns 0,
  337. otherwise -1.<br>
  338. Some ROM file types contain information such as the internal name, country
  339. and creator of the game that can be used to fill ucon64.c/main()/rom. SNES
  340. ROM files are an example of this type of file. For other ROM file types this
  341. information is not present inside the ROM file. NES ROMs are an example of
  342. that type. In that case uCON64 uses the DAT files in the data file
  343. directory. That makes it possible to display the full name of the game.
  344. ucon64.c/ucon64_rom_handling() calls the function
  345. ucon64_dat.c/ucon64_dat_search() that uses the CRC32 of the ROM file data to
  346. find the required information in the DAT files. If the information could be
  347. found ucon64_dat.c/ucon64_dat_search() fills ucon64.c/ucon64.dat with it.
  348. ucon64.c/ucon64_rom_handling() copies the name to ucon64.rominfo->name.<br>
  349. After that if ucon64.c/ucon64.quiet has a value smaller than 1 uCON64 will
  350. call ucon64.c/ucon64_nfo() which displays the values and strings of ucon64.
  351. For some options it doesn't make sense to display ROM info. If one of those
  352. options has been specified on the command line
  353. (ucon64.c/ucon64.flags &amp; WF_NFO) will be zero.<br>
  354. After all this the option will be executed (ucon64_opts.c/ucon64_options()).<br>
  355. <br>
  356. <p>
  357. <a name="7"><b>Q7</b>: What coding style is preferred?</a><br>
  358. <b>A</b>:<br>
  359. <br>
  360. <b>Keywords</b><br>
  361. Always put a space after a keyword. That includes the keyword <i>sizeof</i>.<br>
  362. <br>
  363. <b>Indentation</b><br>
  364. Two spaces instead of a real tab. The curly braces of functions should not
  365. be indented.<br>
  366. If an <i>if</i> statement has an <i>else</i> part, that part should be
  367. aligned with the <i>if</i> part. For a <i>do-while</i> compound statement,
  368. <i>do</i> and <i>while</i> should also be aligned.<br>
  369. If <i>else</i> is immediately followed by an <i>if</i> statement, the
  370. <i>if</i> keyword together with the condition statement should be put on the
  371. same line as the <i>else</i> keyword. Example: <br>
  372. <pre>
  373. if (...)
  374. {
  375. ...
  376. }
  377. else if (...)
  378. {
  379. ...
  380. }
  381. else
  382. {
  383. ...
  384. }
  385. </pre>
  386. Note that this doesn't apply to the case where <i>else</i> is followed by a
  387. curly brace.<br>
  388. <br>
  389. <b>New lines</b><br>
  390. The statement(s) for <i>if</i>, <i>while</i> and <i>for</i> should always
  391. start on a new line. That also applies to one-line statements.<br>
  392. <br>
  393. <b>Compound statements</b><br>
  394. The curly braces should be indented and the code of the compound statement
  395. should be indented again. The only exception is the <i>switch</i> statement.
  396. The labels inside a <i>switch</i> statement should be aligned with the curly
  397. braces. Example:<br>
  398. <pre>
  399. int
  400. function (int value)
  401. {
  402. if (value &#60; 0)
  403. {
  404. printf ("Invalid argument: %d\n", value);
  405. exit (1);
  406. }
  407. switch (value)
  408. {
  409. case 0:
  410. case 1:
  411. case 2: // falling through
  412. puts ("lesser than or equal to 2\n");
  413. case 3:
  414. case 4:
  415. puts ("lesser than or equal to 4\n");
  416. break;
  417. default:
  418. puts ("greater than 4\n");
  419. break;
  420. }
  421. return 0;
  422. }
  423. </pre>
  424. A <i>do-while</i> compound statement should have this layout:<br>
  425. <pre>
  426. do
  427. {
  428. ...
  429. }
  430. while (...);
  431. </pre>
  432. <br>
  433. <b>Functions</b><br>
  434. Function calls should contain one space after the name of the function.
  435. Every parameter of the function should be separated from a previous one with
  436. a space after the comma.<br>
  437. For a function implementation the return type should be specified on its own
  438. line. This doesn't apply to function prototypes. If a function needn't be
  439. known at global scope it should be declared or defined as <i>static</i>.
  440. Function implementations should be separated from each other by two new
  441. lines.<br>
  442. <br>
  443. <b>Variables</b><br>
  444. Variables of the same type should be defined in one group. Example:<br>
  445. <pre>
  446. int x, y = 0, z;
  447. char str1[] = "xyz", *str2;
  448. </pre>
  449. Variables that need to be known at file scope but not at global scope should
  450. be defined as <i>static</i>. Variables that do need to be known at global
  451. scope should be defined in a source file, not in a header file. The header
  452. file should contain an <i>extern</i> statement for the variable.<br>
  453. <br>
  454. <b>Types (<i>struct</i>s)</b><br>
  455. A <i>struct</i> tag of a <i>struct</i> should have the prefix "st_". A new
  456. type based on a <i>struct</i> should have the same prefix and the suffix
  457. "_t". Example:<br>
  458. <pre>
  459. typedef struct st_unif_chunk
  460. {
  461. unsigned long id;
  462. unsigned long length;
  463. void *data;
  464. } st_unif_chunk_t;
  465. </pre>
  466. <br>
  467. <b>Line length</b><br>
  468. The length of lines shouldn't be much longer than 90 characters. This
  469. doesn't necessarily include the length of comment. Longer lines should be
  470. broken into several shorter ones. Example:<br>
  471. <pre>
  472. static const int unif_prg_ids[] = {PRG0_ID, PRG1_ID, PRG2_ID, PRG3_ID,
  473. PRG4_ID, PRG5_ID, PRG6_ID, PRG7_ID,
  474. PRG8_ID, PRG9_ID, PRGA_ID, PRGB_ID,
  475. PRGC_ID, PRGD_ID, PRGE_ID, PRGF_ID};
  476. </pre>
  477. <br>
  478. <b>Comment</b><br>
  479. Single or two-line comments should use //. Comments that need more lines
  480. should use the pair /* and */. A two-line comment should signify that it is
  481. one two-line comment instead of two one-line comments by putting one extra
  482. space after the //. Single or two-line comments should start at column 49 if
  483. that's possible. Example:<br>
  484. <pre>
  485. char buf[SIZE_INFO], number[80]; // 4 should be enough, but don't
  486. // be too sensitive to errors
  487. </pre>
  488. Long comments should use the same indentation as the code that follows it:<br>
  489. <pre>
  490. if (deinterleave)
  491. /*
  492. This is a bit of a hack, i.e., putting the following code in this
  493. ...
  494. */
  495. {
  496. unsigned char *data;
  497. int size, n = 0, prg = 0, chr = 0;
  498. ...
  499. </pre>
  500. <br>
  501. <b>Preprocessor directives</b><br>
  502. Preprocessor directives should not be indented. This does not only apply to
  503. #include, but to all preprocessor directives.<br>
  504. For #if and #ifdef blocks that are complex or enclose many lines of code the
  505. corresponding #else, #elif or #endif should contain a comment that signifies
  506. to which #if or #ifdef it belongs. <a name="multiplatform">Example:</a><br>
  507. <pre>
  508. #ifdef __unix__ // wait 32 milliseconds
  509. usleep (32000);
  510. ...
  511. #elif defined __MSDOS__ // __unix__
  512. delay (32);
  513. ...
  514. #elif defined __BEOS__ // __MSDOS__
  515. snooze (32000);
  516. ...
  517. #endif // __BEOS__
  518. </pre>
  519. Standard system header files should be included by specifying the name of
  520. the header file between angle brackets. Non-standard header files should be
  521. included with the name between double quotes. Example:<br>
  522. <pre>
  523. #include &#60;stdio.h&#62;
  524. #ifdef __unix__
  525. #include &#60;unistd.h&#62;
  526. #endif
  527. #include "ucon64.h"
  528. </pre>
  529. <br>
  530. <b>Header files</b><br>
  531. Header files should be protected against being included multiple times by
  532. putting the entire file inside an #ifndef block. Define the constant for
  533. which the #ifndef checks inside the #ifndef block. For example, for the file
  534. swc.h:<br>
  535. <pre>
  536. #ifndef SWC_H
  537. #define SWC_H
  538. ...
  539. #endif // SWC_H
  540. </pre>
  541. Header files should only contain information about their corresponding
  542. source file that may be needed by other source files. They should not
  543. include information about variables or function definitions that are used
  544. only inside the source file.<br>
  545. <br>
  546. <b>Portability</b><br>
  547. Platform-specific function calls, variable types and #includes of header
  548. files should be put inside #ifdef or #if blocks. For an example see the
  549. <a href="#multiplatform">first code example</a> in the section Preprocessor
  550. directives.<br>
  551. <br>
  552. <p>
  553. <br>
  554. <br>
  555. <br>
  556. <br>
  557. <br>
  558. <br>
  559. <br>
  560. <br>
  561. <br>
  562. <br>
  563. <br>
  564. <br>
  565. <br>
  566. <br>
  567. <br>
  568. <br>
  569. <br>
  570. <br>
  571. <br>
  572. <br>
  573. <br>
  574. <br>
  575. <br>
  576. <br>
  577. <br>
  578. <br>
  579. <br>
  580. <br>
  581. <br>
  582. <br>
  583. <br>
  584. <br>
  585. <br>
  586. <br>
  587. <br>
  588. <br>
  589. <br>
  590. <br>
  591. <br>
  592. <br>
  593. <br>
  594. <br>
  595. <br></tt></body></html>