# OS_IsRunOnTwl

## Syntax

  `#include <nitro/os.h>`
  `BOOL OS_IsRunOnTwl( void );`

## Arguments

None.

## Return Values

If `TRUE`, the application is running in TWL mode. The actual operating environment may be either an actual TWL system or the IS-TWL-DEBUGGER hardware.

If `FALSE`, the application is running in some other mode (that is, in NITRO mode). The actual operating environment may be either an actual NITRO console or IS-NITRO-DEBUGGER. This also applies to the case of running an application in NITRO mode on IS-TWL-DEBUGGER.

## Description

Determines whether the program is running in TWL mode.

The `OS_IsRunOnTwl` function determines the operating mode. It does not determine the operating environment. For example, this function will sometimes return `TRUE` and sometimes return `FALSE`, even though the application is running on the IS-TWL-DEBUGGER hardware in both cases. In other words, programs run on IS-TWL-DEBUGGER will sometimes be run in TWL mode and will sometimes be run in NITRO mode.

`OS_IsRunOnTwl` is a useful function when creating TWL/NITRO hybrid ROMs. Hybrid ROMs will run in TWL mode on TWL, and in NITRO mode on NITRO. This function will return `TRUE` when run on a TWL, and `FALSE` when run on NITRO. This can be used to switch between code dynamically.

Example: How to Split Up Code That Supports NITRO/TWL Hybrid ROMs

> `if ( OS_IsRunOnTwl() )
> {
> // Code you want to run in TWL mode
> }
> else
> {
> // Code you want to run in NITRO mode
> }`

Also, while this will not be a very common case during normal development, you can use code like the following to match the `#define` directives defined for the SDK during development of libraries that support all three types of ROMs (NITRO-exclusive, TWL-exclusive, and NITRO/TWL hybrid). This code could be included in the library's source code.

Example: How to Split Up Code That Supports NITRO-Exclusive ROMs, TWL-Exclusive ROMs, and NITRO/TWL Hybrid ROMs

> `if ( OS_IsRunOnTwl() )
> {
> #ifdef SDK_TWL
> // Code you want to run in TWL mode
> #endif
> }
> else
> {
> #ifndef SDK_TWLLTD
> // Code you want to run in NITRO mode
> #endif
> }`

The `OS_IsRunOnTwl` function determines the platform at run time for hybrid ROMs, but for NITRO-exclusive ROMs, it will return the constant `FALSE`, and for TWL-exclusive ROMs, it will return the constant `TRUE`. When creating NITRO-exclusive ROMs or TWL-exclusive ROMs, you can expect the cases that do not match the conditions of the `if` statement to be deadstripped. However, we have used `SDK_TWL` (defined at compile time for TWL-exclusive ROMs and NITRO/TWL hybrid ROMs) and `SDK_TWLLTD` (defined at compile time for TWL-exclusive ROMs) to avoid undefined errors and other problems with functions appearing in the code that will be deadstripped.

### Actual Values Due to the Environment:

Below is a list of values that can be returned by the `OS_IsRunOnTwl` function. There are no differences as a result of the build type (DEBUG, RELEASE, FINALROM).

For NITRO Mode
Operating Environment | Value of `OS_IsRunOnTwl`
--- | ---
Actual DS unit | FALSE
Actual TWL unit | FALSE
IS-NITRO-DEBUGGER | FALSE
ENSATA EMULATOR | FALSE
IS-TWL-DEBUGGER (For standard development: ARM9) | FALSE
IS-TWL-DEBUGGER (For component development ARM9 + ARM7) | FALSE
For TWL Mode
Operating Environment | Value of `OS_IsRunOnTwl`
Actual TWL unit | TRUE
IS-TWL-DEBUGGER (For standard development: ARM9) | TRUE
IS-TWL-DEBUGGER (For component development ARM9 + ARM7) | TRUE

## Internal Operation

Makes the judgment based the value in the System Configuration register.

## See Also

`OS_Printf`
`OS_GetConsoleType`

## Revision History

2007/11/16 Added information.
2007/11/06 Initial version.

CONFIDENTIAL