IoanThomas / constexpr-chip8

A compile-time CHIP-8 emulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

constexpr-chip8

A compile-time CHIP-8 emulator.

The emulator makes extensive use of the C++ keyword constexpr meaning that most opcodes can be evaluated at compile-time assuming the CHIP-8 code to be run is available then. Instructions that cannot be evaluated at compile-time, such as key input, can be executed at runtime, however.

My emulator running PONG2

Inspiration

This project was inspired by Jason Turner's ARM emulator, which through good C++ practices and heavy use of constexpr could be made to execute code at compile-time. The CppCon talk he did on it can be found here which highlights just some of the great things you can do with modern C++. I was especially interested in the testing part of it - which he notes could also be done at compile-time, meaning that if the tests simply compile then they have already succeeded.

Getting Started

Prerequisites

The code requires C++17 or later to compile, and CMake is used for building project files. In order to support C++17, a CMake version of 3.9 or later is required.

All dependencies required are downloaded using Git submodules during project generation, so other than Git no other programs are required to be installed.

Building

In the project directory, run the following commands:

mkdir build
cd build
cmake ..

This will generate project files in the build folder.

Testing

Since the entire emulator can run at compile-time, simply compiling the tests successfully should indicate that they pass. To do this, run the following command from the project directory:

cmake --build build --target tests

The executable file will be generated in the build folder if you want to run the tests directly.

Tools and Libraries

  • CMake - Cross-platform build system
  • SFML - Simple cross-platform multimedia library
  • Catch2 - Test framework for C++

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A compile-time CHIP-8 emulator

License:MIT License


Languages

Language:C++ 95.2%Language:CMake 4.8%