summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c111
1 files changed, 15 insertions, 96 deletions
diff --git a/sux.c b/sux.c
index cf66bfd..3082632 100644
--- a/sux.c
+++ b/sux.c
@@ -33,6 +33,8 @@ uint8_t *addr;
uint8_t kbd_rdy;
+uint8_t end = 0;
+
WINDOW *scr;
struct suxthr {
@@ -489,13 +491,15 @@ void *run(void *args) {
ins++;
#endif
#if !bench
- if (step) {
+ if (end) {
pthread_mutex_lock(&main_mutex);
pthread_cond_signal(&main_cond);
pthread_mutex_unlock(&main_mutex);
- pthread_mutex_lock(&mutex);
- pthread_cond_wait(&cond, &mutex);
- pthread_mutex_unlock(&mutex);
+ return NULL;
+ }
+ if (step) {
+ int c = 0;;
+ for (; step && c != 19 && !end; c = get_key(scr));
#if debug
wrefresh(scr);
#endif
@@ -539,7 +543,7 @@ void init_scr() {
scr = initscr();
}
nodelay(scr, 0);
- wtimeout(scr, 8);
+ keypad(scr, 1);
crmode();
noecho();
nl();
@@ -551,11 +555,13 @@ void init_scr() {
attron(COLOR_PAIR(1) | A_BOLD);
}
+
+
+
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
@@ -609,102 +615,15 @@ int main(int argc, char **argv) {
result = pthread_create(&therads[i], NULL, run, &thr[i]);
assert(!result);
}
- int c = 0;
- uint8_t step_key = 0;
- uint8_t end = 0;
werase(scr);
while (threads_done < THREADS && !end) {
#if !bench
- int x, y;
- if ((step_key && step && !kbd_rdy) || !step || kbd_rdy) {
- if ((c != EOF && c !=-1)) {
- #if !keypoll
- pthread_mutex_lock(&mutex);
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&mutex);
- #endif
- pthread_mutex_lock(&main_mutex);
- curs_set(0);
- pthread_cond_wait(&main_cond, &main_mutex);
- pthread_mutex_unlock(&main_mutex);
- curs_set(1);
- c = 0;
- step_key = 0;
- addr[CTRL_ADDR] = 0;
- wrefresh(scr);
- }
- }
+ pthread_mutex_lock(&main_mutex);
+ pthread_cond_wait(&main_cond, &main_mutex);
+ pthread_mutex_unlock(&main_mutex);
#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) {
- if (c != 19 && c != 18 && c != 0x11 && !isalnum(c)) {
- /*WINDOW *w;
- int maxcol = getmaxx(scr)/2;
- int maxrow = getmaxy(scr)/2;*/
- int keycode = get_keycode(key);
- switch (keycode) {
- case KEY_F(1):
- /*w = newwin(maxrow, maxcol, maxrow, maxcol);
- emumon(w);
- delwin(w);*/
- endwin();
- puts("Starting asmmon()");
- asmmon("stdin");
- puts("Reinitializing screen.");
- init_scr();
- wrefresh(scr);
- break;
- }
- #if debug && !bench
- wmove(scr, getmaxy(scr)-1, 0);
- wclrtoeol(scr);
- wprintw(scr, "c: %i", c);
- wmove(scr, y, x);
- #endif
- }
- }
- if (kbd_rdy) {
- switch (c) {
- case ERR:
- addr[CTRL_ADDR] = 0;
- break;
- case '\0': break;
- default:
- if (kbd_rdy && c < 0x100) {
- addr[RX_ADDR] = (uint8_t)c;
- addr[CTRL_ADDR] = 1;
- #if debug && !bench
- wmove(scr, getmaxy(scr)-1, 0);
- wclrtoeol(scr);
- 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
- }
- break;
- }
- } else {
- if (step) {
- step = !(c == 18);
- step_key = (c == 19);
- }
- }
- addr[STEP_ADDR] = step;
#if keypoll
pthread_mutex_unlock(&mutex);
#endif