waddle-0.1.0.6: DOOM WAD file utilities.

Copyright(c) 2015 Martin Grabmueller
LicenseBSD3
Maintainermartin@grabmueller.de
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Game.Waddle.Types

Contents

Description

All public data types used by the Waddle library. The Wad type is a good entry point into understanding the types.

I recommend the Unofficial Doom Specification by Matthew S Fell, available at http://aiforge.net/test/wadview/dmspec16.txt and the Doom Wiki at http://doomwiki.org for details.

Synopsis

Exceptions

data WadException Source

Exception thrown when reading and decoding WAD files.

Constructors

WadExceptionFormatError String String

General WAD file format error. The first string is the context where the error occured, the second contains details on the error.

WadExceptionDecodeError String String

Decoding of the general WAD format or individual lumps failed. The first string is the context where the error occured, the second contains details on the error.

WAD file structures

data Wad Source

WAD structure, including the file contents and decoded common lumps.

Constructors

Wad 

Fields

wadHeader :: WadHeader

WAD header.

wadDirectory :: [WadEntry]

All WAD directory entries, in the same order as in the file.

wadLumps :: [ByteString]

All WAD lumps, each entry matching the corresponding entry in wadDirectory.

wadLumpLookup :: Map (CI LumpName) ByteString

Mapping from lump names to lump content.

wadFlats :: Map (CI LumpName) Flat

Mapping from lump names to flats (floors and ceilings).

wadSprites :: Map (CI LumpName) Sprite

Mapping from lump names to sprites (monsters and things).

wadPatches :: Map (CI LumpName) Patch

Mapping from lump names to patches (parts of wall textures).

wadTextures :: Map (CI LumpName) Texture

Mapping from lump names to wall textures.

wadLevels :: Map (CI LumpName) Level

Mapping from lump names to levels.

wadPNames :: Map Int LumpName

Mapping from patch indices to patch names.

wadColormap :: Maybe Colormap

WAD colormap for mapping palette entries according to light levels.

wadPalettes :: Maybe Palettes

Palettes for mapping color indices to RGB tuples.

type LumpName = ByteString Source

Lump name. This is at mot 8 bytes long, and internally, all trailing NULs are stripped.

data WadHeader Source

WAD file header.

Constructors

WadHeader 

Fields

wadHeaderIdentifier :: ByteString

Normally "IWAD" or "PWAD", always of length 4.

wadHeaderLumpCount :: Int32

Number of lumps in the file.

wadHeaderDirectoryOffset :: Int32

Byte offset (relative to beginning of the file) of the WAD directory.

data WadEntry Source

Entry in WAd directory.

Constructors

WadEntry 

Fields

wadEntryOffset :: Int32

Offset of the lump data in the file.

wadEntrySize :: Int32

Size (in bytes) of the lump data.

wadEntryName :: ByteString

Name of the lump. Note that trailing NULs are stripped when the name is read in.

Sprites and textures

data Sprite Source

Sprites are used for players, monsters, and things in general.

Constructors

Sprite 

Fields

spriteName :: LumpName

Lump name for this sprite.

spritePicture :: Picture

Picture for the sprite. It is drawn relative to the thing's position.

data Picture Source

Picture. Sprites and wall patches are stored in this format.

Constructors

Picture 

Fields

pictureWidth :: Int

Width of the picture.

pictureHeight :: Int

Height of the picture.

pictureLeftOffset :: Int

Offset of the left side to the origin of the picture.

pictureTopOffset :: Int

Offset of the top to the origin of the picture.

picturePosts :: [[Post]]

Each element in this list is a column, where each column is a list of posts.

data Post Source

A Post is a part of a column. There can (and often will) be gaps in columns for transparent parts in sprites and walls.

Constructors

Post 

Fields

postTop :: Word8

Where to start drawing this part of the column.

postPixels :: ByteString

Pixels of this post. The length of this field defines how many pixels to draw.

