MitchellSternke / SuperMarioBros-C

An attempt to translate the original Super Mario Bros. for the NES to readable C/C++
625 stars 70 forks source link

SuperMarioBros-C

An attempt to translate the original Super Mario Bros. for the NES to readable C/C++.

I've taken the smbdis.asm disassembly of Super Mario Bros. and successfully converted it to C++ using an automated codegen program I wrote (which you can be found in the codegen/ subdirectory of the repo). Right now, it looks very similar to the original disassembly and is fairly dense code, but it works! Check out source/SMB/SMB.cpp if you're curious.

Many thanks to doppelganger (doppelheathen@gmail.com), who wrote the original comprehensive Super Mario Bros. disassembly. This can be found in the docs/ folder of the repo.

Demo gif

looks and plays just like the original

Building

Dependencies

From the root of the repo, execute:

mkdir build
cd build
cmake ..
make

This should create the executable smbc in the build directory.

Running

This requires an unmodified copy of the Super Mario Bros. (JU) (PRG0) [!].nes ROM to run. Without this, the game won't have any graphics, since the CHR data is used for rendering. By default, the program will look for this file in the current working directory, but this can also be configured in smbc.conf.

Configuration

Optionally, the program can be configured with a file named smbc.conf in the working directory. This file has an INI format. For example, the following would configure the option audio.frequency to be 22050:

[audio]
frequency = 22050

The following is a list of all configurable options:

[audio] options

enabled

frequency

[game] options

frame_rate

rom_file

[video] options

palette_file

scale

scanlines

vsync

Architecture

The game consists of a few parts:

Essentially, the game is a statically recompiled version of Super Mario Bros. for modern platforms. The only part of the NES that doesn't have to be emulated is the CPU, since most instructions are now native C++ code.

The plan is to eventually ditch all of the emulation layer and convert code that relies upon it. Once that's done, this will be a true cross-platform version of Super Mario Bros. which behaves identically to the original. It could then be easily modified and extended with new features!

License

TODO