Coder Social home page Coder Social logo

[Feature] Support for Doom WAD Files about fq HOT 5 OPEN

sleibrock avatar sleibrock commented on June 9, 2024 2
[Feature] Support for Doom WAD Files

from fq.

Comments (5)

gcr avatar gcr commented on June 9, 2024 2

Here's a very rudimentary decoder you can use in fq. Run fq -d raw -i . MAPS2.wad and paste the following into the REPL:

def num_le: tobytes|explode|reverse|map(. band 0xff)|tobytes|tonumber;
tobytes as $file | {} 
| .type = $file[:4]
| .n_lumps = ($file[4:8]|num_le)
| .offset = ($file[8:12]|num_le)
| ($file[.offset:]) as $lumpdir 
| .lumps = [
    range(.n_lumps)
    | ($lumpdir[16* . :16*( . +1)]) as $rec | {}
    | .offset = ($rec[:4]|num_le)
    |.size = ($rec[4:8]|num_le)
    |.name = ($rec[8:16]|gsub("\u0000";""))
    |.data = $file[.offset:.offset+.size]
]

fq doesn't support creating Decode Values, so you don't get those nice-looking hexdumps like this, but it's a start.

from fq.

wader avatar wader commented on June 9, 2024

Hey! sure i'm willing to add any format that is used publicly. Want to work on adding support? as it seems to be a quite basic archive format i'm guessing it shouldn't be that much work.

from fq.

sleibrock avatar sleibrock commented on June 9, 2024

Definitely! I can't say I'm familiar with the internals of fq just yet but I would love to get started and see what I can pull off. Doom WADs have a very simple structure of header, LUMP table, then a blob of all object tables. It should be fun to add in.

from fq.

wader avatar wader commented on June 9, 2024

Nice! hopefully you should not need to know much about most internals, the decode API used by a format decoders don't know much a the rest of fq on puropse. Maybe a good start is to look at some existing format decode that is similar, maybe ar, tar or zip? also i'm happy to help out, you can for example open a PR with a early draft and then we work from that.

from fq.

wader avatar wader commented on June 9, 2024

Nice! tip is to put the code into a file wad.jq as a function from_wad and then do fq -d bytes -I . 'include "wad"; from_wad' file.wad

btw is this for an older version of fq? the band infix-operator is now a function band/2 and -d raw has been split into bytes and bits for different slicing units.

from fq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.