mirror of
https://github.com/astronautlevel2/Anemone3DS.git
synced 2026-01-24 08:42:43 -05:00
Compare commits
21 Commits
v1.0.0-alp
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 9afbe22df7 | |||
| 448a9ceb8a | |||
|
|
25aa02008e | ||
| 49e6c6f827 | |||
| 365ae87477 | |||
| f461b3b5b5 | |||
|
|
6ea3904682 | ||
| aac093f466 | |||
| 9442afb608 | |||
|
|
91f54ff22e | ||
|
|
aa593c61a6 | ||
|
|
2a8e3176a8 | ||
|
|
c84f40cf57 | ||
|
|
45cbf0761b | ||
| 8c7c409bca | |||
| d9ddd68d2e | |||
| d93f4f9207 | |||
| 867f4b61ab | |||
| 72153ba15d | |||
| c4a096249c | |||
|
|
91ba5fed49 |
13
Makefile
13
Makefile
@@ -167,9 +167,9 @@ MAKEROM ?= makerom
|
||||
|
||||
MAKEROM_ARGS := -elf "$(OUTPUT).elf" -rsf "$(RSF_PATH)" -banner "$(BUILD)/banner.bnr" -icon "$(BUILD)/icon.icn" -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(PRODUCT_CODE)" -DAPP_UNIQUE_ID="$(UNIQUE_ID)"
|
||||
|
||||
ifneq ($(strip $(ROMFS)),)
|
||||
MAKEROM_ARGS += -romfs "$(BUILD)/romfs.bin"
|
||||
endif
|
||||
#ifneq ($(strip $(ROMFS)),)
|
||||
# MAKEROM_ARGS += -romfs "$(BUILD)/romfs.bin"
|
||||
#endif
|
||||
ifneq ($(strip $(LOGO)),)
|
||||
MAKEROM_ARGS += -logo "$(LOGO)"
|
||||
endif
|
||||
@@ -178,7 +178,7 @@ ifeq ($(strip $(ROMFS)),)
|
||||
$(OUTPUT).cia: $(OUTPUT).elf $(BUILD)/banner.bnr $(BUILD)/icon.icn
|
||||
$(MAKEROM) -f cia -o "$@" -target t -exefslogo $(MAKEROM_ARGS)
|
||||
else
|
||||
$(OUTPUT).cia: $(OUTPUT).elf $(BUILD)/romfs.bin $(BUILD)/banner.bnr $(BUILD)/icon.icn
|
||||
$(OUTPUT).cia: $(OUTPUT).elf $(BUILD)/banner.bnr $(BUILD)/icon.icn
|
||||
$(MAKEROM) -f cia -o "$@" -target t -exefslogo $(MAKEROM_ARGS)
|
||||
endif
|
||||
|
||||
@@ -204,11 +204,6 @@ $(BUILD)/icon.icn : $(APP_ICON)
|
||||
$(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i "$(APP_ICON)" -f "$(ICON_FLAGS)" -o "$@"
|
||||
|
||||
|
||||
3DSTOOL ?= 3dstool
|
||||
|
||||
$(BUILD)/romfs.bin : $(ROMFS)
|
||||
$(3DSTOOL) -ctf romfs "$@" --romfs-dir "$(ROMFS)"
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
|
||||
33
README.md
33
README.md
@@ -1,27 +1,30 @@
|
||||
# Anemone3DS
|
||||
A Theme Manager for the Nintendo3DS, written in C
|
||||

|
||||
|
||||
A Theme and Splashscreen Manager for the Nintendo3DS, written in C
|
||||
|
||||
# Dependencies
|
||||
This depends on zlib. Get it from portlibs.
|
||||
* zlib, which can be retrieved from the [3ds_portlibs](https://github.com/devkitPro/3ds_portlibs)
|
||||
* [makerom](https://github.com/profi200/Project_CTR) and [bannertool](https://github.com/Steveice10/buildtools), which can be retrieved from [SteveIce10's](https://github.com/Steveice10) buildtools repo. These must be added to your PATH.
|
||||
* [pp2d](https://github.com/BernardoGiordano/pp2d), which is included in the repo if you do a git clone --recursive.
|
||||
|
||||
# License
|
||||
This project is licensed under the GNU GPLv3. See LICENSE.md for details. Additional terms 7b and 7c apply to this project.
|
||||
|
||||
# Credits
|
||||
|
||||
The following people contributed to Anemone3DS in some way. Without these people, Anemone3DS wouldn't exist, or wouldn't be as good as it is:
|
||||
* Daedreth, who wrote the initial implementation of theme application code and SMDH parsing
|
||||
* LiquidFenrir, who refactored a lot of my messy GUI code and wrote the image preview from zip code, as well as the icon code
|
||||
* Sono, who wrote the BCSTM playback code
|
||||
* Kenn (mattkenster) for designing the GUI, a number of sprites used in the application, and drawing the banner and icon.
|
||||
* [Daedreth](https://github.com/daedreth), who wrote the initial implementation of theme application code and SMDH parsing.
|
||||
* [LiquidFenrir](https://github.com/LiquidFenrir), who refactored a lot of my messy GUI code and wrote the image preview from zip code, as well as the icon code.
|
||||
* [Sono](https://github.com/MarcuzD), who wrote the BCSTM playback code.
|
||||
* [Kenn (mattkenster)](https://github.com/mattkenster), for designing the GUI, a number of sprites used in the application, and drawing the banner and icon.
|
||||
|
||||
Special thanks go to these people who, while not directly contributing, helped immensely:
|
||||
* Rinnegatamante, whose code served as reference on theme installation.
|
||||
* BernardoGiordano for making pp2d, and being super responsive to feature requests and just general help
|
||||
* yellows8 for his home menu extdump tool, which was invaluable in debugging.
|
||||
* the folks on #dev of Nintendo Homebrew, who helped with unicode shenanigans (especially Stary2001, Fenrir, and DanielKO).
|
||||
* [Rinnegatamante](https://github.com/Rinnegatamante), whose code served as reference on theme installation.
|
||||
* [BernardoGiordano](https://github.com/BernardoGiordano) for making pp2d, and being super responsive to feature requests and just general help
|
||||
* [yellows8](https://github.com/yellows8) for his home menu extdump tool, which was invaluable in debugging.
|
||||
* the folks on #dev of Nintendo Homebrew, who helped with unicode shenanigans (especially [Stary2001](https://github.com/Stary2001), [Fenrir](https://github.com/FenrirWolf), and DanielKO).
|
||||
* the maintainers for all used libraries, including ctrulib, zlib, citro3d, pp2d and minizip.
|
||||
* all the people who helped keep me going and motivated me to work. This includes, but is definitely not limited to:
|
||||
* The members of the Nintendo Homebrew Discord
|
||||
* The members of the Secret Shack Service Discord
|
||||
* The members of the ThemePlaza Discord
|
||||
|
||||
+ The members of the [Nintendo Homebrew Discord](https://discord.gg/C29hYvh)
|
||||
+ The members of the __Secret Shack Service Discord__
|
||||
+ The members of the [ThemePlaza Discord](https://discord.gg/2hUQwXz)
|
||||
|
||||
@@ -36,12 +36,23 @@
|
||||
#define THEMES_PATH "/Themes/"
|
||||
#define SPLASHES_PATH "/Splashes/"
|
||||
|
||||
#define SINGLE_INSTALL 0
|
||||
#define SHUFFLE_INSTALL 1
|
||||
#define BGM_INSTALL 2
|
||||
#define UNINSTALL 3
|
||||
|
||||
static const int THEMES_PER_SCREEN = 4;
|
||||
|
||||
enum TextureID {
|
||||
TEXTURE_FONT_RESERVED = 0, //used by pp2d for the font
|
||||
TEXTURE_ARROW,
|
||||
TEXTURE_SHUFFLE,
|
||||
TEXTURE_BATTERY_1,
|
||||
TEXTURE_BATTERY_2,
|
||||
TEXTURE_BATTERY_3,
|
||||
TEXTURE_BATTERY_4,
|
||||
TEXTURE_BATTERY_5,
|
||||
TEXTURE_BATTERY_CHARGE,
|
||||
TEXTURE_PREVIEW,
|
||||
};
|
||||
|
||||
|
||||
@@ -33,8 +33,9 @@
|
||||
void init_screens(void);
|
||||
void exit_screens(void);
|
||||
|
||||
void draw_theme_install(bool shuffle_install);
|
||||
void draw_theme_install(int install_type);
|
||||
void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_theme, bool preview_mode);
|
||||
void draw_splash_install(int install_type);
|
||||
void draw_splash_interface(Splash_s *splashes_list, int splash_count, int selected_splash, bool preview_mode);
|
||||
|
||||
#endif
|
||||
@@ -37,5 +37,5 @@ typedef struct{
|
||||
|
||||
Result get_splashes(Splash_s** splashes_list, int *splash_count);
|
||||
void splash_install(Splash_s splash_to_install);
|
||||
|
||||
void splash_delete();
|
||||
#endif
|
||||
@@ -38,6 +38,7 @@ typedef struct {
|
||||
ssize_t icon_id;
|
||||
|
||||
bool has_preview;
|
||||
int preview_offset;
|
||||
|
||||
u16 path[0x106];
|
||||
bool is_zip;
|
||||
@@ -49,5 +50,6 @@ void load_theme_preview(Theme_s *theme);
|
||||
Result get_themes(Theme_s **themes_list, int *theme_count);
|
||||
Result single_install(Theme_s theme);
|
||||
Result shuffle_install(Theme_s *themes_list, int theme_count);
|
||||
Result bgm_install(Theme_s bgm_to_install);
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,7 @@ BasicInfo:
|
||||
CompanyCode : "00"
|
||||
ProductCode : "CTR-P-ANEM"
|
||||
ContentType : Application
|
||||
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
|
||||
Logo : Homebrew # Nintendo / Licensed / Distributed / iQue / iQueForSystem
|
||||
|
||||
TitleInfo:
|
||||
UniqueId : 0xAFEN
|
||||
@@ -33,6 +33,9 @@ SystemControlInfo:
|
||||
RemasterVersion: 7
|
||||
StackSize: 0x40000
|
||||
|
||||
RomFs:
|
||||
RootPath : romfs
|
||||
|
||||
# DO NOT EDIT BELOW HERE OR PROGRAMS WILL NOT LAUNCH (most likely)
|
||||
|
||||
AccessControlInfo:
|
||||
|
||||
BIN
romfs/battery1.png
Normal file
BIN
romfs/battery1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 610 B |
BIN
romfs/battery2.png
Normal file
BIN
romfs/battery2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
BIN
romfs/battery3.png
Normal file
BIN
romfs/battery3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 285 B |
BIN
romfs/battery4.png
Normal file
BIN
romfs/battery4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 280 B |
BIN
romfs/battery5.png
Normal file
BIN
romfs/battery5.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 251 B |
BIN
romfs/charging.png
Normal file
BIN
romfs/charging.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 800 B |
@@ -47,6 +47,12 @@ void init_screens(void)
|
||||
|
||||
pp2d_load_texture_png(TEXTURE_ARROW, "romfs:/arrow.png");
|
||||
pp2d_load_texture_png(TEXTURE_SHUFFLE, "romfs:/shuffle.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_1, "romfs:/battery1.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_2, "romfs:/battery2.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_3, "romfs:/battery3.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_4, "romfs:/battery4.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_5, "romfs:/battery5.png");
|
||||
pp2d_load_texture_png(TEXTURE_BATTERY_CHARGE, "romfs:/charging.png");
|
||||
}
|
||||
|
||||
void exit_screens(void)
|
||||
@@ -54,21 +60,6 @@ void exit_screens(void)
|
||||
pp2d_exit();
|
||||
}
|
||||
|
||||
static Result MCUHWC_GetBatteryLevel(u8 *out) // Code taken from daedreth's fork of lpp-3ds
|
||||
{
|
||||
#define TRY(expr) if(R_FAILED(res = (expr))) { svcCloseHandle(mcuhwcHandle); return res; }
|
||||
Result res;
|
||||
Handle mcuhwcHandle;
|
||||
TRY(srvGetServiceHandle(&mcuhwcHandle, "mcu::HWC"));
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
cmdbuf[0] = 0x50000;
|
||||
TRY(svcSendSyncRequest(mcuhwcHandle));
|
||||
*out = (u8) cmdbuf[2];
|
||||
svcCloseHandle(mcuhwcHandle);
|
||||
return cmdbuf[1];
|
||||
#undef TRY
|
||||
}
|
||||
|
||||
static int theme_vertical_scroll = 0;
|
||||
static int splash_vertical_scroll = 0;
|
||||
|
||||
@@ -84,9 +75,14 @@ void draw_base_interface(void)
|
||||
pp2d_draw_text(28, 2, 0.6, 0.6, COLOR_WHITE, (tm.tm_sec % 2 == 1) ? ":" : " ");
|
||||
pp2d_draw_textf(34, 2, 0.6, 0.6, COLOR_WHITE, "%.2i", tm.tm_min);
|
||||
|
||||
u8 battery_val = 0;
|
||||
MCUHWC_GetBatteryLevel(&battery_val);
|
||||
pp2d_draw_textf(350, 2, 0.6, 0.6, COLOR_WHITE, "%i%%", battery_val);
|
||||
u8 battery_charging;
|
||||
PTMU_GetBatteryChargeState(&battery_charging);
|
||||
u8 battery_status;
|
||||
PTMU_GetBatteryLevel(&battery_status);
|
||||
pp2d_draw_texture(2 + battery_status, 357, 2);
|
||||
|
||||
if (battery_charging)
|
||||
pp2d_draw_texture(TEXTURE_BATTERY_CHARGE, 357, 2);
|
||||
|
||||
pp2d_draw_on(GFX_BOTTOM);
|
||||
pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT);
|
||||
@@ -94,10 +90,23 @@ void draw_base_interface(void)
|
||||
pp2d_draw_on(GFX_TOP);
|
||||
}
|
||||
|
||||
void draw_theme_install(bool shuffle_install)
|
||||
void draw_theme_install(int install_type)
|
||||
{
|
||||
draw_base_interface();
|
||||
pp2d_draw_textf(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a %s theme...", !shuffle_install ? "single" : "shuffle");
|
||||
switch(install_type)
|
||||
{
|
||||
case 0:
|
||||
pp2d_draw_text(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a single theme...");
|
||||
break;
|
||||
case 1:
|
||||
pp2d_draw_text(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a shuffle theme...");
|
||||
break;
|
||||
case 2:
|
||||
pp2d_draw_text(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing BGM...");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pp2d_end_draw();
|
||||
}
|
||||
|
||||
@@ -107,7 +116,7 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
|
||||
if (themes_list == NULL)
|
||||
{
|
||||
pp2d_begin_draw(GFX_TOP);
|
||||
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "FAILURE");
|
||||
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "NO THEMES FOUND");
|
||||
pp2d_end_draw();
|
||||
return;
|
||||
}
|
||||
@@ -119,9 +128,9 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
|
||||
if (current_theme.has_preview)
|
||||
{
|
||||
pp2d_begin_draw(GFX_TOP);
|
||||
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 6, 0, 400, 240);
|
||||
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, current_theme.preview_offset, 0, 400, 240);
|
||||
pp2d_draw_on(GFX_BOTTOM);
|
||||
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 46, 240, 320, 240);
|
||||
pp2d_draw_texture_part(TEXTURE_PREVIEW, 0, 0, 40+current_theme.preview_offset, 240, 320, 240);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -139,9 +148,12 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
|
||||
utf16_to_utf32((u32*)description, current_theme.desc, 0x80);
|
||||
pp2d_draw_wtext(20, 65, 0.5, 0.5, COLOR_WHITE, description);
|
||||
|
||||
pp2d_draw_wtext_center(GFX_TOP, 150, 0.7, 0.7, COLOR_WHITE, L"\uE000 Install Theme \uE004 Switch to Splashes");
|
||||
pp2d_draw_wtext_center(GFX_TOP, 180, 0.7, 0.7, COLOR_WHITE, L"\uE001 Queue Shuffle \uE046 Install shuffle");
|
||||
pp2d_draw_wtext_center(GFX_TOP, 210, 0.7, 0.7, COLOR_WHITE, L"\uE003 Preview Theme");
|
||||
pp2d_draw_wtext(20, 150, 0.6, 0.6, COLOR_WHITE, L"\uE046 Install Shuffle Theme");
|
||||
pp2d_draw_wtext(200, 150, 0.6, 0.6, COLOR_WHITE, L"\uE004 Switch to Splashes");
|
||||
pp2d_draw_wtext(20, 180, 0.6, 0.6, COLOR_WHITE, L"\uE000 Install Theme");
|
||||
pp2d_draw_wtext(200, 180, 0.6, 0.6, COLOR_WHITE, L"\uE001 Queue Shuffle");
|
||||
pp2d_draw_wtext(20, 210, 0.6, 0.6, COLOR_WHITE, L"\uE002 Install BGM");
|
||||
pp2d_draw_wtext(200, 210, 0.6, 0.6, COLOR_WHITE, L"\uE003 Preview Theme");
|
||||
|
||||
pp2d_draw_on(GFX_BOTTOM);
|
||||
|
||||
@@ -197,12 +209,29 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
|
||||
pp2d_end_draw();
|
||||
}
|
||||
|
||||
void draw_splash_install(int install_type)
|
||||
{
|
||||
draw_base_interface();
|
||||
switch (install_type)
|
||||
{
|
||||
case SINGLE_INSTALL:
|
||||
pp2d_draw_textf(20, 30, 0.7, 0.7, COLOR_WHITE, "Installing a splash...");
|
||||
break;
|
||||
case UNINSTALL:
|
||||
pp2d_draw_textf(20, 30, 0.7, 0.7, COLOR_WHITE, "Uninstalling a splash...");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pp2d_end_draw();
|
||||
}
|
||||
|
||||
void draw_splash_interface(Splash_s *splashes_list, int splash_count, int selected_splash, bool preview_mode)
|
||||
{
|
||||
if (splashes_list == NULL)
|
||||
{
|
||||
pp2d_begin_draw(GFX_TOP);
|
||||
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "FAILURE");
|
||||
pp2d_draw_text_center(GFX_TOP, 100, 1, 1, COLOR_WHITE, "NO SPLASHES FOUND");
|
||||
pp2d_end_draw();
|
||||
return;
|
||||
}
|
||||
@@ -216,8 +245,8 @@ void draw_splash_interface(Splash_s *splashes_list, int splash_count, int select
|
||||
draw_base_interface();
|
||||
pp2d_draw_text_center(GFX_TOP, 4, 0.5, 0.5, COLOR_WHITE, "Splash mode");
|
||||
|
||||
pp2d_draw_wtext_center(GFX_TOP, 210, 0.7, 0.7, COLOR_WHITE, L"\uE000 Install Splash \uE004 Switch to Themes");
|
||||
|
||||
pp2d_draw_wtext_center(GFX_TOP, 180, 0.7, 0.7, COLOR_WHITE, L"\uE000 Install Splash \uE004 Switch to Themes");
|
||||
pp2d_draw_wtext_center(GFX_TOP, 210, 0.7, 0.7, COLOR_WHITE, L"\uE002 Delete current Splash");
|
||||
pp2d_draw_on(GFX_BOTTOM);
|
||||
for (int i = 0; i < splash_count; i++) {
|
||||
if (splash_count <= THEMES_PER_SCREEN)
|
||||
|
||||
@@ -51,6 +51,10 @@ Result open_archives(void)
|
||||
CFGU_SecureInfoGetRegion(®ionCode);
|
||||
switch(regionCode)
|
||||
{
|
||||
case 0:
|
||||
archive1 = 0x000002cc;
|
||||
archive2 = 0x00000082;
|
||||
break;
|
||||
case 1:
|
||||
archive1 = 0x000002cd;
|
||||
archive2 = 0x0000008f;
|
||||
@@ -59,10 +63,6 @@ Result open_archives(void)
|
||||
archive1 = 0x000002ce;
|
||||
archive2 = 0x00000098;
|
||||
break;
|
||||
case 3:
|
||||
archive1 = 0x000002cc;
|
||||
archive2 = 0x00000082;
|
||||
break;
|
||||
default:
|
||||
archive1 = 0x00;
|
||||
archive2 = 0x00;
|
||||
|
||||
@@ -28,12 +28,13 @@
|
||||
#include "themes.h"
|
||||
#include "splashes.h"
|
||||
#include "draw.h"
|
||||
#include "common.h"
|
||||
|
||||
int init_services(void)
|
||||
{
|
||||
cfguInit();
|
||||
ptmuInit();
|
||||
open_archives();
|
||||
ptmSysmInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -41,6 +42,7 @@ int exit_services(void)
|
||||
{
|
||||
close_archives();
|
||||
cfguExit();
|
||||
ptmuExit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -49,7 +51,6 @@ int main(void)
|
||||
init_services();
|
||||
init_screens();
|
||||
|
||||
|
||||
int theme_count = 0;
|
||||
Theme_s * themes_list = NULL;
|
||||
Result res = get_themes(&themes_list, &theme_count);
|
||||
@@ -72,6 +73,7 @@ int main(void)
|
||||
bool splash_mode = false;
|
||||
int selected_splash = 0;
|
||||
int selected_theme = 0;
|
||||
int previously_selected = 0;
|
||||
int shuffle_theme_count = 0;
|
||||
bool preview_mode = false;
|
||||
|
||||
@@ -83,6 +85,15 @@ int main(void)
|
||||
if (!splash_mode) draw_theme_interface(themes_list, theme_count, selected_theme, preview_mode);
|
||||
else draw_splash_interface(splashes_list, splash_count, selected_splash, preview_mode);
|
||||
|
||||
if (kDown & KEY_START)
|
||||
{
|
||||
APT_HardwareResetAsync();
|
||||
}
|
||||
else if (kDown & KEY_L)
|
||||
{
|
||||
splash_mode = !splash_mode;
|
||||
}
|
||||
|
||||
if (themes_list == NULL && !splash_mode)
|
||||
continue;
|
||||
|
||||
@@ -96,11 +107,10 @@ int main(void)
|
||||
{
|
||||
if (!preview_mode)
|
||||
{
|
||||
load_theme_preview(current_theme);
|
||||
if (current_theme->has_preview)
|
||||
{
|
||||
preview_mode = true;
|
||||
}
|
||||
if (!current_theme->has_preview)
|
||||
load_theme_preview(current_theme);
|
||||
|
||||
preview_mode = current_theme->has_preview;
|
||||
}
|
||||
else
|
||||
preview_mode = false;
|
||||
@@ -111,21 +121,25 @@ int main(void)
|
||||
continue;
|
||||
|
||||
// Actions
|
||||
else if (kDown & KEY_L)
|
||||
{
|
||||
splash_mode = !splash_mode;
|
||||
}
|
||||
else if (kDown & KEY_X)
|
||||
{
|
||||
// install_bgm(current_theme);
|
||||
if (splash_mode) {
|
||||
draw_splash_install(UNINSTALL);
|
||||
splash_delete();
|
||||
} else {
|
||||
draw_theme_install(BGM_INSTALL);
|
||||
bgm_install(*current_theme);
|
||||
}
|
||||
}
|
||||
else if (kDown & KEY_A)
|
||||
{
|
||||
if (splash_mode)
|
||||
{
|
||||
draw_splash_install(SINGLE_INSTALL);
|
||||
splash_install(*current_splash);
|
||||
svcSleepThread(5e8);
|
||||
} else {
|
||||
draw_theme_install(false);
|
||||
draw_theme_install(SINGLE_INSTALL);
|
||||
single_install(*current_theme);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +172,7 @@ int main(void)
|
||||
} else {
|
||||
if (shuffle_theme_count > 0)
|
||||
{
|
||||
draw_theme_install(true);
|
||||
draw_theme_install(SHUFFLE_INSTALL);
|
||||
shuffle_install(themes_list, theme_count);
|
||||
}
|
||||
}
|
||||
@@ -171,11 +185,11 @@ int main(void)
|
||||
{
|
||||
selected_splash++;
|
||||
if (selected_splash >= splash_count)
|
||||
selected_splash = splash_count-1;
|
||||
selected_splash = 0;
|
||||
} else {
|
||||
selected_theme++;
|
||||
if (selected_theme >= theme_count)
|
||||
selected_theme = theme_count-1;
|
||||
selected_theme = 0;
|
||||
}
|
||||
}
|
||||
else if (kDown & KEY_UP)
|
||||
@@ -184,35 +198,41 @@ int main(void)
|
||||
{
|
||||
selected_splash--;
|
||||
if (selected_splash < 0)
|
||||
selected_splash = 0;
|
||||
selected_splash = splash_count - 1;
|
||||
} else {
|
||||
selected_theme--;
|
||||
if (selected_theme < 0)
|
||||
selected_theme = 0;
|
||||
selected_theme = theme_count - 1;
|
||||
}
|
||||
}
|
||||
// Quick moving
|
||||
else if (kDown & KEY_LEFT)
|
||||
{
|
||||
if (splash_mode) selected_splash = 0;
|
||||
else selected_theme = 0;
|
||||
if (splash_mode)
|
||||
{
|
||||
selected_splash -= 4;
|
||||
if (selected_splash < 0) selected_splash = 0;
|
||||
} else {
|
||||
selected_theme -= 4;
|
||||
if (selected_theme < 0) selected_theme = 0;
|
||||
}
|
||||
}
|
||||
else if (kDown & KEY_RIGHT)
|
||||
{
|
||||
if (splash_mode) selected_splash = splash_count - 1;
|
||||
else selected_theme = theme_count-1;
|
||||
if (splash_mode)
|
||||
{
|
||||
selected_splash += 4;
|
||||
if (selected_splash >= splash_count) selected_splash = splash_count-1;
|
||||
} else {
|
||||
selected_theme += 4;
|
||||
if (selected_theme >= theme_count) selected_theme = theme_count-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (kDown & KEY_START)
|
||||
if (!splash_mode && selected_theme != previously_selected)
|
||||
{
|
||||
exit_screens();
|
||||
exit_services();
|
||||
PTMSYSM_RebootAsync(0);
|
||||
ptmSysmExit();
|
||||
current_theme->has_preview = false;
|
||||
previously_selected = selected_theme;
|
||||
}
|
||||
}
|
||||
|
||||
free(themes_list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Submodule source/pp2d updated: cb235fa83b...f786d09700
@@ -86,13 +86,18 @@ Result get_splashes(Splash_s** splashes_list, int *splash_count)
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void splash_delete()
|
||||
{
|
||||
remove("/luma/splash.bin");
|
||||
remove("/luma/splashbottom.bin");
|
||||
}
|
||||
void splash_install(Splash_s splash_to_install)
|
||||
{
|
||||
char *screen_buf;
|
||||
u32 size = file_to_buf(fsMakePath(PATH_UTF16, splash_to_install.top_path), ArchiveSD, &screen_buf);
|
||||
if (size)
|
||||
{
|
||||
remake_file("/luma/splash.bin", ArchiveSD, size);
|
||||
buf_to_file(size, "/luma/splash.bin", ArchiveSD, screen_buf);
|
||||
free(screen_buf);
|
||||
}
|
||||
@@ -100,6 +105,7 @@ void splash_install(Splash_s splash_to_install)
|
||||
size = file_to_buf(fsMakePath(PATH_UTF16, splash_to_install.bottom_path), ArchiveSD, &screen_buf);
|
||||
if (size)
|
||||
{
|
||||
remake_file("/luma/splashbottom.bin", ArchiveSD, size);
|
||||
buf_to_file(size, "/luma/splashbottom.bin", ArchiveSD, screen_buf);
|
||||
free(screen_buf);
|
||||
}
|
||||
|
||||
@@ -80,13 +80,14 @@ void load_theme_preview(Theme_s *theme)
|
||||
|
||||
theme->has_preview = true;
|
||||
pp2d_load_texture_memory(TEXTURE_PREVIEW, image, (u32)width, (u32)height);
|
||||
theme->preview_offset = (width-400)/2;
|
||||
}
|
||||
|
||||
free(image);
|
||||
free(preview_buffer);
|
||||
}
|
||||
|
||||
static void parse_smdh(Theme_s *theme, ssize_t textureID)
|
||||
static void parse_smdh(Theme_s *theme, ssize_t textureID, u16 *dir_name)
|
||||
{
|
||||
char *info_buffer = NULL;
|
||||
u64 size = 0;
|
||||
@@ -104,6 +105,12 @@ static void parse_smdh(Theme_s *theme, ssize_t textureID)
|
||||
if (!size)
|
||||
{
|
||||
free(info_buffer);
|
||||
memset(theme->name, 0, 0x80);
|
||||
memset(theme->desc, 0, 0x100);
|
||||
memset(theme->author, 0, 0x80);
|
||||
memcpy(theme->name, dir_name, 0x80);
|
||||
utf8_to_utf16(theme->desc, (u8*)"No description", 0x100);
|
||||
utf8_to_utf16(theme->author, (u8*)"Unknown author", 0x80);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +187,7 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
|
||||
current_theme->is_zip = !strcmp(entry.shortExt, "ZIP");
|
||||
|
||||
ssize_t iconID = TEXTURE_PREVIEW + *theme_count;
|
||||
parse_smdh(current_theme, iconID);
|
||||
parse_smdh(current_theme, iconID, entry.name);
|
||||
}
|
||||
|
||||
FSDIR_Close(dir_handle);
|
||||
@@ -188,6 +195,75 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
|
||||
return res;
|
||||
}
|
||||
|
||||
Result bgm_install(Theme_s bgm_to_install)
|
||||
{
|
||||
char *savedata_buf;
|
||||
char *thememanage_buf;
|
||||
char *music;
|
||||
u32 music_size = 0;
|
||||
u32 savedata_size;
|
||||
|
||||
savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf);
|
||||
savedata_buf[0x141b] = 0;
|
||||
memset(&savedata_buf[0x13b8], 0, 8);
|
||||
savedata_buf[0x13bd] = 3;
|
||||
savedata_buf[0x13b8] = 0xff;
|
||||
u32 size = buf_to_file(savedata_size, "/SaveData.dat", ArchiveHomeExt, savedata_buf);
|
||||
free(savedata_buf);
|
||||
|
||||
if (bgm_to_install.is_zip) // Same as above but this time with bgm
|
||||
{
|
||||
music_size = zip_file_to_buf("bgm.bcstm", bgm_to_install.path, &music);
|
||||
} else {
|
||||
u16 path[0x106] = {0};
|
||||
memcpy(path, bgm_to_install.path, 0x106 * sizeof(u16));
|
||||
struacat(path, "/bgm.bcstm");
|
||||
music_size = file_to_buf(fsMakePath(PATH_UTF16, path), ArchiveSD, &music);
|
||||
}
|
||||
|
||||
if (music_size == 0)
|
||||
{
|
||||
free(music);
|
||||
music = calloc(1, 3371008);
|
||||
} else if (music_size > 3371008) {
|
||||
free(music);
|
||||
puts("musicrip");
|
||||
return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_TOO_LARGE);
|
||||
}
|
||||
|
||||
size = buf_to_file(music_size, "/BgmCache.bin", ArchiveThemeExt, music);
|
||||
free(music);
|
||||
|
||||
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
|
||||
|
||||
file_to_buf(fsMakePath(PATH_ASCII, "/ThemeManage.bin"), ArchiveThemeExt, &thememanage_buf);
|
||||
thememanage_buf[0x00] = 1;
|
||||
thememanage_buf[0x01] = 0;
|
||||
thememanage_buf[0x02] = 0;
|
||||
thememanage_buf[0x03] = 0;
|
||||
thememanage_buf[0x04] = 0;
|
||||
thememanage_buf[0x05] = 0;
|
||||
thememanage_buf[0x06] = 0;
|
||||
thememanage_buf[0x07] = 0;
|
||||
|
||||
u32 *music_size_location = (u32*)(&thememanage_buf[0xC]);
|
||||
*music_size_location = music_size;
|
||||
|
||||
thememanage_buf[0x10] = 0xFF;
|
||||
thememanage_buf[0x14] = 0x01;
|
||||
thememanage_buf[0x18] = 0xFF;
|
||||
thememanage_buf[0x1D] = 0x02;
|
||||
|
||||
memset(&thememanage_buf[0x338], 0, 4);
|
||||
memset(&thememanage_buf[0x340], 0, 4);
|
||||
memset(&thememanage_buf[0x360], 0, 4);
|
||||
memset(&thememanage_buf[0x368], 0, 4);
|
||||
size = buf_to_file(0x800, "/ThemeManage.bin", ArchiveThemeExt, thememanage_buf);
|
||||
free(thememanage_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Install a single theme
|
||||
Result single_install(Theme_s theme_to_install)
|
||||
{
|
||||
@@ -199,8 +275,6 @@ Result single_install(Theme_s theme_to_install)
|
||||
u32 music_size;
|
||||
u32 savedata_size;
|
||||
|
||||
printf("Writing SaveData.dat...\n");
|
||||
|
||||
savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf);
|
||||
savedata_buf[0x141b] = 0;
|
||||
memset(&savedata_buf[0x13b8], 0, 8);
|
||||
@@ -210,7 +284,6 @@ Result single_install(Theme_s theme_to_install)
|
||||
free(savedata_buf);
|
||||
|
||||
// Open body cache file. Test if theme is zipped
|
||||
printf("Writing BodyCache.bin...\n");
|
||||
if (theme_to_install.is_zip)
|
||||
{
|
||||
body_size = zip_file_to_buf("body_LZ.bin", theme_to_install.path, &body);
|
||||
@@ -235,7 +308,6 @@ Result single_install(Theme_s theme_to_install)
|
||||
|
||||
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
|
||||
|
||||
printf("Writing BgmCache.bin...\n");
|
||||
if (theme_to_install.is_zip) // Same as above but this time with bgm
|
||||
{
|
||||
music_size = zip_file_to_buf("bgm.bcstm", theme_to_install.path, &music);
|
||||
@@ -261,7 +333,6 @@ Result single_install(Theme_s theme_to_install)
|
||||
|
||||
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
|
||||
|
||||
printf("Writing ThemeManage.bin...\n");
|
||||
file_to_buf(fsMakePath(PATH_ASCII, "/ThemeManage.bin"), ArchiveThemeExt, &thememanage_buf);
|
||||
thememanage_buf[0x00] = 1;
|
||||
thememanage_buf[0x01] = 0;
|
||||
@@ -289,8 +360,6 @@ Result single_install(Theme_s theme_to_install)
|
||||
size = buf_to_file(0x800, "/ThemeManage.bin", ArchiveThemeExt, thememanage_buf);
|
||||
free(thememanage_buf);
|
||||
|
||||
printf("Done!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user