diff --git a/fx92-programmer.py b/fx92-programmer.py index 2aea0c7..3ebeb6b 100644 --- a/fx92-programmer.py +++ b/fx92-programmer.py @@ -211,44 +211,45 @@ if offset >= 0: process(hwnd, init) code = '' -mode = 0 counter = 0 +mode = 0 for element in program: code += element counter += 1 script = code.startswith('F') - if (script and counter == 4) or (not script and counter == 2): - if code == 'F908': - mode = 4 - sequence = commands.get(code) - elif code == 'F90B': - mode = 3 - sequence = commands.get(code) - elif code == 'F90C': - mode = 2 - sequence = commands.get(code) - elif code == 'F90D' or code == 'F90F': - mode = 1 - sequence = commands.get(code) - elif code == '00' and mode == 4: - mode = 0 - sequence = ['exe'] - elif code == '00' and mode == 3: - mode = 2 - sequence = ['exe'] - elif code == '00' and mode == 2: - mode = 0 - sequence = ['exe'] - elif code == '00' and mode == 1: - mode = 0 - sequence = None - elif code == '00' and mode == 0: - sequence = ['exe', 'exe'] - elif mode == 2: - sequence = variables.get(code) - else: - sequence = commands.get(code) - if sequence is not None: - process(hwnd, sequence) - code = '' - counter = 0 + if (script and counter != 4) or (not script and counter != 2): + continue + elif code == 'F908': + mode = 4 + sequence = commands.get(code) + elif code == 'F90B': + mode = 3 + sequence = commands.get(code) + elif code == 'F90C': + mode = 2 + sequence = commands.get(code) + elif code == 'F90D' or code == 'F90F': + mode = 1 + sequence = commands.get(code) + elif code == '00' and mode == 4: + mode = 0 + sequence = ['exe'] + elif code == '00' and mode == 3: + mode = 2 + sequence = ['exe'] + elif code == '00' and mode == 2: + mode = 0 + sequence = ['exe'] + elif code == '00' and mode == 1: + mode = 0 + sequence = None + elif code == '00' and mode == 0: + sequence = ['exe', 'exe'] + elif mode == 2: + sequence = variables.get(code) + else: + sequence = commands.get(code) + if sequence is not None: + process(hwnd, sequence) + code = '' + counter = 0