mirror of
https://github.com/mnaberez/py65.git
synced 2025-01-06 13:31:08 +00:00
Remove flag/value duplication
This commit is contained in:
parent
1d031cab3c
commit
9e4fad6588
@ -67,14 +67,10 @@ class Monitor(cmd.Cmd):
|
|||||||
self._usage()
|
self._usage()
|
||||||
self._exit(1)
|
self._exit(1)
|
||||||
|
|
||||||
flag_load = False
|
load = None
|
||||||
load_value = ""
|
rom = None
|
||||||
flag_rom = False
|
goto = None
|
||||||
rom_value = ""
|
mpu = None
|
||||||
flag_goto = False
|
|
||||||
goto_value = ""
|
|
||||||
flag_mpu = False
|
|
||||||
mpu_value = "6502"
|
|
||||||
|
|
||||||
for opt, value in options:
|
for opt, value in options:
|
||||||
if opt in ('-i', '--input'):
|
if opt in ('-i', '--input'):
|
||||||
@ -84,48 +80,44 @@ class Monitor(cmd.Cmd):
|
|||||||
self.putc_addr = int(value, 16)
|
self.putc_addr = int(value, 16)
|
||||||
|
|
||||||
if opt in ('-l', '--load'):
|
if opt in ('-l', '--load'):
|
||||||
flag_load = True
|
load = value
|
||||||
load_value = value
|
|
||||||
|
|
||||||
if opt in ('-r', '--rom'):
|
if opt in ('-r', '--rom'):
|
||||||
flag_rom = True
|
rom = value
|
||||||
rom_value = value
|
|
||||||
|
|
||||||
if opt in ('-g', '--goto'):
|
if opt in ('-g', '--goto'):
|
||||||
flag_goto = True
|
goto = value
|
||||||
goto_value = value
|
|
||||||
|
|
||||||
if opt in ('-m', '--mpu'):
|
if opt in ('-m', '--mpu'):
|
||||||
flag_mpu = True
|
mpu = value
|
||||||
mpu_value = value
|
|
||||||
|
|
||||||
elif opt in ("-h", "--help"):
|
elif opt in ("-h", "--help"):
|
||||||
self._usage()
|
self._usage()
|
||||||
self._exit(0)
|
self._exit(0)
|
||||||
|
|
||||||
if (flag_mpu == True) or (flag_rom == True):
|
if (mpu is not None) or (rom is not None):
|
||||||
if mpu_value == "":
|
if mpu is None:
|
||||||
mpu_value = "6502"
|
mpu = "6502"
|
||||||
if self._get_mpu(mpu_value) is None:
|
if self._get_mpu(mpu) is None:
|
||||||
mpus = list(self.Microprocessors.keys())
|
mpus = list(self.Microprocessors.keys())
|
||||||
mpus.sort()
|
mpus.sort()
|
||||||
msg = "Fatal: no such MPU. Available MPUs: %s"
|
msg = "Fatal: no such MPU. Available MPUs: %s"
|
||||||
self._output(msg % ', '.join(mpus))
|
self._output(msg % ', '.join(mpus))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
cmd = "mpu %s" % mpu_value
|
cmd = "mpu %s" % mpu
|
||||||
self.onecmd(cmd)
|
self.onecmd(cmd)
|
||||||
|
|
||||||
if flag_load == True:
|
if load is not None:
|
||||||
cmd = "load %s" % load_value
|
cmd = "load %s" % load
|
||||||
self.onecmd(cmd)
|
self.onecmd(cmd)
|
||||||
|
|
||||||
if flag_goto == True:
|
if goto is not None:
|
||||||
cmd = "goto %s" % goto_value
|
cmd = "goto %s" % goto
|
||||||
self.onecmd(cmd)
|
self.onecmd(cmd)
|
||||||
|
|
||||||
if flag_rom == True:
|
if rom is not None:
|
||||||
# load a ROM and run from the reset vector
|
# load a ROM and run from the reset vector
|
||||||
cmd = "load '%s' top" % rom_value
|
cmd = "load '%s' top" % rom
|
||||||
self.onecmd(cmd)
|
self.onecmd(cmd)
|
||||||
physMask = self._mpu.memory.physMask
|
physMask = self._mpu.memory.physMask
|
||||||
reset = self._mpu.RESET & physMask
|
reset = self._mpu.RESET & physMask
|
||||||
|
Loading…
Reference in New Issue
Block a user