summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/sux.c b/sux.c
index 4a08d59..cf66bfd 100644
--- a/sux.c
+++ b/sux.c
@@ -1,7 +1,5 @@
#include "sux.h"
#include <assert.h>
-#include <ctype.h>
-#include <string.h>
#if getclk
uint64_t clk[THREADS]; /* Per Thread Clock cycles. */
@@ -512,7 +510,7 @@ void *run(void *args) {
#if getclk
wprintw(scr, ", Clock cycles: %"PRIu64, iclk);
#endif
- if (!step && !subdbg) {
+ if (step && !subdbg) {
wrefresh(scr);
}
#if keypoll
@@ -540,7 +538,8 @@ void init_scr() {
if (!scr) {
scr = initscr();
}
- nodelay(stdscr, 0);
+ nodelay(scr, 0);
+ wtimeout(scr, 8);
crmode();
noecho();
nl();
@@ -556,6 +555,7 @@ int main(int argc, char **argv) {
struct suxthr thr[THREADS];
char *tmp = malloc(2048);
addr = malloc(mem_size);
+ memset(key, 0, sizeof(key));
#if bench
inss = 0;
#endif
@@ -637,14 +637,24 @@ int main(int argc, char **argv) {
#if keypoll
pthread_mutex_lock(&mutex);
#endif
+ c = get_key(scr);
+ if (c == 19) {
+ if (kbd_rdy) {
+
+ c = get_key(scr);
+ }
+ step = 1;
+ } else if (c == 0x11) {
+ end = 1;
+ continue;
+ }
if (step) {
- keypad(scr, 1);
- c = wgetch(scr);
if (c != 19 && c != 18 && c != 0x11 && !isalnum(c)) {
/*WINDOW *w;
int maxcol = getmaxx(scr)/2;
int maxrow = getmaxy(scr)/2;*/
- switch (c) {
+ int keycode = get_keycode(key);
+ switch (keycode) {
case KEY_F(1):
/*w = newwin(maxrow, maxcol, maxrow, maxcol);
emumon(w);
@@ -663,20 +673,7 @@ int main(int argc, char **argv) {
wprintw(scr, "c: %i", c);
wmove(scr, y, x);
#endif
- c = 0;
}
- keypad(scr, 0);
- } else {
- c = wgetch(scr);
- }
- if (c == 19) {
- if (kbd_rdy) {
- c = wgetch(scr);
- }
- step = 1;
- } else if (c == 0x11) {
- end = 1;
- continue;
}
if (kbd_rdy) {
switch (c) {
@@ -691,7 +688,11 @@ int main(int argc, char **argv) {
#if debug && !bench
wmove(scr, getmaxy(scr)-1, 0);
wclrtoeol(scr);
- wprintw(scr, "c: %i", c);
+ wprintw(scr, "c: %i ", c);
+ wprintw(scr, "key: ");
+ for (int i = 0; key[i] != '\0'; i++) {
+ wprintw(scr, "$%02X%s", key[i], (key[i+1] != '\0') ? ", " : "");
+ }
wmove(scr, y, x);
#endif
}