When an actual N64 application is booted up, it always goes through the procedures explained so far, but if you use NuSystem, you can omit all of these boot processes. This is because NuSystem has a special function called nuBoot that takes charge of all of the necessary processes when booting.
Thanks to nuBoot, the programmer does not have to deal with the boot part of the program, and can start writing from the functions that make up the main thread. In fact, no boot process is described in any of the source files of basic2.
If you are not using NuSystem, then the mainproc function (the main thread) must perform a variety of processes in order to render graphics, but if you leave these processes to NuSystem, then the main thread function becomes very simple, as shown below:
|List 2-3 See basic2 "main.c"|
This source is short and simple, so it should be easy to understand from the comments, but we will explain it below.
nuGfxInit is one of the functions supplied by NuSystem. As its name implies, it performs graphics-related initializations. To be more specific, it registers the framebuffers (which hold the video output images) and the rendering routines (called microcode). We will talk about the microcode in a later chapter.
nuGfxFuncSet sets (the pointer to) the user functions for rendering. The function set here is a so-called callback function that is called repeatedly in time with vertical retrace events. The user sees the result of each rendering process performed in this function as a frame of video output.
nuGfxDisplayOn is the function that allows the rendering result to be output to video. If, on the other hand, the nuGfxDisplayOff function is called, then the entire screen appears black.
In the basic2 sample program, once the vsyncCallback function that performs simple rendering is registered, vsyncCallback is called automatically, and there is nothing else for mainproc to do. So, it enters into an infinite "while" loop.
If you need to use the main thread to perform some process other than rendering, you can just delete the while loop and write the next process.