summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile6
-rw-r--r--src/czx81.c54
2 files changed, 55 insertions, 5 deletions
diff --git a/src/Makefile b/src/Makefile
index a9a835d..8ed3914 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -15,7 +15,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
TARGET=czx81
-CURSES=-lcursesw
+
+# This library may need to be set to one of these:
+# cursesw
+# ncursesw
+CURSES=-lncurses
OBJS= czx81.o \
zx81rom.o
diff --git a/src/czx81.c b/src/czx81.c
index 57d3525..ccdceba 100644
--- a/src/czx81.c
+++ b/src/czx81.c
@@ -18,17 +18,63 @@
#include "wide_curses.h"
#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
#include <locale.h>
+static long TimeDiff(const struct timespec *start,
+ const struct timespec *end)
+{
+ long diff;
+
+ diff = (end->tv_nsec - start->tv_nsec) +
+ (end->tv_sec - start->tv_sec) * 1000000000L;
+
+ return diff;
+}
+
int main(void)
{
+ struct timespec start;
+ int quit = FALSE;
+
setlocale(LC_ALL, "");
+
initscr();
- printw("Euro\n");
- printw("\u20ac\n");
- addwstr(L"\u20AC\n");
+ raw();
+ noecho();
+ keypad(stdscr, TRUE);
+ nodelay(stdscr, TRUE);
+
+ clock_gettime(CLOCK_MONOTONIC, &start);
+
+ while(!quit)
+ {
+ struct timespec end;
+ struct timespec pause = {0};
+ int ch;
+
+ clear();
+
+ ch = getch();
+
+ if (ch == 3)
+ {
+ quit = TRUE;
+ }
+
+ refresh();
+
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ start = end;
+ pause.tv_nsec = 20000000 - TimeDiff(&start, &end);
+
+ if (pause.tv_nsec > 0)
+ {
+ nanosleep(&pause, NULL);
+ }
+ }
- getch();
endwin();
return EXIT_SUCCESS;