From a6eec9f7c4296598050060fffa44fbe09c7630a5 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 12 Mar 2022 02:24:23 -0500 Subject: [PATCH] GUI: implement randomize --- src/gui/gui.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2d3342fe..e4803494 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3201,6 +3201,34 @@ void FurnaceGUI::doRandomize(int bottom, int top) { finishSelection(); prepareUndo(GUI_UNDO_PATTERN_RANDOMIZE); + int iCoarse=selStart.xCoarse; + int iFine=selStart.xFine; + int ord=e->getOrder(); + for (; iCoarse<=selEnd.xCoarse; iCoarse++) { + if (!e->song.chanShow[iCoarse]) continue; + DivPattern* pat=e->song.pat[iCoarse].getPattern(e->song.orders.ord[iCoarse][ord],true); + for (; iFine<3+e->song.pat[iCoarse].effectRows*2 && (iCoarsesong.ins.empty()) continue; + absoluteTop=e->song.ins.size()-1; + } else if (iFine==2) { // volume + absoluteTop=e->getMaxVolumeChan(iCoarse); + } + for (int j=selStart.y; j<=selEnd.y; j++) { + if (top-bottom<=0) { + pat->data[j][iFine+1]=MIN(absoluteTop,bottom); + } else { + pat->data[j][iFine+1]=MIN(absoluteTop,bottom+(rand()%(top-bottom))); + } + } + } + } + iFine=0; + } + makeUndo(GUI_UNDO_PATTERN_RANDOMIZE); }