1 !% $MAX_STATIC_DATA=150000
6 include "interpreter.h";
10 constant HEAP_SIZE $7FFF;
11 array heap -> HEAP_SIZE;
12 array parsebuffer -> 256;
14 ! Draw the status line.
23 print "baZic 0.1 (C) 2001 David Given. ";
24 ! We add on some stuff in the next line, because we don't want to
25 ! include the input buffer in the memory count.
26 print (mem_countfree()+255+AB__SIZE), " bytes free.";
32 ! Read in a command from the user into the parse buffer.
34 [ read_interactive_command buf in;
39 ! Prompt the user for input.
43 read buf 0 draw_status;
45 ! Ensure the string is zero-terminated.
50 ! Tokenise the stream.
52 in = tokenise_stream(in, parsebuffer);
58 ! Clear all variables and reinit the heap.
61 mem_init(store_eop+1, heap+HEAP_SIZE);
66 ! Invoke a command loop.
68 [ command_loop func i;
76 !detokenise_stream(parsebuffer+1);
77 i = execute_command(parsebuffer);
81 print "Insufficient memory for interactive prompt!^";
82 print "Dumping variables and trying again.^";
86 -3: ! end of program or script or whatever
90 default: ! parse error
91 print "Parse error at offset ", i, ".^";
100 print "^^^^^^^^baZic v0.1^(C) 2001 David Given^^";
101 print "To play ~Hunt the Wumpus~, type ~script 2~ to load ";
102 print "the program, and then ~run~ to start it. Try ~script~ on its ";
103 print "own to see what else is available.^^";
106 store_init(heap, heap+HEAP_SIZE);
108 i = command_loop(read_interactive_command);
109 } until ((i == ESTATE_QUIT) || (i == ESTATE_NEW));
110 } until (i == ESTATE_QUIT);