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
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Dn-help/*
# this should be automatically generated at build
hlp/HTMLDefines.h

# generated headers
/Source/drivers/*.h
/Source/drivers/asm/build/*

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand Down Expand Up @@ -441,6 +445,3 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

# generated headers
/Source/drivers/*.h
2 changes: 1 addition & 1 deletion Dn-help
16 changes: 10 additions & 6 deletions Source/APU/N163.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,16 @@ uint8_t CN163::Read(uint16_t Address, bool &Mapped)
void CN163::Process(uint32_t Time, Blip_Buffer& Output)
{
// Mix level will dynamically change based on number of channels
if (!m_UseSurveyMix) {
int channels = m_N163.GetNumberOfChannels();
auto channels = m_N163.GetNumberOfChannels();
auto scale = m_bUseLinearMixing ? (channels + 1) : 1;

if (m_UseSurveyMix) {
m_SynthN163.volume(m_Attenuation, 225 * scale);
}
else {
double N163_volume = (channels == 0) ? 1.3f : (1.5f + float(channels) / 1.5f);
N163_volume *= m_Attenuation;
m_SynthN163.volume(N163_volume * 1.1, 1600);
m_SynthN163.volume(N163_volume * 1.1, 1600 * scale);
}

uint32_t now = 0;
Expand Down Expand Up @@ -199,9 +204,8 @@ void CN163::UpdateMixLevel(double v, bool UseSurveyMix)
{
m_Attenuation = v;
m_UseSurveyMix = UseSurveyMix;
if (UseSurveyMix)
m_SynthN163.volume(m_Attenuation, 225);
// Legacy mixing recalculates chip levels at runtime
// Recalculate chip levels at runtime; this is dependent on the amount of
// N163 channels at execution.
}

void CN163::Log(uint16_t Address, uint8_t Value) // // //
Expand Down
2 changes: 1 addition & 1 deletion Source/APU/mesen/Namco163Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Namco163Audio
for (int i = 7, min = 7 - GetNumberOfChannels(); i >= min; i--) {
summedOutput += _channelOutput[i];
}
summedOutput /= (GetNumberOfChannels() + 1);
// Adjust the volume range on the blip_synth!
return (_mixLinear ? summedOutput : _channelOutput[_currentChannel]);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/AboutDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ BOOL CAboutDlg::OnInitDialog()
_T("- Sunsoft 5B information in manual by forple\r\n") // // !!
_T("- Additional manual information by Persune\r\n") // // !!
_T("- Toolbar icons are made by ilkke\r\n")
_T("- Dn-FT icon design by Pale Moon\r\n") // // !!
_T("- Dn-FT icon design by Sun Rays\r\n") // // !!
_T("- DPCM import resampler by Jarhmander\r\n")
_T("- DPCM sample bit order reverser mod by Persune\r\n") // // !!
_T("- Module text import/export by rainwarrior")); // // //
Expand Down
5 changes: 3 additions & 2 deletions Source/Channels2A03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,11 @@ bool CTriangleChan::HandleEffect(effect_t EffNum, unsigned char EffParam)
m_bResetEnvelope = true;
}
else {
m_bEnvelopeLoop = true;
// Avoid touching the envelope loop flag if under a retrigger effect
if (!m_bRetrigger)
m_bEnvelopeLoop = true;
return CChannelHandler2A03::HandleEffect(EffNum, EffParam); // true
}
m_bRetrigger = false;
break;
case EF_RETRIGGER:
if (EffParam > 0x7f)
Expand Down
1 change: 1 addition & 0 deletions Source/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const int CCompiler::FLAG_LINEARPITCH = 1 << 2; // // //


// chan_id_t to ft_channel_enable index
// TODO: utilize WriteChannelMap() ?
const size_t CH_MAP[] = {
0, 1, 2, 3, 27, // 2A03
6, 7, 8, // VRC6
Expand Down
18 changes: 5 additions & 13 deletions Source/FamiTrackerDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,6 @@ BOOL CFamiTrackerDoc::SaveDocument(LPCTSTR lpszPathName) const
bool CFamiTrackerDoc::WriteBlocks(CDocumentFile *pDocFile) const
{
static const int DEFAULT_BLOCK_VERSION[] = { // // // TODO: use version info
#ifdef TRANSPOSE_FDS
// internal
6, // Parameters
1, // Song Info
Expand All @@ -816,21 +815,14 @@ bool CFamiTrackerDoc::WriteBlocks(CDocumentFile *pDocFile) const
6, // Instruments
6, // Sequences
3, // Frames
5, // Patterns
1, // DSamples
1, // Comments
// Patterns
#ifdef TRANSPOSE_FDS
5,
#else
6, // Parameters
1, // Song Info
0, // Tuning
3, // Header
6, // Instruments
6, // Sequences
3, // Frames
4, // Patterns
4,
#endif
1, // DSamples
1, // Comments
#endif
// expansion
6, // SequencesVRC6
1, // SequencesN163
Expand Down
3 changes: 2 additions & 1 deletion Source/InstrumentEditDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void CInstrumentEditDlg::ClearPanels()
m_iInstrument = -1;
}

void CInstrumentEditDlg::SetCurrentInstrument(int Index)
void CInstrumentEditDlg::SetCurrentInstrument(int Index, bool Focus)
{
CFamiTrackerDoc *pDoc = CFamiTrackerDoc::GetDoc();
std::shared_ptr<CInstrument> pInstrument = pDoc->GetInstrument(Index);
Expand Down Expand Up @@ -220,6 +220,7 @@ void CInstrumentEditDlg::SetCurrentInstrument(int Index)
for (int i = 0; i < PANEL_COUNT; ++i) {
if (m_pPanels[i] != NULL) {
m_pPanels[i]->SelectInstrument(pInstrument);
if (Focus) m_pPanels[i]->SetFocus();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/InstrumentEditDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CInstrumentEditDlg : public CDialog
virtual ~CInstrumentEditDlg();

void ChangeNoteState(int Note);
void SetCurrentInstrument(int Index);
void SetCurrentInstrument(int Index, bool Focus = true);
float GetRefreshRate() const; // // //
void SetRefreshRate(float Rate); // // //
bool IsOpened() const;
Expand Down
2 changes: 0 additions & 2 deletions Source/InstrumentEditorSeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ void CInstrumentEditorSeq::SelectInstrument(std::shared_ptr<CInstrument> pInst)
SetDlgItemInt(IDC_SEQ_INDEX, m_pInstrument->GetSeqIndex(m_iSelectedSetting = Sel));

SelectSequence(m_pInstrument->GetSeqIndex(m_iSelectedSetting), m_iSelectedSetting);

SetFocus();
}

void CInstrumentEditorSeq::SelectSequence(int Sequence, int Type)
Expand Down
3 changes: 2 additions & 1 deletion Source/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,8 @@ void CMainFrame::SelectInstrument(int Index)

// Update instrument editor
if (m_wndInstEdit.IsOpened())
m_wndInstEdit.SetCurrentInstrument(Index);
// Do not shift focus when selecting the instrument due to a instrument column edit
m_wndInstEdit.SetCurrentInstrument(Index, false);
}
else {
// Remove selection
Expand Down
14 changes: 4 additions & 10 deletions Source/drivers/asm/apu.s
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,11 @@ ft_update_2a03:
beq @KillTriangle
lda var_ch_Note + APU_TRI
beq @KillTriangle
lda var_ch_LengthCounter + APU_TRI ;;; ;; ;
and #%00000111
beq :++ ; branch if no length counter and no linear counter
: lda var_Linear_Counter
and #$7F
bpl :++ ; always
: lda var_Triangle_Trill ; still write linear counter if we have retriggering enabled
bne :--

; linear counter is already processed at this point
lda var_Linear_Counter
ora #$80 ; ;; ;;;
: sta $4008
sta $4008

@EndTriangleVolume:
; Period table isn't limited to $7FF anymore
lda var_ch_PeriodCalcHi + APU_TRI
Expand Down
27 changes: 22 additions & 5 deletions Source/drivers/asm/build/build_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

parser = argparse.ArgumentParser()
parser.add_argument("-d", "--debug", action="store_true")
parser.add_argument("-n", "--no-nsfdrv", action="store_true")
args = parser.parse_args()

DEBUG = args.debug

HEADERLESS = args.no_nsfdrv

def resolvelabel(label: str) -> str:
match label:
case "ft_vibrato_table":
Expand All @@ -37,26 +40,40 @@ def resolvelabel(label: str) -> str:
def build(chip: str):
print("Building NSF driver for " + chip + "...")

package = "" if HEADERLESS else "-D PACKAGE"
hdrless = "_hdrless" if HEADERLESS else ""

# compile assembly to object
out = subprocess.run(f"ca65 ../driver.s -l out_{chip}.lst \
-D USE_{chip} -D NAMCO_CHANNELS=8 -D PACKAGE \
out = subprocess.run(f"ca65 ../driver.s -l out_{chip}{hdrless}.lst \
-D USE_{chip} -D NAMCO_CHANNELS=8 \
-D RELOCATE_MUSIC -D USE_BANKSWITCH -D USE_OLDVIBRATO \
-D USE_LINEARPITCH -o driver_{chip}.o",
-D USE_LINEARPITCH {package} -o driver_{chip}{hdrless}.o",
shell=True, capture_output=True, text=True)
print(out.stdout, end="")
print(out.stderr, end="")

# compile object with shifted memory config to determine pointer locations
out = subprocess.run(f"ld65 -o c0_{chip}.bin driver_{chip}.o -C c0.cfg",
out = subprocess.run(f"ld65 -o c0_{chip}{hdrless}.bin \
driver_{chip}{hdrless}.o -C c0.cfg",
shell=True, capture_output=True, text=True)
print(out.stdout, end="")
print(out.stderr, end="")

out = subprocess.run(f"ld65 -o c1_{chip}.bin driver_{chip}.o -C c1.cfg",
out = subprocess.run(f"ld65 -o c1_{chip}{hdrless}.bin \
driver_{chip}{hdrless}.o -C c1.cfg",
shell=True, capture_output=True, text=True)
print(out.stdout, end="")
print(out.stderr, end="")

# headerless NSF kernel binary not supported
if HEADERLESS:
print("debug: NSF kernel binary not supported")
os.remove(f"out_{chip}{hdrless}.lst")
os.remove(f"c0_{chip}{hdrless}.bin")
os.remove(f"c1_{chip}{hdrless}.bin")
os.remove(f"driver_{chip}{hdrless}.o")
return

adr = {}
pos = {}
reloc_lo = {}
Expand Down
6 changes: 3 additions & 3 deletions Source/drivers/asm/driver.s
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ PLAY:
USE_PADJMP = 1 ; disable if you don't need FDS write protection

;;
; manually define a jump command as an optimization
.macro jmppadjmp jump, count, startpad, endpad, condition
; manually define a jump command before padding as an optimization
.macro jmppad jump, count, startpad, endpad, condition
.if (count > 3) && condition && USE_PADJMP
.assert * = LOAD+((startpad-$8000) & $FFFF), ldwarning, .sprintf("padding does not start at $%04X", startpad)
jump
Expand All @@ -515,7 +515,7 @@ USE_PADJMP = 1 ; disable if you don't need FDS write protection
.macro padjmp count, startpad, endpad, condition
.if (count > 3) && condition && USE_PADJMP
.local end
jmppadjmp {jmp end}, count, startpad, endpad, condition
jmppad {jmp end}, count, startpad, endpad, condition
end:
.endif
.endmacro
Expand Down
Loading