Пример #1
0
void OpBubble::OnTimeOut(OpTimer* timer)
{
	if (timer == &m_timer)
	{
		double duration = GetAnimationDuration(GetAnimation());
		double now = g_op_time_info->GetWallClockMS();
		double progress = (now - m_timer_start_time) / duration;
		if (progress < 1)
			m_timer.Start(BUBBLE_ANIM_TIMER_RES);
		else
			progress = 1;
		if (GetAnimation() == ANIMATION_BOUNCE)
		{
			m_extra_distance = (int)((op_fabs(op_cos(progress * M_PI * BUBBLE_ANIM_BOUNCE_COUNT) * (1 - progress * progress))) * BUBBLE_ANIM_BOUNCE_DROP_DISTANCE);
			Show();

			// Fade should be twice as fast as the bounce
			progress *= 2;
			progress = MIN(progress, 1);
		}
		else if (GetAnimation() == ANIMATION_SHAKE)
		{
			m_extra_shift = (int)(op_sin(progress * M_PI * BUBBLE_ANIM_SHAKE_COUNT) * BUBBLE_ANIM_SHAKE_DISTANCE * (1 - progress * progress));
			Show();

			// Fade should be four times as fast as the shake
			progress *= 4;
			progress = MIN(progress, 1);
		}
		GetWindow()->SetTransparency((INT32)(progress * 255));
	}
}
Пример #2
0
/**
 * Runs the instruction at the program counters position in memory.
 */
void vm_exec()
{
	cycles++;
	Instruction* op = mem_load_instr(pcounter);
	print_instr(op);

	switch(op->op)
	{
		case OP_NAP: break;

		case OP_ADD: 	op_add(op); 	break;
		case OP_SUB: 	op_sub(op); 	break;

		case OP_EXP:	op_exp(op);		break;
		case OP_SIN:	op_sin(op);		break;
		case OP_COS:	op_cos(op);		break;
		case OP_TAN:	op_tan(op);		break;

		case OP_LW: 	op_lw(op);		break;

		case OP_SW:		op_sw(op);		break;
		case OP_SB:		op_sb(op);		break;

		case OP_J:		op_j(op); 		return; // Jump
		case OP_JR:		op_jr(op);		return;
		case OP_JAL:	op_jal(op);		return;
		case OP_JZ:		op_jz(op);		return;
		case OP_JNZ:	op_jnz(op);		return;
		case OP_JEQ:	op_jeq(op);		return;
		case OP_JNQ:	op_jnq(op);		return;

		case OP_PUSH:	op_push(op);	break;
		case OP_POP:	op_pop(op);		break;

		case OP_PRTI:	op_prti(op);	break;

		case OP_EXIT: 	
			vm_exit(op->k); 
			return;

		/* Unsupported operation */
		default:
			printf("Error: Invalid operation at %d\n", pcounter);
			print_instr(op);
			vm_exit(-1);
			return;
	}

	pcounter = pcounter + 8;
}