Auto-restore

From IFWiki

Revision as of 08:07, 24 March 2019 by Zzo38 (talk | contribs) (Created page with "The auto-restore mechanism for Glulx was invented by Aaron Black. After creating windows, if the story file has just been loaded and the RESTART command hasn't been used,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The auto-restore mechanism for Glulx was invented by Aaron Black.

After creating windows, if the story file has just been loaded and the RESTART command hasn't been used, and glk_gestalt(0x14FE,0x140C) returns nonzero, then it should attempt to restore a saved game; if that fails, just start the game normally.

Inform 6

TODO

Inform 7

Note that this code is untested (the author uses neither Inform6 nor Inform7, but is providing it for the convenience of those who do use Inform). (If it is wrong and you know how to fix it, you may do so.)

Auto-restore (for Glulx only) by Aaron Black begins here.

[Public domain]

Use authorial modesty.

Include (-
  Global auto_restoring_var = 0;
-).

Before starting the virtual machine: (-
  @glk $0022 0 auto_restoring_var;
-).

Include (-
  [ AUTORESTORE_R;
    @jnz auto_restoring_var 0;
    @copy $140C sp;
    @copy $14FE sp;
    @glk $0004 2 sp;
    @jz sp 0;
    @callf IMMEDIATELY_RESTORE_SAVED_R 0;
    @return 0;
  ];
-).

The auto-restore rule translates into I6 as "AUTORESTORE_R".

The auto-restore rule is listed first in the when play begins rules.

Auto-restore ends here.