Super Mario Bros. is definitely the most famous videogame created yet, selling a scorching 40.23 million copies. http://en.wikipedia.org/wiki/List_of_best-selling_video_games

What programming language was it written in? Does anyone have some original code reference?

  • 7
    \$\begingroup\$ I get the feeling a lot of the old NES games were written in machine-specific assembly. \$\endgroup\$ – meager Dec 2 '10 at 15:40
  • 3
    \$\begingroup\$ possible duplicate of How were 8-bit and 16-bit games developed? \$\endgroup\$ – user744 Dec 2 '10 at 16:34
  • 7
    \$\begingroup\$ Not a duplicate, as this one asks for specific code samples from a specific game. \$\endgroup\$ – AttackingHobo Dec 2 '10 at 20:00
  • 5
    \$\begingroup\$ I don't see the value in having many "What language was X written in?" questions, no matter how notable X is, unless it was notable because of the development platform. Also, it's asking for specific code samples of a game still under copyright (and still being sold) with no intentional source availability. \$\endgroup\$ – user744 Dec 2 '10 at 22:11
  • 3
    \$\begingroup\$ @Toad: Yes, but you generally don't have the right to post it online, or to download a copy (even if you own the game yourself), or to make derivative works based off your own reading of the code. \$\endgroup\$ – user744 Dec 3 '10 at 9:51

6502 Assembly

Here is a forum page about hacking the ROM. http://forums.selectbutton.net/viewtopic.php?t=26956&sid=1a883209e1ba63877bcd58c007bb63ae

It should contain any code references you need as well.

A few posts down there is a link to a zip file that contains these items needed to edit/hack the game.

  • ca65 - a 6502 assembly compiler from https://www.cc65.org/
  • ld65 - a 6502 linker from https://www.cc65.org/
  • smbdis.asm - a comprehensive Super Mario Bros. disassembly
  • smb.chr - Super Mario Bros. graphics (Character ROM Data)
  • smb.hdr - Super Mario Bros. ROM header (iNES header)
  • MAKESMB.BAT - a batch file I made that automates the compilation process.
  • 6502jsm.doc - a summary of 6502 instructions.
  • 7
    \$\begingroup\$ Wow, perfect answer! Kudos \$\endgroup\$ – DFectuoso Dec 2 '10 at 19:00
  • 33
    \$\begingroup\$ I'm confused by this answer myself. You're basically pointing to an executable (the ROM) and claiming that it was written in assembly... because it was disassembled. It's an executable; of course it can be disassembled. By this logic, every C/C++ program ever written was actually written in assembly. To prove that this was written in assembly, you need to actually show that Nintendo wrote it in assembly, not that you can disassemble the executable binary. \$\endgroup\$ – Nicol Bolas Nov 22 '12 at 20:18

Almost all NES games were hand-written in 6502 assembly, the same as used in the Commodore 64, the Apple ][e, etc. The very few which were written in C had a reputation for being terribly slow because the NES is only 2Mhz and has 2Kb of onboard RAM (with an 8Kb window for the cartridge to patch more in). Careful assembly designed to take full advantage of the NES's peculiar architecture was much more effective.

Stop and think about that... games like Super Mario Bros 3 and Kirby's Adventure ran on 2Mhz. Compare how rich they are to today's games which swallow gigahertz and hundreds of megabytes of RAM...

  • 4
    \$\begingroup\$ @Lohoris I just logged in to up-vote that comment. And to my surprise, I already did \$\endgroup\$ – IluTov Nov 19 '13 at 15:43
  • 6
    \$\begingroup\$ What's an example of a licensed NES game that was written in C? \$\endgroup\$ – tgies May 19 '15 at 15:51
  • 1
    \$\begingroup\$ [citation needed] \$\endgroup\$ – Almo Jan 7 '16 at 15:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.