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
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ LONG_NAME := ModMoon: Mods Manager for 3DS
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft

CFLAGS := -g -Wall -Og -mword-relocations \
CFLAGS := -g -Wall -Wno-psabi -Og -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)

CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CFLAGS += $(INCLUDE) -D__3DS__

CXXFLAGS := $(CFLAGS) -fno-exceptions -std=gnu++11

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -z execstack

LIBS := -lz -lcitro3dd -lctrud -lm

Expand Down Expand Up @@ -215,9 +215,9 @@ run: all
citra $(TARGET).3dsx

cia: all
@./bannertool makebanner -i "$(BANNER_IMAGE)" -a "$(BANNER_AUDIO)" -o $(BUILD)/banner.bnr
@./bannertool makesmdh -l "$(LONG_NAME)" -s "$(APP_TITLE)" -p "$(APP_AUTHOR)" -i "$(ICON)" -f "$(ICON_FLAGS)" -o $(BUILD)/icon.icn
@./makerom -f cia -o $(OUTPUT).cia -target t -exefslogo -elf "$(OUTPUT).elf" -rsf "$(RSF_PATH)" -ver "$$(($(VERSION_MAJOR)*1024+$(VERSION_MINOR)*16+$(VERSION_MICRO)))" -banner "$(BUILD)/banner.bnr" -icon "$(BUILD)/icon.icn" -logo "CIA/logo.bcma.lz" -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)" -DAPP_ROMFS="$(ROMFS_DIR)"
@bannertool makebanner -i "$(BANNER_IMAGE)" -a "$(BANNER_AUDIO)" -o $(BUILD)/banner.bnr
@bannertool makesmdh -l "$(LONG_NAME)" -s "$(APP_TITLE)" -p "$(APP_AUTHOR)" -i "$(ICON)" -f "$(ICON_FLAGS)" -o $(BUILD)/icon.icn
@makerom -f cia -o $(OUTPUT).cia -target t -exefslogo -elf "$(OUTPUT).elf" -rsf "$(RSF_PATH)" -ver "$$(($(VERSION_MAJOR)*1024+$(VERSION_MINOR)*16+$(VERSION_MICRO)))" -banner "$(BUILD)/banner.bnr" -icon "$(BUILD)/icon.icn" -logo "CIA/logo.bcma.lz" -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)" -DAPP_ROMFS="$(ROMFS_DIR)"


#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -290,4 +290,4 @@ endef

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ For future civilizations reading this code through the Artic Code Vault, an alte


# Building
You'll need the latest ctrulib, citro3d and zlib to build ModMoon. Just type "make" at the command line.
You'll need the latest ctrulib, citro3d and zlib to build ModMoon. Just type `make` at the command line.
For building a CIA, you'll additionally need [bannertool](https://github.com/epicpkmn11/bannertool) and [makerom](https://github.com/3DSGuy/Project_CTR). To build, just type `make cia` at the command line.

