- Rust 95.4%
- Shell 3.4%
- WGSL 0.8%
- Nix 0.4%
| .forgejo/workflows | ||
| crates | ||
| nix | ||
| tas | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
| regress.sh | ||
| rustfmt.toml | ||
sisters — giana-rs
A Rust reimplementation of The Great Giana Sisters (C64, 1987, Time Warp / Rainbow Arts), reverse-engineered from the original and ported routine by routine, then checked frame by frame against the original running in VICE.
This repository contains no game data. You need your own disk image of the game. The game's
graphics, maps, tables and music are read from it at runtime (or unpacked once into a
git-ignored assets/ directory):
cargo run --release --bin extract-assets -- path/to/GIANA1.D64 assets
Supported image: the "ASS" cracked release (GREAT GIANA S.+, GIANA SISTERS HI). The
extractor unpacks it with native versions of the release's own decrunchers — no C64 ROMs are
needed — and checks that the unpacked game code is where it expects it.
Playing
cargo run --release -p giana-play -- path/to/GIANA1.D64 # or the assets/ directory
Arrow keys = joystick (Up jumps), Ctrl = fire, Space = use the power-up (as on the C64: at power-up
levels 5 and 6 it freezes the enemies or strikes them with lightning), P = pause, F11 or Alt+Enter =
fullscreen (--fullscreen starts in it), Esc = quit. A game controller works as well (plug it in any
time): D-pad or left stick = joystick, A / cross = jump, X / B = fire, Y / triangle = Space, Start =
pause. The window can be resized; the picture scales to fit, as large as the window allows with the
aspect ratio kept. It shows the 320×200 game area only (the C64's border is black in the game and
would only add bars), so a 16:9 screen has bars left and right and a 16:10 screen none; --border
shows the whole 384×272 frame with the border. On the title
screen 1 / 2 pick one or two players (fire = one player). On the high-score screen type a name,
Return to enter it. The all-time high scores are saved whenever they change, and with F1 as in the
original, to $GIANA_HISCORE (default ~/.local/share/giana-sisters/giana-hiscore.prg, or under
$XDG_DATA_HOME). The file is in the format the original writes to disk. Today's table starts empty
each run, as on the C64. A stage number after the image skips the title. --tas tas/run.txt plays
the tool-assisted full run in real time instead (see tas/README.md).
Keys for the speed and the overlay: + / - (also on the keypad) double / halve the game speed
between ¼× and 8× (--speed 1/4|1/2|1|2|4|8 starts at one of them), 0 goes back to 1×, and while
paused (P) . advances exactly one tick (--paused starts paused). The game runs on the clock,
speed × 50 ticks per real second (PAL: 50 at 1×), and the picture is drawn independently of that,
once per display refresh: the GPU renderers wait for the vsync, the CPU one is held to the monitor's
refresh rate. Input is read per tick, so a --tas run plays the same game at any speed. The sound
is played at the game's speed, like a tape: pitch and tempo follow, it is never muted. F3 shows or
hides a small overlay in the top-left corner, in window pixels (not scaled with the picture), with
the frames drawn per second, the game ticks per second and the speed, e.g. FPS 144 TPS 100 2x
(--no-overlay starts without it); it is drawn the same way by all three renderers and doesn't
change the C64 picture under it.
--renderer cpu|gpu|gpu-scale picks who draws the C64 picture: the GPU (gpu, the default; wgpu over
Vulkan or OpenGL) draws it itself from the frame's VIC state in a shader — chars, scroll bands,
sprites — and also looks up the colours and scales; gpu-scale draws it on the CPU and only lets the
GPU scale it (handy for debugging); cpu does everything on the CPU (softbuffer). Without a usable GPU
the game prints gpu renderer unavailable: …, using cpu and carries on on the CPU. The picture is pixel
for pixel the same: a test reads the GPU's picture back and compares it with the CPU renderer's (see
Verification).
With Nix: nix run git+https://forge.constellation.darkest.space/mara/sisters -- GIANA1.D64
(.#extract-assets for the extractor, nix develop for a dev shell with the runtime libraries).
Without Nix, the Linux build needs the ALSA headers (alsa-lib dev package), and at run time a Vulkan
loader (or libGL/libEGL) for the GPU renderer. The window uses winit + softbuffer or wgpu; sound is
a port of the game's own music player, fed into reSID (resid-rs).
Layout
crates/giana-assets— D64 reader, ROM-less depacker, typed access to graphics, stage maps and enemy lists.crates/giana-dummy— stand-in game data made only of our own bytes: Pipo the plumber, four short feature-test stages and a bonus room (all 33 stage slots point at them), as text art and text maps.giana-dummy <dir>writes<dir>/giana.ram;giana-play <dir>then runs it like the real game. Its tests play the stages without the disk, so CI runs the whole engine; its README lists every part of the game image the engine reads.crates/giana— the game, no dependencies besides the assets crate:game.rs(the raster IRQ chain and the main loop as a state machine),player.rs(movement, jumps, probes, scrolling),items.rs(blocks, diamonds, item animations),enemies.rs(spawning, movement, collisions, power-ups, the projectile, end-of-stage bosses),bonus.rs(bonus rooms),hiscore.rs(game over and high scores),sound.rs,charanim.rs,timing.rs,video.rs(a software VIC-II subset: multicolour text, three scroll bands, sprites, pixel-exact sprite collisions).crates/giana-play— window, keyboard, audio;clock.rs(game speed, tick scheduler, FPS/TPS meter),overlay.rs(+overlay_gpu.rs,overlay.wgsl: the on-screen FPS/TPS badge),present.rs/gpu.rs/vic.rs(+vic.wgsl) show the picture, on the CPU or the GPU.
Verification
The port keeps the original's RAM layout for the state it shares with the game, so every frame
can be compared with a recording of the original running in VICE (vice.rs, bin diff-vice).
regress.sh replays all recordings (they contain game RAM, so they live outside this repo);
currently 25 recordings — title screen, deaths, items, enemies, warp, bonus room, power-ups,
the Space-key freeze and lightning, shooting, stage clears, boss fights, the lift and the
ending — match on every frame. The bin
plan searches joystick inputs on the port itself to produce those runs.
The GPU renderer is checked against the CPU one, which is the reference: tests in giana-play
(vic_check) draw displays with a headless wgpu device (no window), read the picture back and compare
every byte with video::render — synthetic displays covering each VIC rule plus random ones, and
with the game data (GIANA_ASSETS, --ignored) the title, four stages and the whole tool-assisted
run. They need an adapter and skip (printing why) without one; software Vulkan is enough: set
VK_ICD_FILENAMES to mesa's lvp_icd.x86_64.json.
Not verified against VICE (keyboard input can't be recorded yet): the high-score screen and two-player mode.
Known differences (none touches a variable the recordings compare, so they still match):
- Crumbling floor during a coarse scroll step. On the C64 the shift of the screen by one
column (
$9600, in the IRQ) is often still running when the player logic reads the chars under Giana's feet. How far it has got depends on that frame's IRQ load, which the port doesn't model: it always sees the screen fully shifted. So when Giana lands on crumbling floor exactly then, the original can crumble one tile more. - Entering a bonus room: the original turns the background black 2 frames earlier. The port does the room's setup and the return in one frame each, while the original runs them with busy-waits.
Formatting and checks
nix fmt formats everything (treefmt: rustfmt, nixfmt, taplo for TOML, prettier for Markdown and
YAML; config in nix/treefmt.nix). nix flake check builds the package, runs clippy with
-D warnings on all targets and fails on any file nix fmt would change; CI runs the same.