1
0
mirror of https://github.com/mnaberez/py65.git synced 2025-01-19 07:31:34 +00:00

monitor: extend save and load to 16-bit

This commit is contained in:
BigEd 2011-08-21 10:51:15 +01:00
parent 4b453e3b7a
commit 8294727858

View File

@ -421,7 +421,12 @@ class Monitor(cmd.Cmd):
self._output(msg)
return
self._fill(start, start, map(ord, bytes))
if self.byteWidth==8:
bytes=map(ord, bytes)
elif self.byteWidth==16:
bytes=map(lambda msb,lsb: (ord(msb)<<8)+ord(lsb),bytes[1::2],bytes[0::2])
self._fill(start, start, bytes)
def do_save(self, args):
split = shlex.split(args)
@ -437,7 +442,9 @@ class Monitor(cmd.Cmd):
try:
f = open(filename, 'wb')
for byte in bytes:
f.write(chr(byte))
for char in range (0,self.byteWidth,8):
f.write(chr(byte & 0xff))
byte = byte >> 8
f.close()
except (OSError, IOError), why:
msg = "Cannot save file: [%d] %s" % (why[0], why[1])