Synced from pmdsky-debug

This commit is contained in:
AnonymousRandomPerson 2026-01-28 21:04:37 -05:00
parent f4f4e9754e
commit a05015dfe2
6 changed files with 57 additions and 37 deletions

View File

@ -1679,11 +1679,11 @@
.public SoundLfoWave_InvalidFunc
.public SoundLfoWave_ReverseSawFunc
.public SoundLfoWave_SawFunc
.public ST_I2N_E_BIN
.public ST_I2N_F_BIN
.public ST_I2N_G_BIN
.public ST_I2N_I_BIN
.public ST_I2N_S_BIN
.public ST_I2N_E_BIN_FILE_NAME
.public ST_I2N_F_BIN_FILE_NAME
.public ST_I2N_G_BIN_FILE_NAME
.public ST_I2N_I_BIN_FILE_NAME
.public ST_I2N_S_BIN_FILE_NAME
.public STRING_BALANCE_M_LEVEL_BIN
.public STRING_DUNGEON_DUNGEON_BIN
.public STRING_EFFECT_EFFECT_BIN

View File

@ -2886,24 +2886,24 @@ _02097FE4:
.byte 0x25, 0x73, 0x5B, 0x43, 0x53, 0x3A, 0x31, 0x3A, 0x52, 0x5D, 0x25, 0x73, 0x5B, 0x43, 0x52, 0x3A
.byte 0x31, 0x5D, 0x00, 0x00
#ifdef EUROPE
.global ST_I2N_I_BIN
ST_I2N_I_BIN:
.global ST_I2N_I_BIN_FILE_NAME
ST_I2N_I_BIN_FILE_NAME:
.string "st_i2n_i.bin"
.align 4
.global ST_I2N_E_BIN
ST_I2N_E_BIN:
.global ST_I2N_E_BIN_FILE_NAME
ST_I2N_E_BIN_FILE_NAME:
.string "st_i2n_e.bin"
.align 4
.global ST_I2N_S_BIN
ST_I2N_S_BIN:
.global ST_I2N_S_BIN_FILE_NAME
ST_I2N_S_BIN_FILE_NAME:
.string "st_i2n_s.bin"
.align 4
.global ST_I2N_G_BIN
ST_I2N_G_BIN:
.global ST_I2N_G_BIN_FILE_NAME
ST_I2N_G_BIN_FILE_NAME:
.string "st_i2n_g.bin"
.align 4
.global ST_I2N_F_BIN
ST_I2N_F_BIN:
.global ST_I2N_F_BIN_FILE_NAME
ST_I2N_F_BIN_FILE_NAME:
.string "st_i2n_f.bin"
.align 4
#endif
@ -2914,16 +2914,16 @@ BABY_EXCLUSIVE_ITEM_PAIRS:
.byte 0xCF, 0x01, 0x0B, 0x01, 0xD0, 0x01, 0x46, 0x01, 0xD1, 0x01, 0x88, 0x01, 0xD2, 0x01, 0xE0, 0x01
.byte 0xD3, 0x01, 0xE1, 0x01, 0xD4, 0x01, 0xE2, 0x01, 0xD5, 0x01, 0xE9, 0x01, 0xD6, 0x01, 0xF4, 0x01
.byte 0xD7, 0x01, 0x13, 0x02
.global ITEM_P_BIN
ITEM_P_BIN:
.global ITEM_P_BIN_FILE_PATH
ITEM_P_BIN_FILE_PATH:
.string "rom0:/BALANCE/item_p.bin"
.align 4
.global ITEM_S_P_BIN
ITEM_S_P_BIN:
.global ITEM_S_P_BIN_FILE_PATH
ITEM_S_P_BIN_FILE_PATH:
.string "rom0:/BALANCE/item_s_p.bin"
.align 4
.global ITEM_ST_I2N_BIN
ITEM_ST_I2N_BIN:
.global ITEM_ST_I2N_BIN_FORMAT
ITEM_ST_I2N_BIN_FORMAT:
#ifdef EUROPE
.string "rom0:/BALANCE/%s"
#else

View File

@ -11671,11 +11671,11 @@ ITEM_DATA_TABLE_PTRS:
#ifdef EUROPE
.global ITEM_LANG_FILE_ARRAY
ITEM_LANG_FILE_ARRAY:
.word ST_I2N_E_BIN
.word ST_I2N_F_BIN
.word ST_I2N_G_BIN
.word ST_I2N_I_BIN
.word ST_I2N_S_BIN
.word ST_I2N_E_BIN_FILE_NAME
.word ST_I2N_F_BIN_FILE_NAME
.word ST_I2N_G_BIN_FILE_NAME
.word ST_I2N_I_BIN_FILE_NAME
.word ST_I2N_S_BIN_FILE_NAME
#endif
.global _020AF6D0
_020AF6D0:

View File

