Skip to content

Commit

Permalink
Set trampoline delay slot instruction based on version
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyZac committed Jan 31, 2025
1 parent d012f83 commit 3f846a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class GameInfo:
title: str
crc: str
hook_adr: int
hook_delayslot: str
lang_adr: int
asm_adr: int
strings_adr: int
Expand All @@ -27,6 +28,7 @@ class GameInfo:
title="Sly 2: Band of Thieves (USA)",
crc="07652DD9",
hook_adr=0x2013e380,
hook_delayslot="lw $v0, 0x4($a0)",
lang_adr=None,
asm_adr=0x202E60B0,
strings_adr=0x203C7980,
Expand All @@ -36,6 +38,7 @@ class GameInfo:
title="Sly 2: Band of Thieves (Europe)",
crc="FDA1CBF6",
hook_adr=0x2013e398,
hook_delayslot="lw $v0, 0x4($a0)",
lang_adr=0x2E9254,
asm_adr=0x202ED500,
strings_adr=0x203CF190,
Expand All @@ -47,6 +50,7 @@ class GameInfo:
title="Sly 3: Honor Among Thieves (USA)",
crc="8BC95883",
hook_adr=0x20150648,
hook_delayslot="lw $v0, 0x4($v1)",
lang_adr=None,
asm_adr=0x2045af00,
strings_adr=0x200F1050,
Expand All @@ -55,6 +59,8 @@ class GameInfo:
)#,
#"pal": GameInfo(
#title="Sly 3: Honour Among Thieves (Europe)",
#hook_delayslot="lw $v0, 0x4($v1)",
#encoding='UTF-16',
#string_table=0x47B958
#)
}
Expand Down Expand Up @@ -82,7 +88,7 @@ class Generator:
verbose = False
debug = False

def __init__(self, game: int, region: str = "ntsc", lang: str = None, strings_address: int = None, code_address: int = None):
def __init__(self, game: int, region: str, lang: str = None, strings_address: int = None, code_address: int = None):
"""
Initializes the generator with the specified region and addresses
"""
Expand Down Expand Up @@ -192,7 +198,7 @@ def _gen_asm(self, string_pointers: list) -> str:
print("Generating assembly code...")

trampoline_obj = trampoline.Trampoline(string_pointers)
mips_code = trampoline_obj.gen_asm()
mips_code = trampoline_obj.gen_asm(self.game_info.hook_delayslot)

# Print assembly code if verbose
if self.verbose:
Expand Down
4 changes: 2 additions & 2 deletions generator/trampoline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ def __init__(self, id_string_pairs: list = None):
else:
self.id_string_pairs = id_string_pairs

def gen_asm(self) -> str:
def gen_asm(self, hook_delayslot) -> str:
"""
Generates the trampoline assembly code from the ID/string pairs on the object
"""
asm = "trampoline:\n"
asm += "lw $v0, 0x4($a0)\n"
asm += f"{hook_delayslot}\n"

for string_id, string_ptr in self.id_string_pairs:
asm += f"# check matched string ID {string_id}\n"
Expand Down

0 comments on commit 3f846a4

Please sign in to comment.