Bwa-hahahaha!

Any developer realated stuff
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

Horpner wrote: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.
How did you modify the disk image? I tried to no avail (mostly because I'm inept)... :?

Coming soon - BTCS for the C64 by Horpner. :? 8)
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

So I took it upon myself to map out all squares to their corresponding locations in memory.

So far, it looks like this. Can you tell me if it's going in the right direction?
Image
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

I'm at the entry stairs of the Wine Cellar, and the monitor in WinVICE is giving me:

Code: Select all

C:f800  c4 14 45 05   05 05 05 05   05 05 05 05   05 05 05 05   05 05 05 05   05 34 41 00   . . E . . . . . . . . . . . . . . . . . . 4 A .
The next address is "C:f818", not f801 as I expected...what's this all mean?
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

I think each location stores TWO squares (east-west), not one on its own.

For instance $F800 seems to hold 0N, 0E and 0N, 1E.

Do you concur?
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

I've cracked something here.

Each address represents the west-east row.

Consider $F800. It has (referring to your hacked disk where you put in the secret door) the following bits/bytes/whatever they're called:

Code: Select all

 C:f800  c4 14 45 05   05 05 05 05   05 05 05 05   05 05 05 05   05 05 05 05   05 34 41 00
Now, if you take each value and put it into a hex-to-binary converter, you get the binary codes.

Thusly:

WESN

11 00 01 00
c4
0N, 0E:[Secret door to the west, wall to the south]

00010100
14
0N, 1E:[Wall to the east, wall to the south]

01000101
45
0N, 2E:[Wall to the west, wall to the south, wall to the north]

0101
05
0N, 3E:[Wall to north, wall to south]; not sure why "00" is omitted for west and east...]

0101
05
0N, 4E - 0N, 20E: [Wall to north, wall to south]

00110100
34
0N, 21E: [Secret door to the east, wall to the south]

The last two bits (41, 00) I have no idea about.
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

0N, 0E through to 0N, 21E takes up locations $F800, $F808 and the first 6 bits of $F810. Bit 7 starts 1N, 0E with the value 41 (indicating a wall to the north and west) and the 8th bit indicates 00 at 1N, 1E, meaning nothing at all (this is where the first special is, welcoming players to the dungeon).
Memory location $F818 continues at 1N, 3E and so forth.

This ought to be interesting... :?
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

The map takes up memory locations: $F800 to $F9E0 (first 4 bits).

Thusly:
Image
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

And finally, the maps for Bard's Tale II appear to not be in the same location in memory as for I. :?
User avatar
Horpner
Posts: 224
Joined: Thu Jan 08, 2009 11:53 pm
Location: New England
Contact:

Post by Horpner »

Darendor wrote:Now, if you take each value and put it into a hex-to-binary converter, you get the binary codes.

Thusly:

WESN

11 00 01 00
c4
0N, 0E:[Secret door to the west, wall to the south]

00010100
14
0N, 1E:[Wall to the east, wall to the south]

01000101
45
0N, 2E:[Wall to the west, wall to the south, wall to the north]

0101
05
0N, 3E:[Wall to north, wall to south]; not sure why "00" is omitted for west and east...]
The converter just didn't display leading zeroes. After all, 00000101 has the same value as 101.
Death and drek? WTF?
User avatar
Horpner
Posts: 224
Joined: Thu Jan 08, 2009 11:53 pm
Location: New England
Contact:

Post by Horpner »

Darendor wrote:I think each location stores TWO squares (east-west), not one on its own.

For instance $F800 seems to hold 0N, 0E and 0N, 1E.

Do you concur?
It's just a slight confusion about byte size.

If you use the monitor, and enter m f800, you get something like

Code: Select all

f800: C414 4105 0505 0505
It's only four groups, but each group is two bytes. Grouped by bytes, it's:

f800: c4 14 41 05 05 05 05 05
Death and drek? WTF?
User avatar
Horpner
Posts: 224
Joined: Thu Jan 08, 2009 11:53 pm
Location: New England
Contact:

Post by Horpner »

Darendor wrote:How did you modify the disk image? I tried to no avail (mostly because I'm inept)... :?

Coming soon - BTCS for the C64 by Horpner. :? 8)
The correct way will be to modify it inside the emulator, using Mr. Nibble or some such sector editing utility. But first I have to figure out where the data resides using that addressing scheme.

I edited the disk using Vim, a text editor. I piped the entire file through xxd to translate it into a text representation, made my modifications, and then used xxd -r to translate it back.

You'll have to install Vim to get xxd, but you can use xxd without using Vim.

Using xxd.exe and the Windows command prompt:

c:\> xxd BT1_Dung.d64 BT1_Dung.txd

That makes a human-editable text file version of the dungeon disk. Edit Bt1_Dung.txd with your favorite text editor.

Search for the string of bytes that indicate the start of the dungeon you're looking for. You have to know the first several bytes in order to have a good chance of finding it.

I found The Cellars here on the version of the dungeon disk I have:

0009c00: 0818 0040 4414 4505 0505 0505 0505 0505 ...@D.E.....

If you use my modified disk, it'll say c414 4505 etc.

So you can see that The Cellars' map data starts at 4414. Carefully edit the hex data. For example, to make a secret door west from the start, I changed the above to:

0009c00: 0818 0040 c414 4505 0505 0505 05050505 ...@D.E.....

Note that I don't have to change the ASCII representation that's hanging off to the right. That's just for informational purposes.

Save it and exit.

Now reverse the xxd program to turn it back into a binary file.

