ndspy


Namendspy JSON
Version 4.1.0 PyPI version JSON
download
home_pagehttps://github.com/RoadrunnerWMC/ndspy
SummaryPython library that can help you read, modify and create many types of files used in Nintendo DS games.
upload_time2023-07-28 08:11:05
maintainer
docs_urlNone
authorRoadrunnerWMC
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ndspy
=====

[![Discord](https://img.shields.io/discord/534221996230180884.svg?logo=discord&logoColor=white&colorB=7289da)](https://discord.gg/RQhxAxw)
[![Documentation](https://img.shields.io/badge/documentation-Read%20the%20Docs-brightgreen.svg?logo=read%20the%20docs&logoColor=white)](http://ndspy.readthedocs.io/)
[![PyPI](https://img.shields.io/pypi/v/ndspy.svg?logo=python&logoColor=white)](https://pypi.org/project/ndspy/)
[![License: GNU GPL 3.0](https://img.shields.io/github/license/RoadrunnerWMC/ndspy.svg?logo=gnu&logoColor=white)](https://www.gnu.org/licenses/gpl-3.0)

**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](https://ndspy.readthedocs.io/en/latest/api/index.html) to see the
documentation for a specific module. When you're ready to install, head over to
the [Installation](#installation) section!



A few examples of ndspy in action
---------------------------------

Create a *BMG* file containing message strings:

```python
>>> 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](https://youtu.be/cSAp9sBzPbc):

```python
>>> 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:

```python
>>> 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:

```python
>>> 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](https://ndspy.readthedocs.io/en/latest/tutorials/index.html)
    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.


<a name="installation"></a>
Installation
------------

ndspy requires Python 3.6 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 get the latest stable release of ndspy is through PyPI using
pip.

pip is a command-line application, so you'll need to use the Windows command
prompt or bash to do this. The exact command you need to enter depends on your
operating system and the settings you chose when you installed Python. One of
the following possibilities will probably work for you, though:

    pip install ndspy

    python3 -m pip install ndspy

    py -3 -m pip install ndspy

If you want the very latest version of ndspy including features and bugfixes
not yet in any official release, you can also download the code from the
[GitHub repository](https://github.com/RoadrunnerWMC/ndspy) and install it
manually.


Documentation
-------------

[ndspy's documentation is hosted on Read the
Docs](https://ndspy.readthedocs.io/en/latest/index.html), and the documentation
source code can be found in the ``docs/`` folder in this repository. In
addition to the [API
reference](https://ndspy.readthedocs.io/en/latest/api/index.html), there are
also
[examples](https://ndspy.readthedocs.io/en/latest/index.html#a-few-examples-of-ndspy-in-action)
and [tutorials](https://ndspy.readthedocs.io/en/latest/tutorials/index.html) to
help you out!


Support
-------

I spent a long time writing the documentation for ndspy, so first please
double-check that your question isn't already answered in the [API
reference](https://ndspy.readthedocs.io/en/latest/api/index.html) or
[Tutorials](https://ndspy.readthedocs.io/en/latest/tutorials/index.html)
sections in the documentation.

If that doesn't help, you can ask me (RoadrunnerWMC) your questions via [the
ndspy Discord server](https://discord.gg/RQhxAxw). I'll try to get back to
you as quickly as I can!

If you think you've found a bug in ndspy, please [file an issue on
GitHub](https://github.com/RoadrunnerWMC/ndspy/issues/new). Thanks!


Versioning
----------

ndspy follows [semantic versioning](https://semver.org/) to the best of my
ability. If a tool claims to work with ndspy 1.0.2, it should also work with
ndspy 1.2.0, but not necessarily 2.0.0. (Please note that not all of those
version numbers actually exist!)

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](https://ndspy.readthedocs.io/en/latest/api/index.html#undocumented-apis)
section of the documentation.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RoadrunnerWMC/ndspy",
    "name": "ndspy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "RoadrunnerWMC",
    "author_email": "roadrunnerwmc@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/12/19/33a7a3b4549950ad96fbbf2944b9e69dc67e54c0b99fc22b309e146cbd3b/ndspy-4.1.0.tar.gz",
    "platform": null,
    "description": "ndspy\n=====\n\n[![Discord](https://img.shields.io/discord/534221996230180884.svg?logo=discord&logoColor=white&colorB=7289da)](https://discord.gg/RQhxAxw)\n[![Documentation](https://img.shields.io/badge/documentation-Read%20the%20Docs-brightgreen.svg?logo=read%20the%20docs&logoColor=white)](http://ndspy.readthedocs.io/)\n[![PyPI](https://img.shields.io/pypi/v/ndspy.svg?logo=python&logoColor=white)](https://pypi.org/project/ndspy/)\n[![License: GNU GPL 3.0](https://img.shields.io/github/license/RoadrunnerWMC/ndspy.svg?logo=gnu&logoColor=white)](https://www.gnu.org/licenses/gpl-3.0)\n\n**ndspy** (\"en-dee-ESS-pie\") is a Python library and suite of command-line\ntools that can help you read, modify and create many types of files used in\nNintendo DS games.\n\nndspy follows a few key design principles:\n\n-   **Accuracy**: ndspy should be able to open and resave any supported file\n    with byte-for-byte accuracy if it's in its canonical format.\n-   **Flexibility**: ndspy should be able to read any valid file in a format it\n    supports. In cases where there's a high chance it will be unable to fully\n    interpret some especially complex part of a file, it should still be useful\n    for editing the other parts.\n-   **Semantic**: ndspy's APIs should closely match the semantics of file\n    structures while hiding their binary-level details.\n\nndspy provides both a Python API and a set of simple command-line tools that\nmake use of it. The command-line tools let you convert files to and from binary\nformats without having to write any Python code yourself. The API is suitable\nfor use in applications written in Python, and in scripts to do more complex\ntasks than the command-line tools are capable of.\n\nAs ndspy is written in pure Python, it is cross-platform and should run on all\nplatforms Python supports. Note that Python doesn't support the Nintendo DS\nitself; ndspy is intended to be used on your PC.\n\nInterested? Read on to see some examples, or check the [API\nReference](https://ndspy.readthedocs.io/en/latest/api/index.html) to see the\ndocumentation for a specific module. When you're ready to install, head over to\nthe [Installation](#installation) section!\n\n\n\nA few examples of ndspy in action\n---------------------------------\n\nCreate a *BMG* file containing message strings:\n\n```python\n>>> import ndspy.bmg\n>>> message1 = ndspy.bmg.Message(b'', ['Open your eyes...'])\n>>> message2 = ndspy.bmg.Message(b'', ['Wake up, Link...'])\n>>> bmg = ndspy.bmg.BMG.fromMessages([message1, message2])\n>>> bmg.save()\nb'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'\n>>>\n```\n\nChange all notes in a *SSEQ* sequenced music file to middle C, similar to [this\nsong](https://youtu.be/cSAp9sBzPbc):\n\n```python\n>>> import ndspy.soundSequence\n>>> song = ndspy.soundSequence.SSEQ.fromFile('never-gonna-give-you-up.sseq')\n>>> song.parse()\n>>> for event in song.events:\n...     if isinstance(event, ndspy.soundSequence.NoteSequenceEvent):\n...         event.pitch = 60\n...\n>>> song.saveToFile('never-gonna-give-you-up-but-all-the-notes-are-c.sseq')\n>>>\n```\n\nCompress and decompress data using the *LZ10* compression format:\n\n```python\n>>> import ndspy.lz10\n>>> compressed = ndspy.lz10.compress(b'This is some data to compress')\n>>> compressed\nb'\\x10\\x1d\\x00\\x00\\x04This \\x00\\x02so\\x00me data \\x00to compr\\x00ess\\x00\\x00\\x00\\x00\\x00'\n>>> ndspy.lz10.decompress(compressed)\nb'This is some data to compress'\n>>>\n```\n\nSearch for all files starting with a particular byte sequence in a ROM:\n\n```python\n>>> import ndspy.rom\n>>> rom = ndspy.rom.NintendoDSRom.fromFile('nsmb.nds')\n>>> for i, file in enumerate(rom.files):\n...     if file.startswith(b'BMD0'):\n...         print(rom.filenames[i] + ' is a NSBMD model')\n...\ndemo/end_kp.nsbmd is a NSBMD model\ndemo/staffroll.nsbmd is a NSBMD model\ndemo/staffroll_back.nsbmd is a NSBMD model\nenemy/A_jiku.nsbmd is a NSBMD model\nenemy/all_goal_flag.nsbmd is a NSBMD model\n...\nmap/world7.nsbmd is a NSBMD model\nmap/world8.nsbmd is a NSBMD model\n>>>\n```\n\n\nMisconceptions\n--------------\n\nStill a little confused about what exactly ndspy is or what it's capable of?\nThis section will try to answer some questions you may have.\n\n-   ndspy is a *library*, not a *program.* To use ndspy, you have to write your\n    own Python code; ndspy is essentially a tool your code can use. This may\n    sound daunting -- especially if you're not very familiar with Python -- but\n    the\n    [tutorials](https://ndspy.readthedocs.io/en/latest/tutorials/index.html)\n    walk you through this process step-by-step for some common tasks. In the\n    future, I plan to add some command-line and maybe even GUI tools powered by\n    ndspy, but until then, this is how you use it.\n-   ndspy runs on your PC, not on the Nintendo DS itself. You use it to create\n    and modify game files, which can then be run on the console. DS games have\n    to be written in a compiled language such as C or C++ to have any hope of\n    being efficient; Python will never be a serious option there,\n    unfortunately.\n-   ndspy doesn't support every type of file used in every DS game. In fact,\n    for any given game, it's likely that the majority of the game's files\n    *won't* be supported by ndspy. There's a huge amount of variety in video\n    game file formats, and it would be impossible to support them all. ndspy\n    focuses on file formats used in many games, especially first-party ones.\n    Support for formats that are specific to a particular game would best\n    belong in a separate Python library instead.\n\n    That said, certain parts of ndspy (such as its support for ROM files and\n    raw texture data) have to do with the console's hardware rather than its\n    software, and thus should be relevant to most or all games.\n\n\n<a name=\"installation\"></a>\nInstallation\n------------\n\nndspy requires Python 3.6 or newer to run. CPython (the reference\nimplementation of Python) and PyPy are both supported. Python 2, though, is not\nsupported at all.\n\nThe easiest way to get the latest stable release of ndspy is through PyPI using\npip.\n\npip is a command-line application, so you'll need to use the Windows command\nprompt or bash to do this. The exact command you need to enter depends on your\noperating system and the settings you chose when you installed Python. One of\nthe following possibilities will probably work for you, though:\n\n    pip install ndspy\n\n    python3 -m pip install ndspy\n\n    py -3 -m pip install ndspy\n\nIf you want the very latest version of ndspy including features and bugfixes\nnot yet in any official release, you can also download the code from the\n[GitHub repository](https://github.com/RoadrunnerWMC/ndspy) and install it\nmanually.\n\n\nDocumentation\n-------------\n\n[ndspy's documentation is hosted on Read the\nDocs](https://ndspy.readthedocs.io/en/latest/index.html), and the documentation\nsource code can be found in the ``docs/`` folder in this repository. In\naddition to the [API\nreference](https://ndspy.readthedocs.io/en/latest/api/index.html), there are\nalso\n[examples](https://ndspy.readthedocs.io/en/latest/index.html#a-few-examples-of-ndspy-in-action)\nand [tutorials](https://ndspy.readthedocs.io/en/latest/tutorials/index.html) to\nhelp you out!\n\n\nSupport\n-------\n\nI spent a long time writing the documentation for ndspy, so first please\ndouble-check that your question isn't already answered in the [API\nreference](https://ndspy.readthedocs.io/en/latest/api/index.html) or\n[Tutorials](https://ndspy.readthedocs.io/en/latest/tutorials/index.html)\nsections in the documentation.\n\nIf that doesn't help, you can ask me (RoadrunnerWMC) your questions via [the\nndspy Discord server](https://discord.gg/RQhxAxw). I'll try to get back to\nyou as quickly as I can!\n\nIf you think you've found a bug in ndspy, please [file an issue on\nGitHub](https://github.com/RoadrunnerWMC/ndspy/issues/new). Thanks!\n\n\nVersioning\n----------\n\nndspy follows [semantic versioning](https://semver.org/) to the best of my\nability. If a tool claims to work with ndspy 1.0.2, it should also work with\nndspy 1.2.0, but not necessarily 2.0.0. (Please note that not all of those\nversion numbers actually exist!)\n\nUndocumented modules are considered exempt from semantic versioning, and are\nsubject to drastic changes at any time. This is also mentioned in the\n[Undocumented\nAPIs](https://ndspy.readthedocs.io/en/latest/api/index.html#undocumented-apis)\nsection of the documentation.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python library that can help you read, modify and create many types of files used in Nintendo DS games.",
    "version": "4.1.0",
    "project_urls": {
        "Homepage": "https://github.com/RoadrunnerWMC/ndspy"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "55f5722373a8af1c54f3e78734f826d4e2d37f6d96f42e71a2f57ba1bb84d6d3",
                "md5": "5da79eb48a45fcc48ce62929d74b057d",
                "sha256": "46bdb1491ea27f6b14b15a51930a607b17e4502ad42ad12674ea4c5d04d66ea7"
            },
            "downloads": -1,
            "filename": "ndspy-4.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5da79eb48a45fcc48ce62929d74b057d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 138257,
            "upload_time": "2023-07-28T08:11:03",
            "upload_time_iso_8601": "2023-07-28T08:11:03.221289Z",
            "url": "https://files.pythonhosted.org/packages/55/f5/722373a8af1c54f3e78734f826d4e2d37f6d96f42e71a2f57ba1bb84d6d3/ndspy-4.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "121933a7a3b4549950ad96fbbf2944b9e69dc67e54c0b99fc22b309e146cbd3b",
                "md5": "bf0586d7dcf012a0472e461450955ac7",
                "sha256": "1576ca7ec5542075511185133c20c9b722b118f4aaf52929f0408d6081eee013"
            },
            "downloads": -1,
            "filename": "ndspy-4.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bf0586d7dcf012a0472e461450955ac7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 128457,
            "upload_time": "2023-07-28T08:11:05",
            "upload_time_iso_8601": "2023-07-28T08:11:05.421572Z",
            "url": "https://files.pythonhosted.org/packages/12/19/33a7a3b4549950ad96fbbf2944b9e69dc67e54c0b99fc22b309e146cbd3b/ndspy-4.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-28 08:11:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RoadrunnerWMC",
    "github_project": "ndspy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ndspy"
}
        
Elapsed time: 0.22412s