Example Code

LABWAD - LLB to open WAD files from Doom & Doom2

Code and Documents

Attachment

Overview

Demonstrates how to read WAD files from original DOOM games.

 

Clipboard 2.jpg

 

Description

As I wanted to train reading binary files, I wrote this small LLB to read IWAD & PWAD files of old DOOM & DOOM2 games (id Software).
You will need the original WAD files, that you can get for cheap on Steam or GOG websites.

Simply: launch the top-level vi and choose a .wad file to open.
The program will list the different objects in the wad, you can then select and display them. It manages Levels, Textures, Patches, Flats, Sprites & User Interface elements. You can export images in PNG with the drop-down menu. Musics, Sounds, Demos, etc... are not supported (but everyone is welcome to contribute!).

I tested it for original DOOM, DOOM2, TNT & PLUTONIA wads, it seems to work fine. However, the .wad format is quite versatile and some strange behaviour can appear:
* IWAD files are original files, with all information needed inside. These should open fine.
* PWAD files are mods, that will be added on top of an IWAD. For example, if a PWAD has only the E1M1 level, this one will be loaded from the PWAD and not from the IWAD. All the rest will be loaded from the IWAD. Opening such a PWAD with this LLB will only show the E1M1 level, as there is nothing else in the file.
* WAD files from other games such as HEXEN or HERETIC will not work properly, as many objects have different names (specially the THINGS List).
* Recent WAD files overcome many limitations of the old format, and are way more complicated. Those may create funny errors, as the opening process could be different.

 

Hardware and Software Requirements

Labview 2017, Vision 2017, OpenG libraries

 

Steps to Implement or Execute Code

1. Run this VI.
2. Select a .wad file.
3. Clic on different items to display it.
4. Export as PNG is possible via drop-down menu on the displayed picture or the object list.
5. Quit by using the File > Quit menu.

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Dataflow_G
Member
Member
on

This is really awesome _Sylvain, thanks for sharing! Kudos on the software design too, very easy to pickup and modify.

 

I've made a few modifications which can be downloaded from here (I can't seem to attach anything here). Modifications include:

  • Set low level byte manipulation subVIs to inline and disabled debugging - this reduces load time dramatically.
  • Replaced all IMAQ functions with the LabVIEW Picture functions (NI Vision is no longer required).
  • Replaced LLB with a project.
  • Added some PSX Doom Fire!

For anyone wanting to try this example code who doesn't have Doom, you can also use the Doom demo WAD for free. Or just buy Doom.

 

labwad_doom.png

_Sylvain
Member
Member
on

Thanks for the participation!
The Labview Picture function makes it much simpler indeed, I should have thought about that. The Doom Fire in the background is a bit over the top for me, but it's fun 🙂 And thanks for the new icon as well.

As I had a bit more time, I added some things:

 

* It now opens and reads the sound files, either in DMX or "Motherboard speaker" format. It was easier than expected, actually. Be careful with the speaker format, it can be quite annoying.

* I slightly modified the architecture to accommodate for those changes, but nothing dramatic.

* I started opening the musics as well, but it will be a harder job. Musics are encoded in MUS format. I can probably write something to convert them to MIDI format (it is pretty close), but I don't want to write my own MIDI player... We will see.

 

It can be downloaded here.

Dataflow_G
Member
Member
on

Awesome stuff. I can't say I've ever heard the PC speaker versions before, very Commander Keen. If you do add a MUS to MIDI function, I think the MIDI files can be played using Windows' media playback via ActiveX. Not as nice as an OPL2/OPL3 emulator (or real hardware), but good enough.

 

Yeah, the fire was just a bit of fun. The full source for that has options to start and stop the fire, so I might add those in at some point.

 

If I get around to making code changes in future, I'll fork your repo and submit pull requests 🙂

Contributors