Restarting Games

From AGI Wiki
Jump to navigationJump to search

The restart.game command is used to restart a game from the beginning. Restarting a game is similar to restoring a game, except all memory is reset to its default state, all objects are unloaded, and all resources are removed from the memory heap.

If a sound is playing when restart.game command is called, AGI stops it. If reserved flag f16 (auto restart) is FALSE, a message box is displayed asking the player to confirm the restart. If f16 is TRUE, or if the player presses ENTER when asked, the game is restarted.

The restart process first caches the value of reserved flag f9 (sound on). Then the memory heap is cleared (which unloads all resources) and the OBJECT file is reloaded. The screen object table is reset, all variables are reset to 0 and all flags are reset to FALSE.

Then reserved variables v20 (computer type), v26 (monitor type), v22 (sound channel count) and reserved flag f11 (noise channel available) are restored to match current hardware capabilities.

Reserved flag f6 (game restarted) is set to TRUE, and reserved flag f9 (sound on) is restored from the value cached earlier. If a trace logic was loaded before the restore, it gets reloaded. Finally, all menu items are enabled and AGI begins a new interpreter cycle.