From 9e252566c63d3e74611d686f511637f806de7d2c Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Sat, 2 Dec 2023 14:33:53 +0300 Subject: [PATCH 01/12] looks like the pasting works, untested though --- src/gui/editing.cpp | 825 ++++++++++++++++++++++++++++++++++++++++++-- src/gui/gui.h | 2 + 2 files changed, 796 insertions(+), 31 deletions(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 45603e68c..379dddde1 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -24,6 +24,18 @@ #include "actionUtil.h" +static const char* text_format_headers[] = +{ + "ModPlug Tracker MOD", + "ModPlug Tracker S3M", + "ModPlug Tracker XM", + "ModPlug Tracker XM", + "ModPlug Tracker IT", + "ModPlug Tracker IT", + "ModPlug Tracker MPT", + NULL, +}; + const char* FurnaceGUI::noteNameNormal(short note, short octave) { if (note==100) { // note cut return "OFF"; @@ -433,36 +445,8 @@ String FurnaceGUI::doCopy(bool cut, bool writeClipboard, const SelectionPoint& s return clipb; } -void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String clipb) { - if (readClipboard) { - finishSelection(); - prepareUndo(GUI_UNDO_PATTERN_PASTE); - char* clipText=SDL_GetClipboardText(); - if (clipText!=NULL) { - if (clipText[0]) { - clipboard=clipText; - } - SDL_free(clipText); - } - clipb=clipboard; - } - std::vector data; - String tempS; - for (char i: clipb) { - if (i=='\r') continue; - if (i=='\n') { - data.push_back(tempS); - tempS=""; - continue; - } - tempS+=i; - } - data.push_back(tempS); - - int startOff=-1; - bool invalidData=false; - if (data.size()<2) return; - if (data[0].find("org.tildearrow.furnace - Pattern Data")!=0) return; +void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int startOff, bool invalidData) +{ if (sscanf(data[1].c_str(),"%d",&startOff)!=1) return; if (startOff<0) return; @@ -513,7 +497,7 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli } if ((mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_MIX_FG || - mode==GUI_PASTE_MODE_INS_BG || mode==GUI_PASTE_MODE_INS_FG) && strcmp(note,"...")==0) { + mode==GUI_PASTE_MODE_INS_BG || mode==GUI_PASTE_MODE_INS_FG) && strcmp(note,"...")==0) { // do nothing. } else { if (!(mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_INS_BG) || (pat->data[j][0]==0 && pat->data[j][1]==0)) { @@ -607,6 +591,785 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli } } +uint64_t convert_effect_openmpt_mod(char symbol, uint16_t val) +{ + switch(symbol) + { + case '0': + { + return ((0x00) << 8) | (val); + break; + } + + case '1': + { + return ((0x01) << 8) | (val); + break; + } + + case '2': + { + return ((0x02) << 8) | (val); + break; + } + + case '3': + { + return ((0x03) << 8) | (val); + break; + } + + case '4': + { + return ((0x04) << 8) | (val); + break; + } + + case '5': + { + return ((0x0a) << 8) | (val) | ((0x03) << 24); //Axy + 300 + break; + } + + case '6': + { + return ((0x0a) << 8) | (val) | ((0x04) << 24); //Axy + 400 + break; + } + + case '7': + { + return ((0x07) << 8) | (val); + break; + } + + case '8': + { + return ((0x80) << 8) | (val); + break; + } + + case '9': + { + return ((0x90) << 8) | (val); + break; + } + + case 'A': + { + return ((0x0A) << 8) | (val); + break; + } + + case 'B': + { + return ((0x0B) << 8) | (val); + break; + } + + case 'C': + { + return ((0x0C) << 8) | (val); //interpreted as volume later + break; + } + + case 'D': + { + uint8_t new_param = (val & 0xf) + ((val & 0xff) >> 4) * 10; //hex to decimal, Protracker (and XM too!) lol + return ((0x0D) << 8) | (new_param); + break; + } + + case 'E': + { + switch(val >> 4) + { + case 1: + { + return ((0xF1) << 8) | (val & 0xf); + break; + } + + case 2: + { + return ((0xF2) << 8) | (val & 0xf); + break; + } + + //glissando and vib shape not supported in Furnace + + case 5: + { + return ((0xF5) << 8) | ((val & 0xf) << 4); + break; + } + + //pattern loop not supported + + case 8: + { + return ((0x80) << 8) | ((val & 0xf) << 4); + break; + } + + case 9: + { + return ((0x0C) << 8) | (val & 0xf); + break; + } + + case 0xA: + { + return ((0xF3) << 8) | (val & 0xf); + break; + } + + case 0xB: + { + return ((0xF4) << 8) | (val & 0xf); + break; + } + + case 0xC: + { + return ((0xFC) << 8) | (val & 0xf); + break; + } + + case 0xD: + { + return ((0xFD) << 8) | (val & 0xf); + break; + } + + default: break; + } + } + + case 'F': + { + if(val < 0x20) + { + return ((0x09) << 8) | (val); + } + + else + { + return ((0xF0) << 8) | (val); + } + break; + } + + default: break; + } +} + +uint64_t convert_effect_openmpt_s3m(char symbol, uint16_t val) +{ + switch(symbol) + { + case 'A': + { + return ((0x09) << 8) | (val); + break; + } + + case 'B': + { + return ((0x0B) << 8) | (val); + break; + } + + case 'C': + { + return ((0x0D) << 8) | (val); + break; + } + + case 'D': //who the fuck invented this... + { + if((val & 0xf0) == 0xf0) + { + return ((0xF4) << 8) | (val & 0xf); + } + + else if((val & 0xf) == 0xf) + { + return ((0xF3) << 8) | ((val & 0xf0) >> 4); + } + + else + { + return ((0x0A) << 8) | val; + } + + break; + } + + case 'E': //who the fuck invented this... + { + if(val < 0xe0) + { + return ((0x02) << 8) | val; + } + + else if(val >= 0xe0 && val < 0xf0) + { + return ((0xF2) << 8) | (val & 0xf); + } + + else + { + return ((0xF2) << 8) | ((val & 0xf) / 2); + } + + break; + } + + case 'F': //who the fuck invented this... + { + if(val < 0xe0) + { + return ((0x01) << 8) | val; + } + + else if(val >= 0xe0 && val < 0xf0) + { + return ((0xF1) << 8) | (val & 0xf); + } + + else + { + return ((0xF1) << 8) | ((val & 0xf) / 2); + } + + break; + } + + case 'G': + { + return ((0x03) << 8) | (val); + break; + } + + case 'H': + { + return ((0x04) << 8) | (val); + break; + } + + case 'J': + { + return ((0x00) << 8) | (val); + break; + } + + case 'K': + { + return ((0x0a) << 8) | (val) | ((0x04) << 24); //Axy + 400 + break; + } + + case 'L': + { + return ((0x0a) << 8) | (val) | ((0x03) << 24); //Axy + 300 + break; + } + + case 'O': + { + return ((0x90) << 8) | (val); + break; + } + + case 'Q': + { + return ((0xC0) << 8) | (val & 0xf); + break; + } + + case 'R': + { + return ((0x07) << 8) | (val & 0xf); + break; + } + + case 'S': + { + switch(val >> 4) + { + case 2: + { + return ((0xE5) << 8) | ((val & 0xf) << 4); + break; + } + + case 8: + { + return ((0x80) << 8) | ((val & 0xf) << 4); + break; + } + + case 0xC: + { + return ((0xFC) << 8) | (val & 0xf); + break; + } + + case 0xD: + { + return ((0xFD) << 8) | (val & 0xf); + break; + } + + default: break; + } + } + + case 'T': + { + return ((0xF0) << 8) | (val & 0xf); + break; + } + + case 'U': + { + return ((0x04) << 8) | MAX(1, ((val & 0xf0) >> 4 / 4 << 4)) | MAX(1, ((val & 0xf) / 4)); + break; + } + + case 'X': + { + return ((0x80) << 8) | (val); + break; + } + + default: break; + } +} + +uint64_t convert_effect_openmpt_xm(char symbol, uint16_t val) +{ + return convert_effect_openmpt_mod(symbol, val); + //other effects too obscure bruh +} + +uint64_t convert_effect_openmpt_it(char symbol, uint16_t val) +{ + return convert_effect_openmpt_s3m(symbol, val); + //other effects too obscure bruh +} + +uint64_t convert_effect_openmpt_mptm(char symbol, uint16_t val) +{ + if(symbol == ':') + { + logW("dshit %d", ((val & 0xf0) >> 4)); + return ((0xED) << 8) | ((val & 0xf0) >> 4) | ((0xEC) << 24) | ((((val & 0xf0) >> 4) + (val & 0xf)) << 16); + } + + return convert_effect_openmpt_it(symbol, val); +} + +void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int openmpt_format) +{ + DETERMINE_LAST; + + int j=cursor.y; + char note[4]; + bool invalidData = true; + + for(size_t i=1; icurSubSong->patLen; i++) + { + size_t charPos=1; + int iCoarse=cursor.xCoarse; + int iFine=0; + + String& line=data[i]; + + while (charPoscurPat[iCoarse].getPattern(e->curOrders->ord[iCoarse][curOrder],true); + if (line[charPos]=='|' && charPos != 0) //OpenMPT format starts every pattern line with '|' + { + iCoarse++; + + if (iCoarsecurSubSong->chanShow[iCoarse]) + { + iCoarse++; + if (iCoarse>=lastChannel) break; + } + + iFine=0; + charPos++; + continue; + } + + if (iFine==0) //note + { + if (charPos>=line.size()) + { + invalidData=true; + break; + } + note[0]=line[charPos++]; + if (charPos>=line.size()) { + invalidData=true; + break; + } + note[1]=line[charPos++]; + if (charPos>=line.size()) { + invalidData=true; + break; + } + note[2]=line[charPos++]; + note[3]=0; + + logW("note \"%s\"", note); + + if (iFine==0 && !opMaskPaste.note) { + iFine++; + continue; + } + + if (strcmp(note,"...")==0 || strcmp(note," ")==0) + { + // do nothing. + + logW("note empty"); + } + + else + { + if (!(mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_INS_BG) || (pat->data[j][0]==0 && pat->data[j][1]==0)) + { + if (!decodeNote(note,pat->data[j][0],pat->data[j][1])) + { + invalidData=true; + break; + } + + else + { + pat->data[j][1]--; //OpenMPT is one octave higher... + } + + if (mode==GUI_PASTE_MODE_INS_BG || mode==GUI_PASTE_MODE_INS_FG) pat->data[j][2]=arg; + } + } + } + + else if (iFine==1) //instrument + { + if (charPos>=line.size()) + { + invalidData=true; + break; + } + note[0]=line[charPos++]; + if (charPos>=line.size()) + { + invalidData=true; + break; + } + note[1]=line[charPos++]; + note[2]=0; + + logW("ins \"%s\"", note); + + if (iFine==1) + { + if (!opMaskPaste.ins || mode==GUI_PASTE_MODE_INS_BG || mode==GUI_PASTE_MODE_INS_FG) + { + iFine++; + continue; + } + } + + if (strcmp(note,"..")==0 || strcmp(note," ")==0) + { + if (!(mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_MIX_FG || + mode==GUI_PASTE_MODE_INS_BG || mode==GUI_PASTE_MODE_INS_FG)) + { + pat->data[j][iFine+1]=-1; + } + } + + else + { + unsigned int val=0; + if (sscanf(note,"%2X",&val)!=1) + { + invalidData=true; + break; + } + + if (!(mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_INS_BG) || pat->data[j][iFine+1]==-1) + { + pat->data[j][iFine+1]=val; + } + } + } + + else //volume and effects + { + if (charPos>=line.size()) + { + invalidData=true; + break; + } + note[0]=line[charPos++]; + if (charPos>=line.size()) + { + invalidData=true; + break; + } + note[1]=line[charPos++]; + if (charPos>=line.size()) + { + invalidData=true; + break; + } + note[2]=line[charPos++]; + note[3]=0; + + logW("vol/eff \"%s\"", note); + + if (iFine==2) + { + if (!opMaskPaste.vol) + { + iFine++; + continue; + } + } + + else if ((iFine&1)==0) + { + if (!opMaskPaste.effectVal) + { + iFine++; + continue; + } + } + + else if ((iFine&1)==1) + { + if (!opMaskPaste.effect) + { + iFine++; + continue; + } + } + + if (strcmp(note,"...")==0 || strcmp(note," ")==0) + { + if (!(mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_MIX_FG || + mode==GUI_PASTE_MODE_INS_BG || mode==GUI_PASTE_MODE_INS_FG)) + { + pat->data[j][iFine+1]=-1; + } + } + + else + { + unsigned int val=0; + char symbol = '\0'; + + symbol = note[0]; + + if(iFine == 2) + { + sscanf(¬e[1],"%2d",&val); + } + + else + { + sscanf(¬e[1],"%2X",&val); + } + + logW("vol/eff symbol %c, value %02X", symbol, val); + + if (!(mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_INS_BG) || pat->data[j][iFine+1]==-1) + { + //if (iFine<(3+e->curPat[iCoarse].effectCols*2)) pat->data[j][iFine+1]=val; + if(iFine == 2) //volume + { + switch(symbol) + { + case 'v': + { + pat->data[j][iFine+1]=val; + break; + } + default: break; + } + } + + else //effect + { + uint64_t eff = 0; + + if(openmpt_format == 0) + { + eff = convert_effect_openmpt_mod(symbol, val); //up to 4 effects stored in one variable + + if(((eff & 0x0f00) >> 8) == 0x0C) //set volume + { + pat->data[j][iFine]=eff & 0xff; + } + } + + if(openmpt_format == 1) + { + eff = convert_effect_openmpt_s3m(symbol, val); + } + + if(openmpt_format == 2 || openmpt_format == 3) //set volume + { + eff = convert_effect_openmpt_xm(symbol, val); + + if(((eff & 0x0f00) >> 8) == 0x0C) + { + pat->data[j][iFine]=eff & 0xff; + } + } + + if(openmpt_format == 4 || openmpt_format == 5) + { + eff = convert_effect_openmpt_it(symbol, val); + } + + if(openmpt_format == 6) + { + eff = convert_effect_openmpt_mptm(symbol, val); + } + + pat->data[j][iFine+1]=((eff & 0xff00) >> 8); + pat->data[j][iFine+2]=(eff & 0xff); + + if(eff > 0xffff) + { + pat->data[j][iFine+3]=((eff & 0xff000000) >> 24); + pat->data[j][iFine+4]=((eff & 0xff0000) >> 16); + } + + } + } + } + } + + iFine++; + + if(charPos >= line.size() - 1) + { + logW("line end"); + invalidData = false; + break; + } + } + + if (invalidData) + { + logW("invalid OpenMPT clipboard data! failed at line %d char %d",i,charPos); + logW("%s",line.c_str()); + break; + } + + j++; + if (mode==GUI_PASTE_MODE_OVERFLOW && j>=e->curSubSong->patLen && curOrdercurSubSong->ordersLen-1) + { + j=0; + curOrder++; + } + + if (mode==GUI_PASTE_MODE_FLOOD && i==data.size()-1) + { + i=1; + } + } + + if (readClipboard) { + if (settings.cursorPastePos) { + cursor.y=j; + if (cursor.y>=e->curSubSong->patLen) cursor.y=e->curSubSong->patLen-1; + selStart=cursor; + selEnd=cursor; + updateScroll(cursor.y); + } + + makeUndo(GUI_UNDO_PATTERN_PASTE); + } +} + +void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String clipb) { + if (readClipboard) { + finishSelection(); + prepareUndo(GUI_UNDO_PATTERN_PASTE); + char* clipText=SDL_GetClipboardText(); + if (clipText!=NULL) { + if (clipText[0]) { + clipboard=clipText; + } + SDL_free(clipText); + } + clipb=clipboard; + } + std::vector data; + String tempS; + bool found_string = false; + bool is_furnace = false; + bool is_openmpt = false; + int openmpt_format = 0; + for (char i: clipb) { + if (i=='\r') continue; + if (i=='\n') { + data.push_back(tempS); + tempS=""; + continue; + } + tempS+=i; + } + data.push_back(tempS); + + int startOff=-1; + bool invalidData=false; + if (data.size()<2) return; + + if (data[0].find("org.tildearrow.furnace - Pattern Data")==0) + { + found_string = true; + is_furnace = true; + } + + int i = 0; + + while(text_format_headers[i] != NULL) + { + if (data[0].find(text_format_headers[i])==0) + { + found_string = true; + is_openmpt = true; + openmpt_format = i; + break; + } + + i++; + } + + if(!found_string) return; + + if(is_furnace) + { + doPasteFurnace(mode, arg, readClipboard, clipb, data, startOff, invalidData); + } + + if(is_openmpt) + { + doPasteOpenMPT(mode, arg, readClipboard, clipb, data, openmpt_format); + } +} + void FurnaceGUI::doChangeIns(int ins) { finishSelection(); prepareUndo(GUI_UNDO_PATTERN_CHANGE_INS); diff --git a/src/gui/gui.h b/src/gui/gui.h index 67b83484c..83a8d3dc7 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2426,6 +2426,8 @@ class FurnaceGUI { void doInsert(); void doTranspose(int amount, OperationMask& mask); String doCopy(bool cut, bool writeClipboard, const SelectionPoint& sStart, const SelectionPoint& sEnd); + void doPasteFurnace(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int startOff, bool invalidData); + void doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int openmpt_format); void doPaste(PasteMode mode=GUI_PASTE_MODE_NORMAL, int arg=0, bool readClipboard=true, String clipb=""); void doChangeIns(int ins); void doInterpolate(); From 00736ee7fe313a1ef81153fc023ef71b8fb96300 Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Sat, 2 Dec 2023 14:37:05 +0300 Subject: [PATCH 02/12] remove breakpoints --- src/gui/editing.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 379dddde1..4ab4a043c 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -964,7 +964,6 @@ uint64_t convert_effect_openmpt_mptm(char symbol, uint16_t val) { if(symbol == ':') { - logW("dshit %d", ((val & 0xf0) >> 4)); return ((0xED) << 8) | ((val & 0xf0) >> 4) | ((0xEC) << 24) | ((((val & 0xf0) >> 4) + (val & 0xf)) << 16); } @@ -1025,8 +1024,6 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str note[2]=line[charPos++]; note[3]=0; - logW("note \"%s\"", note); - if (iFine==0 && !opMaskPaste.note) { iFine++; continue; @@ -1035,8 +1032,6 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str if (strcmp(note,"...")==0 || strcmp(note," ")==0) { // do nothing. - - logW("note empty"); } else @@ -1075,8 +1070,6 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str note[1]=line[charPos++]; note[2]=0; - logW("ins \"%s\"", note); - if (iFine==1) { if (!opMaskPaste.ins || mode==GUI_PASTE_MODE_INS_BG || mode==GUI_PASTE_MODE_INS_FG) @@ -1133,8 +1126,6 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str note[2]=line[charPos++]; note[3]=0; - logW("vol/eff \"%s\"", note); - if (iFine==2) { if (!opMaskPaste.vol) @@ -1188,8 +1179,6 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str sscanf(¬e[1],"%2X",&val); } - logW("vol/eff symbol %c, value %02X", symbol, val); - if (!(mode==GUI_PASTE_MODE_MIX_BG || mode==GUI_PASTE_MODE_INS_BG) || pat->data[j][iFine+1]==-1) { //if (iFine<(3+e->curPat[iCoarse].effectCols*2)) pat->data[j][iFine+1]=val; @@ -1263,7 +1252,6 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str if(charPos >= line.size() - 1) { - logW("line end"); invalidData = false; break; } From 8b6fc6d8d741ae2d38a0907d30127b819c2ad794 Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Sat, 2 Dec 2023 14:50:07 +0300 Subject: [PATCH 03/12] bruh --- src/gui/editing.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 4ab4a043c..1021a9ae9 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -976,7 +976,7 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str int j=cursor.y; char note[4]; - bool invalidData = true; + bool invalidData = false; for(size_t i=1; icurSubSong->patLen; i++) { @@ -1003,7 +1003,6 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str charPos++; continue; } - if (iFine==0) //note { if (charPos>=line.size()) From 63dd4fe47ea26de7e9390b773dccdd7a6dea410b Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Sat, 2 Dec 2023 15:41:02 +0300 Subject: [PATCH 04/12] =?UTF-8?q?=D0=BF=D0=B8=D0=B7=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/editing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 1021a9ae9..07eac68c8 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -760,7 +760,7 @@ uint64_t convert_effect_openmpt_mod(char symbol, uint16_t val) break; } - default: break; + default: return 0; break; } } @@ -944,7 +944,7 @@ uint64_t convert_effect_openmpt_s3m(char symbol, uint16_t val) break; } - default: break; + default: return 0; break; } } From 334cd02392f300075bbc0668a6036798d01f58a5 Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Sat, 2 Dec 2023 15:58:55 +0300 Subject: [PATCH 05/12] =?UTF-8?q?=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/editing.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 07eac68c8..817d9324d 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -744,6 +744,8 @@ uint64_t convert_effect_openmpt_mod(char symbol, uint16_t val) default: break; } + + break; } case 'F': @@ -924,6 +926,8 @@ uint64_t convert_effect_openmpt_s3m(char symbol, uint16_t val) default: break; } + + break; } case 'T': From adc8ba99e743bbe60d32593aeb8131b4554e2c73 Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Sat, 2 Dec 2023 16:05:05 +0300 Subject: [PATCH 06/12] =?UTF-8?q?=D0=BF=D0=B8=D0=B7=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/editing.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 817d9324d..dbad0d634 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -764,6 +764,8 @@ uint64_t convert_effect_openmpt_mod(char symbol, uint16_t val) default: return 0; break; } + + return 0; } uint64_t convert_effect_openmpt_s3m(char symbol, uint16_t val) @@ -950,6 +952,8 @@ uint64_t convert_effect_openmpt_s3m(char symbol, uint16_t val) default: return 0; break; } + + return 0; } uint64_t convert_effect_openmpt_xm(char symbol, uint16_t val) From 57a12781ea3a6c0b8653397e6e0421e9a65e0cc4 Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:18:47 +0300 Subject: [PATCH 07/12] Support OpenMPT note off and note release --- src/gui/editing.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index dbad0d634..ebb639934 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -1047,7 +1047,23 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str { if (!decodeNote(note,pat->data[j][0],pat->data[j][1])) { - invalidData=true; + if(strcmp(note, "^^^") == 0) + { + pat->data[j][0]=100; + pat->data[j][1]=0; + } + + else if(strcmp(note, "~~~") == 0 || strcmp(note, "===")) + { + pat->data[j][0]=101; + pat->data[j][1]=0; + } + + else + { + invalidData=true; + } + break; } From c6e3f8707a0a23cff58ed7af0e4757c4b96e8c4c Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Tue, 5 Dec 2023 19:17:47 +0300 Subject: [PATCH 08/12] Update editing.cpp --- src/gui/editing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index ebb639934..ee5fb61c3 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -1053,7 +1053,7 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str pat->data[j][1]=0; } - else if(strcmp(note, "~~~") == 0 || strcmp(note, "===")) + else if(strcmp(note, "~~~") == 0 || strcmp(note, "===") == 0) { pat->data[j][0]=101; pat->data[j][1]=0; From 8bca3c5e4c037666b28d3472a7360bf2838a50fa Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:04:45 +0300 Subject: [PATCH 09/12] fixfixifxifififidiiixcixifificxixixfixfix --- src/gui/editing.cpp | 65 ++++++++++++++++++++++++--------------------- src/gui/gui.h | 2 +- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index ee5fb61c3..15d9d5560 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -24,7 +24,7 @@ #include "actionUtil.h" -static const char* text_format_headers[] = +static const char* modPlugFormatHeaders[] = { "ModPlug Tracker MOD", "ModPlug Tracker S3M", @@ -591,7 +591,7 @@ void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, Str } } -uint64_t convert_effect_openmpt_mod(char symbol, uint16_t val) +unsigned long long convertEffectMPT_MOD(unsigned char symbol, unsigned int val) { switch(symbol) { @@ -768,7 +768,7 @@ uint64_t convert_effect_openmpt_mod(char symbol, uint16_t val) return 0; } -uint64_t convert_effect_openmpt_s3m(char symbol, uint16_t val) +unsigned long long convertEffectMPT_S3M(unsigned char symbol, unsigned int val) { switch(symbol) { @@ -956,29 +956,34 @@ uint64_t convert_effect_openmpt_s3m(char symbol, uint16_t val) return 0; } -uint64_t convert_effect_openmpt_xm(char symbol, uint16_t val) +unsigned long long convertEffectMPT_XM(unsigned char symbol, unsigned int val) { - return convert_effect_openmpt_mod(symbol, val); + if(symbol == 'K') + { + return ((0xEC) << 8) | (val); + } + + return convertEffectMPT_MOD(symbol, val); //other effects too obscure bruh } -uint64_t convert_effect_openmpt_it(char symbol, uint16_t val) +unsigned long long convertEffectMPT_IT(unsigned char symbol, unsigned int val) { - return convert_effect_openmpt_s3m(symbol, val); + return convertEffectMPT_S3M(symbol, val); //other effects too obscure bruh } -uint64_t convert_effect_openmpt_mptm(char symbol, uint16_t val) +unsigned long long convertEffectMPT_MPTM(unsigned char symbol, unsigned int val) { if(symbol == ':') { return ((0xED) << 8) | ((val & 0xf0) >> 4) | ((0xEC) << 24) | ((((val & 0xf0) >> 4) + (val & 0xf)) << 16); } - return convert_effect_openmpt_it(symbol, val); + return convertEffectMPT_IT(symbol, val); } -void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int openmpt_format) +void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int openmpt_format) { DETERMINE_LAST; @@ -1188,7 +1193,7 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str else { unsigned int val=0; - char symbol = '\0'; + unsigned char symbol = '\0'; symbol = note[0]; @@ -1220,11 +1225,11 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str else //effect { - uint64_t eff = 0; + unsigned long long eff = 0; if(openmpt_format == 0) { - eff = convert_effect_openmpt_mod(symbol, val); //up to 4 effects stored in one variable + eff = convertEffectMPT_MOD(symbol, val); //up to 4 effects stored in one variable if(((eff & 0x0f00) >> 8) == 0x0C) //set volume { @@ -1234,12 +1239,12 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str if(openmpt_format == 1) { - eff = convert_effect_openmpt_s3m(symbol, val); + eff = convertEffectMPT_S3M(symbol, val); } if(openmpt_format == 2 || openmpt_format == 3) //set volume { - eff = convert_effect_openmpt_xm(symbol, val); + eff = convertEffectMPT_XM(symbol, val); if(((eff & 0x0f00) >> 8) == 0x0C) { @@ -1249,12 +1254,12 @@ void FurnaceGUI::doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, Str if(openmpt_format == 4 || openmpt_format == 5) { - eff = convert_effect_openmpt_it(symbol, val); + eff = convertEffectMPT_IT(symbol, val); } if(openmpt_format == 6) { - eff = convert_effect_openmpt_mptm(symbol, val); + eff = convertEffectMPT_MPTM(symbol, val); } pat->data[j][iFine+1]=((eff & 0xff00) >> 8); @@ -1328,9 +1333,9 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli } std::vector data; String tempS; - bool found_string = false; - bool is_furnace = false; - bool is_openmpt = false; + bool foundString = false; + bool isFurnace = false; + bool isOpenmpt = false; int openmpt_format = 0; for (char i: clipb) { if (i=='\r') continue; @@ -1349,18 +1354,18 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli if (data[0].find("org.tildearrow.furnace - Pattern Data")==0) { - found_string = true; - is_furnace = true; + foundString = true; + isFurnace = true; } int i = 0; - while(text_format_headers[i] != NULL) + while(modPlugFormatHeaders[i] != NULL) { - if (data[0].find(text_format_headers[i])==0) + if (data[0].find(modPlugFormatHeaders[i])==0) { - found_string = true; - is_openmpt = true; + foundString = true; + isOpenmpt = true; openmpt_format = i; break; } @@ -1368,16 +1373,16 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli i++; } - if(!found_string) return; + if(!foundString) return; - if(is_furnace) + if(isFurnace) { doPasteFurnace(mode, arg, readClipboard, clipb, data, startOff, invalidData); } - if(is_openmpt) + if(isOpenmpt) { - doPasteOpenMPT(mode, arg, readClipboard, clipb, data, openmpt_format); + doPasteMPT(mode, arg, readClipboard, clipb, data, openmpt_format); } } diff --git a/src/gui/gui.h b/src/gui/gui.h index 83a8d3dc7..c40b95950 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2427,7 +2427,7 @@ class FurnaceGUI { void doTranspose(int amount, OperationMask& mask); String doCopy(bool cut, bool writeClipboard, const SelectionPoint& sStart, const SelectionPoint& sEnd); void doPasteFurnace(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int startOff, bool invalidData); - void doPasteOpenMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int openmpt_format); + void doPasteMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int openmpt_format); void doPaste(PasteMode mode=GUI_PASTE_MODE_NORMAL, int arg=0, bool readClipboard=true, String clipb=""); void doChangeIns(int ins); void doInterpolate(); From 0de1659d0d0614bec9dfe8c5bc2078ed7cdb993b Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:40:08 +0300 Subject: [PATCH 10/12] Update editing.cpp --- src/gui/editing.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 15d9d5560..9d899044d 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -983,7 +983,7 @@ unsigned long long convertEffectMPT_MPTM(unsigned char symbol, unsigned int val) return convertEffectMPT_IT(symbol, val); } -void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int openmpt_format) +void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String clipb, std::vector data, int MPTformat) { DETERMINE_LAST; @@ -1227,7 +1227,7 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String { unsigned long long eff = 0; - if(openmpt_format == 0) + if(MPTformat == 0) { eff = convertEffectMPT_MOD(symbol, val); //up to 4 effects stored in one variable @@ -1237,12 +1237,12 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String } } - if(openmpt_format == 1) + if(MPTformat == 1) { eff = convertEffectMPT_S3M(symbol, val); } - if(openmpt_format == 2 || openmpt_format == 3) //set volume + if(MPTformat == 2 || MPTformat == 3) //set volume { eff = convertEffectMPT_XM(symbol, val); @@ -1252,12 +1252,12 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String } } - if(openmpt_format == 4 || openmpt_format == 5) + if(MPTformat == 4 || MPTformat == 5) { eff = convertEffectMPT_IT(symbol, val); } - if(openmpt_format == 6) + if(MPTformat == 6) { eff = convertEffectMPT_MPTM(symbol, val); } @@ -1336,7 +1336,7 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli bool foundString = false; bool isFurnace = false; bool isOpenmpt = false; - int openmpt_format = 0; + int MPTformat = 0; for (char i: clipb) { if (i=='\r') continue; if (i=='\n') { @@ -1366,7 +1366,7 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli { foundString = true; isOpenmpt = true; - openmpt_format = i; + MPTformat = i; break; } @@ -1382,7 +1382,7 @@ void FurnaceGUI::doPaste(PasteMode mode, int arg, bool readClipboard, String cli if(isOpenmpt) { - doPasteMPT(mode, arg, readClipboard, clipb, data, openmpt_format); + doPasteMPT(mode, arg, readClipboard, clipb, data, MPTformat); } } From b6abf2955f49b16c7d5936f5230556ebdc37b9c0 Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:40:29 +0300 Subject: [PATCH 11/12] Update editing.cpp --- src/gui/editing.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index 9d899044d..b3501a230 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -1219,6 +1219,7 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String pat->data[j][iFine+1]=val; break; } + default: break; } } From 4bbb8a673b56c431f0f0c06222e75ca4cf6c010e Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Thu, 7 Dec 2023 07:46:39 +0300 Subject: [PATCH 12/12] fix --- src/gui/editing.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/editing.cpp b/src/gui/editing.cpp index b3501a230..0d19c0d37 100644 --- a/src/gui/editing.cpp +++ b/src/gui/editing.cpp @@ -591,7 +591,7 @@ void FurnaceGUI::doPasteFurnace(PasteMode mode, int arg, bool readClipboard, Str } } -unsigned long long convertEffectMPT_MOD(unsigned char symbol, unsigned int val) +unsigned int convertEffectMPT_MOD(unsigned char symbol, unsigned int val) { switch(symbol) { @@ -768,7 +768,7 @@ unsigned long long convertEffectMPT_MOD(unsigned char symbol, unsigned int val) return 0; } -unsigned long long convertEffectMPT_S3M(unsigned char symbol, unsigned int val) +unsigned int convertEffectMPT_S3M(unsigned char symbol, unsigned int val) { switch(symbol) { @@ -956,7 +956,7 @@ unsigned long long convertEffectMPT_S3M(unsigned char symbol, unsigned int val) return 0; } -unsigned long long convertEffectMPT_XM(unsigned char symbol, unsigned int val) +unsigned int convertEffectMPT_XM(unsigned char symbol, unsigned int val) { if(symbol == 'K') { @@ -967,13 +967,13 @@ unsigned long long convertEffectMPT_XM(unsigned char symbol, unsigned int val) //other effects too obscure bruh } -unsigned long long convertEffectMPT_IT(unsigned char symbol, unsigned int val) +unsigned int convertEffectMPT_IT(unsigned char symbol, unsigned int val) { return convertEffectMPT_S3M(symbol, val); //other effects too obscure bruh } -unsigned long long convertEffectMPT_MPTM(unsigned char symbol, unsigned int val) +unsigned int convertEffectMPT_MPTM(unsigned char symbol, unsigned int val) { if(symbol == ':') { @@ -1226,7 +1226,7 @@ void FurnaceGUI::doPasteMPT(PasteMode mode, int arg, bool readClipboard, String else //effect { - unsigned long long eff = 0; + unsigned int eff = 0; if(MPTformat == 0) {