CHAPTER 2 HOW TO USE DEVICES CONNECTED TO THE PI

The ROM built into the Game Pak, SRAM and the Disk Drive (64DD) are all devices that connect via the Parallel Interface (PI). This chapter explains how to use each of these devices.


2.1 ROM

ROM stores data that the player cannot overwrite, such as the game program and character data. When data is sent from ROM to RDRAM via the PI, the data is directly transferred without CPU intermediation. This is called a DMA transfer.

When you make direct use of N64 OS functions, you need to initialize and activate the PI Manager before performing DMA transfers from ROM. However, when you use the NuSystem you do not need to call the initialization function because the PI is initialized by the NuSystem.

To read data from ROM use the following function:


Function name: nuPiReadRom
Syntax: void nuPiReadRom(u32 rom_addr, void* buf_ptr, u32 size)
Arguments: rom_addr Transfer origin ROM address
  buf_ptr Pointer to transfer destination buffer
  size Transfer size
Return value: None

The nuPiReadRom function DMA transfers data from the ROM cartridge via the PI to RDRAM. Note that the transfer origin ROM address "rom_addr" must have 2byte alignment and the transfer destination buffer pointer "buf_ptr" must have 8byte alignment. In the sample program (source file "rom.c"), the voice waveform data is DMA-transferred each time the A button is pressed and then sent to the Audio Interface (AI) for playback. In actual game programs, comparatively large sets of data like graphics data must be DMA transferred as well. If a large set of data of this sort is DMA-transferred all at one time, the DMA transfer of the waveform data may be delayed, resulting in the generation of noise. However, with the nuPiReadRom function, audio transfers are never delayed because data is split into 16Kbyte blocks for DMA transfer. When accessing ROM via the nuPiReadRom function, you can use the ROM symbols _nameSegmentRomStart and _nameSegmentRomEnd to compute the ROM address.