Instances

data Texture Source

Wall texture.

Constructors

Texture 

Fields

textureName :: LumpName

Name of the texture.

textureWidth :: Int16

Texture width.

textureHeight :: Int16

Texture height.

texturePatchDescriptors :: [PatchDescriptor]

List of patches, in the order they appear in the WAD.

data Patch Source

A wall patch. Wall textures are made up of one or more patches, which are positioned as defined by the patch descriptors in the Texture value.

Constructors

Patch 

Fields

patchName :: LumpName

Name of this patch.

patchPicture :: Picture

Picture for the patch. The offsets in the picture are ignored, because positioning is defined in the patch descriptor referencing this patch.

data PatchDescriptor Source

Patch descriptor.

Constructors

PatchDescriptor 

Fields

patchDescriptorXOffset :: Int16

X offset in wall coordinate system for this patch.

patchDescriptorYOffset :: Int16

Y offset in wall coordinate system for this patch.

patchDescriptorPNameIndex :: Int16

Index in PNAMES of the picture to use.

patchDescriptorStepDir :: Int16

Documented in UDS, but usage unknown.

patchDescriptorColorMap :: Int16

Documented in UDS, but usage unknown.

data Flat Source

Flats are images for texturing floors and ceiling.

Constructors

Flat 

Fields

flatName :: LumpName

Name of this flat.

flatData :: ByteString

Always 64 x 64 = 4096 bytes.

Palettes and colormaps

data Colormap Source

Colormap contains 34 maps, 256 bytes each.

Constructors

Colormap [ByteString] 

data Palettes Source

14 palettes, each a list of 256 RGB tuples.

Constructors

Palettes [[(Word8, Word8, Word8)]] 

Level geometry and details

data Level Source

One level.

Constructors

Level 

Fields

levelName :: LumpName

Level name, E?M? style for DOOM 1 maps, MAP?? for DOOM 2 maps.

levelThings :: [Thing]

List of things that are to be placed in the level on start.

levelVertices :: [Vertex]

List of vertices referenced by linedefs, segs, etc.

levelLineDefs :: [LineDef]

List of linedefs.

levelSideDefs :: [SideDef]

List of sidedefs.

levelSegs :: [Seg]

List of segs (parts of linedefs referenced in BSP tree.

levelSSectors :: [SSector]

List of ssectors (sub-sectors), created from sectors during BSP building. A ssector is made up of segs.

levelSectors :: [Sector]

List of sectors of the level.

levelNodes :: [Node]

BSP tree nodes.

levelReject :: Maybe Reject

Reject bitmap. Used for determining whether one sector can be seen from another.

levelBlockmap :: Maybe Blockmap

Blockmap. For each block of the map, lists the linedefs intersecting that block. Used for actor-wall collision detection.

data Thing Source

Things are parts of levels. When a level is loaded, the things define where to place players, monsters, items and so on.

Constructors

Thing 

Fields

thingX :: Int16

X position of the thing.

thingY :: Int16

Y position of the thing.

thingAngle :: Int16

Angle the thing is looking at when created. This only affects things that have a direction, such as players and monsters.

thingType :: ThingType

Kind of thing.

thingFlags :: Int16

Flags of the thing. Not decoded yet.

data ThingType Source

All supported thing types. Unrecogized types are encoded as ThingTypeOther.

Constructors

ZeroThing 
Player1StartPos 
Player2StartPos 
Player3StartPos 
Player4StartPos 
DeathMatchStartPos 
FormerHuman 
WolfensteinOfficer 
FormerHumanSergeant 
FormerHumanCommando 
Imp 
Demon 
Spectre 
LostSoul 
Cacodemon 
HellKnight 
BaronOfHell 
Arachnotron 
PainElemental 
Revenant 
Mancubus 
ArchVile 
Spiderdemon 
Cyberdemon 
BossBrain 
TeleportLanding 
BossShooter 
SpawnSpot 
Chainsaw 
Shotgun 
SuperShotgun 
Chaingun 
RocketLauncher 
Plasmagun 
BFG9000 
AmmoClip 
ShotgunShells 
Rocket 
CellCharge 
BoxOfAmmo 
BoxOfShells 
BoxOfRockets 
CellChargePack 
Backpack 
StimPack 
Medikit 
HealthPotion 
SpiritArmor 
SecurityArmor 
CombatArmor 
MegaSphere 
SoulSphere 
Invulnerability 
BerserkPack 
Invisibility 
RadiationSuit 
ComputerMap 
LightAmplificationGoggles 
BlueKeyCard 
RedKeyCard 
YellowKeyCard 
BlueSkullKey 
RedSkullKey 
YellowSkullKey 
Barrel 
BurningBarrel 
Candle 
Candelabra 
TallTechnocolumn 
TallGreenPillar 
TallRedPillar 
ShortGreenPillar 
ShortGreenPillarWithHeart 
ShortGreenPillarWithBeatingHeart 
ShortRedPillar 
ShortRedPillarWithSkull 
Stalagmite 
BurntGrayTree 
LargeBrownTree 
TallBlueFirestick 
TallGreenFirestick 
TallRedFirestick 
ShortBlueFirestick 
ShortGreenFirestick 
ShortRedFirestick 
FloorLamp 
TallTechnoLamp 
ShortTechnoLamp 
EvilEyeSymbol 
FlamingSkullRock 
ImpaledHuman 
TwitchingImpaledHuman 
SkullOnPole 
FiveSkullShishKebap 
PileOfSkullsAndCandles 
HangingVictim 
HangingVictimTwitching 
HangingPairOfLegs 
HangingVictim1Leg 
HangingLeg 
HangingVictimNoGuts 
HangingVictimNoGutsBrain 
HangingTorsoLookingDown 
HangingTorsoOpenSkull 
HangingTorsoLookingUp 
HangingTorsoNoBrain 
HangingBilly 
DeadPlayer 
DeadFormerHuman 
DeadFormerSergeant 
DeadImp 
DeadDemon 
DeadCacodemon 
DeadLostSoulInvisible 
BloodyMessExplodedPlayer 
BloodyMessAsAbove 
PoolOfBlood 
PoolOfGuts 
SmallPoolOfGuts 
PoolOfBrains 
HangingVictimTwitching2 
HangingVictimArmsSpread 
HangingVictim1Legged 
HangingPairOfLegs2 
HangingLeg2 
ThingTypeOther Int 

Instances

thingTypeFromNumber :: Integral a => a -> ThingType Source

Convert an integer thing type as found in the WAD file to Haskell.

data Vertex Source

A vertex defines the X/Y coordinates of linedefs, segs etc.

They are referenced by their position in the VERTEXES lump of the level they are used in.

Constructors

Vertex 

Fields

vertexX :: Int16

X coordinate.

vertexY :: Int16

Y coordinate.

data SideDef Source

A sidedef defines the textures to use on walls and to what sector the wall is connected.

Linedefs can have one or two sidedefs.

Constructors

SideDef 

Fields

sideDefXOffset :: Int16

X offset of the sidedef.

sideDefYOffset :: Int16

Y offset of the sidedef.

sideDefUpperTextureName :: ByteString

Name of upper texture.

sideDefLowerTextureName :: ByteString

Name of lower texture.

sideDefMiddleTextureName :: ByteString

Name of middle texture.

sideDefSector :: Int16

Index of sector this sidedef faces.

data LineDef Source

Linedefs make up the geometry of a level and additionally define most of the interactivity.

Constructors

LineDef 

Fields

lineDefStartVertex :: Int16

The linedef starts at the vertex with this index,

lineDefEndVertex :: Int16

... and ends at the vertex with this index.

lineDefFlags :: Int16

Linedef flags. Not decoded yet.

lineDefEffect :: Int16

Linedef effect. Not decoded yet.

lineDefTag :: Int16

Linedef tag. Triggers on this linedef affect sectors witht the same tag.

lineDefRightSideDef :: Int16

Right sidedef of this linedef. Defines textures and sector this linedef is connected to.

lineDefLeftSideDef :: Maybe Int16

For two-sided linedefs, this is the left side.

data Sector Source

Sectors are defined by enclosing linedefs, and the properties below. In WADs, each region of a map with different ceiling or floor heights or textures, or different specials and tags need to be their own sectors.

Constructors

Sector 

Fields

sectorFloorHeight :: Int16

Height of floor.

sectorCeilingHeight :: Int16

Height of ceiling.

sectorFloorFlat :: LumpName

Name of flat for floor texturing.

sectorCeilingFlat :: LumpName

Name of flat for ceiling texturing.

sectorLightLevel :: Int16

Light level of sector. Used as index in COLORMAP for darkening colors.

sectorSpecial :: Int16

Sector special. Not decoded yet.

sectorTag :: Int16

Sector tag. Not decoded yet.

data Node Source

Node of the BSP tree. This is created by the BSP construction process and is used to speed up rendering.

Constructors

Node 

Fields

nodeX :: Int16

X position of start of node line.

nodeY :: Int16

Y position of start of node line.

nodeDX :: Int16

Delta X for end of node line.

nodeDY :: Int16

Delta Y for end of node line.

nodeRightBBUY :: Int16

Upper Y coordinate of right bounding box.

nodeRightBBLY :: Int16

Lower Y coordinate of right bounding box.

nodeRightBBLX :: Int16

Lower X coordinate of right bounding box.

nodeRightBBUX :: Int16

Upper X coordinate of right bounding box.

nodeLeftBBUY :: Int16

Upper Y coordinate of left bounding box.

nodeLeftBBLY :: Int16

Lower Y coordinate of left bounding box.

nodeLeftBBLX :: Int16

Lower X coordinate of left bounding box.

nodeLeftBBUX :: Int16

Upper X coordinate of left bounding box.

nodeRightNodeOrSSector :: Either Int16 Int16

When Left, index of right recursive node, when Right index of right ssector.

nodeLeftNodeOrSSector :: Either Int16 Int16

When Left, index of left recursive node, when Right index of left ssector.

data SSector Source

A SSector (sub-sector?) is also produced by the BSP construction process. All sectors are split into ssectors (convex polygons).

Constructors

SSector 

Fields

ssectorSegCount :: Int16

Number of segs that make up this ssector.

ssectorSegStart :: Int16

Index of first seg of this sector.

data Seg Source

Segs are split up linedefs that are produced by the BSP construction process. Whenever a BSP node splits a linedef, two segs are created representing both sides of the split.

Constructors

Seg 

Fields

segStartVertex :: Int16

Index of start vertex.

segEndVertex :: Int16

Index of end vertex.

segAngle :: Int16

Angle of the seg.

segLineDef :: Int16

Index of linedef this seg is part of.

segDirection :: Int16

0 if seg is in same diretion as linedef, 1 otherwise.

segOffset :: Int16

Offset of the seg relative to the linedef.

data Reject Source

Reject array. This is a bit map and not decoded yet.

Constructors

Reject 

type Blocklist = [Int16] Source

Blocklist is a list of linedef indices.

data Blockmap Source

Blockmap, determines which blocks intersect with linedefs.

Constructors

Blockmap 

Fields

blockmapOriginX :: Int16

X origin in level coordinates.

blockmapOriginY :: Int16

Y origin in level coordinates.

blockmapColumns :: Int16

Number of columns.

blockmapRows :: Int16

Number of rows.

blockmapBlocklists :: [Blocklist]

Blocklists for all blocks, left-to-right, bottom-to-top in level coordinates.