← home original github.com

GitHub - needlestack/lest-c64: LEST: a first-person 3D game for the Commodore 64 (pre-release)

github.com
BranchesTags Open more actions menu

Latest commit

History

97 Commits 97 Commits

Folders and files

Name Name Last commit message Last commit date alternates alternates art art build build data data docs docs krill krill music music src src tools tools .gitignore .gitignore .nojekyll .nojekyll LICENSE LICENSE README.md README.md index.html index.html lest-c64.crt lest-c64.crt lest-c64.d64 lest-c64.d64

Repository files navigation

Lest

A new 3D game for the Commodore 64

"He drove out the man, and at the east of the garden he placed cherubim and a flaming sword that turned every way…"

▶ Watch the trailer  ·  Play it in your browser

Where it started

Can an unmodified C64 run a first-person 3D game at full resolution with a decent frame rate?

That was the question. And the answer turned out to be: better than I expected.

There have been many 3D games for the C64, even up to including a port of DOOM. However they all tend to have poor frame rate (under 10 fps) and often very blocky graphics. My goal was to see if the C64 could produce something smoother and clearer. And it turned out, it can.

Lots and lots of tricks were used to make it possible:

And oh so much more. Aggressive profiling and optimizing, pass after pass, taking advantage of every simplifying rule of our game format, using every 6502 programming trick, precalculating as much math as possible, aligning tables in memory... you name it, it's in there.

Playing

You can play it online right now at:

https://needlestack.github.io/lest-c64/

That plays the cartridge. Add ?disk to the address to play the disk image instead (with its 1541 load times), or ?dvorak for the Dvorak build (see Building).

Or if you prefer, you can use VICE with the disk image lest-c64.d64 in this repository, or the cartridge image lest-c64.crt (see below).

Be sure to use x64sc and enable true drive emulation under peripherals: the fast loader runs its own code inside the 1541, so it needs a real (or truly emulated) drive. The same disk runs on NTSC and PAL machines (it detects which at boot), but it plays slightly better on NTSC, so set the machine to NTSC if you can.

The cartridge. lest-c64.crt is the same game as an EasyFlash cartridge image, for an EasyFlash 3, Kung Fu Flash, Ultimate 64 or 1541 Ultimate, or any emulator (in VICE: x64sc -cartcrt lest-c64.crt). It needs no disk drive at all, so it is the way to play on a machine whose drive is an SD2IEC, which the disk's fast loader cannot talk to. It loads in under a second; the controls come up first and wait for fire or SPACE, then the opening quote and the title hold for a few seconds each, and fire or SPACE skips them.

Controls

