Exemple #1
0
// create a new dot at the good border of the good cube
void Cube::moveDot(const uint8_t d, Cube& c,
                   const Side mine, const Side his) {
    // move the dot to the good border:
    if      (mine == TOP   ) dots[d].pos.y = maxPos.y;
    else if (mine == LEFT  ) dots[d].pos.x = maxPos.x;
    else if (mine == BOTTOM) dots[d].pos.y = minPos.y+SPR_size.y;
    else if (mine == RIGHT ) dots[d].pos.x = minPos.x+SPR_size.x;

    // compute the discrete rotation to perform if needed:
    uint8_t angleI = umod((mine-his-2), 4);
    if (angleI) {
        dots[d].vel = dots[d].vel.rotateI(angleI);    // velocity rotation
        dots[d].pos = rotatePos(dots[d].pos, angleI); // position rotation
    }
    c.newDot(dots[d].pos, dots[d].vel);               // move to good cube
    vid.sprites[d].hide();                            // ...not here !
}
Exemple #2
0
static inline  void forth_vm_execute_instruction(forth_context_type *fc, char cmd)
{
//	printf("%c\n",cmd);
//	getchar();
	switch(cmd)
	{
		case '0': push(fc,0);				break;
		case '1': push(fc,1);				break;
		case '2': push(fc,2);				break;
		case '3': push(fc,3);				break;
		case '4': push(fc,4);				break;
		case '5': push(fc,5);				break;
		case '6': push(fc,6);				break;
		case '7': push(fc,7);				break;
		case '8': push(fc,8);				break;
		case '9': push(fc,9);				break;
		case '@': at(fc);					break; //@
		case '!': to(fc);					break; //!
		case 'd': fc->SP+=fc->cell;			break; //drop
		case 'D': dup(fc);					break; //dup
		case 's': swap_(fc);					break; //swap
		case 'l': push(fc,next_cell(fc));	break; //lit
		case '+': add(fc);  				break; //+
		case '-': sub(fc);  				break; //-
		case '*': mul(fc);					break; //*
		case '/': div_(fc);					break; // /
		case '%': mod(fc);					break; //mod
		case '&': and(fc);  				break; // and
		case '|': or(fc);   				break; // or
		case '^': xor(fc);   				break; // xor
		case '>': more(fc);					break; // >
		case '<': less(fc);					break;  // <
		case '=': eq(fc);					break; // =
		case 'b': branch(fc);				break; // branch
		case '?': cbranch(fc);				break; // ?branch
		case 'c': call(fc);					break; // call
		case 'r': ret(fc);					break; // ret
		case 't': to_r(fc);					break; // >R
		case 'f': from_r(fc);				break; // R>
		case 'i': in(fc);					break; // in
		case 'o': out(fc);					break; // out
		case '_': fc->stop=1;				break; // stop
		case 'A': adr0(fc);					break; // @0
		case 1:	  push(fc,fc->SP);			break; // SP@
		case 2:	  fc->SP=pop(fc);			break; // SP!
		case 3:	  push(fc,fc->RP);			break; // RP@
		case 4:	  fc->RP=pop(fc);			break; // RP!
		case 5:	 shl(fc);					break; // <<
		case 6:	 shr(fc);					break; // >>
		case 7:  push(fc,*(size_t *)(fc->mem+fc->RP)); break; // i
		case 8:  cat(fc);					break; // c@
		case 9:  cto(fc);					break; // c!
		case 10: set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1);				break; // nop
		case 11: in_ready(fc);				break; // ?in
		case 12: out_ready(fc);				break; // ?out
		case 16: umod(fc);					break; // umod
		case 17: udiv(fc);					break; // u/
// kernel
		case 'K': kalsym_lookup(fc);		break; // lookup kallsym address
		case 18:  kcall(fc);				break; // kcall
	}
}
Exemple #3
0
int g (int *x) /*@*/
{
  (void) umod (x);
  (void) umod (mmod (umod (x)));
  return *x;
}
Exemple #4
0
int f (int *x)
{
  (void) umod (mmod (umod (x)));
  return *x;
}