Add files

This commit is contained in:
RocketRobz 2019-11-13 13:40:50 -07:00
parent 619f3ad50b
commit afcd476ee2
38 changed files with 1144 additions and 0 deletions

282
Makefile Normal file
View File

@ -0,0 +1,282 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# External tools
#---------------------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
MAKEROM ?= ../makerom.exe
BANNERTOOL ?= ../bannertool.exe
else
MAKEROM ?= makerom
BANNERTOOL ?= bannertool
endif
#---------------------------------------------------------------------------------
# Version number
#---------------------------------------------------------------------------------
VERSION_MAJOR := 1
VERSION_MINOR := 0
VERSION_MICRO := 0
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := SavvyManager
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include include/utils
GRAPHICS := assets/gfx
ROMFS := romfs
GFXBUILD := $(ROMFS)/gfx
APP_AUTHOR := RocketRobz
APP_DESCRIPTION := Savvy Manager
ICON := app/icon.png
BNR_IMAGE := app/banner.png
BNR_AUDIO := app/BannerAudio.bcwav
RSF_FILE := app/build-cia.rsf
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fpermissive -std=c++11 -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcitro2d -lcitro3d -lctru -lm -lstdc++
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB) $(PORTLIBS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
ifeq ($(GFXBUILD),$(BUILD))
#---------------------------------------------------------------------------------
export T3XFILES := $(GFXFILES:.t3s=.t3x)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(addsuffix .o,$(T3XFILES))
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
$(addsuffix .h,$(subst .,_,$(BINFILES))) \
$(GFXFILES:.t3s=.h)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif
.PHONY: all clean
#---------------------------------------------------------------------------------
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf
@rm -fr $(OUTDIR)
#---------------------------------------------------------------------------------
cia: $(BUILD)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile cia
#---------------------------------------------------------------------------------
3dsx: $(BUILD)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 3dsx
#---------------------------------------------------------------------------------
$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(DEVKITPRO)/tools/bin/tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
all: $(OUTPUT).cia $(OUTPUT).elf $(OUTPUT).3dsx
$(OUTPUT).elf : $(OFILES)
$(OUTPUT).cia : $(OUTPUT).elf $(OUTPUT).smdh
$(BANNERTOOL) makebanner -i "../app/banner.png" -ca "../app/BannerAudio.bcwav" -o "../app/banner.bin"
$(BANNERTOOL) makesmdh -i "../app/icon.png" -s "$(TARGET)" -l "$(TARGET)" -p "$(APP_AUTHOR)" -o "../app/icon.bin"
$(MAKEROM) -f cia -target t -exefslogo -o "../SavvyManager.cia" -elf "../SavvyManager.elf" -rsf "../app/build-cia.rsf" -banner "../app/banner.bin" -icon "../app/icon.bin" -logo "../app/logo.bcma.lz" -DAPP_ROMFS="$(TOPDIR)/$(ROMFS)" -major $(VERSION_MAJOR) -minor $(VERSION_MINOR) -micro $(VERSION_MICRO) -DAPP_VERSION_MAJOR="$(VERSION_MAJOR)"
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
.PRECIOUS : %.t3x
#---------------------------------------------------------------------------------
%.t3x.o %_t3x.h : %.t3x
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $*.shbin)
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
endef
%.shbin.o %_shbin.h : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o %_shbin.h : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o %_shbin.h : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
#---------------------------------------------------------------------------------
%.t3x %.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

BIN
app/BannerAudio.bcwav Normal file

Binary file not shown.

BIN
app/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

285
app/build-cia.rsf Normal file
View File

