/6502

Emulation of the 6502 CPU in C++. Written as a (T/B)DD practice environment

Primary LanguageC++MIT LicenseMIT

6502 Emulation

Platform

Language Code Style

Language Code Style

Language Code Style

Prerequisites

  • Cmake. Must be 3.20 or higher. Normally just get the latest version
  • Node. Should be 14.x, with npm 6.14.x

Project layout and format

This is an example C++ project. The aim of this repository is to give you a basic skeleton for any project you might want to build that uses C++. It includes all the key parts to build a basic project across both macos and windows.

Directory structure

.cmake

  • This is where all the cmake files are defined. This repository includes a lot of utility cmake files, that will let you very simply get started with using cmake.
    We break our project layouts up in to a few types of cmake targets:
    • static libraries are considered the lowest levels. You can declare these using make_library, and then specify the source files you want. Look at CMakeLists.txt in the root for an example. We encourage you to make liberal use of these libraries, to break your code down in to modular sections.
    • tests are next up. Each static library can have an associated test - use make_test which will run an arbitrary executable and link in catch2. Note that the name of each test will be automatically constructed for consistency, and is the form test-${NAME}. By convention, we pass the same name to both make_test and make_library, then you will have libX.lib and test-libX.lib. Note that libX is automatically added to the dependency list, and is not required to be defined.
    • mocks are also available. A mock is a static library that provides a simple way for users of your static lib to get a mocked version of your code for their tests. Use make_mock to make one of these.
  • It is definately worth reading through the cmake files, to understand all the functionality that is available. Especially pay attention to the settings in global_options.cmake .documentation
  • Documentation for the project is defined in here, in MD format. Mostly these files are linked to from this readme. .scripts
  • This directory contains all the build scripts for the project. Most of this will be called from the npm package scripts. Run npm run help to get information on most of these scripts. .utilities
  • Utility build function are in this location. Currently, just the time-trace functions are here to let you time your builds and understand what times the time. See this repo for more info

Additional files

In the directory root you will find a bunch of files:

  • .clang-format
    • The main C++ formatting style is set here
  • .cmake-format
    • Formatting for the cmake files are defined here
  • .prettierrc.json
    • Formatting for the js files are defined here
  • CMakeLists.txt
    • Core cmake list for the project
  • package(-lock).json
    • Node package file to define dependencies and setup
  • .babelrc, .eslintrc.json, tsconfig.json
    • These files are for setting up our js configuration

TL;DR quick start

  1. Install node
  2. Install cmake
  3. Run npm install once to install all dependancies.
  4. npm run generate
  5. npm run build

Building

You can build on the command line, or using an IDE (We support XCode, CLion and VS2019 currently). See here for how to build

Code formatting

We use a variety of code formatting tools. Please make sure you have these installed on your system to keep the codebase styling consistent.

Code caching

We have code caching available to speed up builds. Learn more

Scripts

We have a variety of scripts available in our package.json. Learn more