====== F3DDKR Microcode ======
F3DDKR (unofficial name) is a modified version of the [[super_mario_64:fast3d_display_list_commands|Fast3D microcode]]. It was created by Rareware for the game Diddy Kong Racing.
----
===== Changes from Fast3D =====
- The commands [[super_mario_64:fast3d_display_list_commands#beg_culldl|G_CULLDL]], [[super_mario_64:fast3d_display_list_commands#bfg_tri1|G_TRI1]], and [[super_mario_64:fast3d_display_list_commands#bdg_popmtx|G_POPMTX]] were removed, and are now NOPS (No operations).
- Triangles are drawn in batches; up to 16 triangles per batch.
- The number of vertices was increased from 16 to 24.
- The vertex structure is smaller, being only 10 bytes per vertex instead of 16.
- UV coordinates are per-face instead of per-vertex.
- The lighting overlay was removed. Dynamic lighting & environment mapping for objects are calculated on the CPU.
- The matrix stack has been removed; there are now only 3 matrices at fixed offsets.
- The number of segment banks has been reduced from 16 to 8
- Mipmapping cannot be done, due to some changes in the triangle setup routine.
----
===== Structures =====
==== Vertex (10 bytes) ====
''[XX XX] [YY YY] [ZZ ZZ] [RR] [GG] [BB] [AA]''
| XXXX | short | Position on X axis |
| YYYY | short | Position on Y axis |
| ZZZZ | short | Position on Z axis |
| RR | ubyte | Red color channel |
| GG | ubyte | Green color channel |
| BB | ubyte | Blue color channel |
| AA | ubyte | Alpha (Transparency) |
==== Triangle Face (16 bytes) ====
''[BF] [V0] [V1] [V2] [U1U1] [V1V1] [U2U2] [V2V2] [U3U3] [V3V3]''
| BF | ubyte | 0x40 = Draw the backface of the triangle, 0x00 = Cull backface |
| V0 | ubyte | First vertex index |
| V1 | ubyte | Second vertex index |
| V2 | ubyte | Third vertex index |
| U1U1 | short | Texture coordinate on the U axis for the first vertex |
| V1V1 | short | Texture coordinate on the V axis for the first vertex |
| U2U2 | short | Texture coordinate on the U axis for the second vertex |
| V2V2 | short | Texture coordinate on the V axis for the second vertex |
| U3U3 | short | Texture coordinate on the U axis for the third vertex |
| V3V3 | short | Texture coordinate on the V axis for the third vertex |
----
===== Added/Modified Commands =====
==== 01: G_MTX ====
Loads a matrix from a segmented address.
''01 [II] 00 40 [AA AA AA AA]''
| I | Index in the matrix array within DMEM. 0x00, 0x40, or 0x80 |
| A | Segmented address of vectors |
----
==== 04: G_VTX ====
Loads up to 24 vertices from a segment address.
''04 [NO] [II II] [SS SS SS SS]''
| NO | Upper 5 bits = Number of vertices - 1, Lower 3 bits = Offset within vertex struct to start at |
| I | (Where to start writing vertices inside the vertex buffer) * 2 |
| S | Segmented address to load vertices from |
----
==== 05: G_TRIN ====
Draws a batch of triangles from a segmented address. Up to 16 triangles can be drawn at once.
''05 [N] [T] [LL LL] [SS SS SS SS]''
| N | Number of triangles - 1 |
| T | 0x01 = Enable texture, 0x00 = Disable texture |
| L | Length of data to write in bytes ((N+1)*16) |
| S | Segmented address to load triangle data from |
----
==== 07: G_DMADL ====
DMAs a fixed-size display list from RDRAM and outputs the commands directly to the RDP. This is used by the game engine to load textures for models.
''07 [NN] [LL LL] [SS SS SS SS]''
| N | Number of commands |
| L | Length of data in bytes (N*8) |
| S | Segmented address to the display list. |
----
==== B5: G_SETPERSPNORM ====
Sets the perspective normal value. Might be unused.
''B5 00 00 00 [PP PP] 00 00''
| P | PERSPNORM value |
----
==== BC: G_MOVEWORD ====
The format is still the same as Fast3D, but two indices have been changed:
| G_MW_BILLBOARD | 0x02 | 0x01 = billboarding enabled, 0x00 = disabled |
| G_MW_MVMATRIX | 0x0A | Specifies the index of the modelview matrix. |
----
===== References =====
* https://git.libretro.com/libretro/mupen64plus-libretro-nx/-/blob/develop/GLideN64/src/uCodes/F3DDKR.cpp