Merge branch 'master' of https://github.com/zeldaret/tp into dmap1

This commit is contained in:
root 2023-01-31 20:07:47 -08:00
commit 7745b0432e
11 changed files with 826 additions and 914 deletions

View File

@ -152,7 +152,7 @@ clean_rels:
rm -f -d -r $(BUILD_DIR)/rel
rm -f $(BUILD_PATH)/*.rel
tools: $(ELF2DOL) $(YAZ0)
tools: dirs $(ELF2DOL) $(YAZ0)
assets:
@mkdir -p game

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
lbl_805A26C8:
/* 805A26C8 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 805A26CC 7C 08 02 A6 */ mflr r0
/* 805A26D0 90 01 00 14 */ stw r0, 0x14(r1)
/* 805A26D4 93 E1 00 0C */ stw r31, 0xc(r1)
/* 805A26D8 93 C1 00 08 */ stw r30, 8(r1)
/* 805A26DC 7C 7E 1B 79 */ or. r30, r3, r3
/* 805A26E0 7C 9F 23 78 */ mr r31, r4
/* 805A26E4 41 82 00 1C */ beq lbl_805A2700
/* 805A26E8 38 80 00 00 */ li r4, 0
/* 805A26EC 4B A7 65 A1 */ bl __dt__10fopAc_ac_cFv
/* 805A26F0 7F E0 07 35 */ extsh. r0, r31
/* 805A26F4 40 81 00 0C */ ble lbl_805A2700
/* 805A26F8 7F C3 F3 78 */ mr r3, r30
/* 805A26FC 4B D2 C6 41 */ bl __dl__FPv
lbl_805A2700:
/* 805A2700 7F C3 F3 78 */ mr r3, r30
/* 805A2704 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 805A2708 83 C1 00 08 */ lwz r30, 8(r1)
/* 805A270C 80 01 00 14 */ lwz r0, 0x14(r1)
/* 805A2710 7C 08 03 A6 */ mtlr r0
/* 805A2714 38 21 00 10 */ addi r1, r1, 0x10
/* 805A2718 4E 80 00 20 */ blr

View File

@ -1,23 +0,0 @@
lbl_805A2658:
/* 805A2658 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 805A265C 7C 08 02 A6 */ mflr r0
/* 805A2660 90 01 00 14 */ stw r0, 0x14(r1)
/* 805A2664 93 E1 00 0C */ stw r31, 0xc(r1)
/* 805A2668 7C 7F 1B 78 */ mr r31, r3
/* 805A266C 80 03 04 A0 */ lwz r0, 0x4a0(r3)
/* 805A2670 54 00 07 39 */ rlwinm. r0, r0, 0, 0x1c, 0x1c
/* 805A2674 40 82 00 1C */ bne lbl_805A2690
/* 805A2678 28 1F 00 00 */ cmplwi r31, 0
/* 805A267C 41 82 00 08 */ beq lbl_805A2684
/* 805A2680 4B A7 64 E5 */ bl __ct__10fopAc_ac_cFv
lbl_805A2684:
/* 805A2684 80 1F 04 A0 */ lwz r0, 0x4a0(r31)
/* 805A2688 60 00 00 08 */ ori r0, r0, 8
/* 805A268C 90 1F 04 A0 */ stw r0, 0x4a0(r31)
lbl_805A2690:
/* 805A2690 38 60 00 04 */ li r3, 4
/* 805A2694 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 805A2698 80 01 00 14 */ lwz r0, 0x14(r1)
/* 805A269C 7C 08 03 A6 */ mtlr r0
/* 805A26A0 38 21 00 10 */ addi r1, r1, 0x10
/* 805A26A4 4E 80 00 20 */ blr

View File

@ -1,9 +0,0 @@
lbl_805A26A8:
/* 805A26A8 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 805A26AC 7C 08 02 A6 */ mflr r0
/* 805A26B0 90 01 00 14 */ stw r0, 0x14(r1)
/* 805A26B4 4B FF FF A5 */ bl create__12daTagAJnot_cFv
/* 805A26B8 80 01 00 14 */ lwz r0, 0x14(r1)
/* 805A26BC 7C 08 03 A6 */ mtlr r0
/* 805A26C0 38 21 00 10 */ addi r1, r1, 0x10
/* 805A26C4 4E 80 00 20 */ blr

