Skip to content
Open
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 .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Diagnostics:
Suppress:
- unused-includes
InlayHints:
Designators: false
Designators: false
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ else
else
ifeq ($(shell uname -s),macOS)
ifeq ($(AZAHAR),1)
# TODO: triple check with a mac user
CITRA_DIR := ~/Library/Application Support/Azahar/sdmc
else
CITRA_DIR := ~/Library/Application Support/Citra/sdmc
Expand Down
13 changes: 13 additions & 0 deletions include/CTRPF.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef CTRPF_WRAPPER_H
#define CTRPF_WRAPPER_H

#include <CTRPluginFramework.hpp>

namespace CTRPF = CTRPluginFramework;

using CTRPF::Process;
using CTRPF::OSD;

constexpr auto Format = CTRPF::Utils::Format;

#endif
12 changes: 6 additions & 6 deletions include/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
#define CONFIG_H

#include <3ds.h>
#include <CTRPluginFramework.hpp>
#include "CTRPF.hpp"

#include <string>
#include <map>

struct Config {
typedef std::map<u16, std::string> map;
typedef std::map<u16, std::string> TickflowMap;

map tickflows;
TickflowMap tickflows;

Config();
Config(map map);
static Config* FromFile(std::string fname);
Config(Config::TickflowMap map);
static Config FromFile(std::string fname);
};

extern Config* config;
extern Config config;
extern int configResult;

#endif
File renamed without changes.
1 change: 0 additions & 1 deletion include/Megamix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define MEGAMIX_MODS_PATH "/spicerack/mods/"
#define MEGAMIX_CONFIG_PATH MEGAMIX_BIN_PATH "saltwater.cfg"

#include "Saltwater.hpp"
#include "Megamix/Region.hpp"
#include "Megamix/Hooks.hpp"
#include "Megamix/Patches.hpp"
Expand Down
5 changes: 3 additions & 2 deletions include/Megamix/BTKS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <map>
#include <string>

#include "Megamix/Types.hpp"

