From CloudModding OoT Wiki
(Redirected from F3DZEX/Opcode Details)
This is a sub-page of F3DZEX2.

This is a detailed explanation of all the opcodes known in F3DZEX2. Parameters are explained in terms of various macros N64 programmers had access to, since those parameters will in quite a few cases be easier to describe than their raw GBI form.

Contents

0x00G_NOOP

Argument Mapping

Microcode Reference Function
00000000 tttttttt gsDPNoOp()
gsDPNoOpTag(tag)
Function Param To Microcode From Microcode Explanation
tag tag tttttttt Pointer to a string tag

Description

Does nothing except stall the RDP for a few cycles. Typically used in debugging. In the Z64 games (specifically the debug builds), tag is set to a pointer to a string commenting the display list, which would then likely be output when calling the SDK's guParseGbiDL function.

0x01G_VTX

Argument Mapping

Microcode Reference Function
010nn0aa vvvvvvvv gsSPVertex(vaddr, numv, vbidx)
Function Param To Microcode From Microcode Explanation
numv numv nn Number of vertices to load
vbidx ((vbidx + numv) & 0x7F) << 1 aa >> 1 - nn Index of vertex buffer to begin storing vertices to.
vaddr vaddr vvvvvvvv Address of vertices

Description

Loads numv vertices from address vaddr to the RSP's vertex buffer, starting at buffer index vbidx. For F3DEX2.NoN, numv must be in the range 1 ≤ numv ≤ 32, and vbidx in the range 0 ≤ vbidx ≤ 31. Vertex transformations and lighting calculations (if any) are calculated upon load.

0x02G_MODIFYVTX

Argument Mapping

Microcode Reference Function
02wwnnnn vvvvvvvv gsSPModifyVertex(vbidx, where, val)
Function Param To Microcode From Microcode Explanation
where where ww Enumerated set of values specifying what to change
vbidx vbidx * 2 nnnn / 2 Vertex buffer index of vertex to modify
val val vvvvvvvv New value to insert

Description

Modifies a four-byte portion of the vertex specified by vbidx. The portion modified is specified by where, and the new value is given in val. Lighting calculations (if enabled) and position transformations are not calculated by the RSP after use of this command, so modifications modify final color and vertices.

The valid values for where have names as follows:

  • G_MWO_POINT_RGBA = 0x10 Modifies the color of the vertex
  • G_MWO_POINT_ST = 0x14 Modifies the texture coordinates
  • G_MWO_POINT_XYSCREEN = 0x18 Modifies the X and Y position
  • G_MWO_POINT_ZSCREEN = 0x1C Modifies the Z position (lower four nybbles of val should always be zero for this modification)

The exact nature of these values is unclear. The SDK documentation describes them as "byte offsets", however they don't match offsets in the vertex structure (see below).

0x03G_CULLDL

Argument Mapping

Microcode Reference Function
0300vvvv 0000wwww gsSPCullDisplayList(vfirst, vlast)
Function Param To Microcode From Microcode Explanation
vfirst vfirst * 2 vvvv / 2 Vertex buffer index of first vertex for bounding volume
vlast vlast * 2 wwww / 2 Vertex buffer index of last vertex for bounding volume

Description

This command takes the vertices in the vertex buffer from vfirst through vlast as describing the volume of the object being rendered (called the "bounding value"). If the bounding volume does not intersect with the current viewing volume (aka if the bounding volume is entirely offscreen), then the display list ends, equivalent to a DF opcode. Otherwise, the display list continues as though nothing happened (equivalent to 00, then).

For F3DEX2.NoN, Each of vfirst and vlast must be in the range 0 ≤ x ≤ 31. Additionally, vfirst < vlast must be true (thus a minimum of two vertices must be specified, and range of vertices cannot be reversed). It's not specified what the behavior is when all the vertices are coplanar.

0x04G_BRANCH_Z

Argument Mapping

Microcode Reference Function
E1000000 dddddddd
04aaabbb zzzzzzzz
gsSPBranchLessZraw(newdl, vbidx, zval)
Function Param To Microcode From Microcode Explanation
newdl newdl dddddddd Address of display list to branch to
vbidx vbidx * 5 aaa / 5 Vertex buffer index of vertex to test
vbidx vbidx * 2 bbb / 2 Vertex buffer index of vertex to test
zval zval zzzzzzzz Z value to test against

Description

Tests the Z value of the vertex at buffer index vbidx (described as vbidx.z here) against zval. If vbidx.z ≤ zval, then the processor switches over to the display list at address newdl (equivalent to gsSPBranchList(newdl)). Otherwise continues through the display list. Useful for LOD-related model processing, where several occurrences of this can be stacked to branch to progressively closer versions of the model.

Note that the 04 opcode actually pulls the address of the branching display list from the high half of the "RDP word" (16 bytes used for generic value storage, as far as is known). The italicized opcode given above is set by the "basic function" listed for this opcode, immediately before the actual 04 opcode.

Although not stated in the documentation, vbidx is presumably limited to the range 0 ≤ vbidx ≤ 31 just like other buffer indices. It's unknown why the opcode needs vbidx twice, and multiplied by different amounts.

Also, zval is usually calculated for the N64 programmer (only the *Zraw form specifies a raw zval). The formula used in these cases is as shown, written as C code:

#include <stdint.h>

int32_t FTOFIX32(float x) {
    return (int32_t)(x * 0x00010000);
}

// note: parameter types taken from docs on gSPBranchLessZrg(...)
uint32_t calcZVal(float zval, int32_t flag, float near, float far, int32_t zmin, int32_t zmax) {
    float part1 = (flag == G_BZ_PERSP)
                ? (1.0f - near / zval) / (1.0f - near / far)
                : (zval - near) / (far - near);
    return (uint32_t)FTOFIX32(part1) * ((zmax - zmin) & ~1) + FTOFIX32((float)zmin);
}

Where zval is the Z value the programmer is thinking of comparing against (whereas the "real" Z value handed to the opcode is calculated by this function), near and far denote the distances of the near and far clipping planes, respectively, from the viewpoint. zmin and zmax are the minimum and maximum posible Z values, respectively. flag decides on the projection, taking either of these enumerations:

  • G_BZ_PERSP = 0
  • G_BZ_ORTHO = 1

As their names would suggest, PERSP handles perspective projection, ORTHO handles orthographic.

Note that in a default setup, zmin is 0, and zmax is 0x03FF.

This formula cannot be reversed for the value provided in the microcode, since the necessary information is absent. (Since the values are provided in the macro call generating this opcode, there's no guarantee any of the values match what they're "supposed" to be, e.g. near could be set to something far different from the location of the actual near clipping plane.)

0x05G_TRI1

Argument Mapping

Microcode Reference Function
05aabbcc 00000000 gsSP1Triangle(v0, v1, v2, flag)
Function Param To Microcode From Microcode Explanation
(v0|v1|v2) (v0|v1|v2) * 2 (aa|bb|cc) / 2 Vertex buffer index of one vertex of the triangle

Description

Draws one triangle to screen. v0, v1, and v2 specify vertex buffer indices, all in the range 0 ≤ v ≤ 31 for F3DEX2.NoN.

Vertices are drawn in the order aa -> bb -> cc. aa is considered the "primary" vertex of the triangle, which matters in certain situations (for example, its color is taken as the color of the whole triangle when doing flat shading).

The given macro (gsSP1Triangle) reorders its arguments depending on the value of flag (which is why the argument listing above is generalized). It can be seen as choosing the primary vertex:

flag == 0 
aa = v0, bb = v1, cc = v2
flag == 1 
aa = v1, bb = v2, cc = v0
flag == 2 
aa = v2, bb = v0, cc = v1

0x06G_TRI2

Argument Mapping

Microcode Reference Function
06aabbcc 00ddeeff gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1)
Function Param To Microcode From Microcode Explanation
(v00|v01|v02) (v00|v01|v02) * 2 (aa|bb|cc) / 2 Vertex buffer index of one vertex of the first triangle
(v10|v11|v12) (v10|v11|v12) * 2 (dd|ee|ff) / 2 Vertex buffer index of one vertex of the first triangle

Description

Draws two triangles at once. All six given indices must be in the range 0 ≤ v ≤ 31 for F3DEX2.NoN.

The first triangle is drawn in the order aa -> bb -> cc, with aa being the "primary" vertex. The second triangle is similar, drawn in dd -> ee -> ff order and dd being its "primary" vertex.

flag0 reorders the vertices for the first triangle, and flag1 reorders them for the second triangle. Either flag works as such:

flagX == 0 
aa = vX0, bb = vX1, cc = vX2
flagX == 1 
aa = vX1, bb = vX2, cc = vX0
flagX == 2 
aa = vX2, bb = vX0, cc = vX1

0x07G_QUAD

Argument Mapping

Microcode Reference Function
07aabbcc 00aaccdd gsSPQuadrangle(v0, v1, v2, v3, flag)
Function Param To Microcode From Microcode Explanation
(v0|v1|v2|v3) (v0|v1|v2|v3) * 2 (aa|bb|cc|dd) / 2 Vertex buffer index of one vertex of the quadrangle

Description

Draws a quadrangle, as two triangles. All four vertex indices are in the range 0 ≤ v ≤ 31 for F3DEX2.NoN.

The macro given takes the four vertices and rearranges them according to flag, and as per the opcode writes it as two triangles. The draw order is aa -> bb -> cc for the first triangle, aa -> cc -> dd, with aa being the "primary" vertex for both (thus maintaining a single "primary" vertex for the quadrangle). Both occurrences of aa should be equal, as well as both of cc, since the purpose of this opcode is to draw a quadrilateral polygon.

The flag determines the vertices as such:

flag == 0 
aa = v0, bb = v1, cc = v2, dd = v3
flag == 1 
aa = v1, bb = v2, cc = v3, dd = v0
flag == 2 
aa = v2, bb = v3, cc = v0, dd = v1
flag == 3 
aa = v3, bb = v0, cc = v1, dd = v2

Note: This opcode is functionally equivalent to opcode 06. The macro for this opcode (and thus presumably also the opcode itself) is labeled as no longer supported in Oct 1999 SDK documentation. If you're making new display lists to import into OoT, use 06 instead of this.

0xD3G_SPECIAL_3

Argument Mapping

Microcode Reference Function
D3?????? ???????? G_SPECIAL_3 (no function known)

No arguments for this opcode

Description

Appears to be an explicitly reserved command.

0xD4G_SPECIAL_2

Argument Mapping

Microcode Reference Function
D4?????? ???????? G_SPECIAL_2 (no function known)

No arguments for this opcode

Description

Appears to be an explicitly reserved command.

0xD5G_SPECIAL_1

Argument Mapping

Microcode Reference Function
D5?????? ???????? G_SPECIAL_1 (no function known)

No arguments for this opcode

Description

Appears to be an explicitly reserved command.

0xD6G_DMA_IO

Argument Mapping

Microcode Reference Function
D6___sss rrrrrrrr
___ -> fmmm mmmm mmm0 (binary)
gsSPDma_io(flag, dmem, dram, size)
Function Param To Microcode From Microcode Explanation
flag flag & 0x01 f Chooses between read or write
dmem dmem / 8 & 0x3FF mmm mmmm mmm * 8 Address in DMEM/IMEM(?)
size size - 1 sss + 1 (Presumably) size of data to transfer
dram dram rrrrrrrr DRAM address

Description

Does a DMA between DMEM/IMEM address dmem and DRAM address dram. size bytes are presumably transfered in the process. flag determines the type of transfer. Apparently:

  • flag == 0 — Read from DMEM/IMEM to DRAM
  • flag == 1 — Write DRAM to DMEM/IMEM

The exact nature of this command is unclear, since none of this opcode's macros are documented, and the only available comment suggests this is a debugging tool only. Therefore, you should not expect to see this in production code.

0xD7G_TEXTURE

Argument Mapping

Microcode Reference Function
D700____ sssstttt
____ -> 00LL Lddd nnnn nnn0 (binary)
gsSPTexture(scaleS, scaleT, level, tile, on)
Function Param To Microcode From Microcode Explanation
level level & 0x07 LL L Maximum number of mipmap levels aside from the first
tile tile & 0x07 ddd Tile descriptor number
on on & 0x7F n Decides whether to turn the given texture on or off
scaleS scaleS ssss Scaling factor for the S-axis (horizontal)
scaleT scaleT tttt Scaling factor for the T-axis (vertical)

Description

This opcode enables or disables various tile descriptors, and sets the maximum number of mipmap levels and scaling factor for the texture.

tile is the tile descriptor number being modified by the opcode. level is the maximum number of mipmap levels minus one, (so e.g. a level of zero means at most one mipmap). The scaleS and scaleT parameters set scaling factors for the tile descriptor.

If on is set to 0, then the tile descriptor is disabled, and none of the other parameters are actually applied. If on is set to 1, then the tile descriptor is enabled and the previously-mentioned parameters are applied.

Note that scaleS and scaleT are binary fractional values with an implied 0.; for example, a scaleS of 0x8000 means 0b0.1000_0000_0000_0000, or 0d0.5.

0xD8G_POPMTX

Argument Mapping

Microcode Reference Function
D8380002 aaaaaaaa gsSPPopMatrixN(which, num)
Function Param To Microcode From Microcode Explanation
num num * 64 aaaaaaaa / 64 The number of matrices to pop
which Ignored Ignored Specifies which matrix stack to pop from

Description

Pops num matrices from the stack specified by which

which can be either of:

  • G_MTX_MODELVIEW = 0x00
  • G_MTX_PROJECTION = 0x04

However, since the projection matrix "stack" isn't actually a stack, the which parameter is silently ignored and always assumes the modelview matrix stack.

0xD9G_GEOMETRYMODE

