|
|
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
1.1.1.2 ! root 18: #
! 19: # GEMDOS emulation dir is given because without
! 20: # a disk, EmuTOS console invocation is ~8s
! 21: main = hconsole.Main(sys.argv + ["."])
1.1 root 22: code = hconsole.Scancode
23:
24: # execute commands from external file in current directory
25: main.script(path + "/example-commands")
26:
27: # define shortcut functions for entering specific key presses
28: def backspace():
29: main.run("keypress %s" % code.Backspace)
30: def enter():
31: main.run("keypress %s" % code.Return)
32:
33: # loop removing some of previously script output
34: for i in range(25):
35: backspace()
36: enter()
37:
38: # output some text to EmuTOS console in a loop
39: for i in range(3):
40: main.run("text echo Welcome to 'hconsole'")
41: enter()
42:
43: # ask Hatari debugger to parse breakpoint etc commands from file
44: main.run("parse %s/example-debugger" % path)
45:
46: # hit a Getdrv() breakpoint when EmuTOS prompt is redrawn
47: enter()
48:
49: # wait few secs and kill Hatari
50: main.run("sleep 3")
51: main.run("kill")
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.