From e674e37e08fed77fa724021a29eeaa7d92b25bfa Mon Sep 17 00:00:00 2001 From: lordlou <87331798+lordlou@users.noreply.github.com> Date: Thu, 28 Dec 2023 17:43:16 -0500 Subject: [PATCH] SMZ3: optimized message queues (#2611) --- worlds/smz3/Client.py | 22 +++++++++++----------- worlds/smz3/__init__.py | 3 ++- worlds/smz3/data/zsm.ips | Bin 1470841 -> 1470841 bytes 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/worlds/smz3/Client.py b/worlds/smz3/Client.py index 687a43b0..859cf234 100644 --- a/worlds/smz3/Client.py +++ b/worlds/smz3/Client.py @@ -69,7 +69,7 @@ class SMZ3SNIClient(SNIClient): ctx.finished_game = True return - data = await snes_read(ctx, SMZ3_RECV_PROGRESS_ADDR + 0x680, 4) + data = await snes_read(ctx, SMZ3_RECV_PROGRESS_ADDR + 0xD3C, 4) if data is None: return @@ -77,14 +77,14 @@ class SMZ3SNIClient(SNIClient): recv_item = data[2] | (data[3] << 8) while (recv_index < recv_item): - item_address = recv_index * 8 - message = await snes_read(ctx, SMZ3_RECV_PROGRESS_ADDR + 0x700 + item_address, 8) - is_z3_item = ((message[5] & 0x80) != 0) - masked_part = (message[5] & 0x7F) if is_z3_item else message[5] - item_index = ((message[4] | (masked_part << 8)) >> 3) + (256 if is_z3_item else 0) + item_address = recv_index * 2 + message = await snes_read(ctx, SMZ3_RECV_PROGRESS_ADDR + 0xDA0 + item_address, 2) + is_z3_item = ((message[1] & 0x80) != 0) + masked_part = (message[1] & 0x7F) if is_z3_item else message[1] + item_index = ((message[0] | (masked_part << 8)) >> 3) + (256 if is_z3_item else 0) recv_index += 1 - snes_buffered_write(ctx, SMZ3_RECV_PROGRESS_ADDR + 0x680, bytes([recv_index & 0xFF, (recv_index >> 8) & 0xFF])) + snes_buffered_write(ctx, SMZ3_RECV_PROGRESS_ADDR + 0xD3C, bytes([recv_index & 0xFF, (recv_index >> 8) & 0xFF])) from .TotalSMZ3.Location import locations_start_id from . import convertLocSMZ3IDToAPID @@ -95,7 +95,7 @@ class SMZ3SNIClient(SNIClient): snes_logger.info(f'New Check: {location} ({len(ctx.locations_checked)}/{len(ctx.missing_locations) + len(ctx.checked_locations)})') await ctx.send_msgs([{"cmd": 'LocationChecks', "locations": [location_id]}]) - data = await snes_read(ctx, SMZ3_RECV_PROGRESS_ADDR + 0x600, 4) + data = await snes_read(ctx, SMZ3_RECV_PROGRESS_ADDR + 0xD36, 4) if data is None: return @@ -106,10 +106,10 @@ class SMZ3SNIClient(SNIClient): item = ctx.items_received[item_out_ptr] item_id = item.item - items_start_id - player_id = item.player if item.player <= SMZ3_ROM_PLAYER_LIMIT else 0 - snes_buffered_write(ctx, SMZ3_RECV_PROGRESS_ADDR + item_out_ptr * 4, bytes([player_id & 0xFF, (player_id >> 8) & 0xFF, item_id & 0xFF, (item_id >> 8) & 0xFF])) + player_id = item.player if item.player < SMZ3_ROM_PLAYER_LIMIT else 0 + snes_buffered_write(ctx, SMZ3_RECV_PROGRESS_ADDR + item_out_ptr * 2, bytes([player_id, item_id])) item_out_ptr += 1 - snes_buffered_write(ctx, SMZ3_RECV_PROGRESS_ADDR + 0x602, bytes([item_out_ptr & 0xFF, (item_out_ptr >> 8) & 0xFF])) + snes_buffered_write(ctx, SMZ3_RECV_PROGRESS_ADDR + 0xD38, bytes([item_out_ptr & 0xFF, (item_out_ptr >> 8) & 0xFF])) logging.info('Received %s from %s (%s) (%d/%d in list)' % ( color(ctx.item_names[item.item], 'red', 'bold'), color(ctx.player_names[item.player], 'yellow'), ctx.location_names[item.location], item_out_ptr, len(ctx.items_received))) diff --git a/worlds/smz3/__init__.py b/worlds/smz3/__init__.py index 2cc2ac97..39aa42c0 100644 --- a/worlds/smz3/__init__.py +++ b/worlds/smz3/__init__.py @@ -80,7 +80,8 @@ class SMZ3World(World): locationNamesGT: Set[str] = {loc.Name for loc in GanonsTower(None, None).Locations} # first added for 0.2.6 - required_client_version = (0, 2, 6) + # optimized message queues for 0.4.4 + required_client_version = (0, 4, 4) def __init__(self, world: MultiWorld, player: int): self.rom_name_available_event = threading.Event() diff --git a/worlds/smz3/data/zsm.ips b/worlds/smz3/data/zsm.ips index fff36d95d15c96a9cc756c4fd0aa10ccda3e1751..87a4f924f1933fcf59493753c034192ef03a328c 100644 GIT binary patch delta 508 zcmezQDDvl{$O+3CKWtnvO`6Fece8^`77OFb&8ro5T;lp7_~TYgayzHem*(8h?YW;B zftU%1nSq!Eh*`Jier9WyVpQM$k(d2ABcuBCo&4;ojArfk`PqS(1Bf|+m}~oee(u$e z7+t4#f8ss^v}AhZXKq7phulRkUOWh3xbRV<>Q_d#$F22txr?|~&B(}@zaV!Jh$Gbx zB(gm?4jHUB%U#rOmAgm-s1C#hGW&r-K(2)VgJ|9M`=7au80$9(g4CV2$X)cI=#j$u zPm&B5QrA9Vx{$E;J@bX=rLiX&KJcAn`M`Bj@B`aP@efQ5?n?zuvIE(iK(_T#!3*YV z|4Du@vg-XO2~^6|pnFIGWFXh7{R|0