Sonic and Sega Retro Message Board: Making a WAD file - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

Making a WAD file Or any other kind of data container

#1 User is offline Elektro-Omega 

Posted 12 July 2013 - 04:21 AM

  • Mushroom Hill'in
  • Posts: 400
  • Joined: 23-February 10
  • Gender:Male
  • Location:UK
  • Project:-
Hey Retro,

I have recently taken up a new programming language and I am exploring possibilities with containing assets in a single package. I remembered that the Doom games stored all assets into a WAD file whereby this was accessed by the core engine, this allowed the engine to be reused while keeping content fresh.

I come to you today to ask how to actually make a WAD file. I know there are wad file builders out there for Doom but I may want to have a different extraction algorithm within my program to that which was used by Doom, so it would be off a little.

My main concern is within the creation of the WAD itself. If I have a folder of assets and want it to become a WAD file, how would I go about doing it? Would I need to write a separate application to compress (for a lack of better wording) the folder into a WAD file.

I was wondering if you could all share your pearls of wisdom with me regarding any sort of WAD file and I will take from it what I can.

Thanks :)

#2 User is offline winterhell 

Posted 12 July 2013 - 04:56 AM

  • Posts: 747
  • Joined: 16-October 10
  • Gender:Male
Do you want to actually read from existing WAD files or to make levels for existing games based on Doom?

