Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ def MatchingFor(*versions):
Object(NonMatching, "Kameda/SceneLanEntry.cpp"),
Object(NonMatching, "Kameda/SceneMapSelect.cpp"),
Object(Matching, "Kameda/BattleName2D.cpp"),
Object(NonMatching, "Kameda/LapGhost2D.cpp"),
Object(Matching, "Kameda/LapGhost2D.cpp"),
Object(Matching, "Kameda/CanNotSaveG2D.cpp"),
Object(Matching, "Kameda/LANResult2D.cpp"),
Object(NonMatching, "Kameda/LANNum2D.cpp"),
Expand Down
41 changes: 31 additions & 10 deletions include/Kameda/LapGhost2D.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
#ifndef LAPGHOST2D_H
#define LAPGHOST2D_H

#include "JSystem/J2D/J2DGrafContext.h"
#include "JSystem/J2D/J2DPicture.h"
#include "JSystem/J2D/J2DScreen.h"
#include "JSystem/JKernel/JKRHeap.h"

#include "Kaneshige/RaceTime.h"

class LapGhost2D { // Autogenerated
class LapGhost2D
{
public:
LapGhost2D(JKRHeap *); // 0x801949c4
void init(); // 0x80194b58
void draw(); // 0x80194bac
void calc(); // 0x80194c38
void start(RaceTime, int); // 0x80194d08
// Inline/Unused
~LapGhost2D();
}; // class LapGhost2D
#endif // LAPGHOST2D_H
LapGhost2D(JKRHeap *heap); // 0x801949c4
~LapGhost2D(); // Unused

void init(); // 0x80194b58
void draw(); // 0x80194bac
void calc(); // 0x80194c38
void start(RaceTime raceTime, int lap); // 0x80194d08

private:
J2DAnmTransform *mTransform; // 0x00
u32 _4; // 0x04
f32 mTransformFrame; // 0x08

J2DAnmTevRegKey *mTevRegKey; // 0x0c
u32 _10; // 0x10
f32 mTevRegKeyFrame; // 0x14

J2DGrafContext *mGrafContext; // 0x18
J2DScreen *mScreen; // 0x1c

J2DPicture *mPictures[8]; // 0x20

bool mVisible[2]; // 0x40
};

#endif // LAPGHOST2D_H
4 changes: 2 additions & 2 deletions include/Osako/KartPadRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class KartPadRecord : public TARecord
mLapSplits[lap] = other;
}

void calcLapTime(int lap, RaceTime nextSplit)
const RaceTime& getLapSplit(int lap) const
{
#line 109
JUT_MINMAX_ASSERT(0, lap, NUM_LAP_SPLITS)
nextSplit.sub(nextSplit, mLapSplits[lap]);
return mLapSplits[lap];
}

private:
Expand Down
148 changes: 141 additions & 7 deletions src/Kameda/LapGhost2D.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,148 @@
#include "Kameda/LapGhost2D.h"
#include "mathHelper.h"

LapGhost2D::LapGhost2D(JKRHeap *) {}
#include "JSystem/J2D/J2DAnmLoader.h"
#include "JSystem/J2D/J2DPane.h"
#include "JSystem/JAudio/JASFakeMatch2.h" // For static initializer
#include "JSystem/JKernel/JKRArchive.h"
#include "JSystem/JKernel/JKRFileLoader.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "Kameda/J2DManager.h"
#include "Kaneshige/RaceMgr.h"
#include "Osako/GhostFile.h"
#include "Osako/Kart2DCommon.h"
#include "Osako/KartPadRecord.h"
#include "Osako/system.h"
#include "mathHelper.h" // For unused data

