Previous: The Module-Calling Cycle
Up: Converting Attract Mode into Main Program
Next: State Machine
Previous Page: The Module-Calling Cycle
Next Page: State Machine
In multiple-program format, each module program not only gets automatic
initialization, it also has the operating system cleaning up after it
when it exits. In monoprogram format, this benefit is also lost.
It is therefore important for the menu section of the attract to close
certain things down after each module returns.
- kfClose. Few, if any, dialogue modules are careful to close
their keyed files before they exit. PDisplay, however, allows
only one keyed file to be open at once, so kfClose has to be called
before the next kfOpen.
- Reclaiming the heap. This is a very delicate matter, and whether
it should be done from the Attract menu at all depends on the individual
dialogue. Some dialogues will permit the heap to be marked before a module
is called, and released afterward. With others, the use of the heap
is too intricate, and requires at least some of the modules themselves
to do all cleaning of the heap.