Skip to content

Commit 6e0fa4d

Browse files
authored
Additional changes to SMW v2 (ArchipelagoMW#22)
* Batch of changes * Remove additional get_filler_item_name * Added a way for the client to write to level clear and all blocksanity blocks flags on !collect
1 parent 0151f69 commit 6e0fa4d

24 files changed

+1270
-1641
lines changed

worlds/smw/Aesthetics.py

+9
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,12 @@ def generate_curated_level_palette_data(rom, world: World):
845845
rom.write_byte(EATEN_BERRY_ADDR + 0x05, 0x04)
846846
rom.write_byte(EATEN_BERRY_ADDR + 0x07, 0x04)
847847

848+
# Fix title screen changing background colors
849+
rom.write_bytes(0x1D30, bytearray([0xEA, 0xEA, 0xEA]))
850+
851+
# Skips level intros automatically
852+
rom.write_byte(0x4896, 0x80)
853+
848854
def generate_curated_map_palette_data(rom, world: World):
849855
PALETTE_MAP_CODE_ADDR = 0x88200
850856
PALETTE_UPLOADER_EDIT = 0x88400
@@ -984,6 +990,9 @@ def generate_curated_map_palette_data(rom, world: World):
984990
rom.write_bytes(PALETTE_MAP_PTR_ADDR + ((map_num*3)<<8) + (palette*3), bytearray([data_ptr & 0xFF, (data_ptr>>8)&0xFF, (data_ptr>>16)&0xFF]))
985991
# Write data
986992
rom.write_bytes(PALETTE_MAP_DATA_ADDR + pal_offset, read_palette_file(current_map, maps[current_map][palette], "map"))
993+
# Update map mario palette
994+
chosen_palette = world.options.mario_palette.value
995+
rom.write_bytes(PALETTE_MAP_DATA_ADDR + pal_offset + 206, bytes(ow_mario_palettes[chosen_palette]))
987996
pal_offset += 0x11C
988997
bank_palette_count += 1
989998
map_num += 1

worlds/smw/Client.py

+26-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
SMW_BONUS_BLOCK_DATA = WRAM_START + 0x1A000
2828
SMW_BLOCKSANITY_DATA = WRAM_START + 0x1A400
2929
SMW_BLOCKSANITY_FLAGS = WRAM_START + 0x1A010
30+
SMW_LEVEL_CLEAR_FLAGS = WRAM_START + 0x1A200
3031
SMW_SPECIAL_WORLD_CLEAR = WRAM_START + 0x1FFF
3132

3233

@@ -60,7 +61,7 @@
6061

6162
SMW_RECV_PROGRESS_ADDR = WRAM_START + 0x1A00E
6263

63-
SMW_BLOCKSANITY_BLOCK_COUNT = 658
64+
SMW_BLOCKSANITY_BLOCK_COUNT = 582
6465

6566
SMW_GOAL_LEVELS = [0x28, 0x31, 0x32]
6667
SMW_INVALID_MARIO_STATES = [0x05, 0x06, 0x0A, 0x0C, 0x0D]
@@ -255,7 +256,6 @@ async def handle_trap_queue(self, ctx):
255256

256257
async def game_watcher(self, ctx):
257258
from SNIClient import snes_buffered_write, snes_flush_writes, snes_read
258-
259259

260260
boss_state = await snes_read(ctx, SMW_BOSS_STATE_ADDR, 0x1)
261261
game_state = await snes_read(ctx, SMW_GAME_STATE_ADDR, 0x1)
@@ -328,8 +328,9 @@ async def game_watcher(self, ctx):
328328
blocksanity_data = bytearray(await snes_read(ctx, SMW_BLOCKSANITY_DATA, SMW_BLOCKSANITY_BLOCK_COUNT))
329329
blocksanity_flags = bytearray(await snes_read(ctx, SMW_BLOCKSANITY_FLAGS, 0xC))
330330
blocksanity_active = await snes_read(ctx, SMW_BLOCKSANITY_ACTIVE_ADDR, 0x1)
331+
level_clear_flags = bytearray(await snes_read(ctx, SMW_LEVEL_CLEAR_FLAGS, 0x60))
331332
from worlds.smw.Rom import item_rom_data, ability_rom_data, trap_rom_data, icon_rom_data
332-
from worlds.smw.Levels import location_id_to_level_id, level_info_dict
333+
from worlds.smw.Levels import location_id_to_level_id, level_info_dict, level_blocks_data
333334
from worlds import AutoWorldRegister
334335
for loc_name, level_data in location_id_to_level_id.items():
335336
loc_id = AutoWorldRegister.world_types[ctx.game].location_name_to_id[loc_name]
@@ -537,6 +538,7 @@ async def game_watcher(self, ctx):
537538
new_hidden_1up = False
538539
new_bonus_block = False
539540
new_blocksanity = False
541+
new_blocksanity_flags = False
540542
i = 0
541543
for loc_id in ctx.checked_locations:
542544
if loc_id not in ctx.locations_checked:
@@ -595,13 +597,31 @@ async def game_watcher(self, ctx):
595597

596598
new_bonus_block = True
597599
elif level_data[1] >= 100:
600+
# Blocksanity flag Check
598601
block_index = level_data[1] - 100
599602
blocksanity_data[block_index] = 1
600603
new_blocksanity = True
604+
605+
# All blocksanity blocks flag
606+
new_blocksanity_flags = True
607+
for block_id in level_blocks_data[level_data[0]]:
608+
if blocksanity_data[block_id] != 1:
609+
new_blocksanity_flags = False
610+
continue
611+
if new_blocksanity_flags is True:
612+
progress_byte = (level_data[0] // 8)
613+
progress_bit = 7 - (level_data[0] % 8)
614+
data = blocksanity_flags[progress_byte]
615+
new_data = data | (1 << progress_bit)
616+
blocksanity_flags[progress_byte] = new_data
601617
else:
602618
if level_data[0] in SMW_UNCOLLECTABLE_LEVELS:
603619
continue
604620

621+
# Handle map indicators
622+
flag = 1 if level_data[1] == 0 else 2
623+
level_clear_flags[level_data[0]] |= flag
624+
605625
event_id = event_data[level_data[0]]
606626
event_id_value = event_id + level_data[1]
607627

@@ -650,7 +670,10 @@ async def game_watcher(self, ctx):
650670
snes_buffered_write(ctx, SMW_BONUS_BLOCK_DATA, bytes(bonus_block_data))
651671
if new_blocksanity:
652672
snes_buffered_write(ctx, SMW_BLOCKSANITY_DATA, bytes(blocksanity_data))
673+
if new_blocksanity_flags:
674+
snes_buffered_write(ctx, SMW_BLOCKSANITY_FLAGS, bytes(blocksanity_flags))
653675
if new_events > 0:
676+
snes_buffered_write(ctx, SMW_LEVEL_CLEAR_FLAGS, bytes(level_clear_flags))
654677
snes_buffered_write(ctx, SMW_PROGRESS_DATA, bytes(progress_data))
655678
snes_buffered_write(ctx, SMW_PATH_DATA, bytes(path_data))
656679
old_events = await snes_read(ctx, SMW_NUM_EVENTS_ADDR, 0x1)

0 commit comments

Comments
 (0)