# emulator A simple emulator built in C++17 using SDL2 for video/audio. It loads a ROM file from disk, maps it into memory, and runs a fetch/decode/execute loop rendered to an SDL window. ## Prerequisites - **C++17 compiler** — MSVC (Visual Studio 2019 or 2022 Build Tools) on Windows. The project is currently configured for the MSVC toolchain. - **CMake** 3.21 or newer (required for the CMake Presets feature). - **Ninja** — used as the build generator. - **vcpkg** — dependencies are declared in `vcpkg.json` (manifest mode), so vcpkg fetches them automatically on first configure. A working vcpkg installation must be available on the system. - **Git** — for cloning and for vcpkg to fetch package sources. ## Project layout ``` . ├── CMakeLists.txt # build definition ├── CMakePresets.json # configure/build presets (vcpkg + MSVC + Ninja) ├── vcpkg.json # dependency manifest (sdl2, sdl2-image) ├── .vscode/ # editor / IntelliSense config ├── src/ │ ├── main.cpp # entry point: parses argv, runs the emulator │ ├── emulator.hpp # Emulator class declaration │ └── emulator.cpp # Emulator class implementation └── build/ # generated after configure (gitignored) ``` ## Installation 1. **Clone the repository** ```sh git clone emulator cd emulator ``` 2. **Ensure vcpkg is installed** If you do not already have vcpkg, clone and bootstrap it: ```sh git clone https://github.com/microsoft/vcpkg.git cd vcpkg .\bootstrap-vcpkg.bat ``` Note its root path — you will reference it in the next step. 3. **Point CMake at the vcpkg toolchain** `CMakePresets.json` sets `CMAKE_TOOLCHAIN_FILE` to: ``` C:/Program Files (x86)/Microsoft Visual Studio/18/BuildTools/VC/vcpkg/scripts/buildsystems/vcpkg.cmake ``` If your vcpkg lives elsewhere, edit the `default` configure preset (or create a `CMakeUserPresets.json` next to `CMakePresets.json`) so the `CMAKE_TOOLCHAIN_FILE` value matches your vcpkg install. ## Setup & build Configure and build with the bundled preset (uses vcpkg manifest mode, so `sdl2` and `sdl2-image` are installed automatically on first configure): ```sh cmake --preset default cmake --build --preset default ``` The resulting executable is placed in `build/` (e.g. `build/emulator.exe`). ## Running Pass a ROM file as the only argument: ```sh .\build\emulator.exe ``` Press **Esc** or close the window to quit. ## Editor / IntelliSense VS Code IntelliSense is configured in `.vscode/c_cpp_properties.json` to read `build/compile_commands.json` (generated by the `default` preset). Configure the project once with `cmake --preset default` so the compile database exists; IntelliSense will then resolve `SDL.h` and the project headers correctly.