giga-refactor, part 5

This commit is contained in:
tildearrow 2025-11-13 01:39:21 -05:00
parent 68768004b0
commit 5bde25cf2f
5 changed files with 39 additions and 18 deletions

View file

@ -654,6 +654,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
int curr_chan = 0;
int map_ch = 0;
ds.systemChans[systemID]=5;
ds.system[systemID++] = DIV_SYSTEM_NES;
ds.systemFlags[0].set("resetSweep",true); // FamiTracker behavior
@ -668,6 +669,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
if (expansions & 1) {
ds.systemChans[systemID]=3;
ds.system[systemID++] = DIV_SYSTEM_VRC6;
for (int ch = 0; ch < 3; ch++) {
@ -685,6 +687,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
vrc6_saw_chan = map_ch - 1;
}
if (expansions & 8) {
ds.systemChans[systemID]=3;
ds.system[systemID++] = DIV_SYSTEM_MMC5;
for (int ch = 0; ch < (eft ? 3 : 2); ch++) {
@ -707,6 +710,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
if (expansions & 16) {
ds.system[systemID] = DIV_SYSTEM_N163;
ds.systemFlags[systemID].set("channels", (int)n163Chans - 1);
ds.systemChans[systemID]=CLAMP(n163Chans,1,8);
systemID++;
for (int ch = 0; ch < (int)n163Chans; ch++) {
@ -716,12 +720,13 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
map_ch++;
}
for (int ch = 0; ch < (8 - (int)n163Chans); ch++) {
/*for (int ch = 0; ch < (8 - (int)n163Chans); ch++) {
map_channels[curr_chan] = map_ch; // do not populate and skip the missing N163 channels!
map_ch++;
}
}*/
}
if (expansions & 4) {
ds.systemChans[systemID]=1;
ds.system[systemID++] = DIV_SYSTEM_FDS;
map_channels[curr_chan] = map_ch;
@ -730,6 +735,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
map_ch++;
}
if (expansions & 2) {
ds.systemChans[systemID]=6;
ds.system[systemID++] = DIV_SYSTEM_VRC7;
for (int ch = 0; ch < 6; ch++) {
@ -741,6 +747,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
if (expansions & 32) {
ds.system[systemID] = DIV_SYSTEM_AY8910;
ds.systemChans[systemID]=3;
ds.systemFlags[systemID++].set("chipType", 2); // Sunsoft 5B
for (int ch = 0; ch < 3; ch++) {
@ -751,6 +758,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
}
if (expansions & 64) {
ds.systemChans[systemID]=3;
ds.system[systemID++] = DIV_SYSTEM_AY8930;
for (int ch = 0; ch < 3; ch++) {
@ -761,6 +769,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
}
if (expansions & 128) {
ds.systemChans[systemID]=6;
ds.system[systemID++] = DIV_SYSTEM_SAA1099;
for (int ch = 0; ch < 6; ch++) {
@ -770,6 +779,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
}
if (expansions & 256) {
ds.systemChans[systemID]=5;
ds.system[systemID++] = DIV_SYSTEM_5E01;
for (int ch = 0; ch < 5; ch++) {
@ -779,6 +789,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
}
if (expansions & 512) {
ds.systemChans[systemID]=3;
ds.system[systemID++] = DIV_SYSTEM_C64_6581;
for (int ch = 0; ch < 3; ch++) {
@ -788,6 +799,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
}
if (expansions & 1024) {
ds.systemChans[systemID]=3;
ds.system[systemID++] = DIV_SYSTEM_C64_8580;
for (int ch = 0; ch < 3; ch++) {
@ -797,6 +809,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
}
if (expansions & 2048) {
ds.systemChans[systemID]=4;
ds.system[systemID++] = DIV_SYSTEM_POKEY;
for (int ch = 0; ch < 4; ch++) {
@ -817,13 +830,8 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
calcChans--; // no PCM channel for MMC5 in famitracker
}
calcChans += getChannelCount(ds.system[i]);
total_chans += getChannelCount(ds.system[i]);
if (ds.system[i] == DIV_SYSTEM_N163) {
calcChans -= getChannelCount(ds.system[i]);
calcChans += (int)n163Chans;
}
calcChans += ds.systemChans[i];
total_chans += ds.systemChans[i];
}
if (calcChans != tchans) {
// TODO: would ignore trigger CVE? too bad if so!
@ -2802,7 +2810,6 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
}
}
ds.initDefaultSystemChans();
ds.recalcChans();
if (active) quitDispatch();

View file

@ -392,14 +392,24 @@ struct DivSong {
std::vector<DivEffectStorage> effects;
// INTERNAL STATE - do not modify.
/**
* INTERNAL STATE - do not modify.
*/
// default/"null" instruments (when instrument is none/-1)
DivInstrument nullIns, nullInsOPLL, nullInsOPL, nullInsOPLDrums, nullInsQSound, nullInsESFM;
// default assets, returned by getWave()/getSample() in DivEngine
DivWavetable nullWave;
DivSample nullSample;
// channel information arrays.
// chip of a channel
DivSystem sysOfChan[DIV_MAX_CHANS];
// dispatch (chip index) of a channel
int dispatchOfChan[DIV_MAX_CHANS];
// tracker channel to chip channel mapping
// -1 means "nowhere".
int dispatchChanOfChan[DIV_MAX_CHANS];
// the first channel of a chip, indexed per channel
int dispatchFirstChan[DIV_MAX_CHANS];
std::vector<DivInstrumentType> possibleInsTypes;

View file

@ -3083,7 +3083,7 @@ class FurnaceGUI {
void drawRefPlayer();
void drawMultiInsSetup();
float drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset=-1, float width=-1.0f);
float drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset=-1, float width=-1.0f, int chanCount=-1);
void drawSystemChannelInfoText(const DivSysDef* whichDef);
void drawVolMeterInternal(ImDrawList* dl, ImRect rect, float* data, int chans, bool aspectRatio);

View file

@ -145,7 +145,7 @@ void FurnaceGUI::drawSysManager() {
// channel LEDs and chip config button
float height=0;
if (settings.rackShowLEDs) {
height=drawSystemChannelInfo(sysDef,dispatchOff,ImGui::GetContentRegionAvail().x-(ImGui::CalcTextSize(ICON_FA_CHEVRON_DOWN).x+ImGui::GetStyle().ItemSpacing.x));
height=drawSystemChannelInfo(sysDef,dispatchOff,ImGui::GetContentRegionAvail().x-(ImGui::CalcTextSize(ICON_FA_CHEVRON_DOWN).x+ImGui::GetStyle().ItemSpacing.x),e->song.systemChans[i]);
}
ImGuiID openedID=ImGui::GetID("OpenSysConfig");
@ -168,7 +168,7 @@ void FurnaceGUI::drawSysManager() {
ImGui::EndChild();
ImGui::PopID();
dispatchOff+=sysDef->channels;
dispatchOff+=e->song.systemChans[i];
}
if (e->song.systemLen<DIV_MAX_CHIPS) {

View file

@ -296,24 +296,28 @@ const char* FurnaceGUI::getSystemPartNumber(DivSystem sys, DivConfig& flags) {
}
}
float FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset, float tooltipWidth) {
float FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef, int keyHitOffset, float tooltipWidth, int chanCount) {
if (whichDef==NULL) return 0;
if (chanCount<1) chanCount=whichDef->channels;
ImDrawList* dl=ImGui::GetWindowDrawList();
const ImVec2 p=ImGui::GetCursorScreenPos();
if (tooltipWidth<=0.0f) tooltipWidth=ImGui::GetContentRegionAvail().x;
ImVec2 sep=ImGui::GetStyle().ItemSpacing;
sep.x*=0.5f;
ImVec2 ledSize=ImVec2(
(tooltipWidth-sep.x*(whichDef->channels-1))/(float)whichDef->channels,
(tooltipWidth-sep.x*(chanCount-1))/(float)chanCount,
settings.iconSize*dpiScale
);
if (ledSize.x<8.0f*dpiScale) ledSize.x=8.0f*dpiScale;
float x=p.x, y=p.y;
for (int i=0; i<whichDef->channels; i++) {
for (int i=0; i<chanCount; i++) {
if (x+ledSize.x-0.125>tooltipWidth+p.x) {
x=p.x;
y+=ledSize.y+sep.y;
}
ImVec4 color=uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM];
ImVec4 color=uiColors[GUI_COLOR_CHANNEL_BG];
if (i<whichDef->channels) color=uiColors[whichDef->chanTypes[i]+GUI_COLOR_CHANNEL_FM];
if (keyHitOffset>=0) {
if (e->isChannelMuted(keyHitOffset+i)) {
color=uiColors[GUI_COLOR_CHANNEL_MUTED];