Fix root cause of ALttP hardware crashes on collect. (#2132)
As it turns out, SD2SNES / FXPAK Pro has a limit as to how many bytes can be written in a single command packet. Exceed this limit, and the hardware will crash. That limit is 512 bytes. Even then, I have scaled back to 256 bytes at a time for a margin of safety.
This commit is contained in:
parent
21baa302d4
commit
944fe6cb8c
18
SNIClient.py
18
SNIClient.py
|
@ -565,14 +565,16 @@ async def snes_write(ctx: SNIContext, write_list: typing.List[typing.Tuple[int,
|
||||||
PutAddress_Request: SNESRequest = {"Opcode": "PutAddress", "Operands": [], 'Space': 'SNES'}
|
PutAddress_Request: SNESRequest = {"Opcode": "PutAddress", "Operands": [], 'Space': 'SNES'}
|
||||||
try:
|
try:
|
||||||
for address, data in write_list:
|
for address, data in write_list:
|
||||||
PutAddress_Request['Operands'] = [hex(address)[2:], hex(len(data))[2:]]
|
while data:
|
||||||
# REVIEW: above: `if snes_socket is None: return False`
|
# Divide the write into packets of 256 bytes.
|
||||||
# Does it need to be checked again?
|
PutAddress_Request['Operands'] = [hex(address)[2:], hex(min(len(data), 256))[2:]]
|
||||||
if ctx.snes_socket is not None:
|
if ctx.snes_socket is not None:
|
||||||
await ctx.snes_socket.send(dumps(PutAddress_Request))
|
await ctx.snes_socket.send(dumps(PutAddress_Request))
|
||||||
await ctx.snes_socket.send(data)
|
await ctx.snes_socket.send(data[:256])
|
||||||
else:
|
address += 256
|
||||||
snes_logger.warning(f"Could not send data to SNES: {data}")
|
data = data[256:]
|
||||||
|
else:
|
||||||
|
snes_logger.warning(f"Could not send data to SNES: {data}")
|
||||||
except ConnectionClosed:
|
except ConnectionClosed:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue