Ejemplo n.º 1
0
void kbd_set_color_from_pos(u16 row, u16 key_in_row, u8 color) {
  u16 x, y;
  u16 x_start = 0;

  /* Calculate the map number and then the pointer to the layout */
  int mapNum = caps | (shift << 1);
  u16* map = (u16*)(BG_MAP_RAM(4 + mapNum) + 13 * 32);

  /* Calculate the map offset of the key that was depressed. */
  for (y = 0; y < key_in_row; y++) {
    x_start += kbdrows[row][y].width / 8;
  }

  /* Now update the tile for the key to change its colour. */
  for (y = 0; y < 2; y++) {
    for (x = 0; x < (kbdrows[row][key_in_row].width / 8); x++) {
      /*
       * There's two rows per key, and each row is 32 half-words
       * wide.  The key then starts at some x offset, and then the
       * key is composed of some number of columns.  Finally, we
       * skip the first tile, as it's the black, background tile
       *
       * Knowing that, the following calculation should be self-
       * explanatory, right?
       */
      int idx = (row * 2 + y) * 32 + x + x_start + 1;

      map[idx] = (map[idx] & 0x0FFF) | (color << 12);
    }
  }
}
Ejemplo n.º 2
0
void kbd_init() {
  u16 palette[4];

  nds_load_file("/NetHack/kbd.bin", (void *)BG_TILE_RAM(0));
  nds_load_file("/NetHack/kbd.map", (void *)BG_MAP_RAM(4));
  nds_load_palette("/NetHack/kbd.pal", palette);

  BG_PALETTE[0] = RGB15(0, 0, 0);   /* Regular background */
  BG_PALETTE[16] = RGB15(0, 0, 0);

  BG_PALETTE[1] = palette[0];       /* Key background, normal   */
  BG_PALETTE[17] = palette[1];      /* Key background, selected */

  BG_PALETTE[2] = palette[2];       /* Key text, normal */
  BG_PALETTE[18] = palette[3];      /* Key text, selected */
}
Ejemplo n.º 3
0
	//-------------------------------------------------------------------------------------------------
	Map::Map(Graphics::BackgroundMemory* backgroundMemory, int index) : index(index), size(32, 32), BackgroundMemory(backgroundMemory) 
	{
		sassert(backgroundMemory, "Error: Background memory cannot be null");
		location = BackgroundMemory->IsMain() ? BG_MAP_RAM(index) : BG_MAP_RAM_SUB(index);
		Clear();
	}
Ejemplo n.º 4
0
int width_in_tiles;
int height_in_tiles;
int tile_width_in_tiles, tile_height_in_tiles;
int tile_width_in_px, tile_height_in_px;

/* Text-based graphics variables */

struct font *map_font;
struct ppm *text_img;
int font_char_w;
int font_char_h;

/* General rendering variables */

u16 *tile_ram = (u16 *)BG_TILE_RAM(6);
u16 *map_ram = (u16 *)BG_MAP_RAM(8);

rectangle_t map_dimensions = {
  .start = { .x = 0, .y = 0 },
  .dims = { .width = COLNO, .height = ROWNO }
};

int pet_count;

/*
 * Initialize our tile cache.
 */
void nds_init_tile_cache()
{
  int i;