What it looks like is you just want to be able to contain your resources in a single file, regardless the format. To do that you basically need to know
-how to read all the bytes of a given file inside the game
-use an existing function(you may have to #include or whatever the necessary library) that will tell you the contents of the folder
-iterate through all the files and folders the previous function gave you, read them one by one, and write them all in a single file.
Depending on how you do it, beside the raw data for the files you'll also need to write for each file its filename and its size in bytes

This is all you need to know.

#3 User is offline Elektro-Omega 

Posted 12 July 2013 - 05:12 AM

  • Mushroom Hill'in
  • Posts: 400
  • Joined: 23-February 10
  • Gender:Male
  • Location:UK
  • Project:-
Thanks winterhell,

I'm looking to read from a WAD file in my own programmed game engine, completely independent from anything else. I only used Doom as a simple example because WAD files are key to that engine.

From what I have read, the main WAD format contains a header, a number of folders and then pointers to the start of each piece of the data.

You have actually cleared that up a fair bit. Thank you. I'm still a little confused how you would create a WAD file but using your knowledge I would assume it's basically a read to memory, and then write it to a single file, and iterate through this process until it is all written. My main curiosity here is how to make folders / sub directories whilst using this method.

I just wanted to ask, in the point where you mentioned using an existing function (or #include). Ideally I did not want to have to use an #include or a function that instructs the contents as I pretty much wanted any WAD to be able to be loaded and I ideally wanted to make something where the contents of the WAD could be variable I.e I could have 2 images and a sound in one WAD whilst 20 images and 10 sounds in another, and have the program load them identically, without needing to know in advance.

I think I may be able to pick it up from here but I will still request guidance from you all and I will keep you all well informed.

Thank you for the information winterhell

#4 User is offline Elektro-Omega 

Posted 12 July 2013 - 06:22 AM

  • Mushroom Hill'in
  • Posts: 400
  • Joined: 23-February 10
  • Gender:Male
  • Location:UK
  • Project:-
I know I'm double posting but please don't kill me, there is a purpose.

I have started to write my own format based upon the model of a WAD. It consists of a basic header, amount of directories and then the name and size of each directory.

I have a supplemental question to my earlier one. How do directories within a WAD file work. I was planning on including a number of directories and then including the name and size of each, then going further in and doing the same for the sub directories. This posed the question to me that if I am trying to do that, and it is only going to be me editing the file, is there a need for any directories at all when I could do everything based on file extensions I.e all .png files are images, all .wav files are sounds etc. I may include directories regardless, just for the sake of later editing.

I think I am definitely making progress but it's just the directories concept that is stumping me every time. I can't seem to figure it out. I think what is getting me the most is how do I place a file within a directory, within a WAD using simple programming. I think that is what I am struggling to grasp.

Any future discoveries will be edited to this post unless there is a post in between.

I would like to hear everyones experiences with WAD files and any knowledge that they have.

EDIT: I think by tweaking my thinking I may have possibly come up with a solution. With Doom WADs, everything is classified as a Chunk. I was hoping to use the same principle within my WADs, however I was hoping to treat each file as a chunk within a certain directory. Instead, I might just treat each directory itself as a chunk full of the raw data and parse the files out by reading the size from the raw data.

I may have over complicated that so I will try to explain it more clearly so you can correct me when you find fault with it (because I doubt that I am right)

Previously I had:

Root WAD directory -> directory -> file

where file was being read.

but now I am going to have

Root WAD directory -> directory

where directory is being read as a huge chunk of raw data and each file will be parsed out.

Phew, I think I am getting there, but as I said, if anyone knows better, feel free to correct me.
This post has been edited by Elektro-Omega: 12 July 2013 - 06:42 AM

#5 User is offline Billy 

Posted 12 July 2013 - 11:21 AM

  • RIP Oderus Urungus
  • Posts: 1708
  • Joined: 24-June 05
  • Gender:Male
  • Location:Colorado, USA
  • Project:retrooftheweek.net - Give it a visit and tell me what you think!
  • Wiki edits:15
Personally I'd just find a library for zip files and use those (perhaps renamed to .pk3). Unless you want your assets hard to get at, that is.

#6 User is offline Sodaholic 

Posted 12 July 2013 - 11:27 AM

  • Colony ship for sale, cheap!
  • Posts: 1004
  • Joined: 05-September 04
  • Gender:Male
  • Location:Ohio

View PostBilly, on 12 July 2013 - 11:21 AM, said:

Unless you want your assets hard to get at, that is.

If this is for Doom and not just something otherwise unrelated based on its WAD format, I don't think the Doom community would appreciate this very much.

#7 User is offline winterhell 

Posted 12 July 2013 - 01:57 PM

  • Posts: 747
  • Joined: 16-October 10
  • Gender:Male
As with everything, start small, when it works, grow and expand. You don't have to use any kinds of directories for start. You can easily manage dozens of images/sounds in the same place. Make a game or just demo with them. When you actually get to the point where its easier to get things done with multiple folders, you'll have much better idea of what and how.

And as for any game developer, its mandatory to make at least a couple of Atari 2600 games. If you haven't already, you HAVE to make at least Pong and Snake. Yes it sounds super stupid and it can be done in 15 minutes flat, but if you think about it, every game guru started out by making Commander Keen, Jazz Jackrabbit, Duke Nukem 1 and so on.
This post has been edited by winterhell: 12 July 2013 - 01:58 PM

#8 User is offline saxman 

Posted 12 July 2013 - 10:58 PM

  • Oldbie
  • Posts: 2625
  • Joined: 08-April 04
  • Gender:Male
  • Location:United States of America
  • Wiki edits:136
A Gz or Zip file is the easiest way to go. However, if it's WAD files you want... I haven't worked with the format in a number of years now, but I wrote my own code to read WAD files.

http://www.romhackin.../utilities/649/

Included with the program is the source code. I'll warn you right off the bat that the source is a bit sloppy, but you should still be able to get what you need from it.

#9 User is offline FuzzballFox 

Posted 13 July 2013 - 12:19 AM

  • Hmmmmm
  • Posts: 575
  • Joined: 24-October 05
  • Location:UK - Hampshire
  • Project:Nothing anymore
If you're using a Zdoom-based source port- then PK3 is probably the way to go.
Look about on the Zdoom forums and look into either XWE or Slade. Both will help greatly working with those kinds of things.

#10 User is offline Elektro-Omega 

Posted 16 July 2013 - 08:52 AM

  • Mushroom Hill'in
  • Posts: 400
  • Joined: 23-February 10
  • Gender:Male
  • Location:UK
  • Project:-
Thank you everyone for all the information.

This was meant to be done entirely separate from any version of doom or anything. I was programming a game engine myself and just fancied using the WAD format because it would be easy to replace it with a different WAD I make and I wouldn't have to touch the code of the core engine.

Thanks again for all of your help and you all have certainly given me lots to think about :)

#11 User is offline Sodaholic 

Posted 21 July 2013 - 06:35 AM

  • Colony ship for sale, cheap!
  • Posts: 1004
  • Joined: 05-September 04
  • Gender:Male
  • Location:Ohio

View PostFuzzballFox, on 13 July 2013 - 12:19 AM, said:

XWE

Ew. Never recommend this outdated, buggy and unstable tool, ever. It was abandoned 6 years ago because it was a mess. Slade is wonderful, still actively updated and is far faster, more stable and featureful than XWE is.

#12 User is offline saxman 

Posted 27 July 2013 - 10:31 PM

  • Oldbie
  • Posts: 2625
  • Joined: 08-April 04
  • Gender:Male
  • Location:United States of America
  • Wiki edits:136
WinTex was THE best WAD editing utility on the planet by far, despite some limitations in certain areas. Too bad it's 16-bit and won't run on 64-bit Windows without a VM solution of some sort. =(

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users