Showing posts with label Dunjonquest. Show all posts
Showing posts with label Dunjonquest. Show all posts

Tuesday, June 08, 2010

Hack Your Dunjonquest

My "map the Dunjonquest games" project was going fine until I hit level 8 of Hellfire Warrior. Not only does it feature some tricky "room connection" puzzles in the middle of the Great Plain, but it does not provide you with any room numbers. Even though I knew I'd still be able to solve the puzzle, it reduced my chances of ever being even remotely certain that the whole level was mapped. What would be the point of a half-assed job?

Well yeah, there'd be a point, but it would still be discouraging. So tonight I dove back into the Hellfire Warrior code -- which is very similar to the Temple of Apshai code -- and made a few changes.

Here are the things I've learned by poking around (literally). Some of them are generalizations based on Hellfire and Apshai that I haven't fully checked, so take them with a grain of salt.

The Files

"Temple of Apshai" contains the following files:

TEMPLE.PRG - The Innkeeper program
TEMPLE.DUN - The Dunjonmaster program
TEMPLE.PT1 to .PT7 - Files .PT3 to .PT6 are the data for levels 1-4, but the other .PT files are a mystery to me: character set data? Treasures? Traps? I haven't looked closely.

"Hellfire Warrior" is a bit more complicated, but the main files are:

INN - The Innkeeper program
DM - The Dunjonmaster program
HELLFIRE.5 to .8 - Levels 5 to 8.

There also appear to be different character sets for each level, and perhaps colour data for each level (since the levels ARE different colours).

The Code

The Innkeeper and Dunjonmaster programs are written in ATARI BASIC, with a few machine language routines that I think are for loading the custom character set and drawing the dungeon.

Here are some important things to remember when looking through the code.
  • It's atrocious. Just sayin'.
  • Variables that start with the letter U are really constants that represent numbers...U1 represents the number one, U10 represents ten, etc. This was a common way to conserve program memory, because the ATARI BASIC interpreter tokenized variables but treated every number as a separate piece of memory.
  • The code is full of PEEKs and POKEs, because all character and level data is stored directly to memory addresses, not usually -- as you'd expect -- in variables. This allows the data to persist when the Innkeeper switches to the Dunjonmaster and vice-versa, but it's extremely difficult to untangle.
  • Variable KA represents the memory address where the level data begins, and KB represents the address where the character data begins. In "Apshai," KA is page 103 (103*256) and KB is KA+2251.
  • Much character data is also mirrored in variables, and the program swaps between the variables and memory occasionally, which might explain some wacky behaviour.
  • Each level contains sixty (Q) rooms, but not all levels utilize every room. Judging by the file sizes (identical) I assume that the unused rooms are just full of padding.
Important Variables
  • L: Character level (see below).
  • O$: A string of all the commands that can be entered.
  • MSTR: The line number for monster routines (7000).
  • KF: The direction the character is facing (1 = up, 2 = right, 3 = down, 4 = left, I think).
  • YA: The character's vertical position.
  • XA: The character's horizontal position.
  • TA: Fatigue.
  • WC: Weight carried.
  • PC: Wounds.
  • PH: Maximum wounds.
Experience Points

One of the more mysterious aspects of both "Temple of Apshai" and "Hellfire Warrior" is how experience points are evaluated. You are told the number of points you have, and the "Book of Lore" says that you will benefit from a greater number of points, but it's difficult to figure out HOW.

Here's some insight. The programs DO check your "level" during combat, and characters with a higher level definitely get an edge in the calculations. Some stats also go up when you return to the Innkeeper with a higher level than you previous had (in a circuitous and bizarre chain of statements that I haven't bothered looking closely at).

How do you know when you've gone up a level? That would be nice to find out, wouldn't it? For some odd reason the programs never tell you, but the number of experience points you need to have for each level is 1000 times the square of the level number. So:

Level 1 = 2000
Level 2 = 4000
Level 3 = 9000
...
Level 20 = 400,000 etc.

The highest number of experience points you can get is 16,000,000.

Note that certain things in the game (like potions) can silently raise your stats, which might APPEAR to be a level bonus but isn't really. Also, "Hellfire Warrior" (at least the ATARI version) seems to have a bug where the Innkeeper gives you different numbers for your stats when you arrive from the ones you see when you return to the dungeon, and this discrepancy persists, as though the arrival stats are unmodified and the exit stats are modified by bonuses. Weird.

Important Line Numbers
  • 5000: Parses input at each turn.
  • 5100: Movement.
  • 5300 and higher: Other actions.
  • 7000: Monster stuff.
Unfortunately, many other routines -- various drawing and sound stuff, for instance -- is tucked away wherever it would fit. Lots of it is in the first hundred lines and is GOSUB'd to frequently. Presumably it's there because the earliest lines run fastest in ATARI BASIC.

Hacking the Program

It's easy enough to stop the program during operation (just press BREAK). To get back to the normal character set:

GRAPHICS 0

To reposition the coloured vertical bars (the remainder of the P/M graphics which represent you and a monster):

POKE 53248,0
POKE 53249,0

After you've made your changes, continue the program nicely with:

GOTO 5020

Make Mapping Easier

Here are some changes you can make to the "Hellfire Warrior" Dunjonmaster program to make mapping easier.

To force it to always print room numbers (which it skips for all levels numbered 6 and 8):

65 POSITION LS,U4:? "ROOM NO.:";

To always reveal a secret door when you (E)xamine a wall:

5701 IF PEEK(K+NT)=U3 THEN POKE K+NT,U2:RF(KF-U1)=U1:GOTO 5710

To always reveal traps when you (S)earch:

6300 IF PEEK(NP+KR)>U0 THEN GOSUB 670:GOSUB 679:GOTO MSTR

The last two might work in "Temple of Apshai" as well.

Saturday, May 01, 2010

Dunjonquest: The Curse of Ra

Rah rah rah! Here are the maps for the third and final expansion module in the original "Apshai" trilogy, "The Curse of Ra."

Level One: The Well of Forever


This simple level is a nice introduction to both the game and the overriding Egyptian theme, and it only gets hairy once you reach the pit.

Level Two: The Sphinx


No annoying riddles in this one. The actual MONSTER sphinx is something you meet right near the beginning. The fun part is enjoying their attempt at creating a level which is actually SHAPED like a sphinx, complete with paws, ears, and a tail.

Level Three: The Pyramid

And what a huge place it is, too! Here's the exterior and interior:


but you only reach those inner rooms when you go partway up and then return through the FIRST passage:
Compared to all the other levels, this one provides the most opportunities for increasing your stats (in the sandy rooms to the north). Watch out for the moving statues.

Level Four: Temple of Ra


Because the Apshai engine didn't allow for triggers or conditions of any kind, attempts to convey a complicated causal environment were bound to falter now and then...if you enter a room LATER that the level designers assumed you'd enter much EARLIER, for instance, you might read a room description that tries to evoke a progressive narrative by referring to a room you haven't been in yet. Causality gets reversed. It feels weird.

This is my way of saying that if you proceed through the levels in the way they HOPED you would, you'll feel nicely submerged in the action. If you DON'T, however, then you might feel like you're watching the episodes of a TV series in the wrong order.

Fortunately I played "Temple of Ra" in the "correct" way, so I was baffled by the "mysterious force" in the secret area following the Temple Room. I do suggest you play through the base of the Ra statue before going to the upper section.

And after you're done...that's it for "Temple of Apshai!" But don't despair, the "Hellfire Warrior" sequel comes next.

Saturday, April 24, 2010

Dunjonquest: The Upper Reaches of Apshai

(See this post for background on what I'm talking about here)

Give some creative and intelligent people a framework for creating games, and before long they'll figure out how to do tricks that are far beyond the original specifications. "Temple of Apshai" may have kept rigidly within the Dunjonquest engine's parameters, but "Upper Reaches of Apshai" has the software jumping through hoops.

Specifically, they've realized three things:
  1. Rooms can overlap. Because each room's data is totally discreet -- not being part of a single large structure -- you can create a multi-leveled effect. This is first seen in the spiral staircase of level four, "Benedic's Monestery."
  2. Adjacent doors don't have to have the same connections. This is first seen in "Merlis' Hall of Magic," (level 2) where returning through a door takes you to a room that LOOKS identical but is totally different (and might have different exits, secret doors, etc.) This adds a whole new dimension to the game, allowing rooms to "change" depending on how you enter them.
  3. The other effect of disconnected doors is the simple one-way exit, fully exploited in the "cave ins" within "Olias' Cellar" (level 3). It's easy but effective: walk through a door, and the next room doesn't have a door that goes back in the opposite direction.
  4. Finally, the most maddening and subtle trick of them all: the "two rooms appear to be one room" trick. Because all Dunjonquest rooms must be rectangular, you begin to assume that every rectangle is a single room...you check for secret doors within a room and then you walk out. But by creating two adjacent rooms, each with only three walls, the level creators can make a "hidden" room that is only visible when you cross the midpoint. A treasure might be in that room, or -- in the case of the "bear cave" in "Olias' Cellar" -- a secret door that cannot be detected until you cross the room.
What amazes me about these games is how polished they are. Each time I find that I've missed a room or a treasure, my first thought is that I've encountered a bug, but no...after diligent searching I realize that I didn't find what I was looking for because the level designers wanted me to WORK HARD.

That said, I think there IS a bug in "Olias' Cellar," involving a secret door in room 19 that leads to a corridor section (15) which overlaps another corridor section (20) but shares the same exits. Nothing in the text explains why this happens, so I suspect the design was glitchy and they just left it in.

(I also think there's a missing treasure in the final level of "Curse of Ra," but I'll get to that next time).

Anyway, here are the levels for "The Upper Reaches of Apshai."

Level One: The Innkeeper's Backyard



Level Two: Merlis' Cottage



Level 3: Olias' Cellar



Level Four: Benedics Monastery


Besides the innovations in the room connections, these levels are more fun to play because they're coherent. They have interesting backstories and little mysteries which go far beyond the "kill monsters and find treasures" plots of "Temple." More importantly, these levels tend to be FUNNY. There are actually JOKES in them. Rather than endlessly fighting motivationless Antmen ("Oh no! Antmen") you are meeting vicious farmyard animals ("Oh no! Goose!") and doing your darnedest to vanquish the Creeping Crud.

Tuesday, April 20, 2010

Dunjonquest: Temple of Apshai

I have so many guilty pleasures that I'm in a permanent state of mortification, and one of my pleasures is a good old-fashioned dungeon crawl. It's not because I love killing monsters and collecting treasures; the actual BULK of a dungeon crawl game is incidental to me. What I REALLY like to do is to EXPLORE.

I've always gotten a thrill out of mazes, tunnels, and imaginary digital worlds. Unfortunately there are few games that are simply about exploring...pissy monsters are always attacking you and you have to solve anachronous "eight queens" puzzles at every second step. I'm of the opinion that the world (the real one) is waiting for a computer simulation of a rich landscape that doesn't necessarily have anybody else in it. The fact that I'd enjoy such a thing is creepy, really.

But anyway, my favourite games as a teenager were the ones where you could wander around a maze and map it, and then stare for hours at the map wondering what sort of cool place it would be to live in. Unfortunately back then I had a very low threshold for frustration, so I rarely succeeded in finishing the games that were so fun to explore: Ultima, The Eidolon, Alternate Reality, and...

...the Dunjonquest series, considered to be the first dungeon crawls for the 8-bit home computers. Originally developed by Jon Freeman (who is most idolized these days as being one of the creators of Archon) for his fledgling Automated Simulations company (likewise most idolized for later becoming Epyx), these games were all about wandering around mazes, killing monsters, raising your stats, collecting treasures, and running from Antmen who apparently used a vanilla-scented body lotion.

The Dunjonquest game that most people remember is "Temple of Apshai" and its two sequels, "Upper Reaches of Apshai" and "Curse of Ra." These three games -- like the "Hellfire Warrior" trilogy that followed them -- presented you with a very basic depiction of your surroundings, requiring you to actually read the room descriptions from the accompanying manual (or "Book of Lore.")

Originally written in BASIC in 1979, the first games required a great deal of patience and imagination, and the subsequent games -- with the exception of "Gateway to Apshai," a very different arcade-style adventure -- used the same engine. Even when the Apshai games were eventually released as a re-written, integrated, machine-language "Temple of Apshai Trilogy" -- the way most people remember them -- you still needed to shuffle your little character along featureless corridors, bumping into walls and slaying barely-animated 4-colour monsters.

So Dunjonquest games don't have a lot of appeal to gamers these days, and they've slowly faded away from the eyes of even the most nostalgic 8-bit fans.

Until now!

I'm happy to say I'm not alone in my love of these games, and I've been collaborating with Robinson Mason -- and scrounging the darkest corners of the internet -- to reclaim the programs. And not just the programs, but also the even more rare "Books of Lore" which are both essential for play and a delight to read.

While my compatriot tirelessly unearths more of the games and materials, I've been concentrating on reverse-engineering the BASIC code and mapping all the levels. I've discovered some interesting things buried in the convoluted rats-nest of oddly-ported BASIC, but that will come later. Right now, here are maps for the four levels of the first game, "Temple of Apshai."

I decided not to include room numbers, traps, or treasures -- that would not only clutter up my tiny drawings but would also spoil more of the game. And I make no claims to the 100% accuracy of these maps; they are complete and fully-connected, but their proportions may be slightly off. Click on an image to see a larger version.

Temple of Apshai - Level One


Temple of Apshai - Level Two


Temple of Apshai - Level Three


Temple of Apshai - Level Four


The maps for the next game ("Upper Reaches of Apshai") are coming soon (along with playing tips), and I expect there'll be a resource site starting up eventually. Until then, spare a thought to all those digital worlds that are locked up in decaying floppy disks in attics and basements, and consider rescuing them for one last time.