Skip to content

Commit

Permalink
Initial v2 files
Browse files Browse the repository at this point in the history
they work on AP 0.4.3
  • Loading branch information
TheLX5 committed Nov 6, 2023
1 parent eb30a71 commit 7b45336
Show file tree
Hide file tree
Showing 394 changed files with 6,974 additions and 106 deletions.
874 changes: 865 additions & 9 deletions worlds/smw/Aesthetics.py

Large diffs are not rendered by default.

151 changes: 141 additions & 10 deletions worlds/smw/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
SMW_ROMHASH_START = 0x7FC0
ROMHASH_SIZE = 0x15

SMW_PROGRESS_DATA = WRAM_START + 0x1F02
SMW_DRAGON_COINS_DATA = WRAM_START + 0x1F2F
SMW_PATH_DATA = WRAM_START + 0x1EA2
SMW_EVENT_ROM_DATA = ROM_START + 0x2D608
SMW_ACTIVE_LEVEL_DATA = ROM_START + 0x37F70
SMW_PROGRESS_DATA = WRAM_START + 0x1F02
SMW_DRAGON_COINS_DATA = WRAM_START + 0x1F2F
SMW_PATH_DATA = WRAM_START + 0x1EA2
SMW_EVENT_ROM_DATA = ROM_START + 0x2D608
SMW_ACTIVE_LEVEL_DATA = ROM_START + 0x37F70
SMW_MOON_DATA = WRAM_START + 0x1FEE
SMW_CHECKPOINT_DATA = WRAM_START + 0x1F3C
SMW_BONUS_BLOCK_DATA = WRAM_START + 0x1A000
SMW_BLOCKSANITY_DATA = WRAM_START + 0x1A400
SMW_BLOCKSANITY_FLAGS = WRAM_START + 0x1A010
SMW_SPECIAL_WORLD_CLEAR = WRAM_START + 0x1FFF


SMW_GOAL_DATA = ROM_START + 0x01BFA0
SMW_REQUIRED_BOSSES_DATA = ROM_START + 0x01BFA1
Expand All @@ -31,6 +38,10 @@
SMW_DEATH_LINK_ACTIVE_ADDR = ROM_START + 0x01BFA5
SMW_DRAGON_COINS_ACTIVE_ADDR = ROM_START + 0x01BFA6
SMW_SWAMP_DONUT_GH_ADDR = ROM_START + 0x01BFA7
SMW_MOON_ACTIVE_ADDR = ROM_START + 0x01BFA8
SMW_CHECKPOINT_ACTIVE_ADDR = ROM_START + 0x01BFA9
SMW_BONUS_BLOCK_ACTIVE_ADDR = ROM_START + 0x01BFAA
SMW_BLOCKSANITY_ACTIVE_ADDR = ROM_START + 0x01BFAB

SMW_GAME_STATE_ADDR = WRAM_START + 0x100
SMW_MARIO_STATE_ADDR = WRAM_START + 0x71
Expand All @@ -46,7 +57,9 @@
SMW_PAUSE_ADDR = WRAM_START + 0x13D4
SMW_MESSAGE_QUEUE_ADDR = WRAM_START + 0xC391

SMW_RECV_PROGRESS_ADDR = WRAM_START + 0x1F2B
SMW_RECV_PROGRESS_ADDR = WRAM_START + 0x1A00E

SMW_BLOCKSANITY_BLOCK_COUNT = 657

