@if SAVESTATE

#### BEGIN savestate.script ############################################

# Common elements for saving PDP-8 CPU and core states to disk, included
# into all generated *.script files.  Based on a post by Mark Pizzolato:
#
#   https://github.com/simh/simh/issues/681#issuecomment-483735676
#
# with modifications by Warren Young.

    SET ENV statefile=%HOME%/.pidp8i-@SHORTNAME@.state
    ON SIGTERM SAVE %statefile% ; EXIT
    IF NOT EXIST %statefile% GOTO boot

:restore
    RESTORE %statefile%
    DELETE  %statefile%
    CONTINUE
    GOTO end

:boot

#### END savestate.script ##############################################

@endif
