Zelda3 Documentation

repository·master·Indexed 26 days ago

https://github.com/snesrev/zelda3

A reverse-engineered C reimplementation of 'The Legend of Zelda: A Link to the Past' featuring high fidelity RAM state comparison, pixel shaders, and widescreen support. Includes build instructions for Windows (TCC, Visual Studio), Linux, macOS, and Nintendo Switch, as well as controls, configuration guides, and engine API details.

Tokens
2.3K
Snippets
7
Records
19
Agent score
89%

What's inside Zelda3

  1. Compile Zelda3 on Windows using Visual Studio

    master

    For a full IDE-based build:

    1. Follow steps to download the project, place the zelda3.sfc ROM in the root, and run extract_assets.bat.
    2. Open Zelda3.sln in Visual Studio.
    3. Ensure the Desktop development with C++ workload is installed via the VS Installer.
    4. Change the build configuration from debug to release in the top dropdown.
    5. Select build > build Zelda3 from the menu. The executable zelda3.exe will be created in the /bin/release subfolder.
    6. Configure using zelda3.ini in the main directory.
  2. Compile Zelda3 on Windows using TCC

    master

    Use the Tiny C Compiler (TCC) for a lightweight build process.

    1. Download the project ZIP and extract it.
    2. Place the USA ROM named zelda3.sfc in the root directory.
    3. Run extract_assets.bat in the main directory to generate zelda3_assets.dat.
    4. Download TCC and extract its contents into the \third_party subfolder.
    5. Download SDL2 and extract its contents into the \third_party subfolder.
    6. Run run_with_tcc.bat in the main directory to generate zelda3.exe.
    7. Configure the game using zelda3.ini in the main directory.
    extract_assets.bat
    run_with_tcc.bat
  3. Install libraries and compile on Linux/MacOS

    master

    To build on Linux or MacOS, follow these steps:

    1. Open a terminal and ensure pip is installed:
    python3 -m ensurepip
    1. Clone the repository and enter the directory:
    git clone https://github.com/snesrev/zelda3
    cd zelda3
    1. Install Python requirements:
    python3 -m pip install -r requirements.txt
    1. Install SDL2 based on your distribution:
      • Ubuntu/Debian: sudo apt install libsdl2-dev
      • Fedora: sudo dnf install SDL2-devel
      • Arch Linux: sudo pacman -S sdl2
      • macOS: brew install sdl2
    2. Place your US ROM file named zelda3.sfc in the zelda3 directory.
    3. Compile using make:
    make

    Advanced Make Commands:

    • Run on all cores: make -j$(nproc)
    • Rebuild from scratch: make clean all
    • Use Clang: CC=clang make
    python3 -m pip install -r requirements.txt
    make
  4. Install Python and dependencies on Windows

    master

    To extract game assets (levels, images), you must install Python and specific libraries on Windows.

    1. Download and install Python ensuring the "Add to PATH" checkbox is selected.
    2. Open a command prompt.
    3. Run the following command to install required libraries:
    python -m pip install --upgrade pip pillow pyyaml
    python -m pip install --upgrade pip pillow pyyaml
  5. Compile for Nintendo Switch

    master

    Requires DevKitPro and Atmosphere installed.

    1. Install necessary packages via pacman:
    (dkp-)pacman -S git switch-dev switch-sdl2 switch-tools
    1. Navigate to the switch platform directory:
    cd platform/switch
    1. Build the project:
    make
    1. (Optional) Test the build directly on the Switch:
    nxlink -s zelda3.nro
    (dkp-)pacman -S git switch-dev switch-sdl2 switch-tools
    cd platform/switch
    make
    nxlink -s zelda3.nro
  6. Compile libopus from the git repository

    master

    To build from the source git repository, follow these steps:

    1. Set up a development environment:

      • Ubuntu/Debian: sudo apt-get install git autoconf automake libtool gcc make
      • Fedora/Redhat: sudo dnf install git autoconf automake libtool gcc make (or yum for older releases)
      • macOS: Install Xcode and Homebrew, then run brew install autoconf automake libtool
    2. Clone and Build:

      • Clone the repository, enter the directory, run autogen.sh, configure, and make.
    3. Install (Optional): Run sudo make install to install the codec libraries.

    % git clone https://git.xiph.org/opus.git
    % cd opus
    % ./autogen.sh
    % ./configure
    % make
    % sudo make install
  7. Run Opus automated tests

    master

    After compiling, you should run the integrated unit and system tests to ensure correct operation on your platform.

    To run the built-in tests: make check

    To test against standard RFC 8251 test vectors:

    1. Download the vectors: curl -OL https://opus-codec.org/docs/opus_testvectors-rfc8251.tar.gz
    2. Extract: tar -zxf opus_testvectors-rfc8251.tar.gz
    3. Run the comparison script: ./tests/run_vectors.sh ./ opus_newvectors 48000
    % make check
  8. Configure fixed-point arithmetic for embedded environments

    master

    By default, Opus uses floating-point arithmetic. For embedded environments where only fixed-point arithmetic is available, you can compile using one of two methods:

    1. Using autoconf: Pass the --enable-fixed-point flag to ./configure.
    2. Manual build: Define the FIXED_POINT macro during compilation.

    Note: The fixed-point implementation may have lower audio quality and is slower on platforms with fast FPUs.

  9. Run Zelda3 and verify against original ROM

    master

    The game is executed via ./zelda3.

    To verify that the C implementation matches the original machine code behavior, run the executable and provide the path to the ROM file as an argument. This will compare the RAM state after each frame.

  10. Zelda3 Controls and Commands Reference

    master

    Standard Controls

    ButtonKey
    UpUp arrow
    DownDown arrow
    LeftLeft arrow
    RightRight arrow
    StartEnter
    SelectRight shift
    AX
    BZ
    XS
    YA
    LC
    RV

    Note: Keys can be reconfigured in zelda3.ini.

    Special Commands

    KeyAction
    TabTurbo mode
    WFill health/magic
    Shift+WFill rupees/bombs/arrows
    Ctrl+EReset
    PPause (with dim)
    Shift+PPause (without dim)
    Ctrl+UpIncrease window size
    Ctrl+DownDecrease window size
    TToggle replay turbo mode
    OSet dungeon key to 1
    KClear all input history from the joypad log
    LStop replaying a snapshot
    RToggle between fast and slow renderer
    FDisplay renderer performance
    F1-F10Load snapshot
    Alt+EnterToggle Fullscreen
    Shift+F1-F10Save snapshot
    Ctrl+F1-F10Replay the snapshot
    1-9Load a dungeons playthrough snapshot
    Ctrl+1-9Run a dungeons playthrough in turbo mode
  11. ROM Requirements and Asset Portability

    master

    Required ROM

    The game requires a US region ROM named zelda3.sfc. It must match this exact SHA256 hash: 66871d66be19ad2c34c927d6b14cd8eb6fc3181965b6e517cb361f7316009cfb

    Portability

    If you move the zelda3.exe executable to a different location, you must also include the zelda3_assets.dat file in the same directory.