edit code to match debug build

This commit is contained in:
SwareJonge 2022-07-08 16:17:31 +02:00
parent 6e72e8b66d
commit e3184025aa
15 changed files with 133 additions and 43 deletions

View File

@ -7,4 +7,10 @@ kartLocale.cpp:
.sdata2: [0x804171c0, 0x804171e8]
Kaneshige/KartInfo.cpp:
.text: [0x801a8844, 0x801a89c8]
.text: [0x801a8844, 0x801a89c8]
#Sato/stMath.cpp: # can't be compiled currently
#.text: [0x8021f5fc, 0x8021f6e0]
#.rodata: [0x8037eec8, 0x8037eef0]
#.data: [0x8039d6f0, 0x8039d708]
#.sbss: [0x80416ac8, 0x80416ad0]

View File

@ -15,7 +15,7 @@ global:
0x800035c0: TRK_memcpy
0x80005518: __TRK_reset
#src/kartLocale.cpp:
# kartLocale.cpp:
#.text
0x800056c0: localize__10KartLocaleFv
#.data
@ -30,7 +30,14 @@ global:
0x804156e8: msVideoMode__10KartLocale
0x804156ec: msVideoFrameMode__10KartLocale
# JKRHeap.cpp
# random.cpp
0x800693c8: __ct__Q25JMath13TRandom_fast_FUl
# JUTAssert.cpp
0x80069af4: getSDevice__12JUTAssertionFv
0x80069bd8: showAssert_f__12JUTAssertionFUlPCciPCce
# JKRHeap.cpp
0x80084d9c: __nw__FUl
0x80084e28: __nw__FUli
0x80084eb8: __nw__FUlP7JKRHeapi
@ -40,17 +47,34 @@ global:
0x800851ac: __dl__FPv
0x800851d0: __dla__FPv
# NMWException.cp
# OSError.c
0x800eeaec: OSPanic
# NMWException.cp
0x80105af8: __destroy_new_array
0x80105b74: __destroy_arr
0x80105bec: __construct_array
0x80105ce8: __dt__26__partial_array_destructorFv
0x80105da0: __construct_new_array
# runtime.c
0x80105f24: __cvt_fp2unsigned
# KartInfo.cpp
0x801a8844: __ct__8KartInfoFv
0x801a8898: __dt__Q28KartInfo13KartCharacterFv
0x801a88d4: __ct__Q28KartInfo13KartCharacterFv
0x801a8904: reset__Q28KartInfo13KartCharacterFv
0x801a8914: reset__8KartInfoFv
0x801a896c: __dt__8KartInfoFv
0x801a8914: reset__8KartInfoFv
0x801a896c: __dt__8KartInfoFv
# stMath.cpp
0x8021f5fc: createAllRandom__8stRandomFv
0x8021f668: getRandomMax__8stRandomFUl
0x8021f6e0: getArbitUnitVec__8stRandomFRQ29JGeometry8TVec3<f>ff
0x8021f7f4: getArbitUnitVecSimple__8stRandomFRQ29JGeometry8TVec3<f>f
0x8021f908: getArbitUnitVecXZ__8stRandomFRQ29JGeometry8TVec3<f>f
0x8021f9a4: stGetRnd__FUl
0x8021fa28: stSetRndPermission__FUlb
0x8039d6f0: sRndMgr__8stRandom
0x80416ac8: sMgr__8stRandom

6
include/Dolphin/OS.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef OS_H
#define OS_H
extern "C" void OSPanic(const char* file, int line, const char* msg, ...);
#endif

View File

