/Ekona

.NET implementation of DS and DSi file formats

Primary LanguageC#MIT LicenseMIT

Ekona

Stable version   GitHub commits since latest release (by SemVer)   Build and release   MIT License  

Ekona is a library part of the SceneGate framework that provides support for DS and DSi file formats.

Supported formats

  • 🎮 DS cartridge:
    • 📁 Filesystem: read and write
    • ℹ️ Header: read and write, including extended header
    • 🖼️ Banner and icon: read and write.
    • 🔐 ARM9 secure area encryption and decryption (KEY1).
  • 🎮 DSi cartridge:
    • 📁 Filesystem: read and write arm9i and arm7i programs.
    • ℹ️ Extended header: read and write
    • 🖼️ Animated banner icons
    • 🔐 Modcrypt encryption and decryption
    • 🔏 HMAC validation and generation when keys are provided.
    • 🔏 Signature validation when keys are provided.

Getting started

Check-out the getting started guide to start using Ekona in no time! Below you can find an example that shows how to open a DS/DSi ROM file (cartridge dump).

// Create Yarhl node from a file (binary format).
Node game = NodeFactory.FromFile("game.nds", FileOpenMode.Read);

// Use the `Binary2NitroRom` converter to convert the binary format
// into node containers (virtual file system tree with files and directories).
game.TransformWith<Binary2NitroRom>();

// And it's done!
// Now we can access to every game file. For instance, we can export one file
Node items = Navigator.SearchNode(game, "data/Items.dat");
items.Stream.WriteTo("dump/Items.dat");

Usage

The project provides the following .NET libraries (NuGet packages in nuget.org). The libraries works on supported versions of .NET: 6.0 and 8.0.

  • SceneGate.Ekona
    • SceneGate.Ekona.Containers.Rom: DS and DSi cartridge (ROM) format.
    • SceneGate.Ekona.Security: hash and encryption algorithms

Preview releases can be found in this Azure DevOps package repository. To use a preview release, create a file nuget.config in the same directory of your solution file (.sln) with the following content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear/>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="SceneGate-Preview" value="https://pkgs.dev.azure.com/SceneGate/SceneGate/_packaging/SceneGate-Preview/nuget/v3/index.json" />
  </packageSources>
  <packageSourceMapping>
    <packageSource key="nuget.org">
      <package pattern="*" />
    </packageSource>
    <packageSource key="SceneGate-Preview">
      <package pattern="Yarhl*" />
      <package pattern="Texim*" />
      <package pattern="SceneGate*" />
    </packageSource>
  </packageSourceMapping>
</configuration>

Documentation

You can get full details about how to use library from the documentation website.

Don't miss the formats specifications in case you need to do further research.

And don't hesitate to ask questions in the project Discussion site!

Build

The project requires to build .NET 8.0 SDK.

To build, test and generate artifacts run:

# Build and run tests
dotnet run --project build/orchestrator

# (Optional) Create bundles (nuget, zips, docs)
dotnet run --project build/orchestrator -- --target=Bundle

To build the documentation only, run:

dotnet docfx docs/docfx.json --serve

To run the performance test with memory and CPU traces:

dotnet run --project src/Ekona.PerformanceTests/ -c Release -- -f "*<TestName>*" -m -p EP --maxWidth 60

Special thanks

The DS / DSi cartridge format was based on the amazing reverse engineering work of Martin Korth at GBATek. Its specifications of the hardware of the video controller and I/O ports was also a great help in additional reverse engineering.