Argument Mapping

Microcode Reference Function
D9cccccc ssssssss gsSPGeometryMode(clearbits, setbits)
Function Param To Microcode From Microcode Explanation
clearbits ~clearbits ~cccccc Geometry mode bits to clear
setbits setbits ssssssss Geometry mode bits to set

Description

Changes the various mode bits of the RSP's geometry mode. This opcode can clear and set bits at once.

Assuming G to stand for the geometry mode bits, this command performs the equivalent of

   G = (G & ~clearbits) | setbits

That is, keeps only the bits that aren't meant to be cleared, and then sets the bits that are meant to be set. See below for a list of what the geometry mode bits mean.

0xDAG_MTX

Argument Mapping

Microcode Reference Function
DA3800pp mmmmmmmm gsSPMatrix(mtxaddr, params)
Function Param To Microcode From Microcode Explanation
params params ^ G_MTX_PUSH pp ^ G_MTX_PUSH Parameters controlling nature of matrix addition
mtxaddr mtxaddr mmmmmmmm RAM address of new matrix

Description

Adds a new matrix from mtxaddr to the appropriate matrix stack.

params are a bitfield with the following options:

  • G_MTX_NOPUSH = 0x00
  • G_MTX_PUSH = 0x01
  • G_MTX_MUL = 0x00
  • G_MTX_LOAD = 0x02
  • G_MTX_MODELVIEW = 0x00
  • G_MTX_PROJECTION = 0x04

NOPUSH and PUSH, MUL and LOAD, and MODELVIEW and PROJECTION are exclusive pairs of options. NOPUSH, MUL, and MODELVIEW are "default options", and are named just as programmer convenience, to explicitly state choices.

If PUSH is specified, then the matrix will be added to the top of the stack as a new stack element. If there is no room on the stack, this option is ignored and NOPUSH behavior occurs instead. NOPUSH means the top matrix of the stack will be overwritten with the new matrix.

