diff --git a/firmware/include/xgl.h b/firmware/include/xgl.h index 1813daa..12e18cb 100644 --- a/firmware/include/xgl.h +++ b/firmware/include/xgl.h @@ -4,10 +4,11 @@ // Select the proper library according to the target (4-bit grayscale or full color) #ifdef TARGET_PC -#include "ggl.h" -#endif #ifdef TARGET_PC_PRIMEG1 #include "cgl.h" +#else +#include "ggl.h" +#endif #endif #ifdef TARGET_PRIME1 diff --git a/newrpl/directory.c b/newrpl/directory.c index 1ecf4ef..191bd8d 100644 --- a/newrpl/directory.c +++ b/newrpl/directory.c @@ -1301,6 +1301,60 @@ void rplDoAutoEval(WORDPTR varname, WORDPTR * indir) DSTop = stksave; return; } + + // CHECK IF THE VARIABLE HAS A PREFERRED UNIT + if(attr & IDATTR_PREFUNIT) { + WORDPTR *varcalc = + rplFindGlobalPropInDir(*stkptr, IDPROP_UNIT, indir, 0); + if(varcalc) { + // FOUND PREFERRED UNIT + rplPushData(varcalc[1]); + + rplRunAtomic(CMD_CONVERT); + if(Exceptions) { + if( (Exceptions & EX_ERRORCODE) && (ErrorCode == ERR_INCONSISTENTUNITS)) { + + if(!(attr & IDATTR_FORCEUNIT) ) { + // DON'T CONVERT TO PREFERRED UNITS IF INCONSISTENT, BUT DON'T REPORT THE PROBLEM + rplClearErrors(); + rplDropData(1); + } + else { + // UNITS ARE FORCED, APPLY THE UNIT IF THE RESULT DIDN'T HAVE ANY UNITS + if(!ISUNIT(*rplPeekData(2))) + { + rplClearErrors(); + rplRunAtomic(CMD_OVR_MUL); + } + if(Exceptions) { + if(!((Exceptions & EX_ERRORCODE) + && (ErrorCode == ERR_UNDEFINEDVARIABLE))) + rplBlameError(varcalc[0]); // AT LEAST SHOW WHERE THE ERROR CAME FROM + if(DSTop > stksave) + DSTop = stksave; + return; + + } + } + + + } + + else { + if(!((Exceptions & EX_ERRORCODE) + && (ErrorCode == ERR_UNDEFINEDVARIABLE))) + rplBlameError(varcalc[0]); // AT LEAST SHOW WHERE THE ERROR CAME FROM + if(DSTop > stksave) + DSTop = stksave; + return; + } + } + + + } + + } + // STORE THE NEW RESULT AND CONTINUE var[1] = rplPopData(); } diff --git a/newrpl/lib-28-dirs.c b/newrpl/lib-28-dirs.c index 2ae1c03..c8712a6 100644 --- a/newrpl/lib-28-dirs.c +++ b/newrpl/lib-28-dirs.c @@ -703,6 +703,9 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER rplDropData(5); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); } else { @@ -795,6 +798,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER rplDropData(5); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -887,6 +894,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER rplDropData(5); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -979,6 +990,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER rplDropData(5); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -1061,6 +1076,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE RESULT rplDropData(3); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -1142,6 +1161,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE RESULT rplDropData(3); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -1223,6 +1246,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE RESULT rplDropData(3); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -1315,6 +1342,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER rplOverwriteData(4, rplPeekData(1)); rplDropData(3); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -1407,6 +1438,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER rplOverwriteData(4, rplPeekData(1)); rplDropData(3); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -2244,6 +2279,10 @@ void LIB_HANDLER() *(var + 1) = rplPeekData(1); // STORE THE INCREMENTED COUNTER rplDropData(5); + WORD valattr = rplGetIdentAttr(var[0]); + if(valattr & IDATTR_DEPEND) + rplDoAutoEval(var[0], rplGetDirfromGlobal(var)); + } else { @@ -2391,6 +2430,20 @@ void LIB_HANDLER() } + if(prop == IDPROP_UNIT) { + // SET THE ATTRIBUTE MARKER + varname = rplSetIdentAttr(var[0], IDATTR_PREFUNIT, IDATTR_PREFUNIT); + if(!varname) { + return; + } + var[0] = varname; + + if(Exceptions) + return; + // AND TRIGGER AUTO EVALUATION + + } + // ADD OTHER SYSTEM SIDE EFFECTS HERE rplDropData(2); @@ -2557,7 +2610,7 @@ void LIB_HANDLER() } return; case OVR_ISTRUE: - if(ISPACKEDDIR(rplPeekData(1))) { + if(ISPACKEDDIR(*rplPeekData(1))) { if(OBJSIZE(*rplPeekData(1))==0) { rplOverwriteData(1, (WORDPTR) zero_bint); return; diff --git a/newrpl/lib-32-lam.c b/newrpl/lib-32-lam.c index a6b62fb..991f5ab 100644 --- a/newrpl/lib-32-lam.c +++ b/newrpl/lib-32-lam.c @@ -1270,7 +1270,7 @@ void LIB_HANDLER() if((OPCODE(CurOpcode) == OPCODE_DECOMPEDIT)) { WORD attr = rplGetIdentAttr(DecompileObject); - if(attr) { + if(attr&IDATTR_ALLHINTS) { BINT noinf = 0; // APPEND THE ATTRIBUTES TO THE VARIABLE NAME IN SUBSCRIPT rplDecompAppendChar(':'); diff --git a/newrpl/libraries.h b/newrpl/libraries.h index 95d0853..62c0c15 100644 --- a/newrpl/libraries.h +++ b/newrpl/libraries.h @@ -185,8 +185,12 @@ WORD libComputeHash2(WORDPTR start, BINT nwords); #define IDPROP_UNIT TEXT2WORD('U','n','i','t') #define IDPROP_DEFN TEXT2WORD('D','e','f','n') +#define IDATTR_ALLPROPS 0xffff0000 + // IDENTIFIER ATTRIBUTES USED BY THE CAS + // LOWER 16 BITS ARE USED BY THE CAS +#define IDATTR_ALLHINTS 0xffff #define IDATTR_ISNOTINF 1 #define IDATTR_ISREAL 3