vdp

package
v0.0.0-...-cf2a200 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumColors    = 1024
	BlockRamSize = 256
	NumSprites   = BlockRamSize
	LineBufWidth = BlockRamSize
	ScreenWidth  = 640
	ScreenHeight = 360
)
View Source
const (
	BlockX = iota
	BlockY
	BlockDims
	BlockAddr
	BlockSPos
	BlockRG
	BlockBA
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MemMap

type MemMap struct {
	SheetAddr []int
	SetAddr   []int
	NextAddr  int

	PaletteAddr int
	SpriteAddr  int
}

MemMap is a map of where sheets and sets are stored

type Pixels

type Pixels uint16

func (Pixels) Color0

func (p Pixels) Color0() int

func (Pixels) Color1

func (p Pixels) Color1() int

func (Pixels) Color2

func (p Pixels) Color2() int

func (Pixels) Color3

func (p Pixels) Color3() int

func (Pixels) SetColor0

func (p Pixels) SetColor0(v int) Pixels

func (Pixels) SetColor1

func (p Pixels) SetColor1(v int) Pixels

func (Pixels) SetColor2

func (p Pixels) SetColor2(v int) Pixels

func (Pixels) SetColor3

func (p Pixels) SetColor3(v int) Pixels

type SheetPos

type SheetPos uint16

func (SheetPos) SetSheetX

func (s SheetPos) SetSheetX(v int) SheetPos

func (SheetPos) SetSheetY

func (s SheetPos) SetSheetY(v int) SheetPos

func (SheetPos) SetWrapX

func (s SheetPos) SetWrapX(v bool) SheetPos

func (SheetPos) SetWrapY

func (s SheetPos) SetWrapY(v bool) SheetPos

func (SheetPos) SheetX

func (s SheetPos) SheetX() int

func (SheetPos) SheetY

func (s SheetPos) SheetY() int

func (SheetPos) WrapX

func (s SheetPos) WrapX() bool

func (SheetPos) WrapY

func (s SheetPos) WrapY() bool

type SpriteAddr

type SpriteAddr uint16

func (SpriteAddr) PaletteSet

func (s SpriteAddr) PaletteSet() int

func (SpriteAddr) SetPaletteSet

func (s SpriteAddr) SetPaletteSet(v int) SpriteAddr

func (SpriteAddr) SetSheetAddr

func (s SpriteAddr) SetSheetAddr(v int) SpriteAddr

func (SpriteAddr) SetTileSetAddr

func (s SpriteAddr) SetTileSetAddr(v int) SpriteAddr

func (SpriteAddr) SetTransparent

func (s SpriteAddr) SetTransparent(v bool) SpriteAddr

func (SpriteAddr) SheetAddr

func (s SpriteAddr) SheetAddr() int

func (SpriteAddr) TileSetAddr

func (s SpriteAddr) TileSetAddr() int

func (SpriteAddr) Transparent

func (s SpriteAddr) Transparent() bool

type SpriteDims

type SpriteDims uint16

func (SpriteDims) FlipX

func (s SpriteDims) FlipX() bool

func (SpriteDims) FlipY

func (s SpriteDims) FlipY() bool

func (SpriteDims) Height

func (s SpriteDims) Height() int

func (SpriteDims) SetFlipX

func (s SpriteDims) SetFlipX(v bool) SpriteDims

func (SpriteDims) SetFlipY

func (s SpriteDims) SetFlipY(v bool) SpriteDims

func (SpriteDims) SetHeight

func (s SpriteDims) SetHeight(v int) SpriteDims

func (SpriteDims) SetWidth

func (s SpriteDims) SetWidth(v int) SpriteDims

func (SpriteDims) Width

func (s SpriteDims) Width() int

type Tile

type Tile uint16

func (Tile) Palette

func (t Tile) Palette() int

func (Tile) SetPalette

func (t Tile) SetPalette(v int) Tile

func (Tile) SetTileID

func (t Tile) SetTileID(v int) Tile

func (Tile) TileID

func (t Tile) TileID() int

type VDP

type VDP struct {
	Mem    *data.Memory
	MemMap MemMap

	// block rams
	Palette [NumColors]color.RGBA
	X       [NumSprites]int16
	Y       [NumSprites]int16
	Dims    [NumSprites]SpriteDims
	Addr    [NumSprites]SpriteAddr
	SPos    [NumSprites]SheetPos
	LineBuf [LineBufWidth][4]uint16

	// state
	NumRenderedSprites int
}

VDP is an emulated Video Display Processor

func NewVDP

func NewVDP() *VDP

NewVDP creats a new VDP

func (*VDP) ClearSprites

func (vdp *VDP) ClearSprites(start, len int)

ClearSprites zeros out the specified sprites

func (*VDP) DrawFrame

func (vdp *VDP) DrawFrame(framebuf []byte)

DrawFrame draws a frame of video data onto a frame buffer

func (*VDP) HandleBus

func (vdp *VDP) HandleBus(bus data.Bus) data.Bus

func (*VDP) IncSpritePos

func (vdp *VDP) IncSpritePos(sid, x, y int)

IncSpritePos sets the x, y position of the sprite

func (*VDP) LoadFile

func (vdp *VDP) LoadFile(filename string, addrround int) (int, error)

LoadFile loads a file into memory at NextAddr with the given address granularity (will round NextAddr to the nearest even multiple of addrround)

func (*VDP) LoadPalette

func (vdp *VDP) LoadPalette(filename string) error

LoadPalette loads a palette from a file

func (*VDP) LoadSheetSets

func (vdp *VDP) LoadSheetSets(sheets, tiles string) error

LoadSheetSets loads a set of sprite sheets and tile sets

func (*VDP) ResetMemMap

func (vdp *VDP) ResetMemMap()

ResetMemMap resets the memory map so loading starts at zero

func (*VDP) SetSpriteDims

func (vdp *VDP) SetSpriteDims(sid, w, h int)

SetSpriteDims sets the width and height of the sprite

func (*VDP) SetSpritePos

func (vdp *VDP) SetSpritePos(sid, x, y int)

SetSpritePos sets the x, y position of the sprite

func (*VDP) SetSpriteSheetPos

func (vdp *VDP) SetSpriteSheetPos(sid, x, y int)

SetSpriteSheetPos sets the x, y position of the sprite in the sprite sheet

func (*VDP) SetSpriteSheetSet

func (vdp *VDP) SetSpriteSheetSet(sid, sheet, tileset int)

SetSpriteSheet sets the sheet and tile set address for a sprite from the memory map

Jump to

Keyboard shortcuts

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