BizHawk Documentation

repository·master·Indexed 22 days ago

https://github.com/tasemulators/bizhawk

A multi-system emulator designed for high-precision emulation and Tool-Assisted Speedruns (TAS). It features EmuHawk, a C#-based emulator providing advanced debugging, recording, and playback tools. BizHawk supports a wide array of platforms including Windows, Linux, and NixOS, and emulates systems ranging from Atari and Nintendo to Sega, Sony PlayStation, and various arcade machines. The project includes specialized components such as iso-parser for ISO9660 images, LibBizHash for CRC32 and SHA1 hashing, and chd-capi for CHD file format support.

Tokens
13.7K
Snippets
25
Records
92
Agent score
83%

What's inside BizHawk

  1. Overview of iso-parser

    master

    iso-parser is a C# library designed for parsing ISO9660 format disk images. It allows for navigating the file system within an image to determine the sector offset and length of file data, enabling easy reading of file data directly from the disk image.

    Limitations:

    • Does not support ISO extensions such as Joliet.
    • Does not support other image formats like UDF.
  2. Overview of BizHawk and EmuHawk

    master

    BizHawk is an emulation project featuring EmuHawk, a multi-system emulator written in C#. It is designed for both casual players and Tool-Assisted Speedrunners (TASers), providing advanced debugging, recording, and playback tools.

    Key features common across all cores include:

    • Format, region, and integrity detection for game images.
    • 10 save slots with hotkeys and infinite named savestates.
    • Speed control, including frame stepping and rewinding.
    • Memory view, search, and edit capabilities for all emulated hardware components.
    • Input recording for creating TAS movies.
    • Screenshotting and audio/video recording to file.
    • Firmware management.
    • HUD overlays for input, framerate, and more.
    • Rebindable hotkeys (keyboard, mouse, and gamepad).
    • Comprehensive input mapper for gamepads and peripherals.
    • Programmatic control over the core and frontend using Lua or C#.NET.
  3. Overview of CPCHawk (Amstrad CPC Core)

    master

    CPCHawk is the Amstrad CPC emulation core for BizHawk. As of late 2024, development is active with a focus on improving hardware accuracy through gate array and CRTC re-writes.

    Currently Supported Features

    • Models: CPC464, CPC6128 (default)
    • Hardware Emulation:
      • Port IO decoding
      • i8255 Programmable Peripheral Interface (PPI) chip
      • AY-3-8912 PSG (and Port IO)
      • Keyboard/Joystick
      • FDC and FDD devices
    • File Support:
      • .DSK image parsing and identification (includes automatic differentiation from ZX Spectrum disk bootloaders)
  4. Overview of blip_buf waveform synthesis library

    master

    blip_buf is a C library designed for waveform synthesis in classic video game sound chip emulation. It simplifies emulation by handling resampling details via a Band-Limited Step (BLEP) algorithm.

    Key features:

    • Simplifies sound chip emulation by managing input clock rates and output sample rates.
    • Allows adding waveforms by specifying clock times where amplitude changes.
    • Provides high-quality, fast, band-limited resampling.
    • Output is low-pass and high-pass filtered and clamped to a 16-bit range.
    • Supports mono, stereo, and multi-channel synthesis.
    • Provides a simple C interface.
  5. CPCHawk Roadmap and Known Issues

    master

    Planned Features

    • Models: CPC664, CPC464plus, CPC6128plus, GX4000
    • Hardware/Peripherals:
      • Expansion IO
      • Datacorder (tape) emulation and .CDT file handling
      • Memory expansions
      • External peripherals (e.g., Speech Synthesizers)
    • Improvements: Gate array implementation, CRTC implementations, CRT screen emulation, Z80 timing verification, and general optimization.

    Known Issues

    • Program stalls in Amstrad Diagnostics (likely due to incorrect firmware vertical flyback timing).
    • Shaker Tests cannot be attempted until CRTC emulation and port access timing are corrected.
    • WinAPU PlusTest failures: Monitor HSYNC test and Horizontal Split/Soft-Scroll test are currently failing.
  6. Integrate a GDB-compatible Debug Server into an ares system

    master

    To implement a debugger for a system in ares, you can register callbacks with the GDB::server object. The server is designed to be neutral, meaning operations like stopping, stepping, or reading memory should not affect the game's cycle-accurate behavior.

    Interactions are categorized into:

    • Hooks: Callbacks that allow GDB to call functions in your system (e.g., memory/register access).
    • Report-functions: Methods to notify GDB about events (e.g., exceptions or PC updates).
    • Status-functions: Helpers to check the current GDB status (e.g., if breakpoints are set).

    For a minimal working session, you must implement register/memory reads and a way to report the Program Counter (PC).

    // Example: Registering a register read hook
    GDB::server.hooks.regRead = [](u32 regIdx) {
      return hex(cpu.readRegister(regIdx), 16, '0');
    };
    
    // Example: Main execution loop with PC reporting
    while(!endOfFrame && GDB::server.reportPC(cpu.getPC())) {
      cpu.step();
    }
  7. Identify ROM quality via status bar

    master

    With a core and game loaded, check the status bar (toggle via View > Display Status Bar) for the following indicators:

    • Green checkmark: Loaded a "known good" ROM.
    • Red circle with "!": Loaded a "known bad" ROM (incorrectly dumped).
    • Question mark block (?): ROM is not in the database.
  8. Configure Nix build parameters for BizHawk

    master

    When using Nix to build BizHawk, you can pass several arguments to customize the build without writing a full Nix expression:

    • --arg forNixOS false: Wraps the final executable with nixGL to allow it to run on non-NixOS distributions.
    • --argstr buildConfig Debug: Builds the BizHawk solution using the Debug configuration.
    • --argstr extraDefines "CoolFeatureFlag": Adds a specific flag to <DefineConstants/>.
    • --arg initConfig {}: Used to set up keybinds and other configurations (though not recommended for routine use).

    For a complete list of available parameters, refer to default.nix in the repository.

  9. Prepare a Windows 10 Workstation for Waterbox

    master

    To build the waterbox native side on Windows 10, use WSL2 with an Ubuntu distribution.

    1. Install WSL2 and Ubuntu via the Microsoft guidance.
    2. Clone the bizhawk repository.
    3. Install build tools. Clang is the preferred compiler.
      • For Clang (Preferred): sudo apt-get update && sudo apt-get install make cmake clang lld llvm zstd
      • For GCC: sudo apt-get update && sudo apt-get install make cmake gcc-13 g++-13 llvm zstd
    4. Requirement: You must use clang 16+ or gcc 13 to successfully build libcxx.
    sudo apt-get update && sudo apt-get install make cmake clang lld llvm zstd
  10. Prepare a Linux Workstation for Waterbox

    master

    Debian/Ubuntu based distributions (confirmed working with Debian 11) are supported. Ensure the following packages are installed via your package manager:

    • make
    • cmake
    • gcc/g++ or clang/clang++
    • ld or lld (lld is required if using clang)
    • gcc-ar/gcc-ranlib or llvm-ar/llvm-ranlib
    • llvm-config
    • zstd

    If your distribution provides outdated compilers, use the LLVM apt repository to obtain recent versions of clang and other LLVM tools.