<story><title>How to program an NES game in C</title><url>https://nesdoug.com</url></story><parent_chain><item><author>userbinator</author><text>IMHO a 6502 is too limited to be effectively programmed in C; even this part of the article gives all the limitations: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;nesdoug.com&amp;#x2F;2015&amp;#x2F;11&amp;#x2F;15&amp;#x2F;2-how-cc65-works&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;nesdoug.com&amp;#x2F;2015&amp;#x2F;11&amp;#x2F;15&amp;#x2F;2-how-cc65-works&amp;#x2F;&lt;/a&gt;&lt;p&gt;With this important note: &amp;quot;clean unaltered C code will compile into very slow code that takes up too much of the limited memory space.&amp;quot;&lt;p&gt;In other words, &amp;quot;C&amp;quot; written for such a CPU will be in a vastly different style from more &amp;quot;normal&amp;quot; C, so that it might be better to just use Asm.&lt;p&gt;Then again, 8051s, PICs, and other extremely constrained MCUs have been targeted by &amp;quot;C&amp;quot; (subsets), so it&amp;#x27;s definitely possible if a bit awkward. Personally, I think something like an 8080 would be the minimum to do relatively comfortable C programming in, with a Z80 being far more preferable.</text></item></parent_chain><comment><author>greggman</author><text>Does c65 turn structs into parallel arrays?&lt;p&gt;If you have something like&lt;p&gt;&lt;pre&gt;&lt;code&gt;    struct Monster {
      unsigned char hitPoints;
      unsigned char damage;
      unsigned char shieldLevel;
      char* name;
    };
    static Monster s_monsters[] = {
      { 5,   1, 0, &amp;quot;orc&amp;quot;, },
      { 50, 10, 5, &amp;quot;dragon&amp;quot;, },
      { 10,  3, 1, &amp;quot;goblin&amp;quot;, },
    };
&lt;/code&gt;&lt;/pre&gt;
that&amp;#x27;s a no-no on 6502. You generally need to store those in parallel byte arrays including the string pointer&amp;#x27;s upper and lower bytes each in separate arrays. That was usually done with assembler macros or compile time tools but it was important not to have to generate addresses that have to manually assembled in 6502. Similarly there&amp;#x27;s no multiply so math like sizeof(Monster) * index.</text></comment>
<story><title>How to program an NES game in C</title><url>https://nesdoug.com</url></story><parent_chain><item><author>userbinator</author><text>IMHO a 6502 is too limited to be effectively programmed in C; even this part of the article gives all the limitations: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;nesdoug.com&amp;#x2F;2015&amp;#x2F;11&amp;#x2F;15&amp;#x2F;2-how-cc65-works&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;nesdoug.com&amp;#x2F;2015&amp;#x2F;11&amp;#x2F;15&amp;#x2F;2-how-cc65-works&amp;#x2F;&lt;/a&gt;&lt;p&gt;With this important note: &amp;quot;clean unaltered C code will compile into very slow code that takes up too much of the limited memory space.&amp;quot;&lt;p&gt;In other words, &amp;quot;C&amp;quot; written for such a CPU will be in a vastly different style from more &amp;quot;normal&amp;quot; C, so that it might be better to just use Asm.&lt;p&gt;Then again, 8051s, PICs, and other extremely constrained MCUs have been targeted by &amp;quot;C&amp;quot; (subsets), so it&amp;#x27;s definitely possible if a bit awkward. Personally, I think something like an 8080 would be the minimum to do relatively comfortable C programming in, with a Z80 being far more preferable.</text></item></parent_chain><comment><author>simias</author><text>I feel like handling ROM banking would be the most challenging part of coding in C. You have to swap portions of your program in and out constantly (unless you manage to fit it all in a single bank). It seems hard to abstract that efficiently from a high level language.&lt;p&gt;I heard there were C compilers for the Game Boy as well but as far I know they were never widely used.</text></comment>