Merge upstream changes

Decided to remove config info, and keep 3DSident (original) minimal and only display cruical information.

GSPLCD header is no longer required now that it's been merged into ctrulib

Screenshots are now in the same format as 3DShell.

All file handling functions use FS:USER
This commit is contained in:
Joel 2017-07-15 02:00:34 -04:00
parent a945036c67
commit b288fd5093
11 changed files with 83 additions and 186 deletions

View File

@ -43,10 +43,6 @@ BANNER := $(RESOURCES)/banner.png
JINGLE := $(RESOURCES)/banner.wav
LOGO := $(RESOURCES)/logo.bcma.lz
VERSION_MAJOR := 0
VERSION_MINOR := 7
VERSION_MICRO := 2
# CIA
APP_PRODUCT_CODE := 3DS-I
APP_UNIQUE_ID := 0x16000
@ -57,10 +53,10 @@ APP_SYSTEM_MODE_EXT := Legacy
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations -Werror -DVERSION=$(VERSION)\
-fomit-frame-pointer -ffast-math \
CFLAGS := -g -Wall -O2 -mword-relocations -Werror \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
@ -70,7 +66,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lpng16 -lz -lm -lctru
LIBS := -lctru -lm -lpng16 -lz
OS := $(shell uname)
@ -194,7 +190,7 @@ banner:
cia: clean all
@arm-none-eabi-strip $(TARGET).elf
@makerom -f cia -o $(TARGET).cia -elf $(TARGET).elf -rsf $(RESOURCE)/cia.rsf -icon $(RESOURCES)/icon.png -banner $(RESOURCES)/banner.png -major $(VERSION_MAJOR) -minor $(VERSION_MINOR) -micro $(VERSION_MICRO) -exefslogo -target t
@makerom -f cia -o $(TARGET).cia -elf $(TARGET).elf -rsf $(RESOURCE)/cia.rsf -icon $(RESOURCES)/icon.png -banner $(RESOURCES)/banner.png -exefslogo -target t
#---------------------------------------------------------------------------------

View File

@ -1,13 +0,0 @@
#ifndef CONFIG_H
#define CONFIG_H
#include <3ds.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char * getUsername();
char * getBirthday();
char * getEulaVersion();
#endif

View File

@ -2,17 +2,13 @@
#define FS_H
#include <3ds.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/stat.h>
FS_Archive sdmcArchive;
FS_Archive fsArchive;
void openSdArchive();
void closeSdArchive();
int makeDir(const char * path);
bool fileExists(char * path);
bool dirExists(const char * path);
bool deleteFile(const char *path);
void openArchive(FS_ArchiveID id);
void closeArchive(void);
Result makeDir(FS_Archive archive, const char * path);
bool fileExists(FS_Archive archive, const char * path);
bool dirExists(FS_Archive archive, const char * path);
#endif

View File

@ -8,13 +8,6 @@
#include <zlib.h>
#include <3ds.h>
#define NUM_LEVELS (Z_BEST_COMPRESSION - Z_NO_COMPRESSION + 1)
void captureScreenshot(void);
char fileName[256];
int level, screenCapture;
unsigned int format_choice;
GSPGPU_FramebufferFormats format; // = GSP_RGBA8_OES
void captureScreenshot();
#endif
#endif

View File

@ -1,8 +0,0 @@
#ifndef GSPLCD_H
#define GSPLCD_H
#include <3ds.h>
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness);
#endif

View File

@ -1,46 +0,0 @@
#include "config.h"
const char * getUsername()
{
int i;
size_t size = 0x16;
u8 * temp = (u8*)malloc(size);
char * username = (char*)malloc(size / 2);
for(i = 0; i < (size / 2); i++)
username[i] = 0;
CFGU_GetConfigInfoBlk2(0x1C, 0xA0000, temp);
for(i = 0; i < (size / 2); i++)
username[i] = (char)((u16*)temp)[i];
return username;
}
char * getBirthday()
{
u16 date = 0;
static char birthday[6];
CFGU_GetConfigInfoBlk2(0x2, 0xA0001, (u8*)&date);
u8 month = date / 256;
u8 day = date % 256;
sprintf(birthday, "%u/%u", day, month);
return birthday;
}
char * getEulaVersion()
{
u8 eulaData[4];
static char version[5];
CFGU_GetConfigInfoBlk2(4, 0xD0000, eulaData);
sprintf(version, "%02X.%02X", eulaData[1], eulaData[0]);
return version;
}

View File

