Fixes + Decompile KartDamage

This commit is contained in:
SwareJonge 2024-05-05 00:30:16 +02:00
parent d2c38c241f
commit fe55c43fa2
12 changed files with 470 additions and 32 deletions

View File

@ -1564,6 +1564,12 @@ src/Yamamoto/KartTaeget.cpp:
.bss: [0x803ef200, 0x803ef230]
.sdata2: [0x8041ddc0, 0x8041ddc8]
src/Yamamoto/KartDamage.cpp:
.text: [0x80306cb0, 0x80307c44]
.ctors: [0x80316624, 0x80316628]
.bss: [0x803ef320, 0x803ef350]
.sdata2: [0x8041df10, 0x8041df18]
src/Yamamoto/KartStar.cpp:
.text: [0x80307c44, 0x80307eb8]
.ctors: [0x80316628, 0x8031662c]
@ -1574,13 +1580,12 @@ src/Yamamoto/KartTire.cpp:
.ctors: [0x8031662c, 0x80316630]
.bss: [0x803ef380, 0x803ef3b0]
# This file causes ninja to go over the 16bit character limit for the linking command
#src/Yamamoto/KartDisp.cpp:
#.text: [0x803101d8, 0x80311ae8]
#.ctors: [0x80316640, 0x80316644]
#.rodata: [0x80386e58, 0x803879c0]
#.bss: [0x803ef470, 0x803ef4a0]
#.sdata2: [0x8041e0f0, 0x8041e160]
src/Yamamoto/KartDisp.cpp:
.text: [0x803101d8, 0x80311ae8]
.ctors: [0x80316640, 0x80316644]
.rodata: [0x80386e58, 0x803879c0]
.bss: [0x803ef470, 0x803ef4a0]
.sdata2: [0x8041e0f0, 0x8041e160]
src/Yamamoto/KartHandle.cpp:
.text: [0x80311ae8, 0x80312154]

View File

@ -994,7 +994,7 @@ src/Kaneshige/HioMgr.cpp:
.data: [0x803559c0, 0x803559d0]
src/Kaneshige/KartInfo.cpp:
.text: [0x80183f00, 0x80184598] # excludes sinit
.text: [0x80183f00, 0x80184598]
.ctors: [0x802d8674, 0x802d8678]
.rodata: [0x8033cc18, 0x8033ce58]
.data: [0x803559f8, 0x80355aa0]
@ -1484,6 +1484,12 @@ src/Yamamoto/KartTaeget.cpp:
.bss: [0x803ae560, 0x803ae590]
.sdata2: [0x803dbc08, 0x803dbc10]
src/Yamamoto/KartDamage.cpp:
.text: [0x802c66cc, 0x802c796c]
.ctors: [0x802d8a28, 0x802d8a2c]
.bss: [0x803ae680, 0x803ae6b0]
.sdata2: [0x803dbd88, 0x803dbd90]
src/Yamamoto/KartStar.cpp:
.text: [0x802c796c, 0x802c7c68]
.ctors: [0x802d8a2c, 0x802d8a30]

View File

@ -4262,6 +4262,7 @@ global:
0x802a2ecc: NormalizeMatrix__7KartMatFPA4_f
0x802a30a4: OmegaMatrix__7KartMatFPA4_fP3Vecf
# kartCtrlStrat.cpp
0x802aae28: DoItmCancel__8KartGameFv
0x802ad274: MakeClear__8KartGameFv
0x802ae8f0: DoElementForce__8KartGameFv
0x802afcb0: DoStatus__8KartGameFv
@ -4363,7 +4364,12 @@ global:
# KartAnime.cpp
0x802b862c: IsAppeal__9KartAnimeFi
0x802b86ec: IsDamage__9KartAnimeFi
0x802b872c: IsDamageL__9KartAnimeFi
0x802b876c: IsDamageS__9KartAnimeFi
0x802b87ac: IsRide__9KartAnimeFi
0x802b87ec: IsNormalStart__9KartAnimeFi
0x802b8ba8: IsBurnAnime__9KartAnimeFi
0x802b8be8: IsDrive__9KartAnimeFi
0x802b8e4c: Init__9KartAnimeFv
# KartItemStrat.cpp
@ -4443,9 +4449,19 @@ global:
0x802c65b0: CheckIndication__9KartCheckFv
# KartDamage.cpp
0x802c66cc: Init__10KartDamageFi
0x802c66f8: ClrAllDamage__10KartDamageFv
0x802c6708: TstSetDamage__10KartDamageFv
0x802c6720: SetDamager__10KartDamageFv
0x802c6798: SetDriverEndDamageAnime__10KartDamageFv
0x802c6804: SetDamageAnime__10KartDamageFv
0x802c6aa4: SetBurnAnime__10KartDamageFv
0x802c6db8: SetBigDamageAnime__10KartDamageFv
0x802c71a4: MakeHalfDamage__10KartDamageFv
0x802c734c: MakeDamage__10KartDamageFv
0x802c739c: MakeBigDamage__10KartDamageFv
0x802c7404: MakeBurnDamage__10KartDamageFv
0x802c7454: DoDamageCrl__10KartDamageFv
# KartStar.cpp
0x802c796c: Init__8KartStarFi
0x802c7994: MakeStar__8KartStarFv

