From 59d813db7cf87226f95589ce41d60326bdf78a7b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 4 Mar 2022 02:20:13 -0500 Subject: [PATCH] PCE: add noise macro (finally!) --- src/engine/instrument.cpp | 7 +++++++ src/engine/platform/pce.cpp | 7 +++++++ src/gui/insEdit.cpp | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index d65a27d0e..bdf028905 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -710,6 +710,13 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) { fm.tomTopFreq=reader.readS(); } + // clear noise macro if PCE instrument and version<63 + if (version<63 && type==DIV_INS_PCE) { + std.dutyMacroLen=0; + std.dutyMacroLoop=-1; + std.dutyMacroRel=-1; + } + return DIV_DATA_SUCCESS; } diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index 7b45dfa7b..296eafc41 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -162,6 +162,13 @@ void DivPlatformPCE::tick() { chWrite(i,0x04,0x80|chan[i].outVol); } } + if (chan[i].std.hadDuty && i>=4) { + chan[i].noise=chan[i].std.duty; + chan[i].freqChanged=true; + int noiseSeek=chan[i].note; + if (noiseSeek<0) noiseSeek=0; + chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0); + } if (chan[i].std.hadArp) { if (!chan[i].inPorta) { if (chan[i].std.arpMode) { diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index de381e6ba..4afa67a5c 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -1352,9 +1352,12 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_AY8930) { dutyMax=255; } - if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_PCE || ins->type==DIV_INS_AMIGA) { + if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_AMIGA) { dutyMax=0; } + if (ins->type==DIV_INS_PCE) { + dutyMax=1; + } if (ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPL) { dutyMax=0; }