From 82947278580467225c4064742f2e4ba7b27617c5 Mon Sep 17 00:00:00 2001 From: BigEd Date: Sun, 21 Aug 2011 10:51:15 +0100 Subject: [PATCH] monitor: extend save and load to 16-bit --- src/py65/monitor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/py65/monitor.py b/src/py65/monitor.py index a783bf4..9526dae 100644 --- a/src/py65/monitor.py +++ b/src/py65/monitor.py @@ -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])