1986 · U.S. Gold

Gauntlet

This minisite was contributed by air, chunkypixel. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/gauntlet with me to Gold.

All 128 level files on the disk, each built by the game's own code running in this page.

01 · The levels

Every level file, as the game builds it

Files 1 to 7 are levels 1 to 7. After that the game picks from files 8 to 117 at random, and every four to seven levels from the treasure rooms, files 118 to 128.

The whole 32 by 32 tile maze, built by the game's code. The page puts the file at $0A00, as level_start ($99CF) loads it, and runs level_build ($C625), grid_draw ($CBC2) and monsters_draw_all ($C00E) on the kit's 6502 simulator over the game's bytes from the listing, then draws the 64 by 64 character map at $3000 with the colour map at $2000 and the first maze font, $4800, as maze_style ($8CC5) has just set it for this level. The monsters face whichever way one fixed reading of the timer the game uses for chance gives them. Every exit is shown: on a level that keeps one exit, the game picks it as play begins (exits_pick_one, $CBE6). test_levels.js calls the same code on the simulator directly for all 128 files: every byte of the tile grid, both maps, the fonts' wall glyphs, and the tile colours is the same, with 4,341 monsters placed.

A level's look comes from its header. Bits 3-5 of its second byte pick one of three sets of wall glyphs, which maze_style copies into all three maze fonts, and bits 3-5 of its third byte pick the walls' colour. The same 128 files therefore come in several styles of brick.

02 · The level file

Four bytes of header, the walls as lines, the rest run-length coded

The file for the level shown above, byte by byte.

headerwall linesobjects

The bytes as the disk holds them, after the two-byte address every C64 file starts with. All 128 files carry $1E00 there; the game loads them to $0A00 instead, with secondary address 0 (load_files, $9964, and its address table at $9939).

The header is four bytes: the file's length less two (with bit 7 of the third byte as a ninth bit), the flags, the wall colour, and how many bytes of wall lines follow. The flags make the maze wrap left to right (bit 7) or top to bottom (bit 6), make the players' shots hurt (bit 0) or stun (bit 1) each other, and keep a single exit (bit 2).

A wall line starts with two bytes: the kind of piece in the first byte's top three bits (a wall, a wall a trap takes away, a door either way, or an exit) and the column and row in the low five bits of each (wall_start). Every byte after it draws a run of one to 32 pieces in one of eight directions (wall_run, $C70A). The game joins each piece to its neighbours as it goes, choosing the brick glyph by which sides have wall.

The objects follow, from the top-left tile on (objects_place, $C83B). A byte from $80 skips that many tiles less $7F. A smaller byte is a tile, and when the byte after it is below $13 the tile repeats that many times plus two. Tiles from $40 are monsters, which go into the monster table as well; $3F marks where the players start.