View File

@ -1,11 +0,0 @@
lbl_805A271C:
/* 805A271C 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 805A2720 7C 08 02 A6 */ mflr r0
/* 805A2724 90 01 00 14 */ stw r0, 0x14(r1)
/* 805A2728 38 80 FF FF */ li r4, -1
/* 805A272C 4B FF FF 9D */ bl __dt__12daTagAJnot_cFv
/* 805A2730 38 60 00 01 */ li r3, 1
/* 805A2734 80 01 00 14 */ lwz r0, 0x14(r1)
/* 805A2738 7C 08 03 A6 */ mtlr r0
/* 805A273C 38 21 00 10 */ addi r1, r1, 0x10
/* 805A2740 4E 80 00 20 */ blr

View File

@ -1,9 +0,0 @@
lbl_805A2850:
/* 805A2850 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 805A2854 7C 08 02 A6 */ mflr r0
/* 805A2858 90 01 00 14 */ stw r0, 0x14(r1)
/* 805A285C 4B FF FE E9 */ bl execute__12daTagAJnot_cFv
/* 805A2860 80 01 00 14 */ lwz r0, 0x14(r1)
/* 805A2864 7C 08 03 A6 */ mtlr r0
/* 805A2868 38 21 00 10 */ addi r1, r1, 0x10
/* 805A286C 4E 80 00 20 */ blr

View File

@ -1,6 +1,15 @@
#ifndef D_A_TAG_AJNOT_H
#define D_A_TAG_AJNOT_H
#include "d/com/d_com_inf_game.h"
#include "dolphin/types.h"
#include "f_op/f_op_actor_mng.h"
class daTagAJnot_c : public fopAc_ac_c {
public:
/* 805A2658 */ int create();
/* 805A26C8 */ ~daTagAJnot_c();
/* 805A2744 */ int execute();
};
#endif /* D_A_TAG_AJNOT_H */

View File

