Ultima II Dungeon Format

From ModdingWiki
Jump to: navigation, search
Ultima II Dungeon Format
Ultima II Dungeon Format.png
Format typeMap/level
Map type2D tile-based
Layer count1
Tile size (pixels)N/A
Viewport (pixels)N/A
Games

Ultima II: Revenge of the Enchantress has several dungeon maps. Dungeon maps are those map files which end in 4 or 5, all other maps are planets or towns. Dungeon maps are 16×16 tiles and 16 levels deep.

File Format

Dungeons are stored in a string of 4,096 bytes where each byte represents a tile id. There are only eight different tiles used in dungeon maps, the index numbers only the high nibble, and not all possible values are used.

Data type Name Description
UINT8[4,096] Tile Id The tile id for each tile in the map.

Tile Data

Tile Id Tile Description
0x00 Floor
0x10 Ladder Up
0x20 Ladder Down
0x30 Ladder Up/Down
0x40 Chest
0x80 Wall
0xC0 Door
0xE0 Secret Door

Source Code

Map Viewer

This FreeBASIC program displays all the dungeon levels of the specified map.

' Draws the maps of Ultima II dungeons.
 
' Change the file path to the dungeon you want.
' File names ending with a 4 or 5 are dungeon maps.
Dim As String FilePath = "H:\DOS\Ultima2\mapx24"
 
Screen 13
 
Dim As UByte Map
Dim As UByte X
Dim As UByte Y
Dim As UByte TileNumber
 
' Open the map file.
Open FilePath For Binary As #1
 
Color 8
Locate 3, 23: Print Chr(177)
Color 6
Locate 7, 23: Print Chr(219)
Color 9
Locate 9, 23: Print Chr(219)
Color 10
Locate 11, 23: Print "$"
Color 14
Locate 13, 23: Print Chr(24)
Locate 15, 23: Print Chr(25)
Locate 17, 23: Print Chr(18)
 
Color 15
Locate 3, 25: Print "- Wall"
Locate 5, 25: Print "- Floor"
Locate 7, 25: Print "- Door"
Locate 9, 25: Print "- Secret Door"
Locate 11, 25: Print "- Chest"
Locate 13, 25: Print "- Ladder Up"
Locate 15, 25: Print "- Ladder Down"
Locate 17, 25: Print "- Up/Down"
 
Line (15, 15)-(144, 144), 7, B
 
' Load the entire map, and draw the appropriate tiles.
For Map = 0 To 15
    For Y = 0 To 15
        For X = 0 To 15
            Get #1, , TileNumber
 
            Locate Y + 3, X + 3
            Select Case TileNumber
            Case &h00       ' Floor
                Color 0
                Print " "
            Case &h10       ' Ladder Up
                Color 14
                Print Chr(24)
            Case &h20       ' Ladder Down
                Color 14
                Print Chr(25)
            Case &h30       ' Ladder Up/Down
                Color 14
                Print Chr(18)
            Case &h40       ' Chest
                Color 10
                Print "$"
            Case &h80       ' Wall
                Color 8
                Print Chr(177)
            Case &hC0       ' Door
                Color 6
                Print Chr(219)
            Case &hE0       ' Secret Door
                Color 9
                Print Chr(219)
            End Select
        Next X
    Next Y
 
    Color 15
    Locate 23, 3: Print "Floor: " + Str(Map)
 
    Sleep
Next Map
 
Close #1

Credits

This map format was reverse engineered by TheAlmightyGuru. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)