3 # Copyright (C) 2022 Nick Downing <nick@ndcode.org>
4 # SPDX-License-Identifier: GPL-2.0-only
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free Software
8 # Foundation; version 2.
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software Foundation, Inc., 51
17 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
30 #print('yylex()', lex_yy.yylex())
31 #print('yytext', f'"{lex_yy.yytext:s}"')
35 'alsa': apple_io.BEEP_STYLE_ALSA,
36 'vt100': apple_io.BEEP_STYLE_VT100,
39 while len(sys.argv) >= 2:
40 if sys.argv[1][:7] == '--beep-style=':
41 apple_io.beep_style = beep_styles[sys.arg[1][7:]]
42 elif sys.argv[1] == '--hrcg':
44 elif sys.argv[1][:24] == '--inter-statement-delay=':
45 t_def.inter_statement_delay = float(sys.argv[1][24:])
46 elif sys.argv[1][:11] == '--joystick=':
47 fields = sys.argv[1][11:].split(',')
48 apple_joystick.input_path = fields[0]
51 apple_joystick.flip_x = True
53 apple_joystick.flip_y = True
54 elif i == 'swap_axes':
55 apple_joystick.swap_axes = True
56 elif i == 'swap_buttons':
57 apple_joystick.swap_buttons = True
64 print(f'usage: {sys.argv[0]:s} [--beep-style=alsa|vt100] [--inter-statement-delay=secs] [--joystick=/dev/input/eventNN[,flip_x|flip_y|swap_axes|swap_buttons,...]] program.tok')
65 sys.exit(EXIT_FAILURE)
66 program_bas = sys.argv[1]
68 with open(program_bas) as fin:
70 program = y_tab.yyparse(t_def.Program)
71 #element.serialize(program, sys.stdout)
73 program.post_process(program)
74 #element.serialize(program, sys.stdout)
79 #print('context.run()')
80 context = t_def.Context(program)
83 #print('apple_io.deinit()')
85 apple_joystick.deinit()