several important bug fixes to advanced arp macro
This commit is contained in:
parent
c009cb3536
commit
226f43fea3
7 changed files with 46 additions and 24 deletions
|
|
@ -201,8 +201,13 @@ void FurnaceGUI::encodeMMLStr(String& target, int* macro, int macroLen, int macr
|
|||
for (int i=0; i<macroLen; i++) {
|
||||
if (i==macroLoop) target+="| ";
|
||||
if (i==macroRel) target+="/ ";
|
||||
if (bit30 && macro[i]&0x40000000) target+="@";
|
||||
int macroVal=macro[i]&(bit30?(~0x40000000):0xffffffff);
|
||||
if (bit30 && ((macro[i]&0xc0000000)==0x40000000 || (macro[i]&0xc0000000)==0x80000000)) target+="@";
|
||||
int macroVal=macro[i];
|
||||
if (macro[i]<0) {
|
||||
if (!(macroVal&0x40000000)) macroVal|=0x40000000;
|
||||
} else {
|
||||
if (macroVal&0x40000000) macroVal&=~0x40000000;
|
||||
}
|
||||
if (hex) {
|
||||
if (i==macroLen-1) {
|
||||
snprintf(buf,31,"%.2X",macroVal);
|
||||
|
|
@ -312,7 +317,7 @@ void FurnaceGUI::decodeMMLStr(String& source, int* macro, unsigned char& macroLe
|
|||
negaBuf=false;
|
||||
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
||||
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
||||
if (setBit30) macro[macroLen]|=0x40000000;
|
||||
if (setBit30) macro[macroLen]^=0x40000000;
|
||||
setBit30=false;
|
||||
macroLen++;
|
||||
buf=0;
|
||||
|
|
@ -325,7 +330,7 @@ void FurnaceGUI::decodeMMLStr(String& source, int* macro, unsigned char& macroLe
|
|||
negaBuf=false;
|
||||
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
||||
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
||||
if (setBit30) macro[macroLen]|=0x40000000;
|
||||
if (setBit30) macro[macroLen]^=0x40000000;
|
||||
setBit30=false;
|
||||
macroLen++;
|
||||
buf=0;
|
||||
|
|
@ -341,7 +346,7 @@ void FurnaceGUI::decodeMMLStr(String& source, int* macro, unsigned char& macroLe
|
|||
negaBuf=false;
|
||||
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
||||
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
||||
if (setBit30) macro[macroLen]|=0x40000000;
|
||||
if (setBit30) macro[macroLen]^=0x40000000;
|
||||
setBit30=false;
|
||||
macroLen++;
|
||||
buf=0;
|
||||
|
|
@ -359,7 +364,7 @@ void FurnaceGUI::decodeMMLStr(String& source, int* macro, unsigned char& macroLe
|
|||
negaBuf=false;
|
||||
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
||||
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
||||
if (setBit30) macro[macroLen]|=0x40000000;
|
||||
if (setBit30) macro[macroLen]^=0x40000000;
|
||||
setBit30=false;
|
||||
macroLen++;
|
||||
buf=0;
|
||||
|
|
@ -1774,7 +1779,8 @@ void FurnaceGUI::showError(String what) {
|
|||
displayError=true;
|
||||
}
|
||||
|
||||
#define B30(tt) (macroDragBit30?((tt)&0x40000000):0)
|
||||
// what monster did I just create here?
|
||||
#define B30(tt) (macroDragBit30?((((tt)&0xc0000000)==0x40000000 || ((tt)&0xc0000000)==0x80000000)?0x40000000:0):0)
|
||||
|
||||
#define MACRO_DRAG(t) \
|
||||
if (macroDragBitMode) { \
|
||||
|
|
@ -1808,25 +1814,25 @@ void FurnaceGUI::showError(String what) {
|
|||
} \
|
||||
if (macroDragMouseMoved) { \
|
||||
if ((int)round(x-macroDragLineInitial.x)==0) { \
|
||||
t[x]=B30(t[x])|(int)(macroDragLineInitial.y); \
|
||||
t[x]=B30(t[x])^(int)(macroDragLineInitial.y); \
|
||||
} else { \
|
||||
if ((int)round(x-macroDragLineInitial.x)<0) { \
|
||||
for (int i=0; i<=(int)round(macroDragLineInitial.x-x); i++) { \
|
||||
int index=(int)round(x+i); \
|
||||
if (index<0) continue; \
|
||||
t[index]=B30(t[index])|(int)(y+(macroDragLineInitial.y-y)*((float)i/(float)(macroDragLineInitial.x-x))); \
|
||||
t[index]=B30(t[index])^(int)(y+(macroDragLineInitial.y-y)*((float)i/(float)(macroDragLineInitial.x-x))); \
|
||||
} \
|
||||
} else { \
|
||||
for (int i=0; i<=(int)round(x-macroDragLineInitial.x); i++) { \
|
||||
int index=(int)round(i+macroDragLineInitial.x); \
|
||||
if (index<0) continue; \
|
||||
t[index]=B30(t[index])|(int)(macroDragLineInitial.y+(y-macroDragLineInitial.y)*((float)i/(x-macroDragLineInitial.x))); \
|
||||
t[index]=B30(t[index])^(int)(macroDragLineInitial.y+(y-macroDragLineInitial.y)*((float)i/(x-macroDragLineInitial.x))); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
t[x]=B30(t[x])|(y); \
|
||||
t[x]=B30(t[x])^(y); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1197,6 +1197,16 @@ String genericGuide(float value) {
|
|||
return fmt::sprintf("%d",(int)value);
|
||||
}
|
||||
|
||||
inline int deBit30(const int val) {
|
||||
if ((val&0xc0000000)==0x40000000 || (val&0xc0000000)==0x80000000) return val^0x40000000;
|
||||
return val;
|
||||
}
|
||||
|
||||
inline bool enBit30(const int val) {
|
||||
if ((val&0xc0000000)==0x40000000 || (val&0xc0000000)==0x80000000) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
|
||||
float asFloat[256];
|
||||
int asInt[256];
|
||||
|
|
@ -1292,9 +1302,9 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
|
|||
asFloat[j]=0;
|
||||
asInt[j]=0;
|
||||
} else {
|
||||
asFloat[j]=i.macro->val[j+macroDragScroll]&(i.bit30?(~0x40000000):0xffffffff);
|
||||
asInt[j]=(i.macro->val[j+macroDragScroll]&(i.bit30?(~0x40000000):0xffffffff))+i.bitOffset;
|
||||
if (i.bit30) bit30Indicator[j]=(i.macro->val[j+macroDragScroll]&0x40000000)?1:0;
|
||||
asFloat[j]=deBit30(i.macro->val[j+macroDragScroll]);
|
||||
asInt[j]=deBit30(i.macro->val[j+macroDragScroll])+i.bitOffset;
|
||||
if (i.bit30) bit30Indicator[j]=enBit30(i.macro->val[j+macroDragScroll]);
|
||||
}
|
||||
if (j+macroDragScroll>=i.macro->len || (j+macroDragScroll>i.macro->rel && i.macro->loop<i.macro->rel)) {
|
||||
loopIndicator[j]=0;
|
||||
|
|
@ -1461,10 +1471,10 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros) {
|
|||
ImGui::SetNextItemWidth(availableWidth);
|
||||
String& mmlStr=mmlString[index];
|
||||
if (ImGui::InputText("##IMacroMML",&mmlStr)) {
|
||||
decodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.min,(i.isBitfield)?((1<<(i.isBitfield?i.max:0))-1):i.max,i.macro->rel);
|
||||
decodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.min,(i.isBitfield)?((1<<(i.isBitfield?i.max:0))-1):i.max,i.macro->rel,i.bit30);
|
||||
}
|
||||
if (!ImGui::IsItemActive()) {
|
||||
encodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.macro->rel);
|
||||
encodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.macro->rel,false,i.bit30);
|
||||
}
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue