mirror of
https://github.com/jtauber/applepy.git
synced 2024-06-09 05:29:31 +00:00
unittest fix/workaround - remove CPU options and disable control_server
- CPU options were only used to pass 'pc'. Rather than adding another get_options/Options to tests,py, replacing options with a pc argument removes CPU's dependency on command-line options. - As a workaround for 'Address already in use', control_server is now enabled/disabled by memory.use_bus (which is False in unit tests).
This commit is contained in:
parent
934bf1a495
commit
811104ebcc
25
cpu6502.py
25
cpu6502.py
|
@ -505,10 +505,10 @@ class CPU:
|
||||||
STACK_PAGE = 0x100
|
STACK_PAGE = 0x100
|
||||||
RESET_VECTOR = 0xFFFC
|
RESET_VECTOR = 0xFFFC
|
||||||
|
|
||||||
def __init__(self, options, memory):
|
def __init__(self, memory, pc=None):
|
||||||
self.memory = memory
|
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.accumulator = 0x00
|
||||||
self.x_index = 0x00
|
self.x_index = 0x00
|
||||||
|
@ -528,8 +528,8 @@ class CPU:
|
||||||
|
|
||||||
self.setup_ops()
|
self.setup_ops()
|
||||||
self.reset()
|
self.reset()
|
||||||
if options.pc is not None:
|
if pc is not None:
|
||||||
self.program_counter = options.pc
|
self.program_counter = pc
|
||||||
self.running = True
|
self.running = True
|
||||||
self.quit = False
|
self.quit = False
|
||||||
|
|
||||||
|
@ -704,13 +704,14 @@ class CPU:
|
||||||
# a connection is accepted until the response
|
# a connection is accepted until the response
|
||||||
# is sent. TODO: use an async HTTP server that
|
# is sent. TODO: use an async HTTP server that
|
||||||
# handles input data asynchronously.
|
# handles input data asynchronously.
|
||||||
sockets = [self.control_server]
|
if self.control_server:
|
||||||
rs, _, _ = select.select(sockets, [], [], timeout)
|
sockets = [self.control_server]
|
||||||
for s in rs:
|
rs, _, _ = select.select(sockets, [], [], timeout)
|
||||||
if s is self.control_server:
|
for s in rs:
|
||||||
self.control_server._handle_request_noblock()
|
if s is self.control_server:
|
||||||
else:
|
self.control_server._handle_request_noblock()
|
||||||
pass
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
count = 1000
|
count = 1000
|
||||||
while count > 0 and self.running:
|
while count > 0 and self.running:
|
||||||
|
@ -1225,5 +1226,5 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
mem = Memory(options)
|
mem = Memory(options)
|
||||||
|
|
||||||
cpu = CPU(options, mem)
|
cpu = CPU(mem, options.pc)
|
||||||
cpu.run(options.bus)
|
cpu.run(options.bus)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user