Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/Apu/Apu.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,44 @@ public function setWaveRam(array $waveRam): void
$this->channel3->writeWaveRam($i, $waveRam[$i]);
}
}

/**
* Get Channel 1 (for savestate serialization).
*
* @return Channel\Channel1
*/
public function getChannel1(): Channel\Channel1
{
return $this->channel1;
}

/**
* Get Channel 2 (for savestate serialization).
*
* @return Channel\Channel2
*/
public function getChannel2(): Channel\Channel2
{
return $this->channel2;
}

/**
* Get Channel 3 (for savestate serialization).
*
* @return Channel\Channel3
*/
public function getChannel3(): Channel\Channel3
{
return $this->channel3;
}

/**
* Get Channel 4 (for savestate serialization).
*
* @return Channel\Channel4
*/
public function getChannel4(): Channel\Channel4
{
return $this->channel4;
}
}
102 changes: 102 additions & 0 deletions src/Apu/Channel/Channel1.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,106 @@ public function disable(): void
{
$this->enabled = false;
}

// Savestate serialization methods

public function getLengthCounter(): int
{
return $this->lengthCounter;
}

public function getCurrentVolume(): int
{
return $this->currentVolume;
}

public function getEnvelopeTimer(): int
{
return $this->envelopeTimer;
}

public function getFrequencyTimer(): int
{
return $this->frequencyTimer;
}

public function getDutyPosition(): int
{
return $this->dutyPosition;
}

public function getEnabled(): bool
{
return $this->enabled;
}

public function getSweepTimer(): int
{
return $this->sweepTimer;
}

public function getSweepShadow(): int
{
return $this->sweepShadow;
}

public function getSweepEnabled(): bool
{
return $this->sweepEnabled;
}

public function getDacEnabled(): bool
{
return $this->dacEnabled;
}

public function setLengthCounter(int $value): void
{
$this->lengthCounter = $value;
}

public function setCurrentVolume(int $value): void
{
$this->currentVolume = $value;
}

public function setEnvelopeTimer(int $value): void
{
$this->envelopeTimer = $value;
}

public function setFrequencyTimer(int $value): void
{
$this->frequencyTimer = $value;
}

public function setDutyPosition(int $value): void
{
$this->dutyPosition = $value;
}

public function setEnabled(bool $value): void
{
$this->enabled = $value;
}

public function setSweepTimer(int $value): void
{
$this->sweepTimer = $value;
}

public function setSweepShadow(int $value): void
{
$this->sweepShadow = $value;
}

public function setSweepEnabled(bool $value): void
{
$this->sweepEnabled = $value;
}

public function setDacEnabled(bool $value): void
{
$this->dacEnabled = $value;
}
}
72 changes: 72 additions & 0 deletions src/Apu/Channel/Channel2.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,76 @@ public function disable(): void
{
$this->enabled = false;
}

// Savestate serialization methods

public function getLengthCounter(): int
{
return $this->lengthCounter;
}

public function getCurrentVolume(): int
{
return $this->currentVolume;
}

public function getEnvelopeTimer(): int
{
return $this->envelopeTimer;
}

public function getFrequencyTimer(): int
{
return $this->frequencyTimer;
}

public function getDutyPosition(): int
{
return $this->dutyPosition;
}

public function getEnabled(): bool
{
return $this->enabled;
}

public function getDacEnabled(): bool
{
return $this->dacEnabled;
}

public function setLengthCounter(int $value): void
{
$this->lengthCounter = $value;
}

public function setCurrentVolume(int $value): void
{
$this->currentVolume = $value;
}

public function setEnvelopeTimer(int $value): void
{
$this->envelopeTimer = $value;
}

public function setFrequencyTimer(int $value): void
{
$this->frequencyTimer = $value;
}

public function setDutyPosition(int $value): void
{
$this->dutyPosition = $value;
}

public function setEnabled(bool $value): void
{
$this->enabled = $value;
}

public function setDacEnabled(bool $value): void
{
$this->dacEnabled = $value;
}
}
52 changes: 52 additions & 0 deletions src/Apu/Channel/Channel3.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,56 @@ public function disable(): void
{
$this->enabled = false;
}

// Savestate serialization methods

public function getLengthCounter(): int
{
return $this->lengthCounter;
}

public function getFrequencyTimer(): int
{
return $this->frequencyTimer;
}

public function getSamplePosition(): int
{
return $this->samplePosition;
}

public function getEnabled(): bool
{
return $this->enabled;
}

public function getDacEnabled(): bool
{
return $this->dacEnabled;
}

public function setLengthCounter(int $value): void
{
$this->lengthCounter = $value;
}

public function setFrequencyTimer(int $value): void
{
$this->frequencyTimer = $value;
}

public function setSamplePosition(int $value): void
{
$this->samplePosition = $value;
}

public function setEnabled(bool $value): void
{
$this->enabled = $value;
}

public function setDacEnabled(bool $value): void
{
$this->dacEnabled = $value;
}
}
72 changes: 72 additions & 0 deletions src/Apu/Channel/Channel4.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,76 @@ public function disable(): void
{
$this->enabled = false;
}

// Savestate serialization methods

public function getLengthCounter(): int
{
return $this->lengthCounter;
}

public function getCurrentVolume(): int
{
return $this->currentVolume;
}

public function getEnvelopeTimer(): int
{
return $this->envelopeTimer;
}

public function getFrequencyTimer(): int
{
return $this->frequencyTimer;
}

public function getEnabled(): bool
{
return $this->enabled;
}

public function getDacEnabled(): bool
{
return $this->dacEnabled;
}

public function getLfsr(): int
{
return $this->lfsr;
}

public function setLengthCounter(int $value): void
{
$this->lengthCounter = $value;
}

public function setCurrentVolume(int $value): void
{
$this->currentVolume = $value;
}

public function setEnvelopeTimer(int $value): void
{
$this->envelopeTimer = $value;
}

public function setFrequencyTimer(int $value): void
{
$this->frequencyTimer = $value;
}

public function setEnabled(bool $value): void
{
$this->enabled = $value;
}

public function setDacEnabled(bool $value): void
{
$this->dacEnabled = $value;
}

public function setLfsr(int $value): void
{
$this->lfsr = $value & 0x7FFF; // Keep to 15 bits
}
}
Loading