Documentation ¶
Index ¶
- Constants
- Variables
- func NewLogger2c02(enabled bool, outputPath string) *logger2c02
- func SaveTile(fileName string, tile *image.RGBA)
- type Control
- type LoopyRegister
- type Mask
- type P2c02
- func (ppu *P2c02) FineX() uint8
- func (ppu *P2c02) Frame() *image.RGBA
- func (ppu *P2c02) FrameComplete() bool
- func (ppu *P2c02) FrameNumber() uint16
- func (ppu *P2c02) FramePattern() []byte
- func (ppu *P2c02) GetPaletteColor(palette byte, colorIndex byte) byte
- func (ppu *P2c02) GetRGBColor(palette byte, colorIndex byte) color.RGBA
- func (ppu *P2c02) Nmi() bool
- func (ppu *P2c02) Oam(index byte) []byte
- func (ppu *P2c02) PatternTable(patternTable byte, palette byte) image.RGBA
- func (ppu *P2c02) Peek(address types.Address) byte
- func (ppu *P2c02) Read(address types.Address) byte
- func (ppu *P2c02) ReadRegister(register types.Address) byte
- func (ppu *P2c02) Render()
- func (ppu *P2c02) RenderCycle() uint16
- func (ppu *P2c02) ResetNmi()
- func (ppu *P2c02) Scanline() Scanline
- func (ppu *P2c02) Stop()
- func (ppu *P2c02) TRam() LoopyRegister
- func (ppu *P2c02) Tick()
- func (ppu *P2c02) VBlank() bool
- func (ppu *P2c02) VRam() LoopyRegister
- func (ppu *P2c02) Write(address types.Address, value byte)
- func (ppu *P2c02) WriteRegister(register types.Address, value byte)
- type PPU
- type PPUState
- type Scanline
- type SimplePPUState
- type Status
Constants ¶
const NAMETABLE_SIZE = 1024
const NES_PALETTE_COLORS = 64
const NameTableEndAddress = types.Address(0x2FFF)
const NameTableStartAddress = types.Address(0x2000)
const OAMADDR = 0x2003
const OAMDATA = 0x2004
const OAMDATA_SIZE = 256
Memory sizes
const OAMDMA = 0x4014
const PALETTE_COUNT = 8
const PALETTE_SIZE = 32
const PPUADDR = 0x2006
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)
const PPUDATA = 0x2007
const PPUMASK = 0x2001
PPUMASK color emphasis (BGR), sprite enable (s), background enable (b),
const PPUSCROLL = 0x2005
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
const PPU_CONTROL_SPRITE_SIZE_16 = 1
const PPU_CONTROL_SPRITE_SIZE_8 = 0
const PPU_CYCLES_BY_SCANLINE = 341
const PPU_CYCLES_TO_WARMUP = 29658 / 3
Other
const PPU_HIGH_ADDRESS = types.Address(0x3FFF)
const PPU_LOG_BUFFER_MAXSIZE = 120000
const PPU_NAMETABLES_0_END = types.Address(0x23C0)
const PPU_SCANLINES = 261
const PPU_SCREEN_SPACE_CYCLES_BY_SCANLINE = 256
const PPU_SCREEN_SPACE_SCANLINES = 240
const PPU_VBLANK_END_CYCLE = PPU_SCANLINES * PPU_CYCLES_BY_SCANLINE
const PPU_VBLANK_START_CYCLE = (PPU_SCREEN_SPACE_SCANLINES + 1) * PPU_CYCLES_BY_SCANLINE
const PaletteHighAddress = types.Address(0x3FFF)
const PaletteLowAddress = types.Address(0x3F00)
Memory
const PatternTable0Address = types.Address(0x0000)
const PatternTable1Address = types.Address(0x1000)
const TILE_HEIGHT = 8
const TILE_PIXELS = 8 * 8
const TILE_WIDTH = 8
const VBLANK_END_SCNALINE = 261
const VBLANK_START_SCANLINE = 241
Variables ¶
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 ¶
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 }
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 P2c02 ¶
type P2c02 struct { PpuControl Control PpuStatus Status PpuMask Mask // Controls the rendering of sprites and backgrounds // contains filtered or unexported fields }
func (*P2c02) FrameComplete ¶
func (*P2c02) FrameNumber ¶
func (*P2c02) FramePattern ¶
func (*P2c02) GetPaletteColor ¶
func (*P2c02) GetRGBColor ¶
//$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) PatternTable ¶
func (*P2c02) ReadRegister ¶
Read made by CPU
func (*P2c02) RenderCycle ¶
func (*P2c02) TRam ¶
func (ppu *P2c02) TRam() LoopyRegister
func (*P2c02) VRam ¶
func (ppu *P2c02) VRam() LoopyRegister
type SimplePPUState ¶
func NewSimplePPUState ¶
func NewSimplePPUState(frame uint16, renderCycle uint16, scanline Scanline) SimplePPUState