@ -0,0 +1,285 @@
BasicInfo:
Title : "SavvyManager"
ProductCode : "CTR-H-SAVY"
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
RomFs:
RootPath: "../romfs"
TitleInfo:
Category : Application
UniqueId : 0x36973
Option:
UseOnSD : true # true if App is to be installed to SD
FreeProductCode : true # Removes limitations on ProductCode
MediaFootPadding : false # If true CCI files are created with padding
EnableCrypt : false # Enables encryption for NCCH and CIA
EnableCompress : true # Compresses where applicable (currently only exefs:/.code)
AccessControlInfo:
CoreVersion : 2
# Exheader Format Version
DescVersion : 2
# Minimum Required Kernel Version (below is for 4.5.0)
ReleaseKernelMajor : "02"
ReleaseKernelMinor : "33"
# ExtData
UseExtSaveData : false # enables ExtData
#ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId
# FS:USER Archive Access Permissions
# Uncomment as required
FileSystemAccess:
- CategorySystemApplication
- CategoryHardwareCheck
- CategoryFileSystemTool
- Debug
- TwlCardBackup
- TwlNandData
- Boss
- DirectSdmc
- Core
- CtrNandRo
- CtrNandRw
- CtrNandRoWrite
- CategorySystemSettings
- CardBoard
- ExportImportIvs
- DirectSdmcWrite
- SwitchCleanup
- SaveDataMove
- Shop
- Shell
- CategoryHomeMenu
- SeedDB
IoAccessControl:
- FsMountNand
- FsMountNandRoWrite
- FsMountTwln
- FsMountWnand
- FsMountCardSpi
- UseSdif3
- CreateSeed
- UseCardSpi
# Process Settings
MemoryType : Application # Application/System/Base
SystemMode : 64MB # 64MB(Default)/96MB/80MB/72MB/32MB
IdealProcessor : 0
AffinityMask : 1
Priority : 16
MaxCpu : 0x9E # Default
HandleTableSize : 0x200
DisableDebug : false
EnableForceDebug : false
CanWriteSharedPage : true
CanUsePrivilegedPriority : false
CanUseNonAlphabetAndNumber : true
PermitMainFunctionArgument : true
CanShareDeviceMemory : true
RunnableOnSleep : false
SpecialMemoryArrange : true
# New3DS Exclusive Process Settings
SystemModeExt : Legacy # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
CpuSpeed : 268MHz # 268MHz(Default)/804MHz
EnableL2Cache : false # false(default)/true
CanAccessCore2 : true
# Virtual Address Mappings
IORegisterMapping:
- 1ff00000-1ff7ffff # DSP memory
MemoryMapping:
- 1f000000-1f5fffff:r # VRAM
# Accessible SVCs, <Name>:<ID>
SystemCallAccess:
ControlMemory: 1
QueryMemory: 2
ExitProcess: 3
GetProcessAffinityMask: 4
SetProcessAffinityMask: 5
GetProcessIdealProcessor: 6
SetProcessIdealProcessor: 7
CreateThread: 8
ExitThread: 9
SleepThread: 10
GetThreadPriority: 11
SetThreadPriority: 12
GetThreadAffinityMask: 13
SetThreadAffinityMask: 14
GetThreadIdealProcessor: 15
SetThreadIdealProcessor: 16
GetCurrentProcessorNumber: 17
Run: 18
CreateMutex: 19
ReleaseMutex: 20
CreateSemaphore: 21
ReleaseSemaphore: 22
CreateEvent: 23
SignalEvent: 24
ClearEvent: 25
CreateTimer: 26
SetTimer: 27
CancelTimer: 28
ClearTimer: 29
CreateMemoryBlock: 30
MapMemoryBlock: 31
UnmapMemoryBlock: 32
CreateAddressArbiter: 33
ArbitrateAddress: 34
CloseHandle: 35
WaitSynchronization1: 36
WaitSynchronizationN: 37
SignalAndWait: 38
DuplicateHandle: 39
GetSystemTick: 40
GetHandleInfo: 41
GetSystemInfo: 42
GetProcessInfo: 43
GetThreadInfo: 44
ConnectToPort: 45
SendSyncRequest1: 46
SendSyncRequest2: 47
SendSyncRequest3: 48
SendSyncRequest4: 49
SendSyncRequest: 50
OpenProcess: 51
OpenThread: 52
GetProcessId: 53
GetProcessIdOfThread: 54
GetThreadId: 55
GetResourceLimit: 56
GetResourceLimitLimitValues: 57
GetResourceLimitCurrentValues: 58
GetThreadContext: 59
Break: 60
OutputDebugString: 61
ControlPerformanceCounter: 62
CreatePort: 71
CreateSessionToPort: 72
CreateSession: 73
AcceptSession: 74
ReplyAndReceive1: 75
ReplyAndReceive2: 76
ReplyAndReceive3: 77
ReplyAndReceive4: 78
ReplyAndReceive: 79
BindInterrupt: 80
UnbindInterrupt: 81
InvalidateProcessDataCache: 82
StoreProcessDataCache: 83
FlushProcessDataCache: 84
StartInterProcessDma: 85
StopDma: 86
GetDmaState: 87
RestartDma: 88
DebugActiveProcess: 96
BreakDebugProcess: 97
TerminateDebugProcess: 98
GetProcessDebugEvent: 99
ContinueDebugEvent: 100
GetProcessList: 101
GetThreadList: 102
GetDebugThreadContext: 103
SetDebugThreadContext: 104
QueryDebugProcessMemory: 105
ReadProcessMemory: 106
WriteProcessMemory: 107
SetHardwareBreakPoint: 108
GetDebugThreadParam: 109
ControlProcessMemory: 112
MapProcessMemory: 113
UnmapProcessMemory: 114
CreateCodeSet: 115
CreateProcess: 117
TerminateProcess: 118
SetProcessResourceLimits: 119
CreateResourceLimit: 120
SetResourceLimitValues: 121
AddCodeSegment: 122
Backdoor: 123
KernelSetState: 124
QueryProcessMemory: 125
# Service List
# Maximum 34 services (32 if firmware is prior to 9.6.0)
ServiceAccessControl:
- APT:U
- ac:u
- am:net
- boss:U
- cam:u
- cecd:u
- cfg:nor
- cfg:u
- csnd:SND
- dsp::DSP
- frd:u
- fs:USER
- gsp::Gpu
- gsp::Lcd
- hid:USER
- http:C
- ir:rst
- ir:u
- ir:USER
- mic:u
- ndm:u
- news:s
- nwm::EXT
- nwm::UDS
- ptm:sysm
- ptm:u
- pxi:dev
- soc:U
- ssl:C
- y2r:u
SystemControlInfo:
SaveDataSize: 0KB # Change if the app uses savedata
RemasterVersion: $(APP_VERSION_MAJOR)
StackSize: 0x40000
# Modules that run services listed above should be included below
# Maximum 48 dependencies
# <module name>:<module titleid>
Dependency:
ac: 0x0004013000002402
#act: 0x0004013000003802
am: 0x0004013000001502
boss: 0x0004013000003402
camera: 0x0004013000001602
cecd: 0x0004013000002602
cfg: 0x0004013000001702
codec: 0x0004013000001802
csnd: 0x0004013000002702
dlp: 0x0004013000002802
dsp: 0x0004013000001a02
friends: 0x0004013000003202
gpio: 0x0004013000001b02
gsp: 0x0004013000001c02
hid: 0x0004013000001d02
http: 0x0004013000002902
i2c: 0x0004013000001e02
ir: 0x0004013000003302
mcu: 0x0004013000001f02
mic: 0x0004013000002002
ndm: 0x0004013000002b02
news: 0x0004013000003502
#nfc: 0x0004013000004002
nim: 0x0004013000002c02
nwm: 0x0004013000002d02
pdn: 0x0004013000002102
ps: 0x0004013000003102
ptm: 0x0004013000002202
#qtm: 0x0004013020004202
ro: 0x0004013000003702
socket: 0x0004013000002e02
spi: 0x0004013000002302
ssl: 0x0004013000002f02

