Skip to content

Commit

Permalink
OoS: Changed ASM address convention to a more intuitive one
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinopony committed Jul 12, 2024
1 parent 2a855ef commit fefdc00
Show file tree
Hide file tree
Showing 46 changed files with 753 additions and 766 deletions.
126 changes: 63 additions & 63 deletions worlds/tloz_oos/patching/Constants.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
EOB_ADDR = [
0x3ec8, # 00
0x7e89, # 01
0x75bb, # 02
0x7dd7, # 03
0x7e12, # 04
0x7e2d, # 05
0x7864, # 06 - 128 bytes reserved for sprite expansion w/ web patcher
0x7900, # 07
0x7fc0, # 08
0x7f4e, # 09
0x7bf9, # 0a
0x7f6d, # 0b
0x7ea1, # 0c
0x7b82, # 0d
0x7ef3, # 0e
0x7f9d, # 0f
0x7bee, # 10
0x7eb0, # 11
0x7c8f, # 12
0x7bd2, # 13
0x6fc9, # 14 - ton of free space here
0x792d, # 15
0x7a07, # 16
0x7f3a, # 17
0x7e6d, # 18
0x76e1, # 19
0x70f0, # 1a - here too
0x7c40, # 1b
0x8000, # 1c
0x8000, # 1d
0x8000, # 1e
0x8000, # 1f
0x8000, # 20
0x8000, # 21
0x8000, # 22
0x8000, # 23
0x8000, # 24
0x8000, # 25
0x8000, # 26
0x8000, # 27
0x8000, # 28
0x8000, # 29
0x8000, # 2a
0x8000, # 2b
0x8000, # 2c
0x8000, # 2d
0x8000, # 2e
0x8000, # 2f
0x8000, # 30
0x8000, # 31
0x8000, # 32
0x8000, # 33
0x8000, # 34
0x8000, # 35
0x8000, # 36
0x8000, # 37
0x7df0, # 38
0x8000, # 39
0x8000, # 3a
0x8000, # 3b
0x8000, # 3c
0x8000, # 3d
0x8000, # 3e
0x714b # 3f - also here
0x3e89, # 01
0x35bb, # 02
0x3dd7, # 03
0x3e12, # 04
0x3e2d, # 05
0x3864, # 06 - 128 bytes reserved for sprite expansion w/ web patcher
0x3900, # 07
0x3fc0, # 08
0x3f4e, # 09
0x3bf9, # 0a
0x3f6d, # 0b
0x3ea1, # 0c
0x3b82, # 0d
0x3ef3, # 0e
0x3f9d, # 0f
0x3bee, # 10
0x3eb0, # 11
0x3c8f, # 12
0x3bd2, # 13
0x2fc9, # 14 - ton of free space here
0x392d, # 15
0x3a07, # 16
0x3f3a, # 17
0x3e6d, # 18
0x36e1, # 19
0x30f0, # 1a - here too
0x3c40, # 1b
0x4000, # 1c
0x4000, # 1d
0x4000, # 1e
0x4000, # 1f
0x4000, # 20
0x4000, # 21
0x4000, # 22
0x4000, # 23
0x4000, # 24
0x4000, # 25
0x4000, # 26
0x4000, # 27
0x4000, # 28
0x4000, # 29
0x4000, # 2a
0x4000, # 2b
0x4000, # 2c
0x4000, # 2d
0x4000, # 2e
0x4000, # 2f
0x4000, # 30
0x4000, # 31
0x4000, # 32
0x4000, # 33
0x4000, # 34
0x4000, # 35
0x4000, # 36
0x4000, # 37
0x3df0, # 38
0x4000, # 39
0x4000, # 3a
0x4000, # 3b
0x4000, # 3c
0x4000, # 3d
0x4000, # 3e
0x314b # 3f - also here
]

