CEN64 JG
--------
CEN64 JG is a cycle accurate N64 emulator with support for the 64DD.

This is a fork of CEN64 which aims to continue the original project's goals,
with more focus on portability and reusability. The end goal is to have an N64
emulator with top-tier accuracy that runs on average hardware.

Major changes made post-fork:
 - Audio resampled to a stable output rate at all times
 - RSP entirely rewritten in portable C
 - New high accuracy RDP based on MAME
 - Significant performance increases without loss of accuracy
 - Accurate rumble timing and strength
 - General accuracy improvements
 - Improved 64DD support
 - Removal of unnecessary code

This repository lives at https://gitlab.com/jgemu/cen64

Compiling
---------
Make sure you have The Jolly Good API's header files installed. If you did
not install them, you will be required to include their path in CFLAGS.

WARNING: You should definitely build this with LTO. You should also use clang
over gcc if possible. Follow these instructions or suffer slowness. Example:
  make CC=clang CFLAGS="-O2 -flto" LDFLAGS="-flto"

Options:
  DISABLE_MODULE - Set to a non-zero value to disable building the module.
  ENABLE_STATIC_JG - Set to a non-zero value to build a static JG archive.
  USE_VENDORED_SPEEXDSP - Set to a non-zero value to use vendored SpeexDSP.

Core Options:
  ENABLE_DEBUG_MMIO_REGISTER_ACCESS -
    Set to a non-zero value to enable printing messages on each MMIO
    register access.

  ENABLE_DEVPROF -
    Set to a non-zero value to print device profiler output to stdout.

Linux:
  make

macOS:
  make

BSD:
  gmake

Windows (MSYS2):
  make

Cross Compile:
(For example compiling on Linux for MinGW)
  AR=x86_64-w64-mingw32-ar \
  CC=x86_64-w64-mingw32-cc \
  PKG_CONFIG=x86_64-w64-mingw32-pkg-config \
  STRIP=x86_64-w64-mingw32-strip \
  make

The build will be output to "cen64/". This directory may be used as is
locally by copying it to your local "cores" directory, or may be installed
system-wide using the "install" target specified in the Makefile.

Settings
--------
pak1 = 0
pak2 = 0
pak3 = 0
pak4 = 0
0 = Auto, 1 = None, 2 = Memory, 3 = Rumble

vi_filters = 1
0 = Off, 1 = On

stick_deadzone = 5
N = Deadzone Size

stick_scaling = 0
0 = Simple, 1 = OEM, 2 = Horipad Mini

threading = 1
0 = Off, 1 = On

Accuracy/Caveats
----------------
Since this emulator is still under heavy development, the state format may
break at any time without warning. Do not rely on save states until the
emulator has reached maturity. This is unlikely to happen while there are
outstanding unimplemented edge case behaviours.

CEN64 was famous for not running at full speed on any existing computer. Since
the mid 2020s, and with some serious refactoring, it is now possible on many
mid range to high end computers. Accuracy has not been compromised, in fact it
has increased significantly thanks to newly available research. That being said,
there are some caveats.

 - Threaded mode is on by default. This processes CPU and RCP operations in
   batches, which is theoretically less accurate than single threaded mode,
   which processes everything in sync, cycle by cycle. On ultra high end
   computers, it is possible to run many games at full speed single threaded.

 - N64 emulation, on a general level, is still not up to par with emulation of
   other popular consoles. The hardware is extremely complex and emulating it
   accurately is very demanding. Further research needs to be done before some
   timing edge cases (even ones visible in popular games) can be fixed
   correctly.

 - The RDP is an extremely accurate renderer with MAME heritage. The version
   used in CEN64 JG is based on the sources extracted from MAME into ares, then
   converted to ISO C11, with behaviour backported from ParaLLEl, and
   cross-referenced against the documentation at the n64brew wiki. Later, this
   RDP diverged from the MAME/ParaLLEl heritage to match hardware-adjudicated
   tests. New research was also performed using custom tests on a SummerCart64
   and original N64 hardware.

Contributing
------------
Any contributions should respect the coding style and the direction and goals
of this emulator. All code should be placed under a permissive license (BSD,
MIT, etc). Changes made for portability or speed should be as generic as
possible, and any preprocessor directives for platform-specific code should be
avoided at all costs in the interest of keeping the emulator core clean,
maintainable, and free of regressions.

CEN64 JG is not trying to be everything to everyone. The project takes the
position that no SIMD intrinsics shall be used, no dynamic recompilers shall
be used, and no hardware-accelerated video upscaling shall be used. This
emulator is meant to be a behavioural reference, and great effort has been made
to maintain a simple and portable codebase that does not require constant
maintenance. There are other great N64 emulators available if you are looking
for hacks and enhancements. It would be wiser to backport behaviour from this
emulator into another one than to try to shoehorn dynarecs and upscalers into
this one.

Copyright
---------
CEN64 (BSD-3-Clause)
  Copyright (c) 2015 Tyler J. Stachecki
  Copyright (c) 2016 Mike Ryan, Jason Benaim
  Copyright (c) 2025-2026 Rupert Carmichael
  See LICENSE

CEN64 RDP (BSD-3-Clause)
  Copyright (c) 2011-2023 Ville Linde, Ryan Holtz, Vas Crabb, Aaron Giles
  Copyright (c) 2026 Rupert Carmichael
  See src/rdp/*

CIC-NUS-6105 challenge/response algorithm (BSD-2-Clause)
  Copyright 2011 X-Scale
  See src/si/cic6105.*

haxpatch (BSD-3-Clause)
  Copyright (c) 2026 Rupert Carmichael
  See deps/haxpatch/LICENSE

Extra Credits
-------------
This emulator could not have reached the level of accuracy and quality it has
without the documentation available at the n64brew wiki. Test ROMs written by
Rasky, HailToDodongo, Lemmy, and krom were also used to verify that hardware
behaviour and emulator behaviour align as much as possible. Some obscure
behaviours were referenced against ares. This project is not a testament to any
one person's programming or reverse engineering ability, and simply represents
the accumulated knowledge of the entire N64 emulation and homebrew communities.
A special thanks also goes out to everyone involved in libdragon development,
without which, the custom test ROMs used in development would have been much
more difficult to write.