@ -1,50 +1,59 @@
#include "fs.h"
void openSdArchive()
void openArchive(FS_ArchiveID id)
{
FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""));
FSUSER_OpenArchive(&fsArchive, id, fsMakePath(PATH_EMPTY, ""));
}
void closeSdArchive()
void closeArchive(void)
{
FSUSER_CloseArchive(sdmcArchive);
FSUSER_CloseArchive(fsArchive);
}
int makeDir(const char *path)
Result makeDir(FS_Archive archive, const char * path)
{
if (!path)
if((!archive) || (!path))
return -1;
return mkdir(path, 0777);
return FSUSER_CreateDirectory(archive, fsMakePath(PATH_ASCII, path), 0);
}
bool fileExists(char *path)
bool fileExists(FS_Archive archive, const char * path)
{
FILE * temp = fopen(path, "r");
if(temp == NULL)
return false;
if((!path) || (!archive))
return false;
Handle handle;
fclose(temp);
Result ret = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_ASCII, path), FS_OPEN_READ, 0);
if(ret != 0)
return false;
return true;
ret = FSFILE_Close(handle);
if(ret != 0)
return false;
return true;
}
bool dirExists(const char *path)
{
struct stat info;
bool dirExists(FS_Archive archive, const char * path)
{
if((!path) || (!archive))
return false;
Handle handle;
if(stat( path, &info ) != 0)
return false;
else if(info.st_mode & S_IFDIR)
return true;
else
return false;
}
Result ret = FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_ASCII, path));
if(ret != 0)
return false;
bool deleteFile(const char *path)
{
openSdArchive();
Result ret = FSUSER_DeleteFile(sdmcArchive, fsMakePath(PATH_ASCII, path));
closeSdArchive();
return ret == 0;
ret = FSDIR_Close(handle);
if(ret != 0)
return false;
return true;
}

View File

