Skip to content

Commit

Permalink
fixed python 3.x compatibility issues
Browse files Browse the repository at this point in the history
fixed pep8 code style issues
fixed a shadowing unit test function
  • Loading branch information
irmen committed Jun 30, 2018
1 parent 0069e9c commit 6cfd0e9
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 167 deletions.
65 changes: 33 additions & 32 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,36 @@ A MOS 6502 Emulator intended to be used from within other programs. All opcodes

Example Usage:::

from py65emu.cpu import CPU
from py65emu.mmu import MMU

f = open("program.rom") #Open your rom

#define your blocks of memory. Each tuple is
#(start_address, length, readonly=True, initial_value=None, value_offset=0)
m = MMU([
(0x00, 0x200), #Create RAM with 512 bytes
(0x1000, 0x4000, True, f) #Create ROM starting at 0x1000 with your program.
])

#Create the CPU with the MMU and the starting program counter address
#You can also optionally pass in a value for stack_page, which defaults
#to 1, meaning the stack will be from 0x100-0x1ff. As far as I know this
#is true for all 6502s, but for instance in the 6507 used by the Atari
#2600 it is in the zero page, stack_page=0.
c = CPU(mmu, 0x1000)

#Do this to execute one instruction
c.step()

#You can check the registers and memory values to determine what has changed
print c.r.a # A register
print c.r.x # X register
print c.r.y # Y register
print c.r.s # Stack Pointer
print c.r.pc # Program Counter

print c.r.getFlag('C') #Get the value of a flag from the flag register.

print mmu.read(0xff) #Read a value from memory
from py65emu.cpu import CPU
from py65emu.mmu import MMU

f = open("program.rom", "rb") # Open your rom

#define your blocks of memory. Each tuple is
#(start_address, length, readonly=True, initial_value=None, value_offset=0)
m = MMU([
(0x00, 0x200), #Create RAM with 512 bytes
(0x1000, 0x4000, True, f) #Create ROM starting at 0x1000 with your program.
])

#Create the CPU with the MMU and the starting program counter address
#You can also optionally pass in a value for stack_page, which defaults
#to 1, meaning the stack will be from 0x100-0x1ff. As far as I know this
#is true for all 6502s, but for instance in the 6507 used by the Atari
#2600 it is in the zero page, stack_page=0.
c = CPU(mmu, 0x1000)

#Do this to execute one instruction
c.step()

#You can check the registers and memory values to determine what has changed
print c.r.a # A register
print c.r.x # X register
print c.r.y # Y register
print c.r.s # Stack Pointer
print c.r.pc # Program Counter

print c.r.getFlag('C') #Get the value of a flag from the flag register.

print mmu.read(0xff) #Read a value from memory

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
#texinfo_no_detailmenu = False
3 changes: 2 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ At the command line::
Or, if you have virtualenvwrapper installed::

$ mkvirtualenv py65emu
$ pip install py65emu
$ pip install py65emu

3 changes: 2 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Usage

To use Python 6502 Emulator in a project::

import py65emu
import py65emu

2 changes: 1 addition & 1 deletion py65emu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

__author__ = 'Jeremy Neiman'
__email__ = '[email protected]'
__version__ = '0.0.0'
__version__ = '0.0.0'
Loading

0 comments on commit 6cfd0e9

Please sign in to comment.