View File

@ -89,6 +89,4 @@ private:
// void searchRaceKartLight(unsigned long, int);
}; // class LightMgr
#endif

View File

@ -50,6 +50,7 @@ public:
ERaceGpCup getGpCup() const { return mGpCup; }
bool isLANMode() { return mIsLanMode; }
bool isTinyProcess() const { return mIsTinyProcess; }
bool isTrueEnding() const { return mIsTrueEnding; }
bool isMirror() const { return mIsMirror; }
bool isWaitDemo() const {return mDemoType != 0; }

View File

@ -130,6 +130,7 @@ public:
// RaceInfo related
bool isLANMode() const { return mRaceInfo->isLANMode(); }
bool isMirror() const { return mRaceInfo->isMirror(); }
bool isTinyProcess() const { return mRaceInfo->isTinyProcess(); }
bool isWaitDemoMode() const { return mRaceInfo->isWaitDemo(); }
int getKartNumber() const { return mRaceInfo->getKartNumber(); }
int getAwardKartNo() const { return mRaceInfo->getAwardKartNo(); }

View File

@ -11,6 +11,7 @@ public:
enum EffectType
{
// TODO
Effect_Burn = 0x13,
Effect_Star = 0x1c
};

View File

@ -103,8 +103,10 @@ public:
u8 _0[0x10]; //
u64 mFlags; // 0x10, 0x14
u8 mType; // 0x17
u8 _19[0x48 - 0x19]; //
u8 mType; // 0x18
u8 _19[0x30 - 0x19]; //
u64 mDamageFlags; // 30, 34
u8 _38[0x48 - 0x38]; //
}; // Size: 0x48

View File

@ -1,6 +1,10 @@
#ifndef KARTDAMAGE_H
#define KARTDAMAGE_H
#include "types.h"
class KartBody;
class KartDamage
{ // Autogenerated
public:
@ -8,7 +12,7 @@ public:
void Init(int); // 0x80306cb0
void ClrSetDamage(); // 0x80306d00
void ClrAllDamage(); // 0x80306d14
void TstSetDamage(); // 0x80306d24
bool TstSetDamage(); // 0x80306d24
void SetDamager(); // 0x80306d3c
void SetSetDamage(); // 0x80306dac
void SetSetBurn(); // 0x80306e4c
@ -27,7 +31,12 @@ public:
// void SetThunderDamageAnime();
// void DoAfterDamageCrl();
private:
u8 _0[0xc];
KartBody *mBody; // 0
u16 mFlags; // 4
u8 _6; // 6, unused?
u8 mDamageState; // 7
u16 mTimer; // 8
}; // 0xc
#endif // KARTDAMAGE_H

399
src/Yamamoto/KartDamage.cpp Normal file
View File

