====== Fast3D Display List Commands ====== The Fast3D display list commands are microcode that are passed to the RSP for rendering. The are all 8 bytes long. ===== Fast3D Commands ===== ==== 00: G_NOOP ==== No operation. This should only be used for debugging purposes. ''00 00 00 00 00 00 00 00'' ==== 01: G_MTX ==== Apply transformation matrix. Used in HUD text printing code to translate textures. ''01 [PP] 00 00 [AA AA AA AA]'' | P | Parameters | | A | Segmented address of vectors | Parameters (can be OR'd together): | 0x01 | projection (default: model view) | | 0x02 | load (default: multiply) | | 0x04 | push (default: no push) | Example: Push matrix and and multiply by matrix at 0x00213DF8; Multiply by matrix at 0x00213DB8 01 04 00 40 00 21 3D F8 01 00 00 40 00 21 3D B8 ==== 03: F3D_MOVEMEM ==== Used in Super Mario 64 to load vector lighting ambient/diffuse RGBA values. ''03 [TT] 00 10 [AA AA AA AA]'' | T | If 0x86, loads diffuse(light) values. If 0x88, loads ambient(dark) values | | A | Segmented address of RGBA | Example: Loads diffuse RGBA from 0x0 in RAM bank 0x0E; loads ambient RGBA from 0x08 in RAM Bank 0x0E 03 86 00 10 0E 00 00 00 03 88 00 10 0E 00 00 08 ---- ==== 04: F3D_VTX ==== Fills the vertex buffer with vertex information (ex. coordinates, color values). Max amount of bytes to load in F3D is 0x100 (16 vertices). ''04 [N][I] [LL LL] [SS SS SS SS]'' | N | Number of vertices - 1 | | I | Where to start writing vertices inside the vertex buffer | | L | Length of vertex data to write ((N+1)*0x10) | | S | Segmented address where vertices are stored | Example: Load 15 (0xF0 / 0x10) vertices from 0x0E000780 (current map data) - and put them into the vertex buffer, starting at position 0. 04 E0 00 F0 0E 00 07 80 ---- ==== 06: F3D_DL ==== Signifies the start of a Display List. May be used to link data and branch the current DL. ''06 [AA] 00 00 [BB BB BB BB]'' | AA | 00 = store return address, 01 = don't store (end DL after branch) | | B | Segmented Address to branch to | Example: Loads a display list from 0xA50 in bank 0x07. 06 00 00 00 07 00 0A 50 ---- ==== B5: F3D_QUAD ==== Renders one quad according to the vertices inside the vertex buffer ''B5 [AA] [BB] [CC] 00 [DD] [EE] [FF]'' | A | First vertex to use for the quad (* 0x0A) | | B | Second vertex to use for the quad (* 0x0A) | | C | Third vertex to use for the quad (* 0x0A) | | D | Fourth vertex to use for the quad (* 0x0A) | | E | Fifth vertex to use for the quad (* 0x0A) | | F | Sixth vertex to use for the quad (* 0x0A) | Example: Render a quad using the vertex data specified at the vertex buffer positions 0, 1 (0x0A / 0x0A), 2 (0x14 / 0x0A), 0, 2 (0x14 / 0x0A) and 3 (0x1E / 0x0A). B5 00 0A 14 00 00 14 1E ---- ==== B6: F3D_CLEARGEOMETRYMODE ==== Enables or disables certain geometry parameters (ex. lighting, front-/backface culling, Z-buffer). Used at start of Display List. ''B6 00 00 00 [AA AA AA AA]'' | A | Various parameters | Parameters (can be OR'd together): | 0x00000001 | Use Z-buffering | | 0x00000004 | Use shading | | 0x00000200 | Enable smooth shading (otherwise flat shading) | | 0x00001000 | cull front facing triangles | | 0x00002000 | cull back facing triangles | | 0x00010000 | Fog | | 0x00020000 | Enable lighting? Vertex colors? | | 0x00040000 | generate texture coords using the normal | | 0x00080000 | generate texture coords (not sure how this works)| Examples: B6 00 00 00 00 02 20 00 : Vertex RGB, no culling B6 00 00 00 00 02 00 00 : Vertex RGB, culling B6 00 00 00 00 00 00 00 : No vertex RGB, culling B6 00 00 00 00 00 22 00 : No vertex RGB, no culling ---- ==== B7: F3D_SETGEOMETRYMODE ==== Enables or disables certain geometry parameters (ex. lighting, front-/backface culling, Z-buffer). Used at end of Display List. ''B7 00 00 00 [AA AA AA AA]'' | A | Various parameters | See [[#B6: F3D_CLEARGEOMETRYMODE]] for list of parameters. Examples: B7 00 00 00 00 02 20 00 : Vertex RGB, no culling B7 00 00 00 00 02 00 00 : Vertex RGB, culling B7 00 00 00 00 00 00 00 : No vertex RGB, culling B7 00 00 00 00 00 22 00 : No vertex RGB, no culling ---- ==== B8: F3D_ENDDL ==== Terminates the current Display List ''B8 00 000 000 00 00 00'' ---- ==== BB: F3D_TEXTURE ==== Sets the texture scaling factor. ''BB 00 00 ?? ?? ?? ?? ??'' Examples: BB 00 00 01 FF FF FF FF : Standard - at start for 1 scaling. BB 00 00 01 0F 80 07 C0 : Special case - at start for environment mapping. BB 00 00 00 FF FF FF FF : Always reset to at end of the DL to reset scale to 0. ---- ==== BF: F3D_TRI1 ==== Renders one triangle according to the vertices inside the vertex buffer ''BF 00 00 00 00 [AA] [BB] [CC]'' | A | First vertex to use for the triangle (* 0x0A) | | B | Second vertex to use for the triangle (* 0x0A) | | C | Third vertex to use for the triangle (* 0x0A) | Example: Render a triangle using the vertex data specified at the vertex buffer positions 0, 1 (0x0A / 0x0A) and 2 (0x14 / 0x0A). BF 00 00 00 00 00 0A 14 ---- ==== E4: G_TEXRECT ==== Draws a textured 2D rectangle on the screen ''E4 [xx x][y yy] 0[I] [XX X][Y YY]''\\ ''B3 00 00 00 [SS SS] [TT TT]''\\ ''B2 00 00 00 [DD DD] [EE EE]'' | xxx | Lower-right corner X coordinate | | yyy | Lower-right corner Y coordinate | | I | Tile descriptor to use for rectangle | | XXX | Upper-left corner X coordinate | | YYY | Upper-left corner Y coordinate | | SSSS | Texture S coordinate at upper-left corner | | TTTT | Texture T coordinate at upper-left corner | | DDDD | Change in S coordinate over change in X coordinate | | EEEE | Change in T coordinate over change in Y coordinate | ---- ==== F2: G_SETTILESIZE ==== Sets the texture coordinates and size ''F2 00 00 00 00 [WW W][H HH]'' | W | (width - 1) << 2 | | H | (hieght - 1) << 2 | Examples: F2 00 00 00 00 07 C0 7C : 32x32 textures F2 00 00 00 00 0F C0 7C : 64x32 F2 00 00 00 00 07 C0 FC : 32x64 ---- ==== F3: G_LOADBLOCK ==== Determines how much data to load after SETTIMG ''F3 [SS S][T TT] 0[I] [XX X][D DD]'' | SSS | Upper-left corner of texture to load, S-axis | | TTT | Upper-left corner of texture to load, T-axis | | I | Tile descriptor to load into | | XXX | Number of texels to load to TMEM, minus one | | DDD | Change in T-axis per scanline | Examples: F3 00 00 00 07 7F F1 00 : 32x64 or 64x32 RGBA Textures F3 00 00 00 07 3F F1 00 : 32x32 RGBA Textures ---- ==== F5: G_SETTILE ==== Sets the texture properties (ex. mirroring) ''F5 [XX XX XX XX XX XX XX]'' | X | Bit-wise parameters | Bit-wise parameters: ''[fff] [ii] 0 [nnnnnnnnn] [mmmmmmmmm] 00000 [ttt] [pppp] [cc] [aaaa] [ssss] [dd] [bbbb] [uuuu]'' | fff | Sets color format | | ii | Sets bit size of pixel | | nnnnnnnnn | Number of 64-bit values per row | | mmmmmmmmm | Offset of texture in TMEM | | ttt | Tile descriptor being modified | | pppp | Which palette to use for colors (if relevant) | | cc | Clamp and Mirror flags for the T axis | | aaaa | Sets how much of T axis is shown before wrapping | | ssss | Sets the amount to shift T axis values after perspective division | | dd | Clamp and Mirror flags for the S axis | | bbbb | Sets how much of S axis is shown before wrapping | | uuuu | Sets the amount to shift S axis values after perspective division | |Color formats||| | 0 | RGBA | Color and alpha | | 1 | YUV | | | 2 | CI | Index and look-up pallet | | 3 | IA | Grayscale and alpha | | 4 | I | Grayscale | |Bit sizes||| | 0 | 4-bit | I, IA, and CI | | 1 | 8-bit | I, IA, and CI | | 2 | 16-bit | RGBA, IA, and YUV | | 3 | 32-bit | RGBA | Examples: F5 10 00 00 07 00 00 00 : Always loaded first for normal RGBA, followed by another F5 command F5 70 00 00 07 00 00 00 : Always loaded first for Grayscale, followed by another F5 command F5 10 10 00 07 01 40 50 : Normal for 32x32 textures after G_SETTILESIZE F5 10 20 00 07 01 40 60 : Normal for 64x32 textures after G_SETTILESIZE F5 70 10 00 07 01 40 50 : Grayscale for 32x32 textures after G_SETTILESIZE ---- ==== F6: G_FILLRECT ==== Draws a colored rectangle on the screen. Use command 0xF7 to set the color of the rectangle. ''F6 [VV V][W WW] 00 [XX X][Y YY]'' | VVV | Lower-right corner of rectangle, X-axis | | WWW | Lower-right corner of rectangle, Y-axis | | XXX | Upper-left corner of rectangle, X-axis | | YYY | Upper-left corner of rectangle, Y-axis | ---- ==== F7: G_SETFILLCOLOR ==== Sets the fill color for use in fill mode. ''F7 00 00 00 [CC CC CC CC]'' | CCCCCCCC | Fill value for use in fill mode | ---- ==== F8: G_SETFOGCOLOR ==== Sets the fog color ''F8 00 00 00 [RR] [GG] [BB] [AA]'' | R | red value | | G | green value | | B | blue value | | A | typically set to FF | Example: set the fog for the following polygons to pure green F8 00 00 00 00 FF 00 FF ---- ==== FB: G_SETENVCOLOR ==== Sets the environment color for combiner ''FB 00 00 00 [RR] [GG] [BB] [AA]'' | R | red value | | G | green value | | B | blue value | | A | alpha value | Example: make everything loaded underneath the command red, and semi-transparent FB 00 00 00 FF 00 00 8C ---- ==== FC: G_SETCOMBINE ==== Performs combining operations (ex. multi-texturing). The N64's Color Combiner calculates the output color by combining the various source colors and source alphas using the following equation: outputcolor = ( A - B ) * C + D. ''FC [XX XX XX XX XX XX XX]'' | X | Equation for blending. Mask is bitwise. | Bitwise mask for X: ''[**aaaa**] [**ccccc**] [**eee**] [**ggg**] [**iiii**] [**kkkkk**] [**bbbb**] [**jjjj**] [**mmm**] [**ooo**] [**ddd**] [**fff**] [**hhh**] [**lll**] [**nnn**] [**ppp**]'' | **a** | variable 'a' for mode 1 (color) | | **b** | variable 'b' for mode 1 (color) | | **c** | variable 'c' for mode 1 (color) | | **d** | variable 'd' for mode 1 (color) | | **e** | variable 'e' for mode 1 (alpha) | | **f** | variable 'f' for mode 1 (alpha) | | **g** | variable 'g' for mode 1 (alpha) | | **h** | variable 'h' for mode 1 (alpha) | | **i** | variable 'a' for mode 2 (color) | | **j** | variable 'b' for mode 2 (color) | | **k** | variable 'c' for mode 2 (color) | | **l** | variable 'd' for mode 2 (color) | | **m** | variable 'e' for mode 2 (alpha) | | **n** | variable 'f' for mode 2 (alpha) | | **o** | variable 'g' for mode 2 (alpha) | | **p** | variable 'h' for mode 2 (alpha) | More information here: [[http://n64devkit.square7.ch/pro-man/pro12/12-06.htm|N64's Color Combiner]] Examples: FC 12 7F FF FF FF F8 38 : Standard usage for solid RGBA textures FC 12 18 24 FF 33 FF FF : Standard usage for alpha RGBA textures ---- ==== FD: G_SETTIMG ==== Sets the texture image offset ''FD 10 00 00 [AA AA AA AA]'' | A | Segmented address of texture | Example: Load texture position from 0x90 in RAM bank 0x04 FD 10 00 00 04 00 00 90 ===== References ===== * http://www.smwcentral.net/?p=viewthread&t=74389 * http://origami64.net/showthread.php?tid=114 * http://n64.icequake.net/doc/n64intro/kantan/step2/4-3.html * http://jul.rustedlogic.net/thread.php?id=1234 * http://level42.ca/projects/ultra64/Documentation/man/pro-man/pro25/25-01.html * http://wiki.spinout182.com/w/F3DEX2 * http://wiki.cloudmodding.com/oot/F3DZEX/Opcode_Details