Skip to content

Commit

Permalink
noise reset enable
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Dec 5, 2016
1 parent 7e02b2c commit e08e74c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Version 0.2.2

- Added SN76489 stereo separation to mixer menu
- Added `NE0` / `NE1` noise reset enable effect
- SN76489 VGM logger now eliminates extra register writes that have no side effects
- Extended VGM header size so that it will not be misinterpreted by certain players
- Fixed text export and import (for SN7T only)
Expand Down
20 changes: 18 additions & 2 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,29 @@ _(TODO)_

- **Name:** Panning setting
- **Target:** SN76489, ~~T6W28~~
- **Description:** Changes the volume balance for the left and right output channels. `N01` is left, `N10` is center, `N1F` is right. ~~Intermediate values are supported only by the T6W28 chip; it effectively decreases the output volume in one of the output channels, but never silences it unless `N01` or `N1F` is used.~~ The special `N00` silences both output channels.
- **Default:** `N10`
- **Description:** Changes the volume balance for the left and right output channels. `N01` is left, `N10` is center, `N1F` is right. The special `N00` silences both output channels. ~~Intermediate values are supported only by the T6W28 chip; it effectively decreases the output volume in one of the output channels, but never silences it unless `N01` or `N1F` is used.~~

#### NCx

- **Name:** Channel swap
- **Target:** SN76489
- **Description:** Exchanges Square `x` with Square 3. This allows any square channel to control the pitch of the noise channel. Doing so will cause a pop in the audio output as it essentially tells the chip to swap two channels. Default is `NC3`, where no swapping occurs.
- **Default:** `NC3`
- **Description:** Exchanges Square `x` with Square 3. This allows any square channel to control the pitch of the noise channel. Doing so will cause a pop in the audio output as the channel registers must be rewritten.

#### NE0, NE1

- **Name:** Noise reset enable
- **Target:** SN76489 Noise
- **Default:** `NE0`
- **Description:** Configures whether the noise channel resets its shift register state on new notes. `NE0` disables it, `NE1` enables it and additionally resets the noise state immediately. (Changing the pitch or duty always resets the noise state. This is normal SN76489 behaviour.)

<!--
- **Name:** a
- **Target:** a
- **Default:** ``
- **Description:** a
-->

## New features

Expand Down
19 changes: 18 additions & 1 deletion Source/ChannelsSN7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ void CNoiseChan::HandleNote(int Note, int Octave)
m_iPeriod = NesFreq;

m_bGate = true;
m_bTrigger = true; // // //

m_iNote = NewNote;
m_iDutyPeriod = m_iDefaultDuty;
Expand Down Expand Up @@ -280,11 +281,26 @@ void CNoiseChan::RefreshChannel()
char NoiseMode = !(m_iDutyPeriod & 0x01); // // //

int newCtrl = (NoiseMode << 2) | Period; // // //
if (newCtrl != m_iLastCtrl) {
if ((m_bTrigger && m_bNoiseReset) || newCtrl != m_iLastCtrl) {
WriteRegister(0x06, newCtrl);
m_iLastCtrl = newCtrl;
}
WriteRegister(0x07, 0xF ^ Volume);

m_bTrigger = false;
}

void CNoiseChan::HandleCustomEffects(int EffNum, int EffParam)
{
switch (EffNum) {
case EF_SN_CONTROL:
switch (EffParam) {
case 0xE0: m_bNoiseReset = false; return;
case 0xE1: m_bNoiseReset = m_bTrigger = true; return;
}
}

return CChannelHandlerSN7::HandleCustomEffects(EffNum, EffParam);
}

void CNoiseChan::ClearRegisters()
Expand All @@ -293,6 +309,7 @@ void CNoiseChan::ClearRegisters()
WriteRegister(0x06, 0);
WriteRegister(0x07, 0xF);
SetStereo(true, true);
m_bNoiseReset = false;
}

int CNoiseChan::TriggerNote(int Note)
Expand Down
3 changes: 3 additions & 0 deletions Source/ChannelsSN7.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class CNoiseChan : public CChannelHandlerSN7 {
CNoiseChan();
virtual void RefreshChannel();
protected:
virtual void HandleCustomEffects(int EffNum, int EffParam);
virtual void ClearRegisters();
virtual void HandleNote(int Note, int Octave);
virtual void SetupSlide(int Type, int EffParam);
Expand All @@ -81,6 +82,8 @@ class CNoiseChan : public CChannelHandlerSN7 {

private:
int m_iLastCtrl; // // //
bool m_bNoiseReset; // // //
bool m_bTrigger; // // // 0CC-FT has this built-in
};

// // //

0 comments on commit e08e74c

Please sign in to comment.