void LapGhost2D::init() {}
LapGhost2D::LapGhost2D(JKRHeap *heap)
{
mGrafContext = System::getJ2DOrtho();
mScreen = new (heap, 0) J2DScreen();

void LapGhost2D::draw() {}
mScreen->J2DScreen::set("LapGhost.blo", 0x40000, J2DManager::getManager()->getArchive());

void LapGhost2D::calc() {}
mTransform = (J2DAnmTransform *)J2DAnmLoaderDataBase::load(
JKRFileLoader::getGlbResource("LapGhost.bck", J2DManager::getManager()->getArchive()));
mScreen->setAnimation(mTransform);

void LapGhost2D::start(RaceTime, int) {}
mTevRegKey = (J2DAnmTevRegKey *)J2DAnmLoaderDataBase::load(
JKRFileLoader::getGlbResource("LapGhost.brk", J2DManager::getManager()->getArchive()));
mTevRegKey->searchUpdateMaterialID(mScreen);
mScreen->setAnimation(mTevRegKey);

#include "JSystem/JAudio/JASFakeMatch2.h"
for (int i = 0; i < 8; ++i)
{
J2DPicture *pane = (J2DPicture *)mScreen->search('GhTime0' + i);
#line 60
JUT_ASSERT(pane->getTypeID() == J2DPane_Picture);

mPictures[i] = pane;
}

init();
}

void LapGhost2D::init()
{
mTransformFrame = 0.0f;
mTevRegKeyFrame = 0.0f;

mVisible[0] = false;
mVisible[1] = false;

mTransform->setFrame(mTransformFrame);
mTevRegKey->setFrame(mTevRegKeyFrame);

mScreen->animation();
}

LapGhost2D::~LapGhost2D() {}

void LapGhost2D::draw()
{
if (mVisible[0])
{
ERacePhase racePhase = RCMGetManager()->getRacePhase();
if (racePhase != PHASE_CRS_DEMO)
{
RaceMgr *raceMgr = RCMGetManager();
if (!raceMgr->isReplayMode() && !raceMgr->mRaceInfo->isWaitDemo())
{
mGrafContext->setPort();
mScreen->draw(0.0f, 0.0f, mGrafContext);
}
}
}
}

void LapGhost2D::calc()
{
if (mVisible[0])
{
if (mTransformFrame < 130.0f)
{
mTransform->setFrame(mTransformFrame);
mTevRegKey->setFrame(mTevRegKeyFrame);

mTransformFrame += 1.0f;

if (mVisible[1])
{
if (++mTevRegKeyFrame >= 20.0f)
{
mTevRegKeyFrame = 0.0f;
}
}

mScreen->animation();
}
else
{
mTransformFrame = 0.0f;
mTevRegKeyFrame = 0.0f;

mVisible[0] = false;
mVisible[1] = false;

mTransform->setFrame(mTransformFrame);
mTevRegKey->setFrame(mTevRegKeyFrame);

mScreen->animation();
}
}
}

void LapGhost2D::start(RaceTime raceTime, int lap)
{
KartPadRecord &padRecord = gGhostFile.mFileData.mPadRecord;

if (gGhostFile.isValidGhostOnRace())
{
if (padRecord.isFrameValid())
{
mVisible[0] = true;

Kart2DCommon *kart2DCommon = Kart2DCommon::ptr();

raceTime.sub(padRecord.getLapSplit(lap).get());

int minutes, seconds, milliseconds;
raceTime.get(&minutes, &seconds, &milliseconds);

if (raceTime.get() < 0)
{
mPictures[7]->changeTexture(kart2DCommon->getAsciiTexture('-'), 0);
mVisible[1] = true;
}
else
{
mPictures[7]->changeTexture(kart2DCommon->getAsciiTexture('+'), 0);
mVisible[1] = false;
}

kart2DCommon->changeNumberTexture(minutes, &mPictures[5], 2, true, false);
kart2DCommon->changeNumberTexture(seconds, &mPictures[3], 2, true, false);
kart2DCommon->changeNumberTexture(milliseconds, &mPictures[0], 3, true, false);
}
}
}
Loading