2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
|
cp[cpi-1]=cp[cpi-2]=cp[cpi];
cp[cpi].dir=2;
cp[cpi-1].dir=4;
cp[cpi-2].dir=6;
break;
case OP_SUB:
if(vstackptr>=VSTACKSIZE-1) Throw("Stack overflow");
Push(NVALUE(0));
break;
case OP_THEN:
// This opcode does nothing
break;
case OP_TRACE:
if(main_options['t']) {
printf("ptr=%d cpi=%d x=%d y=%d dir=%d obj=%lu ",ptr,cpi,x,y,d,(long)n);
printf("[ptr=%d x=%d y=%d dir=%d]\n",cp[cpi].ptr,cp[cpi].x,cp[cpi].y,cp[cpi].dir);
}
break;
default:
fprintf(stderr,"Unrecognized opcode 0x%04X at 0x%04X in pattern\n",code[ptr-1],ptr-1);
Throw("Internal error: Unimplemented opcode in pattern");
}
goto again;
fail:
if(!all) {
if(vstackptr<cp->depth) Throw("Stack underflow in pattern matching");
vstackptr=cp[cpi].depth;
}
if(!cpi) return un;
x=cp[cpi].x;
y=cp[cpi].y;
d=cp[cpi].dir;
ptr=cp[cpi].ptr;
n=VOIDLINK;
cpi--;
goto again;
}
static Uint32 v_pattern_anywhere(Uint16*code,int ptr,char all) {
int i;
Uint32 n;
for(i=0;i<pfheight*64;i++) {
n=playfield[i];
if(n!=VOIDLINK) {
n=v_pattern(code,ptr,n,all);
if(n!=VOIDLINK && !all) return n;
}
}
return VOIDLINK;
}
static int v_case(Uint16*code,int ptr,Value v) {
int n=(code[ptr]&255)+1;
int t0=(code[ptr]>>12)&15;
int t1=(code[ptr]>>8)&15;
int i,j,v0,v1;
|
|
|
>
>
>
>
|
|
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
|
cp[cpi-1]=cp[cpi-2]=cp[cpi];
cp[cpi].dir=2;
cp[cpi-1].dir=4;
cp[cpi-2].dir=6;
break;
case OP_SUB:
if(vstackptr>=VSTACKSIZE-1) Throw("Stack overflow");
if(all==2) total--; else Push(NVALUE(0));
break;
case OP_THEN:
// This opcode does nothing
break;
case OP_TRACE:
if(main_options['t']) {
printf("ptr=%d cpi=%d x=%d y=%d dir=%d obj=%lu ",ptr,cpi,x,y,d,(long)n);
printf("[ptr=%d x=%d y=%d dir=%d]\n",cp[cpi].ptr,cp[cpi].x,cp[cpi].y,cp[cpi].dir);
}
break;
default:
fprintf(stderr,"Unrecognized opcode 0x%04X at 0x%04X in pattern\n",code[ptr-1],ptr-1);
Throw("Internal error: Unimplemented opcode in pattern");
}
goto again;
fail:
if(!all) {
if(vstackptr<cp->depth) Throw("Stack underflow in pattern matching");
vstackptr=cp[cpi].depth;
}
if(!cpi) return (all==2?total+(un==VOIDLINK?0:1):un);
x=cp[cpi].x;
y=cp[cpi].y;
d=cp[cpi].dir;
ptr=cp[cpi].ptr;
n=VOIDLINK;
cpi--;
goto again;
stop:
return (all==2?total:VOIDLINK);
}
static Uint32 v_pattern_anywhere(Uint16*code,int ptr,char all) {
int i;
Uint32 n;
Uint32 t=0;
for(i=0;i<pfheight*64;i++) {
n=playfield[i];
if(n!=VOIDLINK) {
n=v_pattern(code,ptr,n,all);
if(n!=VOIDLINK && !all) return n;
if(all==2) t+=n;
}
}
return (all==2?t:VOIDLINK);
}
static int v_case(Uint16*code,int ptr,Value v) {
int n=(code[ptr]&255)+1;
int t0=(code[ptr]>>12)&15;
int t1=(code[ptr]>>8)&15;
int i,j,v0,v1;
|
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
|
case OP_OVER: StackReq(2,3); t2=Pop(); t1=Pop(); Push(t1); Push(t2); Push(t1); break;
case OP_PATTERN: StackReq(0,1); i=code[ptr++]; j=v_pattern(code,ptr,obj,0); ptr=i; Push(OVALUE(j)); break;
case OP_PATTERN_C: StackReq(1,1); i=code[ptr++]; j=v_object(Pop()); if(j!=VOIDLINK) j=v_pattern(code,ptr,j,0); ptr=i; Push(OVALUE(j)); break;
case OP_PATTERN_E: StackReq(0,1); i=code[ptr++]; j=v_pattern_anywhere(code,ptr,0); ptr=i; Push(OVALUE(j)); break;
case OP_PATTERNS: StackReq(0,1); i=code[ptr++]; v_pattern(code,ptr,obj,1); ptr=i; break;
case OP_PATTERNS_C: StackReq(1,1); i=code[ptr++]; j=v_object(Pop()); if(j!=VOIDLINK) v_pattern(code,ptr,j,1); ptr=i; break;
case OP_PATTERNS_E: StackReq(0,1); i=code[ptr++]; v_pattern_anywhere(code,ptr,1); ptr=i; break;
case OP_PICK: StackReq(0,1); t1=Pop(); Numeric(t1); if(t1.u>=vstackptr) Throw("Stack index out of range"); t1=vstack[vstackptr-t1.u-1]; Push(t1); break;
case OP_PLAYER: StackReq(0,1); if(classes[o->class]->cflags&CF_PLAYER) Push(NVALUE(1)); else Push(NVALUE(0)); break;
case OP_PLAYER_C: StackReq(1,1); GetClassFlagOf(CF_PLAYER); break;
case OP_PLUSMOVE: StackReq(1,1); t1=Pop(); Numeric(t1); i=defer_move(obj,t1.u,1); Push(NVALUE(i)); break;
case OP_PLUSMOVE_C: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); i=defer_move(i,t1.u,1); Push(NVALUE(i)); break;
case OP_PLUSMOVE_D: StackReq(1,0); t1=Pop(); Numeric(t1); defer_move(obj,t1.u,1); break;
case OP_PLUSMOVE_CD: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); defer_move(i,t1.u,1); break;
|
>
>
>
|
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
|
case OP_OVER: StackReq(2,3); t2=Pop(); t1=Pop(); Push(t1); Push(t2); Push(t1); break;
case OP_PATTERN: StackReq(0,1); i=code[ptr++]; j=v_pattern(code,ptr,obj,0); ptr=i; Push(OVALUE(j)); break;
case OP_PATTERN_C: StackReq(1,1); i=code[ptr++]; j=v_object(Pop()); if(j!=VOIDLINK) j=v_pattern(code,ptr,j,0); ptr=i; Push(OVALUE(j)); break;
case OP_PATTERN_E: StackReq(0,1); i=code[ptr++]; j=v_pattern_anywhere(code,ptr,0); ptr=i; Push(OVALUE(j)); break;
case OP_PATTERNS: StackReq(0,1); i=code[ptr++]; v_pattern(code,ptr,obj,1); ptr=i; break;
case OP_PATTERNS_C: StackReq(1,1); i=code[ptr++]; j=v_object(Pop()); if(j!=VOIDLINK) v_pattern(code,ptr,j,1); ptr=i; break;
case OP_PATTERNS_E: StackReq(0,1); i=code[ptr++]; v_pattern_anywhere(code,ptr,1); ptr=i; break;
case OP_PATTERNC: StackReq(0,1); i=code[ptr++]; j=v_pattern(code,ptr,obj,2); ptr=i; Push(NVALUE(j)); break;
case OP_PATTERNC_C: StackReq(1,1); i=code[ptr++]; j=v_object(Pop()); if(j!=VOIDLINK) j=v_pattern(code,ptr,j,2); else j=0; Push(NVALUE(j)); ptr=i; break;
case OP_PATTERNC_E: StackReq(0,1); i=code[ptr++]; j=v_pattern_anywhere(code,ptr,2); ptr=i; Push(NVALUE(j)); break;
case OP_PICK: StackReq(0,1); t1=Pop(); Numeric(t1); if(t1.u>=vstackptr) Throw("Stack index out of range"); t1=vstack[vstackptr-t1.u-1]; Push(t1); break;
case OP_PLAYER: StackReq(0,1); if(classes[o->class]->cflags&CF_PLAYER) Push(NVALUE(1)); else Push(NVALUE(0)); break;
case OP_PLAYER_C: StackReq(1,1); GetClassFlagOf(CF_PLAYER); break;
case OP_PLUSMOVE: StackReq(1,1); t1=Pop(); Numeric(t1); i=defer_move(obj,t1.u,1); Push(NVALUE(i)); break;
case OP_PLUSMOVE_C: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); i=defer_move(i,t1.u,1); Push(NVALUE(i)); break;
case OP_PLUSMOVE_D: StackReq(1,0); t1=Pop(); Numeric(t1); defer_move(obj,t1.u,1); break;
case OP_PLUSMOVE_CD: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); defer_move(i,t1.u,1); break;
|