Merge pull request #37 from AnonymousRandomPerson/main

Fixed some incorrect symbol names
This commit is contained in:
AnonymousRandomPerson
2023-11-22 15:11:36 -06:00
committed by GitHub
16 changed files with 97 additions and 73 deletions

View File

@@ -442,12 +442,12 @@
.public sub_02017AB0
.public sub_02017ACC
.public sub_02017B18
.public sub_02017B64
.public sub_02017B70
.public sub_02017B7C
.public sub_02017B88
.public sub_02017B94
.public sub_02017BD4
.public sub_02017BE0
.public sub_02017BEC
.public sub_02017BF8
.public sub_02017C04

View File

@@ -54,6 +54,7 @@
.public ov29_0237C922
.public ov29_0237C96C
.public PlayBgmByIdVeneer
.public PlayBgmByIdVolumeVeneer
.public RANDOM_MUSIC_ID_TABLE
.public RemoveEmptyItemsInBagWrapper
.public RemoveEquivItemNoHole
@@ -71,7 +72,6 @@
.public sub_0200D208
.public sub_02017ACC
.public sub_02017B18
.public sub_02017B64
.public sub_02017B70
.public sub_02017B7C
.public sub_02017C50

View File

@@ -38,7 +38,7 @@
.public GetWeatherColorTable
.public GINSENG_CHANCE_3
.public GUMMI_BELLY_RESTORE_TABLE
.public GUMMI_IQ_STRING_IDS
.public GUMMI_LIKE_STRING_IDS
.public HandleSir0Translation
.public InitMove
.public IQ_GUMMI_GAIN_TABLE

View File

@@ -63,7 +63,6 @@
.public ov10_022BED90
.public ov10_022BF160
.public ov10_022BFC5C
.public ov10_022C48A8
.public ov10_022C4C0C
.public ov10_022C4C0E
.public ov29_022E2CA0
@@ -91,6 +90,7 @@
.public ROLLOUT_DAMAGE_MULT_TABLE
.public SILVER_WIND_BOOST_CHANCE
.public SKY_ATTACK_CRINGE_CHANCE
.public SKY_ATTACK_DAMAGE_MULTIPLIER
.public SLEEP_TURN_RANGE
.public SMOKESCREEN_TURN_RANGE
.public SNORE_CRINGE_CHANCE

View File

@@ -14849,13 +14849,13 @@ PlayBgmByIdVeneer: ; 0x02017B58
_02017B60: .word PlayBgmById
arm_func_end PlayBgmByIdVeneer
arm_func_start sub_02017B64
sub_02017B64: ; 0x02017B64
ldr ip, _02017B6C ; =sub_02017E70
arm_func_start PlayBgmByIdVolumeVeneer
PlayBgmByIdVolumeVeneer: ; 0x02017B64
ldr ip, _02017B6C ; =PlayBgmByIdVolume
bx ip
.align 2, 0
_02017B6C: .word sub_02017E70
arm_func_end sub_02017B64
_02017B6C: .word PlayBgmByIdVolume
arm_func_end PlayBgmByIdVolumeVeneer
arm_func_start sub_02017B70
sub_02017B70: ; 0x02017B70
@@ -14912,13 +14912,13 @@ sub_02017BD4: ; 0x02017BD4
_02017BDC: .word sub_02018024
arm_func_end sub_02017BD4
arm_func_start PlayBgmByIdVolumeVeneer
PlayBgmByIdVolumeVeneer: ; 0x02017BE0
ldr ip, _02017BE8 ; =PlayBgmByIdVolume
arm_func_start sub_02017BE0
sub_02017BE0: ; 0x02017BE0
ldr ip, _02017BE8 ; =sub_020180A0
bx ip
.align 2, 0
_02017BE8: .word PlayBgmByIdVolume
arm_func_end PlayBgmByIdVolumeVeneer
_02017BE8: .word sub_020180A0
arm_func_end sub_02017BE0
arm_func_start sub_02017BEC
sub_02017BEC: ; 0x02017BEC
@@ -15188,8 +15188,8 @@ _02017E68: .word 0x000003E7
_02017E6C: .word _022A4BEC
arm_func_end PlayBgmById
arm_func_start sub_02017E70
sub_02017E70: ; 0x02017E70
arm_func_start PlayBgmByIdVolume
PlayBgmByIdVolume: ; 0x02017E70
stmdb sp!, {r3, r4, r5, r6, r7, lr}
ldr r3, _02017EE0 ; =0x000003E7
mov r6, r0
@@ -15221,7 +15221,7 @@ sub_02017E70: ; 0x02017E70
.align 2, 0
_02017EE0: .word 0x000003E7
_02017EE4: .word _022A4BEC
arm_func_end sub_02017E70
arm_func_end PlayBgmByIdVolume
arm_func_start StopBgmCommand
StopBgmCommand: ; 0x02017EE8
@@ -15368,8 +15368,8 @@ _02018098: .word 0x000003E7
_0201809C: .word _022A4BEC
arm_func_end sub_02018024
arm_func_start PlayBgmByIdVolume
PlayBgmByIdVolume: ; 0x020180A0
arm_func_start sub_020180A0
sub_020180A0: ; 0x020180A0
stmdb sp!, {r3, r4, r5, r6, r7, lr}
ldr r3, _02018110 ; =0x000003E7
mov r6, r0
@@ -15401,7 +15401,7 @@ PlayBgmByIdVolume: ; 0x020180A0
.align 2, 0
_02018110: .word 0x000003E7
_02018114: .word _022A4BEC
arm_func_end PlayBgmByIdVolume
arm_func_end sub_020180A0
arm_func_start sub_02018118
sub_02018118: ; 0x02018118

View File

@@ -10036,8 +10036,8 @@ ov10_022C48A0:
.global SOLARBEAM_DAMAGE_MULTIPLIER
SOLARBEAM_DAMAGE_MULTIPLIER:
.byte 0x00, 0x02, 0x00, 0x00
.global ov10_022C48A8
ov10_022C48A8:
.global SKY_ATTACK_DAMAGE_MULTIPLIER
SKY_ATTACK_DAMAGE_MULTIPLIER:
.byte 0x00, 0x02, 0x00, 0x00
.global ov10_022C48AC
ov10_022C48AC:

View File

@@ -6761,7 +6761,7 @@ _022E20D0:
mov r2, r3, lsl #0x10
mov r1, r1, lsr #0x10
mov r2, r2, lsr #0x10
bl sub_02017B64
bl PlayBgmByIdVolumeVeneer
b _022E2464
_022E2120:
bl sub_02017B70
@@ -6822,7 +6822,7 @@ _022E21A8:
mov r2, r3, lsl #0x10
mov r1, r1, lsr #0x10
mov r2, r2, lsr #0x10
bl PlayBgmByIdVolumeVeneer
bl sub_02017BE0
b _022E2464
_022E21F8:
bl sub_02017BEC

View File

@@ -474,7 +474,7 @@ _022EB0D4:
ldrh r1, [r4, #8]
mov r0, r0, lsr #0x10
mov r2, #0x100
bl sub_02017B64
bl PlayBgmByIdVolumeVeneer
_022EB0EC:
ldrh r1, [r4, #0xa]
mov r0, #4

View File

@@ -471,7 +471,7 @@ _0231D214:
movge fp, #2
movlt fp, #3
_0231D23C:
ldr r0, _0231D480 ; =GUMMI_IQ_STRING_IDS
ldr r0, _0231D480 ; =GUMMI_LIKE_STRING_IDS
mov r1, r5, lsl #1
ldrh r2, [r0, r1]
mov r0, sl
@@ -634,7 +634,7 @@ _0231D470: .word IQ_GUMMI_GAIN_TABLE
_0231D474: .word GUMMI_BELLY_RESTORE_TABLE
_0231D478: .word 0x000003E7
_0231D47C: .word 0x00000BF3
_0231D480: .word GUMMI_IQ_STRING_IDS
_0231D480: .word GUMMI_LIKE_STRING_IDS
_0231D484: .word ov29_02353324
_0231D488: .word ov10_022C44CC
_0231D48C: .word ov10_022C45E4

View File

@@ -2808,7 +2808,7 @@ DoMoveSkyAttack: ; 0x02327A28
bl IsChargingTwoTurnMove
cmp r0, #0
beq _02327AB8
ldr r1, _02327AE8 ; =ov10_022C48A8
ldr r1, _02327AE8 ; =SKY_ATTACK_DAMAGE_MULTIPLIER
mov r0, r8
ldr r3, [r1]
mov r1, r7
@@ -2849,7 +2849,7 @@ _02327ADC:
add sp, sp, #4
ldmia sp!, {r3, r4, r5, r6, r7, r8, pc}
.align 2, 0
_02327AE8: .word ov10_022C48A8
_02327AE8: .word SKY_ATTACK_DAMAGE_MULTIPLIER
_02327AEC: .word SKY_ATTACK_CRINGE_CHANCE
_02327AF0: .word 0x00000CD1
arm_func_end DoMoveSkyAttack

View File

@@ -3920,8 +3920,8 @@ ov29_023532C0:
ov29_023532C8:
.byte 0x0D, 0x00, 0x00, 0x00
.byte 0xDD, 0x3F, 0x00, 0x00
.global GUMMI_IQ_STRING_IDS
GUMMI_IQ_STRING_IDS:
.global GUMMI_LIKE_STRING_IDS
GUMMI_LIKE_STRING_IDS:
.byte 0x48, 0x0B, 0x49, 0x0B
.byte 0x4A, 0x0B, 0x4B, 0x0B
.global ov29_023532D8
@@ -4052,8 +4052,8 @@ ov29_023532C0:
ov29_023532C8:
.byte 0x0D, 0x00, 0x00, 0x00
.byte 0xDB, 0x3F, 0x00, 0x00
.global GUMMI_IQ_STRING_IDS
GUMMI_IQ_STRING_IDS:
.global GUMMI_LIKE_STRING_IDS
GUMMI_LIKE_STRING_IDS:
.byte 0x48, 0x0B, 0x49, 0x0B, 0x4A, 0x0B, 0x4B, 0x0B
.global ov29_023532D8
ov29_023532D8:

View File

@@ -1,17 +1,27 @@
import os
import yaml
from typing import Dict, List
from containing_folder import CONTAINING_FOLDER
from typing import Dict
from symbol_details import SymbolDetails
SYMBOLS_FOLDER = 'symbols'
pmdsky_debug_path = None
LANGUAGE_KEYS = {
LANGUAGE_KEYS_PMDSKY_DEBUG_TO_XMAP = {
'NA': 'us',
'EU': 'eu',
}
LANGUAGE_KEYS_XMAP_TO_PMDSKY_DEBUG = {value: key for key, value in LANGUAGE_KEYS_PMDSKY_DEBUG_TO_XMAP.items()}
# Symbols with duplicate addresses that should be ignored.
SYMBOL_BLACKLIST = set([
'EXCLUSIVE_ITEM_STAT_BOOST_DATA',
'GAME_STATE_VALUES',
'GUMMI_IQ_STRING_IDS',
])
def get_pmdsky_debug_location() -> str:
global pmdsky_debug_path
if not pmdsky_debug_path:
@@ -42,40 +52,48 @@ Dictionary format:
"""
def read_pmdsky_debug_symbols() -> Dict[str, Dict[str, Dict[int, SymbolDetails]]]:
pmdsky_debug_symbols: Dict[str, Dict[str, Dict[int, SymbolDetails]]] = {}
for language in LANGUAGE_KEYS:
pmdsky_debug_symbols[LANGUAGE_KEYS[language]] = {}
for language in LANGUAGE_KEYS_PMDSKY_DEBUG_TO_XMAP:
pmdsky_debug_symbols[LANGUAGE_KEYS_PMDSKY_DEBUG_TO_XMAP[language]] = {}
pmdsky_debug_path = get_pmdsky_debug_location()
def read_yaml_symbols(file_path: str, symbols_key: str, address_suffix = '') -> Dict[int, SymbolDetails]:
full_file_path = os.path.join(pmdsky_debug_path, SYMBOLS_FOLDER, file_path)
with open(full_file_path, 'r') as symbols_file:
symbols_yaml = yaml.safe_load(symbols_file)
symbols_yaml: Dict[str, any] = yaml.safe_load(symbols_file)
def read_symbols_from_array(array_key: str, is_data: bool):
for symbol in symbols_yaml[list(symbols_yaml.keys())[0]][array_key]:
for language in symbol['address'].keys():
if not language.endswith(address_suffix):
continue
base_language = language.replace(address_suffix, '')
if base_language not in LANGUAGE_KEYS:
base_language: str = language.replace(address_suffix, '')
if base_language not in LANGUAGE_KEYS_PMDSKY_DEBUG_TO_XMAP:
continue
language_symbols = pmdsky_debug_symbols[LANGUAGE_KEYS[base_language]]
language_symbols = pmdsky_debug_symbols[LANGUAGE_KEYS_PMDSKY_DEBUG_TO_XMAP[base_language]]
if symbols_key not in language_symbols:
language_symbols[symbols_key] = {}
symbols = language_symbols[symbols_key]
addresses = symbol['address'][language]
symbol_name = symbol['name']
addresses: int | List[int] = symbol['address'][language]
symbol_name: str = symbol['name']
if symbol_name in SYMBOL_BLACKLIST:
continue
def add_symbol_address(address: int, symbol_details: SymbolDetails):
if address in symbols:
print(f'Warning: Duplicate symbols found for address {hex(address)}: {symbols[address].name}, {symbol_details.name}')
symbols[address] = symbol_details
if isinstance(addresses, list):
if len(addresses) > 1:
for address in addresses:
symbols[address] = SymbolDetails(f'{symbol_name}__{address:08X}', full_file_path, is_data)
add_symbol_address(address, SymbolDetails(f'{symbol_name}__{address:08X}', full_file_path, is_data))
else:
symbols[addresses[0]] = SymbolDetails(symbol_name, full_file_path, is_data)
add_symbol_address(addresses[0], SymbolDetails(symbol_name, full_file_path, is_data))
else:
symbols[addresses] = SymbolDetails(symbol_name, full_file_path, is_data)
add_symbol_address(addresses, SymbolDetails(symbol_name, full_file_path, is_data))
read_symbols_from_array('functions', False)
read_symbols_from_array('data', True)

View File

@@ -1,6 +1,6 @@
from dataclasses import dataclass
MIXED_CASE_SYMBOLS = {
MIXED_CASE_SYMBOLS_ARM9 = {
'_secure': 'SECURE',
'_start_AutoloadDoneCallback': 'StartAutoloadDoneCallback',
'_start_ModuleParams': 'START_MODULE_PARAMS',
@@ -9,9 +9,16 @@ MIXED_CASE_SYMBOLS = {
'SVC_CpuSet': 'SvcCpuSet',
'SVC_SoftReset': 'SvcSoftReset',
'SVC_WaitByLoop': 'SvcWaitByLoop',
'SVC_WaitByLoop': 'SvcWaitByLoop',
}
MIXED_CASE_SYMBOLS_ARM7 = {
'_start': '_start_arm7',
'_start_AutoloadDoneCallback': 'StartAutoloadDoneCallbackArm7',
'do_autoload': 'do_autoload_arm7',
}
WRAM_OFFSET = 0x1477E18
@dataclass
class SymbolDetails:
name: str

View File

@@ -1,9 +1,10 @@
import os
import re
from typing import List
from pmdsky_debug_reader import *
from symbol_details import *
from xmap_reader import *
from pmdsky_debug_reader import read_pmdsky_debug_symbols
from symbol_details import MIXED_CASE_SYMBOLS_ARM7, MIXED_CASE_SYMBOLS_ARM9, WRAM_OFFSET
from xmap_reader import HEADER_FOLDER, read_xmap_symbols
# Syncs symbols from pmdsky-debug (https://github.com/UsernameFodder/pmdsky-debug) to the decomp.
# To use this script, you will need:
@@ -43,8 +44,8 @@ for language, pmdsky_debug_language_symbols in pmdsky_debug_symbols.items():
for address, symbol in pmdsky_debug_section.items():
if section_name == 'arm7' and address < 0x27E0000:
# Shift ARM 7 WRAM to its RAM location.
address += 0x1477E18
if address in xmap_section and xmap_section[address].name != symbol.name and xmap_section[address].name not in MIXED_CASE_SYMBOLS and xmap_section[address].name not in replaced_symbols:
address += WRAM_OFFSET
if address in xmap_section and xmap_section[address].name != symbol.name and xmap_section[address].name not in MIXED_CASE_SYMBOLS_ARM9 and xmap_section[address].name not in MIXED_CASE_SYMBOLS_ARM7 and xmap_section[address].name not in replaced_symbols:
old_symbol = xmap_section[address]
if '__' in old_symbol.name:

View File

@@ -1,11 +1,12 @@
import os
import re
from typing import List
from typing import Any, Dict, List
from ruamel.yaml.scalarint import HexCapsInt
from pmdsky_debug_reader import *
from symbol_details import *
from xmap_reader import *
from yaml_writer import *
from pmdsky_debug_reader import LANGUAGE_KEYS_XMAP_TO_PMDSKY_DEBUG, SYMBOLS_FOLDER, get_pmdsky_debug_location, read_pmdsky_debug_symbols
from symbol_details import MIXED_CASE_SYMBOLS_ARM7, MIXED_CASE_SYMBOLS_ARM9, WRAM_OFFSET, SymbolDetails
from xmap_reader import HEADER_FOLDER, read_xmap_symbols
from yaml_writer import YamlManager
# Syncs symbols from the decomp to a local clone of pmdsky-debug (https://github.com/UsernameFodder/pmdsky-debug).
# To use this script, you will need:
@@ -20,13 +21,6 @@ pmdsky_debug_location = get_pmdsky_debug_location()
default_symbol_name = re.compile(r'^(?:ov\d{2}|sub)?_[\dA-F]{8}(?:_[\w]{2})?$')
multiple_symbol_suffix = re.compile(r'__[\dA-F]{8}(?:_[\w]{2})?$')
LANGUAGE_KEYS = {
'us': 'NA',
'eu': 'EU',
}
INDENT_BLANK = '<blank>'
def get_base_symbol_name(symbol_name: str) -> str:
if multiple_symbol_suffix.search(symbol_name):
return symbol_name[:symbol.name.find('__')]
@@ -36,10 +30,14 @@ def sync_xmap_symbol(address: int, symbol: SymbolDetails, language: str, yaml_ma
if default_symbol_name.match(symbol.name):
return
language_key = LANGUAGE_KEYS[language]
language_key = LANGUAGE_KEYS_XMAP_TO_PMDSKY_DEBUG[language]
if symbol.name in MIXED_CASE_SYMBOLS:
symbol.name = MIXED_CASE_SYMBOLS[symbol.name]
if section_name == 'arm7':
mixed_case_symbols = MIXED_CASE_SYMBOLS_ARM7
else:
mixed_case_symbols = MIXED_CASE_SYMBOLS_ARM9
if symbol.name in mixed_case_symbols:
symbol.name = mixed_case_symbols[symbol.name]
base_symbol_name = get_base_symbol_name(symbol.name)
@@ -47,7 +45,7 @@ def sync_xmap_symbol(address: int, symbol: SymbolDetails, language: str, yaml_ma
if section_name == 'arm7' and address >= 0x37F8000:
# Shift ARM 7 WRAM to its ROM location.
wram_address = address
address -= 0x1477E18
address -= WRAM_OFFSET
if address in pmdsky_debug_section:
# If the address is already defined in pmdsky-debug, replace the old symbol name with the new one in the YAML and header files.
@@ -140,21 +138,20 @@ def sync_xmap_symbol(address: int, symbol: SymbolDetails, language: str, yaml_ma
hex_address = HexCapsInt(address)
reorder_languages = language_key == 'EU' and len(symbol_entry_language_addresses) > 1 and not symbol_entry_language_addresses[language_key]
if multiple_symbol_suffix.search(symbol.name):
if symbol_entry_addresses is None:
symbol_entry_language_addresses[language_key] = [hex_address]
if reorder_languages:
symbol_entry_language_addresses.move_to_end(language_key, last=False)
else:
if address not in symbol_entry_addresses:
symbol_entry_addresses.append(hex_address)
return
else:
reorder_languages = language_key == 'EU' and len(symbol_entry_language_addresses) > 1 and not symbol_entry_language_addresses[language_key]
symbol_entry_language_addresses[language_key] = HexCapsInt(hex_address)
if reorder_languages:
symbol_entry_language_addresses.move_to_end(language_key, last=False)
if 'length' in matching_symbol_entry and 'NA' in matching_symbol_entry['length']:
matching_symbol_entry['length'][language_key] = matching_symbol_entry['length']['NA']
matching_symbol_entry['length'].move_to_end(language_key, last=False)
if wram_address is not None:
symbol_entry_language_addresses[language_key + '-WRAM'] = HexCapsInt(wram_address)

View File

@@ -1,6 +1,7 @@
import os
import requests
from typing import Dict
from symbol_details import SymbolDetails
HEADER_FOLDER = 'include'