nesppu

package
v0.0.0-...-fa24f98 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// STATUS
	SpriteOverflow byte = 0x20
	SpriteZeroHit  byte = 0x40 // Set when a nonzero pixel of sprite 0 overlaps a nonzero background pixel
	VBlankStarted  byte = 0x80

	// CTRL
	NameTableMask   byte = 0x03 // 0, 1, 2 or 3
	LargeIncrements byte = 0x04 // VRAM address increment per CPU read/write of PPUDATA (0: add 1, going across; 1: add 32, going down)
	AltSprites      byte = 0x08 // Sprite pattern table address for 8x8 sprites (0: $0000; 1: $1000; ignored in 8x16 mode)
	AltBackground   byte = 0x10 // Background pattern table address (0: $0000; 1: $1000)
	WideSprites     byte = 0x20 // Sprite size (0: 8x8 pixels; 1: 8x16 pixels – see PPU OAM#Byte 1)
	PpuMaster       byte = 0x40 // PPU master/slave select (0: read backdrop from EXT pins; 1: output color on EXT pins)
	GenerateNMI     byte = 0x80 // Generate an NMI at the start of the vertical blanking interval (0: off; 1: on)

	// MASK
	Greyscale       byte = 0x01 // Greyscale (0: normal color, 1: produce a greyscale display)
	ShowLeftBg      byte = 0x02 // 1: Show background in leftmost 8 pixels of screen, 0: Hide
	ShowLeftSprites byte = 0x04 // 1: Show sprites in leftmost 8 pixels of screen, 0: Hide
	ShowBg          byte = 0x08 // 1: Show background
	ShowSprites     byte = 0x10 // 1: Show sprites
	EmphasizeRed    byte = 0x20 // Emphasize red (green on PAL/Dendy)
	EmphasizeGreen  byte = 0x40 // Emphasize green (red on PAL/Dendy)
	EmphasizeBlue   byte = 0x80 // Emphasize blue

	PPUCTRL   = 0
	PPUMASK   = 1
	PPUSTATUS = 2
	OAMADDR   = 3
	OAMDATA   = 4
	PPUSCROLL = 5
	PPUADDR   = 6
	PPUDATA   = 7
)

Variables

View Source
var Palette [64]color.RGBA

Functions

This section is empty.

Types

type MirroringOption

type MirroringOption byte
const (
	InvalidMirroring MirroringOption = iota
	HorizontalMirroring
	VerticalMirroring
	SingleScreenMirroring
	SingleScreen2Mirroring
	FourScreenMirroring
	DiagonalMirroring
	LShapedMirroring
	ThreeScreenMirroring
	ThreeScreenHorizontalMirroring
	ThreeScreenDiagonalMirroring
)

type PPU

type PPU struct {
	Memory memory.Master

	OAM     [256]byte // can be edited by the CPU via DMA
	Palette [32]byte  // color palette

	// https://www.nesdev.org/wiki/PPU_scrolling#PPU_internal_registers
	V uint16 // Current VRAM address (15 bits)
	T uint16 // Temporary VRAM address (15 bits); can also be thought of as the address of the top left onscreen tile.
	X byte   // Fine X scroll (3 bits)
	W bool   // First or second write toggle (1 bit)

	VBlankInterrupt func(byte)

	// Debug trace
	Trace io.Writer
	// contains filtered or unexported fields
}

func New

func New() *PPU

func (*PPU) Clock

func (p *PPU) Clock(cnt uint64) uint64

func (*PPU) Debug

func (p *PPU) Debug() string

func (*PPU) Flip

func (p *PPU) Flip()

func (*PPU) Front

func (p *PPU) Front(cb func(*image.RGBA))

func (*PPU) Length

func (p *PPU) Length() uint16

func (*PPU) MemRead

func (p *PPU) MemRead(offset uint16) byte

func (*PPU) MemWrite

func (p *PPU) MemWrite(offset uint16, val byte) byte

func (*PPU) Ptr

func (p *PPU) Ptr() uintptr

func (*PPU) Reset

func (p *PPU) Reset()

func (*PPU) SetCustomNametables

func (ppu *PPU) SetCustomNametables(device memory.Handler, keys [4]byte)

SetCustomNametables configures nametables memory address (0x2000~0x2fff) to point to the given memory device. keys can be used to configure mirroring, allowing bits 10 and 11 of the address to be altered as needed. giving keys=[4]byte{0,1,2,3} means no rewriting happens, while other values will give various behaviors. If device is null, the PPU's internal WRAM will be used after being resized depending on the largest key provided (for example 0,1,2,3 will allocate 4kB of WRAM).

func (*PPU) SetMirroring

func (ppu *PPU) SetMirroring(mopt MirroringOption)

func (*PPU) String

func (p *PPU) String() string

Jump to

Keyboard shortcuts

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