Ejemplo n.º 1
0
/*
 * Initialize our window port.  Of course, there are no arguments but we
 * also initialize the graphics subsystem, here, so we'll be prepared for
 * later.
 */
void nds_init_nhwindows(int *argc, char **argv)
{
  int i;

  system_font = read_bdf("font.bdf");

  if (system_font == NULL) {
    iprintf("Error loading font!\n");

    return;
  }

  if (nds_init_map()) {
    iprintf("Error loading tiles!\n");

    return;
  }

  keysSetRepeat(30, 2);

  for (i = 0; i < MAX_WINDOWS; i++) {
    windows[i] = NULL;
  }

  /* Set up our palettes. */
  BG_PALETTE_SUB[255] = RGB15(31,31,31);

  nds_load_palette("minimap.pal", BG_PALETTE_SUB + 16);

  BG_PALETTE_SUB[C_CURSOR] = RGB15(31,0, 0);

  iflags.window_inited = true;

  /* Get these set up for our windowing routines */

  up_arrow = alloc_ppm(16, 16);
  down_arrow = alloc_ppm(16, 16);
  okay_button = alloc_ppm(16, 16);
  cancel_button = alloc_ppm(16, 16);

  _nds_copy_header_pixels(up_arrow_data, (unsigned char *)up_arrow->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));
  _nds_copy_header_pixels(down_arrow_data, (unsigned char *)down_arrow->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));
  _nds_copy_header_pixels(okay_data, (unsigned char *)okay_button->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));
  _nds_copy_header_pixels(cancel_data, (unsigned char *)cancel_button->bitmap, 
                          MAP_COLOUR(CLR_BLACK), MAP_COLOUR(CLR_WHITE));

  if (nds_init_cmd() < 0) {
    nds_error();
  }

  nds_init_msg();
  font_bdf_init();

  text_dims(system_font, "*", &tag_width, NULL);

  tag_width *= 4;
}
Ejemplo n.º 2
0
int main(int argc, char** argv){
	irqSet(IRQ_VBLANK, &vblank);

	#ifdef TEXTMODE
		videoSetMode(MODE_0_2D);
		videoSetModeSub(MODE_0_2D);

		vramSetBankA(VRAM_A_MAIN_BG);
		vramSetBankC(VRAM_C_SUB_BG);
	#endif//TEXTMODE

	Display::init();

	keysSetRepeat(30, 12);

	srand(time(NULL));

	Player P1(FGrave);
	Player P2(FMidori);

	ControlLocal	C1(P1);
	ControlAI		C2(P2);

	//DisplayPlayerOverview a(0, 0, 0, 32, 1, P1);
	//DisplayContainer b(0, 0, 1, 32, 21, P1.hand());

	//DisplayCard c(1, 0, 0, 32, 24, P1.hand().at(0), false);

	Game(&C1, &C2);

	while(1){
		update();
	}
	return 0;
}
Ejemplo n.º 3
0
static int play(void *userData)
{
  srand(time(NULL));
  int scroll = 0;
  int quit = 0;
  int down;
  int redraw = 0;
  int mapNum = 0;
  touchPosition touch;

  gui     = new Gui();
  console = new Console();
  try {
    anagram = new Anagram();
  } catch (const char* err) {
    delete console;
    delete gui;

    return EXIT_FAILURE;
  }

  //copy bg tiles
  decompress(map[mapNum], bgGetMapPtr(1));

  reset();
  scroll = printList(scroll);
  console->flush();

  keysSetRepeat(30, 6);

  while(!quit) {
    swiWaitForVBlank();
    bgScrollf(1, -48, 48);
    bgUpdate();
    scanKeys();
    if(redraw) {
      scroll = printList(scroll);
      console->flush();
    }
    redraw = 0;

    down = keysDown() | (keysDownRepeat() & (KEY_UP|KEY_DOWN));

    if(down & KEY_UP)
      redraw = 1, scroll--;
    else if(down & KEY_DOWN)
      redraw = 1, scroll++;
    else if(down & KEY_B)
      redraw = 1, quit = 1;
    else if(down & KEY_START)
      redraw = 1, scroll = reset();
    else if(down & KEY_X) {
      redraw = 1;
      strfry(choices);
      if(strlen(choices) == strlen(solution))
        strcpy(solution, choices);
    }
    else if(down & KEY_Y) {
      mapNum = (mapNum+1)%NUM_MAPS;
      decompress(map[mapNum], bgGetMapPtr(1));
    }

    if(down & KEY_TOUCH)
      touchRead(&touch);
    else
      memset(&touch, 0, sizeof(touch));

    if(gui->update(choices, guess, touch) == GuiRC_Submit) {
      if(strlen(guess) > 2) {
        anagram->attempt(guess);
        addHistory(guess);
      }
      memset(guess,   0, sizeof(guess));
      memset(choices, 0, sizeof(choices));
      strcpy(choices, solution);
      redraw = 1;
    }

  }

  delete gui;
  delete console;
  delete anagram;

  return EXIT_SUCCESS;
}