diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index f507ec64f..f2c1fc0a9 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -141,6 +141,10 @@ int DivEngine::getChannelCount(DivSystem sys) { return 0; } +int DivEngine::getTotalChannelCount() { + return chans; +} + const char* DivEngine::getSystemName(DivSystem sys) { switch (sys) { case DIV_SYSTEM_NULL: @@ -1579,7 +1583,7 @@ void DivEngine::stop() { } void DivEngine::reset() { - for (int i=0; i<17; i++) { + for (int i=0; idispatch(DivCommand(DIV_CMD_GET_VOLMAX,i))<<8)|0xff; chan[i].volume=chan[i].volMax; @@ -2132,7 +2136,7 @@ void DivEngine::quitDispatch() { totalCmds=0; lastCmds=0; cmdsPerSecond=0; - for (int i=0; i<17; i++) { + for (int i=0; i conf; std::queue pendingNotes; - bool isMuted[17]; + bool isMuted[DIV_MAX_CHANS]; std::mutex isBusy; String configPath; String configFile; @@ -211,7 +210,7 @@ class DivEngine { // get sys channel count int getChannelCount(DivSystem sys); - // TODO: get channel count + // get channel count int getTotalChannelCount(); // get channel type diff --git a/src/engine/orders.h b/src/engine/orders.h index f3e43ac53..eb8cc2e09 100644 --- a/src/engine/orders.h +++ b/src/engine/orders.h @@ -1,7 +1,7 @@ struct DivOrders { - unsigned char ord[32][128]; + unsigned char ord[DIV_MAX_CHANS][128]; DivOrders() { - memset(ord,0,32*128); + memset(ord,0,DIV_MAX_CHANS*128); } }; diff --git a/src/engine/platform/dummy.cpp b/src/engine/platform/dummy.cpp index f29524f0e..47a855a12 100644 --- a/src/engine/platform/dummy.cpp +++ b/src/engine/platform/dummy.cpp @@ -76,7 +76,7 @@ void DivPlatformDummy::reset() { int DivPlatformDummy::init(DivEngine* p, int channels, int sugRate, bool pal) { parent=p; skipRegisterWrites=false; - for (int i=0; i<17; i++) { + for (int i=0; i #include + +#define DIV_MAX_CHANS 128 + #include "../ta-utils.h" #include "orders.h" #include "instrument.h" @@ -94,7 +97,7 @@ struct DivSong { DivOrders orders; std::vector ins; - DivChannelData pat[17]; + DivChannelData pat[DIV_MAX_CHANS]; std::vector wave; std::vector sample; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 51c3b6fdc..aca3147da 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -382,7 +382,7 @@ void FurnaceGUI::drawOrders() { ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(1.0f*dpiScale,1.0f*dpiScale)); ImGui::Columns(2,NULL,false); ImGui::SetColumnWidth(-1,regionX-24.0f*dpiScale); - if (ImGui::BeginTable("OrdersTable",1+e->getChannelCount(e->song.system),ImGuiTableFlags_ScrollY)) { + if (ImGui::BeginTable("OrdersTable",1+e->getTotalChannelCount(),ImGuiTableFlags_ScrollY)) { ImGui::PushFont(patFont); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,prevSpacing); ImGui::TableSetupScrollFreeze(0,1); @@ -395,7 +395,7 @@ void FurnaceGUI::drawOrders() { ImGui::TableNextRow(0,lineHeight); ImGui::TableNextColumn(); ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_ROW_INDEX]); - for (int i=0; igetChannelCount(e->song.system); i++) { + for (int i=0; igetTotalChannelCount(); i++) { ImGui::TableNextColumn(); ImGui::Text("%s",e->getChannelShortName(i)); } @@ -410,14 +410,14 @@ void FurnaceGUI::drawOrders() { e->setOrder(i); } ImGui::PopStyleColor(); - for (int j=0; jgetChannelCount(e->song.system); j++) { + for (int j=0; jgetTotalChannelCount(); j++) { ImGui::TableNextColumn(); snprintf(selID,64,"%.2x##O_%.2x_%.2x",e->song.orders.ord[j][i],j,i); if (ImGui::Selectable(selID)) { if (e->getOrder()==i) { prepareUndo(GUI_ACTION_CHANGE_ORDER); if (changeAllOrders) { - for (int k=0; kgetChannelCount(e->song.system); k++) { + for (int k=0; kgetTotalChannelCount(); k++) { if (e->song.orders.ord[k][i]<0x7f) e->song.orders.ord[k][i]++; } } else { @@ -432,7 +432,7 @@ void FurnaceGUI::drawOrders() { if (e->getOrder()==i) { prepareUndo(GUI_ACTION_CHANGE_ORDER); if (changeAllOrders) { - for (int k=0; kgetChannelCount(e->song.system); k++) { + for (int k=0; kgetTotalChannelCount(); k++) { if (e->song.orders.ord[k][i]>0) e->song.orders.ord[k][i]--; } } else { @@ -1088,7 +1088,7 @@ void FurnaceGUI::drawPattern() { ImGui::PushFont(patFont); unsigned char ord=e->isPlaying()?oldOrder:e->getOrder(); oldOrder=e->getOrder(); - int chans=e->getChannelCount(e->song.system); + int chans=e->getTotalChannelCount(); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding,ImVec2(0.0f,0.0f)); ImGui::PushStyleColor(ImGuiCol_Header,uiColors[GUI_COLOR_PATTERN_SELECTION]); ImGui::PushStyleColor(ImGuiCol_HeaderHovered,uiColors[GUI_COLOR_PATTERN_SELECTION_HOVER]); @@ -1670,8 +1670,8 @@ void FurnaceGUI::moveCursor(int x, int y) { for (int i=0; i=3+e->song.pat[cursor.xCoarse].effectRows*2) { cursor.xFine=0; - if (++cursor.xCoarse>=e->getChannelCount(e->song.system)) { - cursor.xCoarse=e->getChannelCount(e->song.system)-1; + if (++cursor.xCoarse>=e->getTotalChannelCount()) { + cursor.xCoarse=e->getTotalChannelCount()-1; cursor.xFine=2+e->song.pat[cursor.xCoarse].effectRows*2; } } @@ -1724,7 +1724,7 @@ void FurnaceGUI::prepareUndo(ActionType action) { case GUI_ACTION_PATTERN_PUSH: case GUI_ACTION_PATTERN_CUT: case GUI_ACTION_PATTERN_PASTE: - for (int i=0; i<17; i++) { + for (int i=0; igetTotalChannelCount(); i++) { memcpy(oldPat[i],e->song.pat[i].getPattern(e->song.orders.ord[i][order],false),sizeof(DivPattern)); } break; @@ -1772,7 +1772,7 @@ void FurnaceGUI::makeUndo(ActionType action) { case GUI_ACTION_PATTERN_PUSH: case GUI_ACTION_PATTERN_CUT: case GUI_ACTION_PATTERN_PASTE: - for (int i=0; i<17; i++) { + for (int i=0; igetTotalChannelCount(); i++) { DivPattern* p=e->song.pat[i].getPattern(e->song.orders.ord[i][order],false); for (int j=0; jsong.patLen; j++) { for (int k=0; k<16; k++) { @@ -1802,7 +1802,7 @@ void FurnaceGUI::doSelectAll() { if (selStart.y==0 && selEnd.y==e->song.patLen-1) { // select entire pattern selStart.xCoarse=0; selStart.xFine=0; - selEnd.xCoarse=e->getChannelCount(e->song.system)-1; + selEnd.xCoarse=e->getTotalChannelCount()-1; selEnd.xFine=2+e->song.pat[selEnd.xCoarse].effectRows*2; } else { // select entire column selStart.y=0; @@ -2008,7 +2008,7 @@ void FurnaceGUI::doPaste() { String& line=data[i]; - while (charPosgetChannelCount(e->song.system)) { + while (charPosgetTotalChannelCount()) { DivPattern* pat=e->song.pat[iCoarse].getPattern(e->song.orders.ord[iCoarse][ord],true); if (line[charPos]=='|') { iCoarse++; @@ -3009,7 +3009,7 @@ bool FurnaceGUI::init() { updateWindowTitle(); - for (int i=0; i<17; i++) { + for (int i=0; isetConf("lastDir",workingDir); - for (int i=0; i<17; i++) { + for (int i=0; i undoHist; std::deque redoHist;