55 lines
837 B
C
55 lines
837 B
C
|
#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;
|
||
|
}
|