SMW_GOAL_LEVELS = [0x28, 0x31, 0x32]
SMW_INVALID_MARIO_STATES = [0x05, 0x06, 0x0A, 0x0C, 0x0D]
Expand Down Expand Up @@ -303,7 +316,16 @@ async def game_watcher(self, ctx):
progress_data = bytearray(await snes_read(ctx, SMW_PROGRESS_DATA, 0x0F))
dragon_coins_data = bytearray(await snes_read(ctx, SMW_DRAGON_COINS_DATA, 0x0C))
dragon_coins_active = await snes_read(ctx, SMW_DRAGON_COINS_ACTIVE_ADDR, 0x1)
from worlds.smw.Rom import item_rom_data, ability_rom_data, trap_rom_data
moon_data = bytearray(await snes_read(ctx, SMW_MOON_DATA, 0x0C))
moon_active = await snes_read(ctx, SMW_MOON_ACTIVE_ADDR, 0x1)
checkpoint_data = bytearray(await snes_read(ctx, SMW_CHECKPOINT_DATA, 0x0C))
checkpoint_active = await snes_read(ctx, SMW_CHECKPOINT_ACTIVE_ADDR, 0x1)
bonus_block_data = bytearray(await snes_read(ctx, SMW_BONUS_BLOCK_DATA, 0x0C))
bonus_block_active = await snes_read(ctx, SMW_BONUS_BLOCK_ACTIVE_ADDR, 0x1)
blocksanity_data = bytearray(await snes_read(ctx, SMW_BLOCKSANITY_DATA, SMW_BLOCKSANITY_BLOCK_COUNT))
blocksanity_flags = bytearray(await snes_read(ctx, SMW_BLOCKSANITY_FLAGS, 0xC))
blocksanity_active = await snes_read(ctx, SMW_BLOCKSANITY_ACTIVE_ADDR, 0x1)
from worlds.smw.Rom import item_rom_data, ability_rom_data, trap_rom_data, icon_rom_data
from worlds.smw.Levels import location_id_to_level_id, level_info_dict
from worlds import AutoWorldRegister
for loc_name, level_data in location_id_to_level_id.items():
Expand All @@ -326,6 +348,54 @@ async def game_watcher(self, ctx):

if bit_set:
new_checks.append(loc_id)
elif level_data[1] == 3:
# Moon Check
if not moon_active or moon_active[0] == 0:
continue

