"INSIDE NuSystem"

1.1 Preface
1.2 NuSystem Structural Components
1.3 NuSystem Boot Flow
1.4 NuSystem Basic Process Flow
1.5 NuSystem Memory Map

1.1 Preface

NuSystem is a system library that provides device and system managers to manage the routine and repetitive aspects of N64 development for you. Essentially, NuSystem is a miniature version of the N64 operating system. You simply include the appropriate NuSystem files in your application, and NuSystem makes N64 development easier by hiding the initialization part of the N64 operating system and exposing only the event message processes and the absolutely necessary threads.

In addition, NuSystem gives you an Audio Manager to play back audio and an SI Manager to control all the devices that connect to the N64 through the SI (serial interface). The SI Manager works by controlling all the SI device managers including the Controller Manager, the Controller Pak Manager, the EEPROM manager, and the Rumble Pak Manager.

The SI Manager and Audio Manager can be created as application-independent managers without changing the NuSystem source code. NuSystem comes complete with the source code, so you can freely customize it. You can add to the NuSystem functions and improve or change libraries to better fit your needs.

The N64 operating system gives you, the game developer, maximum freedom and control. With that freedom comes responsibility. The N64 OS provides only a bare minimum number of functions in order to minimize the consumption of resources and give applications direct access to the resources. Because processing is independent in N64 threads and messages, the programmer needs to use advanced programming techniques for such things as thread synchronization and exclusive control of data. Luckily, most of the necessary processes are common among game programs, so they can be made into easy-to-use components. That is what NuSystem does for you. NuSystem will help ease the process of learning N64 game development by wrapping many of the details up into the NuSystem components.

NuSystem is designed to help you reduce the amount of effort needed in the initial stage of N64 program development. NuSystem turns complex N64 OS functions into easy-to-use components that you can control by using callback and front-end functions. This makes N64 programming easier. The flexible NuSystem design takes processing speed, memory efficiency, and expandability into consideration. With NuSystem, you can begin a program without touching the complicated aspects of the N64 system.

1.2 NuSystem Structural Components

NuSystem can be broadly divided into the following seven components:

1. Initiator
2. Scheduler
3. Graphics Task Manager
4. Audio Manager
5. SI Manager
6. PI Manager
7. Debug Library

Items 2 through 6 are the main components of NuSystem.

The Graphics Manager, Audio Manager, and SI Manager can be application-independent components in which case the Nusystem components are not included. Figure 1.1 shows the relationship between NuSystem and the N64 operating system.

Figure 1.1 -- Hierarchical Structure of NuSystem and N64 OS

As you can see, NuSystem is situated between the N64 operating system and the application. The application can call the N64 operating system directly or through NuSystem.

1.3 NuSystem Boot Flow

The following figure shows the entire process flow when NuSystem is in use, from the time the N64 power is turned on until the application's entry function (mainproc) is executed:

Figure 1.2 -- NuSystem Boot Flow

As you can see in Figure 1.2, after the power is turned on, the boot entry function (nuBoot) is the first function executed. After the N64 operating system is initialized by the Initiator, the nuBoot function creates and then transfers control to the idle thread. The idle thread starts the Scheduler, initializes the PI, and then creates and executes the thread for the mainproc function, which is the entry point for the application.

1.4 NuSystem Basic Process Flow

Figure 1.3 shows the basic processes flow between NuSystem and the application.

Figure 1.3 -- Process Flow Between NuSystem and Application

Each manager is an independent thread waiting for an event message or a message from your application. These event messages are retrace, PRE-NMI, and end of task. Messages from your application are sent from NuSystem functions.

When a manager receives a message, it checks the type of message and performs the appropriate process. Depending on the situation, it returns a termination message and the data. For example, if the SI Manager receives a retrace message, it uses the serial interface (SI) to read the Controller data. This is done in parallel with application processing.

Note that the application uses NuSystem function calls to gain access to each manager. This is a characteristic of NuSystem. The threads and messages are hidden, and the necessary part of the thread is offered to the application in callback form. If an application prepares a callback function and registers the function pointer in NuSystem, NuSystem (or to be more precise, the manager) executes the corresponding callback function to that event or message.

For example, a device manager like the Controller Manager can use the NuSystem SI Manager to manage devices connected through the SI that require complicated exclusive control thus easing the burden on the application and ensuring exclusive control.

1.5 NuSystem Memory Map

When the nuGfxInit and nuAuInit functions are called at the start of an application, they set the default memory map as shown in figure 4 and proceed to initialize graphics and audio.

Figure 1.4 -- Default Memory Map

The system region is reserved for use by parameter and interrupt vectors. The Z-Buffer is mapped below the code region. RDRAM has a page register in each 1M memory bank, so memory access is faster when the Z-Buffer is separated from the frame buffer. By mapping memory in this way, the application allocates of a wide contiguous region of memory.