Skip to content

Commit

Permalink
tgco fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvris committed Jan 29, 2025
1 parent 5917978 commit e1259cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
12 changes: 9 additions & 3 deletions worlds/kss/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
KSS_COMPLETED_SUBGAMES = SRAM_1_START + 0x1A93
KSS_ARENA_HIGH_SCORE = SRAM_1_START + 0x1AA1
KSS_BOSS_DEFEATED = SRAM_1_START + 0x1AE7 # 4 bytes
KSS_SAVE_TREASURE = SRAM_1_START + 0x1A31 # 8 bytes
KSS_TGCO_TREASURE = SRAM_1_START + 0x1B05 # 8 bytes
KSS_SAVE_GOLD = SRAM_1_START + 0x1A3B # 3-byte 24-bit int
KSS_TGC0_GOLD = SRAM_1_START + 0x1B0F # 3-byte 24-bit int
KSS_SAVE_ABILITIES = SRAM_1_START + 0x1A3F
KSS_COPY_ABILITIES = SRAM_1_START + 0x1B1D # originally Milky Way Wishes deluxe essences
# Remapped for sending
KSS_SENT_DYNA_SWITCH = SRAM_1_START + 0x7A64
Expand Down Expand Up @@ -126,16 +129,19 @@ async def game_watcher(self, ctx: "SNIContext") -> None:
ability = (item.item & 0xFF) - 1
unlocked_abilities = int.from_bytes(await snes_read(ctx, KSS_COPY_ABILITIES, 3), "little")
unlocked_abilities |= (1 << ability)
snes_buffered_write(ctx, KSS_COPY_ABILITIES, unlocked_abilities.to_bytes(3, "little"))
for ptr in (KSS_SAVE_ABILITIES, KSS_COPY_ABILITIES):
snes_buffered_write(ctx, ptr, unlocked_abilities.to_bytes(3, "little"))
elif item.item & 0x200 != 0:
treasure = (item.item & 0xFF) - 1
unlocked_treasures = int.from_bytes(await snes_read(ctx, KSS_TGCO_TREASURE, 8), "little")
treasure_value = int.from_bytes(await snes_read(ctx, KSS_TGC0_GOLD, 3), "little")
treasure_info = treasures[ctx.item_names[item.item]]
treasure_value += treasure_info.value
unlocked_treasures |= (1 << treasure)
snes_buffered_write(ctx, KSS_TGCO_TREASURE, unlocked_treasures.to_bytes(8, "little"))
snes_buffered_write(ctx, KSS_TGC0_GOLD, treasure_value.to_bytes(3, "little"))
for ptr in (KSS_SAVE_TREASURE, KSS_TGCO_TREASURE):
snes_buffered_write(ctx, ptr, unlocked_treasures.to_bytes(8, "little"))
for ptr in (KSS_SAVE_GOLD, KSS_TGC0_GOLD):
snes_buffered_write(ctx, ptr, treasure_value.to_bytes(3, "little"))
elif item.item & 0x400 != 0:
planet = item.item & 0xFF
unlocked_planets = int.from_bytes(await snes_read(ctx, KSS_RECEIVED_PLANETS, 2), "little")
Expand Down
Binary file modified worlds/kss/data/kss_basepatch.bsdiff4
Binary file not shown.
1 change: 1 addition & 0 deletions worlds/kss/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class KSSProcedurePatch(APProcedurePatch, APTokenMixin):
procedure = [
("apply_bsdiff4", ["kss_basepatch.bsdiff4"]),
("apply_tokens", ["token_patch.bin"]),
("calc_snes_crc", [])
]


Expand Down
8 changes: 8 additions & 0 deletions worlds/kss/src/kss_basepatch.asm
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ org $02A34B
JML hook_copy_ability
NOP

org $07DEB2
NOP #3 ; Grants the initial treasure of TGCO for some reason, probably for the tutorial?

org $07DF3E
NOP #3 ; Dyna Blade initialization, just need to preserve switch state

Expand Down Expand Up @@ -846,6 +849,11 @@ org $CF3FB1
hook_check_treasure:
JSL check_treasure

org $CF4372
hook_set_treasure_value:
; we don't actually care about this value, just remove it
NOP #22

org $CF44BD
hook_set_treasure:
JSL set_treasure
Expand Down

0 comments on commit e1259cc

Please sign in to comment.