Documentation
¶
Index ¶
- Constants
- Variables
- func ParseHexColor(input string) (color.RGBA, error)
- func ParseHexPalette(input string) (color.Palette, error)
- type Arrangement
- type FileHeader
- type ImageHeader
- type PatternTable
- func (pt *PatternTable) AddPatternTable(newPt *PatternTable)
- func (pt *PatternTable) AddTile(tile *Tile)
- func (pt *PatternTable) Asm(firstPlane bool) string
- func (pt *PatternTable) At(x, y int) color.Color
- func (pt *PatternTable) Bounds() image.Rectangle
- func (pt *PatternTable) Chr(firstPlane bool) []byte
- func (pt *PatternTable) ColorModel() color.Model
- func (pt *PatternTable) Debug() string
- func (pt *PatternTable) PadTileCount(count int)
- func (pt *PatternTable) PadTiles()
- func (pt *PatternTable) RemoveDuplicates(removeEmpty bool) (int, int)
- func (pt *PatternTable) RemoveEmpty() (int, int)
- func (pt *PatternTable) Set(x, y int, c color.Color)
- func (pt *PatternTable) SetPalette(pal color.Palette)
- type Tile
- func (t *Tile) ASCII() string
- func (t *Tile) Asm(half, binary bool) string
- func (t *Tile) At(x, y int) color.Color
- func (t *Tile) Bounds() image.Rectangle
- func (t *Tile) CharacterWidth() int
- func (t *Tile) Chr(firstPlane bool) []byte
- func (t *Tile) ColorModel() color.Model
- func (t *Tile) FillBackground(index uint8)
- func (t *Tile) IsEmpty() bool
- func (thisTile *Tile) IsIdentical(otherTile *Tile) bool
- func (t *Tile) IsNotEmpty() bool
- func (t *Tile) Set(x, y int, c color.Color)
- func (t *Tile) SetBackgroundIndex(index uint8)
- func (t *Tile) SetPaletteIndex(x, y int, idx uint8)
- func (t Tile) ToChr() []byte
- type TileLayout
Constants ¶
const ( TL_SINGLE = iota // Default. A single 8x8 tile. TL_8X16 // 8x16 sprites. TL_ROW // Row sequential TL_COLUMN // Column sequential TL_ASIS // Don't transform. This will break things if there's meta tiles that are not the same size. )
Variables ¶
var DefaultPalette color.Palette = color.Palette{ color.RGBA{R: 0x00, G: 0x39, B: 0x73, A: 0xFF}, color.RGBA{R: 0xAD, G: 0xB5, B: 0x31, A: 0xFF}, color.RGBA{R: 0x84, G: 0x5E, B: 0x21, A: 0xFF}, color.RGBA{R: 0xC6, G: 0xE7, B: 0x9C, A: 0xFF}, }
This is that ugly palette from YYCHR. Currently only used when saving a pattern table to a PNG image. Override this with the --palette command line option.
Note: this variable isn't actually used as the default colors are defined for the --palette option.
var NESModel color.Model = color.ModelFunc(nesModel)
Functions ¶
func ParseHexColor ¶
ParseHexColor takes a single color represented in hexidecimal format and returns a color.RGBA object on success, and an error otherwise.
Shorthand notation can be used (eg, #000 is expanded to #000000).
Types ¶
type Arrangement ¶
type Arrangement uint
const ( ARR_SINGLE Arrangement = iota ARR_DBLHIGH // 8x16 sprite mode )
type FileHeader ¶
type FileHeader struct {
Size int // size of file in bytes
Offset int // offset to start of pixel data
}
func (FileHeader) String ¶
func (f FileHeader) String() string
type ImageHeader ¶
type ImageHeader struct {
Width int
Height int
BitDepth int
Compression int
Size int // image size
ColorMapEntries int
SignificantColors int
// contains filtered or unexported fields
}
func ParseImageHeader ¶
func ParseImageHeader(input []byte) (*ImageHeader, error)
func (ImageHeader) String ¶
func (i ImageHeader) String() string
type PatternTable ¶
type PatternTable struct {
Patterns []*Tile
Layout Arrangement
ReducedIds []int
// Dimensions are in pixels
SourceWidth int
SourceHeight int
// Width in tiles
TableWidth int
}
A PatternTable is the data that will be written as the CHR. It can only be in 1k, 2k, 4k, or 8k sizes; or 64, 128, 256, or 512 tiles; or 128x32, 128x64, 128x128, or 128x256 pixels; or 4, 8, 16, or 32 rows of tiles.
func LoadBitmap ¶
func LoadBitmap(filename string) (*PatternTable, error)
func LoadCHR ¶
func LoadCHR(filename string) (*PatternTable, error)
func NewPatternTable ¶
func NewPatternTable() *PatternTable
func (*PatternTable) AddPatternTable ¶
func (pt *PatternTable) AddPatternTable(newPt *PatternTable)
func (*PatternTable) AddTile ¶
func (pt *PatternTable) AddTile(tile *Tile)
func (*PatternTable) Asm ¶
func (pt *PatternTable) Asm(firstPlane bool) string
WriteFile writes the CHR data of all the tiles in assembly format to the given file.
func (*PatternTable) At ¶
func (pt *PatternTable) At(x, y int) color.Color
TODO: Verify this actually works
func (*PatternTable) Bounds ¶
func (pt *PatternTable) Bounds() image.Rectangle
func (*PatternTable) Chr ¶
func (pt *PatternTable) Chr(firstPlane bool) []byte
Chr returns the pattern table data as bytes in the CHR format.
func (*PatternTable) ColorModel ¶
func (pt *PatternTable) ColorModel() color.Model
Implement the image.Image interface
func (*PatternTable) Debug ¶
func (pt *PatternTable) Debug() string
func (*PatternTable) PadTileCount ¶
func (pt *PatternTable) PadTileCount(count int)
PadTileCount ensures that at least count number of tiles exist in the pattern table
func (*PatternTable) PadTiles ¶
func (pt *PatternTable) PadTiles()
PadTiles ensures that all rows have 16 tiles in them.
func (*PatternTable) RemoveDuplicates ¶
func (pt *PatternTable) RemoveDuplicates(removeEmpty bool) (int, int)
Returns before/after count
func (*PatternTable) RemoveEmpty ¶
func (pt *PatternTable) RemoveEmpty() (int, int)
Returns before/after count
func (*PatternTable) Set ¶
func (pt *PatternTable) Set(x, y int, c color.Color)
TODO: Verify this works
func (*PatternTable) SetPalette ¶
func (pt *PatternTable) SetPalette(pal color.Palette)
type Tile ¶
type Tile struct {
image.Paletted
OrigId int
PaletteId int // 0-3
// contains filtered or unexported fields
}
Data is a list of palette indexes. One ID per pixel. A single tile is always 8x8 pixels. Larger meta tiles (eg, 8*16) will be made up of multiple tiles of 64 total pixels. type Tile [64]byte
func (*Tile) Asm ¶
Asm takes two parameters: Setting `half` to true will only return the first bitplane of the tile. Setting `binary` to true will use the binary notation, otherwise it will use the hexidecimal notation.
func (*Tile) CharacterWidth ¶
func (*Tile) Chr ¶
Chr returns a slice of bytes that contain both the bit planes of a tile's CHR data.
func (*Tile) FillBackground ¶
func (*Tile) IsIdentical ¶
func (*Tile) IsNotEmpty ¶
func (*Tile) SetBackgroundIndex ¶
func (*Tile) SetPaletteIndex ¶
SetPaletteIndex works like Set(), but uses an index instead of a color as input.
type TileLayout ¶
type TileLayout int
Ideally, each tile or object will be in its own input file and is assembled into the final CHR layout during assemble time.