ppu

package
v0.0.0-...-45a14b4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const NAMETABLE_SIZE = 1024
View Source
const NES_PALETTE_COLORS = 64
View Source
const NameTableEndAddress = types.Address(0x2FFF)
View Source
const NameTableStartAddress = types.Address(0x2000)
View Source
const OAMADDR = 0x2003
View Source
const OAMDATA = 0x2004
View Source
const OAMDATA_SIZE = 256

Memory sizes

View Source
const OAMDMA = 0x4014
View Source
const PALETTE_COUNT = 8
View Source
const PALETTE_SIZE = 32
View Source
const PPUADDR = 0x2006
View Source
const PPUCTRL = 0x2000

PPUCTRL NMI enable (V), PPU master/slave (P), sprite height (H), background tile select (B), sprite tile select (S), increment mode (I), name table select (NN)

View Source
const PPUDATA = 0x2007
View Source
const PPUMASK = 0x2001

PPUMASK color emphasis (BGR), sprite enable (s), background enable (b),

View Source
const PPUSCROLL = 0x2005
View Source
const PPUSTATUS = 0x2002

PPSTATUS sprite left column enable (M), background left column enable (m), greyscale (G) vblank (V), sprite 0 hit (S), sprite overflow (O); read resets write pair for $2005/$2006

View Source
const PPU_CONTROL_SPRITE_SIZE_16 = 1
View Source
const PPU_CONTROL_SPRITE_SIZE_8 = 0
View Source
const PPU_CYCLES_BY_SCANLINE = 341
View Source
const PPU_CYCLES_TO_WARMUP = 29658 / 3

Other

View Source
const PPU_HIGH_ADDRESS = types.Address(0x3FFF)
View Source
const PPU_LOG_BUFFER_MAXSIZE = 120000
View Source
const PPU_NAMETABLES_0_END = types.Address(0x23C0)
View Source
const PPU_SCANLINES = 261
View Source
const PPU_SCREEN_SPACE_CYCLES_BY_SCANLINE = 256
View Source
const PPU_SCREEN_SPACE_SCANLINES = 240
View Source
const PPU_VBLANK_END_CYCLE = PPU_SCANLINES * PPU_CYCLES_BY_SCANLINE
View Source
const PPU_VBLANK_START_CYCLE = (PPU_SCREEN_SPACE_SCANLINES + 1) * PPU_CYCLES_BY_SCANLINE
View Source
const PaletteHighAddress = types.Address(0x3FFF)
View Source
const PaletteLowAddress = types.Address(0x3F00)

Memory

View Source
const PatternTable0Address = types.Address(0x0000)
View Source
const PatternTable1Address = types.Address(0x1000)
View Source
const TILE_HEIGHT = 8
View Source
const TILE_PIXELS = 8 * 8
View Source
const TILE_WIDTH = 8
View Source
const VBLANK_END_SCNALINE = 261
View Source
const VBLANK_START_SCANLINE = 241

Variables

View Source
var SystemPalette = [NES_PALETTE_COLORS][3]byte{
	{84, 84, 84},
	{0, 30, 116},
	{8, 16, 144},
	{48, 0, 136},
	{68, 0, 100},
	{92, 0, 48},
	{84, 4, 0},
	{60, 24, 0},
	{32, 42, 0},
	{8, 58, 0},
	{0, 64, 0},
	{0, 60, 0},
	{0, 50, 60},
	{0, 0, 0},
	{0, 0, 0},
	{0, 0, 0},

	{152, 150, 152},
	{8, 76, 196},
	{48, 50, 236},
	{92, 30, 228},
	{136, 20, 176},
	{160, 20, 100},
	{152, 34, 32},
	{120, 60, 0},
	{84, 90, 0},
	{40, 114, 0},
	{8, 124, 0},
	{0, 118, 40},
	{0, 102, 120},
	{0, 0, 0},
	{0, 0, 0},
	{0, 0, 0},

	{236, 238, 236},
	{76, 154, 236},
	{120, 124, 236},
	{176, 98, 236},
	{228, 84, 236},
	{236, 88, 180},
	{236, 106, 100},
	{212, 136, 32},
	{160, 170, 0},
	{116, 196, 0},
	{76, 208, 32},
	{56, 204, 108},
	{56, 180, 204},
	{60, 60, 60},
	{0, 0, 0},
	{0, 0, 0},

	{236, 238, 236},
	{168, 204, 236},
	{188, 188, 236},
	{212, 178, 236},
	{236, 174, 236},
	{236, 174, 212},
	{236, 180, 176},
	{228, 196, 144},
	{204, 210, 120},
	{180, 222, 120},
	{168, 226, 144},
	{152, 226, 180},
	{160, 214, 228},
	{160, 162, 160},
	{0, 0, 0},
	{0, 0, 0},
}

Functions

func NewLogger2c02

func NewLogger2c02(enabled bool, outputPath string) *logger2c02

func SaveTile

func SaveTile(fileName string, tile *image.RGBA)

Types

type Control

type Control struct {
	NameTableX                    byte // Most significant bit of scrolling coordinates (X)
	NameTableY                    byte // Most significant bit of scrolling coordinates (Y)
	IncrementMode                 byte // Address increment per CPU IO of PPUDATA. (0: add 1, going across; 1: add 32, going down)
	SpritePatternTableAddress     byte // Sprite pattern table address for 8x8 sprites. (0: $0000; 1: $1000; ignored in 8x16 mode)
	BackgroundPatternTableAddress byte // Background pattern table address (0: $0000; 1: $1000)
	SpriteSize                    byte // 0: 8x8   1:8x16
	MasterSlaveSelect             byte
	GenerateNMIAtVBlank           bool // NMI enabled/disabled
}

