chip sample selection, part 2

add functions to retrieve whether a sample was loaded in chip memory
eventually I'll put warning feedback on the sample list
This commit is contained in:
tildearrow 2022-11-26 18:44:04 -05:00
parent 1c8440b68d
commit 85cb64b227
29 changed files with 173 additions and 0 deletions

View File

@ -520,19 +520,34 @@ class DivDispatch {
/**
* Get sample memory buffer.
* @param index the memory index.
* @return a pointer to sample memory, or NULL.
*/
virtual const void* getSampleMem(int index = 0);
/**
* Get sample memory capacity.
* @param index the memory index.
* @return memory capacity in bytes, or 0 if memory doesn't exist.
*/
virtual size_t getSampleMemCapacity(int index = 0);
/**
* Get sample memory usage.
* @param index the memory index.
* @return memory usage in bytes.
*/
virtual size_t getSampleMemUsage(int index = 0);
/**
* check whether sample has been loaded in memory.
* @param memory index.
* @param sample the sample in question.
* @return whether it did.
*/
virtual bool isSampleLoaded(int index, int sample);
/**
* Render samples into sample memory.
*/

View File

@ -156,6 +156,10 @@ size_t DivDispatch::getSampleMemUsage(int index) {
return 0;
}
bool DivDispatch::isSampleLoaded(int index, int sample) {
return false;
}
void DivDispatch::renderSamples() {
}

View File

@ -362,6 +362,12 @@ size_t DivPlatformMSM6258::getSampleMemUsage(int index) {
return index == 0 ? adpcmMemLen : 0;
}
bool DivPlatformMSM6258::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformMSM6258::renderSamples() {
memset(adpcmMem,0,getSampleMemCapacity(0));

View File

@ -81,6 +81,7 @@ class DivPlatformMSM6258: public DivDispatch {
unsigned char* adpcmMem;
size_t adpcmMemLen;
bool sampleLoaded[256];
unsigned char sampleBank, msmPan, msmDivider, rateSel, msmClock, clockSel;
signed char msmDividerCount, msmClockCount;
short msmOut;
@ -113,6 +114,7 @@ class DivPlatformMSM6258: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View File

@ -335,6 +335,12 @@ size_t DivPlatformMSM6295::getSampleMemUsage(int index) {
return index == 0 ? adpcmMemLen : 0;
}
bool DivPlatformMSM6295::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformMSM6295::renderSamples() {
unsigned int sampleOffVOX[256];

View File

@ -68,6 +68,7 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf {
unsigned char* adpcmMem;
size_t adpcmMemLen;
bool sampleLoaded[256];
unsigned char sampleBank;
int delay, updateOsc;
@ -101,6 +102,7 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf {
virtual const void* getSampleMem(int index) override;
virtual size_t getSampleMemCapacity(int index) override;
virtual size_t getSampleMemUsage(int index) override;
virtual bool isSampleLoaded(int index, int sample) override;
virtual void renderSamples() override;
virtual int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags) override;

View File

@ -721,6 +721,12 @@ size_t DivPlatformNES::getSampleMemUsage(int index) {
return index==0?dpcmMemLen:0;
}
bool DivPlatformNES::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformNES::renderSamples() {
memset(dpcmMem,0,getSampleMemCapacity(0));

View File

@ -68,6 +68,7 @@ class DivPlatformNES: public DivDispatch {
int dacSample;
unsigned char* dpcmMem;
size_t dpcmMemLen;
bool sampleLoaded[256];
unsigned char dpcmBank;
unsigned char sampleBank;
unsigned char writeOscBuf;
@ -115,6 +116,7 @@ class DivPlatformNES: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View File

@ -1757,6 +1757,12 @@ size_t DivPlatformOPL::getSampleMemUsage(int index) {
return (index==0 && adpcmChan>=0) ? adpcmBMemLen : 0;
}
bool DivPlatformOPL::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformOPL::renderSamples() {
if (adpcmChan<0) return;
memset(adpcmBMem,0,getSampleMemCapacity(0));

View File

@ -91,6 +91,7 @@ class DivPlatformOPL: public DivDispatch {
size_t adpcmBMemLen;
DivOPLAInterface iface;
unsigned int sampleOffB[256];
bool sampleLoaded[256];
ymfm::adpcm_b_engine* adpcmB;
const unsigned char** slotsNonDrums;
@ -152,6 +153,7 @@ class DivPlatformOPL: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View File

@ -644,6 +644,12 @@ size_t DivPlatformQSound::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformQSound::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
// TODO: ADPCM... come on...
void DivPlatformQSound::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());

View File

@ -69,6 +69,7 @@ class DivPlatformQSound: public DivDispatch {
unsigned char* sampleMem;
size_t sampleMemLen;
bool sampleLoaded[256];
struct qsound_chip chip;
unsigned short regPool[512];
@ -103,6 +104,7 @@ class DivPlatformQSound: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View File

@ -385,6 +385,12 @@ size_t DivPlatformRF5C68::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformRF5C68::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformRF5C68::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOffRFC,0,256*sizeof(unsigned int));

View File

@ -67,6 +67,7 @@ class DivPlatformRF5C68: public DivDispatch {
int chipType;
unsigned char curChan;
unsigned int sampleOffRFC[256];
bool sampleLoaded[256];
unsigned char* sampleMem;
size_t sampleMemLen;
@ -99,6 +100,7 @@ class DivPlatformRF5C68: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View File

@ -797,6 +797,12 @@ size_t DivPlatformSNES::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformSNES::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformSNES::renderSamples() {
memset(copyOfSampleMem,0,getSampleMemCapacity());
memset(sampleOff,0,256*sizeof(unsigned int));

View File

@ -109,6 +109,7 @@ class DivPlatformSNES: public DivDispatch {
signed char copyOfSampleMem[65536];
size_t sampleMemLen;
unsigned int sampleOff[256];
bool sampleLoaded[256];
unsigned char regPool[0x80];
SPC_DSP dsp;
friend void putDispatchChan(void*,int,int);
@ -136,6 +137,7 @@ class DivPlatformSNES: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View File

@ -547,6 +547,12 @@ size_t DivPlatformSoundUnit::getSampleMemUsage(int index) {
return (index==0)?sampleMemLen:0;
}
bool DivPlatformSoundUnit::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformSoundUnit::renderSamples() {
memset(su->pcm,0,getSampleMemCapacity(0));
memset(sampleOffSU,0,256*sizeof(unsigned int));

View File

@ -102,6 +102,7 @@ class DivPlatformSoundUnit: public DivDispatch {
unsigned char initIlCtrl, initIlSize, initFil1;
signed char echoVol, initEchoVol;
unsigned int sampleOffSU[256];
bool sampleLoaded[256];
int cycles, curChan, delay;
short tempL;
@ -138,6 +139,7 @@ class DivPlatformSoundUnit: public DivDispatch {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();

View File

@ -949,6 +949,12 @@ size_t DivPlatformX1_010::getSampleMemUsage(int index) {
return index >= 0 ? sampleMemLen : 0;
}
bool DivPlatformX1_010::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformX1_010::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOffX1,0,256*sizeof(unsigned int));

View File

@ -116,6 +116,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
bool isBanked=false;
unsigned int bankSlot[8];
unsigned int sampleOffX1[256];
bool sampleLoaded[256];
unsigned char regPool[0x2000];
double NoteX1_010(int ch, int note);
@ -146,6 +147,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
const char** getRegisterSheet();
void setBanked(bool banked);

View File

@ -1336,6 +1336,12 @@ size_t DivPlatformYM2608::getSampleMemUsage(int index) {
return index == 0 ? adpcmBMemLen : 0;
}
bool DivPlatformYM2608::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformYM2608::renderSamples() {
memset(adpcmBMem,0,getSampleMemCapacity(0));
memset(sampleOffB,0,256*sizeof(unsigned int));

View File

@ -100,6 +100,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
size_t adpcmBMemLen;
DivYM2608Interface iface;
unsigned int sampleOffB[256];
bool sampleLoaded[256];
DivPlatformAY8910* ay;
unsigned char sampleBank;
@ -137,6 +138,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index);
bool isSampleLoaded(int index, int sample);
void renderSamples();
void setFlags(const DivConfig& flags);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View File

@ -142,6 +142,8 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
unsigned char sampleBank;
bool extMode, noExtMacros;
bool sampleLoaded[2][256];
unsigned char writeADPCMAOff, writeADPCMAOn;
int globalADPCMAVolume;
@ -208,10 +210,17 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
return index == 0 ? adpcmAMemLen : index == 1 ? adpcmBMemLen : 0;
}
bool isSampleLoaded(int index, int sample) {
if (index<0 || index>1) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[index][sample];
}
void renderSamples() {
memset(adpcmAMem,0,getSampleMemCapacity(0));
memset(sampleOffA,0,256*sizeof(unsigned int));
memset(sampleOffB,0,256*sizeof(unsigned int));
memset(sampleLoaded,0,256*2*sizeof(bool));
size_t memPos=0;
for (int i=0; i<parent->song.sampleLen; i++) {
@ -231,6 +240,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
memcpy(adpcmAMem+memPos,s->dataA,paddedLen);
}
sampleOffA[i]=memPos;
sampleLoaded[0][i]=true;
memPos+=paddedLen;
}
adpcmAMemLen=memPos+256;
@ -255,6 +265,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
memcpy(adpcmBMem+memPos,s->dataB,paddedLen);
}
sampleOffB[i]=memPos;
sampleLoaded[1][i]=true;
memPos+=paddedLen;
}
adpcmBMemLen=memPos+256;

View File

@ -420,6 +420,12 @@ size_t DivPlatformYMZ280B::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : 0;
}
bool DivPlatformYMZ280B::isSampleLoaded(int index, int sample) {
if (index!=0) return false;
if (sample<0 || sample>255) return false;
return sampleLoaded[sample];
}
void DivPlatformYMZ280B::renderSamples() {
memset(sampleMem,0,getSampleMemCapacity());
memset(sampleOff,0,256*sizeof(unsigned int));

View File

@ -67,6 +67,7 @@ class DivPlatformYMZ280B: public DivDispatch {
bool isMuted[8];
int chipType;
unsigned int sampleOff[256];
bool sampleLoaded[256];
unsigned char* sampleMem;
size_t sampleMemLen;
@ -99,6 +100,7 @@ class DivPlatformYMZ280B: public DivDispatch {
const void* getSampleMem(int index = 0);
size_t getSampleMemCapacity(int index = 0);
size_t getSampleMemUsage(int index = 0);
bool isSampleLoaded(int index, int sample);
void renderSamples();
void setFlags(const DivConfig& flags);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View File

@ -227,6 +227,13 @@ enum FurnaceGUIColors {
GUI_COLOR_SAMPLE_SEL,
GUI_COLOR_SAMPLE_SEL_POINT,
GUI_COLOR_SAMPLE_NEEDLE,
GUI_COLOR_SAMPLE_NEEDLE_PLAYING,
GUI_COLOR_SAMPLE_LOOP_POINT,
GUI_COLOR_SAMPLE_TIME_BG,
GUI_COLOR_SAMPLE_TIME_FG,
GUI_COLOR_SAMPLE_CHIP_DISABLED,
GUI_COLOR_SAMPLE_CHIP_ENABLED,
GUI_COLOR_SAMPLE_CHIP_WARNING,
GUI_COLOR_PAT_MANAGER_NULL,
GUI_COLOR_PAT_MANAGER_USED,

View File

@ -860,6 +860,13 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={
D(GUI_COLOR_SAMPLE_SEL,"",ImVec4(0.26f,0.59f,0.98f,0.25f)),
D(GUI_COLOR_SAMPLE_SEL_POINT,"",ImVec4(0.06f,0.53f,0.98f,0.5f)),
D(GUI_COLOR_SAMPLE_NEEDLE,"",ImVec4(1.0f,0.8f,0.0f,1.0f)),
D(GUI_COLOR_SAMPLE_NEEDLE_PLAYING,"",ImVec4(0.2f,1.0f,0.0f,1.0f)),
D(GUI_COLOR_SAMPLE_LOOP_POINT,"",ImVec4(1.0f,0.0f,0.0f,1.0f)),
D(GUI_COLOR_SAMPLE_TIME_BG,"",ImVec4(0.1f,0.11f,0.12f,1.0f)),
D(GUI_COLOR_SAMPLE_TIME_FG,"",ImVec4(0.4f,0.4f,0.4f,1.0f)),
D(GUI_COLOR_SAMPLE_CHIP_DISABLED,"",ImVec4(0.6f,0.6f,0.6f,1.0f)),
D(GUI_COLOR_SAMPLE_CHIP_ENABLED,"",ImVec4(0.3f,1.0f,0.3f,1.0f)),
D(GUI_COLOR_SAMPLE_CHIP_WARNING,"",ImVec4(1.0f,0.75f,0.3f,1.0f)),
D(GUI_COLOR_PAT_MANAGER_NULL,"",ImVec4(0.15f,0.15f,0.15f,1.0f)),
D(GUI_COLOR_PAT_MANAGER_USED,"",ImVec4(0.15f,1.0f,0.15f,1.0f)),

View File

@ -277,6 +277,7 @@ void FurnaceGUI::drawSampleEdit() {
bool isChipVisible[32];
bool isTypeVisible[4];
bool isMemVisible[4][32];
bool isMemWarning[4][32];
memset(isChipVisible,0,32*sizeof(bool));
memset(isTypeVisible,0,4*sizeof(bool));
memset(isMemVisible,0,32*4*sizeof(bool));
@ -289,6 +290,7 @@ void FurnaceGUI::drawSampleEdit() {
isChipVisible[i]=true;
isTypeVisible[j]=true;
isMemVisible[j][i]=true;
if (!dispatch->isSampleLoaded(j,curSample)) isMemWarning[j][i]=true;
}
}
int selColumns=1;
@ -319,9 +321,41 @@ void FurnaceGUI::drawSampleEdit() {
if (!isMemVisible[i][j]) continue;
snprintf(id,1023,"##_SEC%d_%d",i,j);
ImVec4 baseColor=sample->renderOn[i][j]?(isMemWarning[i][j]?uiColors[GUI_COLOR_SAMPLE_CHIP_WARNING]:uiColors[GUI_COLOR_SAMPLE_CHIP_ENABLED]):uiColors[GUI_COLOR_SAMPLE_CHIP_DISABLED];
ImVec4 color=baseColor;
ImVec4 colorHovered=baseColor;
ImVec4 colorActive=baseColor;
if (settings.guiColorsBase) {
color.x*=0.8f;
color.y*=0.8f;
color.z*=0.8f;
colorHovered.x*=0.65f;
colorHovered.y*=0.65f;
colorHovered.z*=0.65f;
colorActive.x*=0.3f;
colorActive.y*=0.3f;
colorActive.z*=0.3f;
} else {
color.x*=0.2f;
color.y*=0.2f;
color.z*=0.2f;
colorHovered.x*=0.4f;
colorHovered.y*=0.4f;
colorHovered.z*=0.4f;
}
ImGui::PushStyleColor(ImGuiCol_FrameBg,color);
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered,colorHovered);
ImGui::PushStyleColor(ImGuiCol_FrameBgActive,colorActive);
ImGui::PushStyleColor(ImGuiCol_CheckMark,baseColor);
if (ImGui::Checkbox(id,&sample->renderOn[i][j])) {
e->renderSamplesP();
}
ImGui::PopStyleColor(4);
}
}
ImGui::EndTable();

View File

@ -1843,12 +1843,19 @@ void FurnaceGUI::drawSettings() {
if (ImGui::TreeNode("Sample Editor")) {
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_BG,"Background");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_FG,"Waveform");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_TIME_BG,"Time background");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_TIME_FG,"Time text");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_LOOP,"Loop region");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_CENTER,"Center guide");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_GRID,"Grid");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_SEL,"Selection");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_SEL_POINT,"Selection points");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_NEEDLE,"Preview needle");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_NEEDLE_PLAYING,"Playing needles");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_LOOP_POINT,"Loop markers");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_CHIP_DISABLED,"Chip select: disabled");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_CHIP_ENABLED,"Chip select: enabled");
UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_CHIP_WARNING,"Chip select: enabled (failure)");
ImGui::TreePop();
}
if (ImGui::TreeNode("Pattern Manager")) {