add deep clone order - UNTESTED

This commit is contained in:
tildearrow 2022-02-12 03:59:05 -05:00
parent cc9e0c0f57
commit 27497608fe
3 changed files with 48 additions and 0 deletions

View file

@ -5898,6 +5898,45 @@ void DivEngine::addOrder(bool duplicate, bool where) {
isBusy.unlock();
}
void DivEngine::deepCloneOrder(bool where) {
unsigned char order[DIV_MAX_CHANS];
if (song.ordersLen>=0x7e) return;
isBusy.lock();
for (int i=0; i<chans; i++) {
order[i]=song.orders.ord[i][curOrder];
// find free slot
for (int j=0; j<128; j++) {
if (song.pat[i].data[j]==NULL) {
int origOrd=order[i];
order[i]=j;
DivPattern* oldPat=song.pat[i].getPattern(origOrd,false);
DivPattern* pat=song.pat[i].getPattern(j,true);
memcpy(pat->data,oldPat->data,256*32*sizeof(short));
break;
}
}
}
if (where) { // at the end
for (int i=0; i<chans; i++) {
song.orders.ord[i][song.ordersLen]=order[i];
}
song.ordersLen++;
} else { // after current order
for (int i=0; i<chans; i++) {
for (int j=song.ordersLen; j>curOrder; j--) {
song.orders.ord[i][j]=song.orders.ord[i][j-1];
}
song.orders.ord[i][curOrder+1]=order[i];
}
song.ordersLen++;
curOrder++;
if (playing && !freelance) {
playSub(false);
}
}
isBusy.unlock();
}
void DivEngine::deleteOrder() {
if (song.ordersLen<=1) return;
isBusy.lock();

View file

@ -453,6 +453,9 @@ class DivEngine {
// add order
void addOrder(bool duplicate, bool where);
// deep clone orders
void deepCloneOrder(bool where);
// delete order
void deleteOrder();

View file

@ -6423,6 +6423,9 @@ void FurnaceGUI::doAction(int what) {
makeUndo(GUI_UNDO_CHANGE_ORDER);
break;
case GUI_ACTION_ORDERS_DEEP_CLONE:
prepareUndo(GUI_UNDO_CHANGE_ORDER);
e->deepCloneOrder(false);
makeUndo(GUI_UNDO_CHANGE_ORDER);
break;
case GUI_ACTION_ORDERS_DUPLICATE_END:
prepareUndo(GUI_UNDO_CHANGE_ORDER);
@ -6430,6 +6433,9 @@ void FurnaceGUI::doAction(int what) {
makeUndo(GUI_UNDO_CHANGE_ORDER);
break;
case GUI_ACTION_ORDERS_DEEP_CLONE_END:
prepareUndo(GUI_UNDO_CHANGE_ORDER);
e->deepCloneOrder(true);
makeUndo(GUI_UNDO_CHANGE_ORDER);
break;
case GUI_ACTION_ORDERS_REMOVE:
prepareUndo(GUI_UNDO_CHANGE_ORDER);