If MUL is specified, the new matrix is multiplied by the top of the stack before being placed according to PUSH/NOPUSH. Specifically the matrix product of new matrix * top of the stack (XXX verify this is the right order, since matrix multiplication ain't commutative). LOAD means no multiplication is done against the new matrix.

MODELVIEW selects the modelview matrix stack (meaning the new matrix is a modelview matrix), while PROJECTION refers to the projection matrix "stack". Since the projection matrix "stack" is not actually a stack, rather a single matrix, the PUSH option is always ignored for new projection matrices.

0xDBG_MOVEWORD

Argument Mapping

Microcode Reference Function
DBiioooo dddddddd gsMoveWd(index, offset, data)

gsSPSegment(segment, base)

Function Param To Microcode From Microcode Explanation
index index ii Index into DMEM pointer table(?)
offset offset oooo Offset from the indexed base address(?)
data data dddddddd New 32-bit value

Description

Loads a new 32-bit value data to the location specified by index and offset.

index is an index into a table of DMEM addresses. The enumerations given for this for F3DEX2 are:

Define Value
G_MW_MATRIX 0x00
G_MW_NUMLIGHT 0x02
G_MW_CLIP 0x04
G_MW_SEGMENT 0x06
G_MW_FOG 0x08
G_MW_LIGHTCOL 0x0A
G_MW_FORCEMTX 0x0C
G_MW_PERSPNORM 0x0E

The offset is, as the name suggests, an offset from the address that index resolves to. G_MWO_SEGMENT_# does not follow this rule, and is expected to be used with the gsSPSegment macro. Enumerations are also provided for this value, for each of the enumerated index values.

Values

Define Value
G_MWO_NUMLIGHT 0x00
G_MWO_CLIP_RNX 0x04
G_MWO_CLIP_RNY 0x0c
G_MWO_CLIP_RPX 0x14
G_MWO_CLIP_RPY 0x1c
G_MWO_SEGMENT_0 0x00
G_MWO_SEGMENT_1 0x01
G_MWO_SEGMENT_2 0x02
G_MWO_SEGMENT_3 0x03
G_MWO_SEGMENT_4 0x04
G_MWO_SEGMENT_5 0x05
G_MWO_SEGMENT_6 0x06
G_MWO_SEGMENT_7 0x07
G_MWO_SEGMENT_8 0x08
G_MWO_SEGMENT_9 0x09
G_MWO_SEGMENT_A 0x0a
G_MWO_SEGMENT_B 0x0b
G_MWO_SEGMENT_C 0x0c
G_MWO_SEGMENT_D 0x0d
G_MWO_SEGMENT_E 0x0e
G_MWO_SEGMENT_F 0x0f
G_MWO_FOG 0x00
G_MWO_aLIGHT_1 0x00
G_MWO_bLIGHT_1 0x04
G_MWO_aLIGHT_2 0x18
G_MWO_bLIGHT_2 0x1c
G_MWO_aLIGHT_3 0x30
G_MWO_bLIGHT_3 0x34
G_MWO_aLIGHT_4 0x48
G_MWO_bLIGHT_4 0x4c
G_MWO_aLIGHT_5 0x60
G_MWO_bLIGHT_5 0x64
G_MWO_aLIGHT_6 0x78
G_MWO_bLIGHT_6 0x7c
G_MWO_aLIGHT_7 0x90
G_MWO_bLIGHT_7 0x94
G_MWO_aLIGHT_8 0xa8
G_MWO_bLIGHT_8 0xac
G_MWO_MATRIX_XX_XY_I 0x00
G_MWO_MATRIX_XZ_XW_I 0x04
G_MWO_MATRIX_YX_YY_I 0x08
G_MWO_MATRIX_YZ_YW_I 0x0c
G_MWO_MATRIX_ZX_ZY_I 0x10
G_MWO_MATRIX_ZZ_ZW_I 0x14
G_MWO_MATRIX_WX_WY_I 0x18
G_MWO_MATRIX_WZ_WW_I 0x1c
G_MWO_MATRIX_XX_XY_F 0x20
G_MWO_MATRIX_XZ_XW_F 0x24
G_MWO_MATRIX_YX_YY_F 0x28
G_MWO_MATRIX_YZ_YW_F 0x2c
G_MWO_MATRIX_ZX_ZY_F 0x30
G_MWO_MATRIX_ZZ_ZW_F 0x34
G_MWO_MATRIX_WX_WY_F 0x38
G_MWO_MATRIX_WZ_WW_F 0x3c
G_MWO_POINT_RGBA 0x10
G_MWO_POINT_ST 0x14
G_MWO_POINT_XYSCREEN 0x18
G_MWO_POINT_ZSCREEN 0x1c

0xDCG_MOVEMEM

Argument Mapping

Microcode Reference Function
DCnnooii aaaaaaaa gsMoveMem(size, index, offset, address)
Function Param To Microcode From Microcode Explanation
size ((size - 1) / 8 & 0x1F) << 3 ((nn >> 3) + 1) * 8 Size in bytes of memory to be moved
offset offset / 8 oo * 8 Offset from indexed base address
index index ii Index into table of DMEM addresses
address address aaaaaaaa RAM address of memory

Description

Transfers a block of data from RDRAM to DMEM, in 8 byte chunks. Size is the number of bytes to copy from RDRAM address, placing it at the DMEM location pointed to by index, plus offset.

index is an index into a table of addresses of DMEM. Given enumerations for index are:

  • G_MV_MMTX = 2
  • G_MV_PMTX = 6
  • G_MV_VIEWPORT = 8
  • G_MV_LIGHT = 10
  • G_MV_POINT = 12
  • G_MV_MATRIX = 14

Note however that only VIEWPORT, LIGHT, and MATRIX are used by any of the macros given to programmers.

offset is, as the name would suggest, an offset from the address index resolves to. This could be anything, though a couple enumerations are provided. (XXX list them here or elsewhere?)

Also note that the function gsMoveMem is imaginary: all of the macros that use this opcode do so directly, as opposed to going through another function. Since no general macro exists for this opcode, gsMoveMem was invented for illustrative purposes.

0xDDG_LOAD_UCODE

Argument Mapping

Microcode Reference Function
E1000000 dddddddd
DD00ssss tttttttt
gsSPLoadUcodeEx(tstart, dstart, dsize)
Function Param To Microcode From Microcode Explanation
dstart dstart dddddddd Start of data section
dsize dsize ssss Size of data section
tstart tstart tttttttt Start of text section

Description

Loads a new microcode executable into the RSP, with pointers dstart to the start of the data section and tstart to the start of the text section, with dsize specifying the size of the data section. After loading the new microcode, the RCP is reset as appropriate.

Note that dstart is stored in the high half of the "RDP word", the opcode for which is shown in italics before the actual DD opcode.

0xDEG_DL

Argument Mapping

Microcode Reference Function
DEpp0000 dddddddd gsSPDisplayList(dl)
gsSPBranchList(dl)
Function Param To Microcode From Microcode Explanation
pp determined by choice of function; see below
dl dl dddddddd Address of new display list to jump to

Description

Tells the RDP to switch over to the display list at address dl. pp mentions what will happen when the end of the new display list is reached.

If pp is set to zero (using gsSPDisplayList), then the current address the display list processor is at is pushed to a display list address stack before switching over. This means execution returns at this point after the new display list is done.

If pp is set to one (using gsSPBranchList), then the current address isn't saved, meaning execution can't return to this point after the new display list is done. (It will instead return to the existing top of the address stack, if any addresses are there.)

0xDFG_ENDDL

Argument Mapping

Microcode Reference Function
DF000000 00000000 gsSPEndDisplayList()

No arguments for this opcode

Description

Ends the current display list. At this point execution will return to the address of the top of the display list address stack. If there are no addresses in this stack, that's the end of graphics processing, until the RCP is asked to do more.

0xE0G_SPNOOP

Argument Mapping

Microcode Reference Function
E0000000 00000000 gsSPNoOp()

No arguments for this opcode

Description

Does nothing. Seemingly different from 00; judging by the names of this opcode and 00, this opcode stalls the RSP, whereas the other stalls the RDP.

0xE1G_RDPHALF_1

Argument Mapping

Microcode Reference Function
E1000000 hhhhhhhh gsDPWord(wordhi, wordlo)
Function Param To Microcode From Microcode Explanation
wordhi wordhi hhhhhhhh New value of high word

Description

This opcode sets the higher half of the generic RDP word to wordhi.

Note: the referenced function also generates opcode F1 (which uses wordlo). See the section on F1 for info on that.

0xE2G_SETOTHERMODE_L

Argument Mapping

Microcode Reference Function
E200ssnn dddddddd gsSPSetOtherMode(0xE2, shift, length, data)
Function Param To Microcode From Microcode Explanation
shift 32 - shift - length 32 - (nn + 1) - ss Amount data is shifted by, or number of LSb of mode bits to be changed
length length - 1 nn + 1 Size of data affected, in bits
data data dddddddd New bit settings to be applied

Description

Modifies various bits of the lower half of the RDP Other Modes word. Various enumerations are provided for shift and data.

The operation performed by the opcode can be expressed as such, assuming LO to stand for the lower word of the RDP other modes:

   LO =  LO & ~(((1 << length) - 1) << shift) | data

Or, in English, it clears all the bits designated to be modified (determined by shift and length), and then sets those bits according to data. Important to note that data is preshifted. That is, it is up to the caller to shift data appropriately. The enumerations provided for data are pre-shifted to match this requirement.

The enumerations provided for shift are:

  • G_MDSFT_ALPHACOMPARE = 0
  • G_MDSFT_ZSRCSEL = 2
  • G_MDSFT_RENDERMODE = 3

The structure of the lower modes is provided in the main page.

0xE3G_SETOTHERMODE_H

Argument Mapping

Microcode Reference Function
E300ssnn dddddddd gsSPSetOtherMode(0xE3, shift, length, data)
Function Param To Microcode From Microcode Explanation
shift 32 - shift - length 32 - (nn + 1) - ss Amount data is shifted by, or number of LSb of mode bits to be changed
length length - 1 nn + 1 Size of data affected, in bits
data data dddddddd New bit settings to be applied

Description

Modifies the various bits of the high half of the RDP Other Modes word. Enumerations are provided for shift and data.

Like with E2, data is preshifted, and the opcode's procedure can be formulized in the same way (where OH stands for the high word of the other modes):

   HO =  HO & ~(((1 << length) - 1) << shift) | data

The enumerations for shift are as follows:

  • G_MDSFT_BLENDMASK = 0
  • G_MDSFT_ALPHADITHER = 4
  • G_MDSFT_RGBDITHER = 6
  • G_MDSFT_COMBKEY = 8
  • G_MDSFT_TEXTCONV = 9
  • G_MDSFT_TEXTFILT = 12
  • G_MDSFT_TEXTLUT = 14
  • G_MDSFT_TEXTLOD = 16
  • G_MDSFT_TEXTDETAIL = 17
  • G_MDSFT_TEXTPERSP = 19
  • G_MDSFT_CYCLETYPE = 20
  • G_MDSFT_COLORDITHER = 22
  • G_MDSFT_PIPELINE = 23

The layout of the high word is describe in the main page.

0xE4G_TEXRECT

Argument Mapping

Microcode Reference Function
E4xxxyyy 0iXXXYYY
E1000000 sssstttt
F1000000 ddddeeee
gsSPTextureRectangle(ulx, uly, lrx, lry, tile, uls, ult, dsdx, dtdy)
Function Param To Microcode From Microcode Explanation
lrx lrx xxx Lower-right corner X coordinate
lry lry yyy Lower-right corner Y coordinate
tile tile i Tile descriptor to use for rectangle
ulx ulx XXX Upper-left corner X coordinate
uly uly YYY Upper-left corner Y coordinate
uls uls ssss Texture S coordinate at upper-left corner
ult ult tttt Texture T coordinate at upper-left corner
dsdx dsdx dddd Change in S coordinate over change in X coordinate
dtdy dtdy eeee Change in T coordinate over change in Y coordinate

Description

Draws a textured rectangle from screen coordinates (ulx,uly) to (lrx, lry), using the texture specified by tile to color the rectangle. The texture is positioned using (uls, ult) as the texture coordinate of (ulx, uly), and changing the texture coordinates with the use of dsdx and dtdy.

ulx, uly, lrx, and lry are 12-bit numbers in a fixed point 10.2 format, giving a range of 0 ≤ n ≤ 1023.75 for each value (with 0b0.01 / 0d0.25 precision). This means that the coordinates cannot reference the framebuffer past a 1024-pixel square, if the framebuffer exceeds those limits in either dimension.

tile refers to any of the eight tile descriptors whose texture will be used on the rectangle. uls and ult specify the S and T coordinate, respectively, of the upper-left corner of the rectangle. uls and ult are in signed fixed point 10.5 format, giving a range -1024 ≤ n ≤ 1023.96875 for each value (with 0b0.00001 / 1/32 precision).

The texture coordinates for other parts of the rectangle are calculated via dsdx and dtdy, which are in signed fixed point 5.10 format, giving a range of -32 ≤ n ≤ 31.999023 (with 0b0.0000000001 / 1/1024 precision). These parameters change the S coordinate per a change of 1.0 in the X coordinate of the rectangle, and the T coordinate per change of 1.0 in the Y coordinate (XXX not entirely sure on what the 'per change's are, but 1.0 seems reasonable).

Important to note that using this opcode requires setting the texture parameters in the high and low words of the RDP after this opcode, which the given function gsSPTextureRectangle does (extra instructions in italics above).

An alternate version of this command exists as gsDPTextureRectangle. It takes the same parameters, but generates a 128-bit opcode, twice the size of other opcodes:

   E4xxxyyy 0iXXXYYY sssstttt ddddeeee

However, this version isn't documented in the SDK's function reference, and it seems to be an outdated or otherwise unusual variant. Therefore this version seems unlikely.

0xE5G_TEXRECTFLIP

Argument Mapping

Microcode Reference Function
E5xxxyyy 0iXXXYYY
E1000000 sssstttt
F1000000 ddddeeee
gsSPTextureRectangleFlip(ulx, uly, lrx, lry, tile, uls, ult, dtdx, dsdy)
Function Param To Microcode From Microcode Explanation
lrx lrx xxx Lower-right corner X coordinate
lry lry yyy Lower-right corner Y coordinate
tile tile i Tile descriptor to use for rectangle
ulx ulx XXX Upper-left corner X coordinate
uly uly YYY Upper-left corner Y coordinate
uls uls ssss Texture S coordinate at upper-left corner
ult ult tttt Texture T coordinate at upper-left corner
dtdx dtdx dddd Change in T coordinate over change in X coordinate
dsdy dsdy eeee Change in S coordinate over change in Y coordinate

Description

This is similar to opcode E4, with the only difference being that the S and T coordinates of a texture are flipped in rendering, so that S coordinates are along the Y axis and T along the X axis. This essentially flips the texture about the diagonal line (ulx,uly),(lrx,lry).

dtdx describes the change in T over the change in X, and dsdy describes change in S over change in Y.

Also like E4, there is an unusual 128-bit variant created by gsDPTextureRectangleFlip:

   E5xxxyyy 0iXXXYYY sssstttt ddddeeee

0xE6G_RDPLOADSYNC

Argument Mapping

Microcode Reference Function
E6000000 00000000 gsDPLoadSync()

No arguments for this opcode

Description

This forces a wait for a texture to load, in order to synchronize with pixel rendering. This ensures that loading a new texture won't disrupt the rendering of primitives mid-render.

0xE7G_RDPPIPESYNC

Argument Mapping

Microcode Reference Function
E7000000 00000000 gsDPPipeSync()

No arguments for this opcode

Description

This is not the "start of display list" command. There is no such thing.

Waits for the RDP to finish rendering its currently-rendering primitive, before updating RDP attributes. This avoids altering the rendering of a primitive in the middle of its render.

Historically, several model viewers have interpreted this command as somehow starting a display list. This is not true. Display lists have no command that starts a display list. To find display lists, the most accurate way would be to find the end display list command (DF) and work backwards, until an invalid display list command is encountered.

0xE8G_RDPTILESYNC

Argument Mapping

Microcode Reference Function
E8000000 00000000 gsDPTileSync()

No arguments for this opcode

Description

Forces a wait for rendering to finish before updating tile descriptor attributes, so as to not disrupt rendering of primitives mid-render.

0xE9G_RDPFULLSYNC

Argument Mapping

Microcode Reference Function
E9000000 00000000 gsDPFullSync()

No arguments for this opcode

Description

Generates an interrupt for the main CPU when the RDP has finished doing everything. This is typically the last opcode before the "end display list" opcode (DF).

0xEAG_SETKEYGB

Argument Mapping

Microcode Reference Function
EAwwwxxx ccssddtt gsDPSetKeyGB(centerG, scaleG, widthG, centerB, scaleB, widthB)
Function Param To Microcode From Microcode Explanation
widthG widthG www Scaled width of half the key window for green
widthB widthB xxx Scaled width of half the key window for blue
centerG centerG cc Intensity of active key for green
scaleG scaleG ss Reciprocal of size of soft edge, normalized to 0..0xFF, for green
centerB centerB dd Intensity of active key for blue
scaleB scaleB tt Reciprocal of size of soft edge, normalized to 0..0xFF, for blue

Description

Sets the center, scale, and width parameters for the green and blue components for chroma key (see EB for red).

widthB and widthG are in an unsigned fixed-point 4.8 format. The other parameters are normal 8-bit unsigned integers.

Note that chroma key was considered unsupported by Oct 1999 documentation, however this opcode may potentially still be used to set registers in the Color Combiner for other purposes.

0xEBG_SETKEYR

Argument Mapping

Microcode Reference Function
EB000000 0wwwccss gsDPSetKeyR(centerR, widthR, scaleR)
Function Param To Microcode From Microcode Explanation
widthR widthR www Scaled with of half the key window for red
centerR centerR cc Intensity of active key for red
scaleR scaleR ss Reciprocal of size of soft edge, normalized to 0..0xFF, for blue

Description

Sets the scale, center, and width parameters for the red component for chroma key (see EA for blue and green).

widthR is an unsigned fixed-point 4.8 number. centerR and sizeR are 8-bit unsigned integers.

Note that chroma key was considered unsupported by Oct 1999 documentation, however this opcode may potentially still be used to set registers in the Color Combiner for other purposes.

0xECG_SETCONVERT

Argument Mapping

Microcode Reference Function
E C 00aa aaaa aaab bbbb bbbb cccc
cccc cddd dddd ddee eeee eeef ffff ffff
gsDPSetConvert(k0, k1, k2, k3, k4, k5)
Function Param To Microcode From Microcode Explanation
k0 k0 aa aaaa aaa K0 term of conversion matrix
k1 k1 b bbbb bbbb K1 term of conversion matrix
k2 k2 cccc cccc c K2 term of conversion matrix
k3 k3 ddd dddd dd K3 term of conversion matrix
k4 k4 ee eeee eee K4 term of conversion matrix
k5 k5 f ffff ffff K5 term of conversion matrix

Description

Sets the terms need to perform conversion from YUV to RGB. All of the parameters are signed 9-bit numbers, with range -256 ≤ k ≤ 255.

Note that YUV support was no longer guaranteed by Oct 1999 documentation, however the K4 and K5 terms could still potentially be used by the Color Combiner.

0xEDG_SETSCISSOR

Argument Mapping

Microcode Reference Function
EDxxxyyy m0vvvwww gsDPSetScissor(mode, ulx, uly, lrx, lry)
Function Param To Microcode From Microcode Explanation
ulx ulx xxx Upper-left X coordinate of rectangle
uly uly yyy Upper-left Y coordinate of rectangle
mode mode m Interpolation mode setting
lrx lrx vvv Lower-right X coordinate of rectangle
lry lry www Lower-right Y coordinate of rectangle

Description

Sets the scissoring rectangle, with upper-left corner at (ulx, uly), and lower-right corner at (lrx, lry).

The mode setting controls interpolation, if any. Valid values are:

  • G_SC_NON_INTERLACE = 0
  • G_SC_EVEN_INTERLACE = 2
  • G_SC_ODD_INTERLACE = 3

NON_INTERLACE draws all scanlines, while EVEN and ODD draw only even or odd scanlines, respectively.

0xEEG_SETPRIMDEPTH

Argument Mapping

Microcode Reference Function
EE000000 zzzzdddd gsDPSetPrimDepth(z, dz)
Function Param To Microcode From Microcode Explanation
z z zzzz Z value for primitive
dz dz dddd delta Z value for primitive

Description

This sets the Z value for the entire primitive to be rendered, when the source for its depth component is set to be taken from this value. (This could be thought of as the depth version of "flat shading".)

z and dz are signed 16-bit values. z sets the actual depth for the primitive, while dz helps rendering of anti-aliased and decal objects (this is usually 0).

0xEFG_RDPSETOTHERMODE

Argument Mapping

Microcode Reference Function
EFhhhhhh LLLLLLLL gsDPSetOtherMode(omodeH, omodeL)
Function Param To Microcode From Microcode Explanation
omodeH omodeH hhhhhh Settings for other mode higher word bits
omodeL omodeL LLLLLLLL Settings for other mode lower word bits

Description

Sets the other mode bits of the RDP. omodeH is similar to using E3, and omodeL is similar to using E2.

The difference from either E3 or E2 is that this command sets all the bits in both halves of the RDP word (that is, this opcode has no way of limiting what bits are actually affected).

See the main page for what the other mode bits mean

0xF0G_LOADTLUT

Argument Mapping

Microcode Reference Function
F0000000 0tccc000 gsDPLoadTLUTCmd(tile, count)
Function Param To Microcode From Microcode Explanation
tile tile t Tile descriptor to load from
count (count & 0x3FF) << 2 ccc >> 2 Number of colors to load minus one

Description

Tells the RDP to load count + 1 colors from the texture loaded to tile descriptor tile. The tile descriptor's attributes and other state related to textures inform the RDP how to load the palette, and where to load it to.

(Note: the count is quadrupled likely due to how palettes are stored in TMEM. Not sure where details on that would be appropriate, though.)

0xF1G_RDPHALF_2

Argument Mapping

Microcode Reference Function
F1000000 LLLLLLLL gsDPWord(wordhi, wordlo)
Function Param To Microcode From Microcode Explanation
wordlo wordlo LLLLLLLL New value of low word

Description

This opcode sets the low half of the generic RDP word to wordlo.

Note: the referenced function also generates opcode E1 (which uses wordhi). See the section on E1 for info on that.

0xF2G_SETTILESIZE

Argument Mapping

Microcode Reference Function
F2sssttt 0iuuuvvv gsDPSetTileSize(tile, uls, ult, lrs, lrt)
Function Param To Microcode From Microcode Explanation
uls uls sss Upper-left texture coordinate, S-axis
ult ult ttt Upper-left texture coordinate, T-axis
tile tile i Tile descriptor to modify
lrs lrs uuu Lower-right texture coordinate, S-axis
lrt lrt vvv Lower-right texture coordinate, T-axis

Description

Sets the size of the texture for tile descriptor tile, setting its upper-left corner at (uls, ult), and its lower-right corner at lrs, lrt.

When loading textures into TMEM, these values indicate the location of the first and last texel to load into TMEM. When rendering, the upper-left corner tells where in texture image space to start taking the texture from, while the lower-right corner applies in rendering only for clamping the texture.

uls, ult, lrs, and lrt are all in unsigned fixed-point 10.2 format, with range 0 ≤ x ≤ 1023.75

0xF3G_LOADBLOCK

Argument Mapping

Microcode Reference Function
F3sssttt 0ixxxddd gsDPLoadBlock(tile, uls, ult, texels, dxt)
Function Param To Microcode From Microcode Explanation
uls uls sss Upper-left corner of texture to load, S-axis
ult ult ttt Upper-left corner of texture to load, T-axis
tile tile i Tile descriptor to load into
texels texels xxx Number of texels to load to TMEM, minus one
dxt dxt ddd Change in T-axis per scanline

Description

Loads a texture into TMEM as one long line of data, starting at (uls, ult) in the currently chosen area of RAM, and loads texels + 1 texels to TMEM for tile descriptor tile. dxt is used for determining when the next row starts.

uls and ult are unsigned fixed-point 10.2 numbers, with range 0 ≤ n ≤ 1023.75.

dxt is an unsigned fixed-point 1.11 number, meaning a range of 0 ≤ n ≤ 1.999512. This number has units, namely lines words-1, where a "word" is 64 bits in length, and a line is one row of the texture. (It may be more easily understood when inverted to get its reciprocal: words/lines . dxt is the reciprocal of the number of 64-bit chunks it takes to get a row of texture.)

When loading an image through this opcode, an internal counter is incremented by dxt for every 64 bits of texture read. When this counter is high enough to turn over to the next integer value (e.g. 0.9 + 0.15 -> 1.05), the current line number is incremented. This is important as odd-numbered rows have their values swapped for interleaved access (the first line read in is line 0, and thus isn't swapped).

Note that if dxt is not a power of two (i.e. only one bit in the value is 'on'), then an error in the counter will accumulate over time, and eventually cause errors in determining where next lines are (when exactly this happens depends on the value and the type of texture being read in).

If the data has bee pre-interleaved by the game, then dxt will be 0, meaning the current line number never advances (and thus loading will never interleave data for you).

0xF4G_LOADTILE

Argument Mapping

Microcode Reference Function
F4sssttt 0iuuuvvv gsDPLoadTile(tile, uls, ult, lrs, lrt)
Function Param To Microcode From Microcode Explanation
uls uls sss Upper-left corner of tile, S-axis
ult ult ttt Upper-left corner of tile, T-axis
tile tile i Tile descriptor being loaded to
lrs lrs uuu Lower-right corner of tile, S-axis
lrt lrt vvv Lower-right corner of tile, T-axis

Description

Loads a rectangular portion of the texture being pointed to in DRAM for tile descriptor tile into TMEM. (uls, ult) specifies the upper-left corner of the texture in RAM, offset from its earlier-specified origin, and (lrs, lrt) specifies the lower-right corner of the texture to load.

All coordinate values are in unsigned fixed-point 10.2 format (range 0 ≤ n ≤ 1023.75).

0xF5G_SETTILE

Argument Mapping

Microcode Reference Function
F 5 fffi i0nn nnnn nnnm mmmm mmmm
0000 0ttt pppp ccaa aass ssdd bbbb uuuu
gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmT, maskT, shiftT, cmS, maskS, shiftS)
Function Param To Microcode From Microcode Explanation
fmt fmt fff Sets color format
siz siz i i Sets bit size of pixel
line line nn nnnn nnn Number of 64-bit values per row
tmem tmem m mmmm mmmm Offset of texture in TMEM
tile tile ttt Tile descriptor being modified
palette palette pppp Which palette to use for colors (if relevant)
cmT cmT cc Clamp and Mirror flags for the T axis
maskT maskT aa aa Sets how much of T axis is shown before wrapping
shiftT shiftT ss ss Sets the amount to shift T axis values after perspective division
cmS cmS dd Clamp and Mirror flags for the S axis
maskS maskS bbbb Sets how much of S axis is shown before wrapping
shiftS shiftS uuuu Sets the amount to shift S axis values after perspective division

Description

Sets many different parameters for tile descriptor tile.

fmt sets the color format in use by the particular texture. It can be one of these values:

  • G_IM_FMT_RGBA = 0
  • G_IM_FMT_YUV = 1
  • G_IM_FMT_CI = 2
  • G_IM_FMT_IA = 3
  • G_IM_FMT_I = 4

siz sets the bit size of each texel. It can be any of these:

  • G_IM_SIZ_4b = 0
  • G_IM_SIZ_8b = 1
  • G_IM_SIZ_16b = 2
  • G_IM_SIZ_32b = 3

(Not every combination of fmt and siz is valid. See below(?) for a table of accepted texture types.)

line sets the number of 64-bit pieces per row of the texture (textures will be padded in TMEM if the row doesn't end in a multiple of 64 bits). tmem is the location in TMEM where the texture is. Note that TMEM is addressed in units of 64 bits here (zero-indexed), so e.g. 1 means byte 8 of TMEM.

palette specifies which of the sixteen palettes this texture will be using. Note that this only applies to ci4 textures (G_IM_FMT_CI and G_IM_SIZ_4b), since ci8 has access to the entirety of the palette area, and no other texture type needs palettes.

cmT and cmS set the clamp and mirror settings for their respective axes. The values of these two parameters can be any combination of:

  • G_TX_NOMIRROR = 0
  • G_TX_MIRROR = 1
  • G_TX_WRAP = 0
  • G_TX_CLAMP = 2

Where NOMIRROR and MIRROR, and WRAP and CLAMP are exclusive pairs of options. (And with NOMIRROR and WRAP currently labeled just to allow explicitly stating desired operation.) MIRROR enables mirroring of the texture along that given access (e.g. setting MIRROR for the S axis will mirror a texture horizontally), whereas NOMIRROR disables it. WRAP repeats texels on a particular cycle, whereas CLAMP enforces clamping instead (sampling the colors at the edges of the texture for texels beyond the set size of the texture).

maskT and maskS sets when the respective axis "loops" its texels. the value is interpreted as the first bit that's ignored. In other words, only the first 2mask texels of the row/column are actually used. If wrapping, then the previous texels are simply repeated; mirroring will mirror the set to be reperated, meaning the maskth bit of the current coordinate decides if its texel is mirrored. A mask value of 0 will implicitly enable clamping.

shiftT and shiftS specify how many bits to shift texture coordinates after perspective division, for their respective axes. If the value is 0, then no shifting is done. If the value is in range 1 ≤ n ≤ 10, then coordinates are right-shifted by that amount. For values in range 11 ≤ n ≤ 15, values are left-shifted by 16 - n.

0xF6G_FILLRECT

Argument Mapping

Microcode Reference Function
F6xxxyyy 00vvvwww gsDPFillRectangle(ulx, uly, lrx, lry)
Function Param To Microcode From Microcode Explanation
lrx (lrx & 0x3FF) << 2 xxx Lower-right corner of rectangle, X-axis
lry (lry & 0x3FF) << 2 yyy Lower-right corner of rectangle, Y-axis
ulx (ulx & 0x3FF) << 2 vvv Upper-left corner of rectangle, X-axis
uly (uly & 0x3FF) << 2 www Upper-left corner of rectangle, Y-axis

Description

Draws a rectangle to the framebuffer with top-left corner (ulx, uly) and bottom-right corner (lrx, lry), coloring it with the current fill color. Similar to E4, but uses a solid color instead of a texture.

All the coordinate values are (probably) fixed-width unsigned 10.2 format, with the macro shown making sure the coordinates sent to microcode are integers.

0xF7G_SETFILLCOLOR

Argument Mapping

Microcode Reference Function
F7000000 cccccccc gsDPSetFillColor(color)
Function Param To Microcode From Microcode Explanation
color color cccccccc Fill value for use in fill mode

Description

Sets the fill color for use in fill mode, which allows clearing the current color buffer.

When clearing the Z buffer, color is a 14-bit Z value and 2-bit dZ value specified twice to fill all 32 bits. In other words, color at the bit level looks like the following:

   ZZZZ ZZZZ  ZZZZ ZZdd  ZZZZ ZZZZ  ZZZZ ZZdd

If dealing with a color buffer, the meaning of color depends on the current color image's format. For an RGBA5551 color image, the chosen fill color is specified twice, like with the Z buffer:

   rrrr rggg  ggbb bbba  rrrr rggg  ggbb bbba

For an RGBA32 color image, color is a single RGBA32 color value.

For the 16-bit versions, the two occurrences of the color/depth value should be the same, however they can be different for an unspecified "special effect".

(Note: there is one reference to being able to use an 8-bit color image, but it's not clear if that applies here. Could the Video Interface settings be related in some way as well?)

0xF8G_SETFOGCOLOR

Argument Mapping

Microcode Reference Function
F8000000 rrggbbaa gsDPSetFogColor(R, G, B, A)
Function Param To Microcode From Microcode Explanation
R R rr Red component of fog color
G G gg Green component of fog color
B B bb Blue component of fog color
A A aa Alpha component of fog color

Description

Sets the fog color in the RDP blender. It's considered a general-purpose register, which as the name suggests is typically intended for fog effects. Note that the fog color is always specified in RGBA32 form, regardless of actual framebuffer formats.

0xF9G_SETBLENDCOLOR

Argument Mapping

Microcode Reference Function
F9000000 rrggbbaa gsDPBlendColor(R, G, B, A)
Function Param To Microcode From Microcode Explanation
R R rr Red component of blend color
G G gg Green component of blend color
B B bb Blue component of blend color
A A aa Alpha component of blend color

Description

Sets the RDP blender's blend color, a general purpose color register available for various purposes in the blender.

0xFAG_SETPRIMCOLOR

Argument Mapping

Microcode Reference Function
FA00mmff rrggbbaa gsDPSetPrimColor(minlevel, lodfrac, R, G, B, A)
Function Param To Microcode From Microcode Explanation
minlevel minlevel mm Minimum possible LOD value (clamped to this at minimum)
lodfrac lodfrac ff Primitive LOD fraction for mipmap filtering
R R rr Red component of primitive color
G G gg Green component of primitive color
B B bb Blue component of primitive color
A A aa Alpha component of primitive color

Description

Sets the primitive color register of the RDP's color combiner. Also sets two additional values available to the color combiner, the minimum LOD level and an LOD fraction.

minlevel and lodfrac are both fixed-point unsigned 0.8 numbers, meaning a range of 0 ≤ n ≤ 0.99609375. minlevel defines the minimum possible value for LOD to have, when the LOD calculated for a particular part of the primitive is less than 1.0. In other words, the LOD of any part of the primitive is clamped at the lower end to max(minlevel, LOD).

lodfrac specifies a fraction that the programmer can specify for use in the color combiner of the RDP. It's meant to offer a further refinement (XXX verify that, not 100% sure on it) on the linear filtering of two mipmaps. (Typically referred to in the SDK and elsewhere as "trilinear" filtering; however, due to the potential ambiguity of this term, we won't use it here. See the note on terminology at [1].)

The RGBA32 color specified via R, G, B, and A is also made available to the color combiner for use by the programmer.

0xFBG_SETENVCOLOR

Argument Mapping

Microcode Reference Function
FB000000 rrggbbaa gsDPSetEnvColor(R, G, B, A)
Function Param To Microcode From Microcode Explanation
R R rr Red component of environment color
G G gg Green component of environment color
B B bb Blue component of environment color
A A aa Alpha component of environment color

Description

Sets the environment color register in the RDP's color combiner. It's available as a general-purpose color register for the programmer to use in the color combiner.

0xFCG_SETCOMBINE

Argument Mapping

Microcode Reference Function
F C aaaa cccc czzz xxxe eeeg gggg
bbbb ffff vvvt ttdd dyyy wwwh hhuu usss
gsDPSetCombineLERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1)
Function Param To Microcode From Microcode Explanation
a0 a0 aaaa Color 'a' value, first cycle
c0 c0 cccc c Color 'c' value, first cycle
Aa0 Aa0 zzz Alpha 'a' value, first cycle
Ac0 Ac0 xxx Alpha 'c' value, first cycle
a1 a1 eee e Color 'a' value, second cycle
c1 c1 g gggg Color 'c' value, second cycle
b0 b0 bbbb Color 'b' value, first cycle
b1 b1 ffff Color 'b' value, second cycle
Aa1 Aa1 vvv Alpha 'a' value, second cycle
Ac1 Ac1 t tt Alpha 'c' value, second cycle
d0 d0 dd d Color 'd' value, first cycle
Ab0 Ab0 yyy Alpha 'b' value, first cycle
Ad0 Ad0 www Alpha 'd' value, first cycle
d1 d1 h hh Color 'd' value, second cycle
Ab1 Ab1 uu u Alpha 'b' value, second cycle
Ad1 Ad1 sss Alpha 'd' value, second cycle

Description

Sets up the RDP's Color Combiner's parameters for primitive rendering. This sets up parameters for color (R, G, B) and alpha for both cycles. (In one-cycle mode, both cycles must have equal parameters.)

The general formula used to mix colors in the Color combiner is of the form:

   (A - B) * C + D

This is performed on all sets of parameters. a0, b0, c0, and d0; a1, b1, c1, and d1; Aa0, Ab0, Ac0, and Ad0; and Aa1, Ab1, Ac1, and Ad1 are those sets of parameters.

The values taken in each parameter are part of an enumeration of potential sources for that value, but which differs for various pieces: all of the color A, B, C, D components have different enumerations, and alpha C is different from the other alpha components. See the main page on the color combiner for details on how it works.

0xFDG_SETTIMG

Argument Mapping

Microcode Reference Function
FD__0www iiiiiiii
__ -> fffs s000 (binary)
gsDPSetTextureImage(fmt, siz, width, imgaddr)
Function Param To Microcode From Microcode Explanation
fmt fmt fff Format of texture to be pointed to
siz siz ss Bit size of pixels in texture to be pointed to
width width - 1 www + 1 Width of the texture
imgaddr imgaddr iiiiiiii RAM address of start of texture

Description

This opcode sets the location in RAM of the image that will be used when using any of the texture loading opcodes. imgaddr is the RAM location of the image to be pulling textures from. width is the width of the image, necessary in finding out when next rows start. The maximum allowed with is 4096, or 0x1000. www is the width minus one so that it can fit within three nybbles.

fmt and siz are the usual image format enumerations, explained on the main page.

0xFEG_SETZIMG

Argument Mapping

Microcode Reference Function
FE000000 iiiiiiii gsDPSetDepthImage(imgaddr)
Function Param To Microcode From Microcode Explanation
imgaddr imgaddr iiiiiiii Address of the depth buffer

Description

Sets the location of the depth buffer to imgaddr. Since the format of the depth buffer is fixed (14-bit Z value and 2-bit dZ value), those parameters are not here, unlike for FD and FF. The width of the depth buffer is shared with the color buffer (see FF), and thus isn't set here.

0xFFG_SETCIMG

Argument Mapping

Microcode Reference Function
FF__0www iiiiiiii
__ -> fffs s000 (binary)
gsDPSetColorImage(fmt, siz, width, imgaddr)
Function Param To Microcode From Microcode Explanation
fmt fmt fff Format of color buffer to be pointed to
siz siz ss Bit size of pixels in color buffer to be pointed to
width width - 1 www + 1 Width of the color buffer
imgaddr imgaddr iiiiiiii RAM address of color buffer

Description

Sets the location of the color framebuffer, usually a framebuffer that's displayed to the screen. The color buffer is set to RAM location imgaddr, with a width of width. fmt and siz are the typical image format enumerations, described on the main page.

The location is usually some place set as the framebuffer to show (which is not handled by display lists), but oftentimes will be set to a depth buffer. This is usually done to fill (aka clear) the depth buffer in fill mode.