diff --git a/README.md b/README.md index 413d6a49..f26c0ab7 100644 --- a/README.md +++ b/README.md @@ -6,29 +6,4 @@ This repository builds the following ROM: * [**pmdsky.us.nds**](https://datomatic.no-intro.org/index.php?page=show_record&s=28&n=4273) `sha1: 5fa96ca8d8dd6405d6cd2bad73ed68bc73a9d152` -Other disassembly and/or decompilation projects: -* [**Pokémon Red and Blue**](https://github.com/pret/pokered) -* [**Pokémon Gold and Silver (Space World '97 demo)**](https://github.com/pret/pokegold-spaceworld) -* [**Pokémon Yellow**](https://github.com/pret/pokeyellow) -* [**Pokémon Trading Card Game**](https://github.com/pret/poketcg) -* [**Pokémon Pinball**](https://github.com/pret/pokepinball) -* [**Pokémon Stadium**](https://github.com/pret/pokestadium) -* [**Pokémon Gold and Silver**](https://github.com/pret/pokegold) -* [**Pokémon Crystal**](https://github.com/pret/pokecrystal) -* [**Pokémon Ruby and Sapphire**](https://github.com/pret/pokeruby) -* [**Pokémon Pinball: Ruby & Sapphire**](https://github.com/pret/pokepinballrs) -* [**Pokémon FireRed and LeafGreen**](https://github.com/pret/pokefirered) -* [**Pokémon Emerald**](https://github.com/pret/pokeemerald) -* [**Pokémon Mystery Dungeon: Red Rescue Team**](https://github.com/pret/pmd-red) - -Gen 4 decompilation projects: -* [**Pokémon Diamond and Pearl**](https://github.com/pret/pokediamond) -* [**Pokémon Platinum**](https://github.com/pret/pokeplatinum) -* [**Pokémon HeartGold and SoulSilver**](https://github.com/pret/pokeheartgold) - -## Contacts - -You can find us on: - -* [Discord (PRET, #pmd-sky)](https://discord.gg/d5dubZ3) -* [IRC](https://web.libera.chat/?#pret) +For contacts and other pret projects, see [pret.github.io](https://pret.github.io/). diff --git a/tools/extract_function/extract_function.py b/tools/extract_function/extract_function.py index 778e3f32..1fdd1e5b 100644 --- a/tools/extract_function/extract_function.py +++ b/tools/extract_function/extract_function.py @@ -14,6 +14,10 @@ if len(sys.argv) != 3: exit(1) _, function_location, function_header = sys.argv +if function_location.endswith('.s'): + function_location = function_location[:-2] +if function_header.endswith(';'): + function_header = function_header[:-1] left_parentheses_index = function_header.find('(') if left_parentheses_index >= 0: @@ -147,21 +151,32 @@ def write_inc_file(lines: List[str], file_path: str): with open(file_path, 'w') as inc_file: inc_file.writelines(write_lines) +print('Updating', LSF_FILE_PATH) +with open(LSF_FILE_PATH, 'w') as lsf_file: + lsf_file.writelines(lsf_lines) + +if remove_orig_file: + print('Removing', original_file_path) + os.remove(original_file_path) + print('Removing', original_inc_path) + os.remove(original_inc_path) +else: + print('Updating', original_file_path) + with open(original_file_path, 'w') as original_file: + original_file.writelines(original_asm_lines) + print('Updating', original_inc_path) + write_inc_file(original_asm_lines, original_inc_path) + if include_new_asm_file: + new_asm_file_path = os.path.join(ASM_FOLDER, new_asm_name) + print('Creating', new_asm_file_path) with open(os.path.join(ASM_FOLDER, new_asm_name), 'w') as new_asm_file: new_asm_file.write(new_asm_header) new_asm_file.writelines(new_asm_lines) -if remove_orig_file: - os.remove(original_file_path) - os.remove(original_inc_path) -else: - with open(original_file_path, 'w') as original_file: - original_file.writelines(original_asm_lines) - write_inc_file(original_asm_lines, original_inc_path) - -if include_new_asm_file: - write_inc_file(new_asm_lines, os.path.join(INCLUDE_FOLDER, f'{file_prefix}{new_file_address}.inc')) + new_asm_inc_path = os.path.join(INCLUDE_FOLDER, f'{file_prefix}{new_file_address}.inc') + print('Creating', new_asm_inc_path) + write_inc_file(new_asm_lines, new_asm_inc_path) function_body = f"""{function_header} {{ @@ -176,10 +191,12 @@ if merge_prev_file: if line != '\n' and not line.startswith('#'): header_lines[i] += f'{function_header};\n' break + print('Updating', header_file_path) with open(header_file_path, 'w') as header_file: header_file.writelines(header_lines) src_file_path = os.path.join(SRC_FOLDER, f'{merge_prev_file}.c') + print('Updating', src_file_path) with open(src_file_path, 'a') as src_file: src_file.write(f'\n{function_body}\n') @@ -195,20 +212,23 @@ elif merge_next_file: add_file.writelines(file_lines) header_file_path = os.path.join(HEADER_FOLDER, f'{merge_next_file}.h') + print('Updating', header_file_path) add_in_body_start(header_file_path, f'{function_header};\n') src_file_path = os.path.join(SRC_FOLDER, f'{merge_next_file}.c') + print('Updating', src_file_path) add_in_body_start(src_file_path, f'{function_body}\n\n') else: - with open(os.path.join(HEADER_FOLDER, f'{extract_file_name}.h'), 'w') as new_header_file: + header_file_path = os.path.join(HEADER_FOLDER, f'{extract_file_name}.h') + print('Creating', header_file_path) + with open(header_file_path, 'w') as new_header_file: file_guard = f'PMDSKY_{(file_prefix + extract_function_address).upper()}_H' new_header_file.write(f'#ifndef {file_guard}\n#define {file_guard}\n\n') new_header_file.write(f'{function_header};\n\n') new_header_file.write(f'#endif //{file_guard}\n') - with open(os.path.join(SRC_FOLDER, f'{extract_file_name}.c'), 'w') as new_src_file: + src_file_path = os.path.join(SRC_FOLDER, f'{extract_file_name}.c') + print('Creating', src_file_path) + with open(src_file_path, 'w') as new_src_file: new_src_file.write(f'#include "{extract_file_name}.h\n\n{function_body}\n') - -with open(LSF_FILE_PATH, 'w') as lsf_file: - lsf_file.writelines(lsf_lines)