Update for latest ctrulib

Now the example compiles using the latest ctrulib. It also uses
standard C Time library to get date and time
This commit is contained in:
Aurelio Mannara 2015-05-25 10:29:06 +02:00
parent eb1d6013cf
commit 1f375c0a75
2 changed files with 22 additions and 22 deletions

View File

@ -32,11 +32,10 @@ SOURCES := source
DATA := data DATA := data
INCLUDES := include INCLUDES := include
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=softfp ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \ CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \ -fomit-frame-pointer -ffast-math \
@ -114,6 +113,10 @@ else
export APP_ICON := $(TOPDIR)/$(ICON) export APP_ICON := $(TOPDIR)/$(ICON)
endif endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
.PHONY: $(BUILD) clean all .PHONY: $(BUILD) clean all
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -138,10 +141,10 @@ DEPENDS := $(OFILES:.o=.d)
# main targets # main targets
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),) ifeq ($(strip $(NO_SMDH)),)
.PHONY: all $(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
all : $(OUTPUT).3dsx $(OUTPUT).smdh else
endif
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).3dsx : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES) $(OUTPUT).elf : $(OFILES)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -14,18 +14,12 @@
#include <3ds.h> #include <3ds.h>
#include <stdio.h> #include <stdio.h>
#include <time.h>
#define SECONDS_IN_DAY 86400
#define SECONDS_IN_HOUR 3600
#define SECONDS_IN_MINUTE 60
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// Initialize services // Initialize services
srvInit(); gfxInitDefault();
aptInit();
gfxInit();
hidInit(NULL);
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one //Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
consoleInit(GFX_TOP, NULL); consoleInit(GFX_TOP, NULL);
@ -44,13 +38,18 @@ int main(int argc, char **argv)
if (kDown & KEY_START) break; // break in order to return to hbmenu if (kDown & KEY_START) break; // break in order to return to hbmenu
//Print current time //Print current time
u64 timeInSeconds = osGetTime() / 1000; time_t unixTime = time(NULL);
u64 dayTime = timeInSeconds % SECONDS_IN_DAY; struct tm* timeStruct = gmtime((const time_t *)&unixTime);
u8 hour = dayTime / SECONDS_IN_HOUR;
u8 min = (dayTime % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE;
u8 seconds = dayTime % SECONDS_IN_MINUTE;
printf("\x1b[0;0H%02d:%02d:%02d", hour, min, seconds); int hours = timeStruct->tm_hour;
int minutes = timeStruct->tm_min;
int seconds = timeStruct->tm_sec;
int day = timeStruct->tm_mday;
int month = timeStruct->tm_mon;
int year = timeStruct->tm_year +1900;
printf("\x1b[0;0H%02i:%02i:%02i", hours, minutes, seconds);
printf("\x1b[1;0H%02i/%02i/%04i", day, month, year);
// Flush and swap framebuffers // Flush and swap framebuffers
gfxFlushBuffers(); gfxFlushBuffers();
@ -62,8 +61,6 @@ int main(int argc, char **argv)
// Exit services // Exit services
gfxExit(); gfxExit();
hidExit();
aptExit();
srvExit();
return 0; return 0;
} }