Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest fix/workaround - remove CPU options and disable control_server #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions cpu6502.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,10 @@ class CPU:
STACK_PAGE = 0x100
RESET_VECTOR = 0xFFFC

def __init__(self, options, memory):
def __init__(self, memory, pc=None):
self.memory = memory

self.control_server = BaseHTTPServer.HTTPServer(("127.0.0.1", 6502), ControlHandlerFactory(self))
self.control_server = memory.use_bus and BaseHTTPServer.HTTPServer(("127.0.0.1", 6502), ControlHandlerFactory(self))

self.accumulator = 0x00
self.x_index = 0x00
Expand All @@ -528,8 +528,8 @@ def __init__(self, options, memory):

self.setup_ops()
self.reset()
if options.pc is not None:
self.program_counter = options.pc
if pc is not None:
self.program_counter = pc
self.running = True
self.quit = False

Expand Down Expand Up @@ -704,13 +704,14 @@ def run(self, bus_port):
# a connection is accepted until the response
# is sent. TODO: use an async HTTP server that
# handles input data asynchronously.
sockets = [self.control_server]
rs, _, _ = select.select(sockets, [], [], timeout)
for s in rs:
if s is self.control_server:
self.control_server._handle_request_noblock()
else:
pass
if self.control_server:
sockets = [self.control_server]
rs, _, _ = select.select(sockets, [], [], timeout)
for s in rs:
if s is self.control_server:
self.control_server._handle_request_noblock()
else:
pass

count = 1000
while count > 0 and self.running:
Expand Down Expand Up @@ -1225,5 +1226,5 @@ def __init__(self):

mem = Memory(options)

cpu = CPU(options, mem)
cpu = CPU(mem, options.pc)
cpu.run(options.bus)