ppu

package
v0.0.0-...-1fe299f Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const CYCLE = 2
View Source
const KB = 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU interface {
	Read(addr uint16) uint8
	IRQ(id int)
	HBlank()
	IsCGBMode() bool // CGBモードかどうか
}

type DMA

type DMA struct {
	Active bool
	Src    uint16
	Until  int64
}

OAM DMA

type LCDStatIRQInfo

type LCDStatIRQInfo struct {
	Triggered bool
	Mode      uint8
	Lx, Ly    uint8
}

フレームの間に起きたLCDSTAT IRQに関する情報(フレームの始まりにリセットされる)

type PPU

type PPU struct {
	RAM VRAM
	DMA DMA

	OAM     [160]uint8
	Palette [(4 * 8) * 2]uint16 // 4bppの8パレットが BG と OBJ の1つずつ

	// For debugging
	StatIRQ LCDStatIRQInfo
	// contains filtered or unexported fields
}

SoCに組み込まれているため、`/cpu`にある方が正確ではある また、コードをシンプルにしたいのでスキャンライン単位で描画を行うことにしている(スキャンライン中にSCX,SCYやWX, WYを変更するようなゲームでは正しく描画されない場合がある)

func New

func New(cpu CPU) *PPU

func (*PPU) ColorizeDMG

func (p *PPU) ColorizeDMG()

GBCのBIOSがやる、DMGゲームに対する色付け処理

func (*PPU) CreateSnapshot

func (p *PPU) CreateSnapshot() Snapshot

func (*PPU) Frame

func (p *PPU) Frame() uint64

func (*PPU) Read

func (p *PPU) Read(addr uint16) uint8

func (*PPU) Reset

func (p *PPU) Reset()

func (*PPU) RestoreSnapshot

func (p *PPU) RestoreSnapshot(snap Snapshot) bool

func (*PPU) Run

func (p *PPU) Run(cycles8MHz int64)

func (*PPU) Screen

func (p *PPU) Screen() []color.NRGBA

func (*PPU) SkipBIOS

func (p *PPU) SkipBIOS()

func (*PPU) TriggerDMA

func (p *PPU) TriggerDMA(src uint16, m int64)

func (*PPU) Write

func (p *PPU) Write(addr uint16, val uint8)

type Snapshot

type Snapshot struct {
	Header          uint64
	Cycles          int64
	Frames          uint64
	Lx, Ly          int16
	VRAM            VRAM
	DMA             DMA
	LCDC, STAT, LYC uint8
	OAM             [160]uint8
	Palette         [(4 * 8) * 2]uint16
	IOReg           [0x30]uint8
	EnableLatch     bool
	ObjCount        uint8
	BGPI, OBPI      uint8
	Reserved        [64]uint8
}

type VRAM

type VRAM struct {
	Data [16 * KB]uint8
	Bank uint8 // 0 or 1; VBK(0xFF4F)
}

便宜的にPPU構造体に入れているが、PPUチップ内にはなくボード上にある

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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