this can only create problems

This commit is contained in:
SwareJonge 2023-02-05 13:57:39 +01:00
parent 8dd483692e
commit dcfd073dbd
9 changed files with 130 additions and 43 deletions

View File

@ -3,7 +3,8 @@ Decompilation of Mario Kart Double Dash!!
## Build Instructions
- Dump a copy of the debug version of the game and extract the main.dol
- Place main.dol in the orig folder
- Place the Codewarrior Compiler in tools/2.5, 2.0, 2.6 and 2.7 might work too
- Place the compilers of GC MW 2.5 in tools/2.5
- Place the compilers of GC MW 1.2.5 in tools/1.2.5
- Install DevkitPPC, Ninja and Python
- DevkitPPC r38 and r41 are known to work, other versions probably do too
- NOTE: if on Windows edit the environment variables to the location where you stored Devkitpro

View File

@ -106,10 +106,14 @@ PROGRESS = f"{PYTHON} {PPCDIS}/progress.py"
# Codewarrior
TOOLS = "tools"
SDK_CW = os.path.join(TOOLS, "1.2.5")
SDK_CC = os.path.join(SDK_CW, "mwcceppc")
CODEWARRIOR = os.path.join(TOOLS, "2.5")
CC = os.path.join(CODEWARRIOR, "mwcceppc")
LD = os.path.join(CODEWARRIOR, "mwldeppc")
if platform != "win32":
SDK_CC = f"wine {SDK_CC}"
CC = f"wine {CC}"
LD = f"wine {LD}"
@ -158,7 +162,7 @@ DOL_LCF = f"{BUILDDIR}/dol.lcf"
# Outputs
DOL_ELF = f"{BUILDDIR}/main.elf"
DOL_OUT = f"{OUTDIR}/main.dol"
DOL_MAP = f"{OUTDIR}/main.map"
DOL_MAP = f"{OUTDIR}/debugInfoM.MAP"
# Optional full disassembly
DOL_FULL = f"{OUTDIR}/dol.s"

View File

@ -101,8 +101,9 @@ JSystem/JAudio/JASReport.cpp:
.bss: [0x803aec98, 0x803aecb0]
.sbss: [0x80415a28, 0x80415a38]
dolphin/__ppc_eabi_init.s:
.text: [0x800f31d8, 0x800f322c]
dolphin/__ppc_eabi_init.cpp:
.init: [0x80003400, 0x80003458]
.text: [0x800f31b8, 0x800f324c]
Bando/EngineSound.cpp:
.text: [0x80118cac, 0x80118d1c]

View File

@ -658,7 +658,31 @@ global:
0x800a5fe0: __ct__Q29JGeometry8TVec3<f>Fv
# mtx.c
# PPCArch.c
0x800af634: PPCMfmsr
0x800af63c: PPCMtmsr
0x800af644: PPCMfhid0
0x800af64c: PPCMthid0
0x800af654: PPCMfl2cr
0x800af65c: PPCMtl2cr
0x800af664: PPCMtdec
0x800af66c: PPCSync
0x800af674: PPCHalt
0x800af688: PPCMtmmcr0
0x800af690: PPCMtmmcr1
0x800af698: PPCMtpmc1
0x800af6a0: PPCMtpmc2
0x800af6a8: PPCMtpmc3
0x800af6b0: PPCMtpmc4
0x800af6b8: PPCMffpscr
0x800af6d8: PPCMtfpscr
0x800af700: PPCMfhid2
0x800af708: PPCMthid2
0x800af710: PPCMtwpar
0x800af718: PPCDisableSpeculation
0x800af740: PPCSetFpNonIEEEMode
# mtx.c
0x800af748: PSMTXIdentity
0x800af774: PSMTXCopy
0x800af7a8: PSMTXConcat
@ -896,7 +920,21 @@ global:
0x800c96bc: GXReadXfRasMetric
# OS.c
0x800ec2cc: __OSFPRInit
0x800ec3f4: OSGetConsoleType
0x800ec580: OSInit
0x800ecc00: __OSSetExceptionHandler
0x800ecc1c: __OSGetExceptionHandler
0x800ecccc: OSDefaultExceptionHandler
0x800ecd24: __OSPSInit
0x800ecd78: __OSGetDIConfig
0x800ecd8c: OSRegisterVersion
0x80414230: __OSVersion
0x80415eec: __OSIsGcam
0x80415f08: __OSSavedRegionEnd
0x80415f0c: __OSSavedRegionStart
0x80415f10: __OSInIPL
0x80415f18: __OSStartTime
# OSAlarm.c
0x800ecdb8: OSInitAlarm

View File

