emuforge

Development

You need the Rust toolchain that rust-toolchain.toml names.

cargo build --release
cargo test --workspace
tools/check.sh          # everything CI runs; before every push
tools/check.sh clippy   # only one of its parts: format, clippy, tests, licenses or markdown

tools/check.sh also needs two tools:

cargo install --locked cargo-deny
cargo install --locked --git https://github.com/emuforge/forge forge-docs

On Linux, the app also needs the development files of ALSA and udev (libasound2-dev and libudev-dev on Debian). To play a game:

cargo run --release -p snesemu -- GAME

Run the tests without --release too, as tools/check.sh does. A debug build also stops at numbers that do not fit, which a release build lets pass.

Tests for the processors

Both processors are tested with SingleStepTests' cases. They have the registers, the memory and each bus cycle of single instructions. They are not in this repository. Both are MIT:

ProcessorRepositoryCommitCases
65C816https://github.com/SingleStepTests/65816307c63f5673c8c6b861c52f71ddb89212a2274805,080,400. Its files have 2.7 GB
SPC700https://github.com/SingleStepTests/spc70067d15f492b2740964abd4efd1229e0ec9c342228256,000

Put both into one folder outside of this repository, as 65816 and spc700, at these commits:

mkdir TESTS && cd TESTS
git clone https://github.com/SingleStepTests/65816
git -C 65816 checkout 307c63f5673c8c6b861c52f71ddb89212a227480
git clone https://github.com/SingleStepTests/spc700
git -C spc700 checkout 67d15f492b2740964abd4efd1229e0ec9c342228

The tests look for 65816/v1/00.e.json and so on, and for spc700/v1/00.json and so on. SNES_TESTS is the folder that has both. Give it a full path, as tests run in the folder of their crate:

SNES_TESTS=/path/to/TESTS cargo test --release -p snes-65816 --locked --test single_step -- --test-threads 6 --nocapture
SNES_TESTS=/path/to/TESTS cargo test --release -p snes-spc700 --locked --test single_step -- --nocapture
  • Without SNES_TESTS, these tests say so and pass. So CI does not run them. --nocapture shows that note, and how many cases were compared. Say in a pull request if you ran them.
  • If a file is missing, the test fails. It also fails if a file of the 65C816 does not have as many cases as it should.
  • For the 65C816, with SNES_TESTS_LIST set to anything, the test also prints each case that fails. For each file, it always says how many failed, and shows the first one. What is not compared is at the top of crates/snes-65816/tests/single_step.rs.
  • For the SPC700, one cycle is moved in 7,000 cases. The top of crates/snes-spc700/tests/single_step.rs says why. It prints how many were moved.
  • What the data can and cannot show is on a page of its own.

All other tests need nothing. A test that needs a game of yours would also pass with a note when it is not there. There is none yet.

Many games without a window

The lab runs your own games without a window and says what each one did. It starts each one with an empty save. So the games with an SPC7110 show their chip's test there, and not the game.

After a change for speed

A change for speed may not change anything that games do. The playbook says how to find and check one, and Performance what was done and what did not help. snesemu-dev (apps/snesemu-dev) runs the core without a window. Forge's tools/builds.py compares two builds of it frame by frame, or times them. Without arguments, snesemu-dev says what it can do.

cargo build --release -p snesemu-dev        # the old commit: keep a copy as OLD
cargo build --release -p snesemu-dev        # the new one: keep a copy as NEW

../forge/tools/builds.py cases games.json --games GAMES --end .zip -- --plays 3600
../forge/tools/builds.py compare OLD NEW games.json --out results.jsonl
../forge/tools/builds.py reload NEW games.json
../forge/tools/builds.py times OLD NEW games.json --quiet
  • Use a few games of each kind: LoROM and HiROM, PAL, mode 7, and each of the chips. Each case is in the JSON with its own options. Run some without buttons too (--idle), as buttons skip intros.
  • Look at pictures of what is timed (snesemu-dev shot). The buttons paused many games, and --start 2420-2426 ended that. A game in its menu or pause says little.
  • Count instructions and cycles too. On a computer that does other things, the same build took up to twice as long from one run to the next. On Linux, perf stat -e instructions:u,cycles:u PROGRAM run GAME ... counts both. Instructions hardly change from run to run.
  • --exact runs the slow code, so verify with and without it can be compared too.
  • The core always makes its picture and sound, so there is no core command or --headless.
  • Keep the lists and results outside of every repository, as they have names of your games in them.

After a change to a part

  • Savestates are part of each part. When something new is kept, add it to the part's state. Tests of the layouts then fail. Until a build with savestates is published, record the new numbers. After that, give the section a new version, and still read the one before. The random tests that save, load and damage states are in crates/snesemu-core/src/console/tests.rs. They have a program for each kind of cartridge, so a new chip needs one there.
  • The exact way and the fast way have to agree. These tests compare them: crates/snes-ppu/tests/same.rs, crates/snes-dsp/src/tests.rs, tests/same.rs in the Cx4 and the Super FX, src/tests.rs in the SA-1, and the tests in sound.rs, sound/timer.rs, bus/tests.rs and console/tests/waits.rs of the core. tests/whole.rs of the sound processor compares whole instructions with their cycles. To see both in a game, Console::set_exact turns on the exact picture, the sound side's cycles, and each step of the main processor. It does not change cartridges' chips.
  • A clock gets its time from outside. Tests and tools use Settings::time. With the same time, all is the same again.
  • The times of the bus and DMA are in crates/snesemu-core/src/bus/tests.rs. They come from documents. If one fails, look in the document before changing the number.
  • examples/speed.rs in some crates, and examples/frame_time.rs of the picture, time a part alone, with programs or scenes that are made up. Each one says what it can compare. None of them says how fast a game runs.
  • Change its page in the same piece of work if what a part does, or how it talks to another, has changed.

This documentation

It is the Markdown in docs/, and emuforge.org makes the pages. The harness says how it is written. To read the comments of the code as pages of their own, run cargo doc --workspace --no-deps --open. They name the source for each rule.

From commit 019fda0af379. Edit this page