apu

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FrameCounterRate  = float64(consts.CPUFrequency) / 240.0
	DefaultSampleRate = float64(consts.CPUFrequency) / float64(consts.AudioSampleRate) * consts.FrameRateDifference
	BufferCap         = consts.AudioSampleRate / 5 * 8
)
View Source
const (
	StatusPulse1 = 1 << iota
	StatusPulse2
	StatusTriangle
	StatusNoise
	StatusDMC

	StatusFrameInterrupt
	StatusDMCInterrupt
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APU

type APU struct {
	Enabled    bool    `msgpack:"-"`
	SampleRate float64 `msgpack:"-"`

	Square   [2]Square
	Triangle Triangle
	Noise    Noise
	DMC      DMC

	Cycle       uint
	FramePeriod uint8
	FrameValue  byte

	IRQEnabled bool `msgpack:"alias:IrqEnabled"`
	IRQPending bool `msgpack:"alias:IrqPending"`
	// contains filtered or unexported fields
}

func New

func New(conf *config.Config) *APU

func (*APU) Clear

func (a *APU) Clear()

func (*APU) Read

func (a *APU) Read(p []byte) (int, error)

func (*APU) ReadMem

func (a *APU) ReadMem(addr uint16) byte

func (*APU) Reset

func (a *APU) Reset()

func (*APU) SetCPU

func (a *APU) SetCPU(c CPU)

func (*APU) Step

func (a *APU) Step() bool

func (*APU) WriteMem

func (a *APU) WriteMem(addr uint16, data byte)

type CPU

type CPU interface {
	memory.Read8
	interrupt.Stall
}

type DMC

type DMC struct {
	Enabled bool
	Value   byte

	IRQEnabled bool `msgpack:"alias:IrqEnabled"`
	IRQPending bool `msgpack:"alias:IrqPending"`
	Loop       bool

	TickPeriod byte
	TickValue  byte

	SampleAddr uint16
	SampleLen  uint16

	CurrAddr      uint16
	CurrLen       uint16
	ShiftRegister byte
	BitCount      byte
	// contains filtered or unexported fields
}

func (*DMC) SetEnabled

func (d *DMC) SetEnabled(v bool)

func (*DMC) Write

func (d *DMC) Write(addr uint16, data byte)

type Noise

type Noise struct {
	Enabled bool

	EnvelopeEnabled bool
	EnvelopeLoop    bool
	EnvelopeStart   bool
	EnvelopeVol     byte
	EnvelopePeriod  byte
	EnvelopeValue   byte

	Volume byte

	LoopNoise     bool
	ShiftRegister uint16

	TimerPeriod uint16
	TimerValue  uint16

	LengthEnabled bool
	LengthValue   byte
}

func (*Noise) SetEnabled

func (n *Noise) SetEnabled(v bool)

func (*Noise) Write

func (n *Noise) Write(addr uint16, data byte)

type Square

type Square struct {
	Enabled  bool
	Channel1 bool

	DutyMode  byte
	DutyValue byte

	EnvelopeEnabled bool
	EnvelopePeriod  byte
	EnvelopeLoop    bool
	EnvelopeStart   bool
	EnvelopeVol     byte
	EnvelopeValue   byte

	Volume byte

	SweepEnabled bool
	SweepPeriod  byte
	SweepNegate  bool
	SweepShift   byte
	SweepReload  bool
	SweepValue   byte

	LengthEnabled bool
	LengthValue   byte

	TimerPeriod uint16
	TimerValue  uint16
}

func (*Square) SetEnabled

func (p *Square) SetEnabled(v bool)

func (*Square) Write

func (p *Square) Write(addr uint16, data byte)

type Triangle

type Triangle struct {
	Enabled bool

	LengthEnabled bool
	LengthValue   byte

	CounterPeriod byte
	CounterValue  byte
	CounterReload bool

	DutyValue byte

	TimerPeriod uint16
	TimerValue  uint16
}

func (*Triangle) SetEnabled

func (t *Triangle) SetEnabled(v bool)

func (*Triangle) Write

func (t *Triangle) Write(addr uint16, data byte)

Jump to

Keyboard shortcuts

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