@ -7,21 +7,6 @@
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Types:
//
struct fopAc_ac_c {
/* 80018B64 */ fopAc_ac_c();
/* 80018C8C */ ~fopAc_ac_c();
};
struct daTagAJnot_c {
/* 805A2658 */ void create();
/* 805A26C8 */ ~daTagAJnot_c();
/* 805A2744 */ void execute();
};
//
// Forward References:
//
@ -42,58 +27,39 @@ extern "C" extern void* g_profile_Tag_AJnot[12];
extern "C" void __ct__10fopAc_ac_cFv();
extern "C" void __dt__10fopAc_ac_cFv();
extern "C" void __dl__FPv();
extern "C" void PSVECSquareDistance();
extern "C" void _savegpr_29();
extern "C" void _restgpr_29();
extern "C" extern void* g_fopAc_Method[8];
extern "C" extern void* g_fpcLf_Method[5 + 1 /* padding */];
extern "C" extern u8 g_dComIfG_gameInfo[122384];
//
// Declarations:
//
/* 805A2658-805A26A8 000078 0050+00 1/1 0/0 0/0 .text create__12daTagAJnot_cFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void daTagAJnot_c::create() {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_ajnot/d_a_tag_ajnot/create__12daTagAJnot_cFv.s"
int daTagAJnot_c::create() {
if (!fopAcM_CheckCondition(this, 8)) {
new (this) daTagAJnot_c();
fopAcM_OnCondition(this, 8);
}
return 4;
}
#pragma pop
/* 805A26A8-805A26C8 0000C8 0020+00 1/0 0/0 0/0 .text daTagAJnot_Create__FP10fopAc_ac_c
*/
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
static asm void daTagAJnot_Create(fopAc_ac_c* param_0) {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_ajnot/d_a_tag_ajnot/daTagAJnot_Create__FP10fopAc_ac_c.s"
static int daTagAJnot_Create(fopAc_ac_c* ajnot) {
return static_cast<daTagAJnot_c*>(ajnot)->create();
}
#pragma pop
/* 805A26C8-805A271C 0000E8 0054+00 1/1 0/0 0/0 .text __dt__12daTagAJnot_cFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm daTagAJnot_c::~daTagAJnot_c() {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_ajnot/d_a_tag_ajnot/__dt__12daTagAJnot_cFv.s"
}
#pragma pop
daTagAJnot_c::~daTagAJnot_c() {}
/* 805A271C-805A2744 00013C 0028+00 1/0 0/0 0/0 .text daTagAJnot_Delete__FP12daTagAJnot_c
*/
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
static asm void daTagAJnot_Delete(daTagAJnot_c* param_0) {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_ajnot/d_a_tag_ajnot/daTagAJnot_Delete__FP12daTagAJnot_c.s"
static int daTagAJnot_Delete(daTagAJnot_c* ajnot) {
ajnot->~daTagAJnot_c();
return 1;
}
#pragma pop
/* ############################################################################################## */
/* 805A2880-805A2884 000000 0004+00 1/1 0/0 0/0 .rodata @3713 */
@ -123,25 +89,19 @@ COMPILER_STRIP_GATE(0x805A2888, &lit_3715);
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void daTagAJnot_c::execute() {
asm int daTagAJnot_c::execute() {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_ajnot/d_a_tag_ajnot/execute__12daTagAJnot_cFv.s"
}
#pragma pop
/* 805A2850-805A2870 000270 0020+00 1/0 0/0 0/0 .text daTagAJnot_Execute__FP12daTagAJnot_c */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
static asm void daTagAJnot_Execute(daTagAJnot_c* param_0) {
nofralloc
#include "asm/rel/d/a/tag/d_a_tag_ajnot/d_a_tag_ajnot/daTagAJnot_Execute__FP12daTagAJnot_c.s"
static int daTagAJnot_Execute(daTagAJnot_c* ajnot) {
return ajnot->execute();
}
#pragma pop
/* 805A2870-805A2878 000290 0008+00 1/0 0/0 0/0 .text daTagAJnot_Draw__FP12daTagAJnot_c
*/
static bool daTagAJnot_Draw(daTagAJnot_c* param_0) {
static bool daTagAJnot_Draw(daTagAJnot_c* ajnot) {
return true;
}

View File

@ -9,5 +9,3 @@ python-Levenshtein
cxxfilt
pyelftools
requests
zipfile
shutil

View File

@ -4,40 +4,26 @@ tp.py - Various tools used for the zeldaret/tp project.
"""
import hashlib
import io
import os
import sys
import time
import struct
import json
import subprocess
import logging
import multiprocessing as mp
import shutil
import platform
import stat
import zipfile
from dataclasses import dataclass, field
from typing import Dict, List, Set, Tuple
from pathlib import Path
try:
import click
import logging
import hashlib
import libdol
import librel
import libarc
import io
import extract_game_assets
import requests
import zipfile
import shutil
from rich.logging import RichHandler
from rich.console import Console
from rich.progress import Progress
from rich.text import Text
from rich.table import Table
except ImportError as e:
def _handle_import_error(ex: ImportError):
MISSING_PREREQUISITES = (
f"Missing prerequisite python module {e}.\n"
f"Run `python3 -m pip install --user -r tools/requirements.txt` to install prerequisites."
@ -46,6 +32,20 @@ except ImportError as e:
print(MISSING_PREREQUISITES, file=sys.stderr)
sys.exit(1)
try:
import click
import libdol
import libarc
import requests
from rich.logging import RichHandler
from rich.console import Console
from rich.progress import Progress
from rich.text import Text
from rich.table import Table
except ImportError as ex:
_handle_import_error(ex)
class PathPath(click.Path):
def convert(self, value, param, ctx):
@ -202,14 +202,12 @@ def setup(debug: bool, game_path: Path, tools_path: Path):
)
sys.exit(1)
c27_lmgr326b = c27.joinpath("Lmgr326b.dll")
if not c27_lmgr326b.exists() or not c27_lmgr326b.is_file():
c27_lmgr326b = c27.joinpath("lmgr326b.dll")
if not c27_lmgr326b.exists() or not c27_lmgr326b.is_file():
c27_lmgr326b = c27.joinpath("LMGR326B.dll")
if not c27_lmgr326b.exists() or not c27_lmgr326b.is_file():
c27_lmgr326b = c27.joinpath("LMGR326B.DLL")
if not c27_lmgr326b.exists() or not c27_lmgr326b.is_file():
c27_lmgr326b = None
for name in os.listdir(c27):
if name.lower() == "lmgr326b.dll":
c27_lmgr326b = c27.joinpath(name)
break
if not c27_lmgr326b or not c27_lmgr326b.is_file():
LOG.error(
(
f"Unable to find 'lmgr326b.dll' in '{c27}': missing file '{c27_lmgr326b}'\n"
@ -218,15 +216,15 @@ def setup(debug: bool, game_path: Path, tools_path: Path):
)
sys.exit(1)
c27_lmgr326b_cc = c27.joinpath("LMGR326B.dll")
if not c27_lmgr326b_cc.exists() or not c27_lmgr326b_cc.is_file():
LOG.debug(f"copy: '{c27_lmgr326b}', to: '{c27_lmgr326b_cc}'")
shutil.copy(c27_lmgr326b, c27_lmgr326b_cc)
def copy_lmgr326b(path: Path):
lmgr326b_cc = path.joinpath("LMGR326B.dll")
if not lmgr326b_cc.is_file():
LOG.debug(f"copy: '{c27_lmgr326b}', to: '{lmgr326b_cc}'")
shutil.copy(c27_lmgr326b, lmgr326b_cc)
c125_lmgr326b_cc = c125.joinpath("LMGR326B.dll")
if not c125_lmgr326b_cc.exists() or not c125_lmgr326b_cc.is_file():
LOG.debug(f"copy: '{c27_lmgr326b}', to: '{c125_lmgr326b_cc}'")
shutil.copy(c27_lmgr326b, c125_lmgr326b_cc)
copy_lmgr326b(c27)
copy_lmgr326b(c125)
copy_lmgr326b(c125e)
c27_mwcceppc = c27.joinpath("mwcceppc.exe")
if not c27_mwcceppc.exists() or not c27_mwcceppc.is_file():
@ -297,6 +295,18 @@ def setup(debug: bool, game_path: Path, tools_path: Path):
)
sys.exit(1)
# add execute flag to compilers for WSL
if os.name == 'posix':
subprocess.run(['chmod', '+x'] + list(compilers.glob("*/*.exe")))
#
text = Text("--- Building tools")
text.stylize("bold magenta")
CONSOLE.print(text)
if subprocess.run(["make", "tools"]).returncode != 0:
LOG.error("An error occurred while running 'make tools'")
exit(1)
#
text = Text("--- Extracting game assets")
text.stylize("bold magenta")
@ -313,10 +323,13 @@ def setup(debug: bool, game_path: Path, tools_path: Path):
sys.exit(1)
try:
import extract_game_assets
previous_dir = os.getcwd()
os.chdir(str(game_path.absolute()))
extract_game_assets.extract("../" + str(iso))
os.chdir(previous_dir)
except ImportError as ex:
_handle_import_error(ex)
except Exception as e:
LOG.error(f"failure:")
LOG.error(e)
@ -428,7 +441,7 @@ class ProgressGroup:
def calculate_rel_progress(build_path: Path, matching: bool, format: str, asm_files: Set[Path], ranges: List[Tuple[int, int]]):
results = []
results: List[ProgressGroup] = []
start = time.time()
rel_paths = get_files_with_ext(build_path.joinpath("rel"), ".rel")
end = time.time()
@ -437,12 +450,13 @@ def calculate_rel_progress(build_path: Path, matching: bool, format: str, asm_fi
start = time.time()
from collections import defaultdict
str_asm_rel = f"asm{os.path.sep}rel{os.path.sep}"
range_dict = defaultdict(list)
for file, range in zip(asm_files, ranges):
str_file = str(file)
if not str_file.startswith("asm/rel/"):
if not str_file.startswith(str_asm_rel):
continue
rel = str_file.split("/")[-3]
rel = str_file.split(os.path.sep)[-3]
range_dict[rel].append(range[1] - range[0])
end = time.time()
@ -459,6 +473,7 @@ def calculate_rel_progress(build_path: Path, matching: bool, format: str, asm_fi
decompiled = size - sum(rel_ranges)
results.append(ProgressGroup(name, size, decompiled, {}))
results.sort(key=lambda prog: prog.name)
return results
@ -1132,6 +1147,11 @@ class CheckException(Exception):
def check_sha1(game_path: Path, build_path: Path, include_rels: bool):
try:
import librel
except ImportError as ex:
_handle_import_error(ex)
EXPECTED = {}
EXPECTED[0] = (
"",