Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -79,17 +79,10 @@ * that don't have a console by default. * * @note This method is only available on Wii, Nintendo DS and Nintendo 3DS. */ + (void)setUpConsole; - -/** - * @brief Waits for the vertical blank of the console. - * - * @note This method is only available on Wii, Nintendo DS and Nintendo 3DS. - */ -+ (void)waitForConsoleVBlank; #endif - (instancetype)init OF_UNAVAILABLE; /** Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -301,38 +301,23 @@ VIDEO_WaitVSync(); CON_InitEx(mode, 2, 2, mode->fbWidth - 4, mode->xfbHeight - 4); VIDEO_ClearFrameBuffer(mode, nextFB, COLOR_BLACK); } - -+ (void)waitForConsoleVBlank -{ - VIDEO_WaitVSync(); -} #elif defined(OF_NINTENDO_DS) + (void)setUpConsole { consoleDemoInit(); } - -+ (void)waitForConsoleVBlank -{ - swiWaitForVBlank(); -} #elif defined(OF_NINTENDO_3DS) + (void)setUpConsole { gfxInitDefault(); atexit(gfxExit); consoleInit(GFX_TOP, NULL); } - -+ (void)waitForConsoleVBlank -{ - gspWaitForVBlank(); -} #endif - (instancetype)init { OF_INVALID_INIT_METHOD Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -244,10 +244,20 @@ /** * @brief Yields a processor voluntarily and moves the thread to the end of the * queue for its priority. */ + (void)yield; + +#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \ + defined(DOXYGEN) +/** + * @brief Waits for the vertical blank. + * + * @note This method is only available on Wii, Nintendo DS and Nintendo 3DS. + */ ++ (void)waitForVerticalBlank; +#endif #ifdef OF_HAVE_THREADS /** * @brief Terminates the current thread, letting it return `nil`. */ Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -40,17 +40,29 @@ # include # undef Class #endif #ifdef OF_WII +# define asm __asm__ # define nanosleep ogc_nanosleep +# include # include # undef nanosleep +# undef asm +#endif + +#ifdef OF_NINTENDO_DS +# define asm __asm__ +# include +# undef asm #endif #ifdef OF_NINTENDO_3DS -# include <3ds/svc.h> +/* Newer versions of libctru started using id as a parameter name. */ +# define id id_3ds +# include <3ds.h> +# undef id #endif #import "OFThread.h" #import "OFThread+Private.h" #ifdef OF_HAVE_ATOMIC_OPS @@ -310,10 +322,27 @@ sched_yield(); #else [self sleepForTimeInterval: 0]; #endif } + +#if defined(OF_WII) ++ (void)waitForVerticalBlank +{ + VIDEO_WaitVSync(); +} +#elif defined(OF_NINTENDO_DS) ++ (void)waitForVerticalBlank +{ + swiWaitForVBlank(); +} +#elif defined(OF_NINTENDO_3DS) ++ (void)waitForVerticalBlank +{ + gspWaitForVBlank(); +} +#endif #ifdef OF_HAVE_THREADS + (void)terminate { [self terminateWithObject: nil]; Index: src/test/OTAppDelegate.m ================================================================== --- src/test/OTAppDelegate.m +++ src/test/OTAppDelegate.m @@ -23,10 +23,11 @@ #import "OFColor.h" #import "OFDictionary.h" #import "OFMethodSignature.h" #import "OFSet.h" #import "OFStdIOStream.h" +#import "OFThread.h" #import "OFValue.h" #import "OTTestCase.h" #import "OFGameController.h" @@ -281,11 +282,11 @@ if ([controller.pressedButtons containsObject: OFGameControllerEastButton]) break; - [OFStdIOStream waitForConsoleVBlank]; + [OFThread waitForVerticalBlank]; objc_autoreleasePoolPop(pool); } #elif defined(OF_NINTENDO_SWITCH) [OFStdOut setForegroundColor: [OFColor silver]]; @@ -562,11 +563,11 @@ if ([controller.pressedButtons containsObject: OFGameControllerStartButton]) # endif break; - [OFStdIOStream waitForConsoleVBlank]; + [OFThread waitForVerticalBlank]; objc_autoreleasePoolPop(pool); } #elif defined(OF_NINTENDO_SWITCH) while (appletMainLoop()) Index: tests/gamecontroller/GameControllerTests.m ================================================================== --- tests/gamecontroller/GameControllerTests.m +++ tests/gamecontroller/GameControllerTests.m @@ -27,11 +27,10 @@ #import "OFNumber.h" #import "OFSet.h" #import "OFStdIOStream.h" #import "OFThread.h" - #if defined(OF_NINTENDO_DS) static size_t buttonsPerLine = 2; #elif defined(OF_NINTENDO_3DS) static size_t buttonsPerLine = 3; #else @@ -132,14 +131,14 @@ } [OFStdOut writeString: @"\n"]; } #if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) - [OFStdIOStream waitForConsoleVBlank]; + [OFThread waitForVerticalBlank]; #else [OFThread sleepForTimeInterval: 1.f / 60.f]; #endif objc_autoreleasePoolPop(pool); } } @end