Permalink
Browse files

Fixed a terminal crash, only inform plugins of memory changes

- Only inform the plugins of memory changes, not writes
- Fixed a terminal crash with writing the 0x0 character
  • Loading branch information...
1 parent aff9fbd commit 90355fc2a2af2025335fd00a9956ab95775e5707 @andre-d andre-d committed Apr 11, 2012
Showing with 11 additions and 5 deletions.
  1. +8 −3 dcpu16.py
  2. +1 −1 emuplugin.py
  3. +2 −1 plugins/terminalplugin.py
View
@@ -226,10 +226,15 @@ def run(self, trace=False, show_speed=False):
print("skipping")
self.skip = False
else:
- op(arg1, arg2)
if 0x01 <= opcode <=0xB: # write to memory
- for p in self.plugins:
- p.memory_changed(self, arg1, self.memory[arg1])
+ oldval = self.memory[arg1]
+ op(arg1, arg2)
+ val = self.memory[arg1]
+ if oldval != val:
+ for p in self.plugins:
+ p.memory_changed(self, arg1, val, oldval)
+ else:
+ op(arg1, arg2)
if trace:
self.dump_registers()
self.dump_stack()
View
@@ -43,7 +43,7 @@ def shutdown(self):
"""
pass
- def memory_changed(self, cpu, address, value):
+ def memory_changed(self, cpu, address, value, oldvalue):
"""
Gets called on a write to memory
"""
@@ -38,13 +38,14 @@ def tick(self, cpu):
if self.term.keys:
self.processkeys(cpu)
- def memory_changed(self, cpu, address, value):
+ def memory_changed(self, cpu, address, value, oldval):
"""
Inform the terminal that the memory is updated
"""
if START_ADDRESS <= address <= START_ADDRESS + self.term.width * self.term.height:
row, column = divmod(address - START_ADDRESS, self.term.width)
ch = value % 0x0080
+ ch = ord(' ') if not ch else ch
fg = (value & 0x4000) >> 14 | (value & 0x2000) >> 12 | (value & 0x1000) >> 10
bg = (value & 0x400) >> 10 | (value & 0x200) >> 8 | (value & 0x100) >> 6
self.term.update_character(row, column, ch, (fg, bg))

0 comments on commit 90355fc

Please sign in to comment.