Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -428,11 +428,11 @@ return OFMaxRetainCount; } - (bool)hasTerminal { -#if defined(OF_WII) +#if defined(OF_WII) || defined(OF_NINTENDO_3DS) return true; #elif defined(HAVE_ISATTY) && !defined(OF_WII_U) return isatty(_fd); #else return false; Index: src/test/OTAppDelegate.m ================================================================== --- src/test/OTAppDelegate.m +++ src/test/OTAppDelegate.m @@ -32,10 +32,17 @@ # define asm __asm__ # include # include # undef asm #endif + +#ifdef OF_NINTENDO_3DS +/* Newer versions of libctru started using id as a parameter name. */ +# define id id_3ds +# include <3ds.h> +# undef id +#endif @interface OTAppDelegate: OFObject @end enum Status { @@ -56,13 +63,16 @@ return false; } @implementation OTAppDelegate -#ifdef OF_WII + (void)initialize { + if (self != [OTAppDelegate class]) + return; + +#if defined(OF_WII) GXRModeObj *mode; void *nextFB; VIDEO_Init(); WPAD_Init(); @@ -78,12 +88,17 @@ if (mode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); CON_InitEx(mode, 2, 2, mode->fbWidth - 4, mode->xfbHeight - 4); VIDEO_ClearFrameBuffer(mode, nextFB, COLOR_BLACK); -} +#elif defined(OF_NINTENDO_3DS) + gfxInitDefault(); + atexit(gfxExit); + + consoleInit(GFX_TOP, NULL); #endif +} - (OFSet OF_GENERIC(Class) *)testClasses { Class *classes = objc_copyClassList(NULL); OFMutableSet *testClasses; @@ -208,25 +223,37 @@ if (description != nil) [OFStdOut writeLine: description]; break; } -#ifdef OF_WII if (status == StatusFailed) { +#if defined(OF_WII) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press A to continue"]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) - return; + break; VIDEO_WaitVSync(); } - } +#elif defined(OF_NINTENDO_3DS) + [OFStdOut setForegroundColor: [OFColor silver]]; + [OFStdOut writeLine: @"Press A to continue"]; + + for (;;) { + hidScanInput(); + + if (hidKeysDown() & KEY_A) + break; + + gspWaitForVBlank(); + } #endif + } } - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFSet OF_GENERIC(Class) *testClasses = [self testClasses]; @@ -233,11 +260,11 @@ size_t numSucceeded = 0, numFailed = 0, numSkipped = 0; OFMutableDictionary *summaries = [OFMutableDictionary dictionary]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeString: @"Found "]; -#ifndef OF_WII +#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", testClasses.count]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test case%s\n", @@ -337,47 +364,59 @@ [OFStdOut setForegroundColor: [OFColor blue]]; [OFStdOut writeFormat: @"%@\n", line.secondObject]; } } -#ifndef OF_WII +#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #else [OFStdOut setForegroundColor: [OFColor purple]]; #endif [OFStdOut writeFormat: @"%zu", numSucceeded]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s succeeded, ", (numSucceeded != 1 ? "s" : "")]; -#ifndef OF_WII +#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", numFailed]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s failed, ", (numFailed != 1 ? "s" : "")]; -#ifndef OF_WII +#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) [OFStdOut setForegroundColor: [OFColor fuchsia]]; #endif [OFStdOut writeFormat: @"%zu", numSkipped]; [OFStdOut setForegroundColor: [OFColor purple]]; [OFStdOut writeFormat: @" test%s skipped\n", (numSkipped != 1 ? "s" : "")]; [OFStdOut reset]; -#ifdef OF_WII +#if defined(OF_WII) [OFStdOut setForegroundColor: [OFColor silver]]; [OFStdOut writeLine: @"Press home button to exit"]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) - [OFApplication terminateWithStatus: (int)numFailed]; + break; VIDEO_WaitVSync(); } -#else - [OFApplication terminateWithStatus: (int)numFailed]; +#elif defined(OF_NINTENDO_3DS) + [OFStdOut setForegroundColor: [OFColor silver]]; + [OFStdOut writeLine: @"Press start button to exit"]; + + for (;;) { + hidScanInput(); + + if (hidKeysDown() & KEY_START) + break; + + gspWaitForVBlank(); + } #endif + + [OFApplication terminateWithStatus: (int)numFailed]; } @end