From CloudModding OoT Wiki

Introduction

The N64's Reality Co-Processor (RCP) is a microcode-reprogrammable GPU, containing two integrated processors known as the Reality Signal Processor (RSP) and the Reality Display Processor (RDP). The RSP is reprogrammable, allowing developers to add extra/custom functionality to the Co-processor. Microcode (sometimes appearing as "ucode", standing for μcode) is thus the set of instructions that can be loaded/executed on the RSP. The RCP is primarily used to graphics processing, with some games using it for audio processing.

Microcode Libraries

Programming for the RCP was greatly simplified via the microcode libraries. The way they works is like so:

Unlike the CPU, which reads machine code from memory and executes it directly, RSP microcodes are designed to parse a binary interface (implemented as a stream of 64 bit "opcodes"), and execute the encoded operations. This way, most N64 programmers did not have to code the RSP directly; instead they would generate a command list they wanted executed, then load up the relevant microcode into the RSP and tell the RCP to process the data.

In order to simplify N64 game development for 3rd party developers, Nintendo and SGI developed their own graphics and audio microcode libraries, which were distributed as part of the N64 SDK. Most N64 games use some iteration or variant of these microcodes, and Zelda64 is no exception.

For graphics, Nintendo developed several different core graphics microcodes for 3D and 2D graphics processing.

  • For 3D graphics, the relevant microcodes in the SDK are Fast3D, F3DEX (Fast3D extended), and F3DEX2 (Fast3D extended 2). All three share a programming interface, a header that defines various macros for generating the graphics binary interface (GBI) for their respective microcodes, allowing developers to swap between them with minimal changes to source code.
    • Fast3D is a full featured microcode, and possibly the first iteration of 3D microcode intended for making 3D games. It was used in demos and early games like Super Mario 64.
    • The F3DEX set of microcodes increases vertex cache and matrix stack size over Fast3D. Additionally, you can select a microcode from the F3DEX that can give you more speed at the cost of functionality.
    • F3DEX2 is a restructured implementation of F3DEX, with the goal of improving the speed of RSP computations. Due to the restructuring, F3DEX2 GBI is significantly different to that of Fast3D and F3DEX
  • For 2D graphics, the relevant microcodes are S2DEX (Sprite 2D extended), and S2DEX2. The S2DEX2 variant is functionally equivalent to S2DEX, and only exists simply to allow F3DEX2 to self load the 2D microcode.

Finalized builds of Ocarina of Time use the following microcodes:

  • F3DZEX2 - a custom variant of F3DEX2. The GBI of F3DZEX2 is identical to F3DEX2, but within the microcode there exist a minor alteration in the implementation of G_BRANCH_Z
  • S2DEX - used in a very limited capacity. The only known usage of S2DEX is within prerendered rooms, in order to display the 2D texture for the top down perspective.

In addition, z_select_static consists of of Fast3D/F3DEX GBI

Microcode Strings

OoT 1.0 (U):

RSP Gfx ucode F3DZEX.NoN  fifo 2.06H Yoshitaka Yasumoto 1998 Nintendo
RSP Gfx[Safe] S2DEX       fifo 2.05  Yoshitaka Yasumoto 1998 Nintendo

Debug Rom:

RSP Gfx ucode F3DZEX.NoN  fifo 2.08J Yoshitaka Yasumoto/Kawasedo 1999
RSP Gfx[Safe] S2DEX       fifo 2.05  Yoshitaka Yasumoto 1998 Nintendo

Note that, despite what the version strings say, Ocarina of Time really does use F3DZEX2; the iQue leak contains files for "Z" variations of many of the N64's standard microcodes, and looking at the version strings inside its "F3DZEX2" microcode files proves that either the developers of the microcode forgot to add the 2 to the name, or that "F3DZEX version 2.xx" was understood as referring to "F3DZEX2".

F3DZEX2

Main article: F3DZEX2

F3DZEX2 is a 3D based graphics microcode, and the primary graphics microcode used by the Zelda 64 engine. F3DZEX2 is based off of the F3DEX2 microcode, sharing the same graphics binary interface.

There are no major differences between 2.06H and 2.08J of the F3DZEX2 microcode.

S2DEX

S2DEX is a 2D based graphics microcode. It is rarely used by the Z64 engine. The only known instance in which is used is to draw rooms with pre-rendered backgrounds from a top-down perspective.

/* 0x0A */ gsSPBgRectCopy(mptr); //mptr points to uObjBg type

Argument Mapping

Microcode Reference Function
0A000000 aaaaaaaaa gsSPBgRectCopy(mptr)

Description

Quickly draws a background image. a is a pointer to a 0x28 byte data structure

Audio

NTSC 1.0 Notes

800E2FC0, size 0x1000

Display List Dump Feature

In the event of a fatal error, the Debug Rom is capable of generating a dump of the entire display list pipeline for the current frame, sending it to the IS64. This dump can be triggered with the following cheat code: 80166D28 0000. Once the dump begins, it's recommended that you set the value back to 0001, since otherwise the game will constantly generate a dump.

Unsorted NTSC 1.0 Microcode Notes

800060B0, size 0x3E8. Sometime cases it seems only 0x160 is transferred
800E2FC0, size 0x1000 //audio
800E3F70, size 0x1000 //F3DZEX2 possibly?
0x40 bytes at address 8012BAC0 is transferred to 04000FC0 //DMEM

This seems to be used to store task data. For example Graphics Context+0x88 stores the data that is later copied to 8012BAC0, which contains the relevant task info

0x3E8 bytes at address 800060B0 is transferred to 04001000 //IMEM

Legacy Credits

cooliscool
ZethAlkar64