Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theobori/tinywad
𩸠A library to manage WAD for DOOM based game
https://github.com/theobori/tinywad
composer doom iwad library manager modding pwad rust
Last synced: 2 months ago
JSON representation
𩸠A library to manage WAD for DOOM based game
- Host: GitHub
- URL: https://github.com/theobori/tinywad
- Owner: theobori
- License: mit
- Created: 2022-11-13T23:36:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-12T19:08:54.000Z (8 months ago)
- Last Synced: 2024-10-31T11:39:21.370Z (3 months ago)
- Topics: composer, doom, iwad, library, manager, modding, pwad, rust
- Language: Rust
- Homepage: https://crates.io/crates/tinywad
- Size: 2.49 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 𩸠tinywad
![build](https://github.com/theobori/tinywad/actions/workflows/build.yml/badge.svg)
A library to manage WAD for DOOM based game. It has been tested with the following IWAD:
- DOOM.WAD
- DOOM2.WAD
- HEXEN.WAD
- CHEX.WAD
- TNT.WAD
- PLUTONIA.WAD
- STRIFE0.WAD
- STRIFE1.WAD
- DOOMU.WAD
- DOOM2F.WAD
- HEXDD.WADIt supports the following features:
- Load WAD buffer/file
- Extract lump raw content
- Extract lump as original files (PNGs)
- Extract the image lumps with a custom color palette
- Update lump raw content
- Build a IWAD/PWAD
- Add/insert lumps then save the WAD file## đ How to build and run ?
1. Install the dependencies
- `cargo`## â Use cases
#### Patching directly the IWAD
```rust
use tinywad::error::WadError;
use tinywad::models::operation::WadOp;
use tinywad::wad::Wad;fn main() -> Result<(), WadError> {
let mut doom_2 = Wad::new();
doom_2.load_from_file("doom2.wad")?;let gate = doom_2.lump("GATE3").unwrap();
let mut doom_1 = Wad::new();
doom_1.load_from_file("doom1.wad")?;doom_1.select("^FLAT|FLOOR");
doom_1.update_lumps_raw(&gate.data().buffer);
doom_1.save("doom1.wad");Ok(())
}
```#### Screenshot(s)
#### Extracting lumps with custom palettes
```rust
use std::fs;use tinywad::dir::MAX_PAL;
use tinywad::error::WadError;
use tinywad::models::operation::WadOp;
use tinywad::wad::Wad;fn main() -> Result<(), WadError> {
let mut doom_2 = Wad::new();
doom_2.load_from_file("doom2.wad")?;for pal in 0..MAX_PAL {
doom_2.set_palette(pal);
doom_2.reload()?;
doom_2.select("^BOSF");
let dirpath = format!("doom2/pal_{}", pal);fs::create_dir_all(dirpath.clone()).unwrap();
doom_2.save_lumps(dirpath);
}Ok(())
}
```#### Extracted lumps (as PNGs)
#### Building a PWAD from scratch
```rust
use tinywad::error::WadError;
use tinywad::lump::{LumpAdd, LumpAddKind};
use tinywad::models::operation::WadOp;
use tinywad::wad::{Wad, WadKind,};fn main() -> Result<(), WadError> {
let mut src = Wad::new();let lump_names = [
"FLOOR0_1", "FLOOR0_3", "FLOOR0_6",
"FLOOR1_1", "FLOOR1_7", "FLOOR3_3",
"FLOOR4_1", "FLOOR4_5", "FLOOR4_6",
"FLOOR4_8", "FLOOR5_1", "FLOOR5_2",
"FLOOR5_3", "FLOOR5_4", "FLOOR6_1",
"FLOOR6_2", "FLOOR7_1", "FLOOR7_2",
];src.load_from_file("doom.wad")?;
let gate = src.lump("FLOOR6_1").unwrap();
let mut dest = Wad::new();
dest.set_kind(WadKind::Pwad);
dest.add_lump_raw(
LumpAdd::new(
LumpAddKind::Back,
&vec![],
"FF_START",
)
)?;for lump_name in lump_names {
dest.add_lump_raw(
LumpAdd::new(
LumpAddKind::Back,
&gate.data().buffer,
lump_name,
)
)?;
}dest.add_lump_raw(
LumpAdd::new(
LumpAddKind::Back,
&vec![],
"F_END",
)
)?;dest.save("doom1_patch.wad");
Ok(())
}
```#### Dumping metadata
```rust
use tinywad::error::WadError;
use tinywad::models::operation::WadOp;
use tinywad::wad::Wad;fn main() -> Result<(), WadError> {
let mut src = Wad::new();src.load_from_file("hexen.wad")?;
src.dump();Ok(())
}
```#### Output
```
Name: XXTIC, Size: 8, Offset: 12
Name: STARTUP, Size: 153648, Offset: 20
Name: PLAYPAL, Size: 21504, Offset: 153668, Palettes amount: 28
Name: COLORMAP, Size: 8704, Offset: 175172
Name: FOGMAP, Size: 8704, Offset: 183876
Name: TINTTAB, Size: 65536, Offset: 192580
Name: TRANTBL0, Size: 256, Offset: 258116
Name: TRANTBL1, Size: 256, Offset: 258372
Name: TRANTBL2, Size: 256, Offset: 258628
...
```## đĒ§ Supported lump types
- DOOM image(s)
- Flat
- Palette
- Markers
- Music## â Todo
Name | State
------------- | :-------------:
Dump WAD header | â
Dump lumps metadata | â
Extract (save) lump | â
Update lump from raw buffer/file| â
Update lump from original buffer/files (PNG, MIDI, etc..) | â
Rebuild then save the WAD as a new file | â
Extract DOOM musics | â
Extract raw lump | â
Remove lumps | â
Add lump unique coherent IDs | â
Update lump size in the metadatas | â
Add lump with raw buffer | â## âšī¸ Documentation
Run `cargo doc --open` to read the documentation in the browser.