1983 · Legend

Valhalla

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

Eighty-one places and thirty-six characters with minds of their own, in a game written mostly in BASIC. Every fight is settled before the first blow, food makes a better weapon than an axe, and the spelling checker forgives a wrong letter.

01 · The game

The game

You are a mortal in the world of the Norse myths, and you play it by typing English.

The loading screen: a Viking helmet, the Legend and Movisoft logos and the word VALHALLA
Valheim, a castle on a green plain, with Leer, Loki, Skadi, you and Idun named below the figures

The loading screen, from the tape in the emulator, and Valheim, where the game starts, from Spectrum Computing. The names under the figures are the characters standing there.

The top of the screen shows where you are: a picture of the place, with you and everyone else there drawn as figures in a row along the ground. Below it, you type what to do: go north, get the axe, Thor, give me the food, attack Loki with the sword. The game answers in a few lines of text.

Thirty-six characters share the world with you, most of them from the myths, and two animals, Snake and Raven. Each has its own goodness, charisma, strength and brains. Those where you are walk off, eat and drink, pick things up, give them away and fight one another without being told, and they can be asked to do things for you. Six quest objects lie locked in chests and cupboards around the 81 places of Midgard, Asgard and Hell: Ofnir, Drapnir, Skornir, Skalir, Felstrong and Grimnir. Grimnir opens the way to the hall of Valhalla, and when you reach it the characters come one by one to congratulate you.

Maps has the 81 places, how each picture is drawn from its place's number, and the way to the six quest objects. Characters has everyone in the game, what goodness does between them, and how the characters seem to lead lives of their own when the game only ever runs the place you are at.

Most of the game is a BASIC program of 20,623 bytes. Machine code at the top of memory, 12,185 bytes, draws the pictures and the figures, reads the keyboard and checks the spelling of every word typed.

02 · Fights

A fight is settled before the first blow

Each side's score is its strength now, plus 40 for a weapon and 40 more for a weapon numbered above 66. The difference between the scores decides the fight. The two or three blows on the screen come after.

Attacker

Defender

A port of lines 1362 to 1376. Choosing a character fills in its full strength and what it carries on the tape; change any of it. The five buttons are fights tried in the emulator, with Idun's strength poked and two lines of the program changed so that nobody walked off before the blow: each ended as the port says.

The attacker's weapon is the object named after "with", so attack Thor is bare hands even with a sword in your pack. The defender always uses whatever is in its first slot. The side behind then adds 32 for a shield and 64 for a helmet, but only if it has something in its first slot (line 1365).

Scores within 20 of each other are a draw, and both lose 32 strength. A win by less than 64 sends the loser off to a random place with 64 less, and costs the winner 32. A win by 64 or more kills the loser, and so does any loss of 20 or more by you: you are never merely defeated (line 1374). Nothing random enters the result.

An attack you order also moves the attacker's goodness, which is how characters come to like or loathe you: the Characters tab has the rule and the two ways it goes wrong.

03 · Weapons

Secret: food is a better weapon than an axe

The test for the better weapon is only the object's number. The axe is 63 and food is 96.

Valheim after the fight: You attack Idun with the food. You defeat Idun. Idun leaves.

You, at 175 strength, against Idun at 215 in the emulator. With the axe, 215 against 215 is a draw; with the food, 255 against 215 is a win by 40. The table is every object you can carry, by its number in the dictionary.

The weapon's score in line 1362 is (w>o)*40+(w>66)*40, where o is the variable that holds 0. Every object counts for 40, and every one numbered above 66 for 80, which puts the sword and Skalir with the rock, the ring, the wine and the food. The axe, Felstrong, the shield and lightning only reach 40. Thrown, the axe and Felstrong do 20 damage and food does 2 (line 1471), so the numbers only favour food in a fight hand to hand.

04 · Typing

The spelling checker forgives one wrong letter

Each word is looked up among the 255 rows of the dictionary as you press ENTER. One letter wrong, missing or extra still finds it, and so does an "s" on the end.

Each word goes through VH.findWord, a port of $D937 and $DA11, on the dictionary at $AFE0. test_parser.py runs it and the game's own code in SkoolKit's Z80 simulator on 746 words: every word in the dictionary that can be typed, each with an "s", three misspellings of each and 100 random strings. They agree on every one.

The editor collects letters into a word, lower-cased, and digits into a number; any other character ends the word ($D7CD). The matcher walks the dictionary from row 1. A row that matches with no allowance used wins at once; otherwise it keeps the row that matched the most letters, and at the end takes it if the letters matched are within two of the word's length. The first word it cannot place is turned red and the line stays for editing ($D8C8), so BASIC never sees a word it does not know.

The last byte of each row is its class: 1 a name or object, 2 a verb, 3 a preposition, 5 a word passed over ("the", "please" and the place names), 6 a swear word and 7 a game command. A swear word is not an error to the editor. The parser sends it to line 120, where Mary appears and slaps you: "Mary is not amused...".

05 · Money

Bug: picking up crowns pays one crown

The routine that adds money, line 3410, adds the number of the one receiving it instead of the amount.

Line 3410 is LET x=FN m(n)+n, with n the character and m the amount. In the emulator, picking up a pile of 50 printed "You get 50 crowns." and then "You have 151 crowns."

The same routine pays the seller in a trade, so a character paid 100 crowns for its sword gets its own number. Thor is 4. The rest of the money leaves the game.

06 · Saving

Bug: BREAK during a save resets the Spectrum

save and load mean to catch BREAK on the tape and carry on. Pressing it resets the machine instead.

Both routines, $5CF0 and $5D0B, change only the low byte of the address BASIC jumps to on an error, to $25, meaning $5D25. In play that address is the game's own handler, $DA3C, so the jump goes to $DA25, in the middle of the spelling checker, and the Spectrum resets. Seen in play, for both.

07 · Sound

Sound: the beeper

There is no music. The machine code clicks each key, and the BASIC has five sounds made with BEEP.

Square waves at each sound's pitch and length: BEEP's pitch p is 261.63 × 2p/12 Hz, and the key sounds call the ROM's BEEPER at $03B5 with the counts in $D5B7 and $D5AE. The chest and the death are 110 and 131 Hz, which small speakers barely play.

08 · Leftovers

Left behind on the tape

The machine code was saved with some of what was in memory on the authors' Spectrum.


  

$D1D3 to $D2B0, 222 bytes nothing reads. From $D200 they hold an older copy of the line editor's variables, with its line buffer marked. The editor in use is at $D2B4.

Someone typed "quitt the axe at Nidhogg". The name "Jas.Learmont" sits at $FE5C, where nothing reads it: James Learmont is in the manual's production team. The BASIC variable i is 13 on the tape, the end of a FOR loop to 12 run as a direct command before the program was saved, and line 10 is REM LEGEND (c) 1983 021083, 2 October 1983.