diff --git a/src/Makefile b/src/Makefile index 45d2a52..474cd42 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,28 +1,36 @@ -OBJS=rk65c02.o bus.o instruction.o emulation.o +CLI=rk65c02cli +CLI_OBJS=rk65c02cli.o + +LIB_OBJS=rk65c02.o bus.o instruction.o emulation.o LIB_SO=librk65c02.so LIB_STATIC=librk65c02.a -LDFLAGS=-shared + +LDFLAGS_SO=-shared +LDFLAGS_CLI=-lreadline CFLAGS=-Wall -fpic 65C02ISA=65c02isa -all : $(LIB_SO) $(LIB_STATIC) +all : $(LIB_SO) $(LIB_STATIC) $(CLI) -$(LIB_SO) : $(OBJS) - $(CC) -o $(LIB_SO) $(LDFLAGS) $(OBJS) +$(CLI) : $(CLI_OBJS) + $(CC) -o $(CLI) $(LDFLAGS_CLI) $(CLI_OBJS) $(LIB_STATIC) + +$(LIB_SO) : $(LIB_OBJS) + $(CC) -o $(LIB_SO) $(LDFLAGS_SO) $(LIB_OBJS) $(LIB_STATIC) : $(OBJS) - $(AR) rcs $(LIB_STATIC) $(OBJS) + $(AR) rcs $(LIB_STATIC) $(LIB_OBJS) $(65C02ISA).h : $(65C02ISA).csv $(65C02ISA).awk awk -f $(65C02ISA).awk $(65C02ISA).csv > $(65C02ISA).h -# XXX: dependency on 65c02isa.h is only for instruction.c +# XXX: dependency on 65c02isa.h is only for instruction.c ? %.o : %.c %.h $(65C02ISA).h $(CC) $(CFLAGS) -c $< clean : rm -f $(65C02ISA).h - rm -f $(OBJS) - rm -f $(LIB_SO) $(LIB_STATIC) + rm -f $(LIB_OBJS) $(CLI_OBJS) + rm -f $(LIB_SO) $(LIB_STATIC) $(CLI) diff --git a/src/rk65c02cli.c b/src/rk65c02cli.c new file mode 100644 index 0000000..1e24534 --- /dev/null +++ b/src/rk65c02cli.c @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "bus.h" +#include "instruction.h" +#include "rk65c02.h" + + +/* +int +main(void) +{ + bus_t b; + + b = bus_init(); + + bus_write_1(&b, 0, OP_INX); + bus_write_1(&b, 1, OP_NOP); + bus_write_1(&b, 2, OP_LDY_IMM); + bus_write_1(&b, 3, 0x1); + bus_write_1(&b, 4, OP_TSB_ZP); + bus_write_1(&b, 5, 0x3); + bus_write_1(&b, 6, OP_JSR); + bus_write_1(&b, 7, 0x09); + bus_write_1(&b, 8, 0x0); + bus_write_1(&b, 9, OP_STP); + + rk6502_start(&b, 0); + + bus_finish(&b); +} +*/ + + +int main() +{ + char* input, shell_prompt[100]; + + rl_bind_key('\t', rl_complete); + + while(true) { + snprintf(shell_prompt, sizeof(shell_prompt), "> "); + + input = readline(shell_prompt); + + if (!input) + break; + + add_history(input); + + free(input); + } + return EXIT_SUCCESS; +} +