From 1241b43ea782f9e97133e4dcdd4784344c7a198f Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 24 Jan 2018 16:39:29 +0300 Subject: [PATCH] no message --- src/console.c | 2 +- src/studio.c | 21 +++++++++++++++++++++ src/studio.h | 4 +++- src/tic.c | 18 ------------------ src/ticapi.h | 1 - 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/console.c b/src/console.c index bd5297f..e964220 100644 --- a/src/console.c +++ b/src/console.c @@ -2615,7 +2615,7 @@ static void tick(Console* console) tic_mem* tic = console->tic; - char sym = tic->api.keytext(tic); + char sym = getKeyboardText(); if(sym) { diff --git a/src/studio.c b/src/studio.c index 6148af1..f258d26 100644 --- a/src/studio.c +++ b/src/studio.c @@ -321,6 +321,27 @@ static struct .argv = NULL, }; + +char getKeyboardText() +{ + tic_mem* tic = studioImpl.studio.tic; + + static const char Symbols[] = "abcdefghijklmnopqrstuvwxyz0123456789-=[]\\;'`,./ "; + static const char Shift[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ)!@#$%^&*(_+{}|:\"~<>? "; + + enum{Count = sizeof Symbols, Hold = 20, Period = 3}; + + for(s32 i = 0; i < TIC80_KEY_BUFFER; i++) + { + tic_key key = tic->ram.input.keyboard.keys[i]; + + if(key > 0 && key < Count && tic->api.keyp(tic, key, Hold, Period)) + return tic->api.key(tic, tic_key_shift) ? Shift[key-1] : Symbols[key-1]; + } + + return 0; +} + tic_tiles* getBankTiles() { return &studioImpl.studio.tic->cart.banks[studioImpl.bank.index.sprites].tiles; diff --git a/src/studio.h b/src/studio.h index 7b0ef46..229279f 100644 --- a/src/studio.h +++ b/src/studio.h @@ -206,4 +206,6 @@ typedef struct Studio* studioInit(s32 argc, char **argv, s32 samplerate); void studioTick(void* pixels); -void studioClose(); \ No newline at end of file +void studioClose(); + +char getKeyboardText(); diff --git a/src/tic.c b/src/tic.c index 77e56bb..e62772c 100644 --- a/src/tic.c +++ b/src/tic.c @@ -1714,23 +1714,6 @@ static bool api_keyp(tic_mem* tic, tic_key key, s32 hold, s32 period) return false; } -static char api_keytext(tic_mem* tic) -{ - static const char Symbols[] = "abcdefghijklmnopqrstuvwxyz0123456789-=[]\\;'`,./ "; - static const char Shift[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ)!@#$%^&*(_+{}|:\"~<>? "; - - enum{Count = sizeof Symbols, Hold = 20, Period = 3}; - - for(s32 i = 0; i < TIC80_KEY_BUFFER; i++) - { - tic_key key = tic->ram.input.keyboard.keys[i]; - - if(key > 0 && key < Count && tic->api.keyp(tic, key, Hold, Period)) - return tic->api.key(tic, tic_key_shift) ? Shift[key-1] : Symbols[key-1]; - } - - return 0; -} static void api_load(tic_cartridge* cart, const u8* buffer, s32 size, bool palette) { const u8* end = buffer + size; @@ -1960,7 +1943,6 @@ static void initApi(tic_api* api) INIT_API(btnp); INIT_API(key); INIT_API(keyp); - INIT_API(keytext); INIT_API(load); INIT_API(save); INIT_API(tick_start); diff --git a/src/ticapi.h b/src/ticapi.h index f6ae5eb..4fc66f4 100644 --- a/src/ticapi.h +++ b/src/ticapi.h @@ -156,7 +156,6 @@ typedef struct u32 (*btnp) (tic_mem* memory, s32 id, s32 hold, s32 period); bool (*key) (tic_mem* memory, tic_key key); bool (*keyp) (tic_mem* memory, tic_key key, s32 hold, s32 period); - char (*keytext) (tic_mem* memory); void (*load) (tic_cartridge* rom, const u8* buffer, s32 size, bool palette); s32 (*save) (const tic_cartridge* rom, u8* buffer);