From d380d8f693254b50acfae5d512d54553bc7bda12 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Tue, 7 Nov 2023 23:19:55 +0000 Subject: [PATCH] Add an initial GUI for the DS port --- Makefile | 10 +- arch/dbugsys.h | 2 +- arch/fdc1772.c | 2 +- hostfs.c | 2 +- nds/ControlPane.c | 272 ++++++++++++++++++++++++++++++++++++++++++++-- nds/ControlPane.h | 7 +- nds/DispKbd.c | 83 +++++--------- nds/KeyTable.h | 251 ++++++++++++++++++++++++++---------------- nds/img/bg.grit | 17 +++ nds/img/bg.png | Bin 0 -> 439 bytes nds/img/keys.grit | 14 +++ nds/img/keys.png | Bin 0 -> 1719 bytes 12 files changed, 499 insertions(+), 161 deletions(-) create mode 100644 nds/img/bg.grit create mode 100644 nds/img/bg.png create mode 100644 nds/img/keys.grit create mode 100644 nds/img/keys.png diff --git a/Makefile b/Makefile index 9bc5d05..99090b0 100644 --- a/Makefile +++ b/Makefile @@ -177,12 +177,13 @@ endif ifeq (${SYSTEM},nds) CC=arm-none-eabi-gcc +AS=arm-none-eabi-as LD=$(CC) ARM9_ARCH = -mthumb -mthumb-interwork -march=armv5te -mtune=arm946e-s CFLAGS += $(ARM9_ARCH) -ffunction-sections -fdata-sections -DSYSTEM_nds -DARM9 -DUSE_FAKEMAIN -DNO_OPEN64 -isystem $(DEVKITPRO)/libnds/include -Wno-cast-align -Wno-format LDFLAGS += -specs=ds_arm9.specs -g $(ARM9_ARCH) -Wl,--gc-sections -L$(DEVKITPRO)/libnds/lib LIBS += -lfilesystem -lfat -lnds9 -OBJS += nds/main.o +OBJS += nds/main.o nds/img/bg.o nds/img/keys.o ifneq ($(DEBUG),yes) CFLAGS += -DNDEBUG endif @@ -195,6 +196,13 @@ all: ArcEm.nds cp support_modules/*/*,ffa romfs/extnrom ndstool -c $@ -9 $< -7 $*.arm7.elf -b nds/arc.bmp "ArcEm;Archimedes Emulator;WIP" -d romfs +%.s %.h: %.png %.grit + grit $< -fts -o$* +%.s %.h: %.bmp %.grit + grit $< -fts -o$* + +nds/ControlPane.o: nds/KeyTable.h nds/img/bg.h nds/img/keys.h + ARM7_ARCH = -mthumb -mthumb-interwork -march=armv4t -mtune=arm7tdmi ARM7_CFLAGS = $(ARM7_ARCH) -Os -ffunction-sections -fdata-sections -DARM7 -isystem $(DEVKITPRO)/libnds/include ARM7_LDFLAGS = -specs=ds_arm7.specs -g $(ARM7_ARCH) -Wl,--gc-sections -L$(DEVKITPRO)/libnds/lib diff --git a/arch/dbugsys.h b/arch/dbugsys.h index e756f40..d9c151a 100644 --- a/arch/dbugsys.h +++ b/arch/dbugsys.h @@ -27,7 +27,7 @@ #undef DEBUG_HDC63463 #undef DEBUG_CONFIG -#ifdef SYSTEM_nds +#if defined(SYSTEM_nds) && defined(NDEBUG) #undef IOC_WARN #undef WARN #undef WARN_MEMC diff --git a/arch/fdc1772.c b/arch/fdc1772.c index 7039d00..605c7ff 100644 --- a/arch/fdc1772.c +++ b/arch/fdc1772.c @@ -914,7 +914,7 @@ void FDC_Init(ARMul_State *state) { FDC.drive[drive].form = avail_format; } -#if !defined(SYSTEM_win) && !defined(MACOSX) && !defined(SYSTEM_X) +#if !defined(SYSTEM_win) && !defined(MACOSX) && !defined(SYSTEM_X) && !defined(SYSTEM_nds) for (drive = 0; drive < 4; drive++) { char tmp[256]; diff --git a/hostfs.c b/hostfs.c index 7ef3bfe..c2f89ae 100644 --- a/hostfs.c +++ b/hostfs.c @@ -221,7 +221,7 @@ dbug_hostfs(const char *format, ...) } #endif -#ifdef SYSTEM_nds +#if defined(SYSTEM_nds) && defined(NDEBUG) static inline void warn_hostfs(const char *format, ...) {} #else static void diff --git a/nds/ControlPane.c b/nds/ControlPane.c index 61ec1e8..088375c 100644 --- a/nds/ControlPane.c +++ b/nds/ControlPane.c @@ -8,32 +8,83 @@ #include "ControlPane.h" #include "../arch/keyboard.h" +#include "KeyTable.h" + +#include "img/bg.h" +#include "img/keys.h" + #include #include #include -bool hasKeyboard = false; +enum { + DRAG_NONE, + DRAG_MOUSE +}; + +static int old_px = -1; +static int old_py = -1; +static int drag_mode = DRAG_NONE; + +static bool keys_caps = false; +static arch_key_id key_pressed = -1; + +static bool has_console = false; +static bool has_keyboard = false; + +static void ControlPane_InitKeyboard(ARMul_State *state); + +static void draw_floppy_leds(unsigned int leds) +{ + unsigned int floppy; + + for (floppy = 0; floppy < 4; floppy++) { + BG_PALETTE_SUB[15 - floppy] = (leds & (1 << floppy)) ? RGB8(0xff, 0xbb, 0x00) : RGB8(0x99, 0x99, 0x99); + } +} + +static void draw_floppy(unsigned int floppy, bool inserted) { + if (inserted) { + BG_PALETTE_SUB[10 - (floppy * 2)] = RGB8(0xff, 0xbb, 0x00); + BG_PALETTE_SUB[11 - (floppy * 2)] = RGB8(0xdd, 0x00, 0x00); + } else { + BG_PALETTE_SUB[10 - (floppy * 2)] = 0; + BG_PALETTE_SUB[11 - (floppy * 2)] = 0; + } +} + +/*----------------------------------------------------------------------------*/ void ControlPane_Init(ARMul_State *state) { videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankH(VRAM_H_SUB_BG); + vramSetBankI(VRAM_I_SUB_SPRITE); + oamInit(&oamSub, SpriteMapping_1D_128, false); #ifndef NDEBUG scanKeys(); int held = keysHeld(); if (held & KEY_SELECT) { - consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true); - } else + consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true); + has_console = true; + } #endif + + if (!has_console) { - Keyboard *keyboard = keyboardInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x512, 15, 0, false, true); - keyboard->OnKeyPressed = OnKeyPressed; - keyboard->OnKeyReleased = OnKeyReleased; - keyboardShow(); - hasKeyboard = true; + BGCTRL_SUB[0] = BG_TILE_BASE(1) | BG_MAP_BASE(0) | BG_COLOR_16 | BG_32x32; + + decompress(bgTiles, (void *)CHAR_BASE_BLOCK_SUB(1), LZ77Vram); + decompress(bgMap, (void *)SCREEN_BASE_BLOCK_SUB(0), LZ77Vram); + dmaCopy(bgPal, BG_PALETTE_SUB, bgPalLen); + + ControlPane_InitKeyboard(state); + + FDC_SetLEDsChangeFunc(draw_floppy_leds); + ControlPane_Redraw(); } } @@ -42,6 +93,9 @@ void ControlPane_Error(int code,const char *fmt,...) va_list args; va_start(args,fmt); + if (!has_console) + consoleDemoInit(); + /* Log it */ vprintf(fmt,args); @@ -55,3 +109,205 @@ void ControlPane_Error(int code,const char *fmt,...) /* Quit */ exit(code); } + +/*----------------------------------------------------------------------------*/ + +static void ControlPane_UpdateKeyboardLEDs(uint8_t leds); + +static void ControlPane_InitKeyboard(ARMul_State *state) +{ + static const u16 keysPal[] = { + /* 0: Not pressed, shift off, leds off */ + 0x5FBD,0x6F7B,0x5EF7,0x7FFF,0x39CE,0x4E73,0x5EF7,0x0000, + 0x0000,0x0000,0x6F7B,0x39CE,0x5FBD,0x022A,0x02FF,0x7EE0, + /* 1: Not pressed, shift off, leds on */ + 0x5FBD,0x6F7B,0x5EF7,0x7FFF,0x39CE,0x4E73,0x5EF7,0x0000, + 0x0000,0x0000,0x6F7B,0x0320,0x5FBD,0x022A,0x02FF,0x7EE0, + /* 2: Not pressed, shift on, leds off */ + 0x5FBD,0x6F7B,0x5EF7,0x7FFF,0x39CE,0x4E73,0x5EF7,0x0000, + 0x6F7B,0x0000,0x0000,0x39CE,0x5FBD,0x022A,0x02FF,0x7EE0, + /* 3: Not pressed, shift on, leds on */ + 0x5FBD,0x6F7B,0x5EF7,0x7FFF,0x39CE,0x4E73,0x5EF7,0x0000, + 0x6F7B,0x0000,0x0000,0x0320,0x5FBD,0x022A,0x02FF,0x7EE0, + /* 4: Pressed, shift off, leds off */ + 0x5FBD,0x6F7B,0x7FFF,0x5EF7,0x5EF7,0x4E73,0x39CE,0x0000, + 0x0000,0x0000,0x6F7B,0x39CE,0x5FBD,0x022A,0x02FF,0x7EE0, + /* 5: Pressed, shift off, leds on */ + 0x5FBD,0x6F7B,0x7FFF,0x5EF7,0x5EF7,0x4E73,0x39CE,0x0000, + 0x0000,0x0000,0x6F7B,0x0320,0x5FBD,0x022A,0x02FF,0x7EE0, + /* 6: Pressed, shift on, leds off */ + 0x5FBD,0x6F7B,0x7FFF,0x5EF7,0x5EF7,0x4E73,0x39CE,0x0000, + 0x6F7B,0x0000,0x0000,0x39CE,0x5FBD,0x022A,0x02FF,0x7EE0, + /* 7: Pressed, shift on, leds on */ + 0x5FBD,0x6F7B,0x7FFF,0x5EF7,0x5EF7,0x4E73,0x39CE,0x0000, + 0x6F7B,0x0000,0x0000,0x0320,0x5FBD,0x022A,0x02FF,0x7EE0 + }; + int i; + + /* We manage sprite VRAM manually here instead of using oamAllocateGfx() */ + decompress(keysTiles, SPRITE_GFX_SUB, LZ77Vram); + dmaCopy(keysPal, SPRITE_PALETTE_SUB, sizeof(keysPal)); + + KBD.leds_changed = ControlPane_UpdateKeyboardLEDs; + + has_keyboard = true; +} + +static void ControlPane_UpdateKeyboardLEDs(uint8_t leds) +{ + keys_caps = (leds & KBD_LED_CAPSLOCK); +} + +static bool ControlPane_ClickKeyboard(ARMul_State *state, int px, int py) +{ + const dvk_to_vkeybd *ktvk; + for (ktvk = dvk_to_vkeybd_map; ktvk->sprite; ktvk++) { + uint width = ((ktvk->sprite) >> 8) * 16; + uint height = 16; + + if (px >= ktvk->x && px < ktvk->x + width && + py >= ktvk->y && py < ktvk->y + height) { + keyboard_key_changed(&KBD, ktvk->kid, 0); + key_pressed = ktvk->kid; + return true; + } + } + return false; +} + +static void ControlPane_ReleaseKeyboard(ARMul_State *state) +{ + if (key_pressed != -1) { + keyboard_key_changed(&KBD, key_pressed, 1); + key_pressed = -1; + } +} + +static void ControlPane_DrawKeyboard(void) +{ + const dvk_to_vkeybd *ktvk; + uint i = 0; + + for (ktvk = dvk_to_vkeybd_map; ktvk->sprite; ktvk++) { + uint sprite = (ktvk->sprite) & 0xFF; + uint width = (ktvk->sprite) >> 8; + uint x = ktvk->x, y = ktvk->y; + uint palette = 0; + + if (keys_caps) palette |= 1; + if (ktvk->kid == key_pressed) palette |= 4; + + do { + oamSet(&oamSub, i++, x, y, 0, palette, SpriteSize_16x16, SpriteColorFormat_16Color, + &SPRITE_GFX_SUB[sprite++ * 64], -1, false, false, false, false, false); + x += 16; + } while (--width); + } +} + +/*----------------------------------------------------------------------------*/ + +static void ControlPane_ClickFloppy(ARMul_State *state, int drive) +{ + const char *err; + char tmp[256]; + + if (FDC_IsFloppyInserted(drive)) { + err = FDC_EjectFloppy(drive); + if (err == NULL) + draw_floppy(drive, false); + /* TODO: Report warning if this fails */ + } else { + sprintf(tmp, "FloppyImage%d", drive); + err = FDC_InsertFloppy(drive, tmp); + if (err == NULL) + draw_floppy(drive, true); + /* TODO: Report warning if this fails */ + } +} + +/*----------------------------------------------------------------------------*/ + +static void ControlPane_ClickTouchpad(ARMul_State *state, int px, int py) +{ + drag_mode = DRAG_MOUSE; + old_px = px; + old_py = py; +} + +static void ControlPane_DragTouchpad(ARMul_State *state, int px, int py) +{ + int newMouseX, newMouseY, xdiff, ydiff; + + xdiff = (px - old_px) << 2; + ydiff = (py - old_py) << 2; + + if (xdiff > 63) + xdiff = 63; + if (xdiff < -63) + xdiff = -63; + + if (ydiff > 63) + ydiff = 63; + if (ydiff < -63) + ydiff = -63; + + old_px += xdiff >> 2; + old_py += ydiff >> 2; + + KBD.MouseXCount = xdiff & 127; + KBD.MouseYCount = -ydiff & 127; +} + +/*----------------------------------------------------------------------------*/ + +bool ControlPane_ProcessTouchPressed(ARMul_State *state, int px, int py) +{ + if (has_keyboard && ControlPane_ClickKeyboard(state, px, py)) + return true; + + if (py > 183 || has_console) { + int drive = 3 - (px / 64); + ControlPane_ClickFloppy(state, drive); + return true; + } else if (py < 78) { + ControlPane_ClickTouchpad(state, px, py); + return true; + } + + return false; +} + +bool ControlPane_ProcessTouchHeld(ARMul_State *state, int px, int py) +{ + if (drag_mode == DRAG_MOUSE) { + ControlPane_DragTouchpad(state, px, py); + return true; + } + + return false; +} + +bool ControlPane_ProcessTouchReleased(ARMul_State *state) +{ + bool retval = false; + + ControlPane_ReleaseKeyboard(state); + + if (drag_mode != DRAG_NONE) { + drag_mode = DRAG_NONE; + old_px = -1; + old_py = -1; + retval = true; + } + + return false; +} + +/*----------------------------------------------------------------------------*/ + +void ControlPane_Redraw(void) +{ + ControlPane_DrawKeyboard(); + oamUpdate(&oamSub); +} diff --git a/nds/ControlPane.h b/nds/ControlPane.h index d47315d..25f69d1 100644 --- a/nds/ControlPane.h +++ b/nds/ControlPane.h @@ -7,7 +7,10 @@ void ControlPane_Init(ARMul_State *state); /* Report an error and exit */ void ControlPane_Error(int code,const char *fmt,...); -void OnKeyPressed(int key); -void OnKeyReleased(int key); +bool ControlPane_ProcessTouchPressed(ARMul_State *state, int px, int py); +bool ControlPane_ProcessTouchHeld(ARMul_State *state, int px, int py); +bool ControlPane_ProcessTouchReleased(ARMul_State *state); + +void ControlPane_Redraw(void); #endif diff --git a/nds/DispKbd.c b/nds/DispKbd.c index cf2708c..0e35522 100644 --- a/nds/DispKbd.c +++ b/nds/DispKbd.c @@ -14,8 +14,6 @@ #include -#include "KeyTable.h" - ARMul_State nds_statestr DTCM_BSS; void *state_alloc(int s) { return &nds_statestr; } void state_free(void *p) {} @@ -134,6 +132,7 @@ static inline void PDD_Name(Host_PollDisplay)(ARMul_State *state) RefreshMouse(state); oamUpdate(&oamMain); bgUpdate(); + ControlPane_Redraw(); } static inline void PDD_Name(Host_DrawBorderRect)(ARMul_State *state,int x,int y,int width,int height) @@ -280,24 +279,26 @@ DisplayDev_Init(ARMul_State *state) } /*-----------------------------------------------------------------------------*/ -static void ProcessKey(ARMul_State *state, int key, bool up) {; - const dvk_to_arch_key *ktak; - for (ktak = dvk_to_arch_key_map; ktak->sym; ktak++) { - if (ktak->sym == key) { - keyboard_key_changed(&KBD, ktak->kid, up); - return; - } - } - dbug_kbd("ProcessKey: unknown key: keysym=%u\n", key); -} - -void OnKeyPressed(int key) { - ProcessKey(&nds_statestr, key, false); -} -void OnKeyReleased(int key) { - ProcessKey(&nds_statestr, key, true); -} +typedef struct { + int sym; + arch_key_id kid; +} button_to_arch_key; + +/* TODO: Provide a GUI for remapping the buttons */ +static const button_to_arch_key button_to_arch_key_map[] = { + { KEY_Y, ARCH_KEY_left }, + { KEY_B, ARCH_KEY_down }, + { KEY_A, ARCH_KEY_right }, + { KEY_X, ARCH_KEY_up }, + { KEY_L, ARCH_KEY_shift_r }, + { KEY_R, ARCH_KEY_control_r }, + { KEY_LEFT, ARCH_KEY_button_1 }, + { KEY_DOWN, ARCH_KEY_button_2 }, + { KEY_RIGHT, ARCH_KEY_button_3 }, + { KEY_UP, ARCH_KEY_space }, + { 0, 0 } +}; static void ProcessButtons(ARMul_State *state, int pressed, int released) { const button_to_arch_key *btak; @@ -309,38 +310,11 @@ static void ProcessButtons(ARMul_State *state, int pressed, int released) { } }; /* ProcessButtons */ -touchPosition oldTouch; -bool touchDown = false; - -static void ProcessRelativeTouch(ARMul_State *state) { - int newMouseX, newMouseY, xdiff, ydiff; - touchPosition touch; - - touchRead(&touch); - xdiff = (touch.px - oldTouch.px) << 1; - ydiff = (touch.py - oldTouch.py) << 1; - - if (xdiff > 63) - xdiff = 63; - if (xdiff < -63) - xdiff = -63; - - if (ydiff > 63) - ydiff = 63; - if (ydiff < -63) - ydiff = -63; - - oldTouch.px += xdiff >> 1; - oldTouch.py += ydiff >> 1; - - KBD.MouseXCount = xdiff & 127; - KBD.MouseYCount = -ydiff & 127; -}; /* ProcessRelativeTouch */ - /*-----------------------------------------------------------------------------*/ int Kbd_PollHostKbd(ARMul_State *state) { + touchPosition touch; scanKeys(); int pressed = keysDown(); @@ -349,17 +323,14 @@ Kbd_PollHostKbd(ARMul_State *state) ProcessButtons(state, pressed, released); if (pressed & KEY_TOUCH) { - touchRead(&oldTouch); - if (oldTouch.py <= 112) - touchDown = true; + touchRead(&touch); + ControlPane_ProcessTouchPressed(state, touch.px, touch.py); + } else if (held & KEY_TOUCH) { + touchRead(&touch); + ControlPane_ProcessTouchHeld(state, touch.px, touch.py); } else if (released & KEY_TOUCH) { - touchDown = false; + ControlPane_ProcessTouchReleased(state); } - if (touchDown) - ProcessRelativeTouch(state); - - keyboardUpdate(); - return 0; } diff --git a/nds/KeyTable.h b/nds/KeyTable.h index a105933..bc64c19 100644 --- a/nds/KeyTable.h +++ b/nds/KeyTable.h @@ -1,107 +1,176 @@ /* Virtual Key codes */ -#include - typedef struct { - int sym; arch_key_id kid; -} button_to_arch_key; + unsigned short sprite; + short x; + short y; +} dvk_to_vkeybd; -/* TODO: Provide a GUI for remapping the buttons */ -static const button_to_arch_key button_to_arch_key_map[] = { - { KEY_Y, ARCH_KEY_left }, - { KEY_B, ARCH_KEY_down }, - { KEY_A, ARCH_KEY_right }, - { KEY_X, ARCH_KEY_up }, - { KEY_L, ARCH_KEY_shift_r }, - { KEY_R, ARCH_KEY_control_r }, - { KEY_LEFT, ARCH_KEY_button_1 }, - { KEY_DOWN, ARCH_KEY_button_2 }, - { KEY_RIGHT, ARCH_KEY_button_3 }, - { KEY_UP, ARCH_KEY_space }, - { 0, 0 } -}; +enum { + spr_f1 = 0 | (1 << 8), + spr_f2 = 1 | (1 << 8), + spr_f3 = 2 | (1 << 8), + spr_f4 = 3 | (1 << 8), + spr_f5 = 4 | (1 << 8), + spr_f6 = 5 | (1 << 8), + spr_f7 = 6 | (1 << 8), + spr_f8 = 7 | (1 << 8), + spr_f9 = 8 | (1 << 8), + spr_f10 = 9 | (1 << 8), + spr_f11 = 10 | (1 << 8), + spr_f12 = 11 | (1 << 8), + spr_up = 12 | (1 << 8), + spr_down = 13 | (1 << 8), + spr_left = 14 | (1 << 8), + spr_right = 15 | (1 << 8), -#include + spr_shift_l = 16 | (3 << 8), + spr_shift_r = spr_shift_l, + spr_caps_lock = 19 | (2 << 8), + spr_tab = 21 | (2 << 8), + spr_escape = 23 | (1 << 8), + spr_alt_l = 24 | (2 << 8), + spr_alt_r = spr_alt_l, + spr_return = 26 | (2 << 8), + spr_control_r = 28 | (2 << 8), + spr_control_l = 30 | (2 << 8), -typedef struct { - int sym; - arch_key_id kid; - bool isShift; -} dvk_to_arch_key; + spr_backspace = 32 | (1 << 8), + spr_space = 33 | (8 << 8), + spr_backslash = 41 | (2 << 8), + spr_grave = 43 | (1 << 8), + spr_1 = 44 | (1 << 8), + spr_2 = 45 | (1 << 8), + spr_3 = 46 | (1 << 8), + spr_4 = 47 | (1 << 8), -#define X(sym, kid) { sym, ARCH_KEY_ ## kid, false }, -#define C(sym, shift, kid) { sym, ARCH_KEY_ ## kid, false }, { shift, ARCH_KEY_ ## kid, true }, -static const dvk_to_arch_key dvk_to_arch_key_map[] = { - X(DVK_FOLD, escape) - X(DVK_MENU, f12) + spr_5 = 48 | (1 << 8), + spr_6 = 49 | (1 << 8), + spr_7 = 50 | (1 << 8), + spr_8 = 51 | (1 << 8), + spr_9 = 52 | (1 << 8), + spr_0 = 53 | (1 << 8), + spr_minus = 54 | (1 << 8), + spr_equal = 55 | (1 << 8), + spr_sterling = 56 | (1 << 8), + spr_q = 57 | (1 << 8), + spr_w = 58 | (1 << 8), + spr_e = 59 | (1 << 8), + spr_r = 60 | (1 << 8), + spr_t = 61 | (1 << 8), + spr_y = 62 | (1 << 8), + spr_u = 63 | (1 << 8), + + spr_i = 64 | (1 << 8), + spr_o = 65 | (1 << 8), + spr_p = 66 | (1 << 8), + spr_bracket_l = 67 | (1 << 8), + spr_bracket_r = 68 | (1 << 8), + spr_a = 69 | (1 << 8), + spr_s = 70 | (1 << 8), + spr_d = 71 | (1 << 8), + spr_f = 72 | (1 << 8), + spr_g = 73 | (1 << 8), + spr_h = 74 | (1 << 8), + spr_j = 75 | (1 << 8), + spr_k = 76 | (1 << 8), + spr_l = 77 | (1 << 8), + spr_semicolon = 78 | (1 << 8), + spr_apostrophe = 79 | (1 << 8), + + + spr_z = 80 | (1 << 8), + spr_x = 81 | (1 << 8), + spr_c = 82 | (1 << 8), + spr_v = 83 | (1 << 8), + spr_b = 84 | (1 << 8), + spr_n = 85 | (1 << 8), + spr_m = 86 | (1 << 8), + spr_comma = 87 | (1 << 8), + spr_period = 88 | (1 << 8), + spr_slash = 89 | (1 << 8), +}; - C('`', '~', grave) - C('1', '!', 1) - C('2', '@', 2) - C('3', '#', 3) - C('4', '$', 4) - C('5', '%', 5) - C('6', '^', 6) - C('7', '&', 7) - C('8', '*', 8) - C('9', '(', 9) - C('0', ')', 0) - C('-', '_', minus) - C('=', '+', equal) - X(DVK_BACKSPACE, backspace) +#define X(kid, x, y) { ARCH_KEY_ ## kid, spr_ ## kid, x, y } +static const dvk_to_vkeybd dvk_to_vkeybd_map[] = { + X(escape, 1, 165-(5*17)), + X(f1, 30+(0*17), 165-(5*17)), + X(f2, 30+(1*17), 165-(5*17)), + X(f3, 30+(2*17), 165-(5*17)), + X(f4, 30+(3*17), 165-(5*17)), + X(f5, 41+(4*17), 165-(5*17)), + X(f6, 41+(5*17), 165-(5*17)), + X(f7, 41+(6*17), 165-(5*17)), + X(f8, 41+(7*17), 165-(5*17)), + X(f9, 52+(8*17), 165-(5*17)), + X(f10, 52+(9*17), 165-(5*17)), + X(f11, 52+(10*17), 165-(5*17)), + X(f12, 52+(11*17), 165-(5*17)), - X(DVK_TAB, tab) - C('q', 'Q', q) - C('w', 'W', w) - C('e', 'E', e) - C('r', 'R', r) - C('t', 'T', t) - C('y', 'Y', y) - C('u', 'U', u) - C('i', 'I', i) - C('o', 'O', o) - C('p', 'P', p) - C('[', '{', bracket_l) - C(']', '}', bracket_r) - C('\\', '|', backslash) + X(grave, 1+(0*17), 167-(4*17)), + X(1, 1+(1*17), 167-(4*17)), + X(2, 1+(2*17), 167-(4*17)), + X(3, 1+(3*17), 167-(4*17)), + X(4, 1+(4*17), 167-(4*17)), + X(5, 1+(5*17), 167-(4*17)), + X(6, 1+(6*17), 167-(4*17)), + X(7, 1+(7*17), 167-(4*17)), + X(8, 1+(8*17), 167-(4*17)), + X(9, 1+(9*17), 167-(4*17)), + X(0, 1+(10*17), 167-(4*17)), + X(minus, 1+(11*17), 167-(4*17)), + X(equal, 1+(12*17), 167-(4*17)), + X(sterling, 1+(13*17), 167-(4*17)), + X(backspace, 1+(14*17), 167-(4*17)), - X(DVK_CTRL, control_l) - C('a', 'A', a) - C('s', 'S', s) - C('d', 'D', d) - C('f', 'F', f) - C('g', 'G', g) - C('h', 'H', h) - C('j', 'J', j) - C('k', 'K', k) - C('l', 'L', l) - C(';', ':', semicolon) - C('\'', '"', apostrophe) - X(DVK_ENTER, return) + X(tab, 1, 167-(3*17)), + X(q, 27+(0*17), 167-(3*17)), + X(w, 27+(1*17), 167-(3*17)), + X(e, 27+(2*17), 167-(3*17)), + X(r, 27+(3*17), 167-(3*17)), + X(t, 27+(4*17), 167-(3*17)), + X(y, 27+(5*17), 167-(3*17)), + X(u, 27+(6*17), 167-(3*17)), + X(i, 27+(7*17), 167-(3*17)), + X(o, 27+(8*17), 167-(3*17)), + X(p, 27+(9*17), 167-(3*17)), + X(bracket_l, 27+(10*17), 167-(3*17)), + X(bracket_r, 27+(11*17), 167-(3*17)), + X(backslash, 27+(12*17), 167-(3*17)), - X(DVK_SHIFT, shift_l) - C('z', 'Z', z) - C('x', 'X', x) - C('c', 'C', c) - C('v', 'V', v) - C('b', 'B', b) - C('n', 'N', n) - C('m', 'M', m) - C(',', '<', comma) - C('.', '>', period) - C('/', '?', slash) + X(control_l, 1, 167-(2*17)), + X(a, 35+(0*17), 167-(2*17)), + X(s, 35+(1*17), 167-(2*17)), + X(d, 35+(2*17), 167-(2*17)), + X(f, 35+(3*17), 167-(2*17)), + X(g, 35+(4*17), 167-(2*17)), + X(h, 35+(5*17), 167-(2*17)), + X(j, 35+(6*17), 167-(2*17)), + X(k, 35+(7*17), 167-(2*17)), + X(l, 35+(8*17), 167-(2*17)), + X(semicolon, 35+(9*17), 167-(2*17)), + X(apostrophe, 35+(10*17), 167-(2*17)), + X(return, 36+(11*17), 167-(2*17)), - X(DVK_CAPS, caps_lock) - X(DVK_ALT, alt_l) - X(DVK_SPACE, space) + X(shift_l, 1, 167-(1*17)), + X(z, 43+(0*17), 167-(1*17)), + X(x, 43+(1*17), 167-(1*17)), + X(c, 43+(2*17), 167-(1*17)), + X(v, 43+(3*17), 167-(1*17)), + X(b, 43+(4*17), 167-(1*17)), + X(n, 43+(5*17), 167-(1*17)), + X(m, 43+(6*17), 167-(1*17)), + X(comma, 43+(7*17), 167-(1*17)), + X(period, 43+(8*17), 167-(1*17)), + X(slash, 43+(9*17), 167-(1*17)), + X(shift_r, 44+(10*17), 167-(1*17)), - X(DVK_UP, up) - X(DVK_LEFT, left) - X(DVK_DOWN, down) - X(DVK_RIGHT, right) + X(caps_lock, 1, 167-(0*17)), + X(alt_l, 47, 167-(0*17)), + X(space, 73, 167-(0*17)), + X(alt_r, 192, 167-(0*17)), + X(control_r, 231, 167-(0*17)), - { 0, 0, false }, + { 0, 0, 0, 0 } }; -#undef C -#undef X diff --git a/nds/img/bg.grit b/nds/img/bg.grit new file mode 100644 index 0000000..617dce0 --- /dev/null +++ b/nds/img/bg.grit @@ -0,0 +1,17 @@ +# graphics in tile format +-gt + +# tile reduction by tiles, palette and hflip/vflip +-mRtf + +# graphics bit depth is 4 (16 color) +-gB4 + +# include palette data +-p + +# map layout standard bg format +-mLs + +# use lz77 compression +-gzl -mzl diff --git a/nds/img/bg.png b/nds/img/bg.png new file mode 100644 index 0000000000000000000000000000000000000000..3ef09fd355f697a8a2fc0b86f638a6c9c21c7b7b GIT binary patch literal 439 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K54zMr-Ny)}w#*I3d4s4p2~}#5JPCv9u&3zlb5oGuTf3JH4eVVxu#@pc3Smi%>gbT`f$5_!rL~kx!un--*0{rzAbwB zlvk04r>_VoI5aRYGO=(FU^HX}zWVq1ss&R}?23eW_Z@7Sey#3!`k2w>V7cJ=-=L6! z0|Tb3-S-dN+ZC?=&$asdyj8i`cPIKkYWi&X%{lw}ME|7yF-iY(WvxGXzPXFVdQ I&MBb@0PAR?3jhEB literal 0 HcmV?d00001 diff --git a/nds/img/keys.grit b/nds/img/keys.grit new file mode 100644 index 0000000..6745630 --- /dev/null +++ b/nds/img/keys.grit @@ -0,0 +1,14 @@ +# exclude map data +-m! + +# graphics bit depth is 4 (16 color) +-gB4 + +# exclude palette data +-p! + +# metatile is 2x2 tiles (16x16 pixels) +-Mw2 -Mh2 + +# use lz77 compression +-gzl diff --git a/nds/img/keys.png b/nds/img/keys.png new file mode 100644 index 0000000000000000000000000000000000000000..c677cfc7967a37bfe410190cb79353d3a0165c72 GIT binary patch literal 1719 zcmV;o21xmdP)EaE4d6q8TYA+wp(q92UYpD21?NvtCwMujf(A4(-hu0dk(hZbVQr7vh*M68L)T&ml zU#*)<015$A9Z$>?*0HX!p9-}bMk&<3tn0>>Ev}9M8Uj$b1r1ohfi|Eul$AoQV_joC z_jAv=VH|)T&X?`@DzgP@1!zue0k4ouovfI*hRPaE4;DzbAOX-;RviJXrp`~q_34(? zCjgpg<+v3Y3#e1hmG}bdrp`H`9R?=WN_!t@v<@vm&Y1eZ!{7Hyui^jxBm{YXmL`Cw zNkMTrl)sB2sy|mg*Dq}^GVPoXqyTSMme2J|+lx#)IbkS&`hl)1f1K%;wgW)Yeg(ik zSaxUoV*vcwcoN{Re+fW83c!ag|HJ>IfplU4?S&@_5)K=F-T4{=C<4&%t6l-P1^|?g z9?I7>4FjmUiC30bpy3s|aGU_B6+q$MDF#?;C?8M`$^Njx#6=7O@KMFCFYg0B9nb_| zJB9!{1c1yU1fZH=3t$vavI4kXcHP0izAIV4ZJUpBI<f5^b)rIw96vJ_l4%4lMBN4x$r2@Em|g97GxM16@~sKi4m5e=joaS%5#1j+e@p z>N)mj+BrVIyxuHs+~Osvpze?HvqAZ0GvSr3&?5q z6U${Dy&eXz09=#r0^p`P_5lVM0BD9SC`U8h+X8Yp2XGjt&;n&QjCb|{J4c%VC|dv+ zpiDj>7qq~`-U0+D_e1NoF>Uk~$l?2)1HUH##^v43@&W*>yawf$OPb^J?Et$J;3X-a zfB4$C{V08P+wU1!0hGAHvZV*0T#Yj(5G4S# zCIX-{UKm{Aujhw+)Vz)Va07K~@#f(rLuEa;3w2|1rJQv^^A2#yQ! z`N0k6z+xreZr{gi#_75*b`U)q;L5oDC|&HHEL%RXy#?+TJHwrg<2mZGi-Qrhul?Xe zle3AQ=aUb|UBi7F0oc1DT0rLF^bT(O!O@wvQ{F&#KB{K`K|lz6I0b+o5F~|F)JFhV zFEPqd{AU1)egnmp5%UUso&eU{G6Gcb7YvT$BkdJ`Sil5jiTh*TQ1x>kh4GRAI*|id zoiGLHG5#N000!>j1cWRQXF36Z>9bpK8URzN6o4n3XrjaiI3>e=2L$NNc?(e77Hmq9 zeG6!U68lLrL;zx$BT!217>MRM+JfZ$q~!F|?{ya^EG}Em_Y+$_u;l}f%m<3k%H8Ap zrvdKmRKFnr-{a{T&G&o^uj3+e*KZ29POZ<~WC1zl<9!_8xqgvLbT{OD!r%2i55U*% zk%CK?1SgDs_>ET@_}a}YCriLzKyI)A-hKstKq%XMet_|Q7)xCLOwFgcGR zzE;Qaof8iH0C8jifBnA23Ds2UF()cVAi{(h4_i=9 zzxW*JzRN-MY=C>m_ZtE37vDG8WRp!c*<_PVHrZs8O*YwNlTAJ;{{f-wx*SkmG~fUL N002ovPDHLkV1g9;0PO$( literal 0 HcmV?d00001