Last active
November 27, 2025 17:29
-
-
Save iconmaster5326/94c25d2adf6479777307f313715ba75b to your computer and use it in GitHub Desktop.
Converting Dragon Spirits graphics to/from .png/.rvdata2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Run this in the root directory of a RPG Maker project. | |
| import os | |
| POSTFIX = ".png" | |
| RVDATA2_HEADER = b"\x85\xa1\x39\x38\x3f\xd3\x3d\x6d" | |
| for dirname, dirs, files in os.walk(os.path.join(os.curdir, "Graphics")): | |
| print(f"Walking through {dirname}...") | |
| for file in files: | |
| if file[-len(POSTFIX):] == POSTFIX: | |
| infilename = os.path.join(dirname, file) | |
| outfilename = infilename[:-len(POSTFIX)] + ".rvdata2" | |
| print(f"Converting {infilename} to {outfilename}!") | |
| with open(infilename, "rb") as infile: | |
| with open(outfilename, "wb") as outfile: | |
| outfile.write(RVDATA2_HEADER + infile.read()[len(RVDATA2_HEADER):]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Run this in the root directory of a RPG Maker project. | |
| import os | |
| POSTFIX = ".rvdata2" | |
| PNG_HEADER = b"\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" | |
| for dirname, dirs, files in os.walk(os.path.join(os.curdir, "Graphics")): | |
| print(f"Walking through {dirname}...") | |
| for file in files: | |
| if file[-len(POSTFIX):] == POSTFIX: | |
| infilename = os.path.join(dirname, file) | |
| outfilename = infilename[:-len(POSTFIX)] + ".png" | |
| print(f"Converting {infilename} to {outfilename}!") | |
| with open(infilename, "rb") as infile: | |
| with open(outfilename, "wb") as outfile: | |
| outfile.write(PNG_HEADER + infile.read()[len(PNG_HEADER):]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| meta: | |
| id: rvdatax | |
| endian: le | |
| doc: A `.rvdatax` file, used in Dragon Spirits. | |
| seq: | |
| - id: header | |
| doc: Header information? | |
| size: 3 | |
| - id: num_entries | |
| doc: Number of entries. | |
| type: varnum | |
| - id: entries | |
| doc: Entries. | |
| type: entry | |
| repeat: expr | |
| repeat-expr: num_entries.value | |
| types: | |
| varnum: | |
| doc: A variable-length number. | |
| seq: | |
| - id: num_bytes | |
| doc: The number of bytes this number is. | |
| type: u1 | |
| - id: bytes_1 | |
| doc: The bytes composing this number. | |
| type: u1 | |
| if: num_bytes == 0x01 | |
| - id: bytes_2 | |
| doc: The bytes composing this number. | |
| type: u2 | |
| if: num_bytes == 0x02 | |
| - id: bytes_4 | |
| doc: The bytes composing this number. | |
| type: u4 | |
| if: num_bytes == 0x04 | |
| instances: | |
| value: | |
| value: | | |
| num_bytes == 0x00 ? 0 : | |
| num_bytes == 0x01 ? bytes_1 : | |
| num_bytes == 0x02 ? bytes_2 : | |
| num_bytes == 0x04 ? bytes_4 : | |
| (num_bytes - 5) | |
| entry: | |
| doc: A single entry in a file. | |
| seq: | |
| - id: magic1 | |
| doc: Magic number. | |
| size: 4 | |
| - id: name | |
| doc: The name of the entity. | |
| type: str | |
| encoding: UTF-8 | |
| terminator: 0x22 # " | |
| consume: false | |
| - id: magic2 | |
| doc: Magic number. | |
| size: 1 | |
| - id: len_contents | |
| doc: The byte length of entry contents. | |
| type: varnum | |
| - id: contents | |
| doc: The contents of this entry. | |
| type: str | |
| encoding: UTF-8 | |
| size: len_contents.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment