Skip to content

Commit

Permalink
Merge pull request #3 from vabold/decomp_MultiDvdArchive
Browse files Browse the repository at this point in the history
MultiDvdArchive / LocalizedArchive: Almost done
  • Loading branch information
em-eight authored Jun 16, 2022
2 parents 5cdc305 + ade53a8 commit 2c33065
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 105 deletions.
3 changes: 2 additions & 1 deletion pack/rel_objects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ out/rel/rodata_8088fab7_8088fdc0.o
out/rel/data_808b2c88_808b2d38.o
out/GhostFile.o
out/rel/text_8051d4d4_8052a098.o
out/rel/data_808b2d50_808b31a8.o
out/rel/data_808b2d50_808b3188.o
out/LocalizedArchive.o
out/MultiDvdArchive.o
out/rel/text_8052ae5c_80555464.o
out/rel/rodata_8088fe28_80891370.o
Expand Down
3 changes: 2 additions & 1 deletion pack/rel_slices.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ enabled,name,textStart,textEnd,ctorsStart,ctorsEnd,dtorsStart,dtorsEnd,rodataSta
1,source/game/jmap/CourseMap.cpp,0x80512694,0x805127ec,,,,,,,0x808B2C30,0x808B2C3C,0x809BD6E8,0x809BD6EC
1,source/game/system/DvdArchive.cpp,0x80518CC0,0x80519670,,,,,0x8088FAA0,0x8088FAB7,0x808B2C78,0x808B2C88,,
1,source/game/system/GhostFile.cpp,0x8051c088,0x8051d4d4,,,,,,,0x808b2d38,0x808b2d50,,
1,source/game/system/MultiDvdArchive.cpp,0x8052a098,0x8052ae5c,,,,,0x8088fdc0,0x8088fe28,0x808b31a8,0x808b31e8,,
1,source/game/system/LocalizedArchive.cpp,0x8052a098,0x8052a538,,,,,0x8088fdc0,0x8088fe00,0x808b3188,0x808b31d8,,
1,source/game/system/MultiDvdArchive.cpp,0x8052a538,0x8052ae5c,,,,,0x8088fe00,0x8088fe28,0x808b31d8,0x808b31e8,,
1,source/game/util/Random.cpp,0x80555464,0x8055572c,,,,,0x80891370,0x80891380,0x808b42e0,0x808b42ec,,
1,source/game/kart/KartComponent.cpp,0x80590128,0x805901d0,,,,,,,,,0x809c1900,0x809c1910
1,source/game/ui/ControlGroup.cpp,0x805c23e4,0x805c2c18,,,,,,,,,,
Expand Down
77 changes: 77 additions & 0 deletions source/game/system/LocalizedArchive.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "LocalizedArchive.hpp"

const char* LOCALIZED_SZS[] = {"\0\0\0", "_E.szs\0", "_G.szs\0", "_F.szs\0",
"_S.szs\0", "_I.szs\0", "_N.szs\0", nullptr};
const char DIF_SZS[] = "_Dif.szs";

namespace System {

MultiDvdArchive* createMultiDvdArchive(SLoaderKind kind) {
MultiDvdArchive* archive = nullptr;

switch (kind) {
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
archive = new MultiDvdArchive(1);
break;
case RACE_COMMON:
archive = new RaceArchive;
break;
case 1:
archive = new CourseArchive;
break;
case 2:
archive = new Unk2Archive;
break;
}

return archive;
}

CourseArchive::CourseArchive() : MultiDvdArchive(4) { init(); }

void CourseArchive::init() {
MultiDvdArchive::init();
const char* dif = DIF_SZS;

if (this->archiveCount > 1) {
this->kinds[1] = 0;
strncpy(this->suffixes[1], dif, 0x80);
}
if (this->archiveCount > 2) {
this->kinds[2] = 4;
}
if (this->archiveCount > 3) {
this->kinds[3] = 4;
}
}

Unk2Archive::Unk2Archive() : MultiDvdArchive(2) { init(); }

void Unk2Archive::init() {
MultiDvdArchive::init();
const char* localization = LOCALIZED_SZS[SystemManager::sInstance->mLanguage];

if (this->archiveCount > 1) {
this->kinds[1] = 0;
strncpy(this->suffixes[1], localization, 0x80);
}
}

RaceArchive::RaceArchive() : MultiDvdArchive(2) { init(); }

void RaceArchive::init() {
MultiDvdArchive::init();
const char* localization = LOCALIZED_SZS[SystemManager::sInstance->mLanguage];

if (this->archiveCount > 1) {
this->kinds[1] = 0;
strncpy(this->suffixes[1], localization, 0x80);
}
}

} // namespace System
26 changes: 26 additions & 0 deletions source/game/system/LocalizedArchive.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
#include "MultiDvdArchive.hpp"