@ -21,11 +21,10 @@ import common as c
####################
# Check CW was added
#os.path.exists("tools/1.2.5/mwcceppc.exe") and \
#os.path.exists("tools/1.2.5/mwldeppc.exe"), \
assert os.path.exists("tools/2.5/mwcceppc.exe") and \
os.path.exists("tools/2.5/mwldeppc.exe") and \
"Error: Codewarrior not found in tools/2.5"
os.path.exists("tools/1.2.5/mwcceppc.exe") and \
os.path.exists("tools/2.5/mwldeppc.exe"), \
"Error: Codewarrior not found!"
# Check binaries were added
assert os.path.exists(c.DOL), \
@ -497,7 +496,12 @@ class AsmSource(Source):
class CSource(Source):
def __init__(self, ctx: c.SourceContext, path: str):
if path.startswith("src/JSystem/JUtility/"):
self.cc = c.CC
self.cflags = ctx.cflags
if path.startswith("src/dolphin/"):
self.cc = c.SDK_CC # TODO: build flags for SDK
elif path.startswith("src/JSystem/JUtility/"):
self.cflags = c.JSYSTEM_SPACE_CFLAGS
elif path.startswith("src/JSystem/JKernel/"):
self.cflags = c.JSYSTEM_SPACE_CFLAGS
@ -507,8 +511,7 @@ class CSource(Source):
self.cflags = c.KANESHIGE_CFLAGS
elif path.startswith("src/Osako/"):
self.cflags = c.OSAKO_CFLAGS
else:
self.cflags = ctx.cflags
self.iconv_path = f"$builddir/iconv/{path}"
# Find generated includes
@ -530,6 +533,7 @@ class CSource(Source):
inputs = self.iconv_path,
implicit = [inc.path for inc in self.gen_includes],
variables = {
"cc": self.cc,
"cflags" : self.cflags,
"dep" : self.dep
}

View File

@ -0,0 +1,70 @@
#include "types.h"
#include "dolphin/os.h"
#include "dolphin/PPCArch.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*voidfunctionptr)(void); // pointer to function returning void
__declspec(section ".ctors") extern voidfunctionptr _ctors[];
__declspec(section ".dtors") extern voidfunctionptr _dtors[];
static void __init_cpp(void);
// clang-format off
__declspec(section ".init") asm void __init_hardware(void) {
nofralloc
mfmsr r0
ori r0,r0,0x2000
mtmsr r0
mflr r31
bl __OSPSInit
bl __OSFPRInit
bl __OSCacheInit
mtlr r31
blr
}
__declspec(section ".init") asm void __flush_cache(void) {
nofralloc
lis r5, 0xFFFFFFF1@h
ori r5, r5, 0xFFFFFFF1@l
and r5, r5, r3
subf r3, r5, r3
add r4, r4, r3
loop:
dcbst 0, r5
sync
icbi 0, r5
addic r5, r5, 8
addic. r4, r4, -8
bge loop
isync
blr
}
// clang-format on
void __init_user(void) { __init_cpp(); }
static void __init_cpp(void)
{
voidfunctionptr* constructor;
/*
* call static initializers
*/
for (constructor = _ctors; *constructor; constructor++) {
(*constructor)();
}
}
void __fini_cpp(void)
{
// UNUSED FUNCTION
}
void _ExitProcess(void) { PPCHalt(); }
#ifdef __cplusplus
}
#endif

View File

@ -1,31 +0,0 @@
# This file is needed to fix __sinit functions unless i start decomping this. problem: Dolphin.a reguires GC MW 1.2.5 instead of 2.5 which the game uses
.include "macros.inc"
.global __init_cpp
__init_cpp:
/* 800F31D8 7C0802A6 */ mflr r0
/* 800F31DC 90010004 */ stw r0, 4(r1)
/* 800F31E0 9421FFF0 */ stwu r1, -0x10(r1)
/* 800F31E4 93E1000C */ stw r31, 0xc(r1)
/* 800F31E8 3C608031 */ lis r3, _ctors@ha
/* 800F31EC 380360A0 */ addi r0, r3, _ctors@l
/* 800F31F0 7C1F0378 */ mr r31, r0
/* 800F31F4 48000004 */ b lbl_800f31f8
lbl_800f31f8:
/* 800F31F8 48000004 */ b lbl_800f31fc
lbl_800f31fc:
/* 800F31FC 48000010 */ b lbl_800f320c
lbl_800f3200:
/* 800F3200 7D8803A6 */ mtlr r12
/* 800F3204 4E800021 */ blrl
/* 800F3208 3BFF0004 */ addi r31, r31, 0x4
lbl_800f320c:
/* 800F320C 819F0000 */ lwz r12, 0(r31)
/* 800F3210 280C0000 */ cmplwi r12, 0
/* 800F3214 4082FFEC */ bne+ lbl_800f3200
/* 800F3218 80010014 */ lwz r0, 0x14(r1)
/* 800F321C 83E1000C */ lwz r31, 0xc(r1)
/* 800F3220 38210010 */ addi r1, r1, 0x10
/* 800F3224 7C0803A6 */ mtlr r0
/* 800F3228 4E800020 */ blr

0
tools/2.5/.gitkeep Normal file
View File