diff --git a/Makefile b/Makefile index be9d52b0949..6ee58131ab9 100644 --- a/Makefile +++ b/Makefile @@ -96,11 +96,10 @@ SBSS_PDHR := 10 default: all -check: +dol: $(DOL) $(SHA1SUM) -c $(TARGET).sha1 -all: dirs $(DOL) check - +all: dirs dol # Make sure build directory exists before compiling anything dirs: @mkdir -p build @@ -142,7 +141,7 @@ $(ELF): $(LIBS) $(O_FILES) $(ELF_SHIFT): $(LIBS) $(O_FILES) @echo $(O_FILES) > build/o_files - @$(PYTHON) tools/lcf.py dol --shift --output $(LDSCRIPT) + @$(PYTHON) tools/lcf.py dol_shift --output $(LDSCRIPT) $(LD) -application $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files $(LIBS) $(DOL_SHIFT): $(ELF_SHIFT) | tools diff --git a/include/dolphin/mtx/mtx.h b/include/dolphin/mtx/mtx.h index a842ce7b00f..adab16dbe9e 100644 --- a/include/dolphin/mtx/mtx.h +++ b/include/dolphin/mtx/mtx.h @@ -9,6 +9,7 @@ typedef float Mtx[3][4]; typedef float Mtx33[3][3]; typedef float Mtx23[2][3]; typedef f32 (*MtxP)[4]; +typedef const f32 (*CMtxP)[4]; //Change name later? extern "C" { void PSMTXIdentity(Mtx matrix); diff --git a/include/m_Do/m_Do_mtx.h b/include/m_Do/m_Do_mtx.h index 30c90bdd625..22ebf7c8267 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -1,8 +1,8 @@ #ifndef M_DO_M_DO_MTX_H #define M_DO_M_DO_MTX_H -#include "SSystem/SComponent/c_Xyz.h" -#include "SSystem/SComponent/c_sXyz.h" +#include "SSystem/SComponent/c_xyz.h" +#include "SSystem/SComponent/c_sxyz.h" #include "dolphin/mtx/mtx.h" #include "dolphin/mtx/quat.h" #include "dolphin/types.h" @@ -15,7 +15,7 @@ void mDoMtx_ZrotS(Mtx, s16); void mDoMtx_YrotS(Mtx, s16); void mDoMtx_XrotS(Mtx, s16); void mDoMtx_YrotM(Mtx, s16); -void mDoMtx_MtxToRot(MtxP, csXyz*); +void mDoMtx_MtxToRot(CMtxP, csXyz*); class mDoMtx_stack_c { public: diff --git a/src/m_Do/m_Do_mtx.cpp b/src/m_Do/m_Do_mtx.cpp index 8f9b9f025ca..9075b8eebf5 100644 --- a/src/m_Do/m_Do_mtx.cpp +++ b/src/m_Do/m_Do_mtx.cpp @@ -287,7 +287,7 @@ asm void mDoMtx_QuatConcat(Quaternion const* param_0, Quaternion const* param_1, #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void mDoMtx_MtxToRot(MtxP param_0, csXyz* param_1) { +asm void mDoMtx_MtxToRot(CMtxP param_0, csXyz* param_1) { nofralloc #include "asm/m_Do/m_Do_mtx/mDoMtx_MtxToRot__FPA4_CfP5csXyz.s" } diff --git a/tools/lcf.py b/tools/lcf.py index 028dc916f69..a350382ae91 100644 --- a/tools/lcf.py +++ b/tools/lcf.py @@ -33,11 +33,17 @@ VERSION = "1.0" sys.path.append("defs") -def lcf_generate(output_path): +def lcf_generate(output_path,shiftable,map_file): """Script for generating .lcf files""" import module0 + if shiftable == True: + print("Generating LCF for shiftability") + map_file = open(map_file,'r') + map_file = map_file.read() + map_file = map_file.splitlines() + # load symbols from compiled files symbols = [] for archive in ARCHIVES: @@ -95,7 +101,17 @@ def lcf_generate(output_path): if symbol["type"] == "LinkerGenerated": # linker handles these symbols continue - file.write(f"\t\"{symbol['label']}\" = 0x{symbol['addr']:08X};\n") + addr = symbol['addr'] + if shiftable==True: + for line in map_file: + if type(symbol['name'])==str and line.find(' '+symbol['name']+' ')!=-1 and name[0] != "@" or type(symbol['label']) == str and line.find(' '+symbol['label']+' ')!=-1: + linesplit = line.split() + if len(linesplit) > 3 and linesplit[2]!="NOT": + addr = int(linesplit[2],16) + file.write(f"\t\"{symbol['label']}\" = 0x{addr:08X};\n") + else: + file.write(f"\t\"{symbol['label']}\" = 0x{addr:08X};\n") + file.write("\n") # @stringBase0 is generated by the compiler. The dol2asm is using a trick to @@ -106,7 +122,18 @@ def lcf_generate(output_path): file.write("\t/* @stringBase0 */\n") for x in module0.SYMBOLS: if x["type"] == "StringBase": - file.write('\t"%s" = 0x%08X;\n' % (x["label"], x["addr"])) + addr = x['addr'] + if shiftable==True: + obj = (module0.TRANSLATION_UNITS[x['tu']].split('/')[-1])+'.o' + #print(obj) + for line in map_file: + if line.find(' '+obj)!=-1 and line.find(' '+x['name']+' ')!=-1 or line.find('\t'+obj)!=-1 and line.find(' '+x['name']+' ')!=-1: + linesplit = line.split() + if len(linesplit) > 3: + addr = int(linesplit[2],16) + file.write("\t\"%s\" = 0x%08X;\n" % (x['label'], addr)) + else: + file.write("\t\"%s\" = 0x%08X;\n" % (x['label'], addr)) file.write("}\n") file.write("\n") @@ -384,7 +411,20 @@ def lcf(): default="build/dolzel2/ldscript.lcf", ) def dol(output_path): - lcf_generate(output_path) + lcf_generate(output_path,False,None) + +@lcf.command(name="dol_shift") +@click.option( + "--output", + "-o", + "output_path", + required=False, + type=PathPath(file_okay=True, dir_okay=False), + default="build/dolzel2/ldscript.lcf", +) +@click.option('--map','-m','map_file',required=False,type=PathPath(file_okay=True, dir_okay=False), default="build/dolzel2/dolzel2.map") +def dol_shift(output_path,map_file): + lcf_generate(output_path,True,map_file) @lcf.command(name="rel")