mirror of
https://github.com/rkujawa/rk65c02.git
synced 2024-06-01 20:41:32 +00:00
Add minimal support for guile.
This commit is contained in:
parent
a1785ae68d
commit
6b8d29b21e
18
src/Makefile
18
src/Makefile
|
@ -1,13 +1,14 @@
|
||||||
CLI=rk65c02cli
|
CLI=g65c02
|
||||||
CLI_OBJS=rk65c02cli.o
|
CLI_OBJ=$(CLI).o
|
||||||
|
|
||||||
LIB_OBJS=rk65c02.o bus.o instruction.o emulation.o debug.o device_ram.o device_serial.o
|
LIB_OBJS=rk65c02.o bus.o instruction.o emulation.o debug.o device_ram.o device_serial.o
|
||||||
LIB_SO=librk65c02.so
|
LIB_SO=librk65c02.so
|
||||||
LIB_STATIC=librk65c02.a
|
LIB_STATIC=librk65c02.a
|
||||||
|
|
||||||
LDFLAGS_SO=-shared
|
LDFLAGS_SO=-shared
|
||||||
LDFLAGS_CLI=-lreadline
|
LDFLAGS_CLI=`pkg-config --libs guile-2.2`
|
||||||
CFLAGS=-Wall -fpic -ggdb
|
CFLAGS=-Wall -fpic -ggdb $(CFLAGS_EXTRA)
|
||||||
|
CFLAGS_CLI=`pkg-config --cflags guile-2.2`
|
||||||
|
|
||||||
65C02ISA=65c02isa
|
65C02ISA=65c02isa
|
||||||
EMULATION=emulation
|
EMULATION=emulation
|
||||||
|
@ -16,8 +17,11 @@ DEVICE=device
|
||||||
|
|
||||||
all : $(LIB_SO) $(LIB_STATIC) $(CLI)
|
all : $(LIB_SO) $(LIB_STATIC) $(CLI)
|
||||||
|
|
||||||
$(CLI) : $(CLI_OBJS)
|
$(CLI) : $(CLI_OBJ)
|
||||||
$(CC) -o $(CLI) $(LDFLAGS_CLI) $(CLI_OBJS) $(LIB_STATIC)
|
$(CC) -o $(CLI) $(LDFLAGS_CLI) $(CLI_OBJ) $(LIB_STATIC)
|
||||||
|
|
||||||
|
$(CLI_OBJ) : $(CLI).c
|
||||||
|
$(CC) $(CFLAGS_CLI) -c $<
|
||||||
|
|
||||||
$(LIB_SO) : $(LIB_OBJS)
|
$(LIB_SO) : $(LIB_OBJS)
|
||||||
$(CC) -o $(LIB_SO) $(LDFLAGS_SO) $(LIB_OBJS)
|
$(CC) -o $(LIB_SO) $(LDFLAGS_SO) $(LIB_OBJS)
|
||||||
|
@ -37,6 +41,6 @@ $(EMULATION).h : $(65C02ISA).csv $(EMULATION).awk
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -f $(65C02ISA).h $(EMULATION).h
|
rm -f $(65C02ISA).h $(EMULATION).h
|
||||||
rm -f $(LIB_OBJS) $(CLI_OBJS)
|
rm -f $(LIB_OBJS) $(CLI_OBJ)
|
||||||
rm -f $(LIB_SO) $(LIB_STATIC) $(CLI)
|
rm -f $(LIB_SO) $(LIB_STATIC) $(CLI)
|
||||||
|
|
||||||
|
|
63
src/g65c02.c
Normal file
63
src/g65c02.c
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include <libguile.h>
|
||||||
|
|
||||||
|
#include "bus.h"
|
||||||
|
#include "rk65c02.h"
|
||||||
|
|
||||||
|
static void guile_main(void *, int, char**);
|
||||||
|
|
||||||
|
static SCM wrap_bus_init(void);
|
||||||
|
static SCM wrap_rk65c02_init(void);
|
||||||
|
|
||||||
|
static rk65c02emu_t e;
|
||||||
|
static bool rk65c02emu_inited;
|
||||||
|
static bus_t b;
|
||||||
|
static bool bus_inited;
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
scm_boot_guile(argc, argv, guile_main, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
guile_main(void* data, int argc, char** argv) {
|
||||||
|
scm_c_define_gsubr("bus-init", 0, 0, 0, wrap_bus_init);
|
||||||
|
scm_c_define_gsubr("rk65c02-init", 0, 0, 0, wrap_rk65c02_init);
|
||||||
|
|
||||||
|
scm_shell(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
wrap_bus_init(void)
|
||||||
|
{
|
||||||
|
if (bus_inited)
|
||||||
|
return SCM_BOOL_F;
|
||||||
|
|
||||||
|
/* XXX: make this customizable */
|
||||||
|
b = bus_init_with_default_devs();
|
||||||
|
|
||||||
|
bus_inited = true;
|
||||||
|
|
||||||
|
return SCM_BOOL_T;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
wrap_rk65c02_init(void)
|
||||||
|
{
|
||||||
|
if (rk65c02_inited)
|
||||||
|
return SCM_BOOL_F;
|
||||||
|
|
||||||
|
e = rk65c02_init(&b);
|
||||||
|
|
||||||
|
rk65c02emu_inited = true;
|
||||||
|
|
||||||
|
return SCM_BOOL_T;
|
||||||
|
}
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <readline/readline.h>
|
|
||||||
#include <readline/history.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user