@ -2,9 +2,9 @@
#define JMATRIGONOMETRIC_H
#include "types.h"
#include <utility> // std::pair
#include "std/pair.h"
// from TP decomp
// from TP decomp and pikmin decomp
struct TSinCosTable {
std::pair<f32, f32> table[0x2000];

View File

@ -10,7 +10,7 @@ namespace JMath {
class TRandom_fast_
{
public:
inline TRandom_fast_(u32 num);
TRandom_fast_(u32 num);
u32 get() {
seed = (seed * 0x19660d) + 0x3c6ef35f;
return seed;
@ -35,6 +35,11 @@ namespace JMath {
private:
u32 seed;
};
template <class T>
class TRandom_ : TRandom_fast_{
public:
TRandom_(u32 num) : TRandom_fast_(num) {};
};
}
#endif // !JMATH_H

View File

@ -0,0 +1,12 @@
#ifndef JUTASSERT_H
#define JUTASSERT_H
#include "types.h"
class JUTAssertion {
public:
static u32 getSDevice(void);
static void showAssert_f(u32 device, char const * file, int line, char const * errormsg, ...);
};
#endif

View File

@ -50,7 +50,7 @@ public:
void shuffleStartNo();
void hideConsole(u32 param_2);
s16 getKartNumber() {
s32 getKartNumber() {
return kartNum;
}
@ -93,6 +93,6 @@ public:
s8 _0x29e[0x2e0 - 0x29e]; // unknown
};
RaceInfo gRaceInfo;
//RaceInfo gRaceInfo;
#endif // !RACEINFO_H

View File

@ -7,30 +7,27 @@
#include "JSystem/JGeometry.h"
class stRandom : JMath::TRandom_fast_ {
public:
static void createAllRandom();
u32 getRandomMax(u32 max);
f32 getArbitUnitVec(JGeometry::TVec3<f32>&, f32, f32);
f32 getArbitUnitVecSimple(JGeometry::TVec3<f32>&, f32);
f32 getArbitUnitVecXZ(JGeometry::TVec3<f32>&, f32);
inline void setPermission(bool perm) {
permission = perm;
}
public:
static stRandom* sRndMgr[6];
private:
static stRandom* sMgr; // not sure if this get's accesssed by something else, more research needed
stRandom() : JMath::TRandom_fast_(0) {
permission = true;
sMgr = this;
}
};
static void createAllRandom();
u32 getRandomMax(u32 max);
f32 getArbitUnitVec(JGeometry::TVec3<f32>&, f32, f32);
f32 getArbitUnitVecSimple(JGeometry::TVec3<f32>&, f32);
f32 getArbitUnitVecXZ(JGeometry::TVec3<f32>&, f32);
private:
u16 _0x4; // sin
u16 _0x6; // cos
f32 _0x8; // angle?
u8 _0xC[4]; // unknown
u32 randomSeed;
public:
bool permission;
// padding bytes
};

View File

@ -49,10 +49,10 @@ enum VideoMode {
namespace KartLocale {
void localize();
extern Language msLanguage;
extern SpeedUnit msSpeedUnit;
extern VideoMode msVideoMode;
extern VideoFrameMode msVideoFrameMode;
Language msLanguage;
SpeedUnit msSpeedUnit;
VideoMode msVideoMode;
VideoFrameMode msVideoFrameMode;
};
#endif // !KARTLOCALE_H

6
include/runtime.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef RUNTIME_H
#define RUNTIME_H
extern "C" unsigned long __cvt_fp2unsigned(double d);
#endif

25
include/std/pair.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef _STD_PAIR_H
#define _STD_PAIR_H
namespace std {
template <typename T1, typename T2> struct pair {
T1 first;
T2 second;
};
template <> struct pair<float, float> {
/*
* --INFO--
* Address: 80035520
* Size: 000010
* In: JSystem/JMath/JMATrigonometric.cpp
*/
pair()
: first(0.0f)
, second(0.0f) {};
float first;
float second;
};
} // namespace std
#endif

View File

@ -1 +0,0 @@
db87a9ec1a34275efc45d965dcdcb1a9eb131885 *out/main.dol

View File

@ -1,6 +1,8 @@
#include "Kaneshige/RaceInfo.h"
#include "JSystem/JMath/JMath.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "Dolphin/OS.h"
void RaceInfo::reset() {
isTinyProcess = false;
@ -77,20 +79,21 @@ void RaceInfo::setRaceLevel(ERaceLevel raceLvl) {
}
void RaceInfo::shuffleRandomSeed() {
// maybe randomSeed is TRandom_fast_? uses a template function in the debug version, probably inlined here
JMath::TRandom_fast_ rndm(randomSeed);
randomSeed = rndm.get();
JMath::TRandom_<JMath::TRandom_fast_> rndm(randomSeed);
randomSeed = ((JMath::TRandom_fast_)rndm).get();
}
void RaceInfo::shuffleStartNo() {
JMath::TRandom_fast_ rndm(randomSeed);
u32 seed;
JMath::TRandom_<JMath::TRandom_fast_> rndm(randomSeed);
for (u32 i = 0; i < (u32)getKartNumber(); i++) {
s32 kartIdx = getKartNumber();
u32 seed = rndm.get();
u32 newidx = i + (((JMath::TRandom_fast_)rndm).get() % (getKartNumber() - i));
u32 newidx = i + (seed % (kartIdx - i));
if(newidx >= getKartNumber()) {
JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), "RaceInfo.cpp", 751, "range over: %d <= dst=%d < %d", 0, newidx, getKartNumber());
OSPanic("RaceInfo.cpp", 751, "Halt");
}
s32 playerStartIdx = startPosIndex[i];
startPosIndex[i] = startPosIndex[newidx];
startPosIndex[newidx] = playerStartIdx;

View File

@ -1,13 +1,16 @@
#include "Sato/stMath.h"
#include "runtime.h"
#include "types.h"
#include <runtime.c>
#include "JSystem/JMath/JMATrigonometric.h"
#include "JSystem/JGeometry.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "Dolphin/OS.h"
void stRandom::createAllRandom() {
for (u32 i = 0; i < 6; i++) {
sRndMgr[i] = new stRandom();
stRandom::sRndMgr[i] = new stRandom();
}
}
@ -53,9 +56,13 @@ f32 stRandom::getArbitUnitVecXZ(JGeometry::TVec3<f32>& p1, f32 p2) {
}
stRandom * stGetRnd(u32 idx) {
if(stRandom::sRndMgr[idx]->permission == false) {
JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), "stMath.cpp", 924, "Random can\'t get :%d", idx);
OSPanic("stMath.cpp", 924, "Halt");
}
return stRandom::sRndMgr[idx];
}
void stSetRndPermission(u32 idx, bool perm) {
stRandom::sRndMgr[idx]->setPermission(perm); // i'm actually not sure at all if this is inlined,
stRandom::sRndMgr[idx]->permission = perm; // i'm actually not sure at all if this is inlined,
}

@ -1 +1 @@
Subproject commit 452d88fb301da9c607eb80f2d7b9ee01312c5e43
Subproject commit 3430452f0048bb235a131cd2038b0dbb697ba236