gpu

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2013 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CGB_VRAM_BANK_SELECT        types.Word = 0xFF4F
	CGB_BGP_WRITESPEC_REGISTER             = 0xFF68
	CGB_BGP_WRITEDATA_REGISTER             = 0xFF69
	CGB_OBJP_WRITESPEC_REGISTER            = 0xFF6A
	CGB_OBJP_WRITEDATA_REGISTER            = 0xFF6B
)

Colour GB graphics register addresses

View Source
const (
	TILEMAP0  types.Word = 0x9800
	TILEMAP1             = 0x9C00
	TILEDATA0            = 0x8800
	TILEDATA1            = 0x8000
)
View Source
const (
	LCDC            types.Word = 0xFF40
	STAT                       = 0xFF41
	SCROLLY                    = 0xFF42
	SCROLLX                    = 0xFF43
	LY                         = 0xFF44
	LYC                        = 0xFF45
	BGP                        = 0xFF47
	OBJECTPALETTE_0            = 0xFF48
	OBJECTPALETTE_1            = 0xFF49
	WX                         = 0xFF4B
	WY                         = 0xFF4A
)

Standard graphics register addresses

View Source
const DISPLAY_HEIGHT int = 144
View Source
const DISPLAY_WIDTH int = 160
View Source
const HBLANK byte = 0x00
View Source
const NAME = "GPU"
View Source
const OAMREAD byte = 0x02
View Source
const PREFIX = NAME + ":"
View Source
const Sprite8x16Mode byte = 0
View Source
const Sprite8x8Mode byte = 1
View Source
const VBLANK byte = 0x01
View Source
const VRAMREAD byte = 0x03

Variables

View Source
var GBColours []types.RGB = []types.RGB{
	types.RGB{Red: 235, Green: 235, Blue: 235},
	types.RGB{Red: 196, Green: 196, Blue: 196},
	types.RGB{Red: 96, Green: 96, Blue: 96},
	types.RGB{Red: 0, Green: 0, Blue: 0},
}

Functions

This section is empty.

Types

type CGBBackgroundTileAttrs

type CGBBackgroundTileAttrs struct {
	HasPriority      bool
	FlipHorizontally bool
	FlipVertically   bool
	BankNo           int
	PaletteNo        int
}

Represents the attribute data for a background tile

func NewCGBBackgroundTileAttrs

func NewCGBBackgroundTileAttrs(attributeData byte) *CGBBackgroundTileAttrs

func (*CGBBackgroundTileAttrs) String

func (cattr *CGBBackgroundTileAttrs) String() string

type CGBColor

type CGBColor types.Word

Represents a color

func (CGBColor) High

func (c CGBColor) High() byte

func (CGBColor) Low

func (c CGBColor) Low() byte

func (CGBColor) ToRGB

func (c CGBColor) ToRGB() types.RGB

type CGBPalette

type CGBPalette [4]CGBColor

Represents a color palette (4 colors)

func (*CGBPalette) UpdateHigh

func (cp *CGBPalette) UpdateHigh(colorNo int, value byte)

func (*CGBPalette) UpdateLow

func (cp *CGBPalette) UpdateLow(colorNo int, value byte)

type CGBPaletteSpecRegister

type CGBPaletteSpecRegister struct {
	Value           byte
	PalleteNo       int
	PalleteDataNo   int
	High            bool
	IncrementOnNext bool
}

Represents the write specification register for a color palette

func (*CGBPaletteSpecRegister) Increment

func (psr *CGBPaletteSpecRegister) Increment()

func (*CGBPaletteSpecRegister) Update

func (psr *CGBPaletteSpecRegister) Update(value byte)

type GPU

type GPU struct {
	RunningColorGBHardware bool
	// contains filtered or unexported fields
}

func NewGPU

func NewGPU() *GPU

func (*GPU) CoincidenceLCDInterruptEnabled

func (g *GPU) CoincidenceLCDInterruptEnabled() bool

func (*GPU) DrawScanline

func (g *GPU) DrawScanline(tilemapOffset, lineOffset types.Word, screenX, tileX, tileY int)

func (*GPU) DrawSpriteTileLine

func (g *GPU) DrawSpriteTileLine(s Sprite, tileId, screenYOffset, tileY int)

TODO: Sprite precedence rules Draws a tile for the given sprite. Only draws one tile

func (*GPU) Dump8x8Sprites

func (g *GPU) Dump8x8Sprites() [40][8][8]types.RGB

func (*GPU) DumpTilemap

func (g *GPU) DumpTilemap(tileMapAddr types.Word, tileDataSigned bool) [256][256]types.RGB

func (*GPU) DumpTiles

func (g *GPU) DumpTiles() [512][8][8]types.RGB

debug helpers

func (*GPU) HblankLCDInterruptEnabled

func (g *GPU) HblankLCDInterruptEnabled() bool

func (*GPU) LinkIRQHandler

func (g *GPU) LinkIRQHandler(m components.IRQHandler)

