Darendor wrote:So, this is what we've found:
- each special that runs the disk drive is loading a file: "NMXX.PRG"; true or false?
True. I modified my text-dumping program to pull all the text from every NMXX file. The dungeon specials start in file NM1F.PRG, the stairs that go a long way up, and run consecutively up to NM44.PRG, Mangar's Antechamber. But I've so far been unable to make sense of the file pointers contained in the dungeon data.
For example, the pointer for the NM1F.PRG program (the long stairway) is 10. This seems easy: just add f to the pointer. This works fine throughout the cellars. But in the catacombs, it stops working. Bashar Kalivor is in program NM23, so using our formula we expect the pointer say 14. But it doesn't--the pointer says 16. It's off by +2. In the Castle, things are again different. The old man's riddle on the second level is in NM2A. So the pointer should be 1B. But it's really 1c, off by -1.
I'm going to have to go through and notate them each with their file pointer, and maybe eventually it'll make sense.
- When the player trips a special, it looks at a memory location for that special. I'm still not crystal clear on this bit.
To simplify things as much as possible, let's consider a four-tile dungeon, with a correspondingly tiny memory map.
The map is stored at 00, and take up four bytes. Our map is just a square dungeon like this. It contains the stairs in with a welcome message, a dastardly anti-magic and darkness zone, 1 spinner, and a special that runs a program to award 500,000 xp to all your characters.
Code: Select all
+--+--+
|A/ @|
+ +
|^s s0|
+--+--+
Using lookup tables I posted elsewhere, we must encode the map at location 00. The map is stored from bottom left to top right, proceeding right and upwards.
That binary code for that map is 0100 0100 0001 0100 0100 0001 0001 0001, or, in hex:
00: 88 18 81 11
Next, there's the array of special features, one byte per tile. That's not enough to store every kind of feature you might like, but it does encode stairs, darkness, traps, portals, and treasure chests. Each feature is stored in one bit. Also, there's a flag set if something other than those features encoded here--these are all detected as "something special is near" by the SESI effect. The tiles are stored in the same order.
The first tile has stairs up and an "other special"--the welcome message. That sets bit 0 for the stairs up, and bit 2 for the special.
The second tile has just an "other special". So we set bit 2.
The top left tile has Anti-magic, which is
also an "other special", and darkness, which we encode directly. So we set bit 2, for other, and bit 3 for darkness.
The top right tile has a spinner, and that's an "other special," too.
So our next four binary patterns look like this:
00000101 00000100 00001100 0000100
or in hex
04: 05 04 0b 04
So now we need somewhere to store which remaining special is which. The game uses a set of lists of coordinates so it can tell.
First, is a list of coordinates of special programs to pull from disk. This dungeon needs only one program, the one that awards bonus xp, but there are room for as many as four. The coordinates of that tile are 0N, 1E, so we get:
08: 00 01 ff ff ff ff ff ff
The remaining, empty, slots for programs are padded with ff.
Below that, we store the pointers to the programs on disk. For the sake of example, xp award is progam 1.
10: 01 ff ff ff ff ff ff ff
Next down is a list of the coordinates of Anti-magic zones. We have one at 1N, 0E.
18: 01 00 ff ff ff ff ff ff
Next down is the list of teleporters, and then a list of destinations. We don't have any of either.
20: ff ff ff ff ff ff ff ff
28: ff ff ff ff ff ff ff ff
Next down are the location of up to four spinners. We have one at 1N, 1E:
30: 01 01 ff ff ff ff ff ff
Next comes three empty tables for HP drains, SP recharge, and tiles where you get stuck.
38: ff ff ff ff ff ff ff ff
40: ff ff ff ff ff ff ff ff
48: ff ff ff ff ff ff ff ff
Next comes a list of message coordinates. We have a message at 0N, 0E.
50: 00 00 ff ff ff ff ff ff
Next comes a list of monster coordinates. We don't have any set monster encounters, so it's empty. Below it is a table of which monster is actually supposed to be encountered at the corresponding tile, and how many. But this is blank, too.
58: ff ff ff ff ff ff ff ff
60: ff ff ff ff ff ff ff ff
Finally, the special message text appears. We have just one message.
68: <some BTSCII text encoding a welcome message, terminated by dc>
So here's the whole dungeon, in roughly 120 bytes:
Code: Select all
00: 88 18 81 11 05 04 0b 04
08: 00 01 ff ff ff ff ff ff
10: 01 ff ff ff ff ff ff ff
18: 01 00 ff ff ff ff ff ff
20: ff ff ff ff ff ff ff ff
28: ff ff ff ff ff ff ff ff
30: 01 01 ff ff ff ff ff ff
38: ff ff ff ff ff ff ff ff
40: ff ff ff ff ff ff ff ff
48: ff ff ff ff ff ff ff ff
50: 00 00 ff ff ff ff ff ff
58: ff ff ff ff ff ff ff ff
60: ff ff ff ff ff ff ff ff
68: <some BTSCII text encoding a welcome message, terminated by dc>
As you walk around our little map, the game draws the screen and prevents you from walking through walls by looking at the 4 bytes at 00.
It also keeps track of the feature list at 04, so that SESI works right.
Let's say you just entered. The game checks location 04, the feature table, and sees there are stairs here, and a special.
On the C64, this means it first asks if you'd like to take the stairs out. If you don't, then it looks up the coordinates 0N, 0E in our little set of tables. It finds 00 00 at location 50, and knows this means it's a message. Since it's the first coordinate in the list, it looks up and prints the first message found at location 68.
Now you walk north. Oops! The game finds that the darkness flag is set, and turns out the light. It also sees the "other" flag, and so looks for 1N, 0E in the set of lists. It finds it in the memory location reserved for Anti-magic, and turns off all your spells.
So you quickly turn around, and go back south. You see the stairs and the welcome message again, and cast your spells again. Now you head east. When you walk here, the program sees that there's a special here (by checking the feature table), and looks up the coordinates in the set of tables. It finds them at 08, and knows this means it is to run a special program. Since this is the first coordinate, it looks up the first file pointer at 10, 01. So it runs NM01.PRG. Viola! You are 500,000 xp more awesome!