Index: class.doc ================================================================== --- class.doc +++ class.doc @@ -1166,10 +1166,13 @@ Write to the Finished variable. Only the low 8-bits are used. When set to nonzero then the beginning and ending phases are skipped (see above), but if IgnoreKey is used, then all phases are skipped, regardless of the value of this flag. +flip ( mark ... -- mark ... ) + Reverses everything above the mark on the stack. + FlushClass ( class -- ) ** Resets the Arrived, Busy, Departed, Inertia, Moved, and UserSignal flags of all objects of the specified class to zero. If the class is -1, then all objects are flushed in this way, and during the input phase, it also skips the beginning and ending phases if the class is -1. Index: exec.c ================================================================== --- exec.c +++ exec.c @@ -1414,10 +1414,24 @@ if(a==VOIDLINK || b==VOIDLINK) return 0; i=abs(objects[a]->x-objects[b]->x); j=abs(objects[a]->y-objects[b]->y); return i>j?i:j; } + +static inline void v_flip(void) { + int p=vstackptr; + int n; + Value v; + while(p-- && vstack[p].t!=TY_MARK); + if(!p) Throw("No mark"); + p++; + for(n=0;n<(vstackptr-p)/2;n++) { + v=vstack[p+n]; + vstack[p+n]=vstack[vstackptr-n-1]; + vstack[vstackptr-n-1]=v; + } +} // Here is where the execution of a Free Hero Mesh bytecode subroutine is executed. #define NoIgnore() do{ changed=1; }while(0) #define GetVariableOf(a,b) (i=v_object(Pop()),i==VOIDLINK?NVALUE(0):b(objects[i]->a)) #define GetVariableOrAttributeOf(a,b) (t2=Pop(),t2.t==TY_CLASS?NVALUE(classes[t2.u]->a):(i=v_object(t2),i==VOIDLINK?NVALUE(0):b(objects[i]->a))) @@ -1570,10 +1584,11 @@ case OP_DROP_D: StackReq(2,0); Pop(); Pop(); break; case OP_DUP: StackReq(1,2); t1=Pop(); Push(t1); Push(t1); break; case OP_EQ: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_equal(t1,t2)?1:0)); break; case OP_FINISHED: StackReq(0,1); Push(NVALUE(all_flushed)); break; case OP_FINISHED_E: StackReq(1,0); t1=Pop(); Numeric(t1); all_flushed=t1.u; break; + case OP_FLIP: v_flip(); break; case OP_FLUSHCLASS: NoIgnore(); StackReq(1,0); t1=Pop(); if(t1.t==TY_CLASS) flush_class(t1.u); else if(t1.t==TY_NUMBER && t1.s==-1) flush_all(); else if(t1.t) Throw("Type mismatch"); break; case OP_FLUSHOBJ: NoIgnore(); flush_object(obj); break; case OP_FLUSHOBJ_C: NoIgnore(); StackReq(1,0); i=v_object(Pop()); if(i!=VOIDLINK) flush_object(i); break; case OP_FOR: NoIgnore(); StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); ptr=v_for(code,ptr,t1,t2,t3); break; case OP_FROM: StackReq(0,1); Push(OVALUE(msgvars.from)); break; Index: instruc ================================================================== --- instruc +++ instruc @@ -260,10 +260,11 @@ mark "_" tmark in nin -mbegin +flip ; Arrays -Array GetArray InitArray Index: instruc.h ================================================================== --- instruc.h +++ instruc.h @@ -377,23 +377,24 @@ #define OP_MARK 32954 #define OP_TMARK 32955 #define OP_IN 32956 #define OP_NIN 32957 #define OP_MBEGIN 32958 -#define OP_ARRAY 32959 -#define OP_GETARRAY 32960 -#define OP_INITARRAY 32961 -#define OP_SETARRAY 32962 -#define OP_ARRAYCELL 32963 -#define OP_FUNCTION 32964 -#define OP_LOCAL 32965 -#define OP_LABEL 32966 -#define OP_STRING 32967 -#define OP_INT16 32968 -#define OP_INT32 32969 -#define OP_DISPATCH 32970 -#define OP_USERFLAG 32971 +#define OP_FLIP 32959 +#define OP_ARRAY 32960 +#define OP_GETARRAY 32961 +#define OP_INITARRAY 32962 +#define OP_SETARRAY 32963 +#define OP_ARRAYCELL 32964 +#define OP_FUNCTION 32965 +#define OP_LOCAL 32966 +#define OP_LABEL 32967 +#define OP_STRING 32968 +#define OP_INT16 32969 +#define OP_INT32 32970 +#define OP_DISPATCH 32971 +#define OP_USERFLAG 32972 #ifdef HEROMESH_CLASS static const Op_Names op_names[]={ {"*",8486937}, {"+",8421399}, {"-",8421400}, @@ -405,12 +406,12 @@ {"Animate",8421508}, {"AnimateDead",8421509}, {"Arg1",8552565}, {"Arg2",8552566}, {"Arg3",8552567}, -{"Array",8683711}, -{"ArrayCell",8421571}, +{"Array",8683712}, +{"ArrayCell",8421572}, {"Arrivals",8618083}, {"Arrived",8618081}, {"Assassinate",8487046}, {"B",9437196}, {"BANG",8389380}, @@ -475,11 +476,11 @@ {"FlushClass",8421522}, {"FlushObj",8487059}, {"From",8421492}, {"GLASS",8389379}, {"GLISSANT",8389419}, -{"GetArray",8421568}, +{"GetArray",8421569}, {"GetInventory",8421524}, {"HAWK",8389425}, {"HEARTBEAT",8389407}, {"HIT",8389134}, {"HITBY",8389135}, @@ -490,11 +491,11 @@ {"INIT",8389120}, {"IgnoreKey",8421526}, {"Image",8618046}, {"InPlace",8683647}, {"Inertia",9142335}, -{"InitArray",8421569}, +{"InitArray",8421570}, {"Input",8683645}, {"IntMove",10584215}, {"Invisible",8618086}, {"JAYAYAYNG",8389416}, {"JUMPED",8389128}, @@ -574,11 +575,11 @@ {"SW",9437189}, {"Seek",8487086}, {"Self",8421490}, {"Send",10584239}, {"SendEx",10584240}, -{"SetArray",8421570}, +{"SetArray",8421571}, {"SetInventory",8421553}, {"Shape",8618042}, {"ShapeDir",8618065}, {"Sharp",8618064}, {"Shovable",8618066}, @@ -658,10 +659,11 @@ {"cz?",8421425}, {"dup",8421377}, {"el",8683532}, {"else",8683530}, {"eq",8421416}, +{"flip",8421567}, {"for",8683538}, {"ge",8486956}, {"gt",8486954}, {"if",8683529}, {"in",8421564}, @@ -696,7 +698,7 @@ {"tmark",8421563}, {"tuck",8421380}, {"until",8683535}, {"while",8683536}, }; -#define N_OP_NAMES 303 +#define N_OP_NAMES 304 #endif