Skip to content

Commit

Permalink
Merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joel16 committed Feb 19, 2017
1 parent 3c3adb4 commit a4ca345
Show file tree
Hide file tree
Showing 21 changed files with 224 additions and 165 deletions.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ APP_AUTHOR := Joel16
ICON := $(RESOURCES)/icon.png
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
Expand Down Expand Up @@ -140,6 +145,12 @@ else
export APP_ICON := $(TOPDIR)/$(ICON)
endif

ifneq ("$(wildcard $(LOGO))","")
COMMON_MAKEROM_FLAGS += -logo "$(LOGO)"
else ifneq ($(LOGO),plain)
COMMON_MAKEROM_FLAGS += -logo "$(RESOURCES)/logo.bcma.lz"
endif

ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
Expand Down Expand Up @@ -183,7 +194,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 -exefslogo -target t
@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

#---------------------------------------------------------------------------------

Expand Down
Binary file removed resources/Thumbs.db
Binary file not shown.
2 changes: 1 addition & 1 deletion resources/cia.rsf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BasicInfo:
Title : $(APP_TITLE)
ProductCode : $(APP_PRODUCT_CODE)
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
Logo : Homebrew

TitleInfo:
Category : Application
Expand Down
16 changes: 16 additions & 0 deletions source/gsplcd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "gsplcd.h"

Result GSPLCD_GetBrightness(u32 screen) //Screen index top = 1, bottom = 2
{
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;

screen = cmdbuf[2];

return cmdbuf[1];
}
5 changes: 5 additions & 0 deletions source/gsplcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <3ds.h>

Handle gspLcdHandle;

Result GSPLCD_GetBrightness(u32 screen);
246 changes: 132 additions & 114 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "am.h"
#include "cfgs.h"
#include "frd.h"
#include "gsplcd.h"
#include "mcu.h"
#include "screenshot.h"
#include "utils.h"
Expand Down Expand Up @@ -236,7 +237,7 @@ char * getNNID(void)
return tmp;
}

int main(int argc, char *argv[])
void initServices()
{
gfxInitDefault();
cfguInit();
Expand All @@ -254,7 +255,33 @@ int main(int argc, char *argv[])
actInit(SDK(11,2,0,200), 0x20000);
gspLcdInit();
httpcInit(0x9000);
frdInit(SDK(11,4,0,200));
frdInit(SDK(11,4,0,200));
}

void termServices()
{
frdExit();
httpcExit();
gspLcdExit();
actExit();
actuExit();
hidExit();
aptExit();
psExit();
acExit();
amExit();
mcuExit();
ptmuExit();
sdmcExit();
fsExit();
cfgsExit();
cfguExit();
gfxExit();
}

int main(int argc, char *argv[])
{
initServices();

/*consoleInit(GFX_BOTTOM, NULL);
Expand All @@ -274,113 +301,119 @@ int main(int argc, char *argv[])
s32 ret;
FS_ArchiveResource resource = {0};

printf("\x1b[0;0H"); //Move the cursor to the top left corner of the screen
printf("\x1b[32;1m3DSident 0.7.1\x1b[0m\n\n");
printf("\x1b[0;0H"); //Move the cursor to the top left corner of the screen
printf("\x1b[32;1m3DSident 0.7.2\x1b[0m\n\n");

//=====================================================================//
//------------------------------Firm Info------------------------------//
//=====================================================================//

snprintf(str_ver, 255, "\x1b[33;1m*\x1b[0m Kernel version: \x1b[33;1m%lu.%lu-%lu\n*\x1b[0m FIRM version is: \x1b[33;1m%lu.%lu-%lu\x1b[0m \n",
GET_VERSION_MAJOR(os_ver),
GET_VERSION_MINOR(os_ver),
GET_VERSION_REVISION(os_ver),
GET_VERSION_MAJOR(firm_ver),
GET_VERSION_MINOR(firm_ver),
GET_VERSION_REVISION(firm_ver)
);

printf(str_ver);

memset(nver, 0, sizeof(OS_VersionBin));
memset(cver, 0, sizeof(OS_VersionBin));
ret = osGetSystemVersionData(nver, cver);

if (ret)
printf("\x1b[33;1m*\x1b[0m osGetSystemVersionData returned 0x%08liX\n\n", ret);

snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m Current system version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n",
cver->mainver,
cver->minor,
cver->build,
nver->mainver
);

if (!ret)
printf(str_sysver);

//=====================================================================//
//-----------------------------System Info-----------------------------//
//=====================================================================//

//u32 brightness = 0;
//GSPLCD_GetBrightness(brightness);

//printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%i\x1b[0m\n", (int)brightness);

//=====================================================================//
//------------------------------Firm Info------------------------------//
//=====================================================================//

printf("\x1b[31;1m*\x1b[0m Model: \x1b[31;1m%s %s\n\x1b[0m", getModel(), getRegion());
getScreenType();
printf("\x1b[31;1m*\x1b[0m Language: \x1b[31;1m%s\x1b[0m \n", getLang());
printf("\x1b[31;1m*\x1b[0m NNID: \x1b[31;1m%s\x1b[0m ", (char*)getNNID());

ret = ACTU_Initialize(0xB0002C8, 0, 0);
ret = ACTU_GetAccountDataBlock(0xFE, 4, 12, &nnidNum);

if (nnidNum != 0xFFFFFFFF)
vaPrint("(\x1b[31;1m%08X\x1b[0m) \n", (int) nnidNum);
else
printf("\x1b[31;1mError could not retrieve NNID\x1b[0m\n");

printf("\x1b[31;1m*\x1b[0m Device ID: \x1b[31;1m%lu \n", getDeviceId());
printf("\x1b[31;1m*\x1b[0m ECS Device ID: \x1b[31;1m%llu \n", getSoapId());
printf("\x1b[31;1m*\x1b[0m Friend Code: \x1b[31;1m%llu \n", principalIdToFriendCode(getMyFriendKey().principalId));
printf("\x1b[31;1m*\x1b[0m MAC Address: \x1b[31;1m%s\x1b[0m \n", getMacAddress());
printf("\x1b[31;1m*\x1b[0m Serial number: \x1b[31;1m%s\x1b[0m \n", getSerialNum());

FSUSER_GetSdmcCid(buf, 0x10);
printf("\x1b[31;1m*\x1b[0m SDMC CID: \x1b[31;1m%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\x1b[0m \n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], buf[15]);

FSUSER_GetNandCid(buf, 0x10);
printf("\x1b[31;1m*\x1b[0m NAND CID: \x1b[31;1m%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\x1b[0m \n\n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], buf[15]);

//=====================================================================//
//----------------------------Battery Info-----------------------------//
//=====================================================================//
snprintf(str_ver, 255, "\x1b[33;1m*\x1b[0m Kernel version: \x1b[33;1m%lu.%lu-%lu\n*\x1b[0m FIRM version is: \x1b[33;1m%lu.%lu-%lu\x1b[0m \n",
GET_VERSION_MAJOR(os_ver),
GET_VERSION_MINOR(os_ver),
GET_VERSION_REVISION(os_ver),
GET_VERSION_MAJOR(firm_ver),
GET_VERSION_MINOR(firm_ver),
GET_VERSION_REVISION(firm_ver)
);

printf(str_ver);

memset(nver, 0, sizeof(OS_VersionBin));
memset(cver, 0, sizeof(OS_VersionBin));
ret = osGetSystemVersionData(nver, cver);

if (ret)
printf("\x1b[33;1m*\x1b[0m osGetSystemVersionData returned 0x%08liX\n\n", ret);

snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m Current system version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n",
cver->mainver,
cver->minor,
cver->build,
nver->mainver
);

if (!ret)
printf(str_sysver);

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());
//=====================================================================//
//-----------------------------System Info-----------------------------//
//=====================================================================//

printf("\x1b[31;1m*\x1b[0m Model: \x1b[31;1m%s %s\n\x1b[0m", getModel(), getRegion());
getScreenType();
printf("\x1b[31;1m*\x1b[0m Language: \x1b[31;1m%s\x1b[0m \n", getLang());
printf("\x1b[31;1m*\x1b[0m NNID: \x1b[31;1m%s\x1b[0m ", (char*)getNNID());

ret = ACTU_Initialize(0xB0002C8, 0, 0);
ret = ACTU_GetAccountDataBlock(0xFE, 4, 12, &nnidNum);

if (nnidNum != 0xFFFFFFFF)
vaPrint("(\x1b[31;1m%08X\x1b[0m) \n", (int) nnidNum);
else
printf("\x1b[31;1mError could not retrieve NNID\x1b[0m\n");

printf("\x1b[31;1m*\x1b[0m Device ID: \x1b[31;1m%lu \n", getDeviceId());
printf("\x1b[31;1m*\x1b[0m ECS Device ID: \x1b[31;1m%llu \n", getSoapId());
printf("\x1b[31;1m*\x1b[0m Friend Code: \x1b[31;1m%llu \n", principalIdToFriendCode(getMyFriendKey().principalId));
printf("\x1b[31;1m*\x1b[0m MAC Address: \x1b[31;1m%s\x1b[0m \n", getMacAddress());
printf("\x1b[31;1m*\x1b[0m Serial number: \x1b[31;1m%s\x1b[0m \n", getSerialNum());

FSUSER_GetSdmcCid(buf, 0x10);
printf("\x1b[31;1m*\x1b[0m SDMC CID: \x1b[31;1m%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\x1b[0m \n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], buf[15]);

FSUSER_GetNandCid(buf, 0x10);
printf("\x1b[31;1m*\x1b[0m NAND CID: \x1b[31;1m%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\x1b[0m \n\n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14], buf[15]);

//=====================================================================//
//----------------------------Battery Info-----------------------------//
//=====================================================================//

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());

mcuGetBatteryVoltage(&batteryVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m\n \n", batteryVolt);//,(Estimated: %0.1lf V) estimatedVolt);
mcuGetBatteryVoltage(&batteryVolt);
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m\n \n", batteryVolt);//,(Estimated: %0.1lf V) estimatedVolt);

//=====================================================================//
//------------------------------Misc Info------------------------------//
//=====================================================================//
//=====================================================================//
//------------------------------Misc Info------------------------------//
//=====================================================================//

FSUSER_GetArchiveResource(&resource, SYSTEM_MEDIATYPE_SD);
printf("\x1b[32;1m*\x1b[0m SD Size: \x1b[32;1m%.1f \x1b[0mMB / \x1b[32;1m%.1f\x1b[0m MB \n",
(((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0),
(((u64) resource.totalClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0));
FSUSER_GetArchiveResource(&resource, SYSTEM_MEDIATYPE_SD);
printf("\x1b[32;1m*\x1b[0m SD Size: \x1b[32;1m%.1f \x1b[0mMB / \x1b[32;1m%.1f\x1b[0m MB \n",
(((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0),
(((u64) resource.totalClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0));

FSUSER_GetArchiveResource(&resource, SYSTEM_MEDIATYPE_CTR_NAND);
printf("\x1b[32;1m*\x1b[0m CTR Size: \x1b[32;1m%.1f\x1b[0m MB / \x1b[32;1m%.1f\x1b[0m MB \n",
(((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0),
(((u64) resource.totalClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0));
FSUSER_GetArchiveResource(&resource, SYSTEM_MEDIATYPE_CTR_NAND);
printf("\x1b[32;1m*\x1b[0m CTR Size: \x1b[32;1m%.1f\x1b[0m MB / \x1b[32;1m%.1f\x1b[0m MB \n",
(((u64) resource.freeClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0),
(((u64) resource.totalClusters * (u64) resource.clusterSize) / 1024.0 / 1024.0));

printf("\x1b[32;1m*\x1b[0m Installed titles: \x1b[32;1m%i\x1b[0m\n", (int)installedTitles);
printf("\x1b[32;1m*\x1b[0m Installed titles: \x1b[32;1m%i\x1b[0m\n", (int)installedTitles);

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);

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);
mcuGetVolume(&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);

mcuGetVolume(&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);

_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);
_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("\n\x1b[32;1m> Press any key to exit =)\x1b[0m");
printf("\n\x1b[32;1m> Press any key to exit =)\x1b[0m");

while (aptMainLoop())
{
Expand Down Expand Up @@ -430,21 +463,6 @@ int main(int argc, char *argv[])
free(str_ver);
free(str_sysver);

frdExit();
httpcExit();
gspLcdExit();
actuExit();
acExit();
hidExit();
aptExit();
psExit();
amExit();
mcuExit();
ptmuExit();
sdmcExit();
fsExit();
cfgsExit();
cfguExit();
gfxExit();
termServices();
return 0;
}
20 changes: 20 additions & 0 deletions source/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,24 @@ Result mcuGetVolume(u8* out)
if(ret < 0) return ret;
*out = ipc[2];
return ipc[1];
}

Result GetMcuFwVerHigh(u8* out)
{
u32* ipc = getThreadCommandBuffer();
ipc[0] = 0x100000;
Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0) return ret;
*out = ipc[2];
return ipc[1];
}

Result GetMcuFwVerLow(u8* out)
{
u32* ipc = getThreadCommandBuffer();
ipc[0] = 0x110000;
Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0) return ret;
*out = ipc[2];
return ipc[1];
}
4 changes: 3 additions & 1 deletion source/mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Result mcuInit();
Result mcuExit();
Result mcuGetBatteryLevel(u8* out);
Result mcuGetBatteryVoltage(u8* out);
Result mcuGetVolume(u8* out);
Result mcuGetVolume(u8* out);
Result GetMcuFwVerHigh(u8* out);
Result GetMcuFwVerLow(u8* out);
Loading

0 comments on commit a4ca345

Please sign in to comment.