@ -17,9 +17,9 @@ extern const char ITEM_NAME_FORMAT_YELLOW;
extern const char ITEM_NAME_FORMAT_INDIGO;
extern const char ITEM_NAME_FORMAT_PLAIN;
extern const char ITEM_NAME_FORMAT_CREAM;
extern const char ITEM_P_BIN;
extern const char ITEM_S_P_BIN;
extern const char ITEM_ST_I2N_BIN;
extern const char ITEM_P_BIN_FILE_PATH;
extern const char ITEM_S_P_BIN_FILE_PATH;
extern const char ITEM_ST_I2N_BIN_FORMAT;
extern char* ITEM_LANG_FILE_ARRAY[];
extern void LoadFileFromRom(struct iovec* iov, const char* filepath, u32 flags);
@ -36,18 +36,18 @@ static void SprintfStatic__0200E990(char*, const char*, ...);
void LoadItemPspi2n(void) {
struct iovec iov;
LoadFileFromRom(&iov, &ITEM_P_BIN, 1);
LoadFileFromRom(&iov, &ITEM_P_BIN_FILE_PATH, 1);
HandleSir0Translation(&ITEM_DATA_TABLE_PTRS.data, iov.iov_base);
LoadFileFromRom(&iov, &ITEM_S_P_BIN, 1);
LoadFileFromRom(&iov, &ITEM_S_P_BIN_FILE_PATH, 1);
HandleSir0Translation(&ITEM_DATA_TABLE_PTRS.exclusive_data, iov.iov_base);
if (PointsToZero(&ITEM_DATA_TABLE_PTRS.langFile) != 0) {
ZInit8(&ITEM_DATA_TABLE_PTRS.langFile);
#ifdef EUROPE
char buf[256];
SprintfStatic__0200E990(buf, &ITEM_ST_I2N_BIN, ITEM_LANG_FILE_ARRAY[GetLanguage()]);
SprintfStatic__0200E990(buf, &ITEM_ST_I2N_BIN_FORMAT, ITEM_LANG_FILE_ARRAY[GetLanguage()]);
LoadFileFromRom(&ITEM_DATA_TABLE_PTRS.langFile, buf, 1);
#else
LoadFileFromRom(&ITEM_DATA_TABLE_PTRS.langFile, &ITEM_ST_I2N_BIN, 1);
LoadFileFromRom(&ITEM_DATA_TABLE_PTRS.langFile, &ITEM_ST_I2N_BIN_FORMAT, 1);
#endif
}
}

View File

@ -3,7 +3,7 @@ import yaml
from typing import Dict, List
from containing_folder import CONTAINING_FOLDER
from symbol_details import SymbolDetails
from symbol_details import ALWAYS_APPEND_ADDRESS_SYMBOLS, IGNORE_DUPLICATE_SYMBOLS, SymbolDetails
SYMBOLS_FOLDER = 'symbols'
pmdsky_debug_path = None
@ -22,6 +22,9 @@ PMDSKY_DEBUG_SYMBOL_BLACKLIST = set([
'MEMORY_ALLOCATION_TABLE'
])
def format_symbol_with_address(symbol_name, address):
return f'{symbol_name}__{address:08X}'
"""
Returns the file path where pmdsky-debug is located locally, defined within pmdsky_debug_location.txt.
"""
@ -90,17 +93,22 @@ def read_pmdsky_debug_symbols() -> Dict[str, Dict[str, Dict[int, SymbolDetails]]
aliases = []
def add_symbol_address(address: int, symbol_details: SymbolDetails):
if address in symbols:
if address in symbols and symbol_details.name not in IGNORE_DUPLICATE_SYMBOLS:
print(f'Warning: Duplicate symbols found for address {hex(address)}: {symbols[address].name}, {symbol_details.name}')
symbols[address] = symbol_details
# If the symbol has multiple addresses in pmdsky-debug, append the address to the symbol name to ensure
# that each instance of the symbol has a unique name within the decomp.
if isinstance(addresses, list):
if len(addresses) > 1:
for address in addresses:
aliases = [f'{alias}__{address:08X}' for alias in aliases]
add_symbol_address(address, SymbolDetails(f'{symbol_name}__{address:08X}', full_file_path, is_data, aliases))
aliases = [format_symbol_with_address(alias, address) for alias in aliases]
add_symbol_address(address, SymbolDetails(format_symbol_with_address(symbol_name, address), full_file_path, is_data, aliases))
else:
add_symbol_address(addresses[0], SymbolDetails(symbol_name, full_file_path, is_data, aliases))
elif symbol_name in ALWAYS_APPEND_ADDRESS_SYMBOLS:
aliases = [format_symbol_with_address(alias, address) for alias in aliases]
add_symbol_address(addresses, SymbolDetails(format_symbol_with_address(symbol_name, address), full_file_path, is_data, aliases))
else:
add_symbol_address(addresses, SymbolDetails(symbol_name, full_file_path, is_data, aliases))

View File

@ -116,6 +116,18 @@ XMAP_TO_PMDSKY_DEBUG_SYMBOL_MAPPING = {
'sPositionZero': 'POSITION_ZERO',
}
# These symbols intentionally have the same address as another symbol in pmdsky-debug. Don't display warnings for them.
IGNORE_DUPLICATE_SYMBOLS = set([
'GUEST_MONSTER_DATA',
'GUEST_MONSTER_BANETTE',
])
# Symbols to always append the address onto.
# Used for symbols that are part of multiple overlays, making it harder to detect whether there are multiple symbols with the same name.
ALWAYS_APPEND_ADDRESS_SYMBOLS = set([
'SprintfStatic',
])
PMDSKY_DEBUG_TO_XMAP_SYMBOL_MAPPING = {pmdsky_debug_name: xmap_name for xmap_name, pmdsky_debug_name in XMAP_TO_PMDSKY_DEBUG_SYMBOL_MAPPING.items()}
@dataclass