mirror of
https://github.com/mnaberez/py65.git
synced 2024-11-18 15:06:35 +00:00
Remove unnecessary constructor args
This commit is contained in:
parent
d1b411fc16
commit
456a345b23
@ -53,10 +53,10 @@ class Assembler:
|
||||
self._mpu = mpu
|
||||
self._address_parser = address_parser
|
||||
|
||||
self.addrWidth = mpu.addrWidth
|
||||
self.byteWidth = mpu.byteWidth
|
||||
self.addrFmt = mpu.addrFmt
|
||||
self.byteFmt = mpu.byteFmt
|
||||
self.addrWidth = mpu.ADDR_WIDTH
|
||||
self.byteWidth = mpu.BYTE_WIDTH
|
||||
self.addrFmt = mpu.ADDR_FORMAT
|
||||
self.byteFmt = mpu.BYTE_FORMAT
|
||||
self.addrMask = mpu.addrMask
|
||||
self.byteMask = mpu.byteMask
|
||||
|
||||
|
@ -17,18 +17,19 @@ class MPU:
|
||||
ZERO = 2
|
||||
CARRY = 1
|
||||
|
||||
def __init__(self, memory=None, pc=0x0000, debug=False, byteWidth=8, addrWidth=16, addrFmt="%04x", byteFmt="%02x"):
|
||||
BYTE_WIDTH = 8
|
||||
BYTE_FORMAT = "%02x"
|
||||
ADDR_WIDTH = 16
|
||||
ADDR_FORMAT = "%04x"
|
||||
|
||||
def __init__(self, memory=None, pc=0x0000, debug=False):
|
||||
# config
|
||||
self.debug = debug
|
||||
self.name = '6502'
|
||||
self.byteWidth = byteWidth
|
||||
self.byteMask = ((1<<byteWidth)-1)
|
||||
self.addrWidth = addrWidth
|
||||
self.addrMask = ((1<<addrWidth)-1)
|
||||
self.addrHighMask = (self.byteMask<<byteWidth)
|
||||
self.addrFmt=addrFmt
|
||||
self.byteFmt=byteFmt
|
||||
self.spBase = 1<<byteWidth
|
||||
self.byteMask = ((1<<self.BYTE_WIDTH)-1)
|
||||
self.addrMask = ((1<<self.ADDR_WIDTH)-1)
|
||||
self.addrHighMask = (self.byteMask<<self.BYTE_WIDTH)
|
||||
self.spBase = 1<<self.BYTE_WIDTH
|
||||
|
||||
# vm status
|
||||
self.excycles = 0
|
||||
@ -49,7 +50,7 @@ class MPU:
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
flags = itoa(self.p, 2).rjust(self.byteWidth, '0')
|
||||
flags = itoa(self.p, 2).rjust(self.BYTE_WIDTH, '0')
|
||||
indent = ' ' * (len(self.name) + 2)
|
||||
|
||||
return self.reprformat() % (indent, self.name,
|
||||
@ -79,11 +80,11 @@ class MPU:
|
||||
return self.memory[addr]
|
||||
|
||||
def WordAt(self, addr):
|
||||
return self.ByteAt(addr) + (self.ByteAt(addr + 1) << self.byteWidth)
|
||||
return self.ByteAt(addr) + (self.ByteAt(addr + 1) << self.BYTE_WIDTH)
|
||||
|
||||
def WrapAt(self, addr):
|
||||
wrap = lambda x: (x & self.addrHighMask) + ((x + 1) & self.byteMask)
|
||||
return self.ByteAt(addr) + (self.ByteAt(wrap(addr)) << self.byteWidth)
|
||||
return self.ByteAt(addr) + (self.ByteAt(wrap(addr)) << self.BYTE_WIDTH)
|
||||
|
||||
def ProgramCounter(self):
|
||||
return self.pc
|
||||
@ -166,12 +167,12 @@ class MPU:
|
||||
return self.ByteAt(self.sp+self.spBase)
|
||||
|
||||
def stPushWord(self, z):
|
||||
self.stPush((z>>self.byteWidth)&self.byteMask)
|
||||
self.stPush((z>>self.BYTE_WIDTH)&self.byteMask)
|
||||
self.stPush(z&self.byteMask)
|
||||
|
||||
def stPopWord(self):
|
||||
z = self.stPop()
|
||||
z += self.stPop()<<self.byteWidth
|
||||
z += self.stPop()<<self.BYTE_WIDTH
|
||||
return z
|
||||
|
||||
def FlagsNZ(self, value):
|
||||
|
@ -13,13 +13,18 @@ class MPU(mpu6502.MPU):
|
||||
One implementation can be found here: https://github.com/BigEd/verilog-6502/wiki
|
||||
"""
|
||||
|
||||
def __init__(self, byteWidth=16, addrWidth=32, addrFmt="%08x", byteFmt="%04x", *args, **kwargs):
|
||||
mpu6502.MPU.__init__(self, byteWidth=byteWidth, addrWidth=addrWidth, addrFmt=addrFmt, byteFmt=byteFmt, *args, **kwargs)
|
||||
BYTE_WIDTH = 16
|
||||
BYTE_FORMAT = "%04x"
|
||||
ADDR_WIDTH = 32
|
||||
ADDR_FORMAT = "%08x"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
mpu6502.MPU.__init__(self, *args, **kwargs)
|
||||
self.name = '65Org16'
|
||||
self.waiting = False
|
||||
self.IrqTo = (1<<self.addrWidth)-2
|
||||
self.ResetTo = (1<<self.addrWidth)-4
|
||||
self.NMITo = (1<<self.addrWidth)-6
|
||||
self.IrqTo = (1<<self.ADDR_WIDTH)-2
|
||||
self.ResetTo = (1<<self.ADDR_WIDTH)-4
|
||||
self.NMITo = (1<<self.ADDR_WIDTH)-6
|
||||
self.NEGATIVE = 1 << 15
|
||||
self.OVERFLOW = 1 << 14
|
||||
|
||||
|
@ -8,10 +8,10 @@ class Disassembler:
|
||||
self._mpu = mpu
|
||||
self._address_parser = address_parser
|
||||
|
||||
self.addrWidth = mpu.addrWidth
|
||||
self.byteWidth = mpu.byteWidth
|
||||
self.addrFmt = mpu.addrFmt
|
||||
self.byteFmt = mpu.byteFmt
|
||||
self.addrWidth = mpu.ADDR_WIDTH
|
||||
self.byteWidth = mpu.BYTE_WIDTH
|
||||
self.addrFmt = mpu.ADDR_FORMAT
|
||||
self.byteFmt = mpu.BYTE_FORMAT
|
||||
self.addrMask = mpu.addrMask
|
||||
self.byteMask = mpu.byteMask
|
||||
|
||||
|
@ -104,10 +104,10 @@ class Monitor(cmd.Cmd):
|
||||
|
||||
def _reset(self, mpu_type):
|
||||
self._mpu = mpu_type()
|
||||
self.addrWidth = self._mpu.addrWidth
|
||||
self.byteWidth = self._mpu.byteWidth
|
||||
self.addrFmt = self._mpu.addrFmt
|
||||
self.byteFmt = self._mpu.byteFmt
|
||||
self.addrWidth = self._mpu.ADDR_WIDTH
|
||||
self.byteWidth = self._mpu.BYTE_WIDTH
|
||||
self.addrFmt = self._mpu.ADDR_FORMAT
|
||||
self.byteFmt = self._mpu.BYTE_FORMAT
|
||||
self.addrMask = self._mpu.addrMask
|
||||
self.byteMask = self._mpu.byteMask
|
||||
self._install_mpu_observers()
|
||||
|
Loading…
Reference in New Issue
Block a user