diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2020-08-10 19:21:59 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2020-08-10 19:21:59 -0400 |
commit | a4931b7202c60749df8aeb01c1acb7d538520041 (patch) | |
tree | c4d32af75fb091583a96ced8db44e925445c9f76 /sux.h | |
parent | 2b03202a30e9da09bfc5c0d382b1f5d2287287a4 (diff) |
Refactored the keyboard I/O emulation.
It now saves the characters of the typed key into a
buffer, and returns each character in the buffer one
at a time, until it reaches a null terminator, at
which point it starts getting the next key.
The reason for doing this was to make getting multi
character keys faster, by not calling getch() for
each character.
The only downside to this is that I have to set a
timeout() for getch(), making it somewhat non
blocking, although the delay is 8 milliseconds.
The next thing I'll probably be doing, is working more
on the SuB suite.
Diffstat (limited to 'sux.h')
-rw-r--r-- | sux.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1,5 +1,7 @@ #include "opcode.h" #include <pthread.h> +#include <ctype.h> +#include <string.h> #if bench #include <sys/time.h> @@ -39,6 +41,11 @@ extern pthread_cond_t main_cond; extern void disasm(struct sux *cpu, uint64_t *operands, uint8_t lines, uint8_t opcode, uint8_t prefix, uint8_t thread); #endif +#define KEYBUF_SIZE 0x40 +char key[KEYBUF_SIZE]; + +extern int get_keycode(char *str); +extern int get_key(WINDOW *scr); extern void io(uint64_t address, uint8_t rw); static inline uint64_t get_addr(struct sux *cpu, uint64_t *tmpaddr, uint8_t opcode, uint8_t prefix, uint8_t thread) { |