keyboard joystick (port 1 or 2) forward, back E, D up, down turn left, right , . (the < > keys) left, right strafe left, right S, F hold the button + left, right pick up, put down SPACE button start again (after you're caught, or at the end) SPACE button

Picking up and putting down happen when you let go of SPACE or the button, unless you strafed while holding it.

On a real C64 the joystick works in either port. In VICE, map the cursor keys or a gamepad to either joystick port. The online version is already set up.

Building

Requirements:

The assembler (src/asm6502.mjs) and the disk-image writer (src/d64lib.js) are part of the project. The test tools in tools/ also need VICE 3.9; they look for /Applications/vice-arm64-gtk3-3.9/bin/x64sc, and X64SC names another.

node src/build-iray.mjs                               # the whole game, levels 1-10 -> lest-c64.d64 and lest-c64.crt
D64=build/test.d64 node src/build-iray.mjs            # the same, to another disk
DVORAK=1 node src/build-iray.mjs                      # -> alternates/lest-c64-dvorak.d64 and .crt
HEAVYSID=1 node src/build-iray.mjs                    # -> alternates/lest-c64-heavysid.d64 and .crt

Every disk is the whole game, starting at level 1. D64 names the disk to write; without it, a build replaces lest-c64.d64, or its alternate in alternates/:

The two combine (alternates/lest-c64-dvorak-heavysid.d64). Each level and each removable wall is built as its own sub-build first, so the engine can be laid out around all of them; the sub-builds run in parallel and are cached in build/.cache/ under a hash of every input they read (src/, data/, art/, music/, krill/, the environment, node and ImageMagick), so a build is about 25 s cold and 5 s when nothing they depend on has changed. NOSUBCACHE=1 makes them all fresh; deleting build/.cache/ is always safe. Run it from the project directory.

docs/TESTING.md says which test answers which question (does it still play, does it still draw the same, did a routine get faster) and how to run it.

The online version is index.html, served from this repository by GitHub Pages. It runs EmulatorJS (pinned, from its CDN) set up for NTSC, true drive emulation, joystick port 1 (either works) and the whole keyboard to the C64, and plays lest-c64.crt straight from the repository (lest-c64.d64 at ?disk), so pushing a new build updates the site.

How it works

The screen is a character-mode framebuffer: 40×25 cells, each drawn from a charset of wall-edge shapes, giving 160×200 multicolour pixels. Around it:

The build also checks itself as it goes. Page alignment, memory overlaps, zero-page ownership, unreachable code, and the precondition of every undocumented opcode it uses are verified before a disk is written.

Deeper notes: docs/RENDERING.md on the renderer. Every entity's size ladder, drawn rung by rung at the C64's pixel aspect, is in docs/ladders/ (regenerate with LADDERSHEET=1 node src/build-iray.mjs).

Layout

path what lest-c64.d64 the game, ready to play lest-c64.crt the same game as an EasyFlash cartridge index.html the game in a browser (EmulatorJS), served by GitHub Pages src/build-iray.mjs the game: emits 6502 assembly, builds every level, writes the disk src/levels.mjs the ten levels as data: maps, walls, sockets, exits, entities, starts, inks (read by the build and by tools/levelsheet.mjs) src/compact.mjs the image layout pass (run by the build) src/loader-src.mjs the boot: autorun, fast first stage, quote, Krill's installer src/cart-src.mjs the cartridge: its boot, loader and .crt writer src/ending-src.mjs the ending: end quote, the tree dissolving in, and the reload src/asm6502.mjs, src/d64lib.js assembler and disk writer src/fit-*.mjs, src/make-*.mjs, src/charsetgen.mjs, tools/endscene.mjs, tools/build-facetest3.mjs the art converters: the fit-* ones run inside every build, the rest by hand to make the assets in data/ (see docs/ASSETS.md) data/ assets made by hand from art/ that the build reads (death picture, quotes, title, pedestal, end scene, charset plan) build/ build output; only build/iray.asm is committed, so a diff shows what a change did to the machine code art/ source art: every picture in the game starts here (docs/ASSETS.md says how); art/tree/ is the end scene's krill/ Krill's loader, prebuilt docs/ TESTING.md, THE tests: what to run for which question and how to read it; SPACE.md, where the image's bytes go; RENDERING.md; levels/, every level as a sheet (key in levels/KEY.txt, regenerate with node tools/levelsheet.mjs); and ladders/: every entity's ladder of sprite sizes, as pictures branch history-main the project's first two months (7 Aug - 8 Oct 2026, 645 commits), before main began; some comments in the code cite commits that live only there tools/ live-machine inspection (probe), frame-rate and cycle benchmarks (fpsr, prof, vprof), test rigs (regress.sh, ship.sh, frames), the level sheets (levelsheet), and the music tools (song-*, sidtrace)

Credits and licence

Everything in this repository -- the code, the art in art/, the end-scene picture and the level designs -- by Jonathan Field, written with Claude (Anthropic) in Claude Code, is released under the MIT licence.

Included third-party code keeps its own licence:

About

LEST: a first-person 3D game for the Commodore 64 (pre-release)

Resources

Readme License Activity

Stars

30 stars

Watchers

1 watching

Forks

0 forks Report repository

Releases

Packages

Contributors

Languages