73

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?

Luca Matteis
  • 863
  • 1
  • 7
  • 5
  • 7
    I get the feeling a lot of the old NES games were written in machine-specific assembly. – user229044 Dec 02 '10 at 15:40
  • 3
  • 7
    Not a duplicate, as this one asks for specific code samples from a specific game. – AttackingHobo Dec 02 '10 at 20:00
  • 5
    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. –  Dec 02 '10 at 22:11
  • 1
    @joe wreschnig: as far as i know one has every right to disassemble a bought game. Just as having the right to break your ferrari down to every last bolt. I think this whole process of figuring the code out might be very educational. – Toad Dec 03 '10 at 06:40
  • 3
    @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. –  Dec 03 '10 at 09:51
  • 1
    @Toad: disassemble it as you wish, but this doesn't mean you have the original code, only a disassembled version of the compiled code. – o0'. Dec 03 '10 at 13:46
  • @lo'oris: In this case, probably it was created in assembly anyway. So the dissasembled code and the original macro assembler should not be that off. – Toad Dec 03 '10 at 15:50
  • Voting to close, as questions about what technology a particular game used are now off topic. – doppelgreener Nov 22 '12 at 05:46
  • @user744: you are assuming that "the game" sources hasn't been released. While it might be true in one specific instance (this), it would still be a valid question. Open source games exist, so asking about the sources of a specific game makes sense. The answer might be "it's closed source". – o0'. Nov 19 '13 at 15:52
  • 1
    "definitely the most famous" [citation needed] – Almo Jan 07 '16 at 15:05

2 Answers2

84

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.
AttackingHobo
  • 7,091
  • 4
  • 36
  • 48
  • 37
    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. – Nicol Bolas Nov 22 '12 at 20:18
56

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...

abadidea
  • 569
  • 3
  • 2