Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SOHNE/CameBoy

Repository files navigation

CameBoy Logo

CameBoy

License CI Build Tests

✨ Learning by doing: Exploring the fundamentals of emulation with a minimalist Game Boy™ project. 🎮

📑 Introduction

CameBoy—a raw dive into retro computing. This Game Boy™ emulator, built in C99, isn't about bells or whistles. It's a hands-on experiment pieced together from a patchwork of online insights, designed to reveal the bare mechanics behind this classic handheld. Here, every line of code tries to be a lesson in minimalism, without unnecessary clutter.

Important

This project is built purely for learning and experimenting. We aren’t connected to Nintendo® in any way. Also, this repository doesn’t include any illegal BIOS nor ROMs, nor do we support using them—the end user are responsible for making sure to use legally obtained softwares.

📸 Screenshots
Instruction timing
instr_timing.gb 🟥
Memory timing
mem_timing.gb 🟨
CPU isntructions
cpu_instrs.gb 🟩
BGB test
bgbtest.gb 🟩

♻️ Building & Using

📦 Prerequisites

  • C99 Compiler (GCC 9+/Clang 12+)
  • CMake (3.26+)
  • SDL2 (2.32.0+ for frontend)
  • SDL2_ttf (2.24.0+ for frontend)
  • ROM file (Game Boy .gb format)

Note

External dependencies (SDL2, SDL2_ttf, ccache) can be managed by CPM.cmake. See /CameBoy/CMakeLists.txt file.

🔧 Building from Source

# Clone repository
git clone https://github.com/SOHNE/CameBoy.git
cd CameBoy

# Configure build (default Release mode)
mkdir build && cd build
cmake ../CameBoy -DCMAKE_BUILD_TYPE=Release

# Compile
cmake --build . --config Release

# Optional: Enable debug features
cmake .. -DCC_DEBUG=ON -DUSE_SANITIZERS=ON

🚀 Basic Usage

CameBoy --help
Usage: CameBoy [options]

A Game Boy™ emulator using CameCore and SDL2.

    -h, --help                show this help message and exit
    -d, --debug               Enable debug logging
    -c, --cartridge=<str>     Path to the cartridge file

Example: CameBoy --debug --cartridge /path/to/legal_rom.gb

📐 Architecture

Warning

Needs to improve and correct this Architecture Overview.

┌───────────────────────────────────────┐        ┌──────────────────────────────┐
│               CameCore                │        │           CameBoy            │
│         (Game Boy Core Library)       │        │    (Standalone Frontend)     │
├───────────────┬───────────────────────┤        ├───────────────┬──────────────┤
│      Core     │         Utils         │        │  Application  │    SDL2      │
│ (Emu Context) │      (Logging/IO)     │◀──────┤     Loop      │ (Rendering/  │
├───────────────┴───┬───────────────────┤        │               │   Input)     │
│      CPU          │        Bus        │        └───────┬───────┴───────┬──────┘
│  ┌───────┐        │    (Memory        │                │               │
│  │Fetch  ├──────▶│     Mapper)       │                └───────┬───────┘
│  │Decode │        ├────────┬──────────┤                        │
│  │Execute│        │  Cart  │   PPU    │                ┌───────▼───────┐
│  └───────┘        │        │          │                │   Platform    │
│ (SM83 Emulation)  │        │          │                │  Integration  │
│                   │        │          │                └───────────────┘
└───────────────────┴────────┴──────────┘
                                                         ┌───────────────────────┐
                                                         │  Future Improvements  │
                                                         │  (Planned Components) │
                                                         ├────────────┬──────────┤
                                                         │    APU     │  Timer   │
                                                         │  (Audio    │ (System  │
                                                         │   System)  │  Timing) │
                                                         └────────────┴──────────┘
Key Components:
CameCore Library:
- Core: Emulator state management (Init/Step/Run)
- CPU: Full SM83 implementation with instruction pipeline
- Bus: Memory bus controller with proper banking
- Cart: ROM loading/validation with MBC support
- Utils: Logging system and file I/O operations

CameBoy Standalone:
- Application Loop: Ties core emulation to platform
- SDL Integration: Handles video output and input
- Platform Layer: Build system and dependency management

Data Flow:
Cartridge → Cart → Bus ↔ CPU ↔ Core
                     │
SDL Events ← Bus ↔ Core → SDL Rendering

Memory Map Implementation:
0000-FFFF Address Space
├─ ROM Banks      (Cart)
├─ VRAM           (Bus)
├─ WRAM           (Bus)
├─ OAM            (Bus)
└─ I/O Registers  (Bus)

Instruction Pipeline:
PC → Fetch → Decode → Execute → Cycle Counting
        ▲        │         │
        └────────┴─────────┘ (Flags/Reg Updates)

🌱 Contributing

The CONTRIBUTING guidelines should help in getting you started on how to contribute to this project.

🙏 Acknowledgments & Resources

A sincere thank you to the individuals, communities, and resources that brought this project to life:

This project stands on the shoulders of the passionate gbdev.io community – thank you for preserving and sharing Game Boy knowledge for future generations.

⚖️ License

CameCore and CameBoy are licensed under zlib/libpng license, an OSI-certified and BSD-like license. Check LICENSE for details.

readme versionreadme version

About

An ultra simple (and incomplete) Game Boy™ emulator

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •