nds

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BannerVersionOriginal = 0x0001
	BannerVersionChinese  = 0x0002
	BannerVersionKorean   = 0x0003
	BannerVersionDSi      = 0x0103
)
View Source
const (
	TitleLanguage_Japanese = TitleLanguage(iota)
	TitleLanguage_English
	TitleLanguage_French
	TitleLanguage_German
	TitleLanguage_Italian
	TitleLanguage_Spanish
	TitleLanguage_Chinese
	TitleLanguage_Korean

	// Constant, how many languages are available in the banner
	TitleLanguage_Count
)

Variables

This section is empty.

Functions

func CRC16

func CRC16(data []byte) uint16

func DeserializePalette

func DeserializePalette(b []byte, firstTransparent bool) color.Palette

Read RGB555 palette from raw data.

func DrawTile

func DrawTile(canvas draw.Image, palette color.Palette, tile *Tile, x int, y int, mirror bool, flip bool)

Draw a single tile onto a canvas

func DrawTileSamePalette

func DrawTileSamePalette(canvas *image.Paletted, tile *Tile, x int, y int, mirror bool, flip bool)

Same as DrawTile, but can skip a lot of code to optimize

func DrawTileShiftPalette

func DrawTileShiftPalette(canvas *image.Paletted, tile *Tile, x int, y int, mirror bool, flip bool, palshift int)

Same as DrawTileSamePalette, but can shift palettes

func OpenBanner

func OpenBanner(r io.Reader) (*banner, error)

func OpenHeader

func OpenHeader(r io.ReadSeeker) (*header, error)

func ReadPalette added in v0.2.0

func ReadPalette(r io.Reader, numColors int, firstTransparent bool) (color.Palette, error)

Read RGB555 palette from raw data.

func SaveBanner

func SaveBanner(out io.Writer, b *banner) error

func SaveHeader

func SaveHeader(w io.WriteSeeker, h *header) error

TODO: validate string lengths

func SaveROM

func SaveROM(o *Rom, out io.Writer) error

Serialize ROM. TODO: ROM validation.

func SerializeIcon

func SerializeIcon(src image.Image) ([]byte, image.PalettedImage, error)

func SerializePalette

func SerializePalette(src color.Palette, pad int) ([]byte, error)

Serialized specified palette to raw RGB555 palette data. Pad specifies how long the file should be. Set pad to 0 to ignore. Will throw an error if (nonzero) pad is smaller than output size.

func SerializeTiles4BPP

func SerializeTiles4BPP(tiles []Tile) ([]byte, error)

Throws an error if color indexes go above 15.

func SerializeTiles8BPP

func SerializeTiles8BPP(tiles []*Tile) ([]byte, error)

Error is always nil and can be ignored.

Types

type Rom

type Rom struct {
	Filesystem nitrofs.NitroFS
	Arm9Binary []byte
	Arm7Binary []byte
	// contains filtered or unexported fields
}

Nintendo DS ROM structure. Contains most of the things you probably want to get from a ROM file.

func OpenROM

func OpenROM(r util.ReadAtSeeker) (*Rom, error)

Open a new ROM. TODO: ROM validation.

func (*Rom) GetBannerVersion

func (o *Rom) GetBannerVersion() uint16

func (*Rom) GetHeader

func (o *Rom) GetHeader() *header

Expose header to outside world.

func (*Rom) GetIcon

func (o *Rom) GetIcon() image.PalettedImage

Get current ROM icon.

func (*Rom) GetTitle

func (o *Rom) GetTitle(language TitleLanguage) (string, error)

Get title in specified language.

func (*Rom) SetBannerVersion

func (o *Rom) SetBannerVersion(version uint16)

func (*Rom) SetIcon

func (o *Rom) SetIcon(src image.Image) error

Set the ROM icon (if possible).

func (*Rom) SetTitle

func (o *Rom) SetTitle(title string, language TitleLanguage) error

Set title in specified language. TODO: validate newlines.

func (*Rom) String

func (o *Rom) String() string

func (*Rom) WhatsHere

func (o *Rom) WhatsHere(at uint32) *mapping.MappingEntry

type Tile

type Tile struct {
	Pix [64]byte
}

A single 8x8 tile

func DeserializeTiles4BPP

func DeserializeTiles4BPP(b []byte) []Tile

Reads a list of 8x8, 4BPP tiles from raw data.

func DeserializeTiles8BPP

func DeserializeTiles8BPP(b []byte) []Tile

Reads a list of 8x8, 8BPP tiles from raw data.

func (*Tile) ColorIndexAt

func (t *Tile) ColorIndexAt(x int, y int) byte

type Tilemap added in v0.2.0

type Tilemap struct {
	Palette    color.Palette
	Tileset    []Tile
	Attributes []TilemapAttributes
	// contains filtered or unexported fields
}

A tilemap. Implements image.PalettedImage

func NewTilemap added in v0.2.0

func NewTilemap(width, height int, tileset []Tile, palette color.Palette) *Tilemap

func (*Tilemap) At added in v0.2.0

func (tilemap *Tilemap) At(x, y int) color.Color

func (*Tilemap) Bounds added in v0.2.0

func (tilemap *Tilemap) Bounds() image.Rectangle

func (*Tilemap) ColorIndexAt added in v0.2.0

func (tilemap *Tilemap) ColorIndexAt(x, y int) uint8

func (*Tilemap) ColorModel added in v0.2.0

func (tilemap *Tilemap) ColorModel() color.Model

func (*Tilemap) GetAttributes added in v0.2.0

func (tilemap *Tilemap) GetAttributes(x, y int) TilemapAttributes

func (*Tilemap) SetAttributes added in v0.2.0

func (tilemap *Tilemap) SetAttributes(x, y int, attributes TilemapAttributes)

type TilemapAttributes added in v0.2.0

type TilemapAttributes uint16

A bitfield, but can be used like a regular uint16.

func (TilemapAttributes) GetFlipX added in v0.2.0

func (attr TilemapAttributes) GetFlipX() bool

If this tile should be mirrored or not

func (TilemapAttributes) GetFlipY added in v0.2.0

func (attr TilemapAttributes) GetFlipY() bool

If this tile should be flipped or not

func (TilemapAttributes) GetPaletteShift added in v0.2.0

func (attr TilemapAttributes) GetPaletteShift() int

For 4bpp tiles, decide which set of 16 colors to use from a 256 color palette. Value ranges from from 0 to 15.

func (TilemapAttributes) GetTileIndex added in v0.2.0

func (attr TilemapAttributes) GetTileIndex() int

Tile index

func (*TilemapAttributes) SetFlipX added in v0.2.0

func (attr *TilemapAttributes) SetFlipX(flipX bool)

func (*TilemapAttributes) SetFlipY added in v0.2.0

func (attr *TilemapAttributes) SetFlipY(flipY bool)

func (*TilemapAttributes) SetPaletteShift added in v0.2.0

func (attr *TilemapAttributes) SetPaletteShift(paletteShift int)

func (*TilemapAttributes) SetTileIndex added in v0.2.0

func (attr *TilemapAttributes) SetTileIndex(tileIndex int)

type TitleLanguage

type TitleLanguage int

IDs of languages in NDS banner titles

func (TitleLanguage) String

func (t TitleLanguage) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL