Bwa-hahahaha!
Bwa-hahahaha!
I believe I've successfully found where the current dungeon map is stored in memory on the C64 version of the game, and I've almost completely deciphered the format of the map data. It's very similar to what I was speculating.
When a dungeon is in memory, it's stored at $f800. There's one byte of data per dungeon square, so 482 bytes. The dungeon is mapped starting at 0N, 0E, and the rows go across to the east, with the more northern rows following.
This is for the map only. More work is needed for locating darkness, specials, stairs, traps, etc. The specials data seems to be located elsewhere in memory, though I have suspects, as before.
A simple plotting program could draw perfect BT maps of the walls, doors and secret doors using just the information I have now.
More details after lunch.
When a dungeon is in memory, it's stored at $f800. There's one byte of data per dungeon square, so 482 bytes. The dungeon is mapped starting at 0N, 0E, and the rows go across to the east, with the more northern rows following.
This is for the map only. More work is needed for locating darkness, specials, stairs, traps, etc. The specials data seems to be located elsewhere in memory, though I have suspects, as before.
A simple plotting program could draw perfect BT maps of the walls, doors and secret doors using just the information I have now.
More details after lunch.
Death and drek? WTF?
As I said above, there's one byte per map square. The byte is split into four two-bit fields, one for each cardinal direction, using the following encoding:
00 -> Nothing
01 -> Wall
10 -> Door
11 -> Secret Door
I have not verified the last one yet, but I will as soon as I study a map containing some known secret doors. There's nothing with that encoding in The Cellars of the Scarlet Bard.
The fields are stored in the following order: West, East, South, North.
The first room, 0N, 0E in The Cellars has a wall to the west and south, so its byte value is:
The next byte in the data file is the square at 0N, 1E, and has a wall to the east and south.
So the first two bytes of data at address $fb00 in memory are $4414.
You can see how the possibility of one-way doors and walls springs forth from this storage scheme.
Now I must decide what to do with this information.
Incidentally, I've verified that the map is stored verbatim on the dungeon disk--there's no compression used. Puzzle and hint texts are obfuscated though, even in memory. I guess MC didn't want anybody with a 64mon cartridge spoiling their fun.
00 -> Nothing
01 -> Wall
10 -> Door
11 -> Secret Door
I have not verified the last one yet, but I will as soon as I study a map containing some known secret doors. There's nothing with that encoding in The Cellars of the Scarlet Bard.
The fields are stored in the following order: West, East, South, North.
The first room, 0N, 0E in The Cellars has a wall to the west and south, so its byte value is:
Code: Select all
W E S N
01 00 01 00
4 4 (in hex)
Code: Select all
W E S N
00 01 01 00
1 4 (in hex)
You can see how the possibility of one-way doors and walls springs forth from this storage scheme.
Now I must decide what to do with this information.
Incidentally, I've verified that the map is stored verbatim on the dungeon disk--there's no compression used. Puzzle and hint texts are obfuscated though, even in memory. I guess MC didn't want anybody with a 64mon cartridge spoiling their fun.
Death and drek? WTF?
Alright, so go to the Wine Cellar, face west, then pause your emulator by starting the ML monitor. Change the "W" byte to 10 (whatever it works out to be in hexadecimal) and exit the monitor and see if a door appears.Horpner wrote:As I said above, there's one byte per map square. The byte is split into four two-bit fields, one for each cardinal direction, using the following encoding:
00 -> Nothing
01 -> Wall
10 -> Door
11 -> Secret Door
I have not verified the last one yet, but I will as soon as I study a map containing some known secret doors. There's nothing with that encoding in The Cellars of the Scarlet Bard.
The fields are stored in the following order: West, East, South, North.
The first room, 0N, 0E in The Cellars has a wall to the west and south, so its byte value is:
The next byte in the data file is the square at 0N, 1E, and has a wall to the east and south.Code: Select all
W E S N 01 00 01 00 4 4 (in hex)
So the first two bytes of data at address $fb00 in memory are $4414.Code: Select all
W E S N 00 01 01 00 1 4 (in hex)
You can see how the possibility of one-way doors and walls springs forth from this storage scheme.
Now I must decide what to do with this information.
Incidentally, I've verified that the map is stored verbatim on the dungeon disk--there's no compression used. Puzzle and hint texts are obfuscated though, even in memory. I guess MC didn't want anybody with a 64mon cartridge spoiling their fun.
- dragonbait
- Posts: 124
- Joined: Tue May 15, 2007 12:21 am
- Location: Under the Ruins of Yulash
Using CCS64, I succeeded in creating a wall west from 0N, 1E in the cellars. It was one-way, of coures, because I didn't make a wall east of 0N, 0E.Darendor wrote: Alright, so go to the Wine Cellar, face west, then pause your emulator by starting the ML monitor. Change the "W" byte to 10 (whatever it works out to be in hexadecimal) and exit the monitor and see if a door appears.
This is powerful enough to allow us to enter any square in any dungeon. I don't know how portable the information will turn out to be, though.
It brings us a step closer to being able to design a dungeon that the original program could run. It just remains to be seen how hard it will be to compose our own specials.
I'll post in the BTCS forum when I'm finished learning as much as I can. I've found where stairs, traps, pre-set random encounters, and specials are flagged. Discovering how specials are stored is going to require some actual disassembling... I've managed to avoid it so far.
It might be more worth the effort to reverse engineer bt2 than this game, though.
Death and drek? WTF?
I successfully modified a bt1 dungeon disk so that there's a secret door to the west from the first square of the cellars (and one back again--it wouldn't do to get stuck in there with a party without PHDO). Secret doors are indeed stored as the bit pattern "11".
Last edited by Horpner on Mon Jan 26, 2009 11:26 pm, edited 1 time in total.
Death and drek? WTF?
Yes, I hate those squares, too. There's a magic mouth that actually cancels the whole spell in the first level of Oscon's Fortress.Darendor wrote:I agree that reverse-engineering BTII would be more worthwhile since it's a more advanced engine.
You do realize that there's "Odd..." square in BTII that disable the party's "eye" spell, meaning doors that are secret become hidden again and such?
Death and drek? WTF?
They are one after the other, starting at $f800 (in memory).
22 bytes per row, with the southern-most row first.
The next row up is next, and so forth.
On the disk, they could be anywhere. I modified the .d64 image directly, so I don't know precisely which track and sector the first dungeon is stored on. I'll have time to find out tomorrow, though, and can let you know. However, I can tell you that the bytes are arranged just the same on the diskette.
22 bytes per row, with the southern-most row first.
The next row up is next, and so forth.
On the disk, they could be anywhere. I modified the .d64 image directly, so I don't know precisely which track and sector the first dungeon is stored on. I'll have time to find out tomorrow, though, and can let you know. However, I can tell you that the bytes are arranged just the same on the diskette.
Death and drek? WTF?