BIN
app/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
app/logo.bcma.lz Normal file

Binary file not shown.

BIN
assets/gfx/blue_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
assets/gfx/phone_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

13
assets/gfx/sprites.t3s Normal file
View File

@ -0,0 +1,13 @@
--atlas -f rgba -z auto
blue_bg.png
phone_bg.png
logo_rocketrobz.png
title1.png
title1_screenshot.png
title2.png
title2_screenshot.png
title2_screenshotJ.png
title3.png
title3_screenshot.png
title4.png
title4_screenshot.png

BIN
assets/gfx/title1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
assets/gfx/title2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

BIN
assets/gfx/title3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

BIN
assets/gfx/title4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

4
clean and compile.bat Normal file
View File

@ -0,0 +1,4 @@
@echo off
make clean
make
pause

2
clean.bat Normal file
View File

@ -0,0 +1,2 @@
@echo off
make clean

3
compile.bat Normal file
View File

@ -0,0 +1,3 @@
@echo off
make
pause

79
include/gui.hpp Normal file
View File

@ -0,0 +1,79 @@
/*
* This file is part of Universal-Manager
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef GUI_HPP
#define GUI_HPP
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include <random>
#include <stack>
#include <string.h>
#include <unordered_map>
#include <wchar.h>
#include "common.hpp"
// Spritesheets.
#include "sprites.h"
#include "colors.hpp"
// emulated
#define sprites_res_null_idx 500
#define FONT_SIZE_18 0.72f
#define FONT_SIZE_17 0.7f
#define FONT_SIZE_15 0.6f
#define FONT_SIZE_14 0.56f
#define FONT_SIZE_12 0.50f
#define FONT_SIZE_11 0.46f
#define FONT_SIZE_9 0.37f
namespace Gui {
Result init(void);
void exit(void);
C3D_RenderTarget* target(gfxScreen_t t);
void clearTextBufs(void);
void sprite(int key, int x, int y);
void Draw_ImageBlend(int key, int x, int y, u32 color);
}
void set_screen(C3D_RenderTarget * screen);
void Draw_EndFrame(void);
void Draw_Text(float x, float y, float size, u32 color, const char *text);
void Draw_Textf(float x, float y, float size, u32 color, const char* text, ...);
void Draw_GetTextSize(float size, float *width, float *height, const char *text);
float Draw_GetTextWidth(float size, const char *text);
float Draw_GetTextHeight(float size, const char *text);
bool Draw_Rect(float x, float y, float w, float h, u32 color);
#endif

44
include/utils/colors.hpp Normal file
View File

@ -0,0 +1,44 @@
/*
* This file is part of Universal-Manager
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef COLORS_HPP
#define COLORS_HPP
#include <citro2d.h>
#include <citro3d.h>
#define TRANSPARENT C2D_Color32(0, 0, 0, 0)
#define BLACK C2D_Color32(0, 0, 0, 255)
#define WHITE C2D_Color32(255, 255, 255, 255)
#define GRAY C2D_Color32(127, 127, 127, 255)
#define BLUE C2D_Color32(0, 0, 255, 255)
#define GREEN C2D_Color32(0, 255, 0, 255)
#define RED C2D_Color32(255, 0, 0, 255)
#define TIME C2D_Color32(16, 0, 0, 223)
typedef u32 Color;
#endif

32
include/utils/common.hpp Normal file
View File

@ -0,0 +1,32 @@
#pragma once
#include <3ds.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#ifdef __cplusplus
}
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <regex>
#include <curl/curl.h>
#endif
extern char * arg0;
#define WORKING_DIR "/3ds/"
#define HBL_FILE_NAME APP_TITLE ".3dsx"
#define HBL_FILE_PATH WORKING_DIR "/" HBL_FILE_NAME

Binary file not shown.

BIN
resources/icon.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
resources/ss2p-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
resources/title.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
resources/title.xcf Normal file

Binary file not shown.

Binary file not shown.

BIN
resources/topselection.xcf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
romfs/gfx/sprites.t3x Normal file
View File

127
source/gui.cpp Normal file
View File

@ -0,0 +1,127 @@
/*
* This file is part of Universal-Manager
* Copyright (C) 2019 VoltZ, Epicpkmn11, Flame, RocketRobz, TotallyNotGuy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "gui.hpp"
#include <assert.h>
#include <stdarg.h>
#include <unistd.h>
C3D_RenderTarget* top;
C3D_RenderTarget* bottom;
static C2D_SpriteSheet sprites;
C2D_TextBuf sizeBuf;
C2D_Font systemFont;
void Gui::clearTextBufs(void) {
C2D_TextBufClear(sizeBuf);
}
Result Gui::init(void) {
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
C2D_Prepare();
top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
sizeBuf = C2D_TextBufNew(4096);
sprites = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x");
systemFont = C2D_FontLoadSystem(CFG_REGION_USA);
return 0;
}
void Gui::exit(void) {
if (sprites) {
C2D_SpriteSheetFree(sprites);
}
C2D_TextBufDelete(sizeBuf);
C2D_Fini();
C3D_Fini();
}
void set_screen(C3D_RenderTarget * screen) {
C2D_SceneBegin(screen);
}
void Gui::sprite(int key, int x, int y) {
if (key == sprites_res_null_idx) {
return;
} else { // standard case
C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, key), x, y, 0.5f);
}
}
void Gui::Draw_ImageBlend(int key, int x, int y, u32 color) {
C2D_ImageTint tint;
C2D_SetImageTint(&tint, C2D_TopLeft, color, 1);
C2D_SetImageTint(&tint, C2D_TopRight, color, 1);
C2D_SetImageTint(&tint, C2D_BotLeft, color, 1);
C2D_SetImageTint(&tint, C2D_BotRight, color, 1);
C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, key), x, y, 0.5f, &tint);
}
void Draw_EndFrame(void) {
C2D_TextBufClear(sizeBuf);
C3D_FrameEnd(0);
}
void Draw_Text(float x, float y, float size, u32 color, const char *text) {
C2D_Text c2d_text;
C2D_TextFontParse(&c2d_text, systemFont, sizeBuf, text);
C2D_TextOptimize(&c2d_text);
C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, size, color);
}
void Draw_Textf(float x, float y, float size, u32 color, const char* text, ...) {
char buffer[256];
va_list args;
va_start(args, text);
vsnprintf(buffer, 256, text, args);
Draw_Text(x, y, size, color, buffer);
va_end(args);
}
void Draw_GetTextSize(float size, float *width, float *height, const char *text) {
C2D_Text c2d_text;
C2D_TextFontParse(&c2d_text, systemFont, sizeBuf, text);
C2D_TextGetDimensions(&c2d_text, size, size, width, height);
}
float Draw_GetTextWidth(float size, const char *text) {
float width = 0;
Draw_GetTextSize(size, &width, NULL, text);
return width;
}
float Draw_GetTextHeight(float size, const char *text) {
float height = 0;
Draw_GetTextSize(size, NULL, &height, text);
return height;
}
bool Draw_Rect(float x, float y, float w, float h, u32 color) {
return C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
}

273
source/main.cpp Normal file
View File

@ -0,0 +1,273 @@
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <3ds.h>
#include <malloc.h>
#include <sys/stat.h>
#include "gui.hpp"
#define CONFIG_3D_SLIDERSTATE (*(float *)0x1FF81080)
extern C3D_RenderTarget* top;
extern C3D_RenderTarget* bottom;
// Current screen mode.
enum ScreenMode {
SCREEN_MODE_ROCKETROBZ = 0, // RocketRobz logo
SCREEN_MODE_GAME_SELECT = 1, // Game select
SCREEN_MODE_CHARACTER_SELECT = 2, // Character select
};
static int screenmode = 0;
static int screenmodebuffer = 0;
static int screenDelay = 0;
static bool screenoff_ran = false;
static bool screenon_ran = true;
void screenoff(void)
{
screenon_ran = false;
if(!screenoff_ran) {
if (R_SUCCEEDED(gspLcdInit())) {
GSPLCD_PowerOffBacklight(GSPLCD_SCREEN_BOTH);
gspLcdExit();
}
screenoff_ran = true;
}
}
void screenon(void)
{
screenoff_ran = false;
if(!screenon_ran) {
if (R_SUCCEEDED(gspLcdInit())) {
GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTH);
gspLcdExit();
}
screenon_ran = true;
}
}
int main()
{
screenoff();
aptInit();
amInit();
sdmcInit();
romfsInit();
srvInit();
hidInit();
gfxInitDefault();
Gui::init();
// make folders if they don't exist
//mkdir("sdmc:/3ds", 0777);
//mkdir("sdmc:/3ds/SavvyGameSelect", 0777);
/*pp2d_load_texture_png(bgtex, "romfs:/graphics/phone_bg.png");
pp2d_load_texture_png(titletex, "romfs:/graphics/title.png");
pp2d_load_texture_png(title1tex, "romfs:/graphics/title1.png");
pp2d_load_texture_png(title2tex, "romfs:/graphics/title2.png");
pp2d_load_texture_png(title3tex, "romfs:/graphics/title3.png");
pp2d_load_texture_png(title4tex, "romfs:/graphics/title4.png");
pp2d_load_texture_png(title1shot, "romfs:/graphics/title1_screenshot.png");
pp2d_load_texture_png(title2shot, "romfs:/graphics/title2_screenshot.png");
pp2d_load_texture_png(title3shot, "romfs:/graphics/title3_screenshot.png");
pp2d_load_texture_png(title4shot, "romfs:/graphics/title4_screenshot.png");
pp2d_load_texture_png(photostudiobg, "romfs:/graphics/photostudio/Studio/blue.png");*/
//titleshot = title1shot;
int highlightedGame = 0;
int fadealpha = 255;
int fadecolor = 0;
bool fadein = true;
bool fadeout = false;
int text_width = 0;
const char* yeartext = "2019 RocketRobz";
const char* yeartext2 = "Games 2008-2017 Nintendo & syn Sophia";
float bg_xPos = 0.0f;
float bg_yPos = 0.0f;
screenon();
// Loop as long as the status is not exit
while(aptMainLoop()) {
// Scan hid shared memory for input events
hidScanInput();
const u32 hDown = hidKeysDown();
//const u32 hHeld = hidKeysHeld();
if(screenmode != SCREEN_MODE_ROCKETROBZ) {
screenDelay = 0;
}
if(screenmode == SCREEN_MODE_ROCKETROBZ) {
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(top, TRANSPARENT);
C2D_TargetClear(bottom, TRANSPARENT);
Gui::clearTextBufs();
set_screen(top);
Gui::sprite(sprites_logo_rocketrobz_idx, 0, 0);
if (fadealpha > 0) Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
set_screen(bottom);
Draw_Rect(0, 0, 320, 240, WHITE);
text_width = 104;
Draw_Text(((320-text_width)/2), 100, 0.50, BLACK, yeartext);
text_width = 264;
Draw_Text(((320-text_width)/2), 116, 0.50, BLACK, yeartext2);
if (fadealpha > 0) Draw_Rect(0, 0, 320, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
Draw_EndFrame();
screenDelay++;
if(screenDelay > 60*3){
screenmodebuffer = SCREEN_MODE_GAME_SELECT;
fadeout = true;
}
} else if(screenmode == SCREEN_MODE_GAME_SELECT) {
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(top, TRANSPARENT);
C2D_TargetClear(bottom, TRANSPARENT);
Gui::clearTextBufs();
set_screen(top);
for(int w = 0; w < 7; w++) {
for(int h = 0; h < 3; h++) {
Gui::sprite(sprites_phone_bg_idx, -72+bg_xPos+w*72, bg_yPos+h*136);
}
}
switch(highlightedGame) {
case 0:
default:
Gui::sprite(sprites_title1_screenshot_idx, 0, 0);
break;
case 1:
Gui::sprite(sprites_title2_screenshot_idx, 0, 0);
break;
case 2:
Gui::sprite(sprites_title3_screenshot_idx, 0, 0);
break;
case 3:
Gui::sprite(sprites_title4_screenshot_idx, 0, 0);
break;
}
if(highlightedGame==0) {
Gui::sprite(sprites_title1_idx, 0, 0);
} else {
Gui::Draw_ImageBlend(sprites_title1_idx, 0, 0, GRAY);
}
if(highlightedGame==1) {
Gui::sprite(sprites_title2_idx, 200, 0);
} else {
Gui::Draw_ImageBlend(sprites_title2_idx, 200, 0, GRAY);
}
if(highlightedGame==2) {
Gui::sprite(sprites_title3_idx, 0, 152);
} else {
Gui::Draw_ImageBlend(sprites_title3_idx, 0, 152, GRAY);
}
if(highlightedGame==3) {
Gui::sprite(sprites_title4_idx, 200, 152);
} else {
Gui::Draw_ImageBlend(sprites_title4_idx, 200, 152, GRAY);
}
if (fadealpha > 0) Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
set_screen(bottom);
for(int w = 0; w < 7; w++) {
for(int h = 0; h < 3; h++) {
Gui::sprite(sprites_phone_bg_idx, -76+bg_xPos+w*72, bg_yPos+h*136);
}
}
Draw_Text(8, 8, 0.50, BLACK, "Select a game to manage it's save data.");
if (fadealpha > 0) Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
Draw_EndFrame();
if(hDown & KEY_UP) {
if(highlightedGame==2 || highlightedGame==3) highlightedGame -= 2;
} else if(hDown & KEY_DOWN) {
if(highlightedGame==0 || highlightedGame==1) highlightedGame += 2;
} else if(hDown & KEY_LEFT) {
if(highlightedGame==1 || highlightedGame==3) highlightedGame--;
} else if(hDown & KEY_RIGHT) {
if(highlightedGame==0 || highlightedGame==2) highlightedGame++;
}
if((hDown & KEY_A) && (!fadein)){
screenmodebuffer = SCREEN_MODE_CHARACTER_SELECT;
fadeout = true;
}
} else if(screenmode == SCREEN_MODE_CHARACTER_SELECT) {
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
C2D_TargetClear(top, TRANSPARENT);
C2D_TargetClear(bottom, TRANSPARENT);
Gui::clearTextBufs();
set_screen(top);
Gui::sprite(sprites_blue_bg_idx, 0, 0);
if (fadealpha > 0) Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
set_screen(bottom);
for(int w = 0; w < 7; w++) {
for(int h = 0; h < 3; h++) {
Gui::sprite(sprites_phone_bg_idx, -76+bg_xPos+w*72, bg_yPos+h*136);
}
}
if (fadealpha > 0) Draw_Rect(0, 0, 400, 240, C2D_Color32(fadecolor, fadecolor, fadecolor, fadealpha)); // Fade in/out effect
Draw_EndFrame();
if(!fadein) {
if(hDown & KEY_B){
screenmodebuffer = SCREEN_MODE_GAME_SELECT;
fadeout = true;
}
}
}
bg_xPos += 0.2;
if(bg_xPos >= 72) bg_xPos = 0.0f;
bg_yPos -= 0.2;
if(bg_yPos <= -136) bg_yPos = 0.0f;
if (fadein == true) {
fadealpha -= 6;
if (fadealpha < 0) {
fadealpha = 0;
fadecolor = 255;
fadein = false;
}
}
if (fadeout) {
fadealpha += 6;
if (fadealpha > 255) {
fadealpha = 255;
screenmode = screenmodebuffer;
fadein = true;
fadeout = false;
}
}
}
Gui::exit();
hidExit();
srvExit();
romfsExit();
sdmcExit();
aptExit();
return 0;
}