commit fc61f19a0758de7429b91c7f49568b7df9085bb6
parent e853a516dc99c01835a1955b88d8608f1e2e24f3
Author: Luxferre <lux@ferre>
Date: Mon, 22 Aug 2022 20:27:21 +0300
some definition changes
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/nrj.c b/nrj.c
@@ -8,14 +8,14 @@
#include <termios.h>
#include <unistd.h>
#include <sys/select.h>
-#ifndef NRJWORD
+#ifndef NRJWORD /* we emulate NRJ16 by default */
#define NRJWORD unsigned short
#endif
#define NRJWSIZE (sizeof(NRJWORD) << 3)
#define NRJSIZE (1 << NRJWSIZE)
#define MAXADDR ((NRJWORD) (NRJSIZE - 1))
-int kbhit() {
+int kbhit() { /* our best attempt to detect a keypress on a POSIX system */
struct timeval tv = { 0L, 0L };
fd_set fds;
FD_ZERO(&fds);
@@ -66,7 +66,7 @@ int main(int argc, char* argv[]) {
fseek(prog, 0, SEEK_END);
int flen = ftell(prog);
fseek(prog, 0, SEEK_SET);
- fread(mem, NRJWSIZE, (flen/NRJWSIZE) & MAXADDR, prog);
+ fread(mem, sizeof(NRJWORD), (flen/sizeof(NRJWORD)) & MAXADDR, prog);
fclose(prog);
/* prepare the terminal */
tcgetattr(STDIN_FILENO, &tty_opts_backup);