rp2cgo2

package
v0.0.0-...-a1fff32 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: GPL-2.0, GPL-2.0 Imports: 8 Imported by: 0

README

rp2cgo2

A RP 2C02 simulator written in Go

Documentation

Index

Constants

View Source
const (
	ClearBuffer int = iota
	CopyYPosition
	CopyIndex
	CopyAttributes
	CopyXPosition
	EvaluateYPosition
	EvaluateIndex
	EvaluateAttributes
	EvaluateXPosition
	FailCopyYPosition
)
View Source
const (
	CyclesPerScanline    uint16 = 341
	PowerupScanline             = 241
	StartNMIScanline            = 241
	FirstVisibleScanline        = 0
	LastVisibleScanline         = 239

	// NTSC
	NumScanlinesNTSC      = 262
	PreRenderScanlineNTSC = 261

	// PAL
	NumScanlinesPAL      = 312
	PreRenderScanlinePAL = 311

	FrameSize = 0xf000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressFlag

type AddressFlag uint16
const (
	CoarseXScroll AddressFlag = 1 << iota

	CoarseYScroll

	NametableSelect

	FineYScroll
)

type ControllerFlag

type ControllerFlag uint8
const (
	BaseNametableAddress ControllerFlag = 1 << iota

	VRAMAddressIncrement
	SpritePatternAddress
	BackgroundPatternAddress
	SpriteSize

	NMIOnVBlank
)

type CycleFunc

type CycleFunc func(oam *OAM, scanline uint16, cycle uint16, size uint16) (spriteOverflow bool)

type MaskFlag

type MaskFlag uint8
const (
	Grayscale MaskFlag = 1 << iota
	ShowBackgroundLeft
	ShowSpritesLeft
	ShowBackground
	ShowSprites
	IntensifyReds
	IntensifyGreens
	IntensifyBlues
)

type Mirroring

type Mirroring uint8
const (
	Horizontal Mirroring = iota
	Vertical
	FourScreen
)

func (Mirroring) String

func (i Mirroring) String() string

type Nametable

type Nametable struct {
	Tables [4]int
	Memory [2][0x0400]uint8
}

func NewNametable

func NewNametable() *Nametable

func (*Nametable) Fetch

func (nametable *Nametable) Fetch(address uint16) (value uint8)

func (*Nametable) Mappings

func (nametable *Nametable) Mappings(which rp2ago3.Mapping) (fetch, store []uint16)

func (*Nametable) Reset

func (nametable *Nametable) Reset()

func (*Nametable) SetTables

func (nametable *Nametable) SetTables(t0, t1, t2, t3 int)

func (*Nametable) Store

func (nametable *Nametable) Store(address uint16, value uint8) (oldValue uint8)

type OAM

type OAM struct {
	*m65go2.BasicMemory
	Address            uint16
	Latch              uint8
	Buffer             *m65go2.BasicMemory
	SpriteZeroInBuffer bool
	Index              uint16

	WriteCycle int
	// contains filtered or unexported fields
}

func NewOAM

func NewOAM() *OAM

func (*OAM) Sprite

func (oam *OAM) Sprite(index uint8) uint32

func (*OAM) SpriteEvaluation

func (oam *OAM) SpriteEvaluation(scanline uint16, cycle uint16, size uint16) (spriteOverflow bool)

type RP2C02

type RP2C02 struct {
	Frame    uint16
	Scanline uint16
	Cycle    uint16

	Registers Registers
	Memory    *rp2ago3.MappedMemory
	Palette   [32]uint8
	Nametable *Nametable
	Interrupt func(state bool) `json:"-"`
	OAM       *OAM

	Latch        bool
	LatchAddress uint16
	LatchValue   uint8

	AddressLine    uint16
	PatternAddress uint16

	AttributeNext  uint8
	AttributeLatch uint8
	Attributes     uint16

	TilesLow       uint8
	TilesHigh      uint8
	TilesLatchLow  uint8
	TilesLatchHigh uint8

	TileData [16]TileData

	Sprites        [8]Sprite
	ShowBackground bool `json:"-"`
	ShowSprites    bool `json:"-"`

	PAL               bool
	NumScanlines      uint16
	PreRenderScanline uint16
	// contains filtered or unexported fields
}

func NewRP2C02

func NewRP2C02(interrupt func(bool), region string) *RP2C02

func (*RP2C02) Execute

func (ppu *RP2C02) Execute() (colors []uint8)

func (*RP2C02) Fetch

func (ppu *RP2C02) Fetch(address uint16) (value uint8)

func (*RP2C02) GetPatternTables

func (ppu *RP2C02) GetPatternTables() (left, right *image.RGBA)

func (*RP2C02) Mappings

func (ppu *RP2C02) Mappings(which rp2ago3.Mapping) (fetch, store []uint16)

func (*RP2C02) Reset

func (ppu *RP2C02) Reset()

func (*RP2C02) SavePatternTables

func (ppu *RP2C02) SavePatternTables() (left, right *image.RGBA)

func (*RP2C02) Store

func (ppu *RP2C02) Store(address uint16, value uint8) (oldValue uint8)

func (*RP2C02) ToggleDecode

func (ppu *RP2C02) ToggleDecode() bool

func (*RP2C02) TriggerScanlineCounter

func (ppu *RP2C02) TriggerScanlineCounter() (trigger bool)

type Registers

type Registers struct {
	Controller uint8
	Mask       uint8
	Status     uint8
	OAMAddress uint8
	Scroll     uint16
	Address    uint16
	Data       uint8
}

func (*Registers) Reset

func (reg *Registers) Reset()

type Sprite

type Sprite struct {
	TileLow   uint8
	TileHigh  uint8
	Sprite    uint32
	XPosition uint8

	Address  uint16
	Priority uint8
	Zero     bool

	TileData [8]TileData
}

type SpriteFlag

type SpriteFlag uint32
const (
	// byte 0
	YPosition SpriteFlag = 1 << iota

	// byte 1
	TileBank
	TileNumber

	// byte 2
	SpritePalette

	Priority
	FlipHorizontally
	FlipVertically
	// byte 3
	XPosition
)

type StatusFlag

type StatusFlag uint8
const (
	SpriteOverflow StatusFlag
	Sprite0Hit
	VBlankStarted
)

type TileData

type TileData struct {
	Pixel uint8
	Index uint8
}

Jump to

Keyboard shortcuts

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