@ -0,0 +1,399 @@
#include "Kaneshige/RaceMgr.h"
#include "Sato/JPEffectPerformer.h"
#include "Yamamoto/kartCtrl.h"
#include "Yamamoto/kartCamera.h"
#include "Yamamoto/KartDamage.h"
#include "JSystem/JAudio/JASFakeMatch2.h"
void KartDamage::Init(int idx)
{
mBody = GetKartCtrl()->getKartBody(idx);
mFlags = 0;
_6 = 0;
mDamageState = 0;
mTimer = 0;
}
void KartDamage::ClrSetDamage()
{
mFlags &= ~(0x80 | 0x8 | 0x4 | 0x1);
}
void KartDamage::ClrAllDamage()
{
mFlags &= ~(0x100 | 0x80 | 0x40 | 0x20 | 0x10 | 0x8 | 0x4 | 0x2 | 0x1);
}
bool KartDamage::TstSetDamage()
{
return mFlags & (0x100 | 0x80 | 0x40 | 0x20 | 0x10 | 0x8 | 0x4 | 0x2 | 0x1);
}
void KartDamage::SetDamager()
{
if (mFlags & 1)
MakeDamage();
if (mFlags & 8)
MakeBigDamage();
if (mFlags & 0x80)
MakeBurnDamage();
ClrSetDamage();
SetDriverEndDamageAnime();
}
void KartDamage::SetSetDamage()
{
mDamageState = 0;
if (GetKartCtrl()->getKartAnime(mBody->mMynum)->IsDamageL(mBody->mMynum))
{
mFlags = 0;
mFlags |= 8;
mFlags &= ~(0x80 | 0x1);
}
else
{
mFlags = 0;
mFlags |= 1;
mFlags &= ~(0x80 | 0x8);
}
}
void KartDamage::SetSetBurn()
{
mDamageState = 0;
KartBody *body = mBody;
if (GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageL(body->mMynum))
{
mFlags = 0;
mFlags |= 8;
mFlags &= ~(0x80 | 0x1);
}
else if (GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageS(body->mMynum))
{
mFlags = 0;
mFlags |= 1;
mFlags &= ~(0x80 | 0x8);
}
else
{
mFlags = 0;
mFlags |= 0x80;
mFlags &= ~(0x8 | 0x1);
}
}
void KartDamage::SetSetBigDamage()
{
mDamageState = 0;
mFlags = 0;
mFlags |= 8;
mFlags &= ~(0x80 | 0x1);
if (GetKartCtrl()->CheckCamera(mBody->mMynum))
{
int camNo = GetKartCtrl()->GetCameraNum(mBody->mMynum);
GetKartCtrl()->getKartCam(camNo)->MakeShaker(0.4f);
}
mBody->getGame()->DoItmCancel();
}
void KartDamage::SetDriverDamageAnime()
{
KartBody *body = mBody;
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDrive(body->mMynum))
GetKartCtrl()->getKartAnime(body->mMynum)->mDamageFlags |= 0x20000;
GetKartCtrl()->getKartAnime(body->mMynum)->mDamageFlags &= ~0x40000;
}
void KartDamage::SetDriverEndDamageAnime()
{
KartBody *body = mBody;
if (GetKartCtrl()->getKartAnime(body->mMynum)->IsDrive(body->mMynum))
GetKartCtrl()->getKartAnime(body->mMynum)->mDamageFlags |= 0x40000;
}
void KartDamage::SetDamageAnime()
{
KartBody *body = mBody;
SetSetDamage();
if ((body->mCarStatus & 0x2000000000000ull) == 0)
{
SetDriverDamageAnime();
}
if ((body->getDamage()->mFlags & 8))
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageL(body->mMynum))
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x80000;
}
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags &= ~0x20000;
}
else
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageS(body->mMynum))
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x20000;
}
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags &= ~0x80000;
}
if (body->getThunder()->_4 & 1)
return;
if (GetKartCtrl()->CheckCamera(body->mMynum))
{
GetKartCtrl()->getKartCam(GetKartCtrl()->GetCameraNum(body->mMynum))->MakeShaker(0.4f);
}
}
void KartDamage::SetBurnAnime()
{
KartBody *body = mBody;
SetSetBurn();
SetDriverDamageAnime();
if ((body->getDamage()->mFlags & 8))
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageL(body->mMynum))
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x80000;
}
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags &= ~(0x40000000 | 0x20000);
}
else if ((body->getDamage()->mFlags & 1))
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageS(body->mMynum))
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x20000;
}
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags &= ~(0x40000000 | 0x20000);
}
else
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsBurnAnime(body->mMynum))
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x40000000;
}
JPEffectPerformer::setEffect(JPEffectPerformer::Effect_Burn, body->mMynum, body->mPos, 2);
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags &= ~(0x80000 | 0x20000);
}
}
void KartDamage::SetBigDamageAnime()
{
KartBody *body = mBody;
if (RaceMgr::getCurrentManager()->isTinyProcess())
{
SetDamageAnime();
}
else
{
SetDriverDamageAnime();
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageL(body->mMynum))
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x80000;
SetSetBigDamage();
}
}
void KartDamage::MakeHalfDamage()
{
KartBody *body = mBody;
body->getGame()->MakeClear();
if (GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageL(body->mMynum))
{
mFlags = 0;
mFlags |= 0x48;
}
else
{
mFlags = 0;
mFlags |= 0x20;
}
if ((body->getDamage()->mFlags & 8))
{
mFlags &= ~8;
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageL(body->mMynum))
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x80000;
}
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags &= ~(0x20000);
}
else
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamageS(body->mMynum))
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x20000;
}
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags &= ~(0x80000);
}
mDamageState = 1;
mTimer = 60;
}
void KartDamage::MakeDamage()
{
mBody->getGame()->MakeClear();
mFlags |= 0x10;
mDamageState = 1;
mTimer = 20;
}
void KartDamage::MakeBigDamage()
{
KartBody *body = mBody;
body->getGame()->MakeClear();
mFlags |= 0x40;
mDamageState = 1;
mTimer = 300;
GetKartCtrl()->getKartSound(body->mMynum)->DoDragVoice();
}
void KartDamage::MakeBurnDamage()
{
mBody->getGame()->MakeClear();
mFlags |= 0x100;
mDamageState = 1;
mTimer = 90;
}
void KartDamage::DoDamageCrl()
{
KartBody *body = mBody;
if (body->mCarStatus & 0x2000000000000ull)
return;
if (!(mFlags & (0x100 | 0x40 | 0x20 | 0x10)))
return;
if (mFlags & 0x10)
{
switch (mDamageState)
{
case 1: // Damage Timer Active
{
mTimer--;
if (mTimer == 0)
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x40000;
mDamageState = 2;
mTimer = 0; // ah yes, check if timer is zero and set it to zero if it's zero
}
break;
}
case 2: // Damage End
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamage(body->mMynum))
{
mDamageState = 0;
mFlags &= ~0x10;
body->mCarStatus &= ~0x80000000ull;
}
break;
}
}
}
else if (mFlags & 0x20)
{
switch (mDamageState)
{
case 1: // Damage Timer Active
{
mTimer--;
if (mTimer == 0)
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x40000;
mDamageState = 2;
mTimer = 0; // ah yes, check if timer is zero and set it to zero if it's zero
}
break;
}
case 2: // Damage End
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsDamage(body->mMynum))
{
mDamageState = 0;
mFlags = 0;
body->mCarStatus &= ~0x80000000ull;
}
break;
}
}
}
else if (mFlags & 0x100)
{
switch (mDamageState)
{
case 1: // Damage Timer Active
{
mTimer--;
if (mTimer == 0)
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x80000000;
mDamageState = 2;
mTimer = 0; // ah yes, check if timer is zero and set it to zero if it's zero
}
break;
}
case 2: // Damage End
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsBurnAnime(body->mMynum))
{
mDamageState = 0;
mFlags &= ~0x100;
body->mCarStatus &= ~0x80000000ull;
}
break;
}
}
}
else
{
if (GetKartCtrl()->CheckTandemItmGet(body->mMynum) && mDamageState == 1)
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x100000;
GetKartCtrl()->getKartSound(body->mMynum)->DoTandemVoice(0);
mDamageState = 2;
mTimer = 10;
}
switch (mDamageState)
{
case 1: // Damage Timer Active
{
mTimer--;
if (mTimer == 0)
{
GetKartCtrl()->getKartAnime(body->mMynum)->mFlags |= 0x100000;
GetKartCtrl()->getKartSound(body->mMynum)->DoTandemVoice(0);
mDamageState = 2;
mTimer = 10;
}
break;
}
case 2: // Damage End
{
if (!GetKartCtrl()->getKartAnime(body->mMynum)->IsNormalStart(body->mMynum))
{
mDamageState = 0;
mFlags &= ~0x40;
body->mCarStatus &= ~0x80000000ull;
}
break;
}
}
}
}

