Merge branch 'master' into website-redesign
This commit is contained in:
commit
0bb3701fa9
|
@ -73,6 +73,7 @@ class Context():
|
||||||
self.snes_reconnect_address = None
|
self.snes_reconnect_address = None
|
||||||
self.snes_recv_queue = asyncio.Queue()
|
self.snes_recv_queue = asyncio.Queue()
|
||||||
self.snes_request_lock = asyncio.Lock()
|
self.snes_request_lock = asyncio.Lock()
|
||||||
|
self.is_sd2snes = False
|
||||||
self.snes_write_buffer = []
|
self.snes_write_buffer = []
|
||||||
|
|
||||||
self.server_task = None
|
self.server_task = None
|
||||||
|
@ -521,6 +522,15 @@ async def snes_connect(ctx: Context, address):
|
||||||
ctx.snes_attached_device = (devices.index(device), device)
|
ctx.snes_attached_device = (devices.index(device), device)
|
||||||
ctx.ui_node.send_connection_status(ctx)
|
ctx.ui_node.send_connection_status(ctx)
|
||||||
|
|
||||||
|
if 'sd2snes' in device.lower() or 'COM' in device:
|
||||||
|
ctx.ui_node.log_info("SD2SNES/FXPAK Detected")
|
||||||
|
ctx.is_sd2snes = True
|
||||||
|
await ctx.snes_socket.send(json.dumps({"Opcode" : "Info", "Space" : "SNES"}))
|
||||||
|
reply = json.loads(await ctx.snes_socket.recv())
|
||||||
|
if reply and 'Results' in reply:
|
||||||
|
ctx.ui_node.log_info(reply['Results'])
|
||||||
|
else:
|
||||||
|
ctx.is_sd2snes = False
|
||||||
|
|
||||||
ctx.snes_reconnect_address = address
|
ctx.snes_reconnect_address = address
|
||||||
recv_task = asyncio.create_task(snes_recv_loop(ctx))
|
recv_task = asyncio.create_task(snes_recv_loop(ctx))
|
||||||
|
@ -637,16 +647,43 @@ async def snes_write(ctx : Context, write_list):
|
||||||
|
|
||||||
PutAddress_Request = {"Opcode": "PutAddress", "Operands": [], 'Space': 'SNES'}
|
PutAddress_Request = {"Opcode": "PutAddress", "Operands": [], 'Space': 'SNES'}
|
||||||
|
|
||||||
|
if ctx.is_sd2snes:
|
||||||
|
cmd = b'\x00\xE2\x20\x48\xEB\x48'
|
||||||
|
|
||||||
|
for address, data in write_list:
|
||||||
|
if (address < WRAM_START) or ((address + len(data)) > (WRAM_START + WRAM_SIZE)):
|
||||||
|
ctx.ui_node.log_error("SD2SNES: Write out of range %s (%d)" % (hex(address), len(data)))
|
||||||
|
return False
|
||||||
|
for ptr, byte in enumerate(data, address + 0x7E0000 - WRAM_START):
|
||||||
|
cmd += b'\xA9' # LDA
|
||||||
|
cmd += bytes([byte])
|
||||||
|
cmd += b'\x8F' # STA.l
|
||||||
|
cmd += bytes([ptr & 0xFF, (ptr >> 8) & 0xFF, (ptr >> 16) & 0xFF])
|
||||||
|
|
||||||
|
cmd += b'\xA9\x00\x8F\x00\x2C\x00\x68\xEB\x68\x28\x6C\xEA\xFF\x08'
|
||||||
|
|
||||||
|
PutAddress_Request['Space'] = 'CMD'
|
||||||
|
PutAddress_Request['Operands'] = ["2C00", hex(len(cmd)-1)[2:], "2C00", "1"]
|
||||||
|
try:
|
||||||
|
if ctx.snes_socket is not None:
|
||||||
|
await ctx.snes_socket.send(json.dumps(PutAddress_Request))
|
||||||
|
await ctx.snes_socket.send(cmd)
|
||||||
|
else:
|
||||||
|
logging.warning(f"Could not send data to SNES: {cmd}")
|
||||||
|
except websockets.ConnectionClosed:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
PutAddress_Request['Space'] = 'SNES'
|
||||||
try:
|
try:
|
||||||
#will pack those requests as soon as qusb2snes actually supports that for real
|
#will pack those requests as soon as qusb2snes actually supports that for real
|
||||||
for address, data in write_list:
|
for address, data in write_list:
|
||||||
PutAddress_Request['Operands'] = [hex(address)[2:], hex(len(data))[2:]]
|
PutAddress_Request['Operands'] = [hex(address)[2:], hex(len(data))[2:]]
|
||||||
if ctx.snes_socket is not None:
|
if ctx.snes_socket is not None:
|
||||||
await ctx.snes_socket.send(json.dumps(PutAddress_Request))
|
await ctx.snes_socket.send(json.dumps(PutAddress_Request))
|
||||||
if ctx.snes_socket is not None:
|
|
||||||
await ctx.snes_socket.send(data)
|
await ctx.snes_socket.send(data)
|
||||||
|
else:
|
||||||
|
logging.warning(f"Could not send data to SNES: {data}")
|
||||||
except websockets.ConnectionClosed:
|
except websockets.ConnectionClosed:
|
||||||
logging.warning("Could not write data to SNES")
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -655,7 +692,8 @@ async def snes_write(ctx : Context, write_list):
|
||||||
|
|
||||||
|
|
||||||
def snes_buffered_write(ctx : Context, address, data):
|
def snes_buffered_write(ctx : Context, address, data):
|
||||||
if len(ctx.snes_write_buffer) > 0 and (ctx.snes_write_buffer[-1][0] + len(ctx.snes_write_buffer[-1][1])) == address:
|
if ctx.snes_write_buffer and (ctx.snes_write_buffer[-1][0] + len(ctx.snes_write_buffer[-1][1])) == address:
|
||||||
|
# append to existing write command, bundling them
|
||||||
ctx.snes_write_buffer[-1] = (ctx.snes_write_buffer[-1][0], ctx.snes_write_buffer[-1][1] + data)
|
ctx.snes_write_buffer[-1] = (ctx.snes_write_buffer[-1][0], ctx.snes_write_buffer[-1][1] + data)
|
||||||
else:
|
else:
|
||||||
ctx.snes_write_buffer.append((address, data))
|
ctx.snes_write_buffer.append((address, data))
|
||||||
|
@ -665,8 +703,9 @@ async def snes_flush_writes(ctx : Context):
|
||||||
if not ctx.snes_write_buffer:
|
if not ctx.snes_write_buffer:
|
||||||
return
|
return
|
||||||
|
|
||||||
await snes_write(ctx, ctx.snes_write_buffer)
|
# swap buffers
|
||||||
ctx.snes_write_buffer = []
|
ctx.snes_write_buffer, writes = [], ctx.snes_write_buffer
|
||||||
|
await snes_write(ctx, writes)
|
||||||
|
|
||||||
|
|
||||||
async def send_msgs(websocket, msgs):
|
async def send_msgs(websocket, msgs):
|
||||||
|
|
|
@ -82,7 +82,7 @@ begin
|
||||||
begin
|
begin
|
||||||
// Is the installed version at least the packaged one ?
|
// Is the installed version at least the packaged one ?
|
||||||
Log('VC Redist x64 Version : found ' + strVersion);
|
Log('VC Redist x64 Version : found ' + strVersion);
|
||||||
Result := (CompareStr(strVersion, 'v14.26.28720') < 0);
|
Result := (CompareStr(strVersion, 'v14.28.29325') < 0);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue