Исходный код игры марио
Learn more about clone URLs
Mario - 01. Исходный код игры Марио (форматирование моё).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- © 2021 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Learn more about clone URLs
Mario - 00. Исходный код игры Марио (форматирование как было у настоящего автора).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- © 2021 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
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.
looks and plays just like the original
Dependencies
From the root of the repo, execute:
This should create the executable smbc in the build directory.
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 .
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 :
The following is a list of all configurable options:
- Allows audio to be enabled (if set to 1) or disabled (if set to 0).
- Default: 1
- Controls the frequency of sampled audio output, in Hz.
- Default: 48000
- The desired frame rate, in frames per second. Note that on some systems it may be necessary to disable vsync (see video.vsync) in order to achieve a frame rate higher than 60 fps.
- Default: 60
- The path to the Super Mario Bros. ROM file. Can be either relative to the working directory or absolute.
- Default: "Super Mario Bros. (JU) (PRG0) [!].nes"
- Controls the scale factor for rendered video.
- Default: 3
- Allows rendering scanlines to be enabled (if set to 1) or disabled (if set to 0)
- Default: 1
- Allows vsync to be enabled (if set to 1) or disabled (if set to 0).
- Default: 1
The game consists of a few parts:
- The decompiled original Super Mario Bros. source code in C++
- An emulation layer, consisting of
- Core NES CPU functionality (RAM, CPU registers, call stack, and emulation of unique 6502 instructions that don't have C++ equivalents)
- Picture Processing Unit (PPU) emulation (for video)
- Audio Processing Unit (APU) emulation (for sound/music)
- Controller emulation
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!
Читайте также: