mirror of
https://github.com/jtauber/applepy.git
synced 2025-01-14 16:32:47 +00:00
implement post to /memory in control requests
This commit is contained in:
parent
80e95d114b
commit
6782a1d268
28
cpu6502.py
28
cpu6502.py
@ -379,8 +379,8 @@ class ControlHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.post_urls = {
|
self.post_urls = {
|
||||||
#r"/memory/(\d+)(-(\d+))?$": self.post_memory,
|
r"/memory/(\d+)(-(\d+))?$": self.post_memory,
|
||||||
#r"/memory/(\d+)(-(\d+))?/raw$": self.post_memory_raw,
|
r"/memory/(\d+)(-(\d+))?/raw$": self.post_memory_raw,
|
||||||
r"/quit$": self.post_quit,
|
r"/quit$": self.post_quit,
|
||||||
r"/reset$": self.post_reset,
|
r"/reset$": self.post_reset,
|
||||||
}
|
}
|
||||||
@ -457,6 +457,30 @@ class ControlHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
"carry_flag",
|
"carry_flag",
|
||||||
))))
|
))))
|
||||||
|
|
||||||
|
def post_memory(self, m):
|
||||||
|
addr = int(m.group(1))
|
||||||
|
e = m.group(3)
|
||||||
|
if e is not None:
|
||||||
|
end = int(e)
|
||||||
|
else:
|
||||||
|
end = addr
|
||||||
|
data = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
|
||||||
|
for i, a in enumerate(range(addr, end + 1)):
|
||||||
|
self.cpu.write_byte(a, data[i])
|
||||||
|
self.response("")
|
||||||
|
|
||||||
|
def post_memory_raw(self, m):
|
||||||
|
addr = int(m.group(1))
|
||||||
|
e = m.group(3)
|
||||||
|
if e is not None:
|
||||||
|
end = int(e)
|
||||||
|
else:
|
||||||
|
end = addr
|
||||||
|
data = self.rfile.read(int(self.headers["Content-Length"]))
|
||||||
|
for i, a in enumerate(range(addr, end + 1)):
|
||||||
|
self.cpu.write_byte(a, data[i])
|
||||||
|
self.response("")
|
||||||
|
|
||||||
def post_quit(self, m):
|
def post_quit(self, m):
|
||||||
self.cpu.quit = True
|
self.cpu.quit = True
|
||||||
self.response("")
|
self.response("")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user