Dokapon Extract
A versatile tool for extracting and repacking various game assets from DOKAPON! Sword of Fury.
Table of contents
- Overview
- Requirements
- Installation
- Usage
- Real-World Examples
- File Format Details
- Technical Details
- Best Practices
- Troubleshooting
- Contributing
- License
Overview
Dokapon Extract is a powerful Python tool that handles multiple file formats used in DOKAPON! Sword of Fury:
π¦ Supported Formats
.tex
- Texture files.mpd
- Map/Cell data files.spranm
- Sprite animation files.fnt
- Font files
π Key Features
- Extract embedded PNG images
- Handle LZ77 compression
- Preserve file metadata
- Repack modified PNGs
- Maintain directory structure
Requirements
- Python 3.6 or higher
- PIL (Python Imaging Library)
- Basic command line knowledge
Installation
- Download
dokapon_extract.py
- Install required Python packages:
pip install pillow
Usage
Basic Command Structure
python dokapon_extract.py [-h] [-i INPUT] [-o OUTPUT] [-t {tex,spranm,fnt,all}] [-v] [--repack]
Arguments
Argument | Description |
---|---|
-i, --input | Input file/directory (default: current dir) |
-o, --output | Output directory (default: ./output) |
-t, --type | File type to process (default: all) |
-v, --verbose | Show detailed processing information |
--repack | Repack a modified PNG using metadata |
Quick Usage in Game Directory
If you place dokapon_extract.py
directly in the gameβs root folder, you can extract assets without specifying full paths:
- Copy the Script
π DOKAPON ~Sword of Fury~ βββ π dokapon_extract.py # Place script here βββ π GameData/
- Extract All Assets
python dokapon_extract.py -i "GameData/app" -o "extracted"
- Extract Specific Types
# Extract all UI textures python dokapon_extract.py -i "GameData/app/Field/TXD" -o "extracted/ui" -t tex # Extract all battle effects python dokapon_extract.py -i "GameData/app/Battle/Effect" -o "extracted/effects" -t spranm # Extract all fonts python dokapon_extract.py -i "GameData/app/Font" -o "extracted/fonts" -t fnt
- Extract Single Files
# Extract a specific UI element python dokapon_extract.py -i "GameData/app/Field/TXD/BoxWin.txd" -o "extracted/ui" # Extract a specific animation python dokapon_extract.py -i "GameData/app/Battle/Effect/EFFECT00_00.spranm" -o "extracted/effects"
Running the script from the game directory makes it easier to use relative paths and maintain your extracted files organization.
Real-World Examples
Game File Structure
π DOKAPON ~Sword of Fury~
βββ π GameData/app/
β βββ π Battle/ # Battle animations and effects
β β βββ π Effect/ # Battle effects
β β βββ π Ability/ # Character abilities
β β βββ π Magic/ # Magic animations
β βββ π Field/
β β βββ π Face/ # Character face animations
β β βββ π Map/ # Map data and textures
β β βββ π TXD/ # UI textures
β β βββ π Guidebook/ # Game guide images
β βββ π Font/ # Game fonts
β βββ π Title/ # Title screen assets
Common Extraction Tasks
- Extract Battle Effects
python dokapon_extract.py -i "GameData/app/Battle/Effect" -o "extracted/effects" -t spranm
Extracts animation files like:
- EFFECT00_00.spranm β EFFECT00_00.png
- EFFECT01_00.spranm β EFFECT01_00.png
- EFFECT02_00.spranm β EFFECT02_00.png
- Extract Character Faces
python dokapon_extract.py -i "GameData/app/Field/Face" -o "extracted/faces" -t spranm
Extracts character face animations:
- FACE00A_00.spranm β FACE00A_00.png
- FACE00B_00.spranm β FACE00B_00.png
- H_FACE00A_00.spranm β H_FACE00A_00.png
- Extract UI Textures
python dokapon_extract.py -i "GameData/app/Field/TXD" -o "extracted/ui" -t tex
Processes UI elements:
- BoxWin.txd β BoxWin.png
- StatusWin.txd β StatusWin.png
- WeekWin.txd β WeekWin.png
- Extract Guidebook Images
python dokapon_extract.py -i "GameData/app/Field/Guidebook" -o "extracted/guide"
Extracts all guidebook pages:
π extracted/guide/ βββ img.png βββ img2.png βββ img3.png ... βββ img34.png
Batch Processing Examples
- Extract All Battle Assets
#!/bin/bash # extract_battle.sh BASE_DIR="GameData/app/Battle" OUT_DIR="extracted/battle" # Extract effects python dokapon_extract.py -i "$BASE_DIR/Effect" -o "$OUT_DIR/effects" -t spranm # Extract abilities python dokapon_extract.py -i "$BASE_DIR/Ability" -o "$OUT_DIR/abilities" # Extract magic python dokapon_extract.py -i "$BASE_DIR/Magic" -o "$OUT_DIR/magic"
- Extract All Field Assets
#!/bin/bash # extract_field.sh BASE_DIR="GameData/app/Field" OUT_DIR="extracted/field" # Extract maps python dokapon_extract.py -i "$BASE_DIR/Map" -o "$OUT_DIR/maps" -t mpd # Extract faces python dokapon_extract.py -i "$BASE_DIR/Face" -o "$OUT_DIR/faces" -t spranm # Extract UI python dokapon_extract.py -i "$BASE_DIR/TXD" -o "$OUT_DIR/ui" -t tex
Language-Specific Content
The game includes language-specific variants in βenβ subdirectories:
python dokapon_extract.py -i "GameData/app/Field/TXD/en" -o "extracted/ui/en"
This extracts English versions of UI elements:
- F_00_FD_02_txt.txd
- MARK_00.txd
- StatusWin.txd
File Format Details
Texture Files (.tex)
PNG Container
Structure:
[LZ77 Header (optional)]
[PNG Data]
Map Data Files (.mpd)
Cell Data
Header Structure:
struct MPDHeader {
char magic[4]; // "Cell"
int data_size; // Size of data section
int width; // Image width
int height; // Image height
int cell_width; // Width of each cell
int cell_height; // Height of each cell
};
Sprite Animation (.spranm)
Animation Data
Format:
[LZ77 Header (optional)]
"Sequ" marker
[PNG Data (if present)]
[Animation Data]
Font Files (.fnt)
Font Data
Contains:
- LZ77 compressed data (optional)
- Raw font data
Technical Details
LZ77 Decompression
The tool implements Nintendo-style LZ77 decompression:
def decompress_lz77(data: bytes) -> Optional[bytes]:
"""
Format:
- 4 byte magic "LZ77"
- 4 byte padding
- 4 byte compressed size
- 4 byte decompressed size
- Compressed data
"""
Metadata Preservation
Each extracted PNG includes a JSON metadata file:
{
"original_file": "path/to/source.tex",
"original_extension": ".tex",
"offset": 1234,
"length": 5678,
"mpd_header": {
"width": 1024,
"height": 1024,
"cell_width": 32,
"cell_height": 32
}
}
PNG Processing
The tool handles PNG data carefully:
- Strips unnecessary metadata
- Preserves core image data
- Maintains original dimensions
- Handles size differences during repacking
Best Practices
Extracting Files
- π Organize Your Files
- Keep original files backed up
- Use meaningful directory names
- Maintain directory structure
- π Use Verbose Mode
python dokapon_extract.py -i "input" -o "output" -v
- Helps track processing
- Shows detailed information
- Identifies potential issues
- π Check Results
- Verify extracted files
- Compare file counts
- Check metadata files
Repacking Files
- π Preserve Metadata
- Keep .json files with PNGs
- Donβt modify metadata manually
- Back up original files
- π Mind the Size
- Keep modifications within original dimensions
- Check warnings about size differences
- Test repacked files
- π§ͺ Test Thoroughly
- Verify in-game appearance
- Check for visual artifacts
- Test different game scenarios
Troubleshooting
Common Issues
- LZ77 Decompression Errors
Decompression error: Invalid compressed data
- Check file integrity
- Verify file is actually compressed
- PNG Extraction Failed
No PNG signature found
- Verify file format
- Check file corruption
- Repacking Size Mismatch
Warning: PNG larger than original
- Reduce image size
- Check image dimensions
Contributing
We welcome contributions!
- Report issues on GitHub
- Submit pull requests
- Share improvements
- Join our Discord
License
This tool is licensed under The Unlicense. You can:
- β Use freely for any purpose
- β Modify and distribute without restrictions
- β No attribution required
- β Dedicated to public domain
- β No warranty provided
See the LICENSE file for details.