   ---- IPL4 README  ----

This is the first version of IPL4. IPL4 is the boot program that is on the
ROM on the disk. If there is no ROM cartridge, then the system will boot 
IPL4 from the disk ROM. The purpose of this program is to boot a game off 
the disk.

The IPL4 program consists of 3 main threads. These are "mainThread", 
"gfxThread", and "diskThread". The main thread starts the graphic thread
and the disk thread. The graphic thread just draws the Nintendo logo until
it is told to stop by the main thread. The disk thread reads the game off the
disk, and places it in the correct spot in main memory. When it finishes 
loading the game, it sends a message to the main thread that the load has
completed.  The main thread then sends the message to the graphics thread
to stop graphics (so that the RSP/RDP are free) and waits for the answer
back. When that messages comes, the main thread calls the boot procedure.
This procedure returns the machine to the same state as at the end of
IPL3 and then jumps to the game. This completes the bootstrap function. All
of the memory that IPL4 used is now available for use by the game. The game
runs, just as if it would have been booted by IPL3 (one exception to this:
IPL3 always transfers one Meg of the game to memory, IPL4 transfers a
variable amount).

I have tested IPL4 by making a version to gload onto the E board. It is 
able to boot a version of onetri. Onetri was placed on the disk using the
leowrite command. The game was put on LBA 5 through LBA 9.


 --- Graphic thread ---

The code for this thread was taken from the Nintendo "ncube" program.
The thread just displays the Nintendo Logo using a simple scheduling
loop. If the main thread sends the graphics thread a stop message, the
graphics thread doesn't create any more RSP tasks. It just drops out
of the while loop and sends a message to the main thread that it is done.

The only interaction between the graphic thread and the disk thread is 
through the global variable "diskState".  Based on the value of this 
variable, "Insert Disk" or "Disk Error" may be displayed. Obviously, Nintendo
will want to change this user interface.

 --- Disk thread ---

The purpose of the disk thread is to read the game off the disk and place
the game at the correct location in memory. The initial code that is here 
should be thrown away and rewritten. Most of the code is fake, temporary
code used to test the rest of IPL4.  A header should be read off the
system area of the disk to get the disk location and size of the boot
portion of the game. The header should also contain the location in main 
memory to place the game and the entry point of the game. Since there is 
no way to place the header in the system area, I created a hardcoded 
IPL4Header stucture. As the integration of IPL4 and the ALPS driver continues,
the IPL4Header structure may change.

The disk thread also uses the old leo library from July 26. It should be
changed to use newer versions of the library. (when the new versions work and
when the API changes)

The only error checking that is performed is to make sure that a disk is
installed. Code needs to be added to make sure that the disk is a valid
bootable disk. Error handling code also needs to be added to take care
of fatal disk errors during the loading phase. This code should be added
after the integration with the new leo library code.


Other notes:

It will be the responsiblity of the "makedisk" program to make sure that
the game does not overlap IPL4. IPL4 uses from megabyte 3 to megabyte 4.
The boot portion of the game cannot be placed in this area.


TO DO LIST:

* Try an EPROM version. (will need to rebuild using correct libraries, 
run through security, ...)

Boot procedure (Boot.c and bootstrap.s):
* Have all the os global variables (osResetType, osTvType, ...) been set
correctly? Do we need to add another variable for boot device?

* What happens with NMI? (Need to burn a ROM to test)

* Check "section 19" from IPL3. Has RSP been halted correctly?

Graphic thread (gfx*.c):
* Does Nintendo want to add audio? If so, I would suggest not yielding 
the graphics task. Calculate the maximum rendering time, and create
a large enough audio buffer to cover that time.

* Need to think about possible race condition between stop message and
retrace message.  (See comment with "XXX")

* Work on user interface - 1) no disk 2) fatal disk error

Disk thread (disk.c, diskbuf.c):
* Cleanup and rewrite.

* Update to new library or libleoipl4 library.

* Update to new API when that is availble

* Add security code, or, is that in libleoipl4?

* May need to modify structure to be placed in system area. (IPL4Header)

* Implement error handling. (For example, what happens if you eject disk 
during loading phase?)

* Could be made faster by reading more than one block at a time.
