ppu

package
v0.0.0-...-e7615e3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ScreenWidth is the width of the screen in pixels.
	ScreenWidth = 160
	// ScreenHeight is the height of the screen in pixels.
	ScreenHeight = 144
)
View Source
const (
	ModeHBlank = iota
	ModeVBlank
	ModeOAM
	ModeVRAM
)
View Source
const (
	Greyscale = iota // default
	Green            // mimics the original green screen
)

Variables

View Source
var ColourPalettes = []Palette{
	{{0xFF, 0xFF, 0xFF}, {0xAA, 0xAA, 0xAA}, {0x55, 0x55, 0x55}, {0x00, 0x00, 0x00}},
	{{0x9B, 0xBC, 0x0F}, {0x8B, 0xAC, 0x0F}, {0x30, 0x62, 0x30}, {0x0F, 0x38, 0x0F}},
}
View Source
var ColourisationPalettes = map[uint16]ColourisationPalette{}

Functions

This section is empty.

Types

type ColourPalette

type ColourPalette [8]Palette

type ColourisationPalette

type ColourisationPalette struct {
	BG, OBJ0, OBJ1 Palette
}

type PPU

type PPU struct {
	Sprites  [40]Sprite           // 40 sprite attributes from OAM
	TileData [2][384]Tile         // 384 tiles, 8x8 pixels each (double in CGB mode)
	TileMaps [2][32][32]TileEntry // 32x32 tiles, 8x8 pixels each

	// palettes used for DMG -> CGB colourisation
	BGColourisationPalette   Palette
	OBJ0ColourisationPalette Palette
	OBJ1ColourisationPalette Palette

	// palettes used by the ppu to display colours
	ColourPalette       ColourPalette
	ColourSpritePalette ColourPalette

	PreparedFrame [ScreenHeight][ScreenWidth][3]uint8

	// debug
	Debug struct {
		SpritesDisabled, BackgroundDisabled, WindowDisabled bool
	}
	// contains filtered or unexported fields
}

func New

func New(b *io.Bus, s *scheduler.Scheduler) *PPU

func (*PPU) DrawSprite

func (p *PPU) DrawSprite(img *image.RGBA, spr Sprite)

func (*PPU) DumpTileMaps

func (p *PPU) DumpTileMaps(tileMap1, tileMap2 *image.RGBA, gap int)

type Palette

type Palette [4][3]uint8 // 4 RGB values

type Sprite

type Sprite struct {
	TileEntry
	// contains filtered or unexported fields
}

Sprite is used to define the attributes of a sprite in OAM.

func (Sprite) String

func (s Sprite) String() string

type Tile

type Tile [16]uint8

A Tile has a size of 8x8 pixels, using a 2bpp format.

func (Tile) Draw

func (t Tile) Draw(img *image.RGBA, i int, i2 int, pal Palette)

Draw draws the tile to the given image at the given position.

type TileEntry

type TileEntry struct {
	// contains filtered or unexported fields
}

TileEntry is used to define a tile in the tile map or OAM.

Jump to

Keyboard shortcuts

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