# I was led to this page by ModMoon with some weird error about a cartridge...?
Ack... This is a fun one. I wrote a special error message at [modpackdownload.cpp](https://github.com/Swiftloke/ModMoon/blob/master/source/modpackdownload.cpp#L141) in the unlikely circumstance that A. A user had just finished downloading a modpack, very slowly, through the 3DS' slow wifi card, and B. the modpack had no modpackinfo.txt, therefore requiring the user to report to ModMoon what game the modpack went to. ModMoon implements this by opening the Active Title Select menu in a special mode that returns the first title selected to the caller (the modpack downloader.) However, if the intended destination for the modpack is on a cartridge, and that cartridge is not currently inserted, the user will be unable to select a destination without restarting the software to allow MM to recognize the new cartridge.

I wrote that error message directing the user here to apologize to them. Sorry that you lost your downloaded modpack... I'm sure it was big and very time-consuming to download :( As it turns out, ModMoon DOES have support for on-the-fly removal and insertion of cartridges. I put in two weeks to support one of ModMoon's hardest to implement features ever. It allows the OS to alert MM to insertion and removal of cartridges, and MM handles the result. [Here is the relevant commit that adds support.](https://github.com/Swiftloke/ModMoon/commit/cb56019642ed05d363b0c897304b4c599d77191b) It took a solid two weeks of hard work and screaming at random segfaults to get it right. In the end, however, before release, [I was forced to disable the feature](https://github.com/Swiftloke/ModMoon/commit/fe620a7175b639775b887d17a4537884468ce809) due to a [very strange bug regarding shutdown time that I never actually figured out.](https://github.com/smealum/ctrulib/issues/410)

You can see the flexible cartridge system, as I dubbed it, for yourself by enabling the [EnableFlexibleCartridgeSystem](https://github.com/Swiftloke/ModMoon/blob/master/source/config.cpp#L109) config in ModMoon's config file. Again, sorry for your loss of time. I hope this detailed explanation at least helped soften the blow.
This was an error in previous versions of ModMoon, however, it has been fixed as of the latest version. If you're on the latest version already, either delete the config file at `/3ds/ModMoon/settings.txt` or, if you'd prefer to keep your existing settings, enable the [EnableFlexibleCartridgeSystem](https://github.com/Swiftloke/ModMoon/blob/master/source/config.cpp#L109) config in ModMoon's config file.
6 changes: 3 additions & 3 deletions source/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ MainMenuHighlightColors{255, 0, 0}
ErrorHighlightColors{255, 0, 0}
TitleSelectHighlightColors{255, 0, 0}
ToolsMenuHighlightColors{133, 46, 165}
EnableFlexibleCartridgeSystem{False}
EnableFlexibleCartridgeSystem{True}
SaltySDHitboxEnabled{False}
;This file saves config info for ModMoon.
;If you change things in this file and ModMoon breaks, just delete it.
Expand Down Expand Up @@ -147,11 +147,11 @@ Config::Config(string path, string filename)

string Config::read(string configsetting)
{
int pos = configfile.find(configsetting, 0);
unsigned int pos = configfile.find(configsetting, 0);
if(pos == string::npos)
return "";
pos += configsetting.size() + 1; //Now pos is after the '{' of the config setting
int posb = configfile.find('}', pos);
unsigned int posb = configfile.find('}', pos);
return configfile.substr(pos, posb-pos);
}

Expand Down
38 changes: 23 additions & 15 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ string slotname = "";

float minusy = 0;

void cleanup(u32 NotificationID);

string getversion()
{
//After each digit, insert a period.
Expand Down Expand Up @@ -226,9 +228,10 @@ int startup()
initializeallSMDHdata(titleids);
//Do this in the main thread, because it may throw error calls
updatecartridgedata();
if (config.read("EnableFlexibleCartridgeSystem", false))
if (config.read("EnableFlexibleCartridgeSystem", true))
{
srv::init();
srv::hook(0x100, cleanup); // Notif 0x100: Terminate
srv::hook(0x208, cartridgesrvhook); //Notif 0x208: Game cartridge inserted
srv::hook(0x20A, cartridgesrvhook); //Notif 0x20A: Game cartridge removed
}
Expand Down Expand Up @@ -541,6 +544,24 @@ void mainmenudraw(unsigned int dpadpos, touchPosition tpos, unsigned int alphapo
//sdraw::drawtext(to_string(sdraw::MM::shader_twocoords->getArrayPos()).c_str(), 0, 50, 1, 1);
}

void cleanup(u32 NotificationID){
updatecheckworker.shutdown();
SMDHworker.shutdown();

//svcWaitSynchronization(event_fadefinished, U64_MAX);
//C3D_TexDelete(spritesheet);
//C3D_TexDelete(progressfiller);
//freeSMDHdata();
sdraw::cleanup();
sdraw::MM::destroymodmoonshaders();
srv::exit();
romfsExit();
gfxExit();
cfguExit();
amExit();
exit(0);
}


int main(int argc, char **argv) {

Expand Down Expand Up @@ -798,19 +819,6 @@ int main(int argc, char **argv) {
config.write("SelectedTitleIDPos", currenttidpos);
config.flush();

updatecheckworker.shutdown();
SMDHworker.shutdown();

//svcWaitSynchronization(event_fadefinished, U64_MAX);
//C3D_TexDelete(spritesheet);
//C3D_TexDelete(progressfiller);
//freeSMDHdata();
sdraw::cleanup();
sdraw::MM::destroymodmoonshaders();
srv::exit();
romfsExit();
gfxExit();
cfguExit();
amExit();
cleanup(0);
return 0;
}
2 changes: 1 addition & 1 deletion source/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void threadfunc_fade(void* main)
int* rgbvalues = (int*)main; //We expect an array of 3 ints for the RGB values
//C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_ONE_MINUS_CONSTANT_ALPHA, GPU_CONSTANT_COLOR, GPU_ONE_MINUS_CONSTANT_ALPHA, GPU_CONSTANT_ALPHA);
//I tried to use blending operations but the equation I used didn't like an alpha value of < 1 for a texture, and overwrote it entirely with the color. It looked gross.
C3D_Tex fbtop, fbbot;
//C3D_Tex fbtop, fbbot;
//linearAlloc isn't thread-safe in current libctru (as of 9/24/18, check again if you're in the future).
//As such, the framebuffer code can't be present here. It still looks fine, actually, because sDraw doesn't
//clear the color buffer at the start of a frame.
Expand Down