namespace Megamix {
Expand All @@ -19,8 +20,8 @@ namespace Megamix {
char* tickflow = nullptr;
char* strings = nullptr;
std::map<u32, TempoTable*> tempos = std::map<u32, TempoTable*>();
u32 tickflowSize;
u32 stringSize;
u32 tickflowSize = 0;
u32 stringSize = 0;

int LoadFile(std::string filename);
void Unload();
Expand Down
10 changes: 1 addition & 9 deletions include/Megamix/Commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ namespace Megamix{
DisplayCondvar = 0x300
};

void tickflowCommandsHookWrapper();

extern "C" int tickflowCommandsHook(CTickflow* self, u32 cmd_num, u32 arg0, u32* args);

void input_cmd(CTickflow* self, u32 arg0, u32* args);
void versionCheck(CTickflow* self, u32 arg0, u32* args);
void languageCheck(CTickflow* self, u32 arg0, u32* args);
void displayCondvar(CTickflow* self, u32 arg0, u32* args);
void msbtWithNum(CTickflow* self, u32 arg0, u32* args);
void tickflowCommands();
}

#endif
9 changes: 2 additions & 7 deletions include/Megamix/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
#define MEGAMIX_ERROR_HPP

#include <string>
#include <CTRPluginFramework.hpp>

#define CALL_STACK_SIZE 5

using CTRPluginFramework::Process;

struct Void{};
#include "CTRPF.hpp"

namespace Megamix {
std::string ErrorMessage(int code);
Expand Down Expand Up @@ -53,6 +47,7 @@ namespace Megamix {
u32 statusRegisterA; // IFSR, DFSR, FPEXC
u32 statusRegisterB; // FAR, FPINST

static constexpr int CALL_STACK_SIZE = 5;
u32 callStack[CALL_STACK_SIZE];
};

Expand Down
23 changes: 16 additions & 7 deletions include/Megamix/Hooks.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#ifndef MEGAMIX_HOOKS_H
#define MEGAMIX_HOOKS_H

#include "types.h"
#include <3ds/types.h>

namespace Megamix::Hooks {
void TickflowHooks();
void TempoHooks();
void RegionHooks();
void CommandHook();
void DisableAllHooks();
void initTickflowHooks();
void initTempoHooks();
void initRegionHooks();
void initCommandHooks();

void disableTickflowHooks();
void disableTempoHooks();
void disableRegionHooks();
void disableCommandHooks();
inline void disableAllHooks() {
disableTickflowHooks();
disableTempoHooks();
disableRegionHooks();
disableCommandHooks();
}

template<typename T> T StubbedFunction();
template<typename T> void StubFunction(u32 address);
}

Expand Down
29 changes: 23 additions & 6 deletions include/Megamix/Region.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
#include <vector>
#include <string>

#include "types.h"

#include <CTRPluginFramework.hpp>
#include <3ds/types.h>

#include "Megamix/Error.hpp"
#include "Megamix/Types.hpp"

extern u8 region;

namespace Megamix {
struct GameInterface {
u32 gameCode;
Expand Down Expand Up @@ -101,7 +97,7 @@ namespace Megamix {

// TODO: if we ever add extra game revisions, add check for those

std::expected<Void, u32> initGameInterface(u32 gameCode);
std::expected<void, u32> initGameInterface(u32 gameCode);
inline bool isJP() {
return pointers->gameCode == 0x155a00;
}
Expand All @@ -117,6 +113,27 @@ namespace Megamix {


namespace Game {
enum class GameVariant: u8 {
JPRev0,
USRev0,
EURev0,
KRRev0,
UNK = (u8)-1,
};

inline GameVariant getRegion() {
if (isJP())
return GameVariant::JPRev0;
else if (isUS())
return GameVariant::USRev0;
else if (isEU())
return GameVariant::EURev0;
else if (isKR())
return GameVariant::KRRev0;
else
return GameVariant::UNK;
}

inline u32 _textEnd () { return pointers->textEnd; }
inline u32 _rodataEnd() { return pointers->rodataEnd; }
inline u32 _dataEnd() { return pointers->dataEnd; }
Expand Down
53 changes: 28 additions & 25 deletions include/Megamix/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

#include <array>

#include "types.h"
#include <3ds/types.h>
#include "CTRPF.hpp"

// TODO: split this file - potentially move into Game?

namespace Megamix {
struct GameDef {
Expand Down Expand Up @@ -46,7 +49,7 @@ namespace Megamix {
struct TempoTable {
u32 id1;
u32 id2;
u8 unk8;
u8 isStreamed;
u16 unkA;
Tempo* pos;
};
Expand Down Expand Up @@ -139,7 +142,7 @@ namespace Megamix {
RvlManjuL = 0x37,
RvlMuscleL = 0x38,
RvlRapL = 0x39,
RvlRecieveL = 0x3a,
RvlReceiveL = 0x3a,
RvlRobotL = 0x3b,
RvlRocketL = 0x3c,
RvlRotationL = 0x3d,
Expand Down Expand Up @@ -216,12 +219,12 @@ namespace Megamix {
u32 lowIndex;

MuseumRow(std::array<u16, 5> gameIndices, const char* titleId, u32 highIndex, u32 lowIndex) {
if (gameIndices[0] == 0x101) this->columnCount = 0;
else if (gameIndices[1] == 0x101) this->columnCount = 1;
else if (gameIndices[2] == 0x101) this->columnCount = 2;
else if (gameIndices[3] == 0x101) this->columnCount = 3;
else if (gameIndices[4] == 0x101) this->columnCount = 4;
else this->columnCount = 5;
if (gameIndices[0] == 0x101) columnCount = 0;
else if (gameIndices[1] == 0x101) columnCount = 1;
else if (gameIndices[2] == 0x101) columnCount = 2; // broken in vanilla
else if (gameIndices[3] == 0x101) columnCount = 3;
else if (gameIndices[4] == 0x101) columnCount = 4;
else columnCount = 5;

this->gameIndices = gameIndices;
this->titleId = titleId;
Expand All @@ -237,24 +240,24 @@ namespace Megamix {
u8 a;

Color8() {
this->r = 0;
this->g = 0;
this->b = 0;
this->a = 0;
r = 0;
g = 0;
b = 0;
a = 0;
}

Color8(u8 r, u8 g, u8 b, u8 a) {
this->r = r;
this->g = g;
this->b = b;
this->a = a;
r = r;
g = g;
b = b;
a = a;
}

Color8(u32 color) {
this->r = color >> 24;
this->g = color >> 16;
this->b = color >> 8;
this->a = color;
r = color >> 24;
g = color >> 16;
b = color >> 8;
a = color;
}
};

Expand All @@ -265,8 +268,8 @@ namespace Megamix {
Color8 unk3;

MuseumRowColor(Color8 background, Color8 edgeFade) {
this->unk1 = {0x00, 0x00, 0x00, 0x00};
this->unk3 = {0xFF, 0xFF, 0xFF, 0x6E};
unk1 = {0x00, 0x00, 0x00, 0x00};
unk3 = {0xFF, 0xFF, 0xFF, 0x6E};

this->background = background;
this->edgeFade = edgeFade;
Expand Down Expand Up @@ -523,8 +526,8 @@ namespace Megamix {
u8 field12_0x2a;
u8 field13_0x2b;
u32 field14_0x2c;
u16 locale[9];
u16 sublocale[9];
char16_t locale[9];
char16_t sublocale[9];
};

struct FileInfo {
Expand Down
23 changes: 11 additions & 12 deletions include/Saltwater.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef SALTWATER_H
#define SALTWATER_H

#include "external/plgldr.h"
#include <3ds.h>
#include <assert.h>

// Saltwater version

Expand All @@ -19,7 +21,6 @@

#ifdef RELEASE


#define VERSION "v" STRC(VERSION_MAJOR) "." STRC(VERSION_MINOR) "." STRC(VERSION_PATCH)

#else
Expand All @@ -29,17 +30,15 @@

#endif

// Params struct
extern "C" {
struct SaltwaterParams {
u16 barista;
bool rhmpatch;
bool plgldr;
bool mod_loaded_msg;
bool extra_rows;
u32 null[30];
};
}
struct SaltwaterParams {
u16 barista;
bool rhmpatch;
bool plgldr;
bool mod_loaded_msg;
bool extra_rows;
u32 null[30];
};
static_assert(sizeof(SaltwaterParams) == sizeof(PluginLoadParameters::config));

extern SaltwaterParams params;

Expand Down
Loading