func (*GPU) LinkScreen

func (g *GPU) LinkScreen(screen inputoutput.Screen)

func (*GPU) Name

func (g *GPU) Name() string

func (*GPU) Read

func (g *GPU) Read(addr types.Word) byte

Called from mmu

func (*GPU) ReadFromVideoRAM

func (g *GPU) ReadFromVideoRAM(addr types.Word) byte

func (*GPU) RenderBackgroundScanline

func (g *GPU) RenderBackgroundScanline()

func (*GPU) RenderSpritesOnScanline

func (g *GPU) RenderSpritesOnScanline()

func (*GPU) RenderWindowScanline

func (g *GPU) RenderWindowScanline()

func (*GPU) Reset

func (g *GPU) Reset()

func (*GPU) Step

func (g *GPU) Step(t int)

func (*GPU) UpdateSprite

func (g *GPU) UpdateSprite(addr types.Word, value byte)

func (*GPU) UpdateTile

func (g *GPU) UpdateTile(addr types.Word, value byte, bank byte)

Update the tile at address with value

func (*GPU) VBlankLCDInterruptEnabled

func (g *GPU) VBlankLCDInterruptEnabled() bool

func (*GPU) Write

func (g *GPU) Write(addr types.Word, value byte)

Called from mmu

func (*GPU) WriteToVideoRAM

func (g *GPU) WriteToVideoRAM(addr types.Word, value byte)

type Palette

type Palette [4]types.RGB

type RawTile

type RawTile [16]byte

type Sprite

type Sprite interface {
	UpdateSprite(addr types.Word, value byte)
	GetTileID(no int) int
	SpriteAttributes() *SpriteAttributes
	PushScanlines(fromScanline, amount int)
	PopScanline() (int, int)
	IsScanlineDrawQueueEmpty() bool
	ResetScanlineDrawQueue()
}

type Sprite8x16

type Sprite8x16 struct {
	SpriteAttrs       *SpriteAttributes
	TileIDs           [2]int
	ScanlineDrawQueue []int
	CurrentTileLine   int
}

8x16 SPRITES!

func NewSprite8x16

func NewSprite8x16() *Sprite8x16

func (*Sprite8x16) GetTileID

func (s *Sprite8x16) GetTileID(no int) int

func (*Sprite8x16) IsScanlineDrawQueueEmpty

func (s *Sprite8x16) IsScanlineDrawQueueEmpty() bool

func (*Sprite8x16) PopScanline

func (s *Sprite8x16) PopScanline() (int, int)

func (*Sprite8x16) PushScanlines

func (s *Sprite8x16) PushScanlines(fromScanline, amount int)

func (*Sprite8x16) ResetScanlineDrawQueue

func (s *Sprite8x16) ResetScanlineDrawQueue()

func (*Sprite8x16) SpriteAttributes

func (s *Sprite8x16) SpriteAttributes() *SpriteAttributes

func (*Sprite8x16) String

func (s *Sprite8x16) String() string

func (*Sprite8x16) UpdateSprite

func (s *Sprite8x16) UpdateSprite(addr types.Word, value byte)

type Sprite8x8

type Sprite8x8 struct {
	SpriteAttrs       *SpriteAttributes
	TileID            int
	ScanlineDrawQueue []int
	CurrentTileLine   int
}

8x8 Sprites!

func NewSprite8x8

func NewSprite8x8() *Sprite8x8

func (*Sprite8x8) GetTileID

func (s *Sprite8x8) GetTileID(no int) int

func (*Sprite8x8) IsScanlineDrawQueueEmpty

func (s *Sprite8x8) IsScanlineDrawQueueEmpty() bool

func (*Sprite8x8) PopScanline

func (s *Sprite8x8) PopScanline() (int, int)

func (*Sprite8x8) PushScanlines

func (s *Sprite8x8) PushScanlines(fromScanline, amount int)

func (*Sprite8x8) ResetScanlineDrawQueue

func (s *Sprite8x8) ResetScanlineDrawQueue()

func (*Sprite8x8) SpriteAttributes

func (s *Sprite8x8) SpriteAttributes() *SpriteAttributes

func (*Sprite8x8) String

func (s *Sprite8x8) String() string

func (*Sprite8x8) UpdateSprite

func (s *Sprite8x8) UpdateSprite(addr types.Word, value byte)

type SpriteAttributes

type SpriteAttributes struct {
	Y                      int
	X                      int
	SpriteHasPriority      bool
	ShouldFlipVertically   bool
	ShouldFlipHorizontally bool
	NonCGBPaletteSelected  int
	CGBBankNo              int
	CGBPaletteNo           int
}

Sprite attributes

func (*SpriteAttributes) String

func (s *SpriteAttributes) String() string

func (*SpriteAttributes) Update

func (sa *SpriteAttributes) Update(attributeId int, fromValue byte)

type Tile

type Tile [8][8]int

Jump to

Keyboard shortcuts

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