View File

@ -121,7 +121,7 @@ void KartCtrl::DynamicsInit(bool videoFlag)
body->mKartCannon = new KartCannon();
body->mKartScene = new KartScene();
body->mKartDossin = new KartDossin();
body->mKartTumble = new KartTumble();
body->mKartTumble = new KartTumble();
body->mKartCheck = new KartCheck();
body->mKartDamage = new KartDamage();
body->mKartStar = new KartStar();
@ -215,22 +215,23 @@ void KartCtrl::DynamicsReset()
}
}
void KartCtrl::DynamicsStage1() {
void KartCtrl::DynamicsStage1()
{
int i;
int kartCount = GetKartNumber();
if (mBitfield & 1)
return;
RivalKart::setRankAry();
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
getKartBody(i)->getItem()->CheckHitItem();
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
@ -243,16 +244,16 @@ void KartCtrl::DynamicsStage1() {
getKartBody(i)->getGame()->DoStatus();
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
DoGForce(i);
getKartBody(i)->DegubBody(0x28);
}
}
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
@ -261,7 +262,7 @@ void KartCtrl::DynamicsStage1() {
}
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
@ -276,16 +277,16 @@ void KartCtrl::DynamicsStage1() {
}
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication()) {
if (getKartBody(i)->getChecker()->CheckIndication())
{
CheckVertexReflection(i);
getKartBody(i)->DegubBody(0x2c);
}
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
@ -294,7 +295,7 @@ void KartCtrl::DynamicsStage1() {
}
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
@ -305,7 +306,7 @@ void KartCtrl::DynamicsStage1() {
DoBodyHit();
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
@ -315,7 +316,7 @@ void KartCtrl::DynamicsStage1() {
}
}
for (i = 0; i < kartCount; i = i + 1)
for (i = 0; i < kartCount; i++)
{
if (getKartBody(i)->getChecker()->CheckIndication())
{
@ -324,7 +325,6 @@ void KartCtrl::DynamicsStage1() {
{
getKartEnemy(i)->ActiveCtrl();
getKartTarget(i)->DoSearchTarget(i);
}
else
{