namespace System {

class RaceArchive : public MultiDvdArchive {
public:
RaceArchive();
virtual void init();
};

class Unk2Archive : public MultiDvdArchive {
public:
Unk2Archive();
virtual void init();
};

class CourseArchive : public MultiDvdArchive {
public:
CourseArchive();
virtual void init();
};

MultiDvdArchive* createMultiDvdArchive(SLoaderKind kind);

} // namespace System
75 changes: 3 additions & 72 deletions source/game/system/MultiDvdArchive.cpp
Original file line number Diff line number Diff line change
@@ -1,86 +1,17 @@
#include "MultiDvdArchive.hpp"
#pragma dont_reuse_strings on


#include <string.h>

#include "game/host_system/SystemManager.hpp"

#define SUFFIX_SIZE 128
const char* LOCALIZED_SZS[] = {"", "_E.szs", "_G.szs", "_F.szs", "_S.szs", "_I.szs", "_N.szs"};
const char* const SZS = ".szs";
const char* const DIF_SZS = "_Dif.szs";
// We have to force an alignment or else the other strings will start four bytes
// early
extern const int _8088FE0C;
const int _8088FE0C = 0;
const char* const SZS = ".szs\0";

extern const int _tmp;
const int _tmp = 0;

namespace System {
MultiDvdArchive* createMultiDvdArchive(SLoaderKind kind) {
MultiDvdArchive* archive = nullptr;

switch(kind) {
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
archive = new MultiDvdArchive(1);
break;
case RACE_COMMON:
archive = new RaceArchive;
break;
case 1:
archive = new CourseArchive;
break;
case 2:
archive = new Unk2Archive;
break;
}

return archive;
}

CourseArchive::CourseArchive() : MultiDvdArchive(4) {
init();
}

void CourseArchive::init() {
MultiDvdArchive::init();

if (this->archiveCount > 1) {
this->kinds[1] = 0;
strncpy(this->suffixes[1], DIF_SZS, 0x80);
}
if (this->archiveCount > 2) {
this->kinds[2] = 4;
}
if (this->archiveCount > 3) {
this->kinds[3] = 4;
}
}

void Unk2Archive::init() {
MultiDvdArchive::init();
const char* localization = LOCALIZED_SZS[SystemManager::sInstance->mLanguage];

if (this->archiveCount > 1) {
this->kinds[1] = 0;
strncpy(this->suffixes[1],localization,0x80);
}
}

void RaceArchive::init() {
MultiDvdArchive::init();
const char* localization = LOCALIZED_SZS[SystemManager::sInstance->mLanguage];

if (this->archiveCount > 1) {
this->kinds[1] = 0;
strncpy(this->suffixes[1],localization,0x80);
}
}

MultiDvdArchive::MultiDvdArchive(u16 archiveCount) {
this->archives = nullptr;
Expand Down
39 changes: 8 additions & 31 deletions source/game/system/MultiDvdArchive.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
#pragma once

#include "DvdArchive.hpp"
#include <game/host_system/SystemManager.hpp>

#include <rk_types.h>
#include <decomp.h>
#include <rvl/dvd/dvd.h>

// TODO: Move somewhere more appropriate
typedef enum {
RACE_COMMON = 0,
SCENE_UI_FONT = 3,
SCENE_MODEL_EARTH = 4,
SCENE_MODEL_MII_BODY = 5,
SCENE_MODEL_DRIVER = 6,
DEMO = 7,
SCENE_MODEL_BACKMODEL = 8
RACE_COMMON = 0,
SCENE_UI_FONT = 3,
SCENE_MODEL_EARTH = 4,
SCENE_MODEL_MII_BODY = 5,
SCENE_MODEL_DRIVER = 6,
DEMO = 7,
SCENE_MODEL_BACKMODEL = 8
} SLoaderKind;

namespace System {

class MultiDvdArchive;

class MultiDvdArchive {
public:
MultiDvdArchive(u16 archiveCount);
Expand Down Expand Up @@ -49,26 +48,4 @@ class MultiDvdArchive {
u32* kinds;
};

class RaceArchive : public MultiDvdArchive {
public:
// not actually inline, just optimized inline here
RaceArchive() : MultiDvdArchive(2) { init(); }
void init();
};

class Unk2Archive : public MultiDvdArchive {
public:
// not actually inline, just optimized inline here
Unk2Archive() : MultiDvdArchive(2) { init(); }
void init();
};

class CourseArchive : public MultiDvdArchive {
public:
CourseArchive();
void init();
};

MultiDvdArchive* createMultiDvdArchive(SLoaderKind kind);

} // namespace System
1 change: 1 addition & 0 deletions sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ class Source:
Source(src="source/game/jmap/CourseMap.cpp", cc='4201_127', opts=REL_OPTS),
Source(src="source/game/system/DvdArchive.cpp", cc='4201_127', opts=REL_OPTS),
Source(src="source/game/system/GhostFile.cpp", cc='4201_127', opts=REL_OPTS),
Source(src="source/game/system/LocalizedArchive.cpp", cc='4201_127', opts=REL_OPTS),
Source(src="source/game/system/MultiDvdArchive.cpp", cc='4201_127', opts=REL_OPTS),
Source(src="source/game/util/Random.cpp", cc='4201_127', opts=REL_OPTS),
Source(src="source/game/kart/KartComponent.cpp", cc='4201_127', opts=REL_OPTS),
Expand Down

0 comments on commit 2c33065

Please sign in to comment.