ndspy-xzonn
This repository is my personal fork of RoadrunnerWMC/ndspy. I publish it to PyPI primarily for use in my own projects and for anyone who needs features that are not implemented in the upstream branch. It is independently maintained and is not an official upstream release.
Compared with upstream ndspy 4.2.0, this fork currently adds:
- LZ11 compression, decompression, and a command-line tool;
- support for loading, editing, rendering, and saving NFTR bitmap fonts;
- CP932 support for BMG files; and
- compression fixes, including correct handling of overlapping matches.
The PyPI distribution is named ndspy-xzonn, while the Python import package remains ndspy for compatibility with existing code.
ndspy ("en-dee-ESS-pie") is a Python library and suite of command-line tools that can help you read, modify and create many types of files used in Nintendo DS games.
ndspy follows a few key design principles:
- Accuracy: ndspy should be able to open and resave any supported file with byte-for-byte accuracy if it's in its canonical format.
- Flexibility: ndspy should be able to read any valid file in a format it supports. In cases where there's a high chance it will be unable to fully interpret some especially complex part of a file, it should still be useful for editing the other parts.
- Semantic: ndspy's APIs should closely match the semantics of file structures while hiding their binary-level details.
ndspy provides both a Python API and a set of simple command-line tools that make use of it. The command-line tools let you convert files to and from binary formats without having to write any Python code yourself. The API is suitable for use in applications written in Python, and in scripts to do more complex tasks than the command-line tools are capable of.
As ndspy is written in pure Python, it is cross-platform and should run on all platforms Python supports. Note that Python doesn't support the Nintendo DS itself; ndspy is intended to be used on your PC.
Interested? Read on to see some examples, or check the API Reference to see the documentation for a specific module. When you're ready to install, head over to the Installation section!
A few examples of ndspy in action
Create a BMG file containing message strings:
>>> import ndspy.bmg
>>> message1 = ndspy.bmg.Message(b'', ['Open your eyes...'])
>>> message2 = ndspy.bmg.Message(b'', ['Wake up, Link...'])
>>> bmg = ndspy.bmg.BMG.fromMessages([message1, message2])
>>> bmg.save()
b'MESGbmg1\xa0\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00INF1 \x00\x00\x00\x02\x00\x04\x00\x00\x00\x00\x00\x02\x00\x00\x00&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00DAT1`\x00\x00\x00\x00\x00O\x00p\x00e\x00n\x00 \x00y\x00o\x00u\x00r\x00 \x00e\x00y\x00e\x00s\x00.\x00.\x00.\x00\x00\x00W\x00a\x00k\x00e\x00 \x00u\x00p\x00,\x00 \x00L\x00i\x00n\x00k\x00.\x00.\x00.\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>>>
Change all notes in a SSEQ sequenced music file to middle C, similar to this song:
>>> import ndspy.soundSequence
>>> song = ndspy.soundSequence.SSEQ.fromFile('never-gonna-give-you-up.sseq')
>>> song.parse()
>>> for event in song.events:
... if isinstance(event, ndspy.soundSequence.NoteSequenceEvent):
... event.pitch = 60
...
>>> song.saveToFile('never-gonna-give-you-up-but-all-the-notes-are-c.sseq')
>>>
Compress and decompress data using the LZ10 compression format:
>>> import ndspy.lz10
>>> compressed = ndspy.lz10.compress(b'This is some data to compress')
>>> compressed
b'\x10\x1d\x00\x00\x04This \x00\x02so\x00me data \x00to compr\x00ess\x00\x00\x00\x00\x00'
>>> ndspy.lz10.decompress(compressed)
b'This is some data to compress'
>>>
Search for all files starting with a particular byte sequence in a ROM:
>>> import ndspy.rom
>>> rom = ndspy.rom.NintendoDSRom.fromFile('nsmb.nds')
>>> for i, file in enumerate(rom.files):
... if file.startswith(b'BMD0'):
... print(rom.filenames[i] + ' is a NSBMD model')
...
demo/end_kp.nsbmd is a NSBMD model
demo/staffroll.nsbmd is a NSBMD model
demo/staffroll_back.nsbmd is a NSBMD model
enemy/A_jiku.nsbmd is a NSBMD model
enemy/all_goal_flag.nsbmd is a NSBMD model
...
map/world7.nsbmd is a NSBMD model
map/world8.nsbmd is a NSBMD model
>>>
Misconceptions
Still a little confused about what exactly ndspy is or what it's capable of? This section will try to answer some questions you may have.
-
ndspy is a library, not a program. To use ndspy, you have to write your own Python code; ndspy is essentially a tool your code can use. This may sound daunting -- especially if you're not very familiar with Python -- but the tutorials walk you through this process step-by-step for some common tasks. In the future, I plan to add some command-line and maybe even GUI tools powered by ndspy, but until then, this is how you use it.
-
ndspy runs on your PC, not on the Nintendo DS itself. You use it to create and modify game files, which can then be run on the console. DS games have to be written in a compiled language such as C or C++ to have any hope of being efficient; Python will never be a serious option there, unfortunately.
-
ndspy doesn't support every type of file used in every DS game. In fact, for any given game, it's likely that the majority of the game's files won't be supported by ndspy. There's a huge amount of variety in video game file formats, and it would be impossible to support them all. ndspy focuses on file formats used in many games, especially first-party ones. Support for formats that are specific to a particular game would best belong in a separate Python library instead.
That said, certain parts of ndspy (such as its support for ROM files and raw texture data) have to do with the console's hardware rather than its software, and thus should be relevant to most or all games.
Installation
ndspy-xzonn requires Python 3.12 or newer to run. CPython (the reference implementation of Python) and PyPy are both supported. Python 2, though, is not supported at all.
The easiest way to install this fork is through PyPI:
python -m pip install ndspy-xzonn
The distribution still provides the ndspy import package, so existing code
does not need to change:
import ndspy
import ndspy.lz11
import ndspy.nftr
The upstream ndspy distribution and ndspy-xzonn install the same import
package and must not be installed in the same environment. Remove upstream
ndspy before switching to this fork:
python -m pip uninstall ndspy
python -m pip install ndspy-xzonn
The latest development version can also be installed from this GitHub repository.
Documentation
The upstream ndspy documentation is hosted on Read the
Docs. It covers the shared
API, while documentation for additions in this fork is maintained in the
docs/ folder in this repository. In addition to the API
reference, there are
also
examples
and tutorials to
help you out!
Support
For questions and bugs specific to this fork, please open an issue in this repository. Questions about upstream behavior should use the upstream project's support channels.
Versioning
This fork follows semantic versioning independently of the upstream PyPI distribution. Release notes identify the upstream version or commit on which each fork release is based.
Undocumented modules are considered exempt from semantic versioning, and are subject to drastic changes at any time. This is also mentioned in the Undocumented APIs section of the documentation.
Metadata
Release files for ndspy-xzonn 4.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ndspy_xzonn-4.3.0.tar.gz | 115.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ndspy_xzonn-4.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 244.3 kB
Release files / ndspy_xzonn-4.3.0.tar.gz
| Download URL | ndspy_xzonn-4.3.0.tar.gz |
|---|---|
| Size | 115.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a530847b911b608369bb83fdeaf99fd9fc5c07942ca2f6e5a605eca4a9b3c300
|
|
BLAKE2b-256 checksum How to use checksums |
70b2281e52d077481cb3eb343d42196d6c03f61915b2c1ceb3fafc76afef96ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency logRelease files / ndspy_xzonn-4.3.0-py3-none-any.whl
| Download URL | ndspy_xzonn-4.3.0-py3-none-any.whl |
|---|---|
| Size | 128.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d45d21703e2c6f826714def42e8788a6ed5e3d7c8549f169363f2897c7b073ac
|
|
BLAKE2b-256 checksum How to use checksums |
3660b0ba7ffba32ce0c7d881e0e543109e41ce3a56b68f3110c91794fb519569
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency log