From b4046663cefdab8c51415fdec219fe1e920f50e0 Mon Sep 17 00:00:00 2001 From: Oscar Lindberg Date: Wed, 1 Apr 2009 07:16:18 +0800 Subject: [PATCH 1/2] Temporary fix so lib can be run on windows. Signed-off-by: Mike Naberezny --- src/py65/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py65/util.py b/src/py65/util.py index ff9011d..cde80c5 100644 --- a/src/py65/util.py +++ b/src/py65/util.py @@ -1,7 +1,5 @@ import re import select -import termios -import fcntl import os class AddressParser: @@ -140,6 +138,8 @@ def getch(stdin): """ Performs a nonblocking read of one byte from stdin and returns its ordinal value. If no byte is available, 0 is returned. """ + import termios + import fcntl fd = stdin.fileno() From 2e87735fdcecd02945b1b61e77762b95c41462dc Mon Sep 17 00:00:00 2001 From: Oscar Lindberg Date: Wed, 1 Apr 2009 07:17:03 +0800 Subject: [PATCH 2/2] Memory and pc start can be given in constructor. Signed-off-by: Mike Naberezny --- src/py65/mpu6502.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/py65/mpu6502.py b/src/py65/mpu6502.py index ab5dcb0..8070bc4 100644 --- a/src/py65/mpu6502.py +++ b/src/py65/mpu6502.py @@ -15,7 +15,7 @@ class MPU: ZERO = 2 CARRY = 1 - def __init__(self): + def __init__(self, memory=None, pc=0): # config self.debug = False @@ -26,8 +26,13 @@ class MPU: self.processorCycles = 0 self.internalCycleDelay = 0 + if not memory: + memory = 0xFFFF * [0x00] + self.memory = memory + self.start_pc = pc + # init - self.clearMemory() + #self.clearMemory() self.reset() def __repr__(self): @@ -48,17 +53,19 @@ class MPU: return self def reset(self): - self.pc=0 - self.sp=255 - self.a=self.x=self.y=0 - self.flags=32 - self.breakFlag=False - self.processorCycles=0 + self.pc = self.start_pc + self.sp = 255 + self.a = 0 + self.x = 0 + self.y = 0 + self.flags = 32 + self.breakFlag = False + self.processorCycles = 0 - def clearMemory(self, start=0x0000, end=0xFFFF): - self.memory = [] - for addr in range(start, end + 1): - self.memory.insert(addr, 0x00) + #def clearMemory(self, start=0x0000, end=0xFFFF): + #self.memory = [] + #for addr in range(start, end + 1): + #self.memory.insert(addr, 0x00) def ByteAt(self, addr): return self.memory[addr]