Merge branch 'master' into master
This commit is contained in:
commit
eb95024fb9
321 changed files with 78416 additions and 69816 deletions
|
|
@ -46,7 +46,9 @@ void* TAAudioSDL::getContext() {
|
|||
bool TAAudioSDL::quit() {
|
||||
if (!initialized) return false;
|
||||
|
||||
SDL_CloseAudioDevice(ai);
|
||||
if (ai!=0) {
|
||||
SDL_CloseAudioDevice(ai);
|
||||
}
|
||||
|
||||
if (running) {
|
||||
running=false;
|
||||
|
|
|
|||
|
|
@ -34,5 +34,6 @@ class TAAudioSDL: public TAAudio {
|
|||
std::vector<String> listAudioDevices();
|
||||
bool init(TAAudioDesc& request, TAAudioDesc& response);
|
||||
TAAudioSDL():
|
||||
ai(0),
|
||||
audioSysStarted(false) {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -215,6 +215,10 @@ bool DivCSPlayer::tick() {
|
|||
case DIV_CMD_HINT_VOL_SLIDE:
|
||||
arg0=(short)stream.readS();
|
||||
break;
|
||||
case DIV_CMD_HINT_VOL_SLIDE_TARGET:
|
||||
arg0=(short)stream.readS();
|
||||
arg1=(short)stream.readS();
|
||||
break;
|
||||
case DIV_CMD_HINT_LEGATO:
|
||||
arg0=(unsigned char)stream.readC();
|
||||
if (arg0==0xff) {
|
||||
|
|
@ -321,6 +325,11 @@ bool DivCSPlayer::tick() {
|
|||
break;
|
||||
case DIV_CMD_HINT_VOL_SLIDE:
|
||||
chan[i].volSpeed=arg0;
|
||||
chan[i].volSpeedTarget=-1;
|
||||
break;
|
||||
case DIV_CMD_HINT_VOL_SLIDE_TARGET:
|
||||
chan[i].volSpeed=arg0;
|
||||
chan[i].volSpeedTarget=arg0==0 ? -1 : arg1;
|
||||
break;
|
||||
case DIV_CMD_HINT_PITCH:
|
||||
chan[i].pitch=arg0;
|
||||
|
|
@ -356,13 +365,29 @@ bool DivCSPlayer::tick() {
|
|||
|
||||
if (sendVolume || chan[i].volSpeed!=0) {
|
||||
chan[i].volume+=chan[i].volSpeed;
|
||||
if (chan[i].volSpeedTarget!=-1) {
|
||||
bool atTarget=false;
|
||||
if (chan[i].volSpeed>0) {
|
||||
atTarget=(chan[i].volume>=chan[i].volSpeedTarget);
|
||||
} else if (chan[i].volSpeed<0) {
|
||||
atTarget=(chan[i].volume<=chan[i].volSpeedTarget);
|
||||
} else {
|
||||
atTarget=true;
|
||||
chan[i].volSpeedTarget=chan[i].volume;
|
||||
}
|
||||
|
||||
if (atTarget) {
|
||||
chan[i].volume=chan[i].volSpeedTarget;
|
||||
chan[i].volSpeed=0;
|
||||
chan[i].volSpeedTarget=-1;
|
||||
}
|
||||
}
|
||||
if (chan[i].volume<0) {
|
||||
chan[i].volume=0;
|
||||
}
|
||||
if (chan[i].volume>chan[i].volMax) {
|
||||
chan[i].volume=chan[i].volMax;
|
||||
}
|
||||
|
||||
e->dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ struct DivCSChannelState {
|
|||
int lastWaitLen;
|
||||
|
||||
int note, pitch;
|
||||
int volume, volMax, volSpeed;
|
||||
int volume, volMax, volSpeed, volSpeedTarget;
|
||||
int vibratoDepth, vibratoRate, vibratoPos;
|
||||
int portaTarget, portaSpeed;
|
||||
unsigned char arp, arpStage, arpTicks;
|
||||
|
|
@ -56,6 +56,7 @@ struct DivCSChannelState {
|
|||
volume(0x7f00),
|
||||
volMax(0),
|
||||
volSpeed(0),
|
||||
volSpeedTarget(-1),
|
||||
vibratoDepth(0),
|
||||
vibratoRate(0),
|
||||
vibratoPos(0),
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ void writePackedCommandValues(SafeWriter* w, const DivCommand& c) {
|
|||
case DIV_CMD_HINT_VOLUME:
|
||||
case DIV_CMD_HINT_PORTA:
|
||||
case DIV_CMD_HINT_VOL_SLIDE:
|
||||
case DIV_CMD_HINT_VOL_SLIDE_TARGET:
|
||||
case DIV_CMD_HINT_LEGATO:
|
||||
w->writeC((unsigned char)c.cmd+0xb4);
|
||||
break;
|
||||
|
|
@ -100,6 +101,10 @@ void writePackedCommandValues(SafeWriter* w, const DivCommand& c) {
|
|||
case DIV_CMD_HINT_VOL_SLIDE:
|
||||
w->writeS(c.value);
|
||||
break;
|
||||
case DIV_CMD_HINT_VOL_SLIDE_TARGET:
|
||||
w->writeS(c.value);
|
||||
w->writeS(c.value2);
|
||||
break;
|
||||
case DIV_CMD_SAMPLE_MODE:
|
||||
case DIV_CMD_SAMPLE_FREQ:
|
||||
case DIV_CMD_SAMPLE_BANK:
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ enum DivDispatchCmds {
|
|||
DIV_CMD_HINT_ARPEGGIO, // (note1, note2)
|
||||
DIV_CMD_HINT_VOLUME, // (vol)
|
||||
DIV_CMD_HINT_VOL_SLIDE, // (amount, oneTick)
|
||||
DIV_CMD_HINT_VOL_SLIDE_TARGET, // (amount, target)
|
||||
DIV_CMD_HINT_PORTA, // (target, speed)
|
||||
DIV_CMD_HINT_LEGATO, // (note)
|
||||
|
||||
|
|
@ -265,6 +266,8 @@ enum DivDispatchCmds {
|
|||
|
||||
DIV_CMD_FDS_MOD_AUTO,
|
||||
|
||||
DIV_CMD_FM_OPMASK, // (mask)
|
||||
|
||||
DIV_CMD_MAX
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,10 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan, bool notNul
|
|||
break;
|
||||
case 0xc0: case 0xc1: case 0xc2: case 0xc3:
|
||||
return _("Cxxx: Set tick rate (hz)");
|
||||
case 0xd3:
|
||||
return _("D3xx: Volume portamento");
|
||||
case 0xd4:
|
||||
return _("D4xx: Volume portamento (fast)");
|
||||
case 0xdc:
|
||||
return _("DCxx: Delayed mute");
|
||||
case 0xe0:
|
||||
|
|
@ -133,9 +137,9 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan, bool notNul
|
|||
case 0xf0:
|
||||
return _("F0xx: Set tick rate (bpm)");
|
||||
case 0xf1:
|
||||
return _("F1xx: Single tick note slide up");
|
||||
return _("F1xx: Single tick pitch up");
|
||||
case 0xf2:
|
||||
return _("F2xx: Single tick note slide down");
|
||||
return _("F2xx: Single tick pitch down");
|
||||
case 0xf3:
|
||||
return _("F3xx: Fine volume slide up");
|
||||
case 0xf4:
|
||||
|
|
@ -147,9 +151,9 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan, bool notNul
|
|||
case 0xf7:
|
||||
return _("F7xx: Restart macro (see manual)");
|
||||
case 0xf8:
|
||||
return _("F8xx: Single tick volume slide up");
|
||||
return _("F8xx: Single tick volume up");
|
||||
case 0xf9:
|
||||
return _("F9xx: Single tick volume slide down");
|
||||
return _("F9xx: Single tick volume down");
|
||||
case 0xfa:
|
||||
return _("FAxx: Fast volume slide (0y: down; x0: up)");
|
||||
case 0xfc:
|
||||
|
|
@ -199,6 +203,12 @@ void DivEngine::walkSong(int& loopOrder, int& loopRow, int& loopEnd) {
|
|||
}
|
||||
}
|
||||
|
||||
void DivEngine::findSongLength(int loopOrder, int loopRow, double fadeoutLen, int& rowsForFadeout, bool& hasFFxx, std::vector<int>& orders, int& length) {
|
||||
if (curSubSong!=NULL) {
|
||||
curSubSong->findLength(loopOrder,loopRow,fadeoutLen,rowsForFadeout,hasFFxx,orders,song.grooves,length,chans,song.jumpTreatment,song.ignoreJumpAtEnd);
|
||||
}
|
||||
}
|
||||
|
||||
#define EXPORT_BUFSIZE 2048
|
||||
|
||||
double DivEngine::benchmarkPlayback() {
|
||||
|
|
@ -510,6 +520,15 @@ void DivEngine::initSongWithDesc(const char* description, bool inBase64, bool ol
|
|||
if (song.subsong[0]->hz<1.0) song.subsong[0]->hz=1.0;
|
||||
if (song.subsong[0]->hz>999.0) song.subsong[0]->hz=999.0;
|
||||
|
||||
curChanMask=c.getIntList("chanMask",{});
|
||||
for (unsigned char i:curChanMask) {
|
||||
int j=i-1;
|
||||
if (j<0) j=0;
|
||||
if (j>DIV_MAX_CHANS) j=DIV_MAX_CHANS-1;
|
||||
curSubSong->chanShow[j]=false;
|
||||
curSubSong->chanShowChanOsc[j]=false;
|
||||
}
|
||||
|
||||
song.author=getConfString("defaultAuthorName","");
|
||||
}
|
||||
|
||||
|
|
@ -744,6 +763,13 @@ int DivEngine::addSubSong() {
|
|||
BUSY_BEGIN;
|
||||
saveLock.lock();
|
||||
song.subsong.push_back(new DivSubSong);
|
||||
for (unsigned char i:curChanMask) {
|
||||
int j=i-1;
|
||||
if (j<0) j=0;
|
||||
if (j>DIV_MAX_CHANS) j=DIV_MAX_CHANS-1;
|
||||
song.subsong.back()->chanShow[j]=false;
|
||||
song.subsong.back()->chanShowChanOsc[j]=false;
|
||||
}
|
||||
saveLock.unlock();
|
||||
BUSY_END;
|
||||
return song.subsong.size()-1;
|
||||
|
|
@ -3589,6 +3615,12 @@ void DivEngine::synchronized(const std::function<void()>& what) {
|
|||
BUSY_END;
|
||||
}
|
||||
|
||||
void DivEngine::synchronizedSoft(const std::function<void()>& what) {
|
||||
BUSY_BEGIN_SOFT;
|
||||
what();
|
||||
BUSY_END;
|
||||
}
|
||||
|
||||
void DivEngine::lockSave(const std::function<void()>& what) {
|
||||
saveLock.lock();
|
||||
what();
|
||||
|
|
@ -3916,6 +3948,9 @@ bool DivEngine::preInit(bool noSafeMode) {
|
|||
// register systems
|
||||
if (!systemsRegistered) registerSystems();
|
||||
|
||||
// register ROM exports
|
||||
if (!romExportsRegistered) registerROMExports();
|
||||
|
||||
// TODO: re-enable with a better approach
|
||||
// see issue #1581
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ class DivWorkPool;
|
|||
|
||||
#define DIV_UNSTABLE
|
||||
|
||||
#define DIV_VERSION "Import Test"
|
||||
#define DIV_ENGINE_VERSION 216
|
||||
#define DIV_VERSION "dev220"
|
||||
#define DIV_ENGINE_VERSION 220
|
||||
// for imports
|
||||
#define DIV_VERSION_MOD 0xff01
|
||||
#define DIV_VERSION_FC 0xff02
|
||||
|
|
@ -133,7 +133,7 @@ struct DivAudioExportOptions {
|
|||
struct DivChannelState {
|
||||
std::vector<DivDelayedCommand> delayed;
|
||||
int note, oldNote, lastIns, pitch, portaSpeed, portaNote;
|
||||
int volume, volSpeed, cut, volCut, legatoDelay, legatoTarget, rowDelay, volMax;
|
||||
int volume, volSpeed, volSpeedTarget, cut, volCut, legatoDelay, legatoTarget, rowDelay, volMax;
|
||||
int delayOrder, delayRow, retrigSpeed, retrigTick;
|
||||
int vibratoDepth, vibratoRate, vibratoPos, vibratoPosGiant, vibratoShape, vibratoFine;
|
||||
int tremoloDepth, tremoloRate, tremoloPos;
|
||||
|
|
@ -157,6 +157,7 @@ struct DivChannelState {
|
|||
portaNote(-1),
|
||||
volume(0x7f00),
|
||||
volSpeed(0),
|
||||
volSpeedTarget(-1),
|
||||
cut(-1),
|
||||
volCut(-1),
|
||||
legatoDelay(-1),
|
||||
|
|
@ -465,6 +466,7 @@ class DivEngine {
|
|||
bool midiIsDirectProgram;
|
||||
bool lowLatency;
|
||||
bool systemsRegistered;
|
||||
bool romExportsRegistered;
|
||||
bool hasLoadedSomething;
|
||||
bool midiOutClock;
|
||||
bool midiOutTime;
|
||||
|
|
@ -473,7 +475,7 @@ class DivEngine {
|
|||
int midiOutTimeRate;
|
||||
float midiVolExp;
|
||||
int softLockCount;
|
||||
int subticks, ticks, curRow, curOrder, prevRow, prevOrder, remainingLoops, totalLoops, lastLoopPos, exportLoopCount, nextSpeed, elapsedBars, elapsedBeats, curSpeed;
|
||||
int subticks, ticks, curRow, curOrder, prevRow, prevOrder, remainingLoops, totalLoops, lastLoopPos, exportLoopCount, curExportChan, nextSpeed, elapsedBars, elapsedBeats, curSpeed;
|
||||
size_t curSubSongIndex;
|
||||
size_t bufferPos;
|
||||
double divider;
|
||||
|
|
@ -497,6 +499,7 @@ class DivEngine {
|
|||
DivAudioExportModes exportMode;
|
||||
DivAudioExportFormats exportFormat;
|
||||
double exportFadeOut;
|
||||
bool isFadingOut;
|
||||
int exportOutputs;
|
||||
bool exportChannelMask[DIV_MAX_CHANS];
|
||||
DivConfig conf;
|
||||
|
|
@ -515,9 +518,11 @@ class DivEngine {
|
|||
std::vector<DivCommand> cmdStream;
|
||||
std::vector<DivInstrumentType> possibleInsTypes;
|
||||
std::vector<DivEffectContainer> effectInst;
|
||||
std::vector<int> curChanMask;
|
||||
static DivSysDef* sysDefs[DIV_MAX_CHIP_DEFS];
|
||||
static DivSystem sysFileMapFur[DIV_MAX_CHIP_DEFS];
|
||||
static DivSystem sysFileMapDMF[DIV_MAX_CHIP_DEFS];
|
||||
static DivROMExportDef* romExportDefs[DIV_ROM_MAX];
|
||||
|
||||
DivCSPlayer* cmdStreamInt;
|
||||
|
||||
|
|
@ -577,7 +582,7 @@ class DivEngine {
|
|||
void processRow(int i, bool afterDelay);
|
||||
void nextOrder();
|
||||
void nextRow();
|
||||
void performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool* sampleDir, bool isSecond, int* pendingFreq, int* playingSample, int* setPos, unsigned int* sampleOff8, unsigned int* sampleLen8, size_t bankOffset, bool directStream);
|
||||
void performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool* sampleDir, bool isSecond, int* pendingFreq, int* playingSample, int* setPos, unsigned int* sampleOff8, unsigned int* sampleLen8, size_t bankOffset, bool directStream, bool* sampleStoppable);
|
||||
// returns true if end of song.
|
||||
bool nextTick(bool noAccum=false, bool inhibitLowLat=false);
|
||||
bool perSystemEffect(int ch, unsigned char effect, unsigned char effectVal);
|
||||
|
|
@ -617,6 +622,17 @@ class DivEngine {
|
|||
void loadFF(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
|
||||
void loadWOPL(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
|
||||
void loadWOPN(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
|
||||
|
||||
//sample banks
|
||||
void loadP(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath);
|
||||
void loadPPC(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath);
|
||||
void loadPPS(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath);
|
||||
void loadPVI(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath);
|
||||
void loadPDX(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath);
|
||||
void loadPZI(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath);
|
||||
void loadP86(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath);
|
||||
|
||||
|
||||
|
||||
int loadSampleROM(String path, ssize_t expectedSize, unsigned char*& ret);
|
||||
|
||||
|
|
@ -624,6 +640,7 @@ class DivEngine {
|
|||
bool deinitAudioBackend(bool dueToSwitchMaster=false);
|
||||
|
||||
void registerSystems();
|
||||
void registerROMExports();
|
||||
void initSongWithDesc(const char* description, bool inBase64=true, bool oldVol=false);
|
||||
|
||||
void exchangeIns(int one, int two);
|
||||
|
|
@ -654,6 +671,8 @@ class DivEngine {
|
|||
// add every export method here
|
||||
friend class DivROMExport;
|
||||
friend class DivExportAmigaValidation;
|
||||
friend class DivExportTiuna;
|
||||
friend class DivExportZSM;
|
||||
|
||||
public:
|
||||
DivSong song;
|
||||
|
|
@ -697,9 +716,8 @@ class DivEngine {
|
|||
// save as .fur.
|
||||
// if notPrimary is true then the song will not be altered
|
||||
SafeWriter* saveFur(bool notPrimary=false, bool newPatternFormat=true);
|
||||
// build a ROM file (TODO).
|
||||
// specify system to build ROM for.
|
||||
std::vector<DivROMExportOutput> buildROM(DivROMExportOptions sys);
|
||||
// return a ROM exporter.
|
||||
DivROMExport* buildROM(DivROMExportOptions sys);
|
||||
// dump to VGM.
|
||||
// set trailingTicks to:
|
||||
// - 0 to add one tick of trailing
|
||||
|
|
@ -707,8 +725,6 @@ class DivEngine {
|
|||
// - -1 to auto-determine trailing
|
||||
// - -2 to add a whole loop of trailing
|
||||
SafeWriter* saveVGM(bool* sysToExport=NULL, bool loop=true, int version=0x171, bool patternHints=false, bool directStream=false, int trailingTicks=-1);
|
||||
// dump to ZSM.
|
||||
SafeWriter* saveZSM(unsigned int zsmrate=60, bool loop=true, bool optimize=true);
|
||||
// dump to TIunA.
|
||||
SafeWriter* saveTiuna(const bool* sysToExport, const char* baseLabel, int firstBankSize, int otherBankSize);
|
||||
// dump command stream.
|
||||
|
|
@ -803,6 +819,9 @@ class DivEngine {
|
|||
// find song loop position
|
||||
void walkSong(int& loopOrder, int& loopRow, int& loopEnd);
|
||||
|
||||
// find song length in rows (up to specified loop point), and find length of every order
|
||||
void findSongLength(int loopOrder, int loopRow, double fadeoutLen, int& rowsForFadeout, bool& hasFFxx, std::vector<int>& orders, int& length);
|
||||
|
||||
// play (returns whether successful)
|
||||
bool play();
|
||||
|
||||
|
|
@ -885,6 +904,9 @@ class DivEngine {
|
|||
// get sys definition
|
||||
const DivSysDef* getSystemDef(DivSystem sys);
|
||||
|
||||
// get ROM export definition
|
||||
const DivROMExportDef* getROMExportDef(DivROMExportOptions opt);
|
||||
|
||||
// convert sample rate format
|
||||
int fileToDivRate(int frate);
|
||||
int divToFileRate(int drate);
|
||||
|
|
@ -991,6 +1013,24 @@ class DivEngine {
|
|||
// is exporting
|
||||
bool isExporting();
|
||||
|
||||
// get how many loops is left
|
||||
void getLoopsLeft(int& loops);
|
||||
|
||||
// get how many loops in total export needs to do
|
||||
void getTotalLoops(int& loops);
|
||||
|
||||
// get current position in song
|
||||
void getCurSongPos(int& row, int& order);
|
||||
|
||||
// get how many files export needs to create
|
||||
void getTotalAudioFiles(int& files);
|
||||
|
||||
// get which file is processed right now (progress for e.g. per-channel export)
|
||||
void getCurFileIndex(int& file);
|
||||
|
||||
// get fadeout state
|
||||
bool getIsFadingOut();
|
||||
|
||||
// add instrument
|
||||
int addInstrument(int refChan=0, DivInstrumentType fallbackType=DIV_INS_STD);
|
||||
|
||||
|
|
@ -1028,7 +1068,8 @@ class DivEngine {
|
|||
int addSamplePtr(DivSample* which);
|
||||
|
||||
// get sample from file
|
||||
DivSample* sampleFromFile(const char* path);
|
||||
//DivSample* sampleFromFile(const char* path);
|
||||
std::vector<DivSample*> sampleFromFile(const char* path);
|
||||
|
||||
// get raw sample
|
||||
DivSample* sampleFromFileRaw(const char* path, DivSampleDepth depth, int channels, bool bigEndian, bool unsign, bool swapNibbles, int rate);
|
||||
|
|
@ -1294,6 +1335,9 @@ class DivEngine {
|
|||
// perform secure/sync operation
|
||||
void synchronized(const std::function<void()>& what);
|
||||
|
||||
// perform secure/sync operation (soft)
|
||||
void synchronizedSoft(const std::function<void()>& what);
|
||||
|
||||
// perform secure/sync song operation
|
||||
void lockSave(const std::function<void()>& what);
|
||||
|
||||
|
|
@ -1361,6 +1405,7 @@ class DivEngine {
|
|||
midiIsDirectProgram(false),
|
||||
lowLatency(false),
|
||||
systemsRegistered(false),
|
||||
romExportsRegistered(false),
|
||||
hasLoadedSomething(false),
|
||||
midiOutClock(false),
|
||||
midiOutTime(false),
|
||||
|
|
@ -1379,6 +1424,7 @@ class DivEngine {
|
|||
totalLoops(0),
|
||||
lastLoopPos(0),
|
||||
exportLoopCount(0),
|
||||
curExportChan(0),
|
||||
nextSpeed(3),
|
||||
elapsedBars(0),
|
||||
elapsedBeats(0),
|
||||
|
|
@ -1417,6 +1463,7 @@ class DivEngine {
|
|||
exportMode(DIV_EXPORT_MODE_ONE),
|
||||
exportFormat(DIV_EXPORT_FORMAT_S16),
|
||||
exportFadeOut(0.0),
|
||||
isFadingOut(false),
|
||||
exportOutputs(2),
|
||||
cmdStreamInt(NULL),
|
||||
midiBaseChan(0),
|
||||
|
|
@ -1467,6 +1514,7 @@ class DivEngine {
|
|||
memset(pitchTable,0,4096*sizeof(int));
|
||||
memset(effectSlotMap,-1,4096*sizeof(short));
|
||||
memset(sysDefs,0,DIV_MAX_CHIP_DEFS*sizeof(void*));
|
||||
memset(romExportDefs,0,DIV_ROM_MAX*sizeof(void*));
|
||||
memset(walked,0,8192);
|
||||
memset(oscBuf,0,DIV_MAX_OUTPUTS*(sizeof(float*)));
|
||||
memset(exportChannelMask,1,DIV_MAX_CHANS*sizeof(bool));
|
||||
|
|
|
|||
|
|
@ -20,18 +20,24 @@
|
|||
#include "engine.h"
|
||||
|
||||
#include "export/amigaValidation.h"
|
||||
#include "export/tiuna.h"
|
||||
#include "export/zsm.h"
|
||||
|
||||
std::vector<DivROMExportOutput> DivEngine::buildROM(DivROMExportOptions sys) {
|
||||
DivROMExport* DivEngine::buildROM(DivROMExportOptions sys) {
|
||||
DivROMExport* exporter=NULL;
|
||||
switch (sys) {
|
||||
case DIV_ROM_AMIGA_VALIDATION:
|
||||
exporter=new DivExportAmigaValidation;
|
||||
break;
|
||||
case DIV_ROM_TIUNA:
|
||||
exporter=new DivExportTiuna;
|
||||
break;
|
||||
case DIV_ROM_ZSM:
|
||||
exporter=new DivExportZSM;
|
||||
break;
|
||||
default:
|
||||
exporter=new DivROMExport;
|
||||
break;
|
||||
}
|
||||
std::vector<DivROMExportOutput> ret=exporter->go(this);
|
||||
delete exporter;
|
||||
return ret;
|
||||
return exporter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class DivEngine;
|
|||
enum DivROMExportOptions {
|
||||
DIV_ROM_ABSTRACT=0,
|
||||
DIV_ROM_AMIGA_VALIDATION,
|
||||
DIV_ROM_ZSM,
|
||||
DIV_ROM_TIUNA,
|
||||
|
||||
DIV_ROM_MAX
|
||||
};
|
||||
|
|
@ -45,30 +47,61 @@ struct DivROMExportOutput {
|
|||
data(NULL) {}
|
||||
};
|
||||
|
||||
struct DivROMExportProgress {
|
||||
String name;
|
||||
float amount;
|
||||
};
|
||||
|
||||
class DivROMExport {
|
||||
protected:
|
||||
DivConfig conf;
|
||||
std::vector<DivROMExportOutput> output;
|
||||
void logAppend(String what);
|
||||
public:
|
||||
virtual std::vector<DivROMExportOutput> go(DivEngine* e);
|
||||
std::vector<String> exportLog;
|
||||
std::mutex logLock;
|
||||
|
||||
void setConf(DivConfig& c);
|
||||
virtual bool go(DivEngine* eng);
|
||||
virtual void abort();
|
||||
virtual void wait();
|
||||
std::vector<DivROMExportOutput>& getResult();
|
||||
virtual bool hasFailed();
|
||||
virtual bool isRunning();
|
||||
virtual DivROMExportProgress getProgress(int index=0);
|
||||
virtual ~DivROMExport() {}
|
||||
};
|
||||
|
||||
#define logAppendf(...) logAppend(fmt::sprintf(__VA_ARGS__))
|
||||
|
||||
enum DivROMExportReqPolicy {
|
||||
// exactly these chips.
|
||||
DIV_REQPOL_EXACT=0,
|
||||
// specified chips must be present but any amount of them is acceptable.
|
||||
DIV_REQPOL_ANY,
|
||||
// at least one of the specified chips.
|
||||
DIV_REQPOL_LAX
|
||||
};
|
||||
|
||||
struct DivROMExportDef {
|
||||
const char* name;
|
||||
const char* author;
|
||||
const char* description;
|
||||
DivSystem requisites[32];
|
||||
int requisitesLen;
|
||||
const char* fileType;
|
||||
const char* fileExt;
|
||||
std::vector<DivSystem> requisites;
|
||||
bool multiOutput;
|
||||
DivROMExportReqPolicy requisitePolicy;
|
||||
|
||||
DivROMExportDef(const char* n, const char* a, const char* d, std::initializer_list<DivSystem> req, bool multiOut):
|
||||
DivROMExportDef(const char* n, const char* a, const char* d, const char* ft, const char* fe, std::initializer_list<DivSystem> req, bool multiOut, DivROMExportReqPolicy reqPolicy):
|
||||
name(n),
|
||||
author(a),
|
||||
description(d),
|
||||
multiOutput(multiOut) {
|
||||
requisitesLen=0;
|
||||
memset(requisites,0,32*sizeof(DivSystem));
|
||||
for (DivSystem i: req) {
|
||||
requisites[requisitesLen++]=i;
|
||||
}
|
||||
fileType(ft),
|
||||
fileExt(fe),
|
||||
multiOutput(multiOut),
|
||||
requisitePolicy(reqPolicy) {
|
||||
requisites=req;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,42 @@
|
|||
#include "../export.h"
|
||||
#include "../../ta-log.h"
|
||||
|
||||
std::vector<DivROMExportOutput> DivROMExport::go(DivEngine* e) {
|
||||
bool DivROMExport::go(DivEngine* eng) {
|
||||
logW("what's this? the null ROM export?");
|
||||
return std::vector<DivROMExportOutput>();
|
||||
return false;
|
||||
}
|
||||
|
||||
void DivROMExport::abort() {
|
||||
}
|
||||
|
||||
std::vector<DivROMExportOutput>& DivROMExport::getResult() {
|
||||
return output;
|
||||
}
|
||||
|
||||
bool DivROMExport::hasFailed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DivROMExportProgress DivROMExport::getProgress(int index) {
|
||||
DivROMExportProgress ret;
|
||||
ret.name="";
|
||||
ret.amount=0.0f;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DivROMExport::logAppend(String what) {
|
||||
logLock.lock();
|
||||
exportLog.push_back(what);
|
||||
logLock.unlock();
|
||||
}
|
||||
|
||||
void DivROMExport::wait() {
|
||||
}
|
||||
|
||||
bool DivROMExport::isRunning() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void DivROMExport::setConf(DivConfig& c) {
|
||||
conf=c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ struct SampleBookEntry {
|
|||
len(0) {}
|
||||
};
|
||||
|
||||
std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
|
||||
std::vector<DivROMExportOutput> ret;
|
||||
void DivExportAmigaValidation::run() {
|
||||
std::vector<WaveEntry> waves;
|
||||
std::vector<SampleBookEntry> sampleBook;
|
||||
unsigned int wavesDataPtr=0;
|
||||
|
|
@ -71,6 +70,7 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
|
|||
bool done=false;
|
||||
|
||||
// sample.bin
|
||||
logAppend("writing samples...");
|
||||
SafeWriter* sample=new SafeWriter;
|
||||
sample->init();
|
||||
for (int i=0; i<256; i++) {
|
||||
|
|
@ -80,6 +80,7 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
|
|||
if (sample->tell()&1) sample->writeC(0);
|
||||
|
||||
// seq.bin
|
||||
logAppend("making sequence...");
|
||||
SafeWriter* seq=new SafeWriter;
|
||||
seq->init();
|
||||
|
||||
|
|
@ -240,6 +241,7 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
|
|||
EXTERN_BUSY_END;
|
||||
|
||||
// wave.bin
|
||||
logAppend("writing wavetables...");
|
||||
SafeWriter* wave=new SafeWriter;
|
||||
wave->init();
|
||||
for (WaveEntry& i: waves) {
|
||||
|
|
@ -247,6 +249,7 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
|
|||
}
|
||||
|
||||
// sbook.bin
|
||||
logAppend("writing sample book...");
|
||||
SafeWriter* sbook=new SafeWriter;
|
||||
sbook->init();
|
||||
for (SampleBookEntry& i: sampleBook) {
|
||||
|
|
@ -256,6 +259,7 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
|
|||
}
|
||||
|
||||
// wbook.bin
|
||||
logAppend("writing wavetable book...");
|
||||
SafeWriter* wbook=new SafeWriter;
|
||||
wbook->init();
|
||||
for (WaveEntry& i: waves) {
|
||||
|
|
@ -266,12 +270,40 @@ std::vector<DivROMExportOutput> DivExportAmigaValidation::go(DivEngine* e) {
|
|||
}
|
||||
|
||||
// finish
|
||||
ret.reserve(5);
|
||||
ret.push_back(DivROMExportOutput("sbook.bin",sbook));
|
||||
ret.push_back(DivROMExportOutput("wbook.bin",wbook));
|
||||
ret.push_back(DivROMExportOutput("sample.bin",sample));
|
||||
ret.push_back(DivROMExportOutput("wave.bin",wave));
|
||||
ret.push_back(DivROMExportOutput("seq.bin",seq));
|
||||
output.reserve(5);
|
||||
output.push_back(DivROMExportOutput("sbook.bin",sbook));
|
||||
output.push_back(DivROMExportOutput("wbook.bin",wbook));
|
||||
output.push_back(DivROMExportOutput("sample.bin",sample));
|
||||
output.push_back(DivROMExportOutput("wave.bin",wave));
|
||||
output.push_back(DivROMExportOutput("seq.bin",seq));
|
||||
|
||||
return ret;
|
||||
logAppend("finished!");
|
||||
|
||||
running=false;
|
||||
}
|
||||
|
||||
bool DivExportAmigaValidation::go(DivEngine* eng) {
|
||||
e=eng;
|
||||
running=true;
|
||||
exportThread=new std::thread(&DivExportAmigaValidation::run,this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DivExportAmigaValidation::wait() {
|
||||
if (exportThread!=NULL) {
|
||||
exportThread->join();
|
||||
delete exportThread;
|
||||
}
|
||||
}
|
||||
|
||||
void DivExportAmigaValidation::abort() {
|
||||
wait();
|
||||
}
|
||||
|
||||
bool DivExportAmigaValidation::isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
bool DivExportAmigaValidation::hasFailed() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,18 @@
|
|||
|
||||
#include "../export.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
class DivExportAmigaValidation: public DivROMExport {
|
||||
DivEngine* e;
|
||||
std::thread* exportThread;
|
||||
bool running;
|
||||
void run();
|
||||
public:
|
||||
std::vector<DivROMExportOutput> go(DivEngine* e);
|
||||
bool go(DivEngine* e);
|
||||
bool isRunning();
|
||||
bool hasFailed();
|
||||
void abort();
|
||||
void wait();
|
||||
~DivExportAmigaValidation() {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "tiuna.h"
|
||||
#include "../engine.h"
|
||||
#include "../ta-log.h"
|
||||
#include <fmt/printf.h>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include "engine.h"
|
||||
#include "../fileutils.h"
|
||||
#include "../ta-log.h"
|
||||
|
||||
struct TiunaNew {
|
||||
short pitch;
|
||||
|
|
@ -126,7 +127,6 @@ struct TiunaMatches {
|
|||
static void writeCmd(std::vector<TiunaBytes>& cmds, TiunaCmd& cmd, unsigned char ch, int& lastWait, int fromTick, int toTick) {
|
||||
while (fromTick<toTick) {
|
||||
int val=MIN(toTick-fromTick,256);
|
||||
assert(val>0);
|
||||
if (lastWait!=val) {
|
||||
cmd.wait=val;
|
||||
lastWait=val;
|
||||
|
|
@ -180,140 +180,161 @@ static void writeCmd(std::vector<TiunaBytes>& cmds, TiunaCmd& cmd, unsigned char
|
|||
}
|
||||
}
|
||||
|
||||
SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel, int firstBankSize, int otherBankSize) {
|
||||
stop();
|
||||
repeatPattern=false;
|
||||
shallStop=false;
|
||||
setOrder(0);
|
||||
BUSY_BEGIN_SOFT;
|
||||
// determine loop point
|
||||
// bool stopped=false;
|
||||
int loopOrder=0;
|
||||
int loopOrderRow=0;
|
||||
int loopEnd=0;
|
||||
walkSong(loopOrder,loopOrderRow,loopEnd);
|
||||
logI("loop point: %d %d",loopOrder,loopOrderRow);
|
||||
|
||||
SafeWriter* w=new SafeWriter;
|
||||
w->init();
|
||||
|
||||
int tiaIdx=-1;
|
||||
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
if (sysToExport!=NULL && !sysToExport[i]) continue;
|
||||
if (song.system[i]==DIV_SYSTEM_TIA) {
|
||||
tiaIdx=i;
|
||||
disCont[i].dispatch->toggleRegisterDump(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tiaIdx<0) {
|
||||
lastError="selected TIA system not found";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// write patterns
|
||||
// bool writeLoop=false;
|
||||
bool done=false;
|
||||
playSub(false);
|
||||
|
||||
void DivExportTiuna::run() {
|
||||
int loopOrder, loopOrderRow, loopEnd;
|
||||
int tick=0;
|
||||
// int loopTick=-1;
|
||||
TiunaLast last[2];
|
||||
TiunaNew news[2];
|
||||
SafeWriter* w;
|
||||
std::map<int,TiunaCmd> allCmds[2];
|
||||
while (!done) {
|
||||
// TODO implement loop
|
||||
// if (loopTick<0 && loopOrder==curOrder && loopOrderRow==curRow
|
||||
// && (ticks-((tempoAccum+virtualTempoN)/virtualTempoD))<=0
|
||||
// ) {
|
||||
// writeLoop=true;
|
||||
// loopTick=tick;
|
||||
// // invalidate last register state so it always force an absolute write after loop
|
||||
// for (int i=0; i<2; i++) {
|
||||
// last[i]=TiunaLast();
|
||||
// last[i].pitch=-1;
|
||||
// last[i].ins=-1;
|
||||
// last[i].vol=-1;
|
||||
// }
|
||||
// }
|
||||
if (nextTick(false,true) || !playing) {
|
||||
// stopped=!playing;
|
||||
done=true;
|
||||
break;
|
||||
}
|
||||
for (int i=0; i<2; i++) {
|
||||
news[i]=TiunaNew();
|
||||
}
|
||||
// get register dumps
|
||||
std::vector<DivRegWrite>& writes=disCont[tiaIdx].dispatch->getRegisterWrites();
|
||||
for (const DivRegWrite& i: writes) {
|
||||
switch (i.addr) {
|
||||
case 0xfffe0000:
|
||||
case 0xfffe0001:
|
||||
news[i.addr&1].pitch=i.val;
|
||||
break;
|
||||
case 0xfffe0002:
|
||||
news[0].sync=i.val;
|
||||
break;
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
news[i.addr-0x15].ins=i.val;
|
||||
break;
|
||||
case 0x19:
|
||||
case 0x1a:
|
||||
news[i.addr-0x19].vol=i.val;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
writes.clear();
|
||||
// collect changes
|
||||
for (int i=0; i<2; i++) {
|
||||
TiunaCmd cmds;
|
||||
bool hasCmd=false;
|
||||
if (news[i].pitch>=0 && (last[i].forcePitch || news[i].pitch!=last[i].pitch)) {
|
||||
int dt=news[i].pitch-last[i].pitch;
|
||||
if (!last[i].forcePitch && abs(dt)<=16) {
|
||||
if (dt<0) cmds.pitchChange=15-dt;
|
||||
else cmds.pitchChange=dt-1;
|
||||
}
|
||||
else cmds.pitchSet=news[i].pitch;
|
||||
last[i].pitch=news[i].pitch;
|
||||
last[i].forcePitch=false;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (news[i].ins>=0 && news[i].ins!=last[i].ins) {
|
||||
cmds.ins=news[i].ins;
|
||||
last[i].ins=news[i].ins;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (news[i].vol>=0 && news[i].vol!=last[i].vol) {
|
||||
cmds.vol=(news[i].vol-last[i].vol)&0xf;
|
||||
last[i].vol=news[i].vol;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (news[i].sync>=0) {
|
||||
cmds.sync=news[i].sync;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (hasCmd) allCmds[i][tick]=cmds;
|
||||
}
|
||||
cmdStream.clear();
|
||||
tick++;
|
||||
}
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
disCont[i].dispatch->getRegisterWrites().clear();
|
||||
disCont[i].dispatch->toggleRegisterDump(false);
|
||||
}
|
||||
|
||||
remainingLoops=-1;
|
||||
playing=false;
|
||||
freelance=false;
|
||||
extValuePresent=false;
|
||||
BUSY_END;
|
||||
// config
|
||||
String baseLabel=conf.getString("baseLabel","song");
|
||||
int firstBankSize=conf.getInt("firstBankSize",3072);
|
||||
int otherBankSize=conf.getInt("otherBankSize",4096-48);
|
||||
int tiaIdx=conf.getInt("sysToExport",-1);
|
||||
|
||||
e->stop();
|
||||
e->repeatPattern=false;
|
||||
e->shallStop=false;
|
||||
e->setOrder(0);
|
||||
e->synchronizedSoft([&]() {
|
||||
// determine loop point
|
||||
// bool stopped=false;
|
||||
loopOrder=0;
|
||||
loopOrderRow=0;
|
||||
loopEnd=0;
|
||||
e->walkSong(loopOrder,loopOrderRow,loopEnd);
|
||||
logAppendf("loop point: %d %d",loopOrder,loopOrderRow);
|
||||
|
||||
w=new SafeWriter;
|
||||
w->init();
|
||||
|
||||
if (tiaIdx<0 || tiaIdx>=e->song.systemLen) {
|
||||
tiaIdx=-1;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
if (e->song.system[i]==DIV_SYSTEM_TIA) {
|
||||
tiaIdx=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tiaIdx<0) {
|
||||
logAppend("ERROR: selected TIA system not found");
|
||||
failed=true;
|
||||
running=false;
|
||||
return;
|
||||
}
|
||||
} else if (e->song.system[tiaIdx]!=DIV_SYSTEM_TIA) {
|
||||
logAppend("ERROR: selected chip is not a TIA!");
|
||||
failed=true;
|
||||
running=false;
|
||||
return;
|
||||
}
|
||||
|
||||
e->disCont[tiaIdx].dispatch->toggleRegisterDump(true);
|
||||
|
||||
// write patterns
|
||||
// bool writeLoop=false;
|
||||
logAppend("recording sequence...");
|
||||
bool done=false;
|
||||
e->playSub(false);
|
||||
|
||||
// int loopTick=-1;
|
||||
TiunaLast last[2];
|
||||
TiunaNew news[2];
|
||||
while (!done) {
|
||||
// TODO implement loop
|
||||
// if (loopTick<0 && loopOrder==curOrder && loopOrderRow==curRow
|
||||
// && (ticks-((tempoAccum+virtualTempoN)/virtualTempoD))<=0
|
||||
// ) {
|
||||
// writeLoop=true;
|
||||
// loopTick=tick;
|
||||
// // invalidate last register state so it always force an absolute write after loop
|
||||
// for (int i=0; i<2; i++) {
|
||||
// last[i]=TiunaLast();
|
||||
// last[i].pitch=-1;
|
||||
// last[i].ins=-1;
|
||||
// last[i].vol=-1;
|
||||
// }
|
||||
// }
|
||||
if (e->nextTick(false,true) || !e->playing) {
|
||||
// stopped=!playing;
|
||||
done=true;
|
||||
break;
|
||||
}
|
||||
for (int i=0; i<2; i++) {
|
||||
news[i]=TiunaNew();
|
||||
}
|
||||
// get register dumps
|
||||
std::vector<DivRegWrite>& writes=e->disCont[tiaIdx].dispatch->getRegisterWrites();
|
||||
for (const DivRegWrite& i: writes) {
|
||||
switch (i.addr) {
|
||||
case 0xfffe0000:
|
||||
case 0xfffe0001:
|
||||
news[i.addr&1].pitch=i.val;
|
||||
break;
|
||||
case 0xfffe0002:
|
||||
news[0].sync=i.val;
|
||||
break;
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
news[i.addr-0x15].ins=i.val;
|
||||
break;
|
||||
case 0x19:
|
||||
case 0x1a:
|
||||
news[i.addr-0x19].vol=i.val;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
writes.clear();
|
||||
// collect changes
|
||||
for (int i=0; i<2; i++) {
|
||||
TiunaCmd cmds;
|
||||
bool hasCmd=false;
|
||||
if (news[i].pitch>=0 && (last[i].forcePitch || news[i].pitch!=last[i].pitch)) {
|
||||
int dt=news[i].pitch-last[i].pitch;
|
||||
if (!last[i].forcePitch && abs(dt)<=16) {
|
||||
if (dt<0) cmds.pitchChange=15-dt;
|
||||
else cmds.pitchChange=dt-1;
|
||||
}
|
||||
else cmds.pitchSet=news[i].pitch;
|
||||
last[i].pitch=news[i].pitch;
|
||||
last[i].forcePitch=false;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (news[i].ins>=0 && news[i].ins!=last[i].ins) {
|
||||
cmds.ins=news[i].ins;
|
||||
last[i].ins=news[i].ins;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (news[i].vol>=0 && news[i].vol!=last[i].vol) {
|
||||
cmds.vol=(news[i].vol-last[i].vol)&0xf;
|
||||
last[i].vol=news[i].vol;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (news[i].sync>=0) {
|
||||
cmds.sync=news[i].sync;
|
||||
hasCmd=true;
|
||||
}
|
||||
if (hasCmd) allCmds[i][tick]=cmds;
|
||||
}
|
||||
e->cmdStream.clear();
|
||||
tick++;
|
||||
}
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
e->disCont[i].dispatch->getRegisterWrites().clear();
|
||||
e->disCont[i].dispatch->toggleRegisterDump(false);
|
||||
}
|
||||
|
||||
e->remainingLoops=-1;
|
||||
e->playing=false;
|
||||
e->freelance=false;
|
||||
e->extValuePresent=false;
|
||||
});
|
||||
|
||||
if (failed) return;
|
||||
|
||||
// render commands
|
||||
logAppend("rendering commands...");
|
||||
std::vector<TiunaBytes> renderedCmds;
|
||||
w->writeText(fmt::format(
|
||||
"; Generated by Furnace " DIV_VERSION "\n"
|
||||
|
|
@ -321,7 +342,7 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
|||
"; Author: {}\n"
|
||||
"; Album: {}\n"
|
||||
"; Subsong #{}: {}\n\n",
|
||||
song.name,song.author,song.category,curSubSongIndex+1,curSubSong->name
|
||||
e->song.name,e->song.author,e->song.category,e->curSubSongIndex+1,e->curSubSong->name
|
||||
));
|
||||
for (int i=0; i<2; i++) {
|
||||
TiunaCmd lastCmd;
|
||||
|
|
@ -347,17 +368,37 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
|||
std::vector<int> callTicks;
|
||||
int cmId=0;
|
||||
int cmdSize=renderedCmds.size();
|
||||
std::vector<bool> processed=std::vector<bool>(cmdSize,false);
|
||||
while (firstBankSize>768 && cmId<(MAX(firstBankSize/1024,1))*256) {
|
||||
bool* processed=new bool[cmdSize];
|
||||
memset(processed,0,cmdSize*sizeof(bool));
|
||||
logAppend("compressing! this may take a while.");
|
||||
int maxCmId=(MAX(firstBankSize/1024,1))*256;
|
||||
int lastMaxPMVal=100000;
|
||||
logAppendf("max cmId: %d",maxCmId);
|
||||
logAppendf("commands: %d",cmdSize);
|
||||
while (firstBankSize>768 && cmId<maxCmId) {
|
||||
if (mustAbort) {
|
||||
logAppend("aborted!");
|
||||
failed=true;
|
||||
running=false;
|
||||
delete[] processed;
|
||||
return;
|
||||
}
|
||||
|
||||
float theOtherSide=pow(1.0/float(MAX(1,lastMaxPMVal)),0.2)*0.98;
|
||||
progress[0].amount=theOtherSide+(1.0-theOtherSide)*((float)cmId/(float)maxCmId);
|
||||
|
||||
logAppendf("start CM %04x...",cmId);
|
||||
std::map<int,TiunaMatches> potentialMatches;
|
||||
for (int i=0; i<cmdSize-1;) {
|
||||
// continue and skip if it's part of previous confirmed matches
|
||||
while (i<cmdSize-1 && processed[i]) i++;
|
||||
if (i>=cmdSize-1) break;
|
||||
progress[1].amount=(float)i/(float)(cmdSize-1);
|
||||
std::vector<TiunaMatch> match;
|
||||
int ch=renderedCmds[i].ch;
|
||||
for (int j=i+1; j<cmdSize;) {
|
||||
while (j<cmdSize && processed[i]) j++;
|
||||
if (processed[i]) break;
|
||||
//while (j<cmdSize && processed[i]) j++;
|
||||
if (j>=cmdSize) break;
|
||||
int k=0;
|
||||
int ticks=0;
|
||||
|
|
@ -421,7 +462,10 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
|||
}
|
||||
i++;
|
||||
}
|
||||
if (potentialMatches.empty()) break;
|
||||
if (potentialMatches.empty()) {
|
||||
logAppend("potentialMatches is empty");
|
||||
break;
|
||||
}
|
||||
int maxPMIdx=0;
|
||||
int maxPMVal=0;
|
||||
for (const auto& i: potentialMatches) {
|
||||
|
|
@ -433,12 +477,18 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
|||
int maxPMLen=potentialMatches[maxPMIdx].length;
|
||||
for (const int i: potentialMatches[maxPMIdx].pos) {
|
||||
confirmedMatches.push_back({i,i+maxPMLen,0,cmId});
|
||||
std::fill(processed.begin()+i,processed.begin()+(i+maxPMLen),true);
|
||||
memset(processed+i,1,maxPMLen);
|
||||
//std::fill(processed.begin()+i,processed.begin()+(i+maxPMLen),true);
|
||||
}
|
||||
callTicks.push_back(potentialMatches[maxPMIdx].ticks);
|
||||
logI("CM %04x added: pos=%d,len=%d,matches=%d,saved=%d",cmId,maxPMIdx,maxPMLen,potentialMatches[maxPMIdx].pos.size(),maxPMVal);
|
||||
logAppendf("CM %04x added: pos=%d,len=%d,matches=%d,saved=%d",cmId,maxPMIdx,maxPMLen,potentialMatches[maxPMIdx].pos.size(),maxPMVal);
|
||||
lastMaxPMVal=maxPMVal;
|
||||
cmId++;
|
||||
}
|
||||
progress[0].amount=1.0f;
|
||||
progress[1].amount=1.0f;
|
||||
logAppend("generating data...");
|
||||
delete[] processed;
|
||||
std::sort(confirmedMatches.begin(),confirmedMatches.end(),[](const TiunaMatch& l, const TiunaMatch& r){
|
||||
return l.pos<r.pos;
|
||||
});
|
||||
|
|
@ -448,14 +498,10 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
|||
// overlap check
|
||||
for (int i=1; i<(int)confirmedMatches.size(); i++) {
|
||||
if (confirmedMatches[i-1].endPos<=confirmedMatches[i].pos) continue;
|
||||
lastError="impossible overlap found in matches list, please report";
|
||||
return NULL;
|
||||
}
|
||||
SafeWriter dbg;
|
||||
dbg.init();
|
||||
dbg.writeText(fmt::format("renderedCmds size={}\n",renderedCmds.size()));
|
||||
for (const auto& i: confirmedMatches) {
|
||||
dbg.writeText(fmt::format("pos={},end={},id={}\n",i.pos,i.endPos,i.id,i.size));
|
||||
logAppend("ERROR: impossible overlap found in matches list, please report");
|
||||
failed=true;
|
||||
running=false;
|
||||
return;
|
||||
}
|
||||
|
||||
// write commands
|
||||
|
|
@ -498,8 +544,10 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
|||
}
|
||||
w->writeC('\n');
|
||||
if (totalSize>firstBankSize) {
|
||||
lastError="first bank is not large enough to contain call table";
|
||||
return NULL;
|
||||
logAppend("ERROR: first bank is not large enough to contain call table");
|
||||
failed=true;
|
||||
running=false;
|
||||
return;
|
||||
}
|
||||
|
||||
int curBank=0;
|
||||
|
|
@ -560,13 +608,50 @@ SafeWriter* DivEngine::saveTiuna(const bool* sysToExport, const char* baseLabel,
|
|||
}
|
||||
w->writeText(" .text x\"e0\"\n .endsection\n");
|
||||
totalSize++;
|
||||
logI("total size: %d bytes (%d banks)",totalSize,curBank+1);
|
||||
|
||||
//FILE* f=ps_fopen("confirmedMatches.txt","wb");
|
||||
//if (f!=NULL) {
|
||||
// fwrite(dbg.getFinalBuf(),1,dbg.size(),f);
|
||||
// fclose(f);
|
||||
//}
|
||||
logAppendf("total size: %d bytes (%d banks)",totalSize,curBank+1);
|
||||
|
||||
return w;
|
||||
output.push_back(DivROMExportOutput("export.asm",w));
|
||||
|
||||
logAppend("finished!");
|
||||
|
||||
running=false;
|
||||
}
|
||||
|
||||
bool DivExportTiuna::go(DivEngine* eng) {
|
||||
progress[0].name="Compression";
|
||||
progress[0].amount=0.0f;
|
||||
progress[1].name="Confirmed Matches";
|
||||
progress[1].amount=0.0f;
|
||||
|
||||
e=eng;
|
||||
running=true;
|
||||
failed=false;
|
||||
mustAbort=false;
|
||||
exportThread=new std::thread(&DivExportTiuna::run,this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DivExportTiuna::wait() {
|
||||
if (exportThread!=NULL) {
|
||||
exportThread->join();
|
||||
delete exportThread;
|
||||
}
|
||||
}
|
||||
|
||||
void DivExportTiuna::abort() {
|
||||
mustAbort=true;
|
||||
wait();
|
||||
}
|
||||
|
||||
bool DivExportTiuna::isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
bool DivExportTiuna::hasFailed() {
|
||||
return failed;
|
||||
}
|
||||
|
||||
DivROMExportProgress DivExportTiuna::getProgress(int index) {
|
||||
if (index<0 || index>2) return progress[2];
|
||||
return progress[index];
|
||||
}
|
||||
38
src/engine/export/tiuna.h
Normal file
38
src/engine/export/tiuna.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "../export.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
class DivExportTiuna: public DivROMExport {
|
||||
DivEngine* e;
|
||||
std::thread* exportThread;
|
||||
DivROMExportProgress progress[3];
|
||||
bool running, failed, mustAbort;
|
||||
void run();
|
||||
public:
|
||||
bool go(DivEngine* e);
|
||||
bool isRunning();
|
||||
bool hasFailed();
|
||||
void abort();
|
||||
void wait();
|
||||
DivROMExportProgress getProgress(int index=0);
|
||||
~DivExportTiuna() {}
|
||||
};
|
||||
|
|
@ -18,9 +18,77 @@
|
|||
*/
|
||||
|
||||
#include "zsm.h"
|
||||
#include "../engine.h"
|
||||
#include "../ta-log.h"
|
||||
#include "../utfutils.h"
|
||||
#include "song.h"
|
||||
#include <fmt/printf.h>
|
||||
|
||||
/// DivZSM definitions
|
||||
|
||||
#define ZSM_HEADER_SIZE 16
|
||||
#define ZSM_VERSION 1
|
||||
#define ZSM_YM_CMD 0x40
|
||||
#define ZSM_DELAY_CMD 0x80
|
||||
#define ZSM_YM_MAX_WRITES 63
|
||||
#define ZSM_SYNC_MAX_WRITES 31
|
||||
#define ZSM_DELAY_MAX 127
|
||||
#define ZSM_EOF ZSM_DELAY_CMD
|
||||
|
||||
#define ZSM_EXT ZSM_YM_CMD
|
||||
#define ZSM_EXT_PCM 0x00
|
||||
#define ZSM_EXT_CHIP 0x40
|
||||
#define ZSM_EXT_SYNC 0x80
|
||||
#define ZSM_EXT_CUSTOM 0xC0
|
||||
|
||||
enum YM_STATE { ym_PREV, ym_NEW, ym_STATES };
|
||||
enum PSG_STATE { psg_PREV, psg_NEW, psg_STATES };
|
||||
|
||||
class DivZSM {
|
||||
private:
|
||||
struct S_pcmInst {
|
||||
int geometry;
|
||||
unsigned int offset, length, loopPoint;
|
||||
bool isLooped;
|
||||
};
|
||||
SafeWriter* w;
|
||||
int ymState[ym_STATES][256];
|
||||
int psgState[psg_STATES][64];
|
||||
int pcmRateCache;
|
||||
int pcmCtrlRVCache;
|
||||
int pcmCtrlDCCache;
|
||||
unsigned int pcmLoopPointCache;
|
||||
bool pcmIsLooped;
|
||||
std::vector<DivRegWrite> ymwrites;
|
||||
std::vector<DivRegWrite> pcmMeta;
|
||||
std::vector<unsigned char> pcmData;
|
||||
std::vector<unsigned char> pcmCache;
|
||||
std::vector<S_pcmInst> pcmInsts;
|
||||
std::vector<DivRegWrite> syncCache;
|
||||
int loopOffset;
|
||||
int numWrites;
|
||||
int ticks;
|
||||
int tickRate;
|
||||
int ymMask;
|
||||
int psgMask;
|
||||
bool optimize;
|
||||
public:
|
||||
DivZSM();
|
||||
~DivZSM();
|
||||
void init(unsigned int rate = 60);
|
||||
int getoffset();
|
||||
void writeYM(unsigned char a, unsigned char v);
|
||||
void writePSG(unsigned char a, unsigned char v);
|
||||
void writePCM(unsigned char a, unsigned char v);
|
||||
void writeSync(unsigned char a, unsigned char v);
|
||||
void setOptimize(bool o);
|
||||
void tick(int numticks = 1);
|
||||
void setLoopPoint();
|
||||
SafeWriter* finish();
|
||||
private:
|
||||
void flushWrites();
|
||||
void flushTicks();
|
||||
};
|
||||
|
||||
/// DivZSM implementation
|
||||
|
||||
DivZSM::DivZSM() {
|
||||
w=NULL;
|
||||
|
|
@ -133,14 +201,6 @@ void DivZSM::writePSG(unsigned char a, unsigned char v) {
|
|||
} else if (a>=64) {
|
||||
return writePCM(a-64,v);
|
||||
}
|
||||
if (optimize) {
|
||||
if ((a&3)==3 && v>64) {
|
||||
// Pulse width on non-pulse waves is nonsense and wasteful
|
||||
// No need to preserve state here because the next write that
|
||||
// selects pulse will also set the pulse width in this register
|
||||
v&=0xc0;
|
||||
}
|
||||
}
|
||||
if (psgState[psg_PREV][a]==v) {
|
||||
if (psgState[psg_NEW][a]!=v) {
|
||||
// NEW value is being reset to the same as PREV value
|
||||
|
|
@ -455,3 +515,243 @@ void DivZSM::flushTicks() {
|
|||
}
|
||||
ticks=0;
|
||||
}
|
||||
|
||||
/// ZSM export
|
||||
|
||||
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
|
||||
constexpr int MASTER_CLOCK_MASK=(sizeof(void*)==8)?0xff:0;
|
||||
|
||||
void DivExportZSM::run() {
|
||||
// settings
|
||||
unsigned int zsmrate=conf.getInt("zsmrate",60);
|
||||
bool loop=conf.getBool("loop",true);
|
||||
bool optimize=conf.getBool("optimize",true);
|
||||
|
||||
// system IDs
|
||||
int VERA=-1;
|
||||
int YM=-1;
|
||||
int IGNORED=0;
|
||||
|
||||
// find indexes for YM and VERA. Ignore other systems.
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
switch (e->song.system[i]) {
|
||||
case DIV_SYSTEM_VERA:
|
||||
if (VERA>=0) {
|
||||
IGNORED++;
|
||||
break;
|
||||
}
|
||||
VERA=i;
|
||||
logAppendf("VERA detected as chip id %d",i);
|
||||
break;
|
||||
case DIV_SYSTEM_YM2151:
|
||||
if (YM>=0) {
|
||||
IGNORED++;
|
||||
break;
|
||||
}
|
||||
YM=i;
|
||||
logAppendf("YM detected as chip id %d",i);
|
||||
break;
|
||||
default:
|
||||
IGNORED++;
|
||||
logAppendf("Ignoring chip %d systemID %d",i,(int)e->song.system[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (VERA<0 && YM<0) {
|
||||
logAppend("ERROR: No supported systems for ZSM");
|
||||
failed=true;
|
||||
running=false;
|
||||
return;
|
||||
}
|
||||
if (IGNORED>0) {
|
||||
logAppendf("ZSM export ignoring %d unsupported system%c",IGNORED,IGNORED>1?'s':' ');
|
||||
}
|
||||
|
||||
DivZSM zsm;
|
||||
|
||||
e->stop();
|
||||
e->repeatPattern=false;
|
||||
e->setOrder(0);
|
||||
e->synchronizedSoft([&]() {
|
||||
double origRate=e->got.rate;
|
||||
e->got.rate=zsmrate&0xffff;
|
||||
|
||||
// determine loop point
|
||||
int loopOrder=0;
|
||||
int loopRow=0;
|
||||
int loopEnd=0;
|
||||
e->walkSong(loopOrder,loopRow,loopEnd);
|
||||
logAppendf("loop point: %d %d",loopOrder,loopRow);
|
||||
|
||||
zsm.init(zsmrate);
|
||||
|
||||
// reset the playback state
|
||||
e->curOrder=0;
|
||||
e->freelance=false;
|
||||
e->playing=false;
|
||||
e->extValuePresent=false;
|
||||
e->remainingLoops=-1;
|
||||
|
||||
// Prepare to write song data
|
||||
e->playSub(false);
|
||||
//size_t tickCount=0;
|
||||
bool done=false;
|
||||
bool loopNow=false;
|
||||
int loopPos=-1;
|
||||
int fracWait=0; // accumulates fractional ticks
|
||||
if (VERA>=0) e->disCont[VERA].dispatch->toggleRegisterDump(true);
|
||||
if (YM>=0) {
|
||||
e->disCont[YM].dispatch->toggleRegisterDump(true);
|
||||
// emit LFO initialization commands
|
||||
zsm.writeYM(0x18,0); // freq=0
|
||||
zsm.writeYM(0x19,0x7F); // AMD =7F
|
||||
zsm.writeYM(0x19,0xFF); // PMD =7F
|
||||
// TODO: incorporate the Furnace meta-command for init data and filter
|
||||
// out writes to otherwise-unused channels.
|
||||
}
|
||||
// Indicate the song's tuning as a sync meta-event
|
||||
// specified in terms of how many 1/256th semitones
|
||||
// the song is offset from standard A-440 tuning.
|
||||
// This is mainly to benefit visualizations in players
|
||||
// for non-standard tunings so that they can avoid
|
||||
// displaying the entire song held in pitch bend.
|
||||
// Tunings offsets that exceed a half semitone
|
||||
// will simply be represented in a different key
|
||||
// by nature of overflowing the signed char value
|
||||
signed char tuningoffset=(signed char)(round(3072*(log(e->song.tuning/440.0)/log(2))))&0xff;
|
||||
zsm.writeSync(0x01,tuningoffset);
|
||||
// Set optimize flag, which mainly buffers PSG writes
|
||||
// whenever the channel is silent
|
||||
zsm.setOptimize(optimize);
|
||||
|
||||
while (!done) {
|
||||
if (loopPos==-1) {
|
||||
if (loopOrder==e->curOrder && loopRow==e->curRow && loop)
|
||||
loopNow=true;
|
||||
if (loopNow) {
|
||||
// If Virtual Tempo is in use, our exact loop point
|
||||
// might be skipped due to quantization error.
|
||||
// If this happens, the tick immediately following is our loop point.
|
||||
if (e->ticks==1 || !(loopOrder==e->curOrder && loopRow==e->curRow)) {
|
||||
loopPos=zsm.getoffset();
|
||||
zsm.setLoopPoint();
|
||||
loopNow=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e->nextTick() || !e->playing) {
|
||||
done=true;
|
||||
if (!loop) {
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
e->disCont[i].dispatch->getRegisterWrites().clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!e->playing) {
|
||||
loopPos=-1;
|
||||
}
|
||||
}
|
||||
// get register dumps
|
||||
for (int j=0; j<2; j++) {
|
||||
int i=0;
|
||||
// dump YM writes first
|
||||
if (j==0) {
|
||||
if (YM<0) {
|
||||
continue;
|
||||
} else {
|
||||
i=YM;
|
||||
}
|
||||
}
|
||||
// dump VERA writes second
|
||||
if (j==1) {
|
||||
if (VERA<0) {
|
||||
continue;
|
||||
} else {
|
||||
i=VERA;
|
||||
}
|
||||
}
|
||||
std::vector<DivRegWrite>& writes=e->disCont[i].dispatch->getRegisterWrites();
|
||||
if (writes.size()>0)
|
||||
logD("zsmOps: Writing %d messages to chip %d",writes.size(),i);
|
||||
for (DivRegWrite& write: writes) {
|
||||
if (i==YM) {
|
||||
if (done && write.addr==0x08 && (write.val&0x78)>0) continue; // don't process keydown on lookahead
|
||||
zsm.writeYM(write.addr&0xff,write.val);
|
||||
}
|
||||
if (i==VERA) {
|
||||
if (done && write.addr>=64) continue; // don't process any PCM or sync events on the loop lookahead
|
||||
zsm.writePSG(write.addr&0xff,write.val);
|
||||
}
|
||||
}
|
||||
writes.clear();
|
||||
}
|
||||
|
||||
// write wait
|
||||
int totalWait=e->cycles>>MASTER_CLOCK_PREC;
|
||||
fracWait+=e->cycles&MASTER_CLOCK_MASK;
|
||||
totalWait+=fracWait>>MASTER_CLOCK_PREC;
|
||||
fracWait&=MASTER_CLOCK_MASK;
|
||||
if (totalWait>0 && !done) {
|
||||
zsm.tick(totalWait);
|
||||
//tickCount+=totalWait;
|
||||
}
|
||||
}
|
||||
// end of song
|
||||
|
||||
// done - close out.
|
||||
e->got.rate=origRate;
|
||||
if (VERA>=0) e->disCont[VERA].dispatch->toggleRegisterDump(false);
|
||||
if (YM>=0) e->disCont[YM].dispatch->toggleRegisterDump(false);
|
||||
|
||||
e->remainingLoops=-1;
|
||||
e->playing=false;
|
||||
e->freelance=false;
|
||||
e->extValuePresent=false;
|
||||
});
|
||||
|
||||
progress[0].amount=1.0f;
|
||||
|
||||
logAppend("finished!");
|
||||
|
||||
output.push_back(DivROMExportOutput("out.zsm",zsm.finish()));
|
||||
running=false;
|
||||
}
|
||||
|
||||
/// DivExpottZSM - FRONTEND
|
||||
|
||||
bool DivExportZSM::go(DivEngine* eng) {
|
||||
progress[0].name="Generate";
|
||||
progress[0].amount=0.0f;
|
||||
|
||||
e=eng;
|
||||
running=true;
|
||||
failed=false;
|
||||
mustAbort=false;
|
||||
exportThread=new std::thread(&DivExportZSM::run,this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DivExportZSM::wait() {
|
||||
if (exportThread!=NULL) {
|
||||
exportThread->join();
|
||||
delete exportThread;
|
||||
}
|
||||
}
|
||||
|
||||
void DivExportZSM::abort() {
|
||||
mustAbort=true;
|
||||
wait();
|
||||
}
|
||||
|
||||
bool DivExportZSM::isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
bool DivExportZSM::hasFailed() {
|
||||
return failed;
|
||||
}
|
||||
|
||||
DivROMExportProgress DivExportZSM::getProgress(int index) {
|
||||
if (index<0 || index>1) return progress[1];
|
||||
return progress[index];
|
||||
}
|
||||
38
src/engine/export/zsm.h
Normal file
38
src/engine/export/zsm.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "../export.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
class DivExportZSM: public DivROMExport {
|
||||
DivEngine* e;
|
||||
std::thread* exportThread;
|
||||
DivROMExportProgress progress[2];
|
||||
bool running, failed, mustAbort;
|
||||
void run();
|
||||
public:
|
||||
bool go(DivEngine* e);
|
||||
bool isRunning();
|
||||
bool hasFailed();
|
||||
void abort();
|
||||
void wait();
|
||||
DivROMExportProgress getProgress(int index=0);
|
||||
~DivExportZSM() {}
|
||||
};
|
||||
63
src/engine/exportDef.cpp
Normal file
63
src/engine/exportDef.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
DivROMExportDef* DivEngine::romExportDefs[DIV_ROM_MAX];
|
||||
|
||||
const DivROMExportDef* DivEngine::getROMExportDef(DivROMExportOptions opt) {
|
||||
return romExportDefs[opt];
|
||||
}
|
||||
|
||||
void DivEngine::registerROMExports() {
|
||||
logD("registering ROM exports...");
|
||||
|
||||
romExportDefs[DIV_ROM_AMIGA_VALIDATION]=new DivROMExportDef(
|
||||
"Amiga Validation", "tildearrow",
|
||||
"a test export for ensuring Amiga emulation is accurate. do not use!",
|
||||
NULL, NULL,
|
||||
{DIV_SYSTEM_AMIGA},
|
||||
true, DIV_REQPOL_EXACT
|
||||
);
|
||||
|
||||
romExportDefs[DIV_ROM_ZSM]=new DivROMExportDef(
|
||||
"Commander X16 ZSM", "ZeroByteOrg and MooingLemur",
|
||||
"Commander X16 Zsound Music File.\n"
|
||||
"for use with Melodius, Calliope and/or ZSMKit:\n"
|
||||
"- https://github.com/mooinglemur/zsmkit (development)\n"
|
||||
"- https://github.com/mooinglemur/melodius (player)\n"
|
||||
"- https://github.com/ZeroByteOrg/calliope (player)\n",
|
||||
"ZSM file", ".zsm",
|
||||
{
|
||||
DIV_SYSTEM_YM2151, DIV_SYSTEM_VERA
|
||||
},
|
||||
false, DIV_REQPOL_LAX
|
||||
);
|
||||
|
||||
romExportDefs[DIV_ROM_TIUNA]=new DivROMExportDef(
|
||||
"Atari 2600 (TIunA)", "Natt Akuma",
|
||||
"advanced driver with software tuning support.\n"
|
||||
"see https://github.com/AYCEdemo/twin-tiuna for code.",
|
||||
"assembly files", ".asm",
|
||||
{
|
||||
DIV_SYSTEM_TIA
|
||||
},
|
||||
false, DIV_REQPOL_ANY
|
||||
);
|
||||
}
|
||||
|
|
@ -63,3 +63,34 @@ enum DivFurVariants: int {
|
|||
DIV_FUR_VARIANT_VANILLA=0,
|
||||
DIV_FUR_VARIANT_B=1,
|
||||
};
|
||||
|
||||
// MIDI-related
|
||||
struct midibank_t {
|
||||
String name;
|
||||
uint8_t bankMsb,
|
||||
bankLsb;
|
||||
};
|
||||
|
||||
// Reused patch data structures
|
||||
|
||||
// SBI and some other OPL containers
|
||||
|
||||
struct sbi_t {
|
||||
uint8_t Mcharacteristics,
|
||||
Ccharacteristics,
|
||||
Mscaling_output,
|
||||
Cscaling_output,
|
||||
Meg_AD,
|
||||
Ceg_AD,
|
||||
Meg_SR,
|
||||
Ceg_SR,
|
||||
Mwave,
|
||||
Cwave,
|
||||
FeedConnect;
|
||||
};
|
||||
|
||||
//bool stringNotBlank(String& str);
|
||||
// detune needs extra translation from register to furnace format
|
||||
//uint8_t fmDtRegisterToFurnace(uint8_t&& dtNative);
|
||||
|
||||
//void readSbiOpData(sbi_t& sbi, SafeReader& reader);
|
||||
|
|
|
|||
|
|
@ -2094,8 +2094,24 @@ bool DivEngine::loadFur(unsigned char* file, size_t len, int variantID) {
|
|||
ds.systemFlags[i].set("oldPitch",true);
|
||||
}
|
||||
}
|
||||
} else if (ds.version<217) {
|
||||
for (int i=0; i<ds.systemLen; i++) {
|
||||
if (ds.system[i]==DIV_SYSTEM_VERA) {
|
||||
ds.systemFlags[i].set("chipType",1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SNES no anti-click
|
||||
if (ds.version<220) {
|
||||
for (int i=0; i<ds.systemLen; i++) {
|
||||
if (ds.system[i]==DIV_SYSTEM_SNES) {
|
||||
ds.systemFlags[i].set("antiClick",false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (active) quitDispatch();
|
||||
BUSY_BEGIN_SOFT;
|
||||
saveLock.lock();
|
||||
|
|
|
|||
|
|
@ -639,6 +639,8 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) {
|
|||
logD("seek not needed...");
|
||||
}
|
||||
|
||||
logV("reading sample data (%d)",s->samples);
|
||||
|
||||
if (flags&8) { // compressed sample
|
||||
unsigned int ret=0;
|
||||
logV("decompression begin... (%d)",s->samples);
|
||||
|
|
@ -672,62 +674,66 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) {
|
|||
}
|
||||
logV("got: %d",ret);
|
||||
} else {
|
||||
if (s->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short l;
|
||||
if (convert&2) {
|
||||
l=reader.readS_BE();
|
||||
} else {
|
||||
l=reader.readS();
|
||||
try {
|
||||
if (s->depth==DIV_SAMPLE_DEPTH_16BIT) {
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short l;
|
||||
if (convert&2) {
|
||||
l=reader.readS_BE();
|
||||
} else {
|
||||
l=reader.readS();
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
l^=0x8000;
|
||||
}
|
||||
s->data16[i]=l;
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
l^=0x8000;
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short r;
|
||||
if (convert&2) {
|
||||
r=reader.readS_BE();
|
||||
} else {
|
||||
r=reader.readS();
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
r^=0x8000;
|
||||
}
|
||||
s->data16[i]=(s->data16[i]+r)>>1;
|
||||
}
|
||||
s->data16[i]=l;
|
||||
}
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
short r;
|
||||
if (convert&2) {
|
||||
r=reader.readS_BE();
|
||||
} else {
|
||||
r=reader.readS();
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
if (convert&2) {
|
||||
s->data16[i]=reader.readS_BE()^((convert&1)?0:0x8000);
|
||||
} else {
|
||||
s->data16[i]=reader.readS()^((convert&1)?0:0x8000);
|
||||
}
|
||||
}
|
||||
if (!(convert&1)) {
|
||||
r^=0x8000;
|
||||
}
|
||||
s->data16[i]=(s->data16[i]+r)>>1;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
if (convert&2) {
|
||||
s->data16[i]=reader.readS_BE()^((convert&1)?0:0x8000);
|
||||
} else {
|
||||
s->data16[i]=reader.readS()^((convert&1)?0:0x8000);
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char l=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
l^=0x80;
|
||||
}
|
||||
s->data8[i]=l;
|
||||
}
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char r=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
r^=0x80;
|
||||
}
|
||||
s->data8[i]=(s->data8[i]+r)>>1;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
s->data8[i]=reader.readC()^((convert&1)?0:0x80);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (flags&4) { // downmix stereo
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char l=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
l^=0x80;
|
||||
}
|
||||
s->data8[i]=l;
|
||||
}
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
signed char r=reader.readC();
|
||||
if (!(convert&1)) {
|
||||
r^=0x80;
|
||||
}
|
||||
s->data8[i]=(s->data8[i]+r)>>1;
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i=0; i<s->samples; i++) {
|
||||
s->data8[i]=reader.readC()^((convert&1)?0:0x80);
|
||||
}
|
||||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
logW("premature end of file...");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
124
src/engine/fileOps/p.cpp
Normal file
124
src/engine/fileOps/p.cpp
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
//P VOX ADPCM sample bank
|
||||
|
||||
/* =======================================
|
||||
Header
|
||||
=======================================
|
||||
|
||||
0x0000 - 0x03FF 256 * {
|
||||
Sample start (uint32_t)
|
||||
- 0x00000000 = unused
|
||||
}
|
||||
|
||||
|
||||
=======================================
|
||||
Body
|
||||
=======================================
|
||||
|
||||
Stream of Sample Data {
|
||||
|
||||
MSM6258 ADPCM encoding
|
||||
nibble-swapped VOX / Dialogic ADPCM
|
||||
Mono
|
||||
Sample rate?
|
||||
16000Hz seems fine
|
||||
|
||||
} */
|
||||
|
||||
#define P_BANK_SIZE 256
|
||||
#define P_SAMPLE_RATE 16000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t start_pointer;
|
||||
} P_HEADER;
|
||||
|
||||
|
||||
void DivEngine::loadP(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.seek(0, SEEK_SET);
|
||||
|
||||
P_HEADER headers[P_BANK_SIZE];
|
||||
|
||||
for(int i = 0; i < P_BANK_SIZE; i++)
|
||||
{
|
||||
headers[i].start_pointer = (unsigned int)reader.readI_BE();
|
||||
}
|
||||
|
||||
for(int i = 0; i < P_BANK_SIZE; i++)
|
||||
{
|
||||
if(headers[i].start_pointer != 0)
|
||||
{
|
||||
DivSample* s = new DivSample;
|
||||
|
||||
s->rate = P_SAMPLE_RATE;
|
||||
s->centerRate = P_SAMPLE_RATE;
|
||||
s->depth = DIV_SAMPLE_DEPTH_VOX;
|
||||
|
||||
reader.seek((int)headers[i].start_pointer, SEEK_SET);
|
||||
|
||||
int sample_pos = 0;
|
||||
int sample_len = 0;
|
||||
|
||||
if(i < P_BANK_SIZE - 1)
|
||||
{
|
||||
sample_len = headers[i + 1].start_pointer - headers[i].start_pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample_len = (int)reader.size() - headers[i].start_pointer;
|
||||
}
|
||||
|
||||
if(sample_len > 0)
|
||||
{
|
||||
s->init(sample_len * 2);
|
||||
|
||||
for(int j = 0; j < sample_len; j++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
curr_byte = (curr_byte << 4) | (curr_byte >> 4);
|
||||
|
||||
s->dataVOX[sample_pos] = curr_byte;
|
||||
sample_pos++;
|
||||
}
|
||||
|
||||
ret.push_back(s);
|
||||
logI("p: start %d len %d", headers[i].start_pointer, sample_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfFileException& e)
|
||||
{
|
||||
lastError=_("premature end of file");
|
||||
logE("premature end of file");
|
||||
}
|
||||
}
|
||||
142
src/engine/fileOps/p86.cpp
Normal file
142
src/engine/fileOps/p86.cpp
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
//P86 8-bit PCM sample bank
|
||||
|
||||
/* =======================================
|
||||
Header
|
||||
=======================================
|
||||
|
||||
0x0000 Identifier (12b)
|
||||
"PCM86 DATA(\n)(\0)"
|
||||
0x000C Targeted P86DRV version (1b)
|
||||
version <high nibble>.<low nibble>
|
||||
0x000D File Length (3b)
|
||||
0x0010 - 0x060F 256 * {
|
||||
|
||||
Pointer to Sample Data Start (3b)
|
||||
Length of Sample Data (3b)
|
||||
|
||||
(0x000000 0x000000 -> no sample for this instrument ID)
|
||||
|
||||
}
|
||||
|
||||
|
||||
=======================================
|
||||
Body
|
||||
=======================================
|
||||
|
||||
Stream of Sample Data {
|
||||
|
||||
8-Bit Signed
|
||||
Mono
|
||||
16540Hz
|
||||
(above sample rate according to KAJA's documentation
|
||||
any sample rate possible, for different base note & octave)
|
||||
|
||||
} */
|
||||
|
||||
#define P86_BANK_SIZE 256
|
||||
#define P86_SAMPLE_RATE 16540
|
||||
|
||||
#define P86_FILE_SIG "PCM86 DATA\n\0"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t start_pointer;
|
||||
uint32_t sample_length;
|
||||
} P86_HEADER;
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
uint32_t read_3bytes(SafeReader& reader)
|
||||
{
|
||||
unsigned char arr[3];
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
arr[i] = (unsigned char)reader.readC();
|
||||
}
|
||||
|
||||
return (arr[0] | (arr[1] << 8) | (arr[2] << 16));
|
||||
}
|
||||
|
||||
void DivEngine::loadP86(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.seek(0, SEEK_SET);
|
||||
|
||||
P86_HEADER headers[P86_BANK_SIZE];
|
||||
|
||||
String file_sig = reader.readString(12);
|
||||
if(file_sig != P86_FILE_SIG) return;
|
||||
|
||||
uint8_t version = reader.readC();
|
||||
UNUSED(version);
|
||||
|
||||
uint32_t file_size = read_3bytes(reader);
|
||||
UNUSED(file_size);
|
||||
|
||||
for(int i = 0; i < P86_BANK_SIZE; i++)
|
||||
{
|
||||
headers[i].start_pointer = read_3bytes(reader);
|
||||
headers[i].sample_length = read_3bytes(reader);
|
||||
}
|
||||
|
||||
for(int i = 0; i < P86_BANK_SIZE; i++)
|
||||
{
|
||||
if(headers[i].start_pointer != 0 && headers[i].sample_length != 0)
|
||||
{
|
||||
DivSample* s = new DivSample;
|
||||
|
||||
s->rate = P86_SAMPLE_RATE;
|
||||
s->centerRate = P86_SAMPLE_RATE;
|
||||
s->depth = DIV_SAMPLE_DEPTH_8BIT;
|
||||
s->init(headers[i].sample_length); //byte per sample
|
||||
|
||||
reader.seek((int)headers[i].start_pointer, SEEK_SET);
|
||||
|
||||
int sample_pos = 0;
|
||||
|
||||
for(uint32_t j = 0; j < headers[i].sample_length; j++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
//curr_byte += 0x80;
|
||||
|
||||
s->data8[sample_pos] = curr_byte;
|
||||
sample_pos++;
|
||||
}
|
||||
|
||||
ret.push_back(s);
|
||||
|
||||
logI("p86: start %06X len %06X", headers[i].start_pointer, headers[i].sample_length);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfFileException& e)
|
||||
{
|
||||
lastError=_("premature end of file");
|
||||
logE("premature end of file");
|
||||
}
|
||||
}
|
||||
101
src/engine/fileOps/pdx.cpp
Normal file
101
src/engine/fileOps/pdx.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
//PDX 8-bit OKI ADPCM sample bank
|
||||
|
||||
/* File format
|
||||
The file starts with a header with 96 8-byte pairs, with each pair containing offset and length of ADPCM data chunks for each note value, like so:
|
||||
|
||||
[[byte pointer to sample in file -- 32-bit unsigned integer (4 bytes)] [empty: $0000 -- 16-bit integer] [length of sample, amount in bytes -- 16-bit unsigned integer] ×96] [ADPCM data] EOF
|
||||
|
||||
The first sample (1) is mapped to 0x80 (= the lowest note within MXDRV) and the last sample (96) is mapped to 0xDF (= the highest note within MXDRV).
|
||||
|
||||
|
||||
Samples are encoded in 4-bit OKI ADPCM encoded nibbles, where each byte contains 2 nibbles: [nibble 2 << 4 || nibble 1]
|
||||
|
||||
|
||||
Unfortunately, sample rates for each samples are not defined within the .PDX file and have to be set manually with the appropriate command for that at play-time */
|
||||
|
||||
#define PDX_BANK_SIZE 96
|
||||
#define PDX_SAMPLE_RATE 16000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int start_pointer;
|
||||
unsigned short sample_length;
|
||||
} PDX_HEADER;
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
void DivEngine::loadPDX(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.seek(0, SEEK_SET);
|
||||
|
||||
PDX_HEADER headers[PDX_BANK_SIZE];
|
||||
|
||||
for(int i = 0; i < PDX_BANK_SIZE; i++)
|
||||
{
|
||||
headers[i].start_pointer = (unsigned int)reader.readI_BE();
|
||||
unsigned short empty = (unsigned short)reader.readS_BE(); //skip 1st 2 bytes
|
||||
UNUSED(empty);
|
||||
headers[i].sample_length = (unsigned short)reader.readS_BE();
|
||||
}
|
||||
|
||||
for(int i = 0; i < PDX_BANK_SIZE; i++)
|
||||
{
|
||||
if(headers[i].start_pointer != 0 && headers[i].sample_length != 0)
|
||||
{
|
||||
DivSample* s = new DivSample;
|
||||
|
||||
s->rate = PDX_SAMPLE_RATE;
|
||||
s->centerRate = PDX_SAMPLE_RATE;
|
||||
s->depth = DIV_SAMPLE_DEPTH_VOX;
|
||||
s->init(headers[i].sample_length * 2);
|
||||
|
||||
reader.seek((int)headers[i].start_pointer, SEEK_SET);
|
||||
|
||||
int sample_pos = 0;
|
||||
|
||||
for(unsigned short j = 0; j < headers[i].sample_length; j++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
curr_byte = (curr_byte << 4) | (curr_byte >> 4);
|
||||
|
||||
s->dataVOX[sample_pos] = curr_byte;
|
||||
sample_pos++;
|
||||
}
|
||||
|
||||
ret.push_back(s);
|
||||
|
||||
logI("pdx: start %d len %d", headers[i].start_pointer, headers[i].sample_length);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfFileException& e)
|
||||
{
|
||||
lastError=_("premature end of file");
|
||||
logE("premature end of file");
|
||||
}
|
||||
}
|
||||
142
src/engine/fileOps/ppc.cpp
Normal file
142
src/engine/fileOps/ppc.cpp
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
//PPC PMD's YM2608 ADPCM-B sample bank
|
||||
|
||||
/* ========================================
|
||||
General
|
||||
========================================
|
||||
|
||||
ADPCM RAM addresses: see docs/common.txt {
|
||||
|
||||
address_start = 0x0026
|
||||
file_header_size = 0x0420
|
||||
|
||||
}
|
||||
|
||||
|
||||
========================================
|
||||
Header
|
||||
========================================
|
||||
|
||||
0x0000 Identifier (30b)
|
||||
"ADPCM DATA for PMD ver.4.4- "
|
||||
0x001E Address of End of Data (32B blocks) in ADPCM RAM (1h)
|
||||
File Size == address -> file offset
|
||||
|
||||
0x0020 - 0x041F 256 * {
|
||||
|
||||
Start of Sample (32b blocks) in ADPCM RAM (1h)
|
||||
End of Sample (32b blocks) in ADPCM RAM (1h)
|
||||
|
||||
(0x0000 0x0000 -> no sample for this instrument ID)
|
||||
|
||||
}
|
||||
|
||||
|
||||
========================================
|
||||
Body
|
||||
========================================
|
||||
|
||||
Stream of Sample Data {
|
||||
|
||||
Yamaha ADPCM-B encoding (4-Bit Signed ADPCM)
|
||||
Mono
|
||||
16kHz
|
||||
(above sample rate according to KAJA's documentation
|
||||
any sample rate possible, for different base note & octave)
|
||||
|
||||
} */
|
||||
|
||||
#define PPC_FILE_SIG "ADPCM DATA for PMD ver.4.4- "
|
||||
|
||||
#define PPC_BANK_SIZE 256
|
||||
#define PPC_SAMPLE_RATE 16000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_pointer;
|
||||
uint16_t end_pointer;
|
||||
} PPC_HEADER;
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#define ADPCM_DATA_START 0x0420
|
||||
|
||||
void DivEngine::loadPPC(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.seek(0, SEEK_SET);
|
||||
|
||||
String file_sig = reader.readString(30);
|
||||
unsigned short end_of_data = (unsigned short)reader.readS();
|
||||
UNUSED(end_of_data);
|
||||
|
||||
if(file_sig != PPC_FILE_SIG) return;
|
||||
|
||||
PPC_HEADER headers[PPC_BANK_SIZE];
|
||||
|
||||
for(int i = 0; i < PPC_BANK_SIZE; i++)
|
||||
{
|
||||
headers[i].start_pointer = (unsigned short)reader.readS();
|
||||
headers[i].end_pointer = (unsigned short)reader.readS();
|
||||
}
|
||||
|
||||
for(int i = 0; i < PPC_BANK_SIZE; i++)
|
||||
{
|
||||
if((headers[i].start_pointer != 0 || headers[i].end_pointer != 0) && headers[i].start_pointer < headers[i].end_pointer)
|
||||
{
|
||||
DivSample* s = new DivSample;
|
||||
|
||||
s->rate = PPC_SAMPLE_RATE;
|
||||
s->centerRate = PPC_SAMPLE_RATE;
|
||||
s->depth = DIV_SAMPLE_DEPTH_ADPCM_B;
|
||||
s->init((headers[i].end_pointer - headers[i].start_pointer) * 32 * 2);
|
||||
|
||||
int sample_pos = 0;
|
||||
int sample_length = (headers[i].end_pointer - headers[i].start_pointer) * 32;
|
||||
|
||||
//reader.seek(ADPCM_DATA_START + headers[i].start_pointer * 32, SEEK_SET);
|
||||
|
||||
for(int j = 0; j < sample_length; j++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
//curr_byte=(curr_byte<<4)|(curr_byte>>4);
|
||||
|
||||
s->dataB[sample_pos] = curr_byte;
|
||||
sample_pos++;
|
||||
}
|
||||
|
||||
logI("ppc: start %d end %d len in bytes %d", headers[i].start_pointer, headers[i].end_pointer, (headers[i].end_pointer - headers[i].start_pointer) * 32);
|
||||
|
||||
ret.push_back(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfFileException& e)
|
||||
{
|
||||
lastError=_("premature end of file");
|
||||
logE("premature end of file");
|
||||
}
|
||||
}
|
||||
125
src/engine/fileOps/pps.cpp
Normal file
125
src/engine/fileOps/pps.cpp
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
//PPS AY-3-8910 sample bank
|
||||
|
||||
/* =======================================
|
||||
Header
|
||||
=======================================
|
||||
|
||||
0x0000 - 0x0053 14 * {
|
||||
|
||||
Pointer to Sample Data Start (1h)
|
||||
Length of Sample Data (1h)
|
||||
"Pitch"(?) (1b)
|
||||
Volume Reduction (1b)
|
||||
|
||||
}
|
||||
|
||||
(0x0000 0x0000 [0x00 0x00] -> no sample for this instrument ID)
|
||||
|
||||
}
|
||||
|
||||
|
||||
=======================================
|
||||
Body
|
||||
=======================================
|
||||
|
||||
Stream of Sample Data {
|
||||
|
||||
4-Bit Unsigned
|
||||
(afaict)
|
||||
Mono
|
||||
16Hz
|
||||
(based on tests, maybe alternatively 8kHz)
|
||||
|
||||
} */
|
||||
|
||||
#define PPS_BANK_SIZE 14
|
||||
#define PPS_SAMPLE_RATE 16000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_pointer;
|
||||
uint16_t sample_length;
|
||||
uint8_t _pitch;
|
||||
uint8_t _vol;
|
||||
} PPS_HEADER;
|
||||
|
||||
|
||||
void DivEngine::loadPPS(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.seek(0, SEEK_SET);
|
||||
|
||||
PPS_HEADER headers[PPS_BANK_SIZE];
|
||||
|
||||
for(int i = 0; i < PPS_BANK_SIZE; i++)
|
||||
{
|
||||
headers[i].start_pointer = (unsigned short)reader.readS();
|
||||
headers[i].sample_length = (unsigned short)reader.readS();
|
||||
headers[i]._pitch = (unsigned char)reader.readC();
|
||||
headers[i]._vol = (unsigned char)reader.readC();
|
||||
}
|
||||
|
||||
for(int i = 0; i < PPS_BANK_SIZE; i++)
|
||||
{
|
||||
if(headers[i].start_pointer != 0 || headers[i].sample_length != 0
|
||||
|| headers[i]._pitch != 0 || headers[i]._vol != 0)
|
||||
{
|
||||
DivSample* s = new DivSample;
|
||||
|
||||
s->rate = PPS_SAMPLE_RATE;
|
||||
s->centerRate = PPS_SAMPLE_RATE;
|
||||
s->depth = DIV_SAMPLE_DEPTH_8BIT;
|
||||
s->init(headers[i].sample_length * 2); //byte per sample
|
||||
|
||||
reader.seek((int)headers[i].start_pointer, SEEK_SET);
|
||||
|
||||
int sample_pos = 0;
|
||||
|
||||
for(int j = 0; j < headers[i].sample_length; j++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
|
||||
s->data8[sample_pos] = (curr_byte >> 4) | (curr_byte & 0xf0);
|
||||
s->data8[sample_pos] += 0x80;
|
||||
sample_pos++;
|
||||
s->data8[sample_pos] = (curr_byte << 4) | (curr_byte & 0xf);
|
||||
s->data8[sample_pos] += 0x80;
|
||||
sample_pos++;
|
||||
}
|
||||
|
||||
ret.push_back(s);
|
||||
|
||||
logI("pps: start %d len %d", headers[i].start_pointer, headers[i].sample_length);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfFileException& e)
|
||||
{
|
||||
lastError=_("premature end of file");
|
||||
logE("premature end of file");
|
||||
}
|
||||
}
|
||||
158
src/engine/fileOps/pvi.cpp
Normal file
158
src/engine/fileOps/pvi.cpp
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
//PVI YM2608 ADPCM-B sample bank
|
||||
|
||||
/* =======================================
|
||||
General
|
||||
=======================================
|
||||
|
||||
ADPCM RAM addresses: see docs/common.txt {
|
||||
|
||||
address_start = 0x0000
|
||||
file_header_size = 0x0210
|
||||
|
||||
}
|
||||
|
||||
=======================================
|
||||
Header
|
||||
=======================================
|
||||
|
||||
0x0000 Identifier (4b)
|
||||
"PVI2"
|
||||
0x0004 - 0x0007 Unknown Settings (4b)
|
||||
Unknown mappings PCME switches <-> Values
|
||||
"0x10 0x00 0x10 0x02" in all example files
|
||||
First 1h may be Start Address in ADPCM RAM?
|
||||
0x0008 - 0x0009 "Delta-N" playback frequency (1h)
|
||||
Default 0x49BA "== 16kHz"??
|
||||
0x000A Unknown (1b)
|
||||
RAM type? (Docs indicate values 0 or 8, all example files have value 0x02?)
|
||||
0x000B Amount of defined Samples (1b)
|
||||
0x000C - 0x000F Unknown (4b)
|
||||
Padding?
|
||||
"0x00 0x00 0x00 0x00" in all example files
|
||||
0x0010 - 0x020F 128 * {
|
||||
|
||||
Start of Sample (32b blocks) in ADPCM RAM (1h)
|
||||
End of Sample (32b blocks) in ADPCM RAM (1h)
|
||||
|
||||
(0x0000 0x0000 -> no sample for this instrument ID)
|
||||
|
||||
}
|
||||
|
||||
|
||||
=======================================
|
||||
Body
|
||||
=======================================
|
||||
|
||||
Stream of Sample Data {
|
||||
|
||||
Yamaha ADPCM-B encoding (4-Bit Signed ADPCM)
|
||||
Mono
|
||||
Sample rate as specified earlier
|
||||
(examples i have seems Stereo or 32kHz despite "16kHz" playback frequency setting?)
|
||||
|
||||
} */
|
||||
|
||||
#define PVIV2_FILE_SIG "PVI2"
|
||||
#define PVIV1_FILE_SIG "PVI1"
|
||||
|
||||
#define PVI_BANK_SIZE 128
|
||||
#define PVI_SAMPLE_RATE 16000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_pointer;
|
||||
uint16_t end_pointer;
|
||||
} PVI_HEADER;
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#define ADPCM_DATA_START 0x0210
|
||||
|
||||
void DivEngine::loadPVI(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.seek(0, SEEK_SET);
|
||||
|
||||
String file_sig = reader.readString(4);
|
||||
if(file_sig != PVIV1_FILE_SIG && file_sig != PVIV2_FILE_SIG) return;
|
||||
|
||||
unsigned int unknown_settings = (unsigned int)reader.readI();
|
||||
UNUSED(unknown_settings);
|
||||
unsigned short delta_n = (unsigned short)reader.readS();
|
||||
UNUSED(delta_n);
|
||||
unsigned char one_byte = (unsigned char)reader.readC();
|
||||
UNUSED(one_byte);
|
||||
unsigned char amount_of_samples = (unsigned char)reader.readC();
|
||||
UNUSED(amount_of_samples);
|
||||
unsigned int padding = (unsigned int)reader.readI();
|
||||
UNUSED(padding);
|
||||
|
||||
PVI_HEADER headers[PVI_BANK_SIZE];
|
||||
|
||||
for(int i = 0; i < PVI_BANK_SIZE; i++)
|
||||
{
|
||||
headers[i].start_pointer = (unsigned short)reader.readS();
|
||||
headers[i].end_pointer = (unsigned short)reader.readS();
|
||||
}
|
||||
|
||||
for(int i = 0; i < PVI_BANK_SIZE; i++)
|
||||
{
|
||||
if((headers[i].start_pointer != 0 || headers[i].end_pointer != 0) && headers[i].start_pointer < headers[i].end_pointer)
|
||||
{
|
||||
DivSample* s = new DivSample;
|
||||
|
||||
s->rate = PVI_SAMPLE_RATE;
|
||||
s->centerRate = PVI_SAMPLE_RATE;
|
||||
s->depth = DIV_SAMPLE_DEPTH_ADPCM_B;
|
||||
s->init((headers[i].end_pointer - headers[i].start_pointer) * 32 * 2);
|
||||
|
||||
int sample_pos = 0;
|
||||
int sample_length = (headers[i].end_pointer - headers[i].start_pointer) * 32;
|
||||
|
||||
reader.seek(ADPCM_DATA_START + headers[i].start_pointer * 32, SEEK_SET);
|
||||
|
||||
for(int j = 0; j < sample_length; j++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
//curr_byte=(curr_byte<<4)|(curr_byte>>4);
|
||||
|
||||
s->dataB[sample_pos] = curr_byte;
|
||||
sample_pos++;
|
||||
}
|
||||
|
||||
logI("pvi: start %d end %d len in bytes %d", headers[i].start_pointer, headers[i].end_pointer, (headers[i].end_pointer - headers[i].start_pointer) * 32);
|
||||
|
||||
ret.push_back(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfFileException& e)
|
||||
{
|
||||
lastError=_("premature end of file");
|
||||
logE("premature end of file");
|
||||
}
|
||||
}
|
||||
155
src/engine/fileOps/pzi.cpp
Normal file
155
src/engine/fileOps/pzi.cpp
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
//PZI 8-bit PCM sample bank
|
||||
|
||||
/* =======================================
|
||||
Header
|
||||
=======================================
|
||||
|
||||
0x0000 Identifier (4b)
|
||||
"PZI1"
|
||||
0x0004 - 0x001F Unknown (28b)
|
||||
Part of identifier? Settings?
|
||||
All (\0)s in all example files
|
||||
0x0020 - 0x091F 128 * {
|
||||
|
||||
Start of Sample after header (2h)
|
||||
Length of Sample (2h)
|
||||
Offset of loop start from sample start (2h)
|
||||
Offset of loop end from sample start (2h)
|
||||
Sample rate (1h)
|
||||
|
||||
(0xFFFFFFFF 0xFFFFFFFF loop offsets -> no loop information)
|
||||
|
||||
}
|
||||
|
||||
|
||||
=======================================
|
||||
Body
|
||||
=======================================
|
||||
|
||||
Stream of Sample Data {
|
||||
|
||||
Unsigned 8-Bit
|
||||
Mono
|
||||
Sample rate as specified in header
|
||||
|
||||
} */
|
||||
|
||||
#define PZI_BANK_SIZE 128
|
||||
|
||||
#define PZI_FILE_SIG "PZI1"
|
||||
|
||||
#define NO_LOOP (0xFFFFFFFFU)
|
||||
|
||||
#define SAMPLE_DATA_OFFSET 0x0920
|
||||
|
||||
#define MAX_SANITY_CAP 9999999
|
||||
|
||||
#define HEADER_JUNK_SIZE 28
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t start_pointer;
|
||||
uint32_t sample_length;
|
||||
uint32_t loop_start;
|
||||
uint32_t loop_end;
|
||||
uint16_t sample_rate;
|
||||
} PZI_HEADER;
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
void DivEngine::loadPZI(SafeReader& reader, std::vector<DivSample*>& ret, String& stripPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
reader.seek(0, SEEK_SET);
|
||||
|
||||
PZI_HEADER headers[PZI_BANK_SIZE];
|
||||
|
||||
String file_sig = reader.readString(4);
|
||||
if(file_sig != PZI_FILE_SIG) return;
|
||||
|
||||
for (int i = 0; i < HEADER_JUNK_SIZE; i++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
UNUSED(curr_byte);
|
||||
}
|
||||
|
||||
for(int i = 0; i < PZI_BANK_SIZE; i++)
|
||||
{
|
||||
headers[i].start_pointer = (unsigned int)reader.readI();
|
||||
headers[i].sample_length = (unsigned int)reader.readI();
|
||||
headers[i].loop_start = (unsigned int)reader.readI();
|
||||
headers[i].loop_end = (unsigned int)reader.readI();
|
||||
headers[i].sample_rate = (unsigned short)reader.readS();
|
||||
}
|
||||
|
||||
for(int i = 0; i < PZI_BANK_SIZE; i++)
|
||||
{
|
||||
if (headers[i].start_pointer < MAX_SANITY_CAP && headers[i].sample_length < MAX_SANITY_CAP &&
|
||||
headers[i].loop_start < MAX_SANITY_CAP && headers[i].loop_end < MAX_SANITY_CAP &&
|
||||
headers[i].start_pointer > 0 && headers[i].sample_length > 0)
|
||||
{
|
||||
DivSample* s = new DivSample;
|
||||
|
||||
s->rate = headers[i].sample_rate;
|
||||
s->centerRate = headers[i].sample_rate;
|
||||
s->depth = DIV_SAMPLE_DEPTH_8BIT;
|
||||
s->init(headers[i].sample_length); //byte per sample
|
||||
|
||||
reader.seek((int)headers[i].start_pointer + SAMPLE_DATA_OFFSET, SEEK_SET);
|
||||
|
||||
int sample_pos = 0;
|
||||
|
||||
for (uint32_t j = 0; j < headers[i].sample_length; j++)
|
||||
{
|
||||
unsigned char curr_byte = (unsigned char)reader.readC();
|
||||
curr_byte += 0x80;
|
||||
|
||||
s->data8[sample_pos] = curr_byte;
|
||||
sample_pos++;
|
||||
}
|
||||
|
||||
if (headers[i].loop_start != NO_LOOP && headers[i].loop_end != NO_LOOP)
|
||||
{
|
||||
s->loop = true;
|
||||
s->loopMode = DIV_SAMPLE_LOOP_FORWARD;
|
||||
s->loopStart = headers[i].loop_start;
|
||||
s->loopEnd = headers[i].loop_end;
|
||||
}
|
||||
|
||||
ret.push_back(s);
|
||||
|
||||
logI("pzi: start %d len %d sample rate %d loop start %d loop end %d", headers[i].start_pointer, headers[i].sample_length,
|
||||
headers[i].sample_rate, headers[i].loop_start, headers[i].loop_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfFileException& e)
|
||||
{
|
||||
lastError=_("premature end of file");
|
||||
logE("premature end of file");
|
||||
}
|
||||
}
|
||||
|
|
@ -19,21 +19,6 @@
|
|||
|
||||
#include "fileOpsCommon.h"
|
||||
|
||||
// SBI and some other OPL containers
|
||||
struct sbi_t {
|
||||
uint8_t Mcharacteristics,
|
||||
Ccharacteristics,
|
||||
Mscaling_output,
|
||||
Cscaling_output,
|
||||
Meg_AD,
|
||||
Ceg_AD,
|
||||
Meg_SR,
|
||||
Ceg_SR,
|
||||
Mwave,
|
||||
Cwave,
|
||||
FeedConnect;
|
||||
};
|
||||
|
||||
static void readSbiOpData(sbi_t& sbi, SafeReader& reader) {
|
||||
sbi.Mcharacteristics = reader.readC();
|
||||
sbi.Ccharacteristics = reader.readC();
|
||||
|
|
@ -51,6 +36,7 @@ static void readSbiOpData(sbi_t& sbi, SafeReader& reader) {
|
|||
bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
||||
struct InvalidHeaderException {};
|
||||
bool success=false;
|
||||
bool opl2=!getConfInt("s3mOPL3",0);
|
||||
char magic[4]={0,0,0,0};
|
||||
SafeReader reader=SafeReader(file,len);
|
||||
warnings="";
|
||||
|
|
@ -273,11 +259,16 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
bool hasPCM=false;
|
||||
bool hasFM=false;
|
||||
int numChans=0;
|
||||
int realNumChans=0;
|
||||
|
||||
for (int i=0; i<32; i++) {
|
||||
if (chanSettings[i]==255) continue;
|
||||
if ((chanSettings[i]&127)>=32) continue;
|
||||
if ((chanSettings[i]&127)>=16) {
|
||||
for (int ch=0; ch<32; ch++) {
|
||||
if (chanSettings[ch]!=255) realNumChans++;
|
||||
}
|
||||
|
||||
for (int ch=0; ch<32; ch++) {
|
||||
if (chanSettings[ch]==255) continue;
|
||||
if ((chanSettings[ch]&127)>=32) continue;
|
||||
if ((chanSettings[ch]&127)>=16) {
|
||||
hasFM=true;
|
||||
} else {
|
||||
hasPCM=true;
|
||||
|
|
@ -287,34 +278,69 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
if (hasFM && hasPCM) break;
|
||||
}
|
||||
|
||||
int pcmChan=hasFM?9:0;
|
||||
int pcmChan=hasFM?(opl2 ? 9 : 18):0;
|
||||
int fmChan=hasPCM?32:0;
|
||||
int invalidChan=40;
|
||||
|
||||
for (int i=0; i<32; i++) {
|
||||
if (chanSettings[i]==255) {
|
||||
chanMap[i]=invalidChan++;
|
||||
for (int ch=0; ch<32; ch++) {
|
||||
if (chanSettings[ch]==255) {
|
||||
chanMap[ch]=invalidChan++;
|
||||
continue;
|
||||
}
|
||||
if ((chanSettings[i]&127)>=32) {
|
||||
chanMap[i]=invalidChan++;
|
||||
if ((chanSettings[ch]&127)>=32) {
|
||||
chanMap[ch]=invalidChan++;
|
||||
continue;
|
||||
}
|
||||
if ((chanSettings[i]&127)>=16) {
|
||||
chanMap[i]=fmChan++;
|
||||
if ((chanSettings[ch]&127)>=16) {
|
||||
chanMap[ch]=fmChan++;
|
||||
} else {
|
||||
chanMap[i]=pcmChan++;
|
||||
chanMap[ch]=pcmChan++;
|
||||
}
|
||||
}
|
||||
|
||||
char buffer[40];
|
||||
int chanIndex = 1;
|
||||
|
||||
if (hasPCM) {
|
||||
for (int i=pcmChan; i<32; i++) {
|
||||
ds.subsong[0]->chanShow[i]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[i]=false;
|
||||
for(int ch = 0; ch < pcmChan - (realNumChans - (hasFM ? 9 : 0)); ch++)
|
||||
{
|
||||
ds.subsong[0]->chanShow[ch]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||
}
|
||||
|
||||
for (int ch=pcmChan; ch<32; ch++) {
|
||||
ds.subsong[0]->chanShow[ch]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||
}
|
||||
|
||||
for(int ch = 0; ch < 32; ch++)
|
||||
{
|
||||
if(ds.subsong[0]->chanShow[ch])
|
||||
{
|
||||
snprintf(buffer, 40, _("Channel %d"), chanIndex);
|
||||
ds.subsong[0]->chanName[ch] = buffer;
|
||||
chanIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasFM && !opl2) {
|
||||
for (int ch=(hasPCM?32:0) + 9; ch<(hasPCM?32:0) + 18; ch++) {
|
||||
ds.subsong[0]->chanShow[ch]=false;
|
||||
ds.subsong[0]->chanShowChanOsc[ch]=false;
|
||||
}
|
||||
|
||||
chanIndex = 1;
|
||||
|
||||
for (int ch=(hasPCM?32:0); ch<(hasPCM?32:0) + 9; ch++) {
|
||||
snprintf(buffer, 40, _("FM %d"), chanIndex);
|
||||
ds.subsong[0]->chanName[ch] = buffer;
|
||||
chanIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
logV("numChans: %d",numChans);
|
||||
logV("realNumChans: %d",realNumChans);
|
||||
|
||||
ds.systemName="PC";
|
||||
if (hasPCM) {
|
||||
|
|
@ -327,7 +353,7 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) {
|
|||
ds.systemLen++;
|
||||
}
|
||||
if (hasFM) {
|
||||
ds.system[ds.systemLen]=DIV_SYSTEM_OPL2;
|
||||
ds.system[ds.systemLen]=opl2 ? DIV_SYSTEM_OPL2 : DIV_SYSTEM_OPL3;
|
||||
ds.systemVol[ds.systemLen]=1.0f;
|
||||
ds.systemPan[ds.systemLen]=0;
|
||||
ds.systemLen++;
|
||||
|
|
|
|||
|
|
@ -24,10 +24,12 @@
|
|||
#include "sfWrapper.h"
|
||||
#endif
|
||||
|
||||
DivSample* DivEngine::sampleFromFile(const char* path) {
|
||||
std::vector<DivSample*> DivEngine::sampleFromFile(const char* path) {
|
||||
std::vector<DivSample*> ret;
|
||||
|
||||
if (song.sample.size()>=256) {
|
||||
lastError="too many samples!";
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
BUSY_BEGIN;
|
||||
warnings="";
|
||||
|
|
@ -58,6 +60,110 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
}
|
||||
extS+=i;
|
||||
}
|
||||
|
||||
if(extS == ".pps" || extS == ".ppc" || extS == ".pvi" ||
|
||||
extS == ".pdx" || extS == ".pzi" || extS == ".p86" ||
|
||||
extS == ".p") //sample banks!
|
||||
{
|
||||
String stripPath;
|
||||
const char* pathReduxEnd=strrchr(pathRedux,'.');
|
||||
if (pathReduxEnd==NULL) {
|
||||
stripPath=pathRedux;
|
||||
} else {
|
||||
for (const char* i=pathRedux; i!=pathReduxEnd && (*i); i++) {
|
||||
stripPath+=*i;
|
||||
}
|
||||
}
|
||||
|
||||
FILE* f=ps_fopen(path,"rb");
|
||||
if (f==NULL) {
|
||||
lastError=strerror(errno);
|
||||
return ret;
|
||||
}
|
||||
unsigned char* buf;
|
||||
ssize_t len;
|
||||
if (fseek(f,0,SEEK_END)!=0) {
|
||||
lastError=strerror(errno);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
len=ftell(f);
|
||||
if (len<0) {
|
||||
lastError=strerror(errno);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
if (len==(SIZE_MAX>>1)) {
|
||||
lastError=strerror(errno);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
if (len==0) {
|
||||
lastError=strerror(errno);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
if (fseek(f,0,SEEK_SET)!=0) {
|
||||
lastError=strerror(errno);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
buf=new unsigned char[len];
|
||||
if (fread(buf,1,len,f)!=(size_t)len) {
|
||||
logW("did not read entire sample bank file buffer!");
|
||||
lastError=_("did not read entire sample bank file!");
|
||||
delete[] buf;
|
||||
return ret;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
SafeReader reader = SafeReader(buf,len);
|
||||
|
||||
if(extS == ".pps")
|
||||
{
|
||||
loadPPS(reader,ret,stripPath);
|
||||
}
|
||||
if(extS == ".ppc")
|
||||
{
|
||||
loadPPC(reader,ret,stripPath);
|
||||
}
|
||||
if(extS == ".pvi")
|
||||
{
|
||||
loadPVI(reader,ret,stripPath);
|
||||
}
|
||||
if(extS == ".pdx")
|
||||
{
|
||||
loadPDX(reader,ret,stripPath);
|
||||
}
|
||||
if(extS == ".pzi")
|
||||
{
|
||||
loadPZI(reader,ret,stripPath);
|
||||
}
|
||||
if(extS == ".p86")
|
||||
{
|
||||
loadP86(reader,ret,stripPath);
|
||||
}
|
||||
if(extS == ".p")
|
||||
{
|
||||
loadP(reader,ret,stripPath);
|
||||
}
|
||||
|
||||
if((int)ret.size() > 0)
|
||||
{
|
||||
int counter = 0;
|
||||
|
||||
for(DivSample* s: ret)
|
||||
{
|
||||
s->name = fmt::sprintf("%s sample %d", stripPath, counter);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] buf; //done with buffer
|
||||
BUSY_END;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (extS==".dmc" || extS==".brr") { // read as .dmc or .brr
|
||||
size_t len=0;
|
||||
DivSample* sample=new DivSample;
|
||||
|
|
@ -68,7 +174,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError=fmt::sprintf("could not open file! (%s)",strerror(errno));
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (fseek(f,0,SEEK_END)<0) {
|
||||
|
|
@ -76,7 +182,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError=fmt::sprintf("could not get file length! (%s)",strerror(errno));
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
len=ftell(f);
|
||||
|
|
@ -86,7 +192,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError="file is empty!";
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (len==(SIZE_MAX>>1)) {
|
||||
|
|
@ -94,7 +200,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError="file is invalid!";
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (fseek(f,0,SEEK_SET)<0) {
|
||||
|
|
@ -102,7 +208,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError=fmt::sprintf("could not seek to beginning of file! (%s)",strerror(errno));
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (extS==".dmc") {
|
||||
|
|
@ -120,7 +226,7 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError="wait... is that right? no I don't think so...";
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned char* dataBuf=sample->dataDPCM;
|
||||
|
|
@ -147,14 +253,14 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError="BRR sample is empty!";
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
} else if ((len%9)!=0) {
|
||||
fclose(f);
|
||||
BUSY_END;
|
||||
lastError="possibly corrupt BRR sample!";
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,16 +269,17 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
BUSY_END;
|
||||
lastError=fmt::sprintf("could not read file! (%s)",strerror(errno));
|
||||
delete sample;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
BUSY_END;
|
||||
return sample;
|
||||
ret.push_back(sample);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_SNDFILE
|
||||
lastError="Furnace was not compiled with libsndfile!";
|
||||
return NULL;
|
||||
return ret;
|
||||
#else
|
||||
SF_INFO si;
|
||||
SFWrapper sfWrap;
|
||||
|
|
@ -186,13 +293,13 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
} else {
|
||||
lastError=fmt::sprintf("could not open file! (%s)\nif this is raw sample data, you may import it by right-clicking the Load Sample icon and selecting \"import raw\".",sf_error_number(err));
|
||||
}
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
if (si.frames>16777215) {
|
||||
lastError="this sample is too big! max sample size is 16777215.";
|
||||
sfWrap.doClose();
|
||||
BUSY_END;
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
void* buf=NULL;
|
||||
sf_count_t sampleLen=sizeof(short);
|
||||
|
|
@ -294,11 +401,12 @@ DivSample* DivEngine::sampleFromFile(const char* path) {
|
|||
sample->loop=false;
|
||||
}
|
||||
|
||||
if (sample->centerRate<4000) sample->centerRate=4000;
|
||||
if (sample->centerRate>64000) sample->centerRate=64000;
|
||||
if (sample->centerRate<100) sample->centerRate=100;
|
||||
if (sample->centerRate>384000) sample->centerRate=384000;
|
||||
sfWrap.doClose();
|
||||
BUSY_END;
|
||||
return sample;
|
||||
ret.push_back(sample);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -363,6 +363,141 @@ void DivInstrument::writeFeatureFM(SafeWriter* w, bool fui) {
|
|||
FEATURE_END;
|
||||
}
|
||||
|
||||
bool MemPatch::calcDiff(const void* pre, const void* post, size_t inputSize) {
|
||||
bool diffValid=false;
|
||||
size_t firstDiff=0;
|
||||
size_t lastDiff=0;
|
||||
const unsigned char* preBytes=(const unsigned char*)pre;
|
||||
const unsigned char* postBytes=(const unsigned char*)post;
|
||||
|
||||
// @NOTE: consider/profile using a memcmp==0 check to early-out, if it's potentially faster
|
||||
// for the common case, which is no change
|
||||
for (size_t ii=0; ii<inputSize; ++ii) {
|
||||
if (preBytes[ii] != postBytes[ii]) {
|
||||
lastDiff=ii;
|
||||
firstDiff=diffValid ? firstDiff : ii;
|
||||
diffValid=true;
|
||||
}
|
||||
}
|
||||
|
||||
if (diffValid) {
|
||||
offset=firstDiff;
|
||||
size=lastDiff - firstDiff + 1;
|
||||
data=new unsigned char[size];
|
||||
|
||||
// the diff is to make pre into post (MemPatch is general, not specific to
|
||||
// undo), so copy from postBytes
|
||||
memcpy(data, postBytes+offset, size);
|
||||
}
|
||||
|
||||
return diffValid;
|
||||
}
|
||||
|
||||
void MemPatch::applyAndReverse(void* target, size_t targetSize) {
|
||||
if (size==0) return;
|
||||
if (offset+size>targetSize) {
|
||||
logW("MemPatch (offset %d, size %d) exceeds target size (%d), can't apply!",offset,size,targetSize);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char* targetBytes=(unsigned char*)target;
|
||||
|
||||
// swap this->data and its segment on target
|
||||
for (size_t ii=0; ii<size; ++ii) {
|
||||
unsigned char tmp=targetBytes[offset+ii];
|
||||
targetBytes[offset+ii] = data[ii];
|
||||
data[ii] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void DivInstrumentUndoStep::applyAndReverse(DivInstrument* target) {
|
||||
if (nameValid) {
|
||||
name.swap(target->name);
|
||||
}
|
||||
podPatch.applyAndReverse((DivInstrumentPOD*)target, sizeof(DivInstrumentPOD));
|
||||
}
|
||||
|
||||
bool DivInstrumentUndoStep::makeUndoPatch(size_t processTime_, const DivInstrument* pre, const DivInstrument* post) {
|
||||
processTime=processTime_;
|
||||
|
||||
// create the patch that will make post into pre
|
||||
podPatch.calcDiff((const DivInstrumentPOD*)post, (const DivInstrumentPOD*)pre, sizeof(DivInstrumentPOD));
|
||||
if (pre->name!=post->name) {
|
||||
nameValid=true;
|
||||
name=pre->name;
|
||||
}
|
||||
|
||||
return nameValid || podPatch.isValid();
|
||||
}
|
||||
|
||||
bool DivInstrument::recordUndoStepIfChanged(size_t processTime, const DivInstrument* old) {
|
||||
DivInstrumentUndoStep step;
|
||||
|
||||
// generate a patch to go back to old
|
||||
if (step.makeUndoPatch(processTime, old, this)) {
|
||||
|
||||
// make room
|
||||
if (undoHist.size()>=undoHist.capacity()) {
|
||||
delete undoHist.front();
|
||||
undoHist.pop_front();
|
||||
}
|
||||
|
||||
// clear redo
|
||||
while (!redoHist.empty()) {
|
||||
delete redoHist.back();
|
||||
redoHist.pop_back();
|
||||
}
|
||||
|
||||
DivInstrumentUndoStep* stepPtr=new DivInstrumentUndoStep;
|
||||
*stepPtr=step;
|
||||
step.podPatch.data=NULL; // don't let it delete the data ptr that's been copied!
|
||||
undoHist.push_back(stepPtr);
|
||||
|
||||
// logI("DivInstrument::undoHist push (%u off, %u size)", stepPtr->podPatch.offset, stepPtr->podPatch.size);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int DivInstrument::undo() {
|
||||
if (undoHist.empty()) return 0;
|
||||
|
||||
DivInstrumentUndoStep* step=undoHist.back();
|
||||
undoHist.pop_back();
|
||||
// logI("DivInstrument::undo (%u off, %u size)", step->podPatch.offset, step->podPatch.size);
|
||||
step->applyAndReverse(this);
|
||||
|
||||
// make room
|
||||
if (redoHist.size()>=redoHist.capacity()) {
|
||||
DivInstrumentUndoStep* step=redoHist.front();
|
||||
delete step;
|
||||
redoHist.pop_front();
|
||||
}
|
||||
redoHist.push_back(step);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DivInstrument::redo() {
|
||||
if (redoHist.empty()) return 0;
|
||||
|
||||
DivInstrumentUndoStep* step = redoHist.back();
|
||||
redoHist.pop_back();
|
||||
// logI("DivInstrument::redo (%u off, %u size)", step->podPatch.offset, step->podPatch.size);
|
||||
step->applyAndReverse(this);
|
||||
|
||||
// make room
|
||||
if (undoHist.size()>=undoHist.capacity()) {
|
||||
DivInstrumentUndoStep* step=undoHist.front();
|
||||
delete step;
|
||||
undoHist.pop_front();
|
||||
}
|
||||
undoHist.push_back(step);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void DivInstrument::writeMacro(SafeWriter* w, const DivInstrumentMacro& m) {
|
||||
if (!m.len) return;
|
||||
|
||||
|
|
@ -3333,3 +3468,28 @@ bool DivInstrument::saveDMP(const char* path) {
|
|||
w->finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
DivInstrument::~DivInstrument() {
|
||||
// free undoHist/redoHist
|
||||
while (!undoHist.empty()) {
|
||||
delete undoHist.back();
|
||||
undoHist.pop_back();
|
||||
}
|
||||
while (!redoHist.empty()) {
|
||||
delete redoHist.back();
|
||||
redoHist.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
DivInstrument::DivInstrument( const DivInstrument& ins ) {
|
||||
// undo/redo history is specifically not copied
|
||||
*(DivInstrumentPOD*)this=ins;
|
||||
name=ins.name;
|
||||
}
|
||||
|
||||
DivInstrument& DivInstrument::operator=( const DivInstrument& ins ) {
|
||||
// undo/redo history is specifically not copied
|
||||
*(DivInstrumentPOD*)this=ins;
|
||||
name=ins.name;
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -23,8 +23,10 @@
|
|||
#include "dataErrors.h"
|
||||
#include "../ta-utils.h"
|
||||
#include "../pch.h"
|
||||
#include "../fixedQueue.h"
|
||||
|
||||
struct DivSong;
|
||||
struct DivInstrument;
|
||||
|
||||
// NOTICE!
|
||||
// before adding new instrument types to this struct, please ask me first.
|
||||
|
|
@ -862,8 +864,7 @@ struct DivInstrumentSID2 {
|
|||
noiseMode(0) {}
|
||||
};
|
||||
|
||||
struct DivInstrument {
|
||||
String name;
|
||||
struct DivInstrumentPOD {
|
||||
DivInstrumentType type;
|
||||
DivInstrumentFM fm;
|
||||
DivInstrumentSTD std;
|
||||
|
|
@ -882,6 +883,77 @@ struct DivInstrument {
|
|||
DivInstrumentPowerNoise powernoise;
|
||||
DivInstrumentSID2 sid2;
|
||||
|
||||
DivInstrumentPOD() :
|
||||
type(DIV_INS_FM) {
|
||||
}
|
||||
};
|
||||
|
||||
struct MemPatch {
|
||||
MemPatch() :
|
||||
data(NULL)
|
||||
, offset(0)
|
||||
, size(0) {
|
||||
}
|
||||
|
||||
~MemPatch() {
|
||||
if (data) {
|
||||
delete[] data;
|
||||
data=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool calcDiff(const void* pre, const void* post, size_t size);
|
||||
void applyAndReverse(void* target, size_t inputSize);
|
||||
bool isValid() const { return size>0; }
|
||||
|
||||
unsigned char* data;
|
||||
size_t offset;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct DivInstrumentUndoStep {
|
||||
DivInstrumentUndoStep() :
|
||||
name(""),
|
||||
nameValid(false),
|
||||
processTime(0) {
|
||||
}
|
||||
|
||||
MemPatch podPatch;
|
||||
String name;
|
||||
bool nameValid;
|
||||
size_t processTime;
|
||||
|
||||
void applyAndReverse(DivInstrument* target);
|
||||
bool makeUndoPatch(size_t processTime_, const DivInstrument* pre, const DivInstrument* post);
|
||||
};
|
||||
|
||||
struct DivInstrument : DivInstrumentPOD {
|
||||
String name;
|
||||
|
||||
DivInstrument() :
|
||||
name("") {
|
||||
// clear and construct DivInstrumentPOD so it doesn't have any garbage in the padding
|
||||
memset((unsigned char*)(DivInstrumentPOD*)this, 0, sizeof(DivInstrumentPOD));
|
||||
new ((DivInstrumentPOD*)this) DivInstrumentPOD;
|
||||
}
|
||||
|
||||
~DivInstrument();
|
||||
|
||||
/**
|
||||
* copy/assignment to specifically avoid leaking or dangling pointers to undo step
|
||||
*/
|
||||
DivInstrument( const DivInstrument& ins );
|
||||
DivInstrument& operator=( const DivInstrument& ins );
|
||||
|
||||
/**
|
||||
* undo stuff
|
||||
*/
|
||||
FixedQueue<DivInstrumentUndoStep*, 128> undoHist;
|
||||
FixedQueue<DivInstrumentUndoStep*, 128> redoHist;
|
||||
bool recordUndoStepIfChanged(size_t processTime, const DivInstrument* old);
|
||||
int undo();
|
||||
int redo();
|
||||
|
||||
/**
|
||||
* these are internal functions.
|
||||
*/
|
||||
|
|
@ -966,9 +1038,5 @@ struct DivInstrument {
|
|||
* @return whether it was successful.
|
||||
*/
|
||||
bool saveDMP(const char* path);
|
||||
DivInstrument():
|
||||
name(""),
|
||||
type(DIV_INS_FM) {
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -761,6 +761,25 @@ int DivPlatformArcade::dispatch(DivCommand c) {
|
|||
immWrite(0x19,0x80|pmDepth);
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_FM_OPMASK:
|
||||
switch (c.value>>4) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
chan[c.chan].opMask&=~(1<<((c.value>>4)-1));
|
||||
if (c.value&15) {
|
||||
chan[c.chan].opMask|=(1<<((c.value>>4)-1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
chan[c.chan].opMask=c.value&15;
|
||||
break;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].opMaskChanged=true;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_FM_HARD_RESET:
|
||||
chan[c.chan].hardReset=c.value;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -113,14 +113,15 @@ const unsigned char dacLogTableAY[256]={
|
|||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15
|
||||
};
|
||||
|
||||
void DivPlatformAY8910::runDAC() {
|
||||
void DivPlatformAY8910::runDAC(int runRate) {
|
||||
if (runRate==0) runRate=dacRate;
|
||||
for (int i=0; i<3; i++) {
|
||||
if (chan[i].active && (chan[i].curPSGMode.val&8) && chan[i].dac.sample!=-1) {
|
||||
chan[i].dac.period+=chan[i].dac.rate;
|
||||
bool end=false;
|
||||
bool changed=false;
|
||||
int prevOut=chan[i].dac.out;
|
||||
while (chan[i].dac.period>dacRate && !end) {
|
||||
while (chan[i].dac.period>runRate && !end) {
|
||||
DivSample* s=parent->getSample(chan[i].dac.sample);
|
||||
if (s->samples<=0 || chan[i].dac.pos<0 || chan[i].dac.pos>=(int)s->samples) {
|
||||
chan[i].dac.sample=-1;
|
||||
|
|
@ -143,7 +144,7 @@ void DivPlatformAY8910::runDAC() {
|
|||
end=true;
|
||||
break;
|
||||
}
|
||||
chan[i].dac.period-=dacRate;
|
||||
chan[i].dac.period-=runRate;
|
||||
}
|
||||
if (changed && !end) {
|
||||
if (!isMuted[i]) {
|
||||
|
|
@ -154,44 +155,79 @@ void DivPlatformAY8910::runDAC() {
|
|||
}
|
||||
}
|
||||
|
||||
void DivPlatformAY8910::runTFX() {
|
||||
if (selCore) return;
|
||||
void DivPlatformAY8910::runTFX(int runRate) {
|
||||
/*
|
||||
developer's note: if you are checking for intellivision
|
||||
make sure to add "&& selCore"
|
||||
because for some reason, the register remap doesn't work
|
||||
when the user uses AtomicSSG core
|
||||
*/
|
||||
float counterRatio=1.0;
|
||||
if (runRate!=0) counterRatio=(double)rate/(double)runRate;
|
||||
int timerPeriod, output;
|
||||
for (int i=0; i<3; i++) {
|
||||
if (chan[i].active && (chan[i].curPSGMode.val&16) && !(chan[i].curPSGMode.val&8) && chan[i].tfx.mode!=-1) {
|
||||
chan[i].tfx.counter += 1;
|
||||
if (chan[i].tfx.mode == -1 && !isMuted[i]) {
|
||||
/*
|
||||
bug: if in the timer FX macro the user enables
|
||||
and then disables PWM while there is no volume macro
|
||||
there is now a random chance that the resulting output
|
||||
is silent or has volume set incorrectly
|
||||
i've tried to implement a fix, but it seems to be
|
||||
ineffective, so...
|
||||
TODO: actually implement a proper fix
|
||||
*/
|
||||
if (intellivision && chan[i].curPSGMode.getEnvelope()) {
|
||||
immWrite(0x08+i,(chan[i].outVol&0xc)<<2);
|
||||
continue;
|
||||
} else {
|
||||
immWrite(0x08+i,(chan[i].outVol&15)|((chan[i].curPSGMode.getEnvelope())<<2));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
chan[i].tfx.counter += counterRatio;
|
||||
if (chan[i].tfx.counter >= chan[i].tfx.period && chan[i].tfx.mode == 0) {
|
||||
chan[i].tfx.counter = 0;
|
||||
chan[i].tfx.counter -= chan[i].tfx.period;
|
||||
chan[i].tfx.out ^= 1;
|
||||
output = MAX(0, ((chan[i].tfx.out) ? (chan[i].outVol&15) : (chan[i].tfx.lowBound-(15-chan[i].outVol))));
|
||||
output &= 15;
|
||||
output = ((chan[i].tfx.out) ? chan[i].outVol : (chan[i].tfx.lowBound-(15-chan[i].outVol)));
|
||||
// TODO: fix this stupid crackling noise that happens
|
||||
// everytime the volume changes
|
||||
output = (output <= 0) ? 0 : output; // underflow
|
||||
output = (output >= 15) ? 15 : output; // overflow
|
||||
output &= 15; // i don't know if i need this but i'm too scared to remove it
|
||||
if (!isMuted[i]) {
|
||||
immWrite(0x08+i,output|(chan[i].curPSGMode.getEnvelope()<<2));
|
||||
if (intellivision && selCore) {
|
||||
immWrite(0x0b+i,(output&0xc)<<2);
|
||||
} else {
|
||||
immWrite(0x08+i,output|(chan[i].curPSGMode.getEnvelope()<<2));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chan[i].tfx.counter >= chan[i].tfx.period && chan[i].tfx.mode == 1) {
|
||||
chan[i].tfx.counter = 0;
|
||||
chan[i].tfx.counter -= chan[i].tfx.period;
|
||||
if (!isMuted[i]) {
|
||||
immWrite(0xd, ayEnvMode);
|
||||
if (intellivision && selCore) {
|
||||
immWrite(0xa, ayEnvMode);
|
||||
} else {
|
||||
immWrite(0xd, ayEnvMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chan[i].tfx.counter >= chan[i].tfx.period && chan[i].tfx.mode == 2) {
|
||||
chan[i].tfx.counter = 0;
|
||||
}
|
||||
if (chan[i].tfx.mode == -1 && !isMuted[i]) {
|
||||
if (intellivision && chan[i].curPSGMode.getEnvelope()) {
|
||||
immWrite(0x08+i,(chan[i].outVol&0xc)<<2);
|
||||
} else {
|
||||
immWrite(0x08+i,(chan[i].outVol&15)|((chan[i].curPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
chan[i].tfx.counter -= chan[i].tfx.period;
|
||||
}
|
||||
}
|
||||
if (chan[i].tfx.num > 0) {
|
||||
timerPeriod = chan[i].freq*chan[i].tfx.den/chan[i].tfx.num;
|
||||
} else {
|
||||
timerPeriod = chan[i].freq*chan[i].tfx.den;
|
||||
}
|
||||
timerPeriod = chan[i].freq*chan[i].tfx.den/chan[i].tfx.num;
|
||||
} else {
|
||||
timerPeriod = chan[i].freq*chan[i].tfx.den;
|
||||
}
|
||||
if (chan[i].tfx.num > 0 && chan[i].tfx.den > 0) chan[i].tfx.period=timerPeriod+chan[i].tfx.offset;
|
||||
// stupid pitch correction because:
|
||||
// YM2149 half-clock and Sunsoft 5B: timers run an octave too high
|
||||
// on AtomicSSG core timers run 2 octaves too high
|
||||
if (clockSel || sunsoft) chan[i].tfx.period = chan[i].tfx.period * 2;
|
||||
if (selCore) chan[i].tfx.period = chan[i].tfx.period * 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,12 +330,9 @@ void DivPlatformAY8910::acquire(short** buf, size_t len) {
|
|||
|
||||
void DivPlatformAY8910::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
|
||||
writes.clear();
|
||||
int rate=(int)(chipClock/sRate);
|
||||
for (size_t i=0; i<len; i++) {
|
||||
for (int h=0; h<rate; h++) {
|
||||
runDAC();
|
||||
runTFX();
|
||||
}
|
||||
runDAC(sRate);
|
||||
runTFX(sRate);
|
||||
while (!writes.empty()) {
|
||||
QueuedWrite& w=writes.front();
|
||||
stream.push_back(DivDelayedWrite(i,w.addr,w.val));
|
||||
|
|
@ -388,12 +421,13 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
|||
if (chan[i].std.phaseReset.had) {
|
||||
if (chan[i].std.phaseReset.val==1) {
|
||||
chan[i].tfx.counter = 0;
|
||||
chan[i].tfx.out = 0;
|
||||
if (chan[i].nextPSGMode.val&8) {
|
||||
if (dumpWrites) addWrite(0xffff0002+(i<<8),0);
|
||||
//if (dumpWrites) addWrite(0xffff0002+(i<<8),0);
|
||||
if (chan[i].dac.sample<0 || chan[i].dac.sample>=parent->song.sampleLen) {
|
||||
if (dumpWrites) {
|
||||
rWrite(0x08+i,0);
|
||||
addWrite(0xffff0000+(i<<8),chan[i].dac.sample);
|
||||
//addWrite(0xffff0000+(i<<8),chan[i].dac.sample);
|
||||
}
|
||||
if (chan[i].dac.setPos) {
|
||||
chan[i].dac.setPos=false;
|
||||
|
|
@ -483,7 +517,7 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
chan[i].dac.rate=((double)rate*((sunsoft||clockSel)?8.0:16.0))/(double)(MAX(1,off*chan[i].freq));
|
||||
if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].dac.rate);
|
||||
//if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].dac.rate);
|
||||
}
|
||||
if (chan[i].freq<0) chan[i].freq=0;
|
||||
if (chan[i].freq>4095) chan[i].freq=4095;
|
||||
|
|
@ -570,12 +604,12 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
}
|
||||
if (chan[c.chan].dac.sample<0 || chan[c.chan].dac.sample>=parent->song.sampleLen) {
|
||||
chan[c.chan].dac.sample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||
//if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) {
|
||||
rWrite(0x08+c.chan,0);
|
||||
addWrite(0xffff0000+(c.chan<<8),chan[c.chan].dac.sample);
|
||||
//addWrite(0xffff0000+(c.chan<<8),chan[c.chan].dac.sample);
|
||||
}
|
||||
}
|
||||
if (chan[c.chan].dac.setPos) {
|
||||
|
|
@ -603,10 +637,10 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
chan[c.chan].dac.sample=12*sampleBank+chan[c.chan].note%12;
|
||||
if (chan[c.chan].dac.sample>=parent->song.sampleLen) {
|
||||
chan[c.chan].dac.sample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||
//if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) addWrite(0xffff0000+(c.chan<<8),chan[c.chan].dac.sample);
|
||||
//if (dumpWrites) addWrite(0xffff0000+(c.chan<<8),chan[c.chan].dac.sample);
|
||||
}
|
||||
if (chan[c.chan].dac.setPos) {
|
||||
chan[c.chan].dac.setPos=false;
|
||||
|
|
@ -617,7 +651,7 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
chan[c.chan].dac.rate=parent->getSample(chan[c.chan].dac.sample)->rate*2048;
|
||||
if (dumpWrites) {
|
||||
rWrite(0x08+c.chan,0);
|
||||
addWrite(0xffff0001+(c.chan<<8),chan[c.chan].dac.rate);
|
||||
//addWrite(0xffff0001+(c.chan<<8),chan[c.chan].dac.rate);
|
||||
}
|
||||
chan[c.chan].dac.furnaceDAC=false;
|
||||
}
|
||||
|
|
@ -652,7 +686,7 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
}
|
||||
case DIV_CMD_NOTE_OFF:
|
||||
chan[c.chan].dac.sample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||
//if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||
chan[c.chan].nextPSGMode.val&=~8;
|
||||
chan[c.chan].keyOff=true;
|
||||
chan[c.chan].active=false;
|
||||
|
|
@ -726,12 +760,10 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
break;
|
||||
}
|
||||
case DIV_CMD_STD_NOISE_MODE:
|
||||
if (c.value&0xf0 && !(chan[c.chan].nextPSGMode.val&8)) {
|
||||
chan[c.chan].nextPSGMode.val|=16;
|
||||
chan[c.chan].tfx.mode = (c.value&3);
|
||||
}
|
||||
if (!(chan[c.chan].nextPSGMode.val&8)) {
|
||||
if (c.value<16) {
|
||||
chan[c.chan].nextPSGMode.val|=16;
|
||||
chan[c.chan].tfx.mode=(((c.value&0xf0)>>4)&3)-1;
|
||||
if ((c.value&15)<16) {
|
||||
chan[c.chan].nextPSGMode.val=(c.value+1)&7;
|
||||
chan[c.chan].nextPSGMode.val|=chan[c.chan].curPSGMode.val&16;
|
||||
if (chan[c.chan].active) {
|
||||
|
|
@ -805,9 +837,16 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
updateOutSel(true);
|
||||
immWrite(14+(c.value?1:0),(c.value?portBVal:portAVal));
|
||||
break;
|
||||
case DIV_CMD_AY_AUTO_PWM:
|
||||
chan[c.chan].tfx.offset=c.value;
|
||||
case DIV_CMD_AY_NOISE_MASK_AND:
|
||||
chan[c.chan].tfx.num=c.value>>4;
|
||||
chan[c.chan].tfx.den=c.value&15;
|
||||
break;
|
||||
case DIV_CMD_AY_AUTO_PWM: {
|
||||
// best way i could find to do signed :/
|
||||
signed char signVal=c.value;
|
||||
chan[c.chan].tfx.offset=signVal;
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_SAMPLE_MODE:
|
||||
if (c.value>0) {
|
||||
chan[c.chan].nextPSGMode.val|=8;
|
||||
|
|
@ -828,7 +867,7 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
case DIV_CMD_SAMPLE_POS:
|
||||
chan[c.chan].dac.pos=c.value;
|
||||
chan[c.chan].dac.setPos=true;
|
||||
if (dumpWrites) addWrite(0xffff0005,chan[c.chan].dac.pos);
|
||||
//if (dumpWrites) addWrite(0xffff0005,chan[c.chan].dac.pos);
|
||||
break;
|
||||
case DIV_CMD_MACRO_OFF:
|
||||
chan[c.chan].std.mask(c.value,true);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ class DivPlatformAY8910: public DivDispatch {
|
|||
} dac;
|
||||
|
||||
struct TFX {
|
||||
int period, counter, offset, den, num, mode, lowBound, out;
|
||||
int period;
|
||||
float counter;
|
||||
int offset, den, num, mode, lowBound, out;
|
||||
TFX():
|
||||
period(0),
|
||||
counter(0),
|
||||
|
|
@ -156,8 +158,8 @@ class DivPlatformAY8910: public DivDispatch {
|
|||
friend void putDispatchChan(void*,int,int);
|
||||
|
||||
public:
|
||||
void runDAC();
|
||||
void runTFX();
|
||||
void runDAC(int runRate=0);
|
||||
void runTFX(int runRate=0);
|
||||
void setExtClockDiv(unsigned int eclk=COLOR_NTSC, unsigned char ediv=8);
|
||||
void acquire(short** buf, size_t len);
|
||||
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ void DivPlatformGB::reset() {
|
|||
immWrite(0x26,0x8f);
|
||||
lastPan=0xff;
|
||||
immWrite(0x25,procMute());
|
||||
immWrite(0x24,0x77);
|
||||
immWrite(0x24,0xff);
|
||||
|
||||
antiClickPeriodCount=0;
|
||||
antiClickWavePos=0;
|
||||
|
|
|
|||
|
|
@ -1463,6 +1463,26 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_FM_OPMASK:
|
||||
if (c.chan>=psgChanOffs) break;
|
||||
switch (c.value>>4) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
chan[c.chan].opMask&=~(1<<((c.value>>4)-1));
|
||||
if (c.value&15) {
|
||||
chan[c.chan].opMask|=(1<<((c.value>>4)-1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
chan[c.chan].opMask=c.value&15;
|
||||
break;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].opMaskChanged=true;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_FM_HARD_RESET:
|
||||
if (c.chan>=6) break;
|
||||
chan[c.chan].hardReset=c.value;
|
||||
|
|
|
|||
|
|
@ -39,14 +39,25 @@ const char** DivPlatformMSM6295::getRegisterSheet() {
|
|||
}
|
||||
|
||||
u8 DivPlatformMSM6295::read_byte(u32 address) {
|
||||
if (adpcmMem==NULL || address>=getSampleMemCapacity(0)) {
|
||||
if (adpcmMem==NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (isBanked) {
|
||||
if (address<0x400) {
|
||||
return adpcmMem[(bank[(address>>8)&0x3]<<16)|(address&0x3ff)];
|
||||
unsigned int bankedAddress=(bank[(address>>8)&0x3]<<16)|(address&0x3ff);
|
||||
if (bankedAddress>=getSampleMemCapacity(0)) {
|
||||
return 0;
|
||||
}
|
||||
return adpcmMem[bankedAddress&0xffffff];
|
||||
}
|
||||
return adpcmMem[(bank[(address>>16)&0x3]<<16)|(address&0xffff)];
|
||||
unsigned int bankedAddress=(bank[(address>>16)&0x3]<<16)|(address&0xffff);
|
||||
if (bankedAddress>=getSampleMemCapacity(0)) {
|
||||
return 0;
|
||||
}
|
||||
return adpcmMem[bankedAddress&0xffffff];
|
||||
}
|
||||
if (address>=getSampleMemCapacity(0)) {
|
||||
return 0;
|
||||
}
|
||||
return adpcmMem[address&0x3ffff];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ struct _nla_table nla_table;
|
|||
|
||||
#define CHIP_DIVIDER 16
|
||||
|
||||
#define rWrite(a,v) if (!skipRegisterWrites) {doWrite(a,v); regPool[(a)&0x7f]=v; if (dumpWrites) {addWrite(a,v);} }
|
||||
#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite((a),v)); if (dumpWrites) {addWrite((a),v);} }
|
||||
|
||||
const char* regCheatSheetNES[]={
|
||||
"S0Volume", "4000",
|
||||
|
|
@ -86,10 +86,10 @@ void DivPlatformNES::doWrite(unsigned short addr, unsigned char data) {
|
|||
unsigned char next=((unsigned char)s->data8[dacPos]+0x80)>>1; \
|
||||
if (dacAntiClickOn && dacAntiClick<next) { \
|
||||
dacAntiClick+=8; \
|
||||
rWrite(0x4011,dacAntiClick); \
|
||||
doWrite(0x4011,dacAntiClick); \
|
||||
} else { \
|
||||
dacAntiClickOn=false; \
|
||||
rWrite(0x4011,next); \
|
||||
doWrite(0x4011,next); \
|
||||
} \
|
||||
} \
|
||||
dacPos++; \
|
||||
|
|
@ -108,6 +108,13 @@ void DivPlatformNES::doWrite(unsigned short addr, unsigned char data) {
|
|||
void DivPlatformNES::acquire_puNES(short** buf, size_t len) {
|
||||
for (size_t i=0; i<len; i++) {
|
||||
doPCM;
|
||||
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
doWrite(w.addr,w.val);
|
||||
regPool[w.addr&0x1f]=w.val;
|
||||
writes.pop();
|
||||
}
|
||||
|
||||
apu_tick(nes,NULL);
|
||||
nes->apu.odd_cycle=!nes->apu.odd_cycle;
|
||||
|
|
@ -134,6 +141,13 @@ void DivPlatformNES::acquire_NSFPlay(short** buf, size_t len) {
|
|||
int out2[2];
|
||||
for (size_t i=0; i<len; i++) {
|
||||
doPCM;
|
||||
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
doWrite(w.addr,w.val);
|
||||
regPool[w.addr&0x1f]=w.val;
|
||||
writes.pop();
|
||||
}
|
||||
|
||||
nes1_NP->Tick(8);
|
||||
nes2_NP->TickFrameSequence(8);
|
||||
|
|
@ -161,6 +175,13 @@ void DivPlatformNES::acquire_NSFPlayE(short** buf, size_t len) {
|
|||
int out2[2];
|
||||
for (size_t i=0; i<len; i++) {
|
||||
doPCM;
|
||||
|
||||
if (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
doWrite(w.addr,w.val);
|
||||
regPool[w.addr&0x1f]=w.val;
|
||||
writes.pop();
|
||||
}
|
||||
|
||||
e1_NP->Tick(8);
|
||||
e2_NP->TickFrameSequence(8);
|
||||
|
|
@ -297,7 +318,7 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
if (chan[i].sweepChanged) {
|
||||
chan[i].sweepChanged=false;
|
||||
if (i==0) {
|
||||
//rWrite(16+i*5,chan[i].sweep);
|
||||
// rWrite(16+i*5,chan[i].sweep);
|
||||
}
|
||||
}
|
||||
if (i<3) if (chan[i].std.phaseReset.had) {
|
||||
|
|
@ -338,7 +359,7 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
if (chan[i].keyOff) {
|
||||
//rWrite(16+i*5+2,8);
|
||||
// rWrite(16+i*5+2,8);
|
||||
if (i==2) { // triangle
|
||||
rWrite(0x4000+i*4,0x00);
|
||||
} else {
|
||||
|
|
@ -400,6 +421,34 @@ void DivPlatformNES::tick(bool sysTick) {
|
|||
logV("switching bank to %d",dpcmBank);
|
||||
if (dumpWrites) addWrite(0xffff0004,dpcmBank);
|
||||
}
|
||||
|
||||
// sample custom loop point...
|
||||
DivSample* lsamp=parent->getSample(dacSample);
|
||||
|
||||
// how it works:
|
||||
// when the initial sample info is written (see above) and playback is launched,
|
||||
// the parameters (start point in memory and length) are locked until sample end
|
||||
// is reached.
|
||||
|
||||
// thus, if we write new data after just several APU clock cycles, it will be used only when
|
||||
// sample finishes one full loop.
|
||||
|
||||
// thus we can write sample's loop point as "start address" and sample's looped part length
|
||||
// as "full sample length".
|
||||
|
||||
// APU will play full sample once and then repeatedly cycle through the looped part.
|
||||
|
||||
// sources:
|
||||
// https://www.nesdev.org/wiki/APU_DMC
|
||||
// https://www.youtube.com/watch?v=vB4P8x2Am6Y
|
||||
|
||||
if (lsamp->loopEnd>lsamp->loopStart && goingToLoop) {
|
||||
int loopStartAddr=sampleOffDPCM[dacSample]+(lsamp->loopStart>>3);
|
||||
int loopLen=(lsamp->loopEnd-lsamp->loopStart)>>3;
|
||||
|
||||
rWrite(0x4012,(loopStartAddr>>6)&0xff);
|
||||
rWrite(0x4013,(loopLen>>4)&0xff);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nextDPCMFreq>=0) {
|
||||
|
|
@ -450,14 +499,14 @@ int DivPlatformNES::dispatch(DivCommand c) {
|
|||
}
|
||||
}
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
dacSample=ins->amiga.getSample(c.value);
|
||||
dacSample=(int)ins->amiga.getSample(c.value);
|
||||
if (ins->type==DIV_INS_AMIGA) {
|
||||
chan[c.chan].sampleNote=c.value;
|
||||
c.value=ins->amiga.getFreq(c.value);
|
||||
chan[c.chan].sampleNoteDelta=c.value-chan[c.chan].sampleNote;
|
||||
}
|
||||
} else if (chan[c.chan].sampleNote!=DIV_NOTE_NULL) {
|
||||
dacSample=ins->amiga.getSample(chan[c.chan].sampleNote);
|
||||
dacSample=(int)ins->amiga.getSample(chan[c.chan].sampleNote);
|
||||
if (ins->type==DIV_INS_AMIGA) {
|
||||
c.value=ins->amiga.getFreq(chan[c.chan].sampleNote);
|
||||
}
|
||||
|
|
@ -790,6 +839,7 @@ float DivPlatformNES::getPostAmp() {
|
|||
}
|
||||
|
||||
void DivPlatformNES::reset() {
|
||||
while (!writes.empty()) writes.pop();
|
||||
for (int i=0; i<5; i++) {
|
||||
chan[i]=DivPlatformNES::Channel();
|
||||
chan[i].std.setEngine(parent);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "sound/nes_nsfplay/nes_apu.h"
|
||||
#include "sound/nes_nsfplay/5e01_apu.h"
|
||||
#include "../../fixedQueue.h"
|
||||
|
||||
class DivPlatformNES: public DivDispatch {
|
||||
struct Channel: public SharedChannel<signed char> {
|
||||
|
|
@ -44,6 +45,13 @@ class DivPlatformNES: public DivDispatch {
|
|||
Channel chan[5];
|
||||
DivDispatchOscBuffer* oscBuf[5];
|
||||
bool isMuted[5];
|
||||
struct QueuedWrite {
|
||||
unsigned short addr;
|
||||
unsigned char val;
|
||||
QueuedWrite(): addr(0), val(0) {}
|
||||
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {}
|
||||
};
|
||||
FixedQueue<QueuedWrite,128> writes;
|
||||
int dacPeriod, dacRate, dpcmPos;
|
||||
unsigned int dacPos, dacAntiClick;
|
||||
int dacSample;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ uint8_t DivOPLAInterface::ymfm_external_read(ymfm::access_class type, uint32_t a
|
|||
if (adpcmBMem==NULL) {
|
||||
return 0;
|
||||
}
|
||||
return adpcmBMem[address&0xffffff];
|
||||
return adpcmBMem[address&0x3ffff];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,8 +165,12 @@ int DivPlatformSMS::snCalcFreq(int ch) {
|
|||
if (ch==3) CHIP_DIVIDER=noiseDivider;
|
||||
int easyStartingPeriod=16;
|
||||
int easyThreshold=round(128.0*12.0*log((chipClock/(easyStartingPeriod*CHIP_DIVIDER))/(0.0625*parent->song.tuning))/log(2.0))-384+64;
|
||||
if (parent->song.linearPitch==2 && easyNoise && chan[ch].baseFreq+chan[ch].pitch+chan[ch].pitch2>(easyThreshold)) {
|
||||
int ret=(((easyStartingPeriod<<7))-(chan[ch].baseFreq+chan[ch].pitch+chan[ch].pitch2-(easyThreshold)))>>7;
|
||||
int curFreq=chan[ch].baseFreq+chan[ch].pitch+chan[ch].pitch2+(chan[ch].arpOff<<7);
|
||||
if (chan[ch].fixedArp) {
|
||||
curFreq=chan[ch].baseNoteOverride<<7;
|
||||
}
|
||||
if (parent->song.linearPitch==2 && easyNoise && curFreq>easyThreshold) {
|
||||
int ret=(((easyStartingPeriod<<7))-(curFreq-(easyThreshold)))>>7;
|
||||
if (ret<0) ret=0;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#define rWrite(a,v) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v)); if (dumpWrites) {addWrite(a,v);} }
|
||||
#define chWrite(c,a,v) {rWrite((a)+(c)*16,v)}
|
||||
#define rWriteDelay(a,v,d) if (!skipRegisterWrites) {writes.push(QueuedWrite(a,v,d)); if (dumpWrites) {addWrite(a,v);} }
|
||||
#define chWriteDelay(c,a,v,d) {rWrite((a)+(c)*16,v,d)}
|
||||
#define sampleTableAddr(c) (sampleTableBase+(c)*4)
|
||||
#define waveTableAddr(c) (sampleTableBase+8*4+(c)*9*16)
|
||||
|
||||
|
|
@ -77,7 +79,7 @@ void DivPlatformSNES::acquire(short** buf, size_t len) {
|
|||
dsp.write(w.addr,w.val);
|
||||
regPool[w.addr&0x7f]=w.val;
|
||||
writes.pop();
|
||||
delay=(w.addr==0x5c)?8:1;
|
||||
delay=w.delay;
|
||||
}
|
||||
}
|
||||
dsp.set_output(out,1);
|
||||
|
|
@ -253,7 +255,18 @@ void DivPlatformSNES::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
if (koff!=0) {
|
||||
rWrite(0x5c,koff);
|
||||
// TODO: improve
|
||||
if (antiClick) {
|
||||
for (int i=0; i<8; i++) {
|
||||
if (koff&(1<<i)) {
|
||||
chWrite(i,5,0);
|
||||
chWrite(i,7,0x9f);
|
||||
chan[i].shallWriteEnv=true;
|
||||
}
|
||||
}
|
||||
rWriteDelay(0x7e,0,64);
|
||||
}
|
||||
rWriteDelay(0x5c,koff,8);
|
||||
}
|
||||
if (writeControl) {
|
||||
unsigned char control=(noiseFreq&0x1f)|(echoOn?0:0x20);
|
||||
|
|
@ -314,10 +327,7 @@ void DivPlatformSNES::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
if (koff!=0) {
|
||||
rWrite(0x5c,0);
|
||||
}
|
||||
if (kon!=0) {
|
||||
rWrite(0x4c,kon);
|
||||
rWriteDelay(0x5c,0,8);
|
||||
}
|
||||
for (int i=0; i<8; i++) {
|
||||
if (chan[i].shallWriteVol) {
|
||||
|
|
@ -325,6 +335,9 @@ void DivPlatformSNES::tick(bool sysTick) {
|
|||
chan[i].shallWriteVol=false;
|
||||
}
|
||||
}
|
||||
if (kon!=0) {
|
||||
rWrite(0x4c,kon);
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformSNES::dispatch(DivCommand c) {
|
||||
|
|
@ -841,6 +854,8 @@ void DivPlatformSNES::reset() {
|
|||
memcpy(sampleMem,copyOfSampleMem,65536);
|
||||
dsp.init(sampleMem);
|
||||
dsp.set_output(NULL,0);
|
||||
dsp.setupInterpolation(!interpolationOff);
|
||||
|
||||
memset(regPool,0,128);
|
||||
// this can't be 0 or channel 1 won't play
|
||||
// this can't be 0x100 either as that's used by SPC700 page 1 and the stack
|
||||
|
|
@ -1023,6 +1038,9 @@ void DivPlatformSNES::setFlags(const DivConfig& flags) {
|
|||
initEchoFIR[7]=flags.getInt("echoFilter7",0);
|
||||
|
||||
initEchoMask=flags.getInt("echoMask",0);
|
||||
|
||||
interpolationOff=flags.getBool("interpolationOff",false);
|
||||
antiClick=flags.getBool("antiClick",true);
|
||||
}
|
||||
|
||||
int DivPlatformSNES::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@ class DivPlatformSNES: public DivDispatch {
|
|||
bool writeEcho;
|
||||
bool writeDryVol;
|
||||
bool echoOn;
|
||||
bool interpolationOff;
|
||||
bool antiClick;
|
||||
|
||||
bool initEchoOn;
|
||||
signed char initEchoVolL;
|
||||
|
|
@ -81,8 +83,10 @@ class DivPlatformSNES: public DivDispatch {
|
|||
struct QueuedWrite {
|
||||
unsigned char addr;
|
||||
unsigned char val;
|
||||
QueuedWrite(): addr(0), val(0) {}
|
||||
QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
|
||||
unsigned char delay;
|
||||
unsigned char padding;
|
||||
QueuedWrite(): addr(0), val(0), delay(0), padding(0) {}
|
||||
QueuedWrite(unsigned char a, unsigned char v, unsigned char d=0): addr(a), val(v), delay(d), padding(0) {}
|
||||
};
|
||||
FixedQueue<QueuedWrite,256> writes;
|
||||
|
||||
|
|
|
|||
|
|
@ -135,24 +135,30 @@ static short const gauss [512] =
|
|||
1299,1300,1300,1301,1302,1302,1303,1303,1303,1304,1304,1304,1304,1304,1305,1305,
|
||||
};
|
||||
|
||||
void SPC_DSP::setupInterpolation(bool interpolate){for(int i=0;i<voice_count;i++){m.voices[i].interpolate=interpolate;}}
|
||||
|
||||
inline int SPC_DSP::interpolate( voice_t const* v )
|
||||
{
|
||||
// Make pointers into gaussian based on fractional position between samples
|
||||
int offset = v->interp_pos >> 4 & 0xFF;
|
||||
short const* fwd = gauss + 255 - offset;
|
||||
short const* rev = gauss + offset; // mirror left half of gaussian
|
||||
if (v->interpolate) {
|
||||
int offset = v->interp_pos >> 4 & 0xFF;
|
||||
short const* fwd = gauss + 255 - offset;
|
||||
short const* rev = gauss + offset; // mirror left half of gaussian
|
||||
|
||||
int const* in = &v->buf [(v->interp_pos >> 12) + v->buf_pos];
|
||||
int out;
|
||||
out = (fwd [ 0] * in [0]) >> 11;
|
||||
out += (fwd [256] * in [1]) >> 11;
|
||||
out += (rev [256] * in [2]) >> 11;
|
||||
out = (int16_t) out;
|
||||
out += (rev [ 0] * in [3]) >> 11;
|
||||
int const* in = &v->buf [(v->interp_pos >> 12) + v->buf_pos];
|
||||
int out;
|
||||
out = (fwd [ 0] * in [0]) >> 11;
|
||||
out += (fwd [256] * in [1]) >> 11;
|
||||
out += (rev [256] * in [2]) >> 11;
|
||||
out = (int16_t) out;
|
||||
out += (rev [ 0] * in [3]) >> 11;
|
||||
|
||||
CLAMP16( out );
|
||||
out &= ~1;
|
||||
return out;
|
||||
CLAMP16( out );
|
||||
out &= ~1;
|
||||
return out;
|
||||
} else {
|
||||
return v->buf [(v->interp_pos >> 12) + v->buf_pos]; //Furnace addition -- no interpolation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ public:
|
|||
// output buffer could hold.
|
||||
int sample_count() const;
|
||||
|
||||
// Furnace addition: disable/enable Gaussian interpolation
|
||||
void setupInterpolation(bool interpolate);
|
||||
|
||||
// Emulation
|
||||
|
||||
// Resets DSP to power-on state
|
||||
|
|
@ -122,6 +125,7 @@ public:
|
|||
int hidden_env; // used by GAIN mode 7, very obscure quirk
|
||||
uint8_t t_envx_out;
|
||||
sample_t out[2]; // Furnace addition, for per-channel oscilloscope
|
||||
bool interpolate; // Furnace addition, to disable interpolation
|
||||
};
|
||||
|
||||
// Furnace addition, gets a voice
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
// Chip revisions
|
||||
// 0: V 0.3.0
|
||||
// 1: V 47.0.0 (9-bit volume, phase reset on mute)
|
||||
// 2: V 47.0.2 (Pulse Width XOR on Saw and Triangle)
|
||||
|
||||
#include "vera_psg.h"
|
||||
|
||||
|
|
@ -88,8 +89,8 @@ render(struct VERA_PSG* psg, int16_t *left, int16_t *right)
|
|||
uint8_t v = 0;
|
||||
switch (ch->waveform) {
|
||||
case WF_PULSE: v = (ch->phase >> 10) > ch->pw ? 0 : 63; break;
|
||||
case WF_SAWTOOTH: v = ch->phase >> 11; break;
|
||||
case WF_TRIANGLE: v = (ch->phase & 0x10000) ? (~(ch->phase >> 10) & 0x3F) : ((ch->phase >> 10) & 0x3F); break;
|
||||
case WF_SAWTOOTH: v = (ch->phase >> 11) ^ (psg->chipType < 2 ? 0 : (ch->pw ^ 0x3f) & 0x3f); break;
|
||||
case WF_TRIANGLE: v = ((ch->phase & 0x10000) ? (~(ch->phase >> 10) & 0x3F) : ((ch->phase >> 10) & 0x3F)) ^ (psg->chipType < 2 ? 0 : (ch->pw ^ 0x3f) & 0x3f); break;
|
||||
case WF_NOISE: v = ch->noiseval; break;
|
||||
}
|
||||
int8_t sv = (v ^ 0x20);
|
||||
|
|
|
|||
|
|
@ -858,6 +858,9 @@ int DivPlatformTX81Z::dispatch(DivCommand c) {
|
|||
immWrite(0x17,0x80|pmDepth);
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_FM_OPMASK:
|
||||
// TODO: if OPZ supports op mask
|
||||
break;
|
||||
case DIV_CMD_FM_HARD_RESET:
|
||||
chan[c.chan].hardReset=c.value;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ void DivPlatformVERA::poke(std::vector<DivRegWrite>& wlist) {
|
|||
}
|
||||
|
||||
void DivPlatformVERA::setFlags(const DivConfig& flags) {
|
||||
psg->chipType=flags.getInt("chipType",1);
|
||||
psg->chipType=flags.getInt("chipType",2);
|
||||
chipClock=25000000;
|
||||
CHECK_CUSTOM_CLOCK;
|
||||
rate=chipClock/512;
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ void DivPlatformYM2203::acquire_combo(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -255,6 +256,7 @@ void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -311,6 +313,16 @@ void DivPlatformYM2203::acquire_lle(short** buf, size_t len) {
|
|||
fmOut[i]=0;
|
||||
}
|
||||
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
immWrite(i.addr&15,i.val);
|
||||
}
|
||||
ay->getRegisterWrites().clear();
|
||||
|
||||
while (true) {
|
||||
bool canWeWrite=fm_lle.prescaler_latch[1]&1;
|
||||
|
||||
|
|
@ -444,6 +456,10 @@ void DivPlatformYM2203::acquire_lle(short** buf, size_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
void DivPlatformYM2203::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
|
||||
ay->fillStream(stream,sRate,len);
|
||||
}
|
||||
|
||||
void DivPlatformYM2203::tick(bool sysTick) {
|
||||
// PSG
|
||||
ay->tick(sysTick);
|
||||
|
|
@ -1004,6 +1020,26 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_FM_OPMASK:
|
||||
if (c.chan>=psgChanOffs) break;
|
||||
switch (c.value>>4) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
chan[c.chan].opMask&=~(1<<((c.value>>4)-1));
|
||||
if (c.value&15) {
|
||||
chan[c.chan].opMask|=(1<<((c.value>>4)-1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
chan[c.chan].opMask=c.value&15;
|
||||
break;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].opMaskChanged=true;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_FM_HARD_RESET:
|
||||
chan[c.chan].hardReset=c.value;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
|
|||
|
||||
public:
|
||||
void acquire(short** buf, size_t len);
|
||||
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivMacroInt* getChanMacroInt(int ch);
|
||||
|
|
|
|||
|
|
@ -325,6 +325,7 @@ void DivPlatformYM2608::acquire_combo(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -440,6 +441,7 @@ void DivPlatformYM2608::acquire_ymfm(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -680,6 +682,10 @@ void DivPlatformYM2608::acquire_lle(short** buf, size_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
void DivPlatformYM2608::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
|
||||
ay->fillStream(stream,sRate,len);
|
||||
}
|
||||
|
||||
void DivPlatformYM2608::tick(bool sysTick) {
|
||||
// FM
|
||||
for (int i=0; i<6; i++) {
|
||||
|
|
@ -1537,6 +1543,26 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_FM_OPMASK:
|
||||
if (c.chan>=psgChanOffs) break;
|
||||
switch (c.value>>4) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
chan[c.chan].opMask&=~(1<<((c.value>>4)-1));
|
||||
if (c.value&15) {
|
||||
chan[c.chan].opMask|=(1<<((c.value>>4)-1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
chan[c.chan].opMask=c.value&15;
|
||||
break;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].opMaskChanged=true;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_FM_HARD_RESET:
|
||||
chan[c.chan].hardReset=c.value;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
|
|||
|
||||
public:
|
||||
void acquire(short** buf, size_t len);
|
||||
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivMacroInt* getChanMacroInt(int ch);
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ void DivPlatformYM2610::acquire_combo(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -373,6 +374,7 @@ void DivPlatformYM2610::acquire_ymfm(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -1507,6 +1509,26 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_FM_OPMASK:
|
||||
if (c.chan>=psgChanOffs) break;
|
||||
switch (c.value>>4) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
chan[c.chan].opMask&=~(1<<((c.value>>4)-1));
|
||||
if (c.value&15) {
|
||||
chan[c.chan].opMask|=(1<<((c.value>>4)-1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
chan[c.chan].opMask=c.value&15;
|
||||
break;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].opMaskChanged=true;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_FM_HARD_RESET:
|
||||
chan[c.chan].hardReset=c.value;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -324,6 +324,7 @@ void DivPlatformYM2610B::acquire_combo(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -439,6 +440,7 @@ void DivPlatformYM2610B::acquire_ymfm(short** buf, size_t len) {
|
|||
for (size_t h=0; h<len; h++) {
|
||||
// AY -> OPN
|
||||
ay->runDAC();
|
||||
ay->runTFX(rate);
|
||||
ay->flushWrites();
|
||||
for (DivRegWrite& i: ay->getRegisterWrites()) {
|
||||
if (i.addr>15) continue;
|
||||
|
|
@ -1576,6 +1578,26 @@ int DivPlatformYM2610B::dispatch(DivCommand c) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_FM_OPMASK:
|
||||
if (c.chan>=psgChanOffs) break;
|
||||
switch (c.value>>4) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
chan[c.chan].opMask&=~(1<<((c.value>>4)-1));
|
||||
if (c.value&15) {
|
||||
chan[c.chan].opMask|=(1<<((c.value>>4)-1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
chan[c.chan].opMask=c.value&15;
|
||||
break;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].opMaskChanged=true;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_FM_HARD_RESET:
|
||||
chan[c.chan].hardReset=c.value;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ class DivPlatformYM2610Base: public DivPlatformOPN {
|
|||
}
|
||||
|
||||
public:
|
||||
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
|
||||
ay->fillStream(stream,sRate,len);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
writeADPCMAOff=0;
|
||||
writeADPCMAOn=0;
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ const char* cmdName[]={
|
|||
"HINT_ARPEGGIO",
|
||||
"HINT_VOLUME",
|
||||
"HINT_VOL_SLIDE",
|
||||
"HINT_VOL_SLIDE_TARGET",
|
||||
"HINT_PORTA",
|
||||
"HINT_LEGATO",
|
||||
|
||||
|
|
@ -263,7 +264,9 @@ const char* cmdName[]={
|
|||
"BIFURCATOR_STATE_LOAD",
|
||||
"BIFURCATOR_PARAMETER",
|
||||
|
||||
"FDS_MOD_AUTO"
|
||||
"FDS_MOD_AUTO",
|
||||
|
||||
"FM_OPMASK"
|
||||
};
|
||||
|
||||
static_assert((sizeof(cmdName)/sizeof(void*))==DIV_CMD_MAX,"update cmdName!");
|
||||
|
|
@ -639,7 +642,23 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
}
|
||||
|
||||
// volume
|
||||
if (pat->data[whatRow][3]!=-1) {
|
||||
int volPortaTarget=-1;
|
||||
bool noApplyVolume=false;
|
||||
for (int j=0; j<curPat[i].effectCols; j++) {
|
||||
short effect=pat->data[whatRow][4+(j<<1)];
|
||||
if (effect==0xd3 || effect==0xd4) { // vol porta
|
||||
volPortaTarget=pat->data[whatRow][3]<<8; // can be -256
|
||||
|
||||
short effectVal=pat->data[whatRow][5+(j<<1)];
|
||||
if (effectVal==-1) effectVal=0;
|
||||
effectVal&=255;
|
||||
|
||||
noApplyVolume=effectVal>0; // "D3.." or "D300" shouldn't stop volume from applying
|
||||
break; // technically you could have both D3 and D4... let's not care
|
||||
}
|
||||
}
|
||||
|
||||
if (pat->data[whatRow][3]!=-1 && !noApplyVolume) {
|
||||
if (!song.oldAlwaysSetVolume || disCont[dispatchOfChan[i]].dispatch->getLegacyAlwaysSetVolume() || (MIN(chan[i].volMax,chan[i].volume)>>8)!=pat->data[whatRow][3]) {
|
||||
if (pat->data[whatRow][0]==0 && pat->data[whatRow][1]==0) {
|
||||
chan[i].midiAftertouch=true;
|
||||
|
|
@ -828,6 +847,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
} else {
|
||||
chan[i].volSpeed=0;
|
||||
}
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,chan[i].volSpeed));
|
||||
break;
|
||||
case 0x06: // vol slide + porta
|
||||
|
|
@ -869,6 +889,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
} else {
|
||||
chan[i].volSpeed=0;
|
||||
}
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,chan[i].volSpeed));
|
||||
break;
|
||||
case 0x07: // tremolo
|
||||
|
|
@ -879,6 +900,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
chan[i].tremoloRate=effectVal>>4;
|
||||
if (chan[i].tremoloDepth!=0) {
|
||||
chan[i].volSpeed=0;
|
||||
chan[i].volSpeedTarget=-1;
|
||||
} else {
|
||||
dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));
|
||||
|
|
@ -898,6 +920,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
} else {
|
||||
chan[i].volSpeed=0;
|
||||
}
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,chan[i].volSpeed));
|
||||
break;
|
||||
case 0x00: // arpeggio
|
||||
|
|
@ -940,6 +963,22 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
chan[i].cutType=0;
|
||||
}
|
||||
break;
|
||||
case 0xd3: // volume portamento (vol porta)
|
||||
// tremolo and vol slides are incompatible
|
||||
chan[i].tremoloDepth=0;
|
||||
chan[i].tremoloRate=0;
|
||||
chan[i].volSpeed=volPortaTarget<0 ? 0 : volPortaTarget>chan[i].volume ? effectVal : -effectVal;
|
||||
chan[i].volSpeedTarget=chan[i].volSpeed==0 ? -1 : volPortaTarget;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE_TARGET,i,chan[i].volSpeed,chan[i].volSpeedTarget));
|
||||
break;
|
||||
case 0xd4: // volume portamento fast (vol porta fast)
|
||||
// tremolo and vol slides are incompatible
|
||||
chan[i].tremoloDepth=0;
|
||||
chan[i].tremoloRate=0;
|
||||
chan[i].volSpeed=volPortaTarget<0 ? 0 : volPortaTarget>chan[i].volume ? 256*effectVal : -256*effectVal;
|
||||
chan[i].volSpeedTarget=chan[i].volSpeed==0 ? -1 : volPortaTarget;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE_TARGET,i,chan[i].volSpeed,chan[i].volSpeedTarget));
|
||||
break;
|
||||
case 0xe0: // arp speed
|
||||
if (effectVal>0) {
|
||||
curSubSong->arpLen=effectVal;
|
||||
|
|
@ -1077,6 +1116,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
chan[i].tremoloDepth=0;
|
||||
chan[i].tremoloRate=0;
|
||||
chan[i].volSpeed=effectVal;
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,chan[i].volSpeed));
|
||||
break;
|
||||
case 0xf4: // fine volume ramp down
|
||||
|
|
@ -1084,6 +1124,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
chan[i].tremoloDepth=0;
|
||||
chan[i].tremoloRate=0;
|
||||
chan[i].volSpeed=-effectVal;
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,chan[i].volSpeed));
|
||||
break;
|
||||
case 0xf5: // disable macro
|
||||
|
|
@ -1097,12 +1138,14 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
break;
|
||||
case 0xf8: // single volume ramp up
|
||||
chan[i].volSpeed=0; // add compat flag?
|
||||
chan[i].volSpeedTarget=-1;
|
||||
chan[i].volume=MIN(chan[i].volume+effectVal*256,chan[i].volMax);
|
||||
dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));
|
||||
break;
|
||||
case 0xf9: // single volume ramp down
|
||||
chan[i].volSpeed=0; // add compat flag?
|
||||
chan[i].volSpeedTarget=-1;
|
||||
chan[i].volume=MAX(chan[i].volume-effectVal*256,0);
|
||||
dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));
|
||||
|
|
@ -1120,9 +1163,9 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
} else {
|
||||
chan[i].volSpeed=0;
|
||||
}
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,chan[i].volSpeed));
|
||||
break;
|
||||
|
||||
case 0xfc: // delayed note release
|
||||
if (song.delayBehavior==2 || effectVal<nextSpeed) {
|
||||
chan[i].cut=effectVal+1;
|
||||
|
|
@ -1590,9 +1633,30 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
if (chan[i].volSpeed!=0) {
|
||||
chan[i].volume=(chan[i].volume&0xff)|(dispatchCmd(DivCommand(DIV_CMD_GET_VOLUME,i))<<8);
|
||||
chan[i].volume+=chan[i].volSpeed;
|
||||
if (chan[i].volSpeedTarget!=-1) {
|
||||
bool atTarget=false;
|
||||
if (chan[i].volSpeed>0) {
|
||||
atTarget=(chan[i].volume>=chan[i].volSpeedTarget);
|
||||
} else if (chan[i].volSpeed<0) {
|
||||
atTarget=(chan[i].volume<=chan[i].volSpeedTarget);
|
||||
} else {
|
||||
atTarget=true;
|
||||
chan[i].volSpeedTarget=chan[i].volume;
|
||||
}
|
||||
|
||||
if (atTarget) {
|
||||
chan[i].volume=chan[i].volSpeedTarget;
|
||||
chan[i].volSpeed=0;
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,0));
|
||||
}
|
||||
}
|
||||
if (chan[i].volume>chan[i].volMax) {
|
||||
chan[i].volume=chan[i].volMax;
|
||||
chan[i].volSpeed=0;
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOL_SLIDE,i,0));
|
||||
|
|
@ -1604,6 +1668,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
} else {
|
||||
chan[i].volume=0;
|
||||
}
|
||||
chan[i].volSpeedTarget=-1;
|
||||
dispatchCmd(DivCommand(DIV_CMD_VOLUME,i,chan[i].volume>>8));
|
||||
dispatchCmd(DivCommand(DIV_CMD_HINT_VOLUME,i,chan[i].volume>>8));
|
||||
} else {
|
||||
|
|
@ -1647,26 +1712,34 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
chan[i].panPos+=chan[i].panRate;
|
||||
chan[i].panPos&=255;
|
||||
|
||||
// calculate...
|
||||
// calculate inverted...
|
||||
switch (chan[i].panPos&0xc0) {
|
||||
case 0: // center -> right
|
||||
chan[i].panL=0xff-((chan[i].panPos&0x3f)<<2);
|
||||
chan[i].panR=0xff;
|
||||
chan[i].panL=((chan[i].panPos&0x3f)<<2);
|
||||
chan[i].panR=0;
|
||||
break;
|
||||
case 0x40: // right -> center
|
||||
chan[i].panL=(chan[i].panPos&0x3f)<<2;
|
||||
chan[i].panR=0xff;
|
||||
chan[i].panL=0xff-((chan[i].panPos&0x3f)<<2);
|
||||
chan[i].panR=0;
|
||||
break;
|
||||
case 0x80: // center -> left
|
||||
chan[i].panL=0xff;
|
||||
chan[i].panR=0xff-((chan[i].panPos&0x3f)<<2);
|
||||
chan[i].panL=0;
|
||||
chan[i].panR=((chan[i].panPos&0x3f)<<2);
|
||||
break;
|
||||
case 0xc0: // left -> center
|
||||
chan[i].panL=0xff;
|
||||
chan[i].panR=(chan[i].panPos&0x3f)<<2;
|
||||
chan[i].panL=0;
|
||||
chan[i].panR=0xff-((chan[i].panPos&0x3f)<<2);
|
||||
break;
|
||||
}
|
||||
|
||||
// multiply by depth
|
||||
chan[i].panL=(chan[i].panL*chan[i].panDepth)/15;
|
||||
chan[i].panR=(chan[i].panR*chan[i].panDepth)/15;
|
||||
|
||||
// then invert it to get final panning
|
||||
chan[i].panL^=0xff;
|
||||
chan[i].panR^=0xff;
|
||||
|
||||
dispatchCmd(DivCommand(DIV_CMD_PANNING,i,chan[i].panL,chan[i].panR));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "sfWrapper.h"
|
||||
#include "../fileutils.h"
|
||||
#include "../ta-log.h"
|
||||
#include "sndfile.h"
|
||||
|
||||
sf_count_t _vioGetSize(void* user) {
|
||||
|
|
@ -80,6 +81,7 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
|
|||
vio.seek=_vioSeek;
|
||||
vio.tell=_vioTell;
|
||||
vio.write=_vioWrite;
|
||||
logV("SFWrapper: opening %s",path);
|
||||
|
||||
const char* modeC="rb";
|
||||
if (mode==SFM_WRITE) {
|
||||
|
|
@ -91,10 +93,12 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
|
|||
|
||||
f=ps_fopen(path,modeC);
|
||||
if (f==NULL) {
|
||||
logE("SFWrapper: failed to open (%s)",strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fseek(f,0,SEEK_END)==-1) {
|
||||
logE("SFWrapper: failed to seek to end (%s)",strerror(errno));
|
||||
fclose(f);
|
||||
f=NULL;
|
||||
return NULL;
|
||||
|
|
@ -102,6 +106,7 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
|
|||
|
||||
len=ftell(f);
|
||||
if (len==(SIZE_MAX>>1)) {
|
||||
logE("SFWrapper: failed to tell (%s)",strerror(errno));
|
||||
len=0;
|
||||
fclose(f);
|
||||
f=NULL;
|
||||
|
|
@ -109,6 +114,7 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
|
|||
}
|
||||
|
||||
if (fseek(f,0,SEEK_SET)==-1) {
|
||||
logE("SFWrapper: failed to seek to beginning (%s)",strerror(errno));
|
||||
len=0;
|
||||
fclose(f);
|
||||
f=NULL;
|
||||
|
|
@ -117,5 +123,8 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
|
|||
|
||||
sf=sf_open_virtual(&vio,mode,sfinfo,this);
|
||||
if (sf!=NULL) fileMode=mode;
|
||||
if (sf==NULL) {
|
||||
logE("SFWrapper: WHY IS IT NULL?!");
|
||||
}
|
||||
return sf;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,173 @@ bool DivSubSong::walk(int& loopOrder, int& loopRow, int& loopEnd, int chans, int
|
|||
return false;
|
||||
}
|
||||
|
||||
double calcRowLenInSeconds(const DivGroovePattern& speeds, float hz, int vN, int vD, int timeBaseFromSong) {
|
||||
double hl=1; //count for 1 row
|
||||
if (hl<=0.0) hl=4.0;
|
||||
double timeBase=timeBaseFromSong+1;
|
||||
double speedSum=0;
|
||||
for (int i=0; i<MIN(16,speeds.len); i++) {
|
||||
speedSum+=speeds.val[i];
|
||||
}
|
||||
speedSum/=MAX(1,speeds.len);
|
||||
if (timeBase<1.0) timeBase=1.0;
|
||||
if (speedSum<1.0) speedSum=1.0;
|
||||
if (vD<1) vD=1;
|
||||
return 1.0/((60.0*hz/(timeBase*hl*speedSum))*(double)vN/(double)vD/60.0);
|
||||
}
|
||||
|
||||
void DivSubSong::findLength(int loopOrder, int loopRow, double fadeoutLen, int& rowsForFadeout, bool& hasFFxx, std::vector<int>& orders_vec, std::vector<DivGroovePattern>& grooves, int& length, int chans, int jumpTreatment, int ignoreJumpAtEnd, int firstPat) {
|
||||
length=0;
|
||||
hasFFxx=false;
|
||||
rowsForFadeout=0;
|
||||
|
||||
float secondsPerThisRow=0.0f;
|
||||
|
||||
DivGroovePattern curSpeeds=speeds; //simulate that we are playing the song, track all speed/BPM/tempo/engine rate changes
|
||||
short curVirtualTempoN=virtualTempoN;
|
||||
short curVirtualTempoD=virtualTempoD;
|
||||
float curHz=hz;
|
||||
double curDivider=(double)timeBase;
|
||||
|
||||
double curLen=0.0; //how many seconds passed since the start of song
|
||||
|
||||
int nextOrder=-1;
|
||||
int nextRow=0;
|
||||
int effectVal=0;
|
||||
int lastSuspectedLoopEnd=-1;
|
||||
DivPattern* subPat[DIV_MAX_CHANS];
|
||||
unsigned char wsWalked[8192];
|
||||
memset(wsWalked,0,8192);
|
||||
if (firstPat>0) {
|
||||
memset(wsWalked,255,32*firstPat);
|
||||
}
|
||||
for (int i=firstPat; i<ordersLen; i++) {
|
||||
bool jumped=false;
|
||||
|
||||
for (int j=0; j<chans; j++) {
|
||||
subPat[j]=pat[j].getPattern(orders.ord[j][i],false);
|
||||
}
|
||||
if (i>lastSuspectedLoopEnd) {
|
||||
lastSuspectedLoopEnd=i;
|
||||
}
|
||||
for (int j=nextRow; j<patLen; j++) {
|
||||
nextRow=0;
|
||||
bool changingOrder=false;
|
||||
bool jumpingOrder=false;
|
||||
if (wsWalked[((i<<5)+(j>>3))&8191]&(1<<(j&7))) {
|
||||
return;
|
||||
}
|
||||
for (int k=0; k<chans; k++) {
|
||||
for (int l=0; l<pat[k].effectCols; l++) {
|
||||
effectVal=subPat[k]->data[j][5+(l<<1)];
|
||||
if (effectVal<0) effectVal=0;
|
||||
|
||||
if (subPat[k]->data[j][4+(l<<1)]==0xff) {
|
||||
hasFFxx=true;
|
||||
|
||||
// FFxx makes YOU SHALL NOT PASS!!! move
|
||||
orders_vec.push_back(j+1); // order len
|
||||
length+=j+1; // add length of order to song length
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (subPat[k]->data[j][4+(l<<1)]) {
|
||||
case 0x09: { // select groove pattern/speed 1
|
||||
if (grooves.empty()) {
|
||||
if (effectVal>0) curSpeeds.val[0]=effectVal;
|
||||
} else {
|
||||
if (effectVal<(short)grooves.size()) {
|
||||
curSpeeds=grooves[effectVal];
|
||||
//curSpeed=0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x0f: { // speed 1/speed 2
|
||||
if (curSpeeds.len==2 && grooves.empty()) {
|
||||
if (effectVal>0) curSpeeds.val[1]=effectVal;
|
||||
} else {
|
||||
if (effectVal>0) curSpeeds.val[0]=effectVal;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xfd: { // virtual tempo num
|
||||
if (effectVal>0) curVirtualTempoN=effectVal;
|
||||
break;
|
||||
}
|
||||
case 0xfe: { // virtual tempo den
|
||||
if (effectVal>0) curVirtualTempoD=effectVal;
|
||||
break;
|
||||
}
|
||||
case 0xf0: { // set Hz by tempo (set bpm)
|
||||
curDivider=(double)effectVal*2.0/5.0;
|
||||
if (curDivider<1) curDivider=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (subPat[k]->data[j][4+(l<<1)]==0x0d) {
|
||||
if (jumpTreatment==2) {
|
||||
if ((i<ordersLen-1 || !ignoreJumpAtEnd)) {
|
||||
nextOrder=i+1;
|
||||
nextRow=effectVal;
|
||||
jumpingOrder=true;
|
||||
}
|
||||
} else if (jumpTreatment==1) {
|
||||
if (nextOrder==-1 && (i<ordersLen-1 || !ignoreJumpAtEnd)) {
|
||||
nextOrder=i+1;
|
||||
nextRow=effectVal;
|
||||
jumpingOrder=true;
|
||||
}
|
||||
} else {
|
||||
if ((i<ordersLen-1 || !ignoreJumpAtEnd)) {
|
||||
if (!changingOrder) {
|
||||
nextOrder=i+1;
|
||||
}
|
||||
jumpingOrder=true;
|
||||
nextRow=effectVal;
|
||||
}
|
||||
}
|
||||
} else if (subPat[k]->data[j][4+(l<<1)]==0x0b) {
|
||||
if (nextOrder==-1 || jumpTreatment==0) {
|
||||
nextOrder=effectVal;
|
||||
if (jumpTreatment==1 || jumpTreatment==2 || !jumpingOrder) {
|
||||
nextRow=0;
|
||||
}
|
||||
changingOrder=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i>loopOrder || (i==loopOrder && j>loopRow)) {
|
||||
// we count each row fadeout lasts. When our time is greater than fadeout length we successfully counted the number of fadeout rows
|
||||
if (curLen<=fadeoutLen && fadeoutLen>0.0) {
|
||||
secondsPerThisRow=calcRowLenInSeconds(speeds,curHz,curVirtualTempoN,curVirtualTempoD,curDivider);
|
||||
curLen+=secondsPerThisRow;
|
||||
rowsForFadeout++;
|
||||
}
|
||||
}
|
||||
|
||||
wsWalked[((i<<5)+(j>>3))&8191]|=1<<(j&7);
|
||||
|
||||
if (nextOrder!=-1) {
|
||||
i=nextOrder-1;
|
||||
orders_vec.push_back(j+1); // order len
|
||||
length+=j+1; // add length of order to song length
|
||||
jumped=true;
|
||||
nextOrder=-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!jumped) { // if no jump occured we add full pattern length
|
||||
orders_vec.push_back(patLen); // order len
|
||||
length+=patLen; // add length of order to song length
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DivSubSong::clearData() {
|
||||
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
||||
pat[i].wipePatterns();
|
||||
|
|
|
|||
|
|
@ -187,6 +187,11 @@ struct DivSubSong {
|
|||
*/
|
||||
bool walk(int& loopOrder, int& loopRow, int& loopEnd, int chans, int jumpTreatment, int ignoreJumpAtEnd, int firstPat=0);
|
||||
|
||||
/**
|
||||
* find song length in rows (up to specified loop point).
|
||||
*/
|
||||
void findLength(int loopOrder, int loopRow, double fadeoutLen, int& rowsForFadeout, bool& hasFFxx, std::vector<int>& orders, std::vector<DivGroovePattern>& grooves, int& length, int chans, int jumpTreatment, int ignoreJumpAtEnd, int firstPat=0);
|
||||
|
||||
void clearData();
|
||||
void optimizePatterns();
|
||||
void rearrangePatterns();
|
||||
|
|
|
|||
|
|
@ -433,6 +433,7 @@ void DivEngine::registerSystems() {
|
|||
{0x25, {DIV_CMD_AY_ENVELOPE_SLIDE, _("25xx: Envelope slide up"), negEffectVal}},
|
||||
{0x26, {DIV_CMD_AY_ENVELOPE_SLIDE, _("26xx: Envelope slide down")}},
|
||||
{0x29, {DIV_CMD_AY_AUTO_ENVELOPE, _("29xy: Set auto-envelope (x: numerator; y: denominator)")}},
|
||||
{0x2c, {DIV_CMD_AY_AUTO_PWM, _("2Cxx: Set timer period offset (bit 7: sign)")}},
|
||||
{0x2e, {DIV_CMD_AY_IO_WRITE, _("2Exx: Write to I/O port A"), constVal<0>, effectVal}},
|
||||
{0x2f, {DIV_CMD_AY_IO_WRITE, _("2Fxx: Write to I/O port B"), constVal<1>, effectVal}},
|
||||
};
|
||||
|
|
@ -503,6 +504,7 @@ void DivEngine::registerSystems() {
|
|||
{0x5d, {DIV_CMD_FM_D2R, _("5Dxx: Set decay 2 of operator 2 (0 to 1F)"), constVal<1>, effectValAnd<31>}},
|
||||
{0x5e, {DIV_CMD_FM_D2R, _("5Exx: Set decay 2 of operator 3 (0 to 1F)"), constVal<2>, effectValAnd<31>}},
|
||||
{0x5f, {DIV_CMD_FM_D2R, _("5Fxx: Set decay 2 of operator 4 (0 to 1F)"), constVal<3>, effectValAnd<31>}},
|
||||
{0x60, {DIV_CMD_FM_OPMASK, _("60xx: Set operator mask (bits 0-3)")}},
|
||||
};
|
||||
|
||||
EffectHandlerMap fmOPMPostEffectHandlerMap(fmOPNPostEffectHandlerMap);
|
||||
|
|
@ -513,6 +515,7 @@ void DivEngine::registerSystems() {
|
|||
{0x1e, {DIV_CMD_FM_AM_DEPTH, _("1Exx: Set AM depth (0 to 7F)"), effectValAnd<127>}},
|
||||
{0x1f, {DIV_CMD_FM_PM_DEPTH, _("1Fxx: Set PM depth (0 to 7F)"), effectValAnd<127>}},
|
||||
{0x55, {DIV_CMD_FM_SSG, _("55xy: Set detune 2 (x: operator from 1 to 4 (0 for all ops); y: detune from 0 to 3)"), effectOpVal<4>, effectValAnd<3>}},
|
||||
{0x60, {DIV_CMD_FM_OPMASK, _("60xx: Set operator mask (bits 0-3)")}},
|
||||
});
|
||||
|
||||
EffectHandlerMap fmOPZPostEffectHandlerMap(fmOPMPostEffectHandlerMap);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@
|
|||
|
||||
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
|
||||
|
||||
void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool* sampleDir, bool isSecond, int* pendingFreq, int* playingSample, int* setPos, unsigned int* sampleOff8, unsigned int* sampleLen8, size_t bankOffset, bool directStream) {
|
||||
// this function is so long
|
||||
// may as well make it something else
|
||||
void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write, int streamOff, double* loopTimer, double* loopFreq, int* loopSample, bool* sampleDir, bool isSecond, int* pendingFreq, int* playingSample, int* setPos, unsigned int* sampleOff8, unsigned int* sampleLen8, size_t bankOffset, bool directStream, bool* sampleStoppable) {
|
||||
unsigned char baseAddr1=isSecond?0xa0:0x50;
|
||||
unsigned char baseAddr2=isSecond?0x80:0;
|
||||
unsigned short baseAddr2S=isSecond?0x8000:0;
|
||||
|
|
@ -647,6 +649,7 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
|||
logD("writing stream command %x:%x with stream ID %d",write.addr,write.val,streamID);
|
||||
switch (write.addr&0xff) {
|
||||
case 0: // play sample
|
||||
sampleStoppable[streamID]=true;
|
||||
if (write.val<(unsigned int)song.sampleLen) {
|
||||
if (playingSample[streamID]!=(int)write.val) {
|
||||
pendingFreq[streamID]=write.val;
|
||||
|
|
@ -685,6 +688,7 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
|||
}
|
||||
break;
|
||||
case 1: { // set sample freq
|
||||
sampleStoppable[streamID]=true;
|
||||
int realFreq=write.val;
|
||||
if (realFreq<0) realFreq=0;
|
||||
if (realFreq>44100) realFreq=44100;
|
||||
|
|
@ -728,11 +732,14 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
|||
break;
|
||||
}
|
||||
case 2: // stop sample
|
||||
w->writeC(0x94);
|
||||
w->writeC(streamID);
|
||||
loopSample[streamID]=-1;
|
||||
playingSample[streamID]=-1;
|
||||
pendingFreq[streamID]=-1;
|
||||
if (sampleStoppable[streamID]) {
|
||||
w->writeC(0x94);
|
||||
w->writeC(streamID);
|
||||
loopSample[streamID]=-1;
|
||||
playingSample[streamID]=-1;
|
||||
pendingFreq[streamID]=-1;
|
||||
sampleStoppable[streamID]=false;
|
||||
}
|
||||
break;
|
||||
case 3: // set sample direction
|
||||
sampleDir[streamID]=write.val;
|
||||
|
|
@ -1224,6 +1231,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
bool sampleDir[DIV_MAX_CHANS];
|
||||
int pendingFreq[DIV_MAX_CHANS];
|
||||
int playingSample[DIV_MAX_CHANS];
|
||||
bool sampleStoppable[DIV_MAX_CHANS];
|
||||
int setPos[DIV_MAX_CHANS];
|
||||
std::vector<unsigned int> chipVol;
|
||||
std::vector<DivDelayedWrite> delayedWrites[DIV_MAX_CHIPS];
|
||||
|
|
@ -1246,6 +1254,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
playingSample[i]=-1;
|
||||
setPos[i]=0;
|
||||
sampleDir[i]=false;
|
||||
sampleStoppable[i]=true;
|
||||
}
|
||||
|
||||
bool writeDACSamples=false;
|
||||
|
|
@ -2160,8 +2169,8 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
w->writeI(0);
|
||||
w->write(writeADPCM_Y8950[i]->getSampleMem(0),writeADPCM_Y8950[i]->getSampleMemUsage(0));
|
||||
}
|
||||
if (writeQSound[i]!=NULL && writeQSound[i]->getSampleMemUsage()>0) {
|
||||
unsigned int blockSize=(writeQSound[i]->getSampleMemUsage()+0xffff)&(~0xffff);
|
||||
if (writeQSound[i]!=NULL && writeQSound[i]->getSampleMemUsage(1)>0) {
|
||||
unsigned int blockSize=(writeQSound[i]->getSampleMemUsage(1)+0xffff)&(~0xffff);
|
||||
if (blockSize > 0x1000000) {
|
||||
blockSize = 0x1000000;
|
||||
}
|
||||
|
|
@ -2169,7 +2178,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
w->writeC(0x66);
|
||||
w->writeC(0x8F);
|
||||
w->writeI((blockSize+8)|(i*0x80000000));
|
||||
w->writeI(writeQSound[i]->getSampleMemCapacity());
|
||||
w->writeI(writeQSound[i]->getSampleMemCapacity(1));
|
||||
w->writeI(0);
|
||||
w->write(writeQSound[i]->getSampleMem(),blockSize);
|
||||
}
|
||||
|
|
@ -2514,7 +2523,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
for (int i=0; i<song.systemLen; i++) {
|
||||
std::vector<DivRegWrite>& writes=disCont[i].dispatch->getRegisterWrites();
|
||||
for (DivRegWrite& j: writes) {
|
||||
performVGMWrite(w,song.system[i],j,streamIDs[i],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i],pendingFreq,playingSample,setPos,sampleOff8,sampleLen8,bankOffset[i],directStream);
|
||||
performVGMWrite(w,song.system[i],j,streamIDs[i],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i],pendingFreq,playingSample,setPos,sampleOff8,sampleLen8,bankOffset[i],directStream,sampleStoppable);
|
||||
writeCount++;
|
||||
}
|
||||
writes.clear();
|
||||
|
|
@ -2554,7 +2563,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
lastOne=i.second.time;
|
||||
}
|
||||
// write write
|
||||
performVGMWrite(w,song.system[i.first],i.second.write,streamIDs[i.first],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i.first],pendingFreq,playingSample,setPos,sampleOff8,sampleLen8,bankOffset[i.first],directStream);
|
||||
performVGMWrite(w,song.system[i.first],i.second.write,streamIDs[i.first],loopTimer,loopFreq,loopSample,sampleDir,isSecond[i.first],pendingFreq,playingSample,setPos,sampleOff8,sampleLen8,bankOffset[i.first],directStream,sampleStoppable);
|
||||
// handle global Furnace commands
|
||||
|
||||
writeCount++;
|
||||
|
|
@ -2670,7 +2679,8 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
|||
w->writeWString(ws,false); // japanese author name
|
||||
w->writeS(0); // date
|
||||
w->writeWString(L"Furnace (chiptune tracker)",false); // ripper
|
||||
w->writeS(0); // notes
|
||||
ws=utf8To16(song.notes.c_str());
|
||||
w->writeWString(ws,false); // notes
|
||||
|
||||
int gd3Len=w->tell()-gd3Off-12;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,78 @@ bool DivEngine::isExporting() {
|
|||
return exporting;
|
||||
}
|
||||
|
||||
void DivEngine::getLoopsLeft(int &loops) {
|
||||
if (totalLoops<0 || exportLoopCount==0) {
|
||||
loops=0;
|
||||
return;
|
||||
}
|
||||
loops=exportLoopCount-1-totalLoops;
|
||||
}
|
||||
|
||||
void DivEngine::getTotalLoops(int &loops) {
|
||||
loops=exportLoopCount-1;
|
||||
}
|
||||
|
||||
void DivEngine::getCurSongPos(int &row, int &order) {
|
||||
row=curRow;
|
||||
order=curOrder;
|
||||
}
|
||||
|
||||
void DivEngine::getTotalAudioFiles(int &files) {
|
||||
files=0;
|
||||
|
||||
switch (exportMode) {
|
||||
case DIV_EXPORT_MODE_ONE: {
|
||||
files=1;
|
||||
break;
|
||||
}
|
||||
case DIV_EXPORT_MODE_MANY_SYS: {
|
||||
files=1; // there actually are several files but they are processed in the same loop, so to correctly draw progress we think of them as one file
|
||||
break;
|
||||
}
|
||||
case DIV_EXPORT_MODE_MANY_CHAN: {
|
||||
for (int i=0; i<chans; i++) {
|
||||
if (exportChannelMask[i]) {
|
||||
files++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DivEngine::getCurFileIndex(int &file) {
|
||||
file=0;
|
||||
|
||||
switch (exportMode) {
|
||||
case DIV_EXPORT_MODE_ONE: {
|
||||
file=0;
|
||||
break;
|
||||
}
|
||||
case DIV_EXPORT_MODE_MANY_SYS: {
|
||||
file=0; // there actually are several files but they are processed in the same loop, so to correctly draw progress we think of them as one file
|
||||
break;
|
||||
}
|
||||
case DIV_EXPORT_MODE_MANY_CHAN: {
|
||||
file=curExportChan;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool DivEngine::getIsFadingOut() {
|
||||
return isFadingOut;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SNDFILE
|
||||
void DivEngine::runExportThread() {
|
||||
size_t fadeOutSamples=got.rate*exportFadeOut;
|
||||
size_t curFadeOutSample=0;
|
||||
bool isFadingOut=false;
|
||||
isFadingOut=false;
|
||||
|
||||
switch (exportMode) {
|
||||
case DIV_EXPORT_MODE_ONE: {
|
||||
|
|
@ -140,7 +207,11 @@ void DivEngine::runExportThread() {
|
|||
sf[i]=NULL;
|
||||
si[i].samplerate=got.rate;
|
||||
si[i].channels=disCont[i].dispatch->getOutputCount();
|
||||
si[i].format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
if (exportFormat==DIV_EXPORT_FORMAT_S16) {
|
||||
si[i].format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
} else {
|
||||
si[i].format=SF_FORMAT_WAV|SF_FORMAT_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
|
|
@ -247,6 +318,8 @@ void DivEngine::runExportThread() {
|
|||
// take control of audio output
|
||||
deinitAudioBackend();
|
||||
|
||||
curExportChan=0;
|
||||
|
||||
float* outBuf[DIV_MAX_OUTPUTS];
|
||||
float* outBufFinal;
|
||||
for (int i=0; i<exportOutputs; i++) {
|
||||
|
|
@ -258,6 +331,7 @@ void DivEngine::runExportThread() {
|
|||
|
||||
for (int i=0; i<chans; i++) {
|
||||
if (!exportChannelMask[i]) continue;
|
||||
|
||||
SNDFILE* sf;
|
||||
SF_INFO si;
|
||||
SFWrapper sfWrap;
|
||||
|
|
@ -338,6 +412,8 @@ void DivEngine::runExportThread() {
|
|||
}
|
||||
}
|
||||
|
||||
curExportChan++;
|
||||
|
||||
if (sfWrap.doClose()!=0) {
|
||||
logE("could not close audio file!");
|
||||
}
|
||||
|
|
@ -378,6 +454,7 @@ void DivEngine::runExportThread() {
|
|||
}
|
||||
logI("done!");
|
||||
exporting=false;
|
||||
curExportChan=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _ZSM_H
|
||||
#define _ZSM_H
|
||||
|
||||
//#include "engine.h"
|
||||
#include "safeWriter.h"
|
||||
#include "dispatch.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ZSM_HEADER_SIZE 16
|
||||
#define ZSM_VERSION 1
|
||||
#define ZSM_YM_CMD 0x40
|
||||
#define ZSM_DELAY_CMD 0x80
|
||||
#define ZSM_YM_MAX_WRITES 63
|
||||
#define ZSM_SYNC_MAX_WRITES 31
|
||||
#define ZSM_DELAY_MAX 127
|
||||
#define ZSM_EOF ZSM_DELAY_CMD
|
||||
|
||||
#define ZSM_EXT ZSM_YM_CMD
|
||||
#define ZSM_EXT_PCM 0x00
|
||||
#define ZSM_EXT_CHIP 0x40
|
||||
#define ZSM_EXT_SYNC 0x80
|
||||
#define ZSM_EXT_CUSTOM 0xC0
|
||||
|
||||
enum YM_STATE { ym_PREV, ym_NEW, ym_STATES };
|
||||
enum PSG_STATE { psg_PREV, psg_NEW, psg_STATES };
|
||||
|
||||
class DivZSM {
|
||||
private:
|
||||
struct S_pcmInst {
|
||||
int geometry;
|
||||
unsigned int offset, length, loopPoint;
|
||||
bool isLooped;
|
||||
};
|
||||
SafeWriter* w;
|
||||
int ymState[ym_STATES][256];
|
||||
int psgState[psg_STATES][64];
|
||||
int pcmRateCache;
|
||||
int pcmCtrlRVCache;
|
||||
int pcmCtrlDCCache;
|
||||
unsigned int pcmLoopPointCache;
|
||||
bool pcmIsLooped;
|
||||
std::vector<DivRegWrite> ymwrites;
|
||||
std::vector<DivRegWrite> pcmMeta;
|
||||
std::vector<unsigned char> pcmData;
|
||||
std::vector<unsigned char> pcmCache;
|
||||
std::vector<S_pcmInst> pcmInsts;
|
||||
std::vector<DivRegWrite> syncCache;
|
||||
int loopOffset;
|
||||
int numWrites;
|
||||
int ticks;
|
||||
int tickRate;
|
||||
int ymMask;
|
||||
int psgMask;
|
||||
bool optimize;
|
||||
public:
|
||||
DivZSM();
|
||||
~DivZSM();
|
||||
void init(unsigned int rate = 60);
|
||||
int getoffset();
|
||||
void writeYM(unsigned char a, unsigned char v);
|
||||
void writePSG(unsigned char a, unsigned char v);
|
||||
void writePCM(unsigned char a, unsigned char v);
|
||||
void writeSync(unsigned char a, unsigned char v);
|
||||
void setOptimize(bool o);
|
||||
void tick(int numticks = 1);
|
||||
void setLoopPoint();
|
||||
SafeWriter* finish();
|
||||
private:
|
||||
void flushWrites();
|
||||
void flushTicks();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,208 +0,0 @@
|
|||
/**
|
||||
* Furnace Tracker - multi-system chiptune tracker
|
||||
* Copyright (C) 2021-2024 tildearrow and contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "engine.h"
|
||||
#include "../ta-log.h"
|
||||
#include "../utfutils.h"
|
||||
#include "song.h"
|
||||
#include "zsm.h"
|
||||
|
||||
constexpr int MASTER_CLOCK_PREC=(sizeof(void*)==8)?8:0;
|
||||
constexpr int MASTER_CLOCK_MASK=(sizeof(void*)==8)?0xff:0;
|
||||
|
||||
SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop, bool optimize) {
|
||||
int VERA=-1;
|
||||
int YM=-1;
|
||||
int IGNORED=0;
|
||||
|
||||
// find indexes for YM and VERA. Ignore other systems.
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
switch (song.system[i]) {
|
||||
case DIV_SYSTEM_VERA:
|
||||
if (VERA>=0) {
|
||||
IGNORED++;
|
||||
break;
|
||||
}
|
||||
VERA=i;
|
||||
logD("VERA detected as chip id %d",i);
|
||||
break;
|
||||
case DIV_SYSTEM_YM2151:
|
||||
if (YM>=0) {
|
||||
IGNORED++;
|
||||
break;
|
||||
}
|
||||
YM=i;
|
||||
logD("YM detected as chip id %d",i);
|
||||
break;
|
||||
default:
|
||||
IGNORED++;
|
||||
logD("Ignoring chip %d systemID %d",i,(int)song.system[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (VERA<0 && YM<0) {
|
||||
logE("No supported systems for ZSM");
|
||||
return NULL;
|
||||
}
|
||||
if (IGNORED>0) {
|
||||
logW("ZSM export ignoring %d unsupported system%c",IGNORED,IGNORED>1?'s':' ');
|
||||
}
|
||||
|
||||
stop();
|
||||
repeatPattern=false;
|
||||
setOrder(0);
|
||||
BUSY_BEGIN_SOFT;
|
||||
|
||||
double origRate=got.rate;
|
||||
got.rate=zsmrate&0xffff;
|
||||
|
||||
// determine loop point
|
||||
int loopOrder=0;
|
||||
int loopRow=0;
|
||||
int loopEnd=0;
|
||||
walkSong(loopOrder,loopRow,loopEnd);
|
||||
logI("loop point: %d %d",loopOrder,loopRow);
|
||||
warnings="";
|
||||
|
||||
DivZSM zsm;
|
||||
zsm.init(zsmrate);
|
||||
|
||||
// reset the playback state
|
||||
curOrder=0;
|
||||
freelance=false;
|
||||
playing=false;
|
||||
extValuePresent=false;
|
||||
remainingLoops=-1;
|
||||
|
||||
// Prepare to write song data
|
||||
playSub(false);
|
||||
//size_t tickCount=0;
|
||||
bool done=false;
|
||||
bool loopNow=false;
|
||||
int loopPos=-1;
|
||||
int fracWait=0; // accumulates fractional ticks
|
||||
if (VERA>=0) disCont[VERA].dispatch->toggleRegisterDump(true);
|
||||
if (YM>=0) {
|
||||
disCont[YM].dispatch->toggleRegisterDump(true);
|
||||
// emit LFO initialization commands
|
||||
zsm.writeYM(0x18,0); // freq=0
|
||||
zsm.writeYM(0x19,0x7F); // AMD =7F
|
||||
zsm.writeYM(0x19,0xFF); // PMD =7F
|
||||
// TODO: incorporate the Furnace meta-command for init data and filter
|
||||
// out writes to otherwise-unused channels.
|
||||
}
|
||||
// Indicate the song's tuning as a sync meta-event
|
||||
// specified in terms of how many 1/256th semitones
|
||||
// the song is offset from standard A-440 tuning.
|
||||
// This is mainly to benefit visualizations in players
|
||||
// for non-standard tunings so that they can avoid
|
||||
// displaying the entire song held in pitch bend.
|
||||
// Tunings offsets that exceed a half semitone
|
||||
// will simply be represented in a different key
|
||||
// by nature of overflowing the signed char value
|
||||
signed char tuningoffset=(signed char)(round(3072*(log(song.tuning/440.0)/log(2))))&0xff;
|
||||
zsm.writeSync(0x01,tuningoffset);
|
||||
// Set optimize flag, which mainly buffers PSG writes
|
||||
// whenever the channel is silent
|
||||
zsm.setOptimize(optimize);
|
||||
|
||||
while (!done) {
|
||||
if (loopPos==-1) {
|
||||
if (loopOrder==curOrder && loopRow==curRow && loop)
|
||||
loopNow=true;
|
||||
if (loopNow) {
|
||||
// If Virtual Tempo is in use, our exact loop point
|
||||
// might be skipped due to quantization error.
|
||||
// If this happens, the tick immediately following is our loop point.
|
||||
if (ticks==1 || !(loopOrder==curOrder && loopRow==curRow)) {
|
||||
loopPos=zsm.getoffset();
|
||||
zsm.setLoopPoint();
|
||||
loopNow=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextTick() || !playing) {
|
||||
done=true;
|
||||
if (!loop) {
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
disCont[i].dispatch->getRegisterWrites().clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!playing) {
|
||||
loopPos=-1;
|
||||
}
|
||||
}
|
||||
// get register dumps
|
||||
for (int j=0; j<2; j++) {
|
||||
int i=0;
|
||||
// dump YM writes first
|
||||
if (j==0) {
|
||||
if (YM<0) {
|
||||
continue;
|
||||
} else {
|
||||
i=YM;
|
||||
}
|
||||
}
|
||||
// dump VERA writes second
|
||||
if (j==1) {
|
||||
if (VERA<0) {
|
||||
continue;
|
||||
} else {
|
||||
i=VERA;
|
||||
}
|
||||
}
|
||||
std::vector<DivRegWrite>& writes=disCont[i].dispatch->getRegisterWrites();
|
||||
if (writes.size()>0)
|
||||
logD("zsmOps: Writing %d messages to chip %d",writes.size(),i);
|
||||
for (DivRegWrite& write: writes) {
|
||||
if (i==YM) zsm.writeYM(write.addr&0xff,write.val);
|
||||
if (i==VERA) {
|
||||
if (done && write.addr>=64) continue; // don't process any PCM or sync events on the loop lookahead
|
||||
zsm.writePSG(write.addr&0xff,write.val);
|
||||
}
|
||||
}
|
||||
writes.clear();
|
||||
}
|
||||
|
||||
// write wait
|
||||
int totalWait=cycles>>MASTER_CLOCK_PREC;
|
||||
fracWait+=cycles&MASTER_CLOCK_MASK;
|
||||
totalWait+=fracWait>>MASTER_CLOCK_PREC;
|
||||
fracWait&=MASTER_CLOCK_MASK;
|
||||
if (totalWait>0 && !done) {
|
||||
zsm.tick(totalWait);
|
||||
//tickCount+=totalWait;
|
||||
}
|
||||
}
|
||||
// end of song
|
||||
|
||||
// done - close out.
|
||||
got.rate=origRate;
|
||||
if (VERA>=0) disCont[VERA].dispatch->toggleRegisterDump(false);
|
||||
if (YM>=0) disCont[YM].dispatch->toggleRegisterDump(false);
|
||||
|
||||
remainingLoops=-1;
|
||||
playing=false;
|
||||
freelance=false;
|
||||
extValuePresent=false;
|
||||
|
||||
BUSY_END;
|
||||
return zsm.finish();
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@ template<typename T, size_t items> struct FixedQueue {
|
|||
void clear();
|
||||
bool empty();
|
||||
size_t size();
|
||||
size_t capacity();
|
||||
FixedQueue():
|
||||
readPos(0),
|
||||
writePos(0) {}
|
||||
|
|
@ -177,4 +178,8 @@ template <typename T, size_t items> size_t FixedQueue<T,items>::size() {
|
|||
return writePos-readPos;
|
||||
}
|
||||
|
||||
template <typename T, size_t items> size_t FixedQueue<T,items>::capacity() {
|
||||
return items-1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ const char* aboutLine[]={
|
|||
_N("-- program --"),
|
||||
"tildearrow",
|
||||
_N("A M 4 N (intro tune)"),
|
||||
"Adam Lederer",
|
||||
"akumanatt",
|
||||
"cam900",
|
||||
"djtuBIG-MaliceX",
|
||||
|
|
@ -75,7 +76,7 @@ const char* aboutLine[]={
|
|||
"Polski: freq-mod, PoznańskiSzybkowiec",
|
||||
"Português (Brasil): Kagamiin~",
|
||||
"Русский: Background2982, LTVA",
|
||||
"Slovenčina: Mr. Hassium",
|
||||
"Slovenčina: Wegfrei",
|
||||
"Svenska: RevvoBolt",
|
||||
"ไทย: akumanatt",
|
||||
"",
|
||||
|
|
@ -180,6 +181,7 @@ const char* aboutLine[]={
|
|||
"Slightly Large NC",
|
||||
"smaybius",
|
||||
"SnugglyBun",
|
||||
"Someone64",
|
||||
"Spinning Square Waves",
|
||||
"src3453",
|
||||
"SuperJet Spade",
|
||||
|
|
@ -205,6 +207,7 @@ const char* aboutLine[]={
|
|||
"Ultraprogramer",
|
||||
"UserSniper",
|
||||
"Weeppiko",
|
||||
"Wegfrei",
|
||||
"Xan",
|
||||
"Yuzu4K",
|
||||
"Zabir",
|
||||
|
|
@ -299,6 +302,7 @@ const char* aboutLine[]={
|
|||
_N("NDS sound emulator by cam900"),
|
||||
"",
|
||||
_N("greetings to:"),
|
||||
"floxy!",
|
||||
"NEOART Costa Rica",
|
||||
"Xenium Demoparty",
|
||||
"@party",
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ void FurnaceGUI::drawCSPlayer() {
|
|||
ImGui::TableNextColumn();
|
||||
ImGui::Text(_("vols"));
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(_("volst"));
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(_("vib"));
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(_("porta"));
|
||||
|
|
@ -189,6 +191,8 @@ void FurnaceGUI::drawCSPlayer() {
|
|||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%+d",state->volSpeed);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%+d",state->volSpeedTarget);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d/%d (%d)",state->vibratoDepth,state->vibratoRate,state->vibratoPos);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("-> %d (%d)",state->portaTarget,state->portaSpeed);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ void FurnaceGUI::startSelection(int xCoarse, int xFine, int y, bool fullRow) {
|
|||
selStart.y=y;
|
||||
selEnd.y=y;
|
||||
} else {
|
||||
if (xCoarse!=cursor.xCoarse || y!=cursor.y) {
|
||||
makeCursorUndo();
|
||||
}
|
||||
cursor.xCoarse=xCoarse;
|
||||
cursor.xFine=xFine;
|
||||
cursor.y=y;
|
||||
|
|
@ -208,6 +211,9 @@ void FurnaceGUI::finishSelection() {
|
|||
}
|
||||
|
||||
void FurnaceGUI::moveCursor(int x, int y, bool select) {
|
||||
if (y>=editStepCoarse || y<=-editStepCoarse || x<=-5 || x>=5 ) {
|
||||
makeCursorUndo();
|
||||
}
|
||||
if (!select) {
|
||||
finishSelection();
|
||||
}
|
||||
|
|
@ -326,6 +332,7 @@ void FurnaceGUI::moveCursor(int x, int y, bool select) {
|
|||
}
|
||||
|
||||
void FurnaceGUI::moveCursorPrevChannel(bool overflow) {
|
||||
makeCursorUndo();
|
||||
finishSelection();
|
||||
curNibble=false;
|
||||
|
||||
|
|
@ -354,6 +361,7 @@ void FurnaceGUI::moveCursorPrevChannel(bool overflow) {
|
|||
}
|
||||
|
||||
void FurnaceGUI::moveCursorNextChannel(bool overflow) {
|
||||
makeCursorUndo();
|
||||
finishSelection();
|
||||
curNibble=false;
|
||||
|
||||
|
|
@ -382,6 +390,7 @@ void FurnaceGUI::moveCursorNextChannel(bool overflow) {
|
|||
}
|
||||
|
||||
void FurnaceGUI::moveCursorTop(bool select) {
|
||||
makeCursorUndo();
|
||||
if (!select) {
|
||||
finishSelection();
|
||||
}
|
||||
|
|
@ -403,6 +412,7 @@ void FurnaceGUI::moveCursorTop(bool select) {
|
|||
}
|
||||
|
||||
void FurnaceGUI::moveCursorBottom(bool select) {
|
||||
makeCursorUndo();
|
||||
if (!select) {
|
||||
finishSelection();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ static float oscDebugMax=1.0;
|
|||
static float oscDebugPower=1.0;
|
||||
static int oscDebugRepeat=1;
|
||||
static int numApples=1;
|
||||
static int getGainChan=0;
|
||||
static int getGainVol=0;
|
||||
|
||||
static void _drawOsc(const ImDrawList* drawList, const ImDrawCmd* cmd) {
|
||||
if (cmd!=NULL) {
|
||||
|
|
@ -143,6 +145,7 @@ void FurnaceGUI::drawDebug() {
|
|||
ImGui::Text("- portaNote = %d",ch->portaNote);
|
||||
ImGui::Text("- volume = %.4x",ch->volume);
|
||||
ImGui::Text("- volSpeed = %d",ch->volSpeed);
|
||||
ImGui::Text("- volSpeedTarget = %d",ch->volSpeedTarget);
|
||||
ImGui::Text("- cut = %d",ch->cut);
|
||||
ImGui::Text("- rowDelay = %d",ch->rowDelay);
|
||||
ImGui::Text("- volMax = %.4x",ch->volMax);
|
||||
|
|
@ -721,6 +724,32 @@ void FurnaceGUI::drawDebug() {
|
|||
ImGui::TreePop();
|
||||
}
|
||||
#endif
|
||||
if (ImGui::TreeNode("Get Gain Test")) {
|
||||
float realVol=e->getGain(getGainChan,getGainVol);
|
||||
ImGui::InputInt("Chan",&getGainChan);
|
||||
ImGui::InputInt("Vol",&getGainVol);
|
||||
ImGui::Text("result: %.0f%%",realVol*100.0f);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("Cursor Undo Debug")) {
|
||||
auto DrawSpot=[&](const CursorJumpPoint& spot) {
|
||||
ImGui::Text("[%d:%d] <%d:%d, %d>", spot.subSong, spot.order, spot.point.xCoarse, spot.point.xFine, spot.point.y);
|
||||
};
|
||||
if (ImGui::BeginChild("##CursorUndoDebugChild", ImVec2(0, 300), true)) {
|
||||
if (ImGui::BeginTable("##CursorUndoDebug", 2, ImGuiTableFlags_Borders|ImGuiTableFlags_SizingStretchSame)) {
|
||||
for (size_t row=0; row<MAX(cursorUndoHist.size(),cursorRedoHist.size()); ++row) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (row<cursorUndoHist.size()) DrawSpot(cursorUndoHist[cursorUndoHist.size()-row-1]);
|
||||
ImGui::TableNextColumn();
|
||||
if (row<cursorRedoHist.size()) DrawSpot(cursorRedoHist[cursorRedoHist.size()-row-1]);
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("User Interface")) {
|
||||
if (ImGui::Button("Inspect")) {
|
||||
inspectorOpen=!inspectorOpen;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ void FurnaceGUI::doAction(int what) {
|
|||
case GUI_ACTION_UNDO:
|
||||
if (curWindow==GUI_WINDOW_SAMPLE_EDIT) {
|
||||
doUndoSample();
|
||||
} else if (curWindow==GUI_WINDOW_INS_EDIT) {
|
||||
doUndoInstrument();
|
||||
} else {
|
||||
doUndo();
|
||||
}
|
||||
|
|
@ -80,6 +82,8 @@ void FurnaceGUI::doAction(int what) {
|
|||
case GUI_ACTION_REDO:
|
||||
if (curWindow==GUI_WINDOW_SAMPLE_EDIT) {
|
||||
doRedoSample();
|
||||
} else if (curWindow==GUI_WINDOW_INS_EDIT) {
|
||||
doRedoInstrument();
|
||||
} else {
|
||||
doRedo();
|
||||
}
|
||||
|
|
@ -123,16 +127,16 @@ void FurnaceGUI::doAction(int what) {
|
|||
pendingStepUpdate=1;
|
||||
break;
|
||||
case GUI_ACTION_OCTAVE_UP:
|
||||
if (++curOctave>7) {
|
||||
curOctave=7;
|
||||
if (++curOctave>GUI_EDIT_OCTAVE_MAX) {
|
||||
curOctave=GUI_EDIT_OCTAVE_MAX;
|
||||
} else {
|
||||
e->autoNoteOffAll();
|
||||
failedNoteOn=false;
|
||||
}
|
||||
break;
|
||||
case GUI_ACTION_OCTAVE_DOWN:
|
||||
if (--curOctave<-5) {
|
||||
curOctave=-5;
|
||||
if (--curOctave<GUI_EDIT_OCTAVE_MIN) {
|
||||
curOctave=GUI_EDIT_OCTAVE_MIN;
|
||||
} else {
|
||||
e->autoNoteOffAll();
|
||||
failedNoteOn=false;
|
||||
|
|
@ -676,6 +680,15 @@ void FurnaceGUI::doAction(int what) {
|
|||
latchTarget=0;
|
||||
latchNibble=false;
|
||||
break;
|
||||
case GUI_ACTION_PAT_ABSORB_INSTRUMENT:
|
||||
doAbsorbInstrument();
|
||||
break;
|
||||
case GUI_ACTION_PAT_CURSOR_UNDO:
|
||||
doCursorUndo();
|
||||
break;
|
||||
case GUI_ACTION_PAT_CURSOR_REDO:
|
||||
doCursorRedo();
|
||||
break;
|
||||
|
||||
case GUI_ACTION_INS_LIST_ADD:
|
||||
if (settings.insTypeMenu) {
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ const bool mobileButtonPersist[32]={
|
|||
// page 1
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
|
|
@ -508,7 +508,7 @@ void FurnaceGUI::drawMobileControls() {
|
|||
mobileMenuOpen=false;
|
||||
doAction(GUI_ACTION_SAVE_AS);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(_("Export"))) {
|
||||
doAction(GUI_ACTION_EXPORT);
|
||||
}
|
||||
|
|
@ -533,6 +533,10 @@ void FurnaceGUI::drawMobileControls() {
|
|||
drawSpeed(true);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem(_("Comments"))) {
|
||||
drawNotes(true);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
break;
|
||||
|
|
@ -619,41 +623,6 @@ void FurnaceGUI::drawMobileControls() {
|
|||
if (ImGui::Button(_("Switch to Desktop Mode"))) {
|
||||
toggleMobileUI(!mobileUI);
|
||||
}
|
||||
|
||||
int numAmiga=0;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++;
|
||||
}
|
||||
|
||||
if (numAmiga) {
|
||||
ImGui::Text(_(
|
||||
"this is NOT ROM export! only use for making sure the\n"
|
||||
"Furnace Amiga emulator is working properly by\n"
|
||||
"comparing it with real Amiga output."
|
||||
));
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text(_("Directory"));
|
||||
ImGui::SameLine();
|
||||
ImGui::InputText("##AVDPath",&workingDirROMExport);
|
||||
if (ImGui::Button(_("Bake Data"))) {
|
||||
std::vector<DivROMExportOutput> out=e->buildROM(DIV_ROM_AMIGA_VALIDATION);
|
||||
if (workingDirROMExport.size()>0) {
|
||||
if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR;
|
||||
}
|
||||
for (DivROMExportOutput& i: out) {
|
||||
String path=workingDirROMExport+i.name;
|
||||
FILE* outFile=ps_fopen(path.c_str(),"wb");
|
||||
if (outFile!=NULL) {
|
||||
fwrite(i.data->getFinalBuf(),1,i.data->size(),outFile);
|
||||
fclose(outFile);
|
||||
}
|
||||
i.data->finish();
|
||||
delete i.data;
|
||||
}
|
||||
showError(fmt::sprintf(_("Done! Baked %d files."),(int)out.size()));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -682,8 +651,8 @@ void FurnaceGUI::drawEditControls() {
|
|||
ImGui::TableNextColumn();
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
if (ImGui::InputInt("##Octave",&curOctave,1,1)) {
|
||||
if (curOctave>7) curOctave=7;
|
||||
if (curOctave<-5) curOctave=-5;
|
||||
if (curOctave>GUI_EDIT_OCTAVE_MAX) curOctave=GUI_EDIT_OCTAVE_MAX;
|
||||
if (curOctave<GUI_EDIT_OCTAVE_MIN) curOctave=GUI_EDIT_OCTAVE_MIN;
|
||||
e->autoNoteOffAll();
|
||||
failedNoteOn=false;
|
||||
|
||||
|
|
@ -843,8 +812,8 @@ void FurnaceGUI::drawEditControls() {
|
|||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(96.0f*dpiScale);
|
||||
if (ImGui::InputInt("##Octave",&curOctave,1,1)) {
|
||||
if (curOctave>7) curOctave=7;
|
||||
if (curOctave<-5) curOctave=-5;
|
||||
if (curOctave>GUI_EDIT_OCTAVE_MAX) curOctave=GUI_EDIT_OCTAVE_MAX;
|
||||
if (curOctave<GUI_EDIT_OCTAVE_MIN) curOctave=GUI_EDIT_OCTAVE_MIN;
|
||||
e->autoNoteOffAll();
|
||||
failedNoteOn=false;
|
||||
|
||||
|
|
@ -961,8 +930,8 @@ void FurnaceGUI::drawEditControls() {
|
|||
float avail=ImGui::GetContentRegionAvail().x;
|
||||
ImGui::SetNextItemWidth(avail);
|
||||
if (ImGui::InputInt("##Octave",&curOctave,0,0)) {
|
||||
if (curOctave>7) curOctave=7;
|
||||
if (curOctave<-5) curOctave=-5;
|
||||
if (curOctave>GUI_EDIT_OCTAVE_MAX) curOctave=GUI_EDIT_OCTAVE_MAX;
|
||||
if (curOctave<GUI_EDIT_OCTAVE_MIN) curOctave=GUI_EDIT_OCTAVE_MIN;
|
||||
e->autoNoteOffAll();
|
||||
failedNoteOn=false;
|
||||
|
||||
|
|
@ -1128,8 +1097,8 @@ void FurnaceGUI::drawEditControls() {
|
|||
float avail=ImGui::GetContentRegionAvail().x;
|
||||
ImGui::SetNextItemWidth(avail);
|
||||
if (ImGui::InputInt("##Octave",&curOctave,1,1)) {
|
||||
if (curOctave>7) curOctave=7;
|
||||
if (curOctave<-5) curOctave=-5;
|
||||
if (curOctave>GUI_EDIT_OCTAVE_MAX) curOctave=GUI_EDIT_OCTAVE_MAX;
|
||||
if (curOctave<GUI_EDIT_OCTAVE_MIN) curOctave=GUI_EDIT_OCTAVE_MIN;
|
||||
e->autoNoteOffAll();
|
||||
failedNoteOn=false;
|
||||
|
||||
|
|
|
|||
|
|
@ -678,6 +678,7 @@ void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, Str
|
|||
|
||||
if (readClipboard) {
|
||||
if (settings.cursorPastePos) {
|
||||
makeCursorUndo();
|
||||
cursor.y=j;
|
||||
if (cursor.y>=e->curSubSong->patLen) cursor.y=e->curSubSong->patLen-1;
|
||||
selStart=cursor;
|
||||
|
|
@ -1220,6 +1221,7 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String
|
|||
|
||||
if (readClipboard) {
|
||||
if (settings.cursorPastePos) {
|
||||
makeCursorUndo();
|
||||
cursor.y=j;
|
||||
if (cursor.y>=e->curSubSong->patLen) cursor.y=e->curSubSong->patLen-1;
|
||||
selStart=cursor;
|
||||
|
|
@ -1823,6 +1825,55 @@ void FurnaceGUI::doExpandSong(int multiplier) {
|
|||
if (e->isPlaying()) e->play();
|
||||
}
|
||||
|
||||
void FurnaceGUI::doAbsorbInstrument() {
|
||||
bool foundIns=false;
|
||||
bool foundOctave=false;
|
||||
auto foundAll = [&]() { return foundIns && foundOctave; };
|
||||
|
||||
// search this order and all prior until we find all the data we need
|
||||
int orderIdx=curOrder;
|
||||
for (; orderIdx>=0 && !foundAll(); orderIdx--) {
|
||||
DivPattern* pat=e->curPat[cursor.xCoarse].getPattern(e->curOrders->ord[cursor.xCoarse][orderIdx],false);
|
||||
if (!pat) continue;
|
||||
|
||||
// start on current row when searching current order, but start from end when searching
|
||||
// prior orders.
|
||||
int searchStartRow=orderIdx==curOrder ? cursor.y : e->curSubSong->patLen-1;
|
||||
for (int i=searchStartRow; i>=0 && !foundAll(); i--) {
|
||||
|
||||
// absorb most recent instrument
|
||||
if (!foundIns && pat->data[i][2] >= 0) {
|
||||
foundIns=true;
|
||||
curIns=pat->data[i][2];
|
||||
}
|
||||
|
||||
// absorb most recent octave (i.e. set curOctave such that the "main row" (QWERTY) of
|
||||
// notes will result in an octave number equal to the previous note). make sure to
|
||||
// skip "special note values" like OFF/REL/=== and "none", since there won't be valid
|
||||
// octave values
|
||||
unsigned char note=pat->data[i][0];
|
||||
if (!foundOctave && note!=0 && note!=100 && note!=101 && note!=102) {
|
||||
foundOctave=true;
|
||||
|
||||
// decode octave data (was signed cast to unsigned char)
|
||||
int octave=pat->data[i][1];
|
||||
if (octave>128) octave-=256;
|
||||
|
||||
// @NOTE the special handling when note==12, which is really an octave above what's
|
||||
// stored in the octave data. without this handling, if you press Q, then
|
||||
// "ABSORB_INSTRUMENT", then Q again, you'd get a different octave!
|
||||
if (pat->data[i][0]==12) octave++;
|
||||
curOctave=CLAMP(octave-1, GUI_EDIT_OCTAVE_MIN, GUI_EDIT_OCTAVE_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no instrument has been set at this point, the only way to match it is to use "none"
|
||||
if (!foundIns) curIns=-1;
|
||||
|
||||
logD("doAbsorbInstrument -- searched %d orders", curOrder-orderIdx);
|
||||
}
|
||||
|
||||
void FurnaceGUI::doDrag() {
|
||||
int len=dragEnd.xCoarse-dragStart.xCoarse+1;
|
||||
|
||||
|
|
@ -2012,3 +2063,52 @@ void FurnaceGUI::doRedo() {
|
|||
|
||||
redoHist.pop_back();
|
||||
}
|
||||
|
||||
CursorJumpPoint FurnaceGUI::getCurrentCursorJumpPoint() {
|
||||
return CursorJumpPoint(cursor, curOrder, e->getCurrentSubSong());
|
||||
}
|
||||
|
||||
void FurnaceGUI::applyCursorJumpPoint(const CursorJumpPoint& spot) {
|
||||
cursor=spot.point;
|
||||
curOrder=MIN(e->curSubSong->ordersLen-1, spot.order);
|
||||
e->setOrder(curOrder);
|
||||
e->changeSongP(spot.subSong);
|
||||
if (!settings.cursorMoveNoScroll) {
|
||||
updateScroll(cursor.y);
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::makeCursorUndo() {
|
||||
CursorJumpPoint spot = getCurrentCursorJumpPoint();
|
||||
if (!cursorUndoHist.empty() && spot == cursorUndoHist.back()) return;
|
||||
|
||||
if (cursorUndoHist.size()>=settings.maxUndoSteps) cursorUndoHist.pop_front();
|
||||
cursorUndoHist.push_back(spot);
|
||||
|
||||
// redo history no longer relevant, we've changed timeline
|
||||
cursorRedoHist.clear();
|
||||
}
|
||||
|
||||
void FurnaceGUI::doCursorUndo() {
|
||||
if (cursorUndoHist.empty()) return;
|
||||
|
||||
// allow returning to current spot
|
||||
if (cursorRedoHist.size()>=settings.maxUndoSteps) cursorRedoHist.pop_front();
|
||||
cursorRedoHist.push_back(getCurrentCursorJumpPoint());
|
||||
|
||||
// apply spot
|
||||
applyCursorJumpPoint(cursorUndoHist.back());
|
||||
cursorUndoHist.pop_back();
|
||||
}
|
||||
|
||||
void FurnaceGUI::doCursorRedo() {
|
||||
if (cursorRedoHist.empty()) return;
|
||||
|
||||
// allow returning to current spot
|
||||
if (cursorUndoHist.size()>=settings.maxUndoSteps) cursorUndoHist.pop_front();
|
||||
cursorUndoHist.push_back(getCurrentCursorJumpPoint());
|
||||
|
||||
// apply spot
|
||||
applyCursorJumpPoint(cursorRedoHist.back());
|
||||
cursorRedoHist.pop_back();
|
||||
}
|
||||
|
|
@ -239,111 +239,126 @@ void FurnaceGUI::drawExportVGM(bool onWindow) {
|
|||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::drawExportZSM(bool onWindow) {
|
||||
void FurnaceGUI::drawExportROM(bool onWindow) {
|
||||
exitDisabledTimer=1;
|
||||
|
||||
ImGui::Text(_("Commander X16 Zsound Music File"));
|
||||
if (ImGui::InputInt(_("Tick Rate (Hz)"),&zsmExportTickRate,1,2)) {
|
||||
if (zsmExportTickRate<1) zsmExportTickRate=1;
|
||||
if (zsmExportTickRate>44100) zsmExportTickRate=44100;
|
||||
const DivROMExportDef* def=e->getROMExportDef(romTarget);
|
||||
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
if (ImGui::BeginCombo("##ROMTarget",def==NULL?"<select one>":def->name)) {
|
||||
for (int i=0; i<DIV_ROM_MAX; i++) {
|
||||
const DivROMExportDef* newDef=e->getROMExportDef((DivROMExportOptions)i);
|
||||
if (newDef!=NULL) {
|
||||
if (romExportAvail[i]) {
|
||||
if (ImGui::Selectable(newDef->name)) {
|
||||
romTarget=(DivROMExportOptions)i;
|
||||
romMultiFile=newDef->multiOutput;
|
||||
romConfig=DivConfig();
|
||||
if (newDef->fileExt==NULL) {
|
||||
romFilterName="";
|
||||
romFilterExt="";
|
||||
} else {
|
||||
romFilterName=newDef->fileType;
|
||||
romFilterExt=newDef->fileExt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::Checkbox(_("loop"),&zsmExportLoop);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox(_("optimize size"),&zsmExportOptimize);
|
||||
|
||||
if (def!=NULL) {
|
||||
ImGui::Text("by %s",def->author);
|
||||
|
||||
ImGui::TextWrapped("%s",def->description);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
bool altered=false;
|
||||
|
||||
switch (romTarget) {
|
||||
case DIV_ROM_TIUNA: {
|
||||
String asmBaseLabel=romConfig.getString("baseLabel","song");
|
||||
int firstBankSize=romConfig.getInt("firstBankSize",3072);
|
||||
int otherBankSize=romConfig.getInt("otherBankSize",4096-48);
|
||||
int sysToExport=romConfig.getInt("sysToExport",-1);
|
||||
|
||||
// TODO; validate label
|
||||
if (ImGui::InputText(_("base song label name"),&asmBaseLabel)) {
|
||||
altered=true;
|
||||
}
|
||||
if (ImGui::InputInt(_("max size in first bank"),&firstBankSize,1,100)) {
|
||||
if (firstBankSize<0) firstBankSize=0;
|
||||
if (firstBankSize>4096) firstBankSize=4096;
|
||||
altered=true;
|
||||
}
|
||||
if (ImGui::InputInt(_("max size in other banks"),&otherBankSize,1,100)) {
|
||||
if (otherBankSize<16) otherBankSize=16;
|
||||
if (otherBankSize>4096) otherBankSize=4096;
|
||||
altered=true;
|
||||
}
|
||||
|
||||
ImGui::Text(_("chip to export:"));
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
DivSystem sys=e->song.system[i];
|
||||
bool isTIA=(sys==DIV_SYSTEM_TIA);
|
||||
ImGui::BeginDisabled(!isTIA);
|
||||
if (ImGui::RadioButton(fmt::sprintf("%d. %s##_SYSV%d",i+1,getSystemName(e->song.system[i]),i).c_str(),sysToExport==i)) {
|
||||
sysToExport=i;
|
||||
altered=true;
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
if (altered) {
|
||||
romConfig.set("baseLabel",asmBaseLabel);
|
||||
romConfig.set("firstBankSize",firstBankSize);
|
||||
romConfig.set("otherBankSize",otherBankSize);
|
||||
romConfig.set("sysToExport",sysToExport);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DIV_ROM_ZSM: {
|
||||
int zsmExportTickRate=romConfig.getInt("zsmrate",60);
|
||||
bool zsmExportLoop=romConfig.getBool("loop",true);
|
||||
bool zsmExportOptimize=romConfig.getBool("optimize",true);
|
||||
|
||||
if (ImGui::InputInt(_("Tick Rate (Hz)"),&zsmExportTickRate,1,2)) {
|
||||
if (zsmExportTickRate<1) zsmExportTickRate=1;
|
||||
if (zsmExportTickRate>44100) zsmExportTickRate=44100;
|
||||
altered=true;
|
||||
}
|
||||
if (ImGui::Checkbox(_("loop"),&zsmExportLoop)) {
|
||||
altered=true;
|
||||
}
|
||||
if (ImGui::Checkbox(_("optimize size"),&zsmExportOptimize)) {
|
||||
altered=true;
|
||||
}
|
||||
if (altered) {
|
||||
romConfig.set("zsmrate",zsmExportTickRate);
|
||||
romConfig.set("loop",zsmExportLoop);
|
||||
romConfig.set("optimize",zsmExportOptimize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DIV_ROM_ABSTRACT:
|
||||
ImGui::TextWrapped("%s",_("select a target from the menu at the top of this dialog."));
|
||||
break;
|
||||
default:
|
||||
ImGui::TextWrapped("%s",_("this export method doesn't offer any options."));
|
||||
break;
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
||||
if (onWindow) {
|
||||
ImGui::Separator();
|
||||
if (ImGui::Button(_("Cancel"),ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
|
||||
ImGui::SameLine();
|
||||
}
|
||||
if (ImGui::Button(_("Export"),ImVec2(200.0f*dpiScale,0))) {
|
||||
openFileDialog(GUI_FILE_EXPORT_ZSM);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::drawExportTiuna(bool onWindow) {
|
||||
exitDisabledTimer=1;
|
||||
|
||||
ImGui::Text(_("for use with TIunA driver. outputs asm source."));
|
||||
ImGui::InputText(_("base song label name"),&asmBaseLabel); // TODO: validate label
|
||||
if (ImGui::InputInt(_("max size in first bank"),&tiunaFirstBankSize,1,100)) {
|
||||
if (tiunaFirstBankSize<0) tiunaFirstBankSize=0;
|
||||
if (tiunaFirstBankSize>4096) tiunaFirstBankSize=4096;
|
||||
}
|
||||
if (ImGui::InputInt(_("max size in other banks"),&tiunaOtherBankSize,1,100)) {
|
||||
if (tiunaOtherBankSize<16) tiunaOtherBankSize=16;
|
||||
if (tiunaOtherBankSize>4096) tiunaOtherBankSize=4096;
|
||||
}
|
||||
|
||||
ImGui::Text(_("chips to export:"));
|
||||
int selected=0;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
DivSystem sys=e->song.system[i];
|
||||
bool isTIA=sys==DIV_SYSTEM_TIA;
|
||||
ImGui::BeginDisabled((!isTIA) || (selected>=1));
|
||||
ImGui::Checkbox(fmt::sprintf("%d. %s##_SYSV%d",i+1,getSystemName(e->song.system[i]),i).c_str(),&willExport[i]);
|
||||
ImGui::EndDisabled();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
|
||||
if (!isTIA) {
|
||||
ImGui::SetTooltip(_("this chip is not supported by the file format!"));
|
||||
} else if (selected>=1) {
|
||||
ImGui::SetTooltip(_("only one Atari TIA is supported!"));
|
||||
}
|
||||
}
|
||||
if (isTIA && willExport[i]) selected++;
|
||||
}
|
||||
if (selected>0) {
|
||||
if (onWindow) {
|
||||
ImGui::Separator();
|
||||
if (ImGui::Button(_("Cancel"),ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
|
||||
ImGui::SameLine();
|
||||
}
|
||||
if (ImGui::Button(_("Export"),ImVec2(200.0f*dpiScale,0))) {
|
||||
openFileDialog(GUI_FILE_EXPORT_TIUNA);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
} else {
|
||||
ImGui::Text(_("nothing to export"));
|
||||
if (onWindow) {
|
||||
ImGui::Separator();
|
||||
if (ImGui::Button(_("Cancel"),ImVec2(400.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::drawExportAmigaVal(bool onWindow) {
|
||||
exitDisabledTimer=1;
|
||||
|
||||
ImGui::Text(_(
|
||||
"this is NOT ROM export! only use for making sure the\n"
|
||||
"Furnace Amiga emulator is working properly by\n"
|
||||
"comparing it with real Amiga output."
|
||||
));
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text(_("Directory"));
|
||||
ImGui::SameLine();
|
||||
ImGui::InputText("##AVDPath",&workingDirROMExport);
|
||||
if (onWindow) {
|
||||
ImGui::Separator();
|
||||
if (ImGui::Button(_("Cancel"),ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
|
||||
ImGui::SameLine();
|
||||
}
|
||||
if (ImGui::Button(_("Bake Data"),ImVec2(200.0f*dpiScale,0))) {
|
||||
std::vector<DivROMExportOutput> out=e->buildROM(DIV_ROM_AMIGA_VALIDATION);
|
||||
if (workingDirROMExport.size()>0) {
|
||||
if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR;
|
||||
}
|
||||
for (DivROMExportOutput& i: out) {
|
||||
String path=workingDirROMExport+i.name;
|
||||
FILE* outFile=ps_fopen(path.c_str(),"wb");
|
||||
if (outFile!=NULL) {
|
||||
fwrite(i.data->getFinalBuf(),1,i.data->size(),outFile);
|
||||
fclose(outFile);
|
||||
}
|
||||
i.data->finish();
|
||||
delete i.data;
|
||||
}
|
||||
showError(fmt::sprintf(_("Done! Baked %d files."),(int)out.size()));
|
||||
openFileDialog(GUI_FILE_EXPORT_ROM);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
|
@ -424,36 +439,9 @@ void FurnaceGUI::drawExport() {
|
|||
drawExportVGM(true);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
int numZSMCompat=0;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
if ((e->song.system[i]==DIV_SYSTEM_VERA) || (e->song.system[i]==DIV_SYSTEM_YM2151)) numZSMCompat++;
|
||||
}
|
||||
if (numZSMCompat>0) {
|
||||
if (ImGui::BeginTabItem(_("ZSM"))) {
|
||||
drawExportZSM(true);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
bool hasTiunaCompat=false;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
if (e->song.system[i]==DIV_SYSTEM_TIA) {
|
||||
hasTiunaCompat=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasTiunaCompat) {
|
||||
if (ImGui::BeginTabItem("TIunA")) {
|
||||
drawExportTiuna(true);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
int numAmiga=0;
|
||||
for (int i=0; i<e->song.systemLen; i++) {
|
||||
if (e->song.system[i]==DIV_SYSTEM_AMIGA) numAmiga++;
|
||||
}
|
||||
if (numAmiga && settings.iCannotWait) {
|
||||
if (ImGui::BeginTabItem(_("Amiga Validation"))) {
|
||||
drawExportAmigaVal(true);
|
||||
if (romExportExists) {
|
||||
if (ImGui::BeginTabItem(_("ROM"))) {
|
||||
drawExportROM(true);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
|
@ -478,14 +466,8 @@ void FurnaceGUI::drawExport() {
|
|||
case GUI_EXPORT_VGM:
|
||||
drawExportVGM(true);
|
||||
break;
|
||||
case GUI_EXPORT_ZSM:
|
||||
drawExportZSM(true);
|
||||
break;
|
||||
case GUI_EXPORT_TIUNA:
|
||||
drawExportTiuna(true);
|
||||
break;
|
||||
case GUI_EXPORT_AMIGA_VAL:
|
||||
drawExportAmigaVal(true);
|
||||
case GUI_EXPORT_ROM:
|
||||
drawExportROM(true);
|
||||
break;
|
||||
case GUI_EXPORT_TEXT:
|
||||
drawExportText(true);
|
||||
|
|
|
|||
|
|
@ -560,6 +560,7 @@ void FurnaceGUI::drawFindReplace() {
|
|||
if (ImGui::TableNextColumn()) {
|
||||
snprintf(tempID,1024,ICON_FA_CHEVRON_RIGHT "##_FR%d",index);
|
||||
if (ImGui::Selectable(tempID)) {
|
||||
makeCursorUndo();
|
||||
e->changeSongP(i.subsong);
|
||||
if (e->isPlaying()) {
|
||||
followPattern=false;
|
||||
|
|
|
|||
824
src/gui/gui.cpp
824
src/gui/gui.cpp
File diff suppressed because it is too large
Load diff
|
|
@ -137,6 +137,9 @@ enum FurnaceGUIRenderBackend {
|
|||
#define ngettext momo_ngettext
|
||||
#endif
|
||||
|
||||
#define GUI_EDIT_OCTAVE_MIN -5
|
||||
#define GUI_EDIT_OCTAVE_MAX 7
|
||||
|
||||
// TODO:
|
||||
// - add colors for FM envelope and waveform
|
||||
// - maybe add "alternate" color for FM modulators/carriers (a bit difficult)
|
||||
|
|
@ -600,8 +603,6 @@ enum FurnaceGUIFileDialogs {
|
|||
GUI_FILE_EXPORT_AUDIO_PER_SYS,
|
||||
GUI_FILE_EXPORT_AUDIO_PER_CHANNEL,
|
||||
GUI_FILE_EXPORT_VGM,
|
||||
GUI_FILE_EXPORT_ZSM,
|
||||
GUI_FILE_EXPORT_TIUNA,
|
||||
GUI_FILE_EXPORT_CMDSTREAM,
|
||||
GUI_FILE_EXPORT_TEXT,
|
||||
GUI_FILE_EXPORT_ROM,
|
||||
|
|
@ -653,10 +654,8 @@ enum FurnaceGUIExportTypes {
|
|||
|
||||
GUI_EXPORT_AUDIO=0,
|
||||
GUI_EXPORT_VGM,
|
||||
GUI_EXPORT_ZSM,
|
||||
GUI_EXPORT_TIUNA,
|
||||
GUI_EXPORT_ROM,
|
||||
GUI_EXPORT_CMD_STREAM,
|
||||
GUI_EXPORT_AMIGA_VAL,
|
||||
GUI_EXPORT_TEXT,
|
||||
GUI_EXPORT_DMF
|
||||
};
|
||||
|
|
@ -820,6 +819,9 @@ enum FurnaceGUIActions {
|
|||
GUI_ACTION_PAT_LATCH,
|
||||
GUI_ACTION_PAT_SCROLL_MODE,
|
||||
GUI_ACTION_PAT_CLEAR_LATCH,
|
||||
GUI_ACTION_PAT_ABSORB_INSTRUMENT,
|
||||
GUI_ACTION_PAT_CURSOR_UNDO,
|
||||
GUI_ACTION_PAT_CURSOR_REDO,
|
||||
GUI_ACTION_PAT_MAX,
|
||||
|
||||
GUI_ACTION_INS_LIST_MIN,
|
||||
|
|
@ -1105,6 +1107,22 @@ struct UndoStep {
|
|||
newPatLen(0) {}
|
||||
};
|
||||
|
||||
struct CursorJumpPoint {
|
||||
SelectionPoint point;
|
||||
int order;
|
||||
int subSong;
|
||||
CursorJumpPoint(const SelectionPoint& p, int o, int ss):
|
||||
point(p), order(o), subSong(ss) {}
|
||||
CursorJumpPoint():
|
||||
point(), order(0), subSong(0) {}
|
||||
bool operator== (const CursorJumpPoint& spot) {
|
||||
return point.xCoarse==spot.point.xCoarse && point.xFine==spot.point.xFine && point.y==spot.point.y && order==spot.order && subSong==spot.subSong;
|
||||
}
|
||||
bool operator!= (const CursorJumpPoint& spot) {
|
||||
return !(*this == spot);
|
||||
}
|
||||
};
|
||||
|
||||
// -1 = any
|
||||
struct MIDIBind {
|
||||
int type, channel, data1, data2;
|
||||
|
|
@ -1595,9 +1613,9 @@ class FurnaceGUI {
|
|||
int sampleTexW, sampleTexH;
|
||||
bool updateSampleTex;
|
||||
|
||||
String workingDir, fileName, clipboard, warnString, errorString, lastError, curFileName, nextFile, sysSearchQuery, newSongQuery, paletteQuery;
|
||||
String workingDir, fileName, clipboard, warnString, errorString, lastError, curFileName, nextFile, sysSearchQuery, newSongQuery, paletteQuery, sampleBankSearchQuery;
|
||||
String workingDirSong, workingDirIns, workingDirWave, workingDirSample, workingDirAudioExport;
|
||||
String workingDirVGMExport, workingDirZSMExport, workingDirROMExport;
|
||||
String workingDirVGMExport, workingDirROMExport;
|
||||
String workingDirFont, workingDirColors, workingDirKeybinds;
|
||||
String workingDirLayout, workingDirROM, workingDirTest;
|
||||
String workingDirConfig;
|
||||
|
|
@ -1607,6 +1625,7 @@ class FurnaceGUI {
|
|||
String folderString;
|
||||
|
||||
std::vector<DivSystem> sysSearchResults;
|
||||
std::vector<std::pair<DivSample*,bool>> sampleBankSearchResults;
|
||||
std::vector<FurnaceGUISysDef> newSongSearchResults;
|
||||
std::vector<int> paletteSearchResults;
|
||||
FixedQueue<String,32> recentFile;
|
||||
|
|
@ -1615,13 +1634,15 @@ class FurnaceGUI {
|
|||
std::vector<String> availRenderDrivers;
|
||||
std::vector<String> availAudioDrivers;
|
||||
|
||||
bool quit, warnQuit, willCommit, edit, editClone, isPatUnique, modified, displayError, displayExporting, vgmExportLoop, zsmExportLoop, zsmExportOptimize, vgmExportPatternHints;
|
||||
bool quit, warnQuit, willCommit, edit, editClone, isPatUnique, modified, displayError, displayExporting, vgmExportLoop, vgmExportPatternHints;
|
||||
bool vgmExportDirectStream, displayInsTypeList, displayWaveSizeList;
|
||||
bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed;
|
||||
bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
|
||||
bool displayNew, displayExport, displayPalette, fullScreen, preserveChanPos, sysDupCloneChannels, sysDupEnd, noteInputPoly, notifyWaveChange;
|
||||
bool wantScrollListIns, wantScrollListWave, wantScrollListSample;
|
||||
bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString;
|
||||
bool displayPendingSamples, replacePendingSample;
|
||||
bool displayExportingROM;
|
||||
bool changeCoarse;
|
||||
bool mobileEdit;
|
||||
bool killGraphics;
|
||||
|
|
@ -1634,10 +1655,6 @@ class FurnaceGUI {
|
|||
int vgmExportTrailingTicks;
|
||||
int cvHiScore;
|
||||
int drawHalt;
|
||||
int zsmExportTickRate;
|
||||
String asmBaseLabel;
|
||||
int tiunaFirstBankSize;
|
||||
int tiunaOtherBankSize;
|
||||
int macroPointSize;
|
||||
int waveEditStyle;
|
||||
int displayInsTypeListMakeInsSample;
|
||||
|
|
@ -1726,6 +1743,16 @@ class FurnaceGUI {
|
|||
char emptyLabel[32];
|
||||
char emptyLabel2[32];
|
||||
|
||||
std::vector<int> songOrdersLengths; // lengths of all orders (for drawing song export progress)
|
||||
int songLength; // length of all the song in rows
|
||||
int songLoopedSectionLength; // length of looped part of the song
|
||||
int songFadeoutSectionLength; // length of fading part of the song
|
||||
bool songHasSongEndCommand; // song has "Song end" command (FFxx)
|
||||
int lengthOfOneFile; // length of one rendering pass. song length times num of loops + fadeout
|
||||
int totalLength; // total length of render (lengthOfOneFile times num of files for per-channel export)
|
||||
float curProgress;
|
||||
int totalFiles;
|
||||
|
||||
struct Settings {
|
||||
bool settingsChanged;
|
||||
int mainFontSize, patFontSize, headFontSize, iconSize;
|
||||
|
|
@ -1963,6 +1990,7 @@ class FurnaceGUI {
|
|||
unsigned int maxUndoSteps;
|
||||
float vibrationStrength;
|
||||
int vibrationLength;
|
||||
int s3mOPL3;
|
||||
String mainFontPath;
|
||||
String headFontPath;
|
||||
String patFontPath;
|
||||
|
|
@ -2219,6 +2247,7 @@ class FurnaceGUI {
|
|||
maxUndoSteps(100),
|
||||
vibrationStrength(0.5f),
|
||||
vibrationLength(20),
|
||||
s3mOPL3(1),
|
||||
mainFontPath(""),
|
||||
headFontPath(""),
|
||||
patFontPath(""),
|
||||
|
|
@ -2260,6 +2289,9 @@ class FurnaceGUI {
|
|||
std::vector<ImWchar> localeExtraRanges;
|
||||
|
||||
DivInstrument* prevInsData;
|
||||
DivInstrument cachedCurIns;
|
||||
DivInstrument* cachedCurInsPtr;
|
||||
bool insEditMayBeDirty;
|
||||
|
||||
unsigned char* pendingLayoutImport;
|
||||
size_t pendingLayoutImportLen;
|
||||
|
|
@ -2375,6 +2407,7 @@ class FurnaceGUI {
|
|||
std::vector<DivCommand> cmdStream;
|
||||
std::vector<Particle> particles;
|
||||
std::vector<std::pair<DivInstrument*,bool>> pendingIns;
|
||||
std::vector<std::pair<DivSample*,bool>> pendingSamples;
|
||||
|
||||
std::vector<FurnaceGUISysCategory> sysCategories;
|
||||
|
||||
|
|
@ -2487,6 +2520,8 @@ class FurnaceGUI {
|
|||
std::map<unsigned short,DivPattern*> oldPatMap;
|
||||
FixedQueue<UndoStep,256> undoHist;
|
||||
FixedQueue<UndoStep,256> redoHist;
|
||||
FixedQueue<CursorJumpPoint,256> cursorUndoHist;
|
||||
FixedQueue<CursorJumpPoint,256> cursorRedoHist;
|
||||
|
||||
// sample editor specific
|
||||
double sampleZoom;
|
||||
|
|
@ -2681,6 +2716,17 @@ class FurnaceGUI {
|
|||
int dmfExportVersion;
|
||||
FurnaceGUIExportTypes curExportType;
|
||||
|
||||
// ROM export specific
|
||||
DivROMExportOptions romTarget;
|
||||
DivConfig romConfig;
|
||||
bool romMultiFile;
|
||||
bool romExportSave;
|
||||
String romFilterName, romFilterExt;
|
||||
String romExportPath;
|
||||
DivROMExport* pendingExport;
|
||||
bool romExportAvail[DIV_ROM_MAX];
|
||||
bool romExportExists;
|
||||
|
||||
// user presets window
|
||||
std::vector<int> selectedUserPreset;
|
||||
|
||||
|
|
@ -2688,9 +2734,7 @@ class FurnaceGUI {
|
|||
|
||||
void drawExportAudio(bool onWindow=false);
|
||||
void drawExportVGM(bool onWindow=false);
|
||||
void drawExportZSM(bool onWindow=false);
|
||||
void drawExportTiuna(bool onWindow=false);
|
||||
void drawExportAmigaVal(bool onWindow=false);
|
||||
void drawExportROM(bool onWindow=false);
|
||||
void drawExportText(bool onWindow=false);
|
||||
void drawExportCommand(bool onWindow=false);
|
||||
void drawExportDMF(bool onWindow=false);
|
||||
|
|
@ -2730,6 +2774,7 @@ class FurnaceGUI {
|
|||
bool portSet(String label, unsigned int portSetID, int ins, int outs, int activeIns, int activeOuts, int& clickedPort, std::map<unsigned int,ImVec2>& portPos);
|
||||
|
||||
void updateWindowTitle();
|
||||
void updateROMExportAvail();
|
||||
void autoDetectSystem();
|
||||
void autoDetectSystemIter(std::vector<FurnaceGUISysDef>& category, bool& isMatch, std::map<DivSystem,int>& defCountMap, std::map<DivSystem,DivConfig>& defConfMap, std::map<DivSystem,int>& sysCountMap, std::map<DivSystem,DivConfig>& sysConfMap);
|
||||
void prepareLayout();
|
||||
|
|
@ -2809,7 +2854,7 @@ class FurnaceGUI {
|
|||
void drawMemory();
|
||||
void drawCompatFlags();
|
||||
void drawPiano();
|
||||
void drawNotes();
|
||||
void drawNotes(bool asChild=false);
|
||||
void drawChannels();
|
||||
void drawPatManager();
|
||||
void drawSysManager();
|
||||
|
|
@ -2899,22 +2944,33 @@ class FurnaceGUI {
|
|||
void doExpand(int multiplier, const SelectionPoint& sStart, const SelectionPoint& sEnd);
|
||||
void doCollapseSong(int divider);
|
||||
void doExpandSong(int multiplier);
|
||||
void doAbsorbInstrument();
|
||||
void doUndo();
|
||||
void doRedo();
|
||||
void doFind();
|
||||
void doReplace();
|
||||
void doDrag();
|
||||
void editOptions(bool topMenu);
|
||||
DivSystem systemPicker();
|
||||
DivSystem systemPicker(bool fullWidth);
|
||||
void noteInput(int num, int key, int vol=-1);
|
||||
void valueInput(int num, bool direct=false, int target=-1);
|
||||
void orderInput(int num);
|
||||
|
||||
void doGenerateWave();
|
||||
|
||||
CursorJumpPoint getCurrentCursorJumpPoint();
|
||||
void applyCursorJumpPoint(const CursorJumpPoint& spot);
|
||||
void makeCursorUndo();
|
||||
void doCursorUndo();
|
||||
void doCursorRedo();
|
||||
|
||||
void doUndoSample();
|
||||
void doRedoSample();
|
||||
|
||||
void checkRecordInstrumentUndoStep();
|
||||
void doUndoInstrument();
|
||||
void doRedoInstrument();
|
||||
|
||||
void play(int row=0);
|
||||
void setOrder(unsigned char order, bool forced=false);
|
||||
void stop();
|
||||
|
|
|
|||
|
|
@ -475,8 +475,8 @@ const FurnaceGUIColors fxColors[256]={
|
|||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
GUI_COLOR_PATTERN_EFFECT_VOLUME,
|
||||
GUI_COLOR_PATTERN_EFFECT_VOLUME,
|
||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||
|
|
@ -689,6 +689,9 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
|
|||
D("PAT_LATCH", _N("Set note input latch"), 0),
|
||||
D("PAT_SCROLL_MODE", _N("Change mobile scroll mode"), 0),
|
||||
D("PAT_CLEAR_LATCH", _N("Clear note input latch"), 0),
|
||||
D("PAT_ABSORB_INSTRUMENT", _N("Absorb instrument/octave from status at cursor"), 0),
|
||||
D("PAT_CURSOR_UNDO", _N("Return cursor to previous jump point"), 0),
|
||||
D("PAT_CURSOR_REDO", _N("Reverse recent cursor undo"), 0),
|
||||
D("PAT_MAX", "", NOT_AN_ACTION),
|
||||
|
||||
D("INS_LIST_MIN", _N("---Instrument list"), NOT_AN_ACTION),
|
||||
|
|
|
|||
|
|
@ -5251,6 +5251,7 @@ void FurnaceGUI::drawInsEdit() {
|
|||
ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(canvasW,canvasH));
|
||||
}
|
||||
if (ImGui::Begin("Instrument Editor",&insEditOpen,globalWinFlags|(settings.allowEditDocking?0:ImGuiWindowFlags_NoDocking),_("Instrument Editor"))) {
|
||||
DivInstrument* ins=NULL;
|
||||
if (curIns==-2) {
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY()+(ImGui::GetContentRegionAvail().y-ImGui::GetFrameHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y)*0.5f);
|
||||
CENTER_TEXT(_("waiting..."));
|
||||
|
|
@ -5278,6 +5279,7 @@ void FurnaceGUI::drawInsEdit() {
|
|||
curIns=i;
|
||||
wavePreviewInit=true;
|
||||
updateFMPreview=true;
|
||||
ins = e->song.ins[curIns];
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
|
|
@ -5300,7 +5302,7 @@ void FurnaceGUI::drawInsEdit() {
|
|||
ImGui::EndTable();
|
||||
}
|
||||
} else {
|
||||
DivInstrument* ins=e->song.ins[curIns];
|
||||
ins=e->song.ins[curIns];
|
||||
if (updateFMPreview) {
|
||||
renderFMPreview(ins);
|
||||
updateFMPreview=false;
|
||||
|
|
@ -7185,6 +7187,8 @@ void FurnaceGUI::drawInsEdit() {
|
|||
macroList.push_back(FurnaceGUIMacroDesc(_("Noise"),&ins->std.dutyMacro,0,8,160,uiColors[GUI_COLOR_MACRO_NOISE]));
|
||||
}
|
||||
macroList.push_back(FurnaceGUIMacroDesc(_("Waveform"),&ins->std.waveMacro,0,waveCount,160,uiColors[GUI_COLOR_MACRO_WAVE],false,NULL,NULL,false,NULL));
|
||||
macroList.push_back(FurnaceGUIMacroDesc(_("Panning (left)"),&ins->std.panLMacro,0,15,46,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL));
|
||||
macroList.push_back(FurnaceGUIMacroDesc(_("Panning (right)"),&ins->std.panRMacro,0,15,46,uiColors[GUI_COLOR_MACRO_OTHER]));
|
||||
macroList.push_back(FurnaceGUIMacroDesc(_("Pitch"),&ins->std.pitchMacro,-2048,2047,160,uiColors[GUI_COLOR_MACRO_PITCH],true,macroRelativeMode));
|
||||
macroList.push_back(FurnaceGUIMacroDesc(_("Phase Reset"),&ins->std.phaseResetMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true));
|
||||
break;
|
||||
|
|
@ -7585,6 +7589,10 @@ void FurnaceGUI::drawInsEdit() {
|
|||
macroList.push_back(FurnaceGUIMacroDesc(_("Timer Num"),&ins->std.ex8Macro,0,15,64,uiColors[GUI_COLOR_MACRO_OTHER]));
|
||||
macroList.push_back(FurnaceGUIMacroDesc(_("Timer Den"),&ins->std.fmsMacro,0,15,64,uiColors[GUI_COLOR_MACRO_OTHER]));
|
||||
macroList.push_back(FurnaceGUIMacroDesc(_("PWM Boundary"),&ins->std.amsMacro,0,15,64,uiColors[GUI_COLOR_MACRO_OTHER]));
|
||||
// workaround, because the gui will not set
|
||||
// zoom or scroll if we're not in macros tab
|
||||
ins->std.ex7Macro.vZoom=128;
|
||||
ins->std.ex7Macro.vScroll=2048-64;
|
||||
drawMacros(macroList,macroEditStateMacros);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
|
@ -7751,6 +7759,63 @@ void FurnaceGUI::drawInsEdit() {
|
|||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_INS_EDIT;
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void FurnaceGUI::checkRecordInstrumentUndoStep() {
|
||||
if (insEditOpen && curIns>=0 && curIns<(int)e->song.ins.size()) {
|
||||
DivInstrument* ins=e->song.ins[curIns];
|
||||
|
||||
// invalidate cachedCurIns/any possible changes if the cachedCurIns was referencing a different
|
||||
// instrument altgoether
|
||||
bool insChanged=ins!=cachedCurInsPtr;
|
||||
if (insChanged) {
|
||||
insEditMayBeDirty=false;
|
||||
cachedCurInsPtr=ins;
|
||||
cachedCurIns=*ins;
|
||||
}
|
||||
|
||||
cachedCurInsPtr=ins;
|
||||
|
||||
// check against the last cached to see if diff -- note that modifications to instruments
|
||||
// happen outside drawInsEdit (e.g. cursor inputs are processed and can directly modify
|
||||
// macro data). but don't check until we think the user input is complete.
|
||||
bool delayDiff=ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseDown(ImGuiMouseButton_Right) || ImGui::GetIO().WantCaptureKeyboard;
|
||||
if (!delayDiff && insEditMayBeDirty) {
|
||||
bool hasChange=ins->recordUndoStepIfChanged(e->processTime, &cachedCurIns);
|
||||
if (hasChange) {
|
||||
cachedCurIns=*ins;
|
||||
}
|
||||
insEditMayBeDirty=false;
|
||||
}
|
||||
} else {
|
||||
cachedCurInsPtr=NULL;
|
||||
insEditMayBeDirty=false;
|
||||
}
|
||||
}
|
||||
|
||||
void FurnaceGUI::doUndoInstrument() {
|
||||
if (!insEditOpen) return;
|
||||
if (curIns<0 || curIns>=(int)e->song.ins.size()) return;
|
||||
DivInstrument* ins=e->song.ins[curIns];
|
||||
// is locking the engine necessary? copied from doUndoSample
|
||||
e->lockEngine([this,ins]() {
|
||||
ins->undo();
|
||||
cachedCurInsPtr=ins;
|
||||
cachedCurIns=*ins;
|
||||
});
|
||||
}
|
||||
|
||||
void FurnaceGUI::doRedoInstrument() {
|
||||
if (!insEditOpen) return;
|
||||
if (curIns<0 || curIns>=(int)e->song.ins.size()) return;
|
||||
DivInstrument* ins=e->song.ins[curIns];
|
||||
// is locking the engine necessary? copied from doRedoSample
|
||||
e->lockEngine([this,ins]() {
|
||||
ins->redo();
|
||||
cachedCurInsPtr=ins;
|
||||
cachedCurIns=*ins;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ void FurnaceGUI::drawNewSong() {
|
|||
selEnd=SelectionPoint();
|
||||
cursor=SelectionPoint();
|
||||
updateWindowTitle();
|
||||
updateROMExportAvail();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1500,6 +1500,7 @@ void FurnaceGUI::drawPattern() {
|
|||
i.cmd==DIV_CMD_HINT_PORTA ||
|
||||
i.cmd==DIV_CMD_HINT_LEGATO ||
|
||||
i.cmd==DIV_CMD_HINT_VOL_SLIDE ||
|
||||
i.cmd==DIV_CMD_HINT_VOL_SLIDE_TARGET ||
|
||||
i.cmd==DIV_CMD_HINT_ARPEGGIO ||
|
||||
i.cmd==DIV_CMD_HINT_PITCH ||
|
||||
i.cmd==DIV_CMD_HINT_VIBRATO ||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
#include "../ta-utils.h"
|
||||
|
||||
struct FurnacePlotArrayGetterData
|
||||
{
|
||||
const float* Values;
|
||||
|
|
@ -270,12 +272,13 @@ int PlotBitfieldEx(const char* label, int (*values_getter)(void* data, int idx),
|
|||
float lineHeight=ImGui::GetTextLineHeight()/2.0;
|
||||
for (int i=0; i<bits && overlay_text[i]; i++) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text,ImVec4(0,0,0,1.0f));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x-1, frame_bb.Min.y-lineHeight-1), ImVec2(frame_bb.Max.x-1,frame_bb.Max.y+lineHeight-1), overlay_text[i], NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x-1, frame_bb.Min.y-lineHeight+1), ImVec2(frame_bb.Max.x-1,frame_bb.Max.y+lineHeight+1), overlay_text[i], NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x+1, frame_bb.Min.y-lineHeight-1), ImVec2(frame_bb.Max.x+1,frame_bb.Max.y+lineHeight-1), overlay_text[i], NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x+1, frame_bb.Min.y-lineHeight+1), ImVec2(frame_bb.Max.x+1,frame_bb.Max.y+lineHeight+1), overlay_text[i], NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
const char* text=_(overlay_text[i]);
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x-1, frame_bb.Min.y-lineHeight-1), ImVec2(frame_bb.Max.x-1,frame_bb.Max.y+lineHeight-1), text, NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x-1, frame_bb.Min.y-lineHeight+1), ImVec2(frame_bb.Max.x-1,frame_bb.Max.y+lineHeight+1), text, NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x+1, frame_bb.Min.y-lineHeight-1), ImVec2(frame_bb.Max.x+1,frame_bb.Max.y+lineHeight-1), text, NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x+1, frame_bb.Min.y-lineHeight+1), ImVec2(frame_bb.Max.x+1,frame_bb.Max.y+lineHeight+1), text, NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y-lineHeight), ImVec2(frame_bb.Max.x,frame_bb.Max.y+lineHeight), overlay_text[i], NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
ImGui::RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y-lineHeight), ImVec2(frame_bb.Max.x,frame_bb.Max.y+lineHeight), text, NULL, NULL, ImVec2(0.0f, (0.5+double(bits-1-i))/double(bits)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1208,6 +1208,41 @@ void FurnaceGUI::initSystemPresets() {
|
|||
CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "")
|
||||
}
|
||||
);
|
||||
SUB_ENTRY(
|
||||
"Sega TeraDrive", {
|
||||
CH(DIV_SYSTEM_YM2612, 1.0f, 0, ""),
|
||||
CH(DIV_SYSTEM_SMS, 0.5f, 0, ""),
|
||||
CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "")
|
||||
}
|
||||
);
|
||||
SUB_SUB_ENTRY(
|
||||
"Sega TeraDrive (extended channel 3)", {
|
||||
CH(DIV_SYSTEM_YM2612_EXT, 1.0f, 0, ""),
|
||||
CH(DIV_SYSTEM_SMS, 0.5f, 0, ""),
|
||||
CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "")
|
||||
}
|
||||
);
|
||||
SUB_SUB_ENTRY(
|
||||
"Sega TeraDrive (CSM)", {
|
||||
CH(DIV_SYSTEM_YM2612_CSM, 1.0f, 0, ""),
|
||||
CH(DIV_SYSTEM_SMS, 0.5f, 0, ""),
|
||||
CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "")
|
||||
}
|
||||
);
|
||||
SUB_SUB_ENTRY(
|
||||
"Sega TeraDrive (DualPCM)", {
|
||||
CH(DIV_SYSTEM_YM2612_DUALPCM, 1.0f, 0, ""),
|
||||
CH(DIV_SYSTEM_SMS, 0.5f, 0, ""),
|
||||
CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "")
|
||||
}
|
||||
);
|
||||
SUB_SUB_ENTRY(
|
||||
"Sega TeraDrive (DualPCM, extended channel 3)", {
|
||||
CH(DIV_SYSTEM_YM2612_DUALPCM_EXT, 1.0f, 0, ""),
|
||||
CH(DIV_SYSTEM_SMS, 0.5f, 0, ""),
|
||||
CH(DIV_SYSTEM_PCSPKR, 1.0f, 0, "")
|
||||
}
|
||||
);
|
||||
ENTRY(
|
||||
"Sharp X1", {
|
||||
CH(DIV_SYSTEM_AY8910, 1.0f, 0, "clockSel=3")
|
||||
|
|
|
|||
|
|
@ -253,16 +253,27 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
SAMPLE_WARN(warnLength,"QSound: maximum sample length is 65535");
|
||||
}
|
||||
break;
|
||||
case DIV_SYSTEM_NES:
|
||||
case DIV_SYSTEM_NES: {
|
||||
if (sample->loop) {
|
||||
if (sample->loopStart!=0 || sample->loopEnd!=(int)(sample->samples)) {
|
||||
SAMPLE_WARN(warnLoopPos,_("NES: loop point ignored on DPCM (may only loop entire sample)"));
|
||||
if (sample->loopStart&511) {
|
||||
int tryWith=(sample->loopStart)&(~511);
|
||||
if (tryWith>(int)sample->samples) tryWith-=512;
|
||||
String alignHint=fmt::sprintf(_("NES: loop start must be a multiple of 512 (try with %d)"),tryWith);
|
||||
SAMPLE_WARN(warnLoopStart,alignHint);
|
||||
}
|
||||
if ((sample->loopEnd-8)&127) {
|
||||
int tryWith=(sample->loopEnd-8)&(~127);
|
||||
if (tryWith>(int)sample->samples) tryWith-=128;
|
||||
tryWith+=8; // +1 bc of how sample length is treated: https://www.nesdev.org/wiki/APU_DMC
|
||||
String alignHint=fmt::sprintf(_("NES: loop end must be a multiple of 128 (try with %d)"),tryWith);
|
||||
SAMPLE_WARN(warnLoopEnd,alignHint);
|
||||
}
|
||||
}
|
||||
if (sample->samples>32648) {
|
||||
SAMPLE_WARN(warnLength,_("NES: maximum DPCM sample length is 32648"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DIV_SYSTEM_X1_010:
|
||||
if (sample->loop) {
|
||||
SAMPLE_WARN(warnLoop,_("X1-010: samples can't loop"));
|
||||
|
|
|
|||
|
|
@ -1084,15 +1084,19 @@ void FurnaceGUI::drawSettings() {
|
|||
ImGui::PushID(i);
|
||||
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize(_("Invert")).x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0);
|
||||
if (ImGui::BeginCombo("##System",getSystemName(sysID))) {
|
||||
for (int j=0; availableSystems[j]; j++) {
|
||||
if (ImGui::Selectable(getSystemName((DivSystem)availableSystems[j]),sysID==availableSystems[j])) {
|
||||
sysID=(DivSystem)availableSystems[j];
|
||||
settings.initialSys.set(fmt::sprintf("id%d",i),(int)e->systemToFileFur(sysID));
|
||||
settings.initialSys.set(fmt::sprintf("flags%d",i),"");
|
||||
settingsChanged=true;
|
||||
}
|
||||
if (ImGui::BeginCombo("##System",getSystemName(sysID),ImGuiComboFlags_HeightLargest)) {
|
||||
|
||||
sysID=systemPicker(true);
|
||||
|
||||
if (sysID!=DIV_SYSTEM_NULL)
|
||||
{
|
||||
settings.initialSys.set(fmt::sprintf("id%d",i),(int)e->systemToFileFur(sysID));
|
||||
settings.initialSys.set(fmt::sprintf("flags%d",i),"");
|
||||
settingsChanged=true;
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
|
|
@ -1254,6 +1258,14 @@ void FurnaceGUI::drawSettings() {
|
|||
}
|
||||
popDestColor();
|
||||
|
||||
// SUBSECTION IMPORT
|
||||
CONFIG_SUBSECTION(_("Import"));
|
||||
bool s3mOPL3B=settings.s3mOPL3;
|
||||
if (ImGui::Checkbox(_("Use OPL3 instead of OPL2 for S3M import"),&s3mOPL3B)) {
|
||||
settings.s3mOPL3=s3mOPL3B;
|
||||
settingsChanged=true;
|
||||
}
|
||||
|
||||
END_SECTION;
|
||||
}
|
||||
CONFIG_SECTION(_("Audio")) {
|
||||
|
|
@ -2415,6 +2427,9 @@ void FurnaceGUI::drawSettings() {
|
|||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_EXPAND_SONG);
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_LATCH);
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_CLEAR_LATCH);
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_ABSORB_INSTRUMENT);
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_CURSOR_UNDO);
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_PAT_CURSOR_REDO);
|
||||
|
||||
KEYBIND_CONFIG_END;
|
||||
ImGui::TreePop();
|
||||
|
|
@ -4747,6 +4762,8 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
|
|||
settings.vibrationStrength=conf.getFloat("vibrationStrength",0.5f);
|
||||
settings.vibrationLength=conf.getInt("vibrationLength",20);
|
||||
|
||||
settings.s3mOPL3=conf.getInt("s3mOPL3",1);
|
||||
|
||||
settings.backupEnable=conf.getInt("backupEnable",1);
|
||||
settings.backupInterval=conf.getInt("backupInterval",30);
|
||||
settings.backupMaxCopies=conf.getInt("backupMaxCopies",5);
|
||||
|
|
@ -5259,6 +5276,7 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
|
|||
clampSetting(settings.backupMaxCopies,1,100);
|
||||
clampSetting(settings.autoFillSave,0,1);
|
||||
clampSetting(settings.autoMacroStepSize,0,1);
|
||||
clampSetting(settings.s3mOPL3,0,1);
|
||||
|
||||
if (settings.exportLoops<0.0) settings.exportLoops=0.0;
|
||||
if (settings.exportFadeOut<0.0) settings.exportFadeOut=0.0;
|
||||
|
|
@ -5332,6 +5350,8 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
|
|||
conf.set("vibrationStrength",settings.vibrationStrength);
|
||||
conf.set("vibrationLength",settings.vibrationLength);
|
||||
|
||||
conf.set("s3mOPL3",settings.s3mOPL3);
|
||||
|
||||
conf.set("backupEnable",settings.backupEnable);
|
||||
conf.set("backupInterval",settings.backupInterval);
|
||||
conf.set("backupMaxCopies",settings.backupMaxCopies);
|
||||
|
|
|
|||
|
|
@ -22,18 +22,23 @@
|
|||
|
||||
// NOTE: please don't ask me to enable text wrap.
|
||||
// Dear ImGui doesn't have that feature. D:
|
||||
void FurnaceGUI::drawNotes() {
|
||||
void FurnaceGUI::drawNotes(bool asChild) {
|
||||
if (nextWindow==GUI_WINDOW_NOTES) {
|
||||
notesOpen=true;
|
||||
ImGui::SetNextWindowFocus();
|
||||
nextWindow=GUI_WINDOW_NOTHING;
|
||||
}
|
||||
if (!notesOpen) return;
|
||||
if (ImGui::Begin("Song Comments",¬esOpen,globalWinFlags,_("Song Comments"))) {
|
||||
if (!notesOpen && !asChild) return;
|
||||
bool began=asChild?ImGui::BeginChild("Song Info##Song Information"):ImGui::Begin("Song Comments",¬esOpen,globalWinFlags,_("Song Comments"));
|
||||
if (began) {
|
||||
if (ImGui::InputTextMultiline("##SongNotes",&e->song.notes,ImGui::GetContentRegionAvail(),ImGuiInputTextFlags_UndoRedo)) {
|
||||
MARK_MODIFIED;
|
||||
}
|
||||
}
|
||||
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_NOTES;
|
||||
ImGui::End();
|
||||
if (!asChild && ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_NOTES;
|
||||
if (asChild) {
|
||||
ImGui::EndChild();
|
||||
} else {
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ void FurnaceGUI::drawSubSongs(bool asChild) {
|
|||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(id,i==e->getCurrentSubSong())) {
|
||||
makeCursorUndo();
|
||||
e->changeSongP(i);
|
||||
updateScroll(0);
|
||||
oldRow=0;
|
||||
|
|
@ -72,6 +73,7 @@ void FurnaceGUI::drawSubSongs(bool asChild) {
|
|||
if (!e->addSubSong()) {
|
||||
showError(_("too many subsongs!"));
|
||||
} else {
|
||||
makeCursorUndo();
|
||||
e->changeSongP(e->song.subsong.size()-1);
|
||||
updateScroll(0);
|
||||
oldRow=0;
|
||||
|
|
@ -92,6 +94,7 @@ void FurnaceGUI::drawSubSongs(bool asChild) {
|
|||
if (!e->duplicateSubSong(e->getCurrentSubSong())) {
|
||||
showError(_("too many subsongs!"));
|
||||
} else {
|
||||
makeCursorUndo();
|
||||
e->changeSongP(e->song.subsong.size()-1);
|
||||
updateScroll(0);
|
||||
oldRow=0;
|
||||
|
|
|
|||
|
|
@ -1969,6 +1969,9 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
|
|||
echoFilter[6]=flags.getInt("echoFilter6",0);
|
||||
echoFilter[7]=flags.getInt("echoFilter7",0);
|
||||
|
||||
bool interpolationOff=flags.getBool("interpolationOff",false);
|
||||
bool antiClick=flags.getBool("antiClick",true);
|
||||
|
||||
ImGui::Text(_("Volume scale:"));
|
||||
if (CWSliderInt(_("Left##VolScaleL"),&vsL,0,127)) {
|
||||
if (vsL<0) vsL=0;
|
||||
|
|
@ -2084,6 +2087,14 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
|
|||
ImGui::Text(_("sum: %d"),filterSum);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (ImGui::Checkbox(_("Disable Gaussian interpolation"),&interpolationOff)) {
|
||||
altered=true;
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox(_("Anti-click"),&antiClick)) {
|
||||
altered=true;
|
||||
}
|
||||
|
||||
if (altered) {
|
||||
e->lockSave([&]() {
|
||||
flags.set("volScaleL",127-vsL);
|
||||
|
|
@ -2102,6 +2113,8 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
|
|||
flags.set("echoFilter6",echoFilter[6]);
|
||||
flags.set("echoFilter7",echoFilter[7]);
|
||||
flags.set("echoMask",echoMask);
|
||||
flags.set("interpolationOff",interpolationOff);
|
||||
flags.set("antiClick",antiClick);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -2505,7 +2518,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
|
|||
break;
|
||||
}
|
||||
case DIV_SYSTEM_VERA: {
|
||||
int chipType=flags.getInt("chipType",1);
|
||||
int chipType=flags.getInt("chipType",2);
|
||||
|
||||
ImGui::Text(_("Chip revision:"));
|
||||
ImGui::Indent();
|
||||
|
|
@ -2517,6 +2530,10 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
|
|||
chipType=1;
|
||||
altered=true;
|
||||
}
|
||||
if (ImGui::RadioButton(_("V 47.0.2 (Tri/Saw PW XOR)"),chipType==2)) {
|
||||
chipType=2;
|
||||
altered=true;
|
||||
}
|
||||
ImGui::Unindent();
|
||||
|
||||
if (altered) {
|
||||
|
|
|
|||
|
|
@ -91,13 +91,18 @@ void FurnaceGUI::drawSysManager() {
|
|||
if (!e->duplicateSystem(i,sysDupCloneChannels,sysDupEnd)) {
|
||||
showError(fmt::sprintf(_("cannot clone chip! (%s)"),e->getLastError()));
|
||||
} else {
|
||||
if (e->song.autoSystem) {
|
||||
autoDetectSystem();
|
||||
updateWindowTitle();
|
||||
}
|
||||
updateROMExportAvail();
|
||||
MARK_MODIFIED;
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(_("Change##SysChange"));
|
||||
if (ImGui::BeginPopupContextItem("SysPickerC",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||
DivSystem picked=systemPicker();
|
||||
DivSystem picked=systemPicker(false);
|
||||
if (picked!=DIV_SYSTEM_NULL) {
|
||||
if (e->changeSystem(i,picked,preserveChanPos)) {
|
||||
MARK_MODIFIED;
|
||||
|
|
@ -105,6 +110,7 @@ void FurnaceGUI::drawSysManager() {
|
|||
autoDetectSystem();
|
||||
}
|
||||
updateWindowTitle();
|
||||
updateROMExportAvail();
|
||||
} else {
|
||||
showError(fmt::sprintf(_("cannot change chip! (%s)"),e->getLastError()));
|
||||
}
|
||||
|
|
@ -132,7 +138,7 @@ void FurnaceGUI::drawSysManager() {
|
|||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_FA_PLUS "##SysAdd");
|
||||
if (ImGui::BeginPopupContextItem("SysPickerA",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||
DivSystem picked=systemPicker();
|
||||
DivSystem picked=systemPicker(false);
|
||||
if (picked!=DIV_SYSTEM_NULL) {
|
||||
if (!e->addSystem(picked)) {
|
||||
showError(fmt::sprintf(_("cannot add chip! (%s)"),e->getLastError()));
|
||||
|
|
@ -143,6 +149,7 @@ void FurnaceGUI::drawSysManager() {
|
|||
autoDetectSystem();
|
||||
}
|
||||
updateWindowTitle();
|
||||
updateROMExportAvail();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include "guiConst.h"
|
||||
#include <imgui.h>
|
||||
|
||||
DivSystem FurnaceGUI::systemPicker() {
|
||||
DivSystem FurnaceGUI::systemPicker(bool fullWidth) {
|
||||
DivSystem ret=DIV_SYSTEM_NULL;
|
||||
DivSystem hoveredSys=DIV_SYSTEM_NULL;
|
||||
bool reissueSearch=false;
|
||||
|
|
@ -61,7 +61,7 @@ DivSystem FurnaceGUI::systemPicker() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (ImGui::BeginTable("SysList",1,ImGuiTableFlags_ScrollY,ImVec2(500.0f*dpiScale,200.0*dpiScale))) {
|
||||
if (ImGui::BeginTable("SysList",1,ImGuiTableFlags_ScrollY,ImVec2(fullWidth ? ImGui::GetContentRegionAvail().x : 500.0f*dpiScale,200.0f*dpiScale))) {
|
||||
if (sysSearchQuery.empty()) {
|
||||
// display chip list
|
||||
for (int j=0; curSysSection[j]; j++) {
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ void FurnaceGUI::drawUserPresets() {
|
|||
tempID=fmt::sprintf("%s##USystem",getSystemName(chip.sys));
|
||||
ImGui::Button(tempID.c_str(),ImVec2(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize(_("Invert")).x-ImGui::GetFrameHeightWithSpacing()*2.0-ImGui::GetStyle().ItemSpacing.x*2.0,0));
|
||||
if (ImGui::BeginPopupContextItem("SysPickerCU",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||
DivSystem picked=systemPicker();
|
||||
DivSystem picked=systemPicker(false);
|
||||
if (picked!=DIV_SYSTEM_NULL) {
|
||||
chip.sys=picked;
|
||||
mustBake=true;
|
||||
|
|
@ -456,7 +456,7 @@ void FurnaceGUI::drawUserPresets() {
|
|||
|
||||
ImGui::Button(ICON_FA_PLUS "##SysAddU");
|
||||
if (ImGui::BeginPopupContextItem("SysPickerU",ImGuiPopupFlags_MouseButtonLeft)) {
|
||||
DivSystem picked=systemPicker();
|
||||
DivSystem picked=systemPicker(false);
|
||||
if (picked!=DIV_SYSTEM_NULL) {
|
||||
preset->orig.push_back(FurnaceGUISysDefChip(picked,1.0f,0.0f,""));
|
||||
mustBake=true;
|
||||
|
|
@ -475,7 +475,8 @@ void FurnaceGUI::drawUserPresets() {
|
|||
ImGui::SetTooltip(_(
|
||||
"insert additional settings in `option=value` format.\n"
|
||||
"available options:\n"
|
||||
"- tickRate"
|
||||
"- tickRate \n"
|
||||
"- chanMask \n"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
30
src/main.cpp
30
src/main.cpp
|
|
@ -85,9 +85,7 @@ FurnaceCLI cli;
|
|||
|
||||
String outName;
|
||||
String vgmOutName;
|
||||
String zsmOutName;
|
||||
String cmdOutName;
|
||||
String tiunaOutName;
|
||||
int benchMode=0;
|
||||
int subsong=-1;
|
||||
DivAudioExportOptions exportOptions;
|
||||
|
|
@ -430,24 +428,12 @@ TAParamResult pVGMOut(String val) {
|
|||
return TA_PARAM_SUCCESS;
|
||||
}
|
||||
|
||||
TAParamResult pZSMOut(String val) {
|
||||
zsmOutName=val;
|
||||
e.setAudio(DIV_AUDIO_DUMMY);
|
||||
return TA_PARAM_SUCCESS;
|
||||
}
|
||||
|
||||
TAParamResult pCmdOut(String val) {
|
||||
cmdOutName=val;
|
||||
e.setAudio(DIV_AUDIO_DUMMY);
|
||||
return TA_PARAM_SUCCESS;
|
||||
}
|
||||
|
||||
TAParamResult pTiunaOut(String val) {
|
||||
tiunaOutName=val;
|
||||
e.setAudio(DIV_AUDIO_DUMMY);
|
||||
return TA_PARAM_SUCCESS;
|
||||
}
|
||||
|
||||
bool needsValue(String param) {
|
||||
for (size_t i=0; i<params.size(); i++) {
|
||||
if (params[i].name==param) {
|
||||
|
|
@ -464,9 +450,7 @@ void initParams() {
|
|||
params.push_back(TAParam("o","output",true,pOutput,"<filename>","output audio to file"));
|
||||
params.push_back(TAParam("O","vgmout",true,pVGMOut,"<filename>","output .vgm data"));
|
||||
params.push_back(TAParam("D","direct",false,pDirect,"","set VGM export direct stream mode"));
|
||||
params.push_back(TAParam("Z","zsmout",true,pZSMOut,"<filename>","output .zsm data for Commander X16 Zsound"));
|
||||
params.push_back(TAParam("C","cmdout",true,pCmdOut,"<filename>","output command stream"));
|
||||
params.push_back(TAParam("T","tiunaout",true,pTiunaOut,"<filename>","output .asm data with TIunA sound data (TIA only)"));
|
||||
params.push_back(TAParam("L","loglevel",true,pLogLevel,"debug|info|warning|error","set the log level (info by default)"));
|
||||
params.push_back(TAParam("v","view",true,pView,"pattern|commands|nothing","set visualization (nothing by default)"));
|
||||
params.push_back(TAParam("i","info",false,pInfo,"","get info about a song"));
|
||||
|
|
@ -568,9 +552,7 @@ int main(int argc, char** argv) {
|
|||
#endif
|
||||
outName="";
|
||||
vgmOutName="";
|
||||
zsmOutName="";
|
||||
cmdOutName="";
|
||||
tiunaOutName="";
|
||||
|
||||
// load config for locale
|
||||
e.prePreInit();
|
||||
|
|
@ -738,14 +720,14 @@ int main(int argc, char** argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (fileName.empty() && (benchMode || infoMode || outName!="" || vgmOutName!="" || zsmOutName!="" || cmdOutName!="" || tiunaOutName!="")) {
|
||||
if (fileName.empty() && (benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
||||
logE("provide a file!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GUI
|
||||
if (e.preInit(consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || zsmOutName!="" || cmdOutName!="" || tiunaOutName!="")) {
|
||||
if (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || zsmOutName!="" || cmdOutName!="" || tiunaOutName!="") {
|
||||
if (e.preInit(consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
||||
if (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="") {
|
||||
logW("engine wants safe mode, but Furnace GUI is not going to start.");
|
||||
} else {
|
||||
safeMode=true;
|
||||
|
|
@ -757,7 +739,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (safeMode && (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || zsmOutName!="" || cmdOutName!="" || tiunaOutName!="")) {
|
||||
if (safeMode && (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
||||
logE("you can't use safe mode and console/export mode together.");
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -766,7 +748,7 @@ int main(int argc, char** argv) {
|
|||
e.setAudio(DIV_AUDIO_DUMMY);
|
||||
}
|
||||
|
||||
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",TUT_INTRO_PLAYED)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || zsmOutName!="" || cmdOutName!="" || tiunaOutName!="")) {
|
||||
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",TUT_INTRO_PLAYED)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
|
||||
logI("loading module...");
|
||||
FILE* f=ps_fopen(fileName.c_str(),"rb");
|
||||
if (f==NULL) {
|
||||
|
|
@ -858,7 +840,7 @@ int main(int argc, char** argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (outName!="" || vgmOutName!="" || zsmOutName!="" || cmdOutName!="" || tiunaOutName!="") {
|
||||
if (outName!="" || vgmOutName!="" || cmdOutName!="") {
|
||||
if (cmdOutName!="") {
|
||||
SafeWriter* w=e.saveCommand();
|
||||
if (w!=NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue