RepositoryCGBUnited Kingdom
Clownacy

Clownacy/clownmdemu-core

Sega Mega Drive/Sega Genesis emulator that emphasises portability.

139stars
17forks
23issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: 68000

#1 Repository of the week

1
TINIX TRENDING·Topic: sega-mega-drive

#1 Repository of the week

1
TINIX TRENDING·Topic: genesis

#1 Repository of the week

Overview

This is ClownMDEmu, a Sega Mega Drive (a.k.a. Sega Genesis) emulator.

Some standard features of the Mega Drive are currently unemulated (see TODO.md for more information).

This repository contains ClownMDEmu's emulation core. It is intended to be self-contained and highly-portable.

Frontends

To actually run software with ClownMDEmu, a frontend is needed. Currently there are two official frontends:

Design

The emulation core's code adheres to the following principles, emphasising minimalism and portability:

  • Use C89. This is required in order to support as many compilers as possible. Ideally, the code should be valid C++ as well, in order to support both C and C++ compilers.

  • Use integer-only logic. The Sega Mega Drive/Sega Genesis had no support for floating point types. Therefore, emulating it should not require floating point types. Additionally, floating point types are prone to rounding error and other precision issues, so I do not trust them. I am also concerned about their performance compared to integers, especially on lower-end hardware.

    • There is one exception to this rule: functions relating to generating 'constant' data. The reasoning for this is that platforms with poor floating-point support can have this data be computed at build-time and embedded into the executable.
  • Do not use dynamic memory. Memory allocation is slow, will cause memory leaks when not correctly freed, and can cause software to fail mid-execution when memory is exhausted, which is more effort to account for than it is worth.

  • Use no global state. All state should be kept in a struct which functions access through a pointer, allowing for such things as simple fast save-state support as well as the possibility of running multiple instances of the emulator at once. Note that the state must not contain pointers, so that it is relocatable and position-independent. Likewise, the state must not depend on outside state, so that it is useable across multiple executions of the emulator.

  • Operate within the guarantees of the C standard: no undefined behaviour and no implementation-defined behaviour.

    • Do not depend on integer type sizes. 'char', 'short', 'int', and 'long' may be different sizes on different platforms, so do not rely on their ability to hold (or not hold) values larger than their standard capacities:

      • -127 to 127 for 'signed char'.
      • 0 to 255 for 'unsigned char'.
      • -32767 to 32767 for 'short' and 'int'.
      • 0 to 65535 for 'unsigned short' and 'unsigned int'.
      • -2147483647 to 2147483647 for 'long'.
      • 0 to 4294967295 for 'unsigned long'.
    • Do not assume that 'char' is always signed by default; it is not. For instance, it is unsigned by default on ARM CPUs.

    • Do not rely on C language extensions.

    • Do not rely on endianness. Code should work correctly on both little-endian and big-endian CPUs.

    • Do not rely on signed number representation. That is to say, do not assume that negative numbers are represented in binary as two's complement.

  • Use original code. No emulation components should be taken from other emulators or libraries. For example, rather than use something like Musashi, the 68000 emulation core is custom. Likewise, a custom YM2612 emulation core is used instead of Nuked-OPN2.

The emulation core is implemented as a library, with all platform-specific logic being relegated to a separate frontend program.

ClownMDEmu attempts to balance correctness with performance, acting as a more high-level emulator than accuracy-focussed alternatives may.

The core exposes a relatively low-level interface: audio from the FM and PSG are output separately at their native sample rates, and video is output a single scanline at a time in its native indexed format. This is to give the frontend the most flexibility in how it can process the data for delivery to the user. For instance, if the platform can play multiple separate audio streams at once, then the frontend can skip the expensive steps of audio resampling and mixing.

Compiling

ClownMDEmu can be built using CMake, however it should not be hard to make the core use a different build system if necessary as its build process is not complicated.

Be aware that this repo uses Git submodules; use git submodule update --init to pull in these submodules before compiling.

Licence

ClownMDEmu is free software, licensed under the AGPLv3 (or any later version). See LICENCE.txt for more information.

Similar Projects

Discover other similar projects and AI models.

RepositoryRust
transistorfet/moa

An emulator for various m68k and z80 based computers, written in Rust. Currently it has support for the Sega Genesis, TRS-80, and Computie (my own project), with Macintosh support in the works

65
Aug 14, 2026
RepositoryC
nukeykt/Nuked-MD

Cycle accurate Mega Drive emulator

190
Aug 20, 2026
RepositoryC
transistorfet/computie

A collection of 68k computer projects, including a unix-like operating system written in C that runs on them

69
Feb 24, 2025
RepositoryAssembly
TheBlad768/Sonic-Clean-Engine-S.C.E.-

Cleaned up the Sonic 3 & Knuckles Disassembly (S.C.E.)

62
Nov 30, 2026
RepositoryC
ArtemioUrbina/240pTestSuite

A homebrew software suite for video game consoles developed to help in the evaluation of upscalers, upscan converters, line doublers and of course TV processing of 240p video. The Wii and Dreamcast versions have modes for 480i and 480p evaluation as well.

374
Nov 25, 2026
RepositoryC
philpem/freebee

FreeBee - AT&T 3B1 / 7300 UNIX PC emulator

148
Jul 30, 2026
RepositoryC
tomstorey/m68k_bare_metal

This repository contains my efforts to create an "idiot proof bare metal m68k cross compiler toolchain of sorts."

58
Jun 25, 2026
RepositoryC++
SukkoPera/MegaDrivePlusPlus

Universal Region mod, 50/60 Hz switch and In-Game-Reset (IGR) for Sega Mega Drive (AKA Genesis)

141
Mar 2, 2024
RepositoryC++
Clownacy/clownassembler

Motorola 68000 assembler, clone of SN 68k (A.K.A. asm68k).

91
Nov 6, 2026