5 include "interpreter.h";
9 constant HEAP_SIZE $7FFF;
10 array heap -> HEAP_SIZE;
11 array parsebuffer -> 256;
13 ! Draw the status line.
22 print "baZic 0.1 (C) 2001 David Given. ";
23 ! We add on some stuff in the next line, because we don't want to
24 ! include the input buffer in the memory count.
25 print (mem_countfree()+255+AB__SIZE), " bytes free.";
31 ! Read in a command from the user into the parse buffer.
33 [ read_interactive_command buf in;
38 ! Prompt the user for input.
42 read buf 0 draw_status;
44 ! Ensure the string is zero-terminated.
49 ! Tokenise the stream.
51 in = tokenise_stream(in, parsebuffer);
57 ! Clear all variables and reinit the heap.
60 mem_init(store_eop+1, heap+HEAP_SIZE);
65 ! Invoke a command loop.
67 [ command_loop func i;
75 !detokenise_stream(parsebuffer+1);
76 i = execute_command(parsebuffer);
80 print "Insufficient memory for interactive prompt!^";
81 print "Dumping variables and trying again.^";
85 -3: ! end of program or script or whatever
89 default: ! parse error
90 print "Parse error at offset ", i, ".^";
99 print "^^^^^^^^baZic v0.1^(C) 2001 David Given^^";
100 print "To play ~Hunt the Wumpus~, type ~script 2~ to load ";
101 print "the program, and then ~run~ to start it. Try ~script~ on its ";
102 print "own to see what else is available.^^";
105 store_init(heap, heap+HEAP_SIZE);
107 i = command_loop(read_interactive_command);
108 } until ((i == ESTATE_QUIT) || (i == ESTATE_NEW));
109 } until (i == ESTATE_QUIT);