no message

This commit is contained in:
BADIM-PC\Vadim 2018-01-24 16:39:29 +03:00
parent 29ab09efd0
commit 1241b43ea7
5 changed files with 25 additions and 21 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -206,4 +206,6 @@ typedef struct
Studio* studioInit(s32 argc, char **argv, s32 samplerate);
void studioTick(void* pixels);
void studioClose();
void studioClose();
char getKeyboardText();

View File

@ -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);

View File

@ -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);