Documentation
¶
Index ¶
- Constants
- func CRC16(data []byte) uint16
- func DeserializePalette(b []byte, firstTransparent bool) color.Palette
- func DrawTile(canvas draw.Image, palette color.Palette, tile *Tile, x int, y int, ...)
- func DrawTileSamePalette(canvas *image.Paletted, tile *Tile, x int, y int, mirror bool, flip bool)
- func DrawTileShiftPalette(canvas *image.Paletted, tile *Tile, x int, y int, mirror bool, flip bool, ...)
- func OpenBanner(r io.Reader) (*banner, error)
- func OpenHeader(r io.ReadSeeker) (*header, error)
- func ReadPalette(r io.Reader, numColors int, firstTransparent bool) (color.Palette, error)
- func SaveBanner(out io.Writer, b *banner) error
- func SaveHeader(w io.WriteSeeker, h *header) error
- func SaveROM(o *Rom, out io.Writer) error
- func SerializeIcon(src image.Image) ([]byte, image.PalettedImage, error)
- func SerializePalette(src color.Palette, pad int) ([]byte, error)
- func SerializeTiles4BPP(tiles []Tile) ([]byte, error)
- func SerializeTiles8BPP(tiles []*Tile) ([]byte, error)
- type Rom
- func (o *Rom) GetBannerVersion() uint16
- func (o *Rom) GetHeader() *header
- func (o *Rom) GetIcon() image.PalettedImage
- func (o *Rom) GetTitle(language TitleLanguage) (string, error)
- func (o *Rom) SetBannerVersion(version uint16)
- func (o *Rom) SetIcon(src image.Image) error
- func (o *Rom) SetTitle(title string, language TitleLanguage) error
- func (o *Rom) String() string
- func (o *Rom) WhatsHere(at uint32) *mapping.MappingEntry
- type Tile
- type Tilemap
- func (tilemap *Tilemap) At(x, y int) color.Color
- func (tilemap *Tilemap) Bounds() image.Rectangle
- func (tilemap *Tilemap) ColorIndexAt(x, y int) uint8
- func (tilemap *Tilemap) ColorModel() color.Model
- func (tilemap *Tilemap) GetAttributes(x, y int) TilemapAttributes
- func (tilemap *Tilemap) SetAttributes(x, y int, attributes TilemapAttributes)
- type TilemapAttributes
- func (attr TilemapAttributes) GetFlipX() bool
- func (attr TilemapAttributes) GetFlipY() bool
- func (attr TilemapAttributes) GetPaletteShift() int
- func (attr TilemapAttributes) GetTileIndex() int
- func (attr *TilemapAttributes) SetFlipX(flipX bool)
- func (attr *TilemapAttributes) SetFlipY(flipY bool)
- func (attr *TilemapAttributes) SetPaletteShift(paletteShift int)
- func (attr *TilemapAttributes) SetTileIndex(tileIndex int)
- type TitleLanguage
Constants ¶
const ( BannerVersionOriginal = 0x0001 BannerVersionChinese = 0x0002 BannerVersionKorean = 0x0003 BannerVersionDSi = 0x0103 )
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 DeserializePalette ¶
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 ¶
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 OpenHeader ¶
func OpenHeader(r io.ReadSeeker) (*header, error)
func ReadPalette ¶ added in v0.2.0
Read RGB555 palette from raw data.
func SaveBanner ¶
func SerializeIcon ¶
func SerializePalette ¶
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 ¶
Throws an error if color indexes go above 15.
func SerializeTiles8BPP ¶
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 (*Rom) GetTitle ¶
func (o *Rom) GetTitle(language TitleLanguage) (string, error)
Get title in specified language.
func (*Rom) SetBannerVersion ¶
type Tile ¶
type Tile struct {
Pix [64]byte
}
A single 8x8 tile
func DeserializeTiles4BPP ¶
Reads a list of 8x8, 4BPP tiles from raw data.
func DeserializeTiles8BPP ¶
Reads a list of 8x8, 8BPP tiles from raw data.
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 (*Tilemap) ColorIndexAt ¶ added in v0.2.0
func (*Tilemap) ColorModel ¶ added in v0.2.0
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