Index: class.doc ================================================================== --- class.doc +++ class.doc @@ -1012,11 +1012,12 @@ Multiply by negative one. NewX ( oldx dir -- newx ) Advance the number in the direction as though it is a X coordinate. If the direction is north or south, leaves it alone, but if it is east or - west then it is increased or decreased by one. + west then it is increased or decreased by one. The output is never less + than zero nor exceeding the playfield width by more than one. NewY ( oldx dir -- newy ) Advance the number in the direction as though it is a Y coordinate. nip ( x y -- y ) Index: exec.c ================================================================== --- exec.c +++ exec.c @@ -397,10 +397,20 @@ static Uint32 obj_dir(Uint32 n,Uint32 d) { if(n==VOIDLINK) return VOIDLINK; d=resolve_dir(n,d); return obj_top_at(objects[n]->x+x_delta[d],objects[n]->y+y_delta[d]); } + +static Sint16 new_x(Sint16 n,Uint8 d) { + n+=x_delta[d]; + return n<0?0:n>pfwidth?pfwidth+1:n; +} + +static Sint16 new_y(Sint16 n,Uint8 d) { + n+=y_delta[d]; + return n<0?0:n>pfheight?pfheight+1:n; +} static void change_shape(Uint32 n,int d,int v) { v&=3; v<<=d+d; v|=objects[n]->shape&~(3<<(d+d)); @@ -1345,10 +1355,12 @@ case OP_MSG: StackReq(0,1); Push(MVALUE(msgvars.msg)); break; case OP_MUL: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u*t2.u)); break; case OP_MUL_C: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.s*t2.s)); break; case OP_NE: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_equal(t1,t2)?0:1)); break; case OP_NEG: StackReq(1,1); t1=Pop(); Numeric(t1); t1.s=-t1.s; Push(t1); break; + case OP_NEWX: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_x(t1.u,resolve_dir(obj,t2.u)))); break; + case OP_NEWY: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_y(t1.u,resolve_dir(obj,t2.u)))); break; case OP_NEXT: StackReq(0,1); ptr=v_next(code,ptr); break; case OP_NIP: StackReq(2,1); t1=Pop(); Pop(); Push(t1); break; case OP_OBJABOVE: StackReq(0,1); i=obj_above(obj); Push(OVALUE(i)); break; case OP_OBJABOVE_C: StackReq(1,1); i=obj_above(v_object(Pop())); Push(OVALUE(i)); break; case OP_OBJBELOW: StackReq(0,1); i=obj_below(obj); Push(OVALUE(i)); break;