progress_byte = (level_data[0] // 8)
progress_bit = 7 - (level_data[0] % 8)

data = moon_data[progress_byte]
masked_data = data & (1 << progress_bit)
bit_set = (masked_data != 0)

if bit_set:
new_checks.append(loc_id)
elif level_data[1] == 4:
# Checkpoint Check
if not checkpoint_active or checkpoint_active[0] == 0:
continue

progress_byte = (level_data[0] // 8)
progress_bit = 7 - (level_data[0] % 8)

data = checkpoint_data[progress_byte]
masked_data = data & (1 << progress_bit)
bit_set = (masked_data != 0)

if bit_set:
new_checks.append(loc_id)
elif level_data[1] == 5:
# Bonus Block Check
if not bonus_block_active or bonus_block_active[0] == 0:
continue

progress_byte = (level_data[0] // 8)
progress_bit = 7 - (level_data[0] % 8)

data = bonus_block_data[progress_byte]
masked_data = data & (1 << progress_bit)
bit_set = (masked_data != 0)

if bit_set:
new_checks.append(loc_id)
elif level_data[1] >= 100:
if not blocksanity_active or blocksanity_active[0] == 0:
continue
block_index = level_data[1] - 100
if blocksanity_data[block_index] != 0:
new_checks.append(loc_id)
else:
event_id_value = event_id + level_data[1]

Expand Down Expand Up @@ -363,8 +433,9 @@ async def game_watcher(self, ctx):
# Don't receive items or collect locations outside of in-level mode
return

recv_count = await snes_read(ctx, SMW_RECV_PROGRESS_ADDR, 1)
recv_index = recv_count[0]
recv_count = await snes_read(ctx, SMW_RECV_PROGRESS_ADDR, 2)
recv_index = recv_count[0]+(recv_count[1]<<8)


if recv_index < len(ctx.items_received):
item = ctx.items_received[recv_index]
Expand All @@ -383,7 +454,7 @@ async def game_watcher(self, ctx):
receive_message = generate_received_text(item_name, player_name)
self.add_message_to_queue(receive_message)

snes_buffered_write(ctx, SMW_RECV_PROGRESS_ADDR, bytes([recv_index]))
snes_buffered_write(ctx, SMW_RECV_PROGRESS_ADDR, bytes([recv_index&0xFF, (recv_index>>8)&0xFF]))
if item.item in trap_rom_data:
item_name = ctx.item_names[item.item]
player_name = ctx.player_names[item.player]
Expand All @@ -404,6 +475,14 @@ async def game_watcher(self, ctx):
snes_buffered_write(ctx, SMW_SFX_ADDR, bytes([item_rom_data[item.item][2]]))

snes_buffered_write(ctx, WRAM_START + item_rom_data[item.item][0], bytes([new_item_count]))
elif item.item in icon_rom_data:
if verify_game_state[0] == 0x14:
queue_addr = await snes_read(ctx, WRAM_START + icon_rom_data[item.item][0], 2)
queue_addr = queue_addr[0]+(queue_addr[1]<<8)
queue_addr += 1
snes_buffered_write(ctx, WRAM_START + icon_rom_data[item.item][0], bytes([queue_addr&0xFF, (queue_addr>>8)&0xFF]))


elif item.item in ability_rom_data:
# Handle Upgrades
for rom_data in ability_rom_data[item.item]:
Expand Down Expand Up @@ -448,6 +527,11 @@ async def game_watcher(self, ctx):
path_data = bytearray(await snes_read(ctx, SMW_PATH_DATA, 0x60))
donut_gh_swapped = await snes_read(ctx, SMW_SWAMP_DONUT_GH_ADDR, 0x1)
new_dragon_coin = False
new_moon = False
new_checkpoint = False
new_bonus_block = False
new_blocksanity = False
i = 0
for loc_id in ctx.checked_locations:
if loc_id not in ctx.locations_checked:
ctx.locations_checked.add(loc_id)
Expand All @@ -456,6 +540,9 @@ async def game_watcher(self, ctx):
if loc_name not in location_id_to_level_id:
continue

logging.info(f"Recovered checks ({i:03}): {loc_name}")
i += 1

level_data = location_id_to_level_id[loc_name]

if level_data[1] == 2:
Expand All @@ -469,6 +556,42 @@ async def game_watcher(self, ctx):
dragon_coins_data[progress_byte] = new_data

new_dragon_coin = True
elif level_data[1] == 3:
# Moon Check

progress_byte = (level_data[0] // 8)
progress_bit = 7 - (level_data[0] % 8)

data = moon_data[progress_byte]
new_data = data | (1 << progress_bit)
moon_data[progress_byte] = new_data

new_moon = True
elif level_data[1] == 4:
# Checkpoint Check
progress_byte = (level_data[0] // 8)
progress_bit = 7 - (level_data[0] % 8)

data = checkpoint_data[progress_byte]
new_data = data | (1 << progress_bit)
checkpoint_data[progress_byte] = new_data

new_checkpoint = True
elif level_data[1] == 5:
# Checkpoint Check

progress_byte = (level_data[0] // 8)
progress_bit = 7 - (level_data[0] % 8)

data = bonus_block_data[progress_byte]
new_data = data | (1 << progress_bit)
bonus_block_data[progress_byte] = new_data

new_bonus_block = True
elif level_data[1] >= 100:
block_index = level_data[1] - 100
blocksanity_data[block_index] = 1
new_blocksanity = True
else:
if level_data[0] in SMW_UNCOLLECTABLE_LEVELS:
continue
Expand Down Expand Up @@ -513,6 +636,14 @@ async def game_watcher(self, ctx):

if new_dragon_coin:
snes_buffered_write(ctx, SMW_DRAGON_COINS_DATA, bytes(dragon_coins_data))
if new_moon:
snes_buffered_write(ctx, SMW_MOON_DATA, bytes(moon_data))
if new_checkpoint:
snes_buffered_write(ctx, SMW_CHECKPOINT_DATA, bytes(checkpoint_data))
if new_bonus_block:
snes_buffered_write(ctx, SMW_BONUS_BLOCK_DATA, bytes(bonus_block_data))
if new_blocksanity:
snes_buffered_write(ctx, SMW_BLOCKSANITY_DATA, bytes(blocksanity_data))
if new_events > 0:
snes_buffered_write(ctx, SMW_PROGRESS_DATA, bytes(progress_data))
snes_buffered_write(ctx, SMW_PATH_DATA, bytes(path_data))
Expand Down
7 changes: 6 additions & 1 deletion worlds/smw/Items.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class SMWItem(Item):

# Separate tables for each type of item.
junk_table = {
ItemName.one_up_mushroom: ItemData(0xBC0001, False),
ItemName.one_coin: ItemData(0xBC0017, False),
ItemName.five_coins: ItemData(0xBC0018, False),
ItemName.ten_coins: ItemData(0xBC0019, False),
ItemName.fifteen_coins: ItemData(0xBC001A, False),
ItemName.one_up_mushroom: ItemData(0xBC0001, False)
}

collectable_table = {
Expand All @@ -36,6 +40,7 @@ class SMWItem(Item):
ItemName.progressive_powerup: ItemData(0xBC000A, True),
ItemName.p_balloon: ItemData(0xBC000B, True),
ItemName.super_star_active: ItemData(0xBC000D, True),
ItemName.special_world_clear: ItemData(0xBC001B, True)
}

switch_palace_table = {
Expand Down
Loading

0 comments on commit 7b45336

Please sign in to comment.