This repository serves as a template project for developing for 8-bit platforms supported by the LLVM-MOS project. It contains a CMake project ready to go, a .editorconfig
, some CMakePresets to get you started with the IDE you are using. This project is able to be targetted towards any supported platform by LLVM-MOS, such as, but not limited to: Nintendo NES, Commodore 64, Commander X16, Commodore VIC-20, and even a barebone 6502 simulator.
- Click the "Use this template" button above in the repository homepage to "fork" it. You can optionally just download it as a
.zip
. Either way, get this repository on your PC somewhere. - Install LLVM-MOS-SDK as given in the instructions. Note that if you had already installed the original LLVM toolchain, skip the "Add LLVM-MOS to PATH " to not come across any name-conflict issues.
- Note where you've downloaded/extracted the sdk, such as
/opt/llvm-mos
. You will need it for the next step. - In your repo, copy
CMakeUserPresets.json.template
asCMakeUserPresets.json
:
cp CMakeUserPresets.json.template CMakeUserPresets.json
- Edit the new file
CMakeUserPresets.json
(note the User part in the file name) and replace the"LLVM_MOS": "/opt/llvm-mos"
lines with the path ofllvm-mos
. Note that this is present for each preset, so you will need to change all occurrences. - (Optional) Edit the
CMakeUserPresets.json
as you wish by adding more target presets, environment variables, options, etc. as per your project. You can use the "inherits" and "hidden" properties to reduce repetition.
This project uses CMake so you will need to install that first, if you don't have it already. You can either build the project using the IDE you're using (such as VSCode or code-server), in which case you will have to set it up to integrate CMake, and follow the instructions accordingly. Or you can do it via command line like so:
- Configure project (creates build scripts, etc.)
# Create a build directory to store all the scripts and build artifacts.
mkdir build
cd build
# Configure the project from within the build folder. Using the llvm-mos-cx16-Debug preset for example.
cmake --preset llvm-mos-cx16-Debug ..
- Build the project to produce both a
.elf
file and the program ROM PRG file (without extension)
# While still within the build directory
cmake --build .