Ejemplo n.º 1
0
void game_conn3(void)
{
	uint8_t cheat = 0;

get:
	switch (ROE_get()) {
	case ROE_CW1:
	case ROE_CW2:
		if (!cheat)
			bar_movey(1, 1);
		break;
	case ROE_CCW1:
	case ROE_CCW2:
		if (!cheat)
			bar_movey(1, 0);
		break;
	case ROE_SW1:
	case ROE_SW2:
		while (ROE_get() != ROE_N);
		if (!box.e)
			return;
#ifdef ENABLE_CHEAT
		cheat = !cheat;
#endif
		break;
	default:
		if (timer0()) {
			if (cheat && box.e)
				bar_follow(1);
			if (!box_move())
				return;
		}
	}
	switch (connect_read()) {
	case CONN_REPORT:
		connect_put(CONN_READY);
		box.x = connect_get();
		box.y = connect_get16();
		box.dx = connect_get();
		connect_put(CONN_READY);
		if (box.y + BOX_SIZE > tft.h)
			box.y = tft.h - BOX_SIZE;
		box.dy = (box.dx >> 1) & 0x01;
		box.dx &= 0x01;
		box.n = 1;
		box.e = 1;
		break;
	case CONN_GAMEOVER:
		cheat = connect_get();
		connect_put(CONN_READY);
		game.mode = 1;		// Disable game_over() send function
		game_over(cheat);
		return;
	case CONN_SOUND:
		sound_freq(connect_get16());
	}
	goto get;
}
Ejemplo n.º 2
0
void game_p1(void)
{
	uint8_t cheat = 0, mode = 0;
get:
	switch (ROE_get()) {
	case ROE_CW1:
		if (mode)
			bar_sizeh(0, 1);
		else if (!cheat)
			bar_movey(0, 1);
		break;
	case ROE_CCW1:
		if (mode)
			bar_sizeh(0, 0);
		else if (!cheat)
			bar_movey(0, 0);
		break;
	case ROE_CW2:
		if (mode)
			bar_sizew(0, 1);
		else if (!cheat)
			bar_movex(0, 1);
		break;
	case ROE_CCW2:
		if (mode)
			bar_sizew(0, 0);
		else if (!cheat)
			bar_movex(0, 0);
		break;
	case ROE_SW1:
		while (ROE_get() == ROE_SW1);
#ifdef ENABLE_CHEAT
		cheat = !cheat;
#else
		mode = !mode;
#endif
		break;
	case ROE_SW2:
		while (ROE_get() == ROE_SW2);
		mode = !mode;
		break;
	default:
		if (!mode && timer0()) {
			if (cheat)
				bar_follow(0);
			if (!box_move())
				return;
		}
	}
	goto get;
}
Ejemplo n.º 3
0
void game_p2(void)
{
	uint8_t cheat[2] = {0, 0};
get:
	switch (ROE_get()) {
	case ROE_CW1:
		if (!cheat[0])
			bar_movey(0, 1);
		break;
	case ROE_CCW1:
		if (!cheat[0])
			bar_movey(0, 0);
		break;
	case ROE_CW2:
		if (!cheat[1])
			bar_movey(1, 1);
		break;
	case ROE_CCW2:
		if (!cheat[1])
			bar_movey(1, 0);
		break;
	case ROE_SW1:
		while (ROE_get() == ROE_SW1);
#ifdef ENABLE_CHEAT
		cheat[0] = !cheat[0];
#endif
		break;
	case ROE_SW2:
		while (ROE_get() == ROE_SW2);
#ifdef ENABLE_CHEAT
		cheat[1] = !cheat[1];
#endif
		break;
	default:
		if (timer0()) {
			if (cheat[0])
				bar_follow(0);
			if (cheat[1])
				bar_follow(1);
			if (!box_move())
				return;
		}
	}
	goto get;
}
Ejemplo n.º 4
0
    TEST(timer, simple) {
      timer timer0(58);
      stream<int64_t> stream0 = timer0.draw();
      int64_t out0(0);

      stream0.bind([&out0](int64_t value){out0 = value;});

      std::chrono::steady_clock::time_point init = std::chrono::steady_clock::now();

      ASSERT_EQ(out0, 0);

      for(;;) {
        timer0.poll();
        std::chrono::steady_clock::time_point curr = std::chrono::steady_clock::now();
        std::chrono::nanoseconds duration = (curr - init);
        if(duration.count() >= 1000000000) break;
      }

      timer0.poll();

      ASSERT_EQ(out0, 58);
    }