@ -6,10 +6,8 @@
#include <unistd.h>
#include "actu.h"
#include "am.h"
#include "cfgs.h"
#include "config.h"
#include "gsplcd.h"
#include "fs.h"
#include "mcu.h"
#include "misc.h"
#include "power.h"
@ -17,7 +15,7 @@
#include "system.h"
#include "utils.h"
#define SDK(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|d)
#define SDK(a, b, c, d) ((a<<24) | (b<<16) | (c<<8) | d)
void initServices()
{
@ -26,6 +24,7 @@ void initServices()
cfgsInit();
fsInit();
sdmcInit();
openArchive(ARCHIVE_SDMC);
ptmuInit();
mcuInit();
amInit();
@ -34,12 +33,10 @@ void initServices()
aptInit();
hidInit();
actInit(SDK(11, 2, 0, 200), 0x20000);
httpcInit(0x9000);
}
void termServices()
{
httpcExit();
actExit();
hidExit();
aptExit();
@ -48,6 +45,7 @@ void termServices()
amExit();
mcuExit();
ptmuExit();
closeArchive();
sdmcExit();
fsExit();
cfgsExit();
@ -61,11 +59,7 @@ int main(int argc, char *argv[])
consoleInit(GFX_BOTTOM, NULL);
printf("\x1b[36;1m*\x1b[0m Username: \x1b[36;1m %s \n\x1b[0m", getUsername());
printf("\x1b[36;1m*\x1b[0m Birthday: \x1b[36;1m%s\x1b[0m \n", getBirthday());
printf("\x1b[36;1m*\x1b[0m EULA version: \x1b[36;1m%s\x1b[0m \n\n ", getEulaVersion());
printf("\n\x1b[32;1m> Press any key to exit =)\x1b[0m");
printf("\x1b[32;1m> Press any key to exit =)\x1b[0m");
//printf("\x1b[31;1m*\x1b[0m Device cert: \x1b[31;1m%s\x1b[0m \n\n", getDeviceCert());
consoleInit(GFX_TOP, NULL);
@ -83,7 +77,7 @@ int main(int argc, char *argv[])
char ctrFreeSize[16], ctrTotalSize[16];
s32 ret;
printf("\x1b[0;0H"); //Move the cursor to the top left corner of the screen
printf("\x1b[1;1H"); //Move the cursor to the top left corner of the screen
printf("\x1b[32;1m3DSident 0.7.6\x1b[0m\n\n");
//=====================================================================//
@ -106,7 +100,7 @@ int main(int argc, char *argv[])
ret = osGetSystemVersionData(nver, cver);
if (ret)
printf("\x1b[33;1m*\x1b[0m System version: 0x%08liX\n\n", ret);
printf("\x1b[33;1m*\x1b[0m System version: \x1b[33;1m0x%08liX\x1b[0m\n\n", ret);
snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m System version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n",
cver->mainver,
@ -184,31 +178,31 @@ int main(int argc, char *argv[])
//----------------------------Battery Info-----------------------------//
//=====================================================================//
printf("\x1b[18;0H"); //Move the cursor to the top left corner of the screen
printf("\x1b[19;0H"); //Move the cursor to the top left corner of the screen
mcuGetBatteryLevel(&batteryPercent);
printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n\x1b[0m", batteryPercent, batteryStatus());
printf("\x1b[19;0H"); //Move the cursor to the top left corner of the screen
printf("\x1b[20;0H"); //Move the cursor to the top left corner of the screen
mcuGetBatteryVoltage(&batteryVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m)\n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0));//,(Estimated: %0.1lf V) estimatedVolt);
//=====================================================================//
//------------------------------Misc Info------------------------------//
//=====================================================================//
printf("\x1b[25;0H"); // Move the cursor
printf("\x1b[26;0H"); // Move the cursor
wifiPercent = (osGetWifiStrength() * 33.3333333333);
printf("\x1b[32;1m*\x1b[0m WiFi signal strength: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent);
printf("\x1b[26;0H"); //Move the cursor
printf("\x1b[27;0H"); //Move the cursor
HIDUSER_GetSoundVolume(&volume);
volPercent = (volume * 1.5873015873);
printf("\x1b[32;1m*\x1b[0m Volume slider state: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", volume, volPercent);
printf("\x1b[27;0H"); //Move the cursor
printf("\x1b[28;0H"); //Move the cursor
_3dSliderPercent = (osGet3DSliderState() * 100.0);
printf("\x1b[32;1m*\x1b[0m 3D slider state: \x1b[32;1m%.1lf\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
printf("\x1b[28;0H"); //Move the cursor
printf("\x1b[29;0H"); //Move the cursor
printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%s\x1b[0m \n", getBrightness(1));
gspWaitForVBlank();

View File

@ -1,19 +1,14 @@
#include "fs.h"
#include "screenshot.h"
static inline void update_gfx(void)
{
gfxFlushBuffers();
gspWaitForVBlank();
gfxSwapBuffers();
}
#define USE_CALLBACK
#define NUM_LEVELS (Z_BEST_COMPRESSION - Z_NO_COMPRESSION + 1)
static void png_file_write(png_structp png_ptr, png_bytep data, png_size_t length)
{
ssize_t rc;
FILE *fp = (FILE*)png_get_io_ptr(png_ptr);
FILE *fp = (FILE*)png_get_io_ptr(png_ptr);
if(length <= 0)
{
@ -22,6 +17,7 @@ static void png_file_write(png_structp png_ptr, png_bytep data, png_size_t lengt
}
rc = fwrite(data, 1, length, fp);
if(rc <= 0)
{
fprintf(stderr, "fwrite failed\n");
@ -34,14 +30,12 @@ static void png_file_write(png_structp png_ptr, png_bytep data, png_size_t lengt
}
}
static void
png_file_flush(png_structp png_ptr)
static void png_file_flush(png_structp png_ptr)
{
/* no-op */
}
static void
png_file_error(png_structp png_ptr, png_const_charp error_msg)
static void png_file_error(png_structp png_ptr, png_const_charp error_msg)
{
fprintf(stderr, "%s\n", error_msg);
}
@ -55,7 +49,7 @@ static void png_file_warning(png_structp png_ptr, png_const_charp warning_msg)
static void png_row_callback(png_structp png_ptr, png_uint_32 row, int pass)
{
fprintf(stderr, "\x1b[2;0H%3d%%\n", row*100 / 480);
fprintf(stderr, "\x1b[2;0H%3d%%\n", row * 100 / 480);
}
#endif
@ -266,31 +260,33 @@ void genScreenshotFileName(int lastNumber, char *fileName, const char *ext)
int num = lastNumber;
int day = timeStruct->tm_mday;
int month = timeStruct->tm_mon + 1;
int year = timeStruct->tm_year;
int year = timeStruct->tm_year + 1900;
if (!(dirExists("/screenshots/")))
makeDir("/screenshots");
if (!(dirExists(fsArchive, "/screenshots/")))
makeDir(fsArchive, "/screenshots");
sprintf(fileName, "/screenshots/screenshot-%d-%d-%d-%i-%s", day, month, year, num, ext);
sprintf(fileName, "/screenshots/Screenshot_%02d%02d%02d-%i%s", year, month, day, num, ext);
}
void captureScreenshot()
void captureScreenshot(void)
{
sprintf(fileName, "%s", "screenshot");
static char name[256];
sprintf(name, "%s", "screenshot");
if(lastNumber == -1)
{
lastNumber = 0;
}
genScreenshotFileName(lastNumber, fileName, ".png");
genScreenshotFileName(lastNumber, name, ".png");
while (fileExists(fileName))
while (fileExists(fsArchive, name))
{
lastNumber++;
genScreenshotFileName(lastNumber, fileName, ".png");
genScreenshotFileName(lastNumber, name, ".png");
}
screenshot_png(fileName, Z_NO_COMPRESSION);
screenshot_png(name, Z_NO_COMPRESSION);
lastNumber++;
}

View File

@ -1,19 +0,0 @@
#include "gsplcd.h"
Handle gspLcdHandle;
Result GSPLCD_GetBrightness(u32 screen, u32 * brightness)
{
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x15, 1, 0); // 0x150040
cmdbuf[1] = screen;
Result ret = 0;
if (R_FAILED(ret = svcSendSyncRequest(gspLcdHandle)))
return ret;
*brightness = cmdbuf[2];
return cmdbuf[2];
}

View File

@ -1,7 +1,6 @@
#include "actu.h"
#include "am.h"
#include "cfgs.h"
#include "gsplcd.h"
#include "system.h"
#include "utils.h"