2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
|
x&=0xFFFF;
x|=x<<8; x&=0x00FF00FF;
x|=x<<4; x&=0x0F0F0F0F;
x|=x<<2; x&=0x33333333;
x|=x<<1; x&=0x55555555;
return x;
}
// 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)))
#define Numeric(a) do{ if((a).t!=TY_NUMBER) Throw("Type mismatch"); }while(0)
#define DivideBy(a) do{ Numeric(a); if(!(a).u) Throw("Division by zero"); }while(0)
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
|
x&=0xFFFF;
x|=x<<8; x&=0x00FF00FF;
x|=x<<4; x&=0x0F0F0F0F;
x|=x<<2; x&=0x33333333;
x|=x<<1; x&=0x55555555;
return x;
}
static Value v_find_connection(Uint32 xobj,Uint32 lnk,Uint32 obj,Uint16*code) {
Object*o=objects[obj];
Value v=NVALUE(0);
Uint32 n;
int i;
int first=nconn;
int last;
if(nconn!=pconn) Throw("Improper nested connected move");
if((o->oflags^OF_CONNECTION)&(OF_CONNECTION|OF_MOVING|OF_DESTROYED|OF_BIZARRO)) return NVALUE(0);
add_connection(obj);
for(i=first;i<nconn;i++) {
o=objects[n=conn[i].obj];
v=send_message(obj,n,MSG_CONNECT,NVALUE(i-first),NVALUE(objects[obj]->dir),UVALUE(0,TY_MARK));
if(v_bool(v)) goto done;
if(o->shovable&0xFF00) add_connection_shov(o);
}
last=pconn=nconn;
for(i=first;i<last;i++) {
StackReq(0,1);
Push(OVALUE(conn[i].obj));
if(lnk!=0xFFFF) execute_program(classes[lnk>>16]->codes,lnk&0xFFFF,xobj);
}
done:
for(i=first;i<nconn;i++) {
o=objects[conn[i].obj];
o->oflags&=~OF_MOVING;
if(conn[i].visual) o->oflags|=OF_VISUALONLY; else o->oflags&=~OF_VISUALONLY;
}
pconn=nconn=first;
StackReq(0,1);
return 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)))
#define Numeric(a) do{ if((a).t!=TY_NUMBER) Throw("Type mismatch"); }while(0)
#define DivideBy(a) do{ Numeric(a); if(!(a).u) Throw("Division by zero"); }while(0)
|
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
|
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_EQ2: StackReq(4,1); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(NVALUE(v_equal(t1,t3)?(v_equal(t2,t4)?1:0):0)); break;
case OP_EXEC: StackReq(1,0); t1=Pop(); i=convert_link(t1,obj,code); if(i==0xFFFF) return; code=classes[i>>16]->codes; ptr=i&0xFFFF; break;
case OP_EXEC_C: StackReq(1,0); t1=Pop(); i=convert_link(t1,obj,code); if(i!=0xFFFF) execute_program(classes[i>>16]->codes,i&0xFFFF,obj); break;
case OP_FAKEMOVE: NoIgnore(); StackReq(1,1); t1=Pop(); Numeric(t1); Push(NVALUE(fake_move_dir(obj,resolve_dir(obj,t1.u),0))); break;
case OP_FAKEMOVE_C: NoIgnore(); StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i==VOIDLINK) Push(NVALUE(0)); else Push(NVALUE(fake_move_dir(i,resolve_dir(i,t1.u),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;
|
>
>
|
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
|
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_EQ2: StackReq(4,1); t4=Pop(); t3=Pop(); t2=Pop(); t1=Pop(); Push(NVALUE(v_equal(t1,t3)?(v_equal(t2,t4)?1:0):0)); break;
case OP_EXEC: StackReq(1,0); t1=Pop(); i=convert_link(t1,obj,code); if(i==0xFFFF) return; code=classes[i>>16]->codes; ptr=i&0xFFFF; break;
case OP_EXEC_C: StackReq(1,0); t1=Pop(); i=convert_link(t1,obj,code); if(i!=0xFFFF) execute_program(classes[i>>16]->codes,i&0xFFFF,obj); break;
case OP_FAKEMOVE: NoIgnore(); StackReq(1,1); t1=Pop(); Numeric(t1); Push(NVALUE(fake_move_dir(obj,resolve_dir(obj,t1.u),0))); break;
case OP_FAKEMOVE_C: NoIgnore(); StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i==VOIDLINK) Push(NVALUE(0)); else Push(NVALUE(fake_move_dir(i,resolve_dir(i,t1.u),0))); break;
case OP_FINDCONNECTION: NoIgnore(); StackReq(1,1); t1=Pop(); t2=v_find_connection(obj,convert_link(t1,obj,code),obj,code); Push(t2); break;
case OP_FINDCONNECTION_C: NoIgnore(); StackReq(2,1); t1=Pop(); i=v_object(Pop()); t2=(i==VOIDLINK)?NVALUE(0):v_find_connection(obj,convert_link(t1,obj,code),i,code); Push(t2); 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;
|