forked from deadsy/py_z80
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
90 lines (69 loc) · 2.48 KB
/
Copy pathmain.py
File metadata and controls
90 lines (69 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#-----------------------------------------------------------------------------
"""
PyZ80: Z80 platform Emulator
"""
#-----------------------------------------------------------------------------
import logging
import conio
import cli
import util
import jace
import tec1
#-----------------------------------------------------------------------------
_version_str = 'PyZ80: Python Z80 Platform Emulator 0.1'
#-----------------------------------------------------------------------------
class application:
def __init__(self):
self.menu_targets = (
('jace', 'Jupiter Ace', util.cr, self.target_jace, None),
('tec1', 'Talking Electronics TEC-1', util.cr, self.target_tec1, None),
)
self.menu_root = (
('exit', 'exit the application', util.cr, self.exit, None),
('help', 'display general help', util.cr, self.general_help, None),
('target', 'select a target', None, None, self.menu_targets),
('version', 'display version information', util.cr, self.version, None),
)
# create the cli
self.io = conio.console()
self.cli = cli.cli(self)
self.main_menu()
def cleanup(self):
"""application cleanup prior to exit"""
self.io.close()
def main_menu(self):
self.cli.set_root(self.menu_root)
self.cli.set_prompt('\npyz80> ')
def put(self, data):
"""console ouput for leaf functions"""
self.io.put(data)
def run(self):
self.cli.run()
def exit(self, app, args):
app.cli.exit()
def version(self, app, args):
"""display a version string"""
app.put('\n\n%s\n' % _version_str)
def target_jace(self, app, args):
app.put('\n\nemulating "Jupiter ACE"\n')
jace.jace(app)
def target_tec1(self, app, args):
app.put('\n\nemulating "Talking Electronics TEC 1"\n')
tec1.tec1(app)
def general_help(self, app, args):
app.cli.func_help(util.general)
#-----------------------------------------------------------------------------
def main():
app = application()
app.put('\n%s\n' % _version_str)
try:
app.run()
except:
app.cleanup()
raise
app.cleanup()
#-----------------------------------------------------------------------------
if __name__ == '__main__':
logging.getLogger('').addHandler(logging.StreamHandler())
main()
#-----------------------------------------------------------------------------