func (*Control) Value

func (control *Control) Value() byte

type LoopyRegister

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

LoopyRegister Internal PPU Register The 15 bit registers t and v are composed this way during rendering:

yyy NN YYYYY XXXXX
||| || ||||| +++++-- coarse X scroll
||| || +++++-------- coarse Y scroll
||| ++-------------- nametable select
+++----------------- fine Y scroll

func (*LoopyRegister) CoarseX

func (register *LoopyRegister) CoarseX() byte

func (*LoopyRegister) CoarseY

func (register *LoopyRegister) CoarseY() byte

func (*LoopyRegister) FineY

func (register *LoopyRegister) FineY() byte

func (*LoopyRegister) NameTableX

func (register *LoopyRegister) NameTableX() byte

func (*LoopyRegister) NameTableY

func (register *LoopyRegister) NameTableY() byte

func (*LoopyRegister) Value

func (register *LoopyRegister) Value() types.Address

type Mask

type Mask struct {
	GreyScale              byte
	ShowBackgroundLeftMost byte
	ShowSpritesLeftMost    byte
	ShowBackground         byte // x8
	ShowSprites            byte
	EmphasizeRed           byte
	EmphasizeGreen         byte
	EmphasizeBlue          byte
}

func (*Mask) Value

func (register *Mask) Value() byte

type P2c02

type P2c02 struct {
	PpuControl Control
	PpuStatus  Status
	PpuMask    Mask // Controls the rendering of sprites and backgrounds
	// contains filtered or unexported fields
}

func CreatePPU

func CreatePPU(cartridge *gamePak.GamePak, debug bool, logPath string) *P2c02

func (*P2c02) FineX

func (ppu *P2c02) FineX() uint8

func (*P2c02) Frame

func (ppu *P2c02) Frame() *image.RGBA

func (*P2c02) FrameComplete

func (ppu *P2c02) FrameComplete() bool

func (*P2c02) FrameNumber

func (ppu *P2c02) FrameNumber() uint16

func (*P2c02) FramePattern

func (ppu *P2c02) FramePattern() []byte

func (*P2c02) GetPaletteColor

func (ppu *P2c02) GetPaletteColor(palette byte, colorIndex byte) byte

func (*P2c02) GetRGBColor

func (ppu *P2c02) GetRGBColor(palette byte, colorIndex byte) color.RGBA

//$3F00 Universal background color //$3F01-$3F03 Background palette 0 //$3F05-$3F07 Background palette 1 //$3F09-$3F0B Background palette 2 //$3F0D-$3F0F Background palette 3 //$3F11-$3F13 Sprite palette 0 //$3F15-$3F17 Sprite palette 1 //$3F19-$3F1B Sprite palette 2 //$3F1D-$3F1F Sprite palette 3

func (*P2c02) Nmi

func (ppu *P2c02) Nmi() bool

func (*P2c02) Oam

func (ppu *P2c02) Oam(index byte) []byte

func (*P2c02) PatternTable

func (ppu *P2c02) PatternTable(patternTable byte, palette byte) image.RGBA

func (*P2c02) Peek

func (ppu *P2c02) Peek(address types.Address) byte

func (*P2c02) Read

func (ppu *P2c02) Read(address types.Address) byte

func (*P2c02) ReadRegister

func (ppu *P2c02) ReadRegister(register types.Address) byte

Read made by CPU

func (*P2c02) Render

func (ppu *P2c02) Render()

func (*P2c02) RenderCycle

func (ppu *P2c02) RenderCycle() uint16

func (*P2c02) ResetNmi

func (ppu *P2c02) ResetNmi()

func (*P2c02) Scanline

func (ppu *P2c02) Scanline() Scanline

func (*P2c02) Stop

func (ppu *P2c02) Stop()

func (*P2c02) TRam

func (ppu *P2c02) TRam() LoopyRegister

func (*P2c02) Tick

func (ppu *P2c02) Tick()

func (*P2c02) VBlank

func (ppu *P2c02) VBlank() bool

func (*P2c02) VRam

func (ppu *P2c02) VRam() LoopyRegister

func (*P2c02) Write

func (ppu *P2c02) Write(address types.Address, value byte)

func (*P2c02) WriteRegister

func (ppu *P2c02) WriteRegister(register types.Address, value byte)

Write made by CPU

type PPU

type PPU interface {
	WriteRegister(register types.Address, value byte)
	ReadRegister(register types.Address) byte
}

type PPUState

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

func (*PPUState) String

func (s *PPUState) String() string

type Scanline

type Scanline uint16

type SimplePPUState

type SimplePPUState struct {
	Frame       uint16
	RenderCycle uint16
	Scanline    Scanline
}

func NewSimplePPUState

func NewSimplePPUState(frame uint16, renderCycle uint16, scanline Scanline) SimplePPUState

type Status

type Status struct {
	SpriteOverflow       byte
	Sprite0Hit           byte
	VerticalBlankStarted bool
}

func (*Status) Value

func (status *Status) Value() byte

Jump to

Keyboard shortcuts

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