summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2006-08-28 00:46:51 +0000
committerIan C <ianc@noddybox.co.uk>2006-08-28 00:46:51 +0000
commite7ed44a6f32c37c736d1e516da5df101087b90c1 (patch)
tree2c01a4d8bb1000ffb2258827c1a90348e6ed0cc7
parent8092443b5ed2d33b076749387577f4e1466735fe (diff)
Added readline to EMMA
-rw-r--r--Makefile9
-rw-r--r--emma.c27
2 files changed, 33 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index e83b30d..975c790 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@
#
# -------------------------------------------------------------------------
#
-# $Id: Makefile,v 1.7 2006-08-28 00:19:04 ianc Exp $
+# $Id: Makefile,v 1.8 2006-08-28 00:46:51 ianc Exp $
#
# This CFLAGS assumes that gcc is being used.
@@ -31,6 +31,11 @@ CFLAGS = -g -Wall -Werror -pedantic -ansi -O2 -finline-functions
#
CFLAGS += -DENABLE_DISASSEM
+# Remove the follwing to disable the use of readline
+#
+CFLAGS += -DENABLE_READLINE
+LIBS += -lreadline
+
TARGET = emma
@@ -49,7 +54,7 @@ OBJECTS = z80.o \
all: $(TARGET) emucpm.hex zexdoc.hex zexall.hex
$(TARGET): $(OBJECTS)
- cc -o $(TARGET) $(OBJECTS)
+ cc -o $(TARGET) $(OBJECTS) $(LIBS)
emucpm.hex: emucpm.z80
tpasm -P Z80 -o intel emucpm.hex emucpm.z80
diff --git a/emma.c b/emma.c
index f8f0932..94d3c89 100644
--- a/emma.c
+++ b/emma.c
@@ -30,6 +30,11 @@ static const char id[]="$Id$";
#include <signal.h>
#include <stdarg.h>
+#ifdef ENABLE_READLINE
+#include <readline/readline.h>
+#include <readline/history.h>
+#endif
+
#include "z80.h"
#include "expr.h"
@@ -1080,7 +1085,6 @@ static int IntCheck(Z80 *z80, Z80Val v)
int main(int argc, char *argv[])
{
const char *autoarg[2]={".","auto"};
- char buff[1024];
int f;
for(f=0;f<256;f++) memctl[f]=1;
@@ -1111,6 +1115,26 @@ int main(int argc, char *argv[])
while(!quit)
{
+#ifdef ENABLE_READLINE
+ char *line;
+
+ if ((line=readline("EMMA> ")))
+ {
+ if (line[0])
+ {
+ Run(line);
+ add_history(line);
+ free(line);
+ }
+ }
+ else
+ {
+ quit=TRUE;
+ continue;
+ }
+#else
+ char buff[1024];
+
Log("EMMA> ");
fflush(stdout);
@@ -1121,6 +1145,7 @@ int main(int argc, char *argv[])
}
Run(buff);
+#endif
}
return EXIT_SUCCESS;