Skip to content

Commit

Permalink
Now saves screenshot upon exit.
Browse files Browse the repository at this point in the history
More similarity towards PSPident :p
  • Loading branch information
joel16 committed Jul 27, 2016
1 parent 78b88c6 commit 6a61408
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lctru -lm
LIBS := -lpng16 -lz -lm -lctru

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
LIBDIRS := $(CTRULIB) $(PORTLIBS)


#---------------------------------------------------------------------------------
Expand Down
50 changes: 50 additions & 0 deletions source/fs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "fs.h"

void openSdArchive()
{
FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""));
}

void closeSdArchive()
{
FSUSER_CloseArchive(sdmcArchive);
}

int makeDir(const char *path)
{
if (!path)
return -1;

return mkdir(path, 0777);
}

bool fileExists(char *path)
{
FILE * temp = fopen(path, "r");
if(temp == NULL)
return false;

fclose(temp);

return true;
}

bool dirExists(const char *path)
{
struct stat info;

if(stat( path, &info ) != 0)
return false;
else if(info.st_mode & S_IFDIR)
return true;
else
return false;
}

bool deleteFile(const char *path)
{
openSdArchive();
Result ret = FSUSER_DeleteFile(sdmcArchive, fsMakePath(PATH_ASCII, path));
closeSdArchive();
return ret == 0;
}
13 changes: 13 additions & 0 deletions source/fs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <3ds.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/stat.h>

FS_Archive sdmcArchive;

void openSdArchive();
void closeSdArchive();
int makeDir(const char * path);
bool fileExists(char * path);
bool dirExists(const char * path);
bool deleteFile(const char *path);
19 changes: 14 additions & 5 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
#include <string.h>
#include <malloc.h>

#include "screenshot.h"

const char * getModel()
{
const char *models[] = {
const char *models[] =
{
"O3DS",
"O3DS XL",
"N3DS",
Expand All @@ -25,7 +28,8 @@ const char * getModel()

const char * getRegion()
{
const char *regions[] = {
const char *regions[] =
{
"JPN",
"USA",
"EUR",
Expand All @@ -47,7 +51,8 @@ const char * getRegion()

const char * getLang()
{
const char *languages[] = {
const char *languages[] =
{
"Japanese",
"English",
"French",
Expand Down Expand Up @@ -157,8 +162,12 @@ int main(int argc, char *argv[])
{
gspWaitForVBlank();
hidScanInput();
if (hidKeysDown()) break;
gfxFlushBuffers();
if (hidKeysDown())
{
captureScreenshot();
break;
}
gfxFlushBuffers();
gfxSwapBuffers();
}

Expand Down
Loading

0 comments on commit 6a61408

Please sign in to comment.