Annotation of hatari/tools/hconsole/example.py, revision 1.1

1.1     ! root        1: #!/usr/bin/env python
        !             2: #
        !             3: # This is an example of scripting hatari using hconsole
        !             4: #
        !             5: # Run with (using correct EmuTOS path):
        !             6: #   PATH=../../build/src/:$PATH ./example.py --tos etos512k.img
        !             7: # Or if Hatari and hconsole are installed to the system:
        !             8: #   /usr/share/hatari/hconsole/example.py --tos etos512k.img
        !             9: 
        !            10: import hconsole, os, sys
        !            11: 
        !            12: # path for this script
        !            13: path = os.path.dirname(sys.argv[0])
        !            14: # current work directory
        !            15: cwd = os.path.abspath(os.path.curdir)
        !            16: 
        !            17: # shortcuts to hconsole stuff
        !            18: main = hconsole.Main()
        !            19: code = hconsole.Scancode
        !            20: 
        !            21: # execute commands from external file in current directory
        !            22: main.script(path + "/example-commands")
        !            23: 
        !            24: # define shortcut functions for entering specific key presses
        !            25: def backspace():
        !            26:     main.run("keypress %s" % code.Backspace)
        !            27: def enter():
        !            28:     main.run("keypress %s" % code.Return)
        !            29: 
        !            30: # loop removing some of previously script output
        !            31: for i in range(25):
        !            32:     backspace()
        !            33: enter()
        !            34: 
        !            35: # output some text to EmuTOS console in a loop
        !            36: for i in range(3):
        !            37:     main.run("text echo Welcome to 'hconsole'")
        !            38:     enter()
        !            39: 
        !            40: # ask Hatari debugger to parse breakpoint etc commands from file
        !            41: main.run("parse %s/example-debugger" % path)
        !            42: 
        !            43: # hit a Getdrv() breakpoint when EmuTOS prompt is redrawn
        !            44: enter()
        !            45: 
        !            46: # wait few secs and kill Hatari
        !            47: main.run("sleep 3")
        !            48: 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.