Avalon's entire game code, as saved on the cassette tape, is encrypted.
Once the data is loaded from tape, the whole game code & data (39000 bytes, starting from 25001) is put through a short unencryption algorithm, in the routine at 65023.
The encryption and code sheet were added by Steve Marsden(link to games list at Spectrum Computing)
Graphics data
Avalon's graphics are stored from 39247 and referenced from an address table at 38851.
Graphics consist a number of 1 character wide tiles - graphic pieces that make up the full graphic 'jigsaw'. To save memory, the tile pieces are trimmed to only contain the graphic bytes necessary; there are no leading or trailing 'empty bytes' with zero values.
Stored with each tile is a number that tells us how many bytes there are in the tile. Also stored are two pixel offset bytes (X/Y) indicating where to position the tile in relation to the graphic's central pixel X/Y co-ordinates.
For example, Maroc's X,Y central pixel position for frame 1 is somewhere in the middle of the sprite:
The first tile graphic is 16 bytes and consists of Maroc's hat and eyes (39248).
The offset co-ordinates stored with this tile are 253 and 231 which indicate pixel offsets of -3 (X) and -25 (Y) respectively.
This tells us that this tile should be positioned 3 pixels to the left of, and 25 pixels above, the overall graphic's central X/Y pixel location.
GRAPHICS MIRRORING
When Maroc enters a room, each room element - background scenery, doors, door frames, connecting walls, creatures and objects - is evaluated, to decide whether it needs a mirrored/flipped version of its graphics.
Some room items will always need mirroring. For example, the left and right vertical floor/wall connectors (see 49600).
For room creatures, the graphics need mirroring if they have left/right facing directions (e.g. goblin warriors - see 42140), but they won't if they don't (e.g. demons - see 42702).
The routine that creates the flipped versions of the graphics is at 57589. The flipped graphics data is stored from 32851.
This area of memory was originally used for the game menus, and drawing the decorative border, but once the game starts it is overwritten (as the menus and border do not need revisiting).
Graphic properties byte
Each game graphic is preceded by a single byte that holds various graphic item's properties (see 42317 for an example).
The makeup of this byte is as follows:
Bit
Value
0-3
Number of animation frames for this graphic
4
Unused
5
Graphic has a horizontally mirrored/flipped version
6
Graphic has a left/right facing direction
7
Graphic is animated
Setting the scene(ry)
A standard room contains a few different elements:
Back and side wall/floor dividers
Vertical corner joints
Back wall decorations
Foreground scenery objects
Door frames and doors
There are different versions of each of these elements for the 'brick' styled levels and the 'cavern' style levels.
The first byte of the room's data at 25001 indicates the size of the room. For the starting room this byte value is 5, and can be used for the position of the room scenery:
Each of the right and left sides of the room can contain 2 elements, either a door or a side wall section. Two vertical connectors signify the corners of the room - their position is calculated based on room size.
In the above image, the room is the smallest possible (size = 5) and so the back wall only consists of 1 section. However, some rooms are long, scrolling horizontally across vast hallways. The flexible room data banks at 25001 allow for a variety of room types and elements.
The room attribute colour is calculated at 50747 and is based on the bits in the room number, with a few INK/PAPER combinations avoided.
The foreground scenery objects at 50433 for each room are selected using an algorithm using byte values contained in the Spectrum ROM. This saves memory while ensuring consistent foreground scenery for each game. The number of foreground scenery objects is based on the room's size divided by two.
Doors and brickwork
The data at 25001 - after the first byte holding room size - contains information about where to put DOORS and BRICKWORK patterns in any room, as well as the set number of the connecting door tables at 26512.
Each element is held in a pair of bits of information. These are checked in the routine at 49679. The 2 bits determine whether the item is a door (bit 0 set), brickwork (bit 1 set), or nothing (no bits set).
For example, here's room 6, in the Gatehouse Level:
That's two doors, and two bits of brickwork on the back wall.
The second row of this table is just an alternative representation of the data, with binary values for the 2nd and 3rd bytes.
The first byte indicates room size. In this case it's 8:
Two sections for the left wall (same for every room)
Two sections for the right wall (same for every room)
Four sections for the back wall (varies from room to room)
Starting from the far left-hand-side of the room, the Data 1 byte:
First (top) two bits = %01 - this signifies a door
Next two bits are = %00 - this signifies nothing, i.e. an empty bit of wall
Then onto the back wall - two more bits = %00 - another bit of empty wall
Finally (for this byte) - %10 - this indicates some brickwork
...That's taken us to the middle of the back wall - half the room in just one byte..!
Using a similar process for the Data 2 byte, we've got %00, %10, %01, %00. This translates to empty-brickwork-door-empty.
Maroc's rank
There are 8 x 16 = 128 possible ranks (29206), from APPRENTICE LORE SEEKER to SUPREME LORE LORD.
Maroc score is increased by killing creatures and descending into lower dungeon levels. His score determines his RANK, which is shown when he runs out of energy, or finishes the game.
Action
Points
Max points available
Destroying warlocks
4 * warlock number
112
Destroying (any number of) demons
32
32
Destroying any goblin, wraith, or guardian of chaos
This score is halved (= 112) and then added to Maroc's RANK. However, this means that the highest rank Maroc can attain - after destroying every creature in the game - is GUARDIAN OF LORE.
In the routine that determines the score however, there is another calculation; at 58619 three points are gained for every spell collected. There are 27 spells listed at 28156. This would allow Maroc to advance an extra (27*3)/2 = 40 ranks.
This is way too many. It'd probably take Maroc's rank way past SUPREME LORE LORD by the end of the game.
Fortunately this doesn't happen because there the score is (perhaps deliberately) reset at 58651 after calculating the 'score for spells' points. This means that acquired spells don't affect on Maroc's score/rank after all.
You can remove this score reset with POKE 58651,0, but this will probably result in bugs later in the game as Maroc will be able to advance past the highest rank listed.
** 30/11/2022 - Update note from Steve Turner ** (Twitter link):
"You can reach the highest rank, you need to kill all meanies, do all of the adventure events, trade with the warlords and the destroy them. I did it so there were a few points to spare."
I haven't checked how the rankings are calculated in Dragontorc, but in the generally available version of Avalon (used for this disassembly), the player doesn't gain any points from the puzzles/adventure events (action of one object on another), including trading with the warlocks.
It may be that there was a corrected version of Avalon released since. If so, the code for this version would need checking/disassembling to confirm this.
Maroc's sprite rotational movement
Maroc's sprite has 8-directional movement:
This movement is rotational. When a player presses keys or moves the joystick to move him about, rather than immediately switch his graphics frame to that direction, the sprite smoothly and incrementally rotates clockwise or anti-clockwise towards the new position.
Additionally, Maroc's sprite position above his (fixed) shadow rises and falls depending on his movement speed.
These elements are calculated in the routine at 54120. Small enhancements like these reduce jarring sprite movements and help the player work out Maroc's position in relation to the room, doors, objects etc.
Creatures spooked by Maroc's magic
Maroc can make creatures apprehensive if he wields powerful magic. For example, the routine at 53054 shows how goblin warriors can be scared of Maroc.
This isn't restricted to offensive spells, it can be any spell with number >=5 in the spell table at 28156.
In the example of the goblin warrior this is anything beyond the MISSILE spell, and can include other cursor-based spells, like the FIND spell (as shown in the animated image above).
You can even see this effect (to a lesser degree) by repeatedly casting a spell such as ENERGIZE (the 5th spell in the list). Although the effect is short (as the spell is an instant effect one), you can see a short creature reaction if cast repeatedly.
Unused rooms
In the room data table at 25001 there's capacity for up to 223 rooms. Rooms 224 - 255 are vertical scrolling tunnels.
It looks as if all these rooms were intended for used as "223 rooms" is mentioned on the Inlay back cover.
However:
Rooms 213 - 223 are unused. Their entries contain placeholder data giving them a size of 5 (the smallest room size), and no doors.
Similar data at the end of the room creature table at 27744 contains a placeholder byte of 85 for rooms 213 - 217 which puts those 3 creatures in these rooms
When Maroc casts WAYSTONE, there's a check at 55509 to see if Maroc's room number is less than 224, to prevent him teleporting from room 223 to 224, which would be a tunnel room
However, Maroc can cast WAYSTONE in the final room containing Avelach (room 212) to get to room 213. This is a small doorless room containing a goblin warrior, goblin missile thrower and guardian of chaos:
Maroc can continue to use WAYSTONE to jump to the consecutive (identical) unused rooms, until he gets to room 223. At this point the waystone check will prevent him moving any further.
After WAYSTONE-ing past the first 5 rooms (room creature data contains 3 creatures), there's no more creature data.
However, as we're still in the High Temple of Chaos, there's now space for a DEMON to materialize instead:
The jump from room 212 can be fixed (if you really want to fix it) with POKE 55514,212
This reduces the WAYSTONE maximum room number check from 223 to 212. Nothing will happen if Maroc casts WAYSTONE in the final room.
** 30/11/2022 - Update note from Steve Turner ** (Twitter link):
"The little rooms at the end were intentional. They were meant to be the demons cells and there to trap the player if he used the waystone to escape."
...If that's the case it's fairly evil on the part of the author, considering how near the end of the game the player is..! In reviews and features I haven't read much about using the WAYSTONE spell to bypass various obstacles, so it doesn't seem to have been a game mechanic picked up much by players.
At least the player can't get trapped in the demon's cells; they're likely to die fairly quickly and get put back in the start room.
Places of healing
There are SIX energy-restoration points scattered around Avalon's levels.
These places let Maroc heal without having to use spells - it helps the player preserve their ENERGIZE spell charges.
Some places are immediately accessible, others have to be activated in some way, or are behind locked doors that will need to be opened.
Gatehouse Level
The first point Maroc will encounter is the star marking on the floor on room 2, next to Maroc's starting location:
Maroc activates this floor marking with the STAR symbol (45332). The warlock on the Gatehouse Level carries this.
The quickest way for Maroc to get it is by trading the COINS (45357) from the chest in room 20 with the warlock.
Caverns of Doom
In the Caverns of Doom there's a patch of mushrooms in room 96, that can restore Maroc's energy:
The mushrooms work without Maroc having to do anything to them.
There's similar set of mushrooms in the Mines of Madness (room 120) that drain Maroc's energy, so the player may be wary of mushrooms if they've encountered these first.
Mines of Madness
There are no healing points in the Mines of Madness.
Great Halls of the Deep
There are TWO healing places in the Great Halls of the Deep.
There are some flames in room 77. These will heal Maroc if he moves over them:
There's an colour-changing orb/energy ball in room 40, behind a locked door.
If Maroc casts DISPEL on the BONE in room 38 (three rooms away) to get the flashing key, he can use it to open this door.
Goblin Warren
There are no healing points in the Goblin Warren.
However, Maroc can obtain the CHALICE spell (see Spells - CHALICE spell) on this level in room 150, which is effectively a portable energy point.
The Labyrinth
There's a healing orb under the trapdoor in room 159.
Maroc can open the trapdoor with a yellow key he finds in another trapdoor in the previous room (room 158). This will cause the orb to appear.
Catacombs of the Undead
There's a healing orb in room 190 on this level.
Two rooms away (room 188) there's a similar orb that drains Maroc's energy.
Chambers of Chaos and High Temple of Chaos
There are no healing points on either of these levels.