void VID_SetPalette (unsigned char *palette) { int i; u8 *pal = palette; u16 *table = d_8to16table; unsigned r, g, b; for(i=0; i<256; i++){ r = pal[0]; g = pal[1]; b = pal[2]; table[0] = RGB8_to_565(r,g,b); table++; pal += 3; } }
void keyboard_draw_char(int x, int y, int c, u16 fg) { if (c < 0 || c > 256) return; u8 *fontdata = default_font_bin + (8 * c); u16 bg = RGB8_to_565(0, 0, 0);// colorTable[screenColor]; //u16 fg = RGB8_to_565(192, 192, 192);// colorTable[writingColor]; u8 b1 = *(fontdata++); u8 b2 = *(fontdata++); u8 b3 = *(fontdata++); u8 b4 = *(fontdata++); u8 b5 = *(fontdata++); u8 b6 = *(fontdata++); u8 b7 = *(fontdata++); u8 b8 = *(fontdata++); //if (currentConsole->flags & CONSOLE_UNDERLINE) b8 = 0xff; //if (currentConsole->flags & CONSOLE_CROSSED_OUT) b4 = 0xff; u8 mask = 0x80; int i; u16 *screen = &keyboard_screen[(x * 240) + (239 - (y + 7))]; for (i = 0; i<8; i++) { if (b8 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } if (b7 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } if (b6 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } if (b5 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } if (b4 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } if (b3 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } if (b2 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } if (b1 & mask) { *(screen++) = fg; } else{ *(screen++) = bg; } mask >>= 1; screen += 240 - 8; } }
#include <stdio.h> #include <string.h> #include <sys/iosupport.h> #include <3ds/gfx.h> #include <3ds/console.h> #include <3ds/svc.h> #include "default_font_bin.h" //set up the palette for color printing static u16 colorTable[] = { RGB8_to_565( 0, 0, 0), // black RGB8_to_565(128, 0, 0), // red RGB8_to_565( 0,128, 0), // green RGB8_to_565(128,128, 0), // yellow RGB8_to_565( 0, 0,128), // blue RGB8_to_565(128, 0,128), // magenta RGB8_to_565( 0,128,128), // cyan RGB8_to_565(192,192,192), // white RGB8_to_565(128,128,128), // bright black RGB8_to_565(255, 0, 0), // bright red RGB8_to_565( 0,255, 0), // bright green RGB8_to_565(255,255, 0), // bright yellow RGB8_to_565( 0, 0,255), // bright blue RGB8_to_565(255, 0,255), // bright magenta RGB8_to_565( 0,255,255), // bright cyan RGB8_to_565(255,255,255), // bright white RGB8_to_565( 0, 0, 0), // faint black RGB8_to_565( 64, 0, 0), // faint red
{ 5 * 8 + 11 * 16 + 2, 2 * 16, 1, 0, KEYD_ENTER, key_return }, { 0, 3 * 16, 1, 0, KEYD_RSHIFT, key_shift }, { 6 * 8, 3 * 16, 0, 0, 0, key_row_4, key_row_4_shift }, { 256 - 16 * 2, 3 * 16, 2, 0, KEYD_UPARROW, 0 }, { 0, 4 * 16, 1, 0, KEYD_RCTRL, key_ctrl }, { 5 * 8, 4 * 16, 1, 0, KEYD_LALT, key_alt }, { 9 * 8, 4 * 16, 1, 0, ' ', key_space }, { 256 - 16 * 3, 4 * 16, 3, 0, KEYD_LEFTARROW, 0 }, { 256 - 16 * 2, 4 * 16, 4, 0, KEYD_DOWNARROW, 0 }, { 256 - 16 * 1, 4 * 16, 5, 0, KEYD_RIGHTARROW, 0 }, { 270, 4 * 16, 6, 0, 0x200, 0 }, }; static u16 keyboard_fg = RGB8_to_565(192, 192, 192); static u16 keyboard_bg = RGB8_to_565(204, 102, 0); static int keyboard_vofs; static int keyboard_hofs; static sregion_t *key_touching = 0; static int key_touching_index = -1; static int key_in_touch = 0; static int last_in_touch = 0; static int last_index = -1; static sregion_t *last_touching = 0; static int key_down = 0; static int key_in_shift = 0;