File:  [HATARI the Atari ST Emulator] / hatari / tools / hconsole / example.py
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 9 08:54:53 2019 UTC (7 years, 3 months ago) by root
Branches: hatari, MAIN
CVS tags: hatari02210, hatari02200, hatari02100, hatari02000, hatari01900, hatari01800, HEAD
hatari 1.8.0

#!/usr/bin/env python
#
# This is an example of scripting hatari using hconsole
#
# Run with (using correct EmuTOS path):
#   PATH=../../build/src/:$PATH ./example.py --tos etos512k.img
# Or if Hatari and hconsole are installed to the system:
#   /usr/share/hatari/hconsole/example.py --tos etos512k.img

import hconsole, os, sys

# path for this script
path = os.path.dirname(sys.argv[0])
# current work directory
cwd = os.path.abspath(os.path.curdir)

# shortcuts to hconsole stuff
#
# GEMDOS emulation dir is given because without
# a disk, EmuTOS console invocation is ~8s
main = hconsole.Main(sys.argv + ["."])
code = hconsole.Scancode

# execute commands from external file in current directory
main.script(path + "/example-commands")

# define shortcut functions for entering specific key presses
def backspace():
    main.run("keypress %s" % code.Backspace)
def enter():
    main.run("keypress %s" % code.Return)

# loop removing some of previously script output
for i in range(25):
    backspace()
enter()

# output some text to EmuTOS console in a loop
for i in range(3):
    main.run("text echo Welcome to 'hconsole'")
    enter()

# ask Hatari debugger to parse breakpoint etc commands from file
main.run("parse %s/example-debugger" % path)

# hit a Getdrv() breakpoint when EmuTOS prompt is redrawn
enter()

# wait few secs and kill Hatari
main.run("sleep 3")
main.run("kill")

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.