21 Commits

Author SHA1 Message Date
9afbe22df7 Merge branch 'master' of github.com:3dsfug/Anemone3DS 2017-09-02 17:26:10 -04:00
448a9ceb8a Fix no-smdh case 2017-09-02 17:25:59 -04:00
Laine
25aa02008e Update README.md (#25)
* fix readme

* fix?

* fix?

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md
2017-09-02 15:59:55 -04:00
49e6c6f827 Add splash uninstall screen 2017-09-02 12:16:17 -04:00
365ae87477 Merge branch 'master' of github.com:3dsfug/Anemone3DS 2017-09-02 11:57:18 -04:00
f461b3b5b5 Remove GPIO error on reboot, change battery % indicator to battery graphics 2017-09-02 11:57:02 -04:00
Nils P
6ea3904682 Adding splash deletion feature (#24)
* Adding splash deletion feature

* Add Mention for deleting splashes
2017-09-02 11:45:56 -04:00
aac093f466 Resolved merge conflicts 2017-09-02 10:08:52 -04:00
9442afb608 Change stuff with MCUHWC, reboot functionality 2017-09-02 10:05:42 -04:00
Helloman892
91f54ff22e Start button functionality (#21)
* srvPublishToSubscriber

Pressing Start from the app now sends the user to the Power Off screen.

* *hax check

As per Sono, checks whether the current environment is *hax. If it isn't, it goes to the home screen; otherwise, it restarts the console.

* Bugfixes

This may work?

* Revert "Bugfixes"

This reverts commit 7c382d719a.
2017-09-02 10:05:18 -04:00
pokecraft98
aa593c61a6 Added invite to theme plaza discord (#23) 2017-09-02 10:05:10 -04:00
Nils P
2a8e3176a8 Readme Overhaul (#20)
* Readme Overhaul

* Linking to Project_CTR for makerom
2017-09-02 09:23:48 -04:00
thedax
c84f40cf57 3dstool isn't really needed for romfs generation. (#19) 2017-09-01 19:33:24 -04:00
Alex Taber
45cbf0761b Add dependencies 2017-09-01 15:07:27 -04:00
8c7c409bca Update pp2d 2017-09-01 12:51:47 -04:00
d9ddd68d2e Change to using the homebrew logo I guess 2017-09-01 12:51:25 -04:00
d93f4f9207 Add install BGM option 2017-09-01 12:31:55 -04:00
867f4b61ab Fix splash install when /luma/splash.bin or /luma/splashbottom.bin were missing 2017-09-01 12:11:25 -04:00
72153ba15d Make controls more untuitive 2017-09-01 12:02:09 -04:00
c4a096249c Fix softlock and make error more descriptive, and fixed preview offset 2017-09-01 11:55:32 -04:00
LiquidFenrir
91ba5fed49 previews overhaul (#13)
* allow quitting if there are no themes or splashes

* load preview only once if the user toggles more than once
2017-09-01 10:12:26 -04:00
19 changed files with 242 additions and 103 deletions

View File

@@ -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)" 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)),) #ifneq ($(strip $(ROMFS)),)
MAKEROM_ARGS += -romfs "$(BUILD)/romfs.bin" # MAKEROM_ARGS += -romfs "$(BUILD)/romfs.bin"
endif #endif
ifneq ($(strip $(LOGO)),) ifneq ($(strip $(LOGO)),)
MAKEROM_ARGS += -logo "$(LOGO)" MAKEROM_ARGS += -logo "$(LOGO)"
endif endif
@@ -178,7 +178,7 @@ ifeq ($(strip $(ROMFS)),)
$(OUTPUT).cia: $(OUTPUT).elf $(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) $(MAKEROM) -f cia -o "$@" -target t -exefslogo $(MAKEROM_ARGS)
else 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) $(MAKEROM) -f cia -o "$@" -target t -exefslogo $(MAKEROM_ARGS)
endif 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 "$@" $(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 else

View File

@@ -1,27 +1,30 @@
# Anemone3DS ![# Anemone3DS](https://github.com/astronautlevel2/Anemone3DS/blob/master/meta/banner.png)
A Theme Manager for the Nintendo3DS, written in C
A Theme and Splashscreen Manager for the Nintendo3DS, written in C
# Dependencies # 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 # License
This project is licensed under the GNU GPLv3. See LICENSE.md for details. Additional terms 7b and 7c apply to this project. This project is licensed under the GNU GPLv3. See LICENSE.md for details. Additional terms 7b and 7c apply to this project.
# Credits # 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: 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 * [Daedreth](https://github.com/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 * [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, who wrote the BCSTM playback code * [Sono](https://github.com/MarcuzD), 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. * [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: Special thanks go to these people who, while not directly contributing, helped immensely:
* Rinnegatamante, whose code served as reference on theme installation. * [Rinnegatamante](https://github.com/Rinnegatamante), whose code served as reference on theme installation.
* BernardoGiordano for making pp2d, and being super responsive to feature requests and just general help * [BernardoGiordano](https://github.com/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. * [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, Fenrir, and DanielKO). * 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. * 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: * 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 [Nintendo Homebrew Discord](https://discord.gg/C29hYvh)
* The members of the ThemePlaza Discord + The members of the __Secret Shack Service Discord__
+ The members of the [ThemePlaza Discord](https://discord.gg/2hUQwXz)

View File

@@ -36,12 +36,23 @@
#define THEMES_PATH "/Themes/" #define THEMES_PATH "/Themes/"
#define SPLASHES_PATH "/Splashes/" #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; static const int THEMES_PER_SCREEN = 4;
enum TextureID { enum TextureID {
TEXTURE_FONT_RESERVED = 0, //used by pp2d for the font TEXTURE_FONT_RESERVED = 0, //used by pp2d for the font
TEXTURE_ARROW, TEXTURE_ARROW,
TEXTURE_SHUFFLE, TEXTURE_SHUFFLE,
TEXTURE_BATTERY_1,
TEXTURE_BATTERY_2,
TEXTURE_BATTERY_3,
TEXTURE_BATTERY_4,
TEXTURE_BATTERY_5,
TEXTURE_BATTERY_CHARGE,
TEXTURE_PREVIEW, TEXTURE_PREVIEW,
}; };

View File

@@ -33,8 +33,9 @@
void init_screens(void); void init_screens(void);
void exit_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_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); void draw_splash_interface(Splash_s *splashes_list, int splash_count, int selected_splash, bool preview_mode);
#endif #endif

View File

@@ -37,5 +37,5 @@ typedef struct{
Result get_splashes(Splash_s** splashes_list, int *splash_count); Result get_splashes(Splash_s** splashes_list, int *splash_count);
void splash_install(Splash_s splash_to_install); void splash_install(Splash_s splash_to_install);
void splash_delete();
#endif #endif

View File

@@ -38,6 +38,7 @@ typedef struct {
ssize_t icon_id; ssize_t icon_id;
bool has_preview; bool has_preview;
int preview_offset;
u16 path[0x106]; u16 path[0x106];
bool is_zip; 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 get_themes(Theme_s **themes_list, int *theme_count);
Result single_install(Theme_s theme); Result single_install(Theme_s theme);
Result shuffle_install(Theme_s *themes_list, int theme_count); Result shuffle_install(Theme_s *themes_list, int theme_count);
Result bgm_install(Theme_s bgm_to_install);
#endif #endif

View File

@@ -3,7 +3,7 @@ BasicInfo:
CompanyCode : "00" CompanyCode : "00"
ProductCode : "CTR-P-ANEM" ProductCode : "CTR-P-ANEM"
ContentType : Application ContentType : Application
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem Logo : Homebrew # Nintendo / Licensed / Distributed / iQue / iQueForSystem
TitleInfo: TitleInfo:
UniqueId : 0xAFEN UniqueId : 0xAFEN
@@ -33,6 +33,9 @@ SystemControlInfo:
RemasterVersion: 7 RemasterVersion: 7
StackSize: 0x40000 StackSize: 0x40000
RomFs:
RootPath : romfs
# DO NOT EDIT BELOW HERE OR PROGRAMS WILL NOT LAUNCH (most likely) # DO NOT EDIT BELOW HERE OR PROGRAMS WILL NOT LAUNCH (most likely)
AccessControlInfo: AccessControlInfo:

BIN
romfs/battery1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

BIN
romfs/battery2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

BIN
romfs/battery3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

BIN
romfs/battery4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

BIN
romfs/battery5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

BIN
romfs/charging.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

View File

@@ -47,6 +47,12 @@ void init_screens(void)
pp2d_load_texture_png(TEXTURE_ARROW, "romfs:/arrow.png"); pp2d_load_texture_png(TEXTURE_ARROW, "romfs:/arrow.png");
pp2d_load_texture_png(TEXTURE_SHUFFLE, "romfs:/shuffle.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) void exit_screens(void)
@@ -54,21 +60,6 @@ void exit_screens(void)
pp2d_exit(); 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 theme_vertical_scroll = 0;
static int splash_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_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); pp2d_draw_textf(34, 2, 0.6, 0.6, COLOR_WHITE, "%.2i", tm.tm_min);
u8 battery_val = 0; u8 battery_charging;
MCUHWC_GetBatteryLevel(&battery_val); PTMU_GetBatteryChargeState(&battery_charging);
pp2d_draw_textf(350, 2, 0.6, 0.6, COLOR_WHITE, "%i%%", battery_val); 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_on(GFX_BOTTOM);
pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT); pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT);
@@ -94,10 +90,23 @@ void draw_base_interface(void)
pp2d_draw_on(GFX_TOP); pp2d_draw_on(GFX_TOP);
} }
void draw_theme_install(bool shuffle_install) void draw_theme_install(int install_type)
{ {
draw_base_interface(); 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(); 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) if (themes_list == NULL)
{ {
pp2d_begin_draw(GFX_TOP); 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(); pp2d_end_draw();
return; return;
} }
@@ -119,9 +128,9 @@ void draw_theme_interface(Theme_s * themes_list, int theme_count, int selected_t
if (current_theme.has_preview) if (current_theme.has_preview)
{ {
pp2d_begin_draw(GFX_TOP); 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_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 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); utf16_to_utf32((u32*)description, current_theme.desc, 0x80);
pp2d_draw_wtext(20, 65, 0.5, 0.5, COLOR_WHITE, description); 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(20, 150, 0.6, 0.6, COLOR_WHITE, L"\uE046 Install Shuffle Theme");
pp2d_draw_wtext_center(GFX_TOP, 180, 0.7, 0.7, COLOR_WHITE, L"\uE001 Queue Shuffle \uE046 Install shuffle"); pp2d_draw_wtext(200, 150, 0.6, 0.6, COLOR_WHITE, L"\uE004 Switch to Splashes");
pp2d_draw_wtext_center(GFX_TOP, 210, 0.7, 0.7, COLOR_WHITE, L"\uE003 Preview Theme"); 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); 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(); 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) void draw_splash_interface(Splash_s *splashes_list, int splash_count, int selected_splash, bool preview_mode)
{ {
if (splashes_list == NULL) if (splashes_list == NULL)
{ {
pp2d_begin_draw(GFX_TOP); 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(); pp2d_end_draw();
return; return;
} }
@@ -216,8 +245,8 @@ void draw_splash_interface(Splash_s *splashes_list, int splash_count, int select
draw_base_interface(); draw_base_interface();
pp2d_draw_text_center(GFX_TOP, 4, 0.5, 0.5, COLOR_WHITE, "Splash mode"); 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); pp2d_draw_on(GFX_BOTTOM);
for (int i = 0; i < splash_count; i++) { for (int i = 0; i < splash_count; i++) {
if (splash_count <= THEMES_PER_SCREEN) if (splash_count <= THEMES_PER_SCREEN)

View File

@@ -51,6 +51,10 @@ Result open_archives(void)
CFGU_SecureInfoGetRegion(&regionCode); CFGU_SecureInfoGetRegion(&regionCode);
switch(regionCode) switch(regionCode)
{ {
case 0:
archive1 = 0x000002cc;
archive2 = 0x00000082;
break;
case 1: case 1:
archive1 = 0x000002cd; archive1 = 0x000002cd;
archive2 = 0x0000008f; archive2 = 0x0000008f;
@@ -59,10 +63,6 @@ Result open_archives(void)
archive1 = 0x000002ce; archive1 = 0x000002ce;
archive2 = 0x00000098; archive2 = 0x00000098;
break; break;
case 3:
archive1 = 0x000002cc;
archive2 = 0x00000082;
break;
default: default:
archive1 = 0x00; archive1 = 0x00;
archive2 = 0x00; archive2 = 0x00;

View File

@@ -28,12 +28,13 @@
#include "themes.h" #include "themes.h"
#include "splashes.h" #include "splashes.h"
#include "draw.h" #include "draw.h"
#include "common.h"
int init_services(void) int init_services(void)
{ {
cfguInit(); cfguInit();
ptmuInit();
open_archives(); open_archives();
ptmSysmInit();
return 0; return 0;
} }
@@ -41,6 +42,7 @@ int exit_services(void)
{ {
close_archives(); close_archives();
cfguExit(); cfguExit();
ptmuExit();
return 0; return 0;
} }
@@ -48,7 +50,6 @@ int main(void)
{ {
init_services(); init_services();
init_screens(); init_screens();
int theme_count = 0; int theme_count = 0;
Theme_s * themes_list = NULL; Theme_s * themes_list = NULL;
@@ -72,6 +73,7 @@ int main(void)
bool splash_mode = false; bool splash_mode = false;
int selected_splash = 0; int selected_splash = 0;
int selected_theme = 0; int selected_theme = 0;
int previously_selected = 0;
int shuffle_theme_count = 0; int shuffle_theme_count = 0;
bool preview_mode = false; 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); 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); 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) if (themes_list == NULL && !splash_mode)
continue; continue;
@@ -96,11 +107,10 @@ int main(void)
{ {
if (!preview_mode) if (!preview_mode)
{ {
load_theme_preview(current_theme); if (!current_theme->has_preview)
if (current_theme->has_preview) load_theme_preview(current_theme);
{
preview_mode = true; preview_mode = current_theme->has_preview;
}
} }
else else
preview_mode = false; preview_mode = false;
@@ -111,21 +121,25 @@ int main(void)
continue; continue;
// Actions // Actions
else if (kDown & KEY_L)
{
splash_mode = !splash_mode;
}
else if (kDown & KEY_X) 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) else if (kDown & KEY_A)
{ {
if (splash_mode) if (splash_mode)
{ {
draw_splash_install(SINGLE_INSTALL);
splash_install(*current_splash); splash_install(*current_splash);
svcSleepThread(5e8);
} else { } else {
draw_theme_install(false); draw_theme_install(SINGLE_INSTALL);
single_install(*current_theme); single_install(*current_theme);
} }
} }
@@ -158,7 +172,7 @@ int main(void)
} else { } else {
if (shuffle_theme_count > 0) if (shuffle_theme_count > 0)
{ {
draw_theme_install(true); draw_theme_install(SHUFFLE_INSTALL);
shuffle_install(themes_list, theme_count); shuffle_install(themes_list, theme_count);
} }
} }
@@ -171,11 +185,11 @@ int main(void)
{ {
selected_splash++; selected_splash++;
if (selected_splash >= splash_count) if (selected_splash >= splash_count)
selected_splash = splash_count-1; selected_splash = 0;
} else { } else {
selected_theme++; selected_theme++;
if (selected_theme >= theme_count) if (selected_theme >= theme_count)
selected_theme = theme_count-1; selected_theme = 0;
} }
} }
else if (kDown & KEY_UP) else if (kDown & KEY_UP)
@@ -184,35 +198,41 @@ int main(void)
{ {
selected_splash--; selected_splash--;
if (selected_splash < 0) if (selected_splash < 0)
selected_splash = 0; selected_splash = splash_count - 1;
} else { } else {
selected_theme--; selected_theme--;
if (selected_theme < 0) if (selected_theme < 0)
selected_theme = 0; selected_theme = theme_count - 1;
} }
} }
// Quick moving // Quick moving
else if (kDown & KEY_LEFT) else if (kDown & KEY_LEFT)
{ {
if (splash_mode) selected_splash = 0; if (splash_mode)
else selected_theme = 0; {
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) else if (kDown & KEY_RIGHT)
{ {
if (splash_mode) selected_splash = splash_count - 1; if (splash_mode)
else selected_theme = theme_count-1; {
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(); current_theme->has_preview = false;
exit_services(); previously_selected = selected_theme;
PTMSYSM_RebootAsync(0);
ptmSysmExit();
} }
} }
free(themes_list);
return 0;
} }

View File

@@ -86,13 +86,18 @@ Result get_splashes(Splash_s** splashes_list, int *splash_count)
return res; return res;
} }
void splash_delete()
{
remove("/luma/splash.bin");
remove("/luma/splashbottom.bin");
}
void splash_install(Splash_s splash_to_install) void splash_install(Splash_s splash_to_install)
{ {
char *screen_buf; char *screen_buf;
u32 size = file_to_buf(fsMakePath(PATH_UTF16, splash_to_install.top_path), ArchiveSD, &screen_buf); u32 size = file_to_buf(fsMakePath(PATH_UTF16, splash_to_install.top_path), ArchiveSD, &screen_buf);
if (size) if (size)
{ {
remake_file("/luma/splash.bin", ArchiveSD, size);
buf_to_file(size, "/luma/splash.bin", ArchiveSD, screen_buf); buf_to_file(size, "/luma/splash.bin", ArchiveSD, screen_buf);
free(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); size = file_to_buf(fsMakePath(PATH_UTF16, splash_to_install.bottom_path), ArchiveSD, &screen_buf);
if (size) if (size)
{ {
remake_file("/luma/splashbottom.bin", ArchiveSD, size);
buf_to_file(size, "/luma/splashbottom.bin", ArchiveSD, screen_buf); buf_to_file(size, "/luma/splashbottom.bin", ArchiveSD, screen_buf);
free(screen_buf); free(screen_buf);
} }

View File

@@ -80,13 +80,14 @@ void load_theme_preview(Theme_s *theme)
theme->has_preview = true; theme->has_preview = true;
pp2d_load_texture_memory(TEXTURE_PREVIEW, image, (u32)width, (u32)height); pp2d_load_texture_memory(TEXTURE_PREVIEW, image, (u32)width, (u32)height);
theme->preview_offset = (width-400)/2;
} }
free(image); free(image);
free(preview_buffer); 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; char *info_buffer = NULL;
u64 size = 0; u64 size = 0;
@@ -104,6 +105,12 @@ static void parse_smdh(Theme_s *theme, ssize_t textureID)
if (!size) if (!size)
{ {
free(info_buffer); 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; return;
} }
@@ -180,7 +187,7 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
current_theme->is_zip = !strcmp(entry.shortExt, "ZIP"); current_theme->is_zip = !strcmp(entry.shortExt, "ZIP");
ssize_t iconID = TEXTURE_PREVIEW + *theme_count; ssize_t iconID = TEXTURE_PREVIEW + *theme_count;
parse_smdh(current_theme, iconID); parse_smdh(current_theme, iconID, entry.name);
} }
FSDIR_Close(dir_handle); FSDIR_Close(dir_handle);
@@ -188,6 +195,75 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
return res; 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 // Install a single theme
Result single_install(Theme_s theme_to_install) Result single_install(Theme_s theme_to_install)
{ {
@@ -199,8 +275,6 @@ Result single_install(Theme_s theme_to_install)
u32 music_size; u32 music_size;
u32 savedata_size; u32 savedata_size;
printf("Writing SaveData.dat...\n");
savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf); savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf);
savedata_buf[0x141b] = 0; savedata_buf[0x141b] = 0;
memset(&savedata_buf[0x13b8], 0, 8); memset(&savedata_buf[0x13b8], 0, 8);
@@ -210,7 +284,6 @@ Result single_install(Theme_s theme_to_install)
free(savedata_buf); free(savedata_buf);
// Open body cache file. Test if theme is zipped // Open body cache file. Test if theme is zipped
printf("Writing BodyCache.bin...\n");
if (theme_to_install.is_zip) if (theme_to_install.is_zip)
{ {
body_size = zip_file_to_buf("body_LZ.bin", theme_to_install.path, &body); 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); 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 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); 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); 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); file_to_buf(fsMakePath(PATH_ASCII, "/ThemeManage.bin"), ArchiveThemeExt, &thememanage_buf);
thememanage_buf[0x00] = 1; thememanage_buf[0x00] = 1;
thememanage_buf[0x01] = 0; 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); size = buf_to_file(0x800, "/ThemeManage.bin", ArchiveThemeExt, thememanage_buf);
free(thememanage_buf); free(thememanage_buf);
printf("Done!\n");
return 0; return 0;
} }