/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ //////////////////////////////////////////////////// // // Helper functions // //////////////////////////////////////////////////// // Returns darker or lighter with a higher status (opposite brightness if status == -1) CVec4 WhiteDarker(int status) {if (status == -1) return CVec4(0, 0, 0, 1.0); /* else */ return CVec4(0.8 - 0.2 * status, 0.8 - 0.2 * status, 0.8 - 0.2 * status, 1.0);} CVec4 BlackLighter(int status) {if (status == -1) return CVec4(0.6, 0.6, 0.6, 1.0); /* else */ return CVec4(0.05 + 0.1 * status, 0.05 + 0.1 * status, 0.05 + 0.1 * status, 1.0);} // Literally does nothing void DoNothing() {} void DoNothingVoidP(void*) {} // Does nothing, returns true bool BoolDoNothing() {return true;} bool BoolDoNothingVoidP(void*) {return true;} // Returns if the values are close bool CloseEnough(float a, float b) { if (a - b > 0.1) return false; return (a - b >= -0.1); } // Takes the core as 0, 1, or 2 and turns it into the value the system wants (1, 2, 4) int GetCore(int core) { switch (core) { case 0: core = OS_THREAD_ATTR_AFFINITY_CORE0; break; case 1: core = OS_THREAD_ATTR_AFFINITY_CORE1; break; case 2: core = OS_THREAD_ATTR_AFFINITY_CORE2; break; default: OSHalt("Invalid core chosen!"); } return core; } // A "safe" version of strcat char* strcat_s(char* dest, int len, const char* src) { dest[len - 1] = 0; strcat(dest, src); ASSERT(dest[len - 1] == 0); return dest; } // A "safe" version of strcpy char* strcpy_s(char* dest, int len, const char* src) { dest[len - 1] = 0; strcpy(dest, src); ASSERT(dest[len - 1] == 0); return dest; } // A "safe" version of sprintf int sprintf_s(char* dest, int len, const char* src, ...) { dest[len - 1] = 0; va_list args; va_start (args, src); int count = vsprintf(dest, src, args); va_end (args); ASSERT(dest[len - 1] == 0); return count; } // A "safe" version of vsprintf int vsprintf_s(char* dest, int len, const char* src, va_list list) { dest[len - 1] = 0; int count = vsprintf(dest, src, list); ASSERT(dest[len - 1] == 0); return count; }