C:\> xxd -r BT1_Dung.txd BT1_DungMod.d64

That commdn translates BT1_Dung.txd back into a binary file, which we call BT1_DungMod.d64.

Don't overwrite your original dungeon disk, because it's easy to make a mistake that renders your modified disk unusable. My first few tries were failures due to editor settings.

An editing tool designed to modify dungeons could probably work directly on d64 images, and make all the modifications in the background.
Death and drek? WTF?
User avatar
Horpner
Posts: 224
Joined: Thu Jan 08, 2009 11:53 pm
Location: New England
Contact:

Post by Horpner »

Here's the translation table I promised.

Translation table:

Each map tile's wall, door and secret door configuration is
encoded in two hex digits, i.e., one byte.

Code: Select all

 
  FIRST HEX DIGIT

      Binary
  Hex W  E    Result
  0 : 00 00 : nothing.
  1 : 00 01 : wall east
  2 : 00 10 : door east
  3 : 00 11 : secret door east
  4 : 01 00 : wall west 
  5 : 01 01 : walls west and east
  6 : 01 10 : wall west, door east
  7 : 01 11 : wall west, secret door east
  8 : 10 00 : door west
  9 : 10 01 : door west, wall east
  A : 10 10 : door west, door east
  B : 10 11 : door west, secret door east
  C : 11 00 : secret door west
  D : 11 01 : secret door west, wall east
  E : 11 10 : secret door west, door east
  F : 11 11 : secret door west, secret door east

  SECOND HEX DIGIT

      Binary
  Hex S  N    Result
  0 : 00 00 : nothing.
  1 : 00 01 : wall north
  2 : 00 10 : door north
  3 : 00 11 : secret door north
  4 : 01 00 : wall south 
  5 : 01 01 : walls south and north
  6 : 01 10 : wall south, door north
  7 : 01 11 : wall south, secret door north
  8 : 10 00 : door south
  9 : 10 01 : door south, wall north
  A : 10 10 : door south, door north
  B : 10 11 : door south, secret door north
  C : 11 00 : secret door south
  D : 11 01 : secret door south, wall north
  E : 11 10 : secret door south, door north
  F : 11 11 : secret door south, secret door north
So let's say you want a tile like this:

Code: Select all

  +  +
  #  |
  +ss+
For those who don't read my stinky ascii art, that's a door to the west, a secret door to the south, and a wall to the east.

For the first digit, I want a door west, and wall east. So that's hex digit 9.

For the second digit, I want a secret door south, so that's hex digit C.

Putting it together, the first byte, which corresponds to the picture above, is: 9C

Let's do one more example, an actual tile from an actual dungeon.

0N, 0E in the first level of The Sewers looks like this:

Code: Select all

  +--+
  |  #
  +--+
The first digit should be a wall west, and a door east. That's A.

The second digit should be walls south and north. That's 6.

So we know that the first level of the sewers starts with A6.
Death and drek? WTF?
User avatar
Horpner
Posts: 224
Joined: Thu Jan 08, 2009 11:53 pm
Location: New England
Contact:

Post by Horpner »

Darendor wrote:And finally, the maps for Bard's Tale II appear to not be in the same location in memory as for I. :?
I'm fairly comfortable assuming he used the same encoding scheme. I should be able to find the map for BT2 by examining a memory dump.
Death and drek? WTF?
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

There's more than 26 (or 27) files on the dungeon disk. Which filenames correspond to the dungeon maps themselves and which ones correspond to data files (such as say magic mouths and old men selling keys and such)?
User avatar
Darendor
Posts: 1503
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Post by Darendor »

XXD doesn't work.
Horpner wrote:
Darendor wrote:How did you modify the disk image? I tried to no avail (mostly because I'm inept)... :?

Coming soon - BTCS for the C64 by Horpner. :? 8)
The correct way will be to modify it inside the emulator, using Mr. Nibble or some such sector editing utility. But first I have to figure out where the data resides using that addressing scheme.

I edited the disk using Vim, a text editor. I piped the entire file through xxd to translate it into a text representation, made my modifications, and then used xxd -r to translate it back.

You'll have to install Vim to get xxd, but you can use xxd without using Vim.

Using xxd.exe and the Windows command prompt:

c:\> xxd BT1_Dung.d64 BT1_Dung.txd

That makes a human-editable text file version of the dungeon disk. Edit Bt1_Dung.txd with your favorite text editor.

Search for the string of bytes that indicate the start of the dungeon you're looking for. You have to know the first several bytes in order to have a good chance of finding it.

I found The Cellars here on the version of the dungeon disk I have:

0009c00: 0818 0040 4414 4505 0505 0505 0505 0505 ...@D.E.....

If you use my modified disk, it'll say c414 4505 etc.

So you can see that The Cellars' map data starts at 4414. Carefully edit the hex data. For example, to make a secret door west from the start, I changed the above to:

0009c00: 0818 0040 c414 4505 0505 0505 05050505 ...@D.E.....

Note that I don't have to change the ASCII representation that's hanging off to the right. That's just for informational purposes.

Save it and exit.

Now reverse the xxd program to turn it back into a binary file.

C:\> xxd -r BT1_Dung.txd BT1_DungMod.d64

That commdn translates BT1_Dung.txd back into a binary file, which we call BT1_DungMod.d64.

Don't overwrite your original dungeon disk, because it's easy to make a mistake that renders your modified disk unusable. My first few tries were failures due to editor settings.

An editing tool designed to modify dungeons could probably work directly on d64 images, and make all the modifications in the background.
Post Reply