summaryrefslogtreecommitdiffstats
path: root/misplays.c
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-05-07 04:42:24 -0400
committerMalfurious <m@lfurio.us>2024-05-08 05:57:59 -0400
commit27bb9ccc06b715ea8f76c269e8bc2fab03110155 (patch)
treecc159f7474a1043ec733088326dcdeaec2623b9e /misplays.c
parent635cfa9d02cff374b1e8cff1493aef178f73cfab (diff)
downloadmisplays-27bb9ccc06b715ea8f76c269e8bc2fab03110155.tar.gz
misplays-27bb9ccc06b715ea8f76c269e8bc2fab03110155.zip
Only update ncurses display on activity or keypressHEADmaster
Previously, the test UI logic would constantly regenerate and print the screen's contents every iteration of the main processing loop to naively ensure that changes to the underlying system were reflected immediately. Sometimes, this would result in a screen flicker due to the rapid clearing and printing. This makes the UI a bit smarter about when refreshes occur, by monitoring activity results from the debugger and console modules in addition to user input. This should improve the screen flicker performance. This also addresses an issue selecting text on the screen, which was previously not possible due to the rapid refreshing as well. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'misplays.c')
-rw-r--r--misplays.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/misplays.c b/misplays.c
index a2535c3..3e3ae20 100644
--- a/misplays.c
+++ b/misplays.c
@@ -193,10 +193,12 @@ static void info_update(struct thread *th, PANEL *pan) {
disasm(th, pan);
}
-static void wait_all_threads(struct list *processes) {
+static int wait_all_threads(struct list *processes) {
+ int action = 0;
for (struct process *proc = processes->head; proc != processes->end; proc = proc->next) {
- dbg_sync(proc);
+ action |= dbg_sync(proc);
}
+ return action;
}
static void layout(struct list *processes, struct thread *th) {
@@ -286,14 +288,11 @@ int main(int argc, char **argv) {
int quit = 0;
int mode = 0;
+ int dirty = 1;
+ int pressed = 0;
while (!quit) {
- wait_all_threads(&processes);
- layout(&processes, th);
- console_update(&cons, right);
- info_update(th, left);
- cursupdate();
-
int ch = getch();
+ pressed = 1;
if (mode == 0) {
switch (ch) {
@@ -406,6 +405,9 @@ int main(int argc, char **argv) {
b->enabled = en;
b->tid = tid;
break;
+ case ERR:
+ pressed = 0;
+ break;
}
} else {
switch (ch) {
@@ -417,12 +419,23 @@ int main(int argc, char **argv) {
console_leave(&cons, right);
break;
case ERR:
+ pressed = 0;
break;
default:
console_input(&cons, ch);
break;
}
}
+
+ dirty |= wait_all_threads(&processes);
+ dirty |= console_update(&cons, right);
+
+ if (dirty || pressed) {
+ layout(&processes, th);
+ info_update(th, left);
+ cursupdate();
+ dirty = 0;
+ }
}
for (struct process *p = processes.head; p != processes.end; p = p->next) {