Example #1
0
void main()
{
	ENABLE_RAM_MBC1;
	SWITCH_ROM_MBC1(7);
    kwakwa_screen();
	//disable_APA();
	credits = 0U;
	while(1)
	{
		ENABLE_RAM_MBC1;
		SWITCH_ROM_MBC1(7);
		title_screen();
		credits = 0U;
		reset_game();
		disable_APA();
		while(credits == 0U)
		{

			game_screen();

		}
		//disable_APA();
		ENABLE_RAM_MBC1;
		SWITCH_ROM_MBC1(7);
		credits_screen();
		disable_APA();
	}
}
Example #2
0
void main()
{

	kwakwa_screen();
	DISPLAY_OFF;
	disable_APA();

	while(1)
	{
		title_screen();
		DISPLAY_OFF;
		disable_APA();

		game_screen();
	}
}
Example #3
0
// YOLOYOLO
int main()
{
	printf("\n\n\n----- STARTING A NEW GAME -----");
	init();
	printf("\nInitialization complete.");

 	srand(alt_timestamp()); // TODO change in de2 env
	int i;
	int new_player_count = 2;

	bool first_game = true;
	GameState state = SETUP;

	for (;;) {

	switch (state) {
	  case SETUP:
		printf("\n\n----- ENTERING SETUP STATE -----\n\n");
		initialize_dealer(new_player_count);
		printf("Initialized dealer.");

		joining_period();

		/* Move dealer chip to the next player */
		if (dealer_chip == dealer->number_players-1) dealer_chip = 0;
		else dealer_chip++;

		state = DEAL_HANDS;
		break;

	  case DEAL_HANDS:

		printf("\n\n ----- ENTERING DEAL_HANDS STATE -----\n\n");

		deal_hands();
		send_player_hands();

		for (i=0; i<dealer->number_players; i++) {
		  printf("\n\nDealt cards for Player %d: Suite %d, Value %d & Suite %d, Value %d", i,
			dealer->players[i].hand[0].suite, dealer->players[i].hand[0].value,
			dealer->players[i].hand[1].suite, dealer->players[i].hand[1].value);
		}

		state = ANTY_CALL;
		break;

	  case FLOP:
		flop();
		printf("\n\n----------------------------------------");
		printf("\nFLOP (%s) (%s) (%s) \n",
		  card_name(dealer->cards_on_table[0]),
		  card_name(dealer->cards_on_table[1]),
		  card_name(dealer->cards_on_table[2]));

		state = BET;
		break;

	  case TURN:
		turn();
		printf("\n\n----------------------------------------");
		printf("\nTURN (%s) (%s) (%s) (%s) \n",
		  card_name(dealer->cards_on_table[0]),
		  card_name(dealer->cards_on_table[1]),
		  card_name(dealer->cards_on_table[2]),
		  card_name(dealer->cards_on_table[3]));

		state = BET;
		break;

	  case RIVER:
		river();

		printf("\n\n----------------------------------------");
		printf("\nRIVER (%s) (%s) (%s) (%s) (%s) \n",
		  card_name(dealer->cards_on_table[0]),
		  card_name(dealer->cards_on_table[1]),
		  card_name(dealer->cards_on_table[2]),
		  card_name(dealer->cards_on_table[3]),
		  card_name(dealer->cards_on_table[4]));

		state = BET;
		break;

	  case ANTY_CALL:
		printf("\nCalling anty from all players");

		get_bet_for_player(dealer_chip);
		if (dealer_chip == dealer->number_players-1) {
		  for (i=0; i<dealer->number_players-1; i++) {
			if (dealer->players[i].active) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
		} else {
		  for (i=dealer_chip+1; i<dealer->number_players; i++) {
			if (dealer->players[i].active) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
		  for (i=0; i<dealer_chip; i++) {
			if (dealer->players[i].active) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
		}
		/* Put bet money into the pot */
		for (i=0; i<dealer->number_players; i++) {
		  dealer->pot += dealer->players[i].money;
		  dealer->players[i].money = 0;
		  dealer->current_bet = 0;
		}

		printf("\n----------------------------------------\n");
		printf("\nPOT %d", dealer->pot);
		printf("\n----------------------------------------\n");

	  state = BET;
	  break;

	  case BET:
		  for (i=0; i<dealer->number_players; i++) {
			  if (dealer->players[i].active && dealer->players[i].total_money > 0)
			  	sprintf(dealer->players[i].message, " ");
		  }

	  /* Betting Round 1 */
		get_bet_for_player(dealer_chip);
		if (dealer_chip == dealer->number_players-1) {
		  for (i=0; i<dealer->number_players-1; i++) {
			if (dealer->players[i].active) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
		} else {
		  for (i=dealer_chip+1; i<dealer->number_players; i++) {
			if (dealer->players[i].active) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
		  for (i=0; i<dealer_chip; i++) {
			if (dealer->players[i].active) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
		}

		/* If still betting, continue that */
		while (still_betting()) {
		  for (i=dealer_chip; i<dealer->number_players; i++) {
			if (player_still_playing(i)) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
		  for (i=0; i<dealer_chip; i++) {
			if (player_still_playing(i)) {
			  get_bet_for_player(i);
			  if (dealer->number_active_players == 1) {state = GAME_OVER; goto HOTSTUFF;}
			}
		  }
	   }
		switch (dealer->number_cards_on_table) {
		  case 0: state = FLOP; break;
		  case 3: state = TURN; break;
		  case 4: state = RIVER; break;
		  case 5: state = GAME_OVER; break;
		}


	   HOTSTUFF:;

		/* Put bet money into the pot */
		for (i=0; i<dealer->number_players; i++) {
		  dealer->pot += dealer->players[i].money;
		  dealer->players[i].money = 0;
		  dealer->current_bet = 0;
		}

		printf("\n----------------------------------------\n");
		printf("\nPOT %d", dealer->pot);
		printf("\n----------------------------------------\n");

		break;

	  case GAME_OVER:
		if (dealer->number_active_players > 1) {
		  rank_poker_hands();
		  split_pot();
		} else {
		  last_man_standing();
		}

		send_game_results();
		printf("\n\nWaiting for response from all players.\n");
		receive_replay_status();

		state = SETUP;

		free(dealer->deck);
		free(dealer->players);
		free(dealer);
		free(ph);

		break;
	}
	game_screen();
	}


	 return 0;
}