pete286/jopl.c
Jeremy Penner 49f532a85b JOPL adlib livecoding environment; stop including JIM files in git
I now have multiple executables that depend on the same .jor source files
and I am not diligent about ensuring that both are up-to-date and working.
As small changes to source files can cause .jim files to fail silently,
I've removed them from the repo for now.
2019-03-31 19:29:16 -04:00

55 lines
837 B
C
Executable file

#include "jorth.h"
#include "adlib.h"
#include "kbd.h"
#include "timer.h"
cell ontick = 0;
void f_adlib_read() {
PUSHU(adlib_read());
}
void f_adlib_write() {
adlib_write(TOP().u & 0xff, ST1().u & 0xff);
DROP(2);
}
static void timer_callback() {
if (ontick.p) {
f_execcp(ontick);
}
}
int DONE = 0;
static void f_quit() {
DONE = 1;
}
void do_repl() {
char buf[128];
adlib_init();
timer_init(TIMER_18HZ);
f_init();
CDEF("quit", f_quit);
CDEF("adlib!", f_adlib_write);
CDEF("adlib@", f_adlib_read);
f_loadfile("jopl.jor");
ontick = f_lookupcp("ontick");
timer_setcallback(timer_callback);
f_taskloop();
while (!DONE) {
PUSHS(gets(buf));
f_runstring("REPL send");
f_taskloop();
}
}
int main() {
do_repl();
return 0;
}