DEFINES = {
Expand Down
2 changes: 1 addition & 1 deletion worlds/tloz_oos/patching/ProcedurePatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def apply_patches(caller: APProcedurePatch, rom: bytes, patch_file: str) -> byte
assembler.add_block(Z80Block(metalabel, contents))
assembler.compile_all()
for block in assembler.blocks:
rom_data.write_bytes(block.addr.full_address(), block.byte_array)
rom_data.write_bytes(block.addr.address_in_rom(), block.byte_array)

# Perform direct edits on the ROM
alter_treasures(rom_data)
Expand Down
6 changes: 4 additions & 2 deletions worlds/tloz_oos/patching/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ def get_item_id_and_subid(item: Dict):
return item_id, item_subid


def hex_str(value, size=1):
def hex_str(value, size=1, min_length=0):
if value < 0:
if size == 1:
value += 0x100
elif size == 2:
value += 0x10000
else:
raise Exception("Invalid size (should be 1 or 2)")
return hex(value)[2:]
if min_length == 0:
min_length = size * 2
return hex(value)[2:].rjust(min_length, "0")
42 changes: 21 additions & 21 deletions worlds/tloz_oos/patching/asm/animals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
pop bc
ld a,(wWarpDestRoom)
ret
04/461e/: call checkSetAnimalSavePoint
04/061e/: call checkSetAnimalSavePoint

# vanilla game doesn't save non-natzu animal positions when it thinks you
# won't need them anymore. stop that.
05/45c9/: jr $28
05/05c9/: jr $28

# do this so that animals don't immediately stop walking onscreen when called
# on a bridge, namely the one to/from d1.
Expand All @@ -55,10 +55,10 @@
ret z
cp $1b
ret
05/493b/: |
05/093b/: |
call animalEntryIgnoreBridges
nop
05/71ea/: |
05/31ea/: |
call animalEntryIgnoreBridges
nop
Expand All @@ -67,8 +67,8 @@
05//checkFlute: |
ld a,TREASURE_FLUTE
jp checkTreasureObtained
05/776b/: call checkFlute
05/7a65/: call checkFlute
05/376b/: call checkFlute
05/3a65/: call checkFlute

# animals called by flute normally veto any nonzero collision value for the
# purposes of entering a screen, but this allows double-wide bridges (1a and
Expand Down Expand Up @@ -103,61 +103,61 @@
call convertShortToLongPosition
xor a
ret
09/4d9a/: call checkFluteCollisions
09/4dad/: call checkFluteCollisions
09/0d9a/: call checkFluteCollisions
09/0dad/: call checkFluteCollisions

# some of the ricky code here doesn't matter since ricky's flute isn't
# currently randomized (6cefde1), but it can stay in case things change.

# check flute icon instead of animal region for dimitri events:
# spawning dimitri + kids in sunken
09/4e4b/: |
09/0e4b/: |
ld a,($c6af)
cp $02
09/6f07/: |
09/2f07/: |
ld a,($c6af)
cp $02
09/737d/: |
09/337d/: |
ld a,($c6af)
cp $02
# trying to leave sunken w/ dimitri
09/6f34/: |
09/2f34/: |
ld a,($c6af)
cp $02
# check flute icon instead of animal region for ricky events:
# spawn ricky in pen
09/4e76/: |
09/0e76/: |
ld a,(wFluteIcon)
cp $01
# say goodbye when reaching spool
09/6ccc/: |
09/2ccc/: |
ld a,(wFluteIcon)
cp $01
# prevent subrosian dancing from giving dimitri's flute.
09/5e37/: or $20
09/1e37/: or $20

# stop ricky from giving his flute.
09/6e6c/: ret
0b/6b77/: |
09/2e6c/: ret
0b/2b77/: |
db jumpifmemoryeq
dw wAnimalRegion
db $7f
# prevent holodrum plain from changing the animal region when entered.
09/6f79/: jr $08
09/2f79/: jr $08

# remove the moosh and dimitri events in spool swamp.
11/6572/: db $ff
11/68d4/: db $ff
11/2572/: db $ff
11/28d4/: db $ff

# add proper treasure entries for each flute, like ages has.
15//fluteTreasureData: |
db $0a,$0b,$38,$3c
db $0a,$0c,$39,$3d
db $0a,$0d,$3a,$3e
15/5161/: |
15/1161/: |
db $80
dw fluteTreasureData
db $00
4 changes: 2 additions & 2 deletions worlds/tloz_oos/patching/asm/boss_items.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
pop hl
ret
0b/4b8f/: |
0b/0b8f/: |
db asm15
dw spawnBossItem
0b/4bb1/: |
0b/0bb1/: |
db asm15
dw spawnBossItem
2 changes: 1 addition & 1 deletion worlds/tloz_oos/patching/asm/collect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
ld e,$75 ; var35, containing text id
ld a,(de)
ret
09/42ef/: call bypassKeydropsTextbox
09/02ef/: call bypassKeydropsTextbox

# collect modes starting at 80 index this jump table to determine the actual
# mode.
Expand Down
2 changes: 1 addition & 1 deletion worlds/tloz_oos/patching/asm/combat_difficulty.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
ld (de),a
ld hl,$468d ; @ringDamageModifierTable
jp $4683 ; @writeDamageToApply
06/464d/: call alterDamageReceived
06/064d/: call alterDamageReceived
Loading

0 comments on commit fefdc00

Please sign in to comment.