Pentagram's quest is a chain, each link an update routine acting on the next thing: shoot the well until it gives a bucket; carry the bucket to each of four rough stones, where it flies to the stone and finishes it; with all four finished the pentagram appears in room 82; bring the five collectables there, and each glides to its place on it; the fifth ends the game. This page follows the chain through the code, and then through the game itself, played in a simulator the way the build plays it.

Graphic 120 Graphic 90 Graphic 112 Graphic 116

The quest's things

None of these is in the room data. They live in 18 records of 16 bytes at QUEST_RECORDS -- an object record's first half, with its room at +8 -- copied from QUEST_START at every new game by NEW_QUEST. QUEST_OUT_OF_ROOM copies each one in the room being left back to its record, by graphic, and QUEST_INTO_ROOM copies those in the room being entered into free object records, so a thing stays wherever it was left. The records as a game starts:

RecordWhatGraphicIts spriteWhere
0quest item112 → 116Graphic 112 → Graphic 116room 122 at (80, 160, 128)
1quest item113 → 117Graphic 113 → Graphic 117room 128 at (112, 160, 128)
2quest item114 → 118Graphic 114 → Graphic 118room 17 at (132, 160, 128)
3quest item115 → 119Graphic 115 → Graphic 119room 33 at (160, 160, 128)
4collectable148 → 156Graphic 148 → Graphic 156placed at random at each new game (below)
5collectable147 → 155Graphic 147 → Graphic 155placed at random at each new game (below)
6collectable146 → 154Graphic 146 → Graphic 154placed at random at each new game (below)
7collectable145 → 153Graphic 145 → Graphic 153placed at random at each new game (below)
8collectable144 → 152Graphic 144 → Graphic 152placed at random at each new game (below)
9piece of the pentagram128Graphic 128room 82 at (96, 128, 127)
10piece of the pentagram129Graphic 129room 82 at (108, 140, 127)
11piece of the pentagram130Graphic 130room 82 at (120, 152, 127)
12piece of the pentagram131Graphic 131room 82 at (132, 164, 127)
13piece of the pentagram132Graphic 132room 82 at (120, 104, 127)
14piece of the pentagram133Graphic 133room 82 at (132, 116, 127)
15piece of the pentagram134Graphic 134room 82 at (144, 128, 127)
16piece of the pentagram135Graphic 135room 82 at (156, 140, 127)
17the bucket0 until the well gives one

The block holds 19 records' worth, 304 bytes; the last nothing reads or writes. The collectables start at five neighbouring places of the twenty at SPOTS, the first picked by the random number (AND $3C, so one of the first sixteen):

PlaceRoomUVZUsed
012018472128first or later
1377272164first or later
262120184128first or later
3112184184129first or later
4108120184152first or later
50104120152first or later
669184184128first or later
714272152176first or later
878128128129first or later
91512072164first or later
1042120120176first or later
115104120164first or later
12141120104176first or later
1370128128128first or later
144184120176first or later
151672120176first or later
1612916872129only as a later one
17188888176only as a later one
18146168152176only as a later one
192772120176only as a later one

The well

Every turn, WELL asks BOLT_TOUCHING whether a bolt is within two units of it, with the bolts' own hit test (BOLT_HIT), and if one is adds one to a count in its +$14. On the 32nd it makes the bucket: a copy of its own record, graphic 90, at the well's U and 8 further in V, 141 up, and BUCKET_OUT set -- none while a bucket is out, or in the room, or with no free record. The count lives in the well's own record, and the room builder makes that afresh every time the room is entered, so the 32 must all come in one visit. A bolt touches the well for several turns as it goes by and puffs against it, so it takes a volley aimed the right way, not 32 shots. The two bolt records are not tested alike: the first is taken into BOLT_HIT's test past its check for a puff, so its puff goes on counting as touching; the second's does not.

Played in room 71 (a well with no monsters), standing at (120, 148) inside its ring of hazards, firing twelve times a volley and turning a quarter between volleys, as the build's session does. The well's count and the bucket, volley by volley:

VolleyThe count after each shot, until the bucketBucket outTurns it took
10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0no37
20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0no40
30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0no48
45, 9, 13, 18, 19, 23, 28, 28yes49

Each shot that reached the well added 1 to 5 turns of contact; the count stood at 28 at the last shot before the bucket, and on the turn it reached 32 the bucket came and the count went back to 0. The volleys that added nothing were fired while he faced away from it.

Firing at the well, and the bucket

Firing at the well, and the bucket just out. Pictures from the game's own screen in the simulator.

The bucket

Carried (the pick-up key, TAKE_OR_LEAVE), the bucket goes in the carried slots; put down, it is an object again. Each turn, until it has a target, it falls a unit and looks for a stone not yet finished (graphics 112 to 115) among the room's records; found, it takes the stone's U and V as its target, and from then on rises a unit a turn up to Z 176 while HEAD_FOR_TARGET steers it a unit a turn towards the target, without falling. When it can move no more -- over the stone at the top of its rise -- it sets bit 0 of the stone's +$16, clears BUCKET_OUT so the well may give another, plays the quest tune, empties its own quest record and turns into a puff. The stone, on its next update, is finished.

Room 122, from the moment the bucket is put down, turn by turn (some of the turns):

Turns afterThe bucketThe stoneQUEST_DONELives
0the bucket at (109, 147, 137)graphic 11205
7the bucket at (102, 154, 144)graphic 11205
15the bucket at (94, 160, 152)graphic 11205
19the bucket at (93, 160, 156)graphic 11205
23the bucket at (92, 160, 160)graphic 11205
31the bucket at (84, 160, 168)graphic 11205
39the bucket at (80, 160, 176)graphic 11205
41a puff at (80, 160, 176)graphic 11616
44a puff at (80, 160, 176)graphic 11616
51gonegraphic 11616
The bucket flying to the quest item

The bucket put down, rising and flying to the stone, over it, the puff, and the finished pillar (turns 0, 19, 39, 41, 44, 51). Lives went from 5 to 6: a quest item gives a life. Each picture is the screen as a turn began.

It rose a unit a turn from Z 137 to 176 while it steered, and was over the stone 39 turns after it was put down.

The pentagram

With the fourth stone finished, ALL_FOUR_DONE finds all four quest records at 116 to 119, and sets PENTAGRAM_ON. The pieces' quest records have been in room 82 all along; QUEST_INTO_ROOM simply leaves them out until then. From then on nothing falls from the sky in room 82 either, since the pieces are among what bans a drop there (BAN_DROPS).

Room 82 before the quest items are done, and after

Room 82 as the game drew it at the start of this run, and after the fourth quest item.

A collectable is otherwise an ordinary thing that falls and can be pushed or carried. In room 82 with the pentagram showing, COLLECTABLE takes its place from TARGETS by the low three bits of its graphic and glides there a unit a turn in U and in V, without falling:

GraphicSpriteUVBecomes
144Graphic 144112176152
145Graphic 145156162153
146Graphic 146162106154
147Graphic 14711492155
148Graphic 14880136156

The build's session stages this last part: the five collectables are put on the floor of room 82, sixteen units short of their places, and the room entered again. Being the same distance from their places, they arrived together: PLACED went from 0 to 5 within one round of updates, the fifth jumping to the win from inside it.

The collectables gliding to their places

The collectables gliding to their places on the pentagram.

Winning

When PLACED reaches 5, COLLECTABLE jumps straight to WON, from inside the main loop's round of updates: the buffer cleared, the screen's colours bright cyan, six lines of text each in its own colour (CONGRATULATIONS... YOUR ADVENTURE CONTINUES IN MIRE MARE, from WON_CONGRATULATIONS), the border, the screen shown, the winning tune. Then it runs on into the game-over screen, GAME_OVER, with the percentage, and after about four seconds back to the menu. Winning is a game over with a different first screen.

The winning screen The game-over screen

The two screens as the game showed them at the end of this run: it printed 49 per cent.

The percentage

PERCENTAGE adds three things: the rooms seen (a bit each in the 31 bytes at ROOMS_SEEN, set by MARK_ROOM_SEEN as each is built) halved, up to 54; 4 for each quest item done, 16 in all; 6 for each collectable placed, 30 in all. 54, 16 and 30 make 100. The sum is turned into BCD by counting: a DJNZ loop adding 1 with DAA, B times. With B = 0 a DJNZ loop runs 256 times, and 256 counted in BCD leaves 56 in the last two digits. So a player who has seen no more than one room and done nothing else is told 56 per cent -- anyone who loses all five lives in the room they started in (one of the bugs). Run on its own for a few sums:

Rooms seenQuest itemsCollectablesThe sumPrinted
000056
100056
200101
300101
20112020
60203838
107459999
10845100100
13945100100

This run printed 49: it had seen 7 rooms (3), done 4 quest items and placed 5 collectables. The staged session reaches rooms by restarting in them, not by walking, which is why it has seen so few.

The drop timer

Things fall from the sky (see the creatures) when DROP_TIMER runs out. RESET_DROP_TIMER, run at every room's start and after every drop, is written to count the quest items still to do and allow four turns for each, plus eight: 24 turns with all four to do, down to 8. But it loads the record length into DE and never adds it to HL, so it tests the first record eighteen times: the answer is 80 while the first quest item is to do, and 8 once it is done, whatever the others are (another of the bugs). Run on its own:

Quest items done (1 is room 122's)MeantSet
none2480
1208
22080
2, 3, 41280
1, 2168
1, 2, 3, 488

Confirmed and inferred