This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
super_mario_64:fast3d_display_list_commands [2018/08/12 02:53] David Removed G_QUAD, since it doesn't work with Fast3D 1.0 |
super_mario_64:fast3d_display_list_commands [2022/05/31 02:34] (current) David [B2: G_RDPHALF_CONT] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Fast3D Display List Commands ====== | ====== 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. | + | The Fast3D display list commands are microcode that are passed to the RSP for rendering. They are all 8 bytes long. |
===== Fast3D Commands ===== | ===== Fast3D Commands ===== | ||
Line 29: | Line 29: | ||
Takes a block of memory from an address and puts it in the location pointed to by an index and an offset. | Takes a block of memory from an address and puts it in the location pointed to by an index and an offset. | ||
- | ''03 [<color #ff1010>nn</color>] [<color #ff7f27>oo</color>] [<color #00a2e8>ii</color>] [<color #A946F2>aa aa aa aa</color>]'' | + | ''03 [<color #ff7f27>ii</color>] [<color #ff1010>nnnn</color>] [<color #A946F2>aa aa aa aa</color>]'' |
- | | <color #ff1010>n</color> | (((//Size in bytes of memory to be moved//) >> 3)+1)*8 | | + | | <color #ff7f27>i</color> | Index into table of DMEM addresses | |
- | | <color #ff7f27>o</color> | Offset from indexed base address (*8) | | + | | <color #ff1010>n</color> | Size in bytes of memory to be moved | |
- | | <color #00a2e8>i</color> | Index into table of DMEM addresses | | + | |
| <color #A946F2>a</color> | Segmented address of memory | | | <color #A946F2>a</color> | Segmented address of memory | | ||
- | <color #00a2e8>**i**</color> is an index into a table of addresses of DMEM. Given enumerations for <color #00a2e8>**i**</color> are: | + | <color #ff7f27>**i**</color> is an index into a table of addresses of DMEM. Given enumerations for <color #ff7f27>**i**</color> are: |
- | * <color #22b14c>G_MV_MMTX</color> = 2 | + | |
- | * <color #22b14c>G_MV_PMTX</color> = 6 | + | |
- | * <color #22b14c>G_MV_VIEWPORT</color> = 8 | + | |
- | * <color #22b14c>G_MV_LIGHT</color> = 10 | + | |
- | * <color #22b14c>G_MV_POINT</color> = 12 | + | |
- | * <color #22b14c>G_MV_MATRIX</color> = 14 | + | |
- | Note however that only <color #22b14c>VIEWPORT</color>, <color #22b14c>LIGHT</color>, and <color #22b14c>MATRIX</color> are used by any of the macros given to programmers. | + | * <color #22b14c>G_MV_VIEWPORT</color> = 0x80 |
+ | * <color #22b14c>G_MV_LOOKATY</color> = 0x82 | ||
+ | * <color #22b14c>G_MV_LOOKATX</color> = 0x84 | ||
+ | * <color #22b14c>G_MV_L0</color> = 0x86 | ||
+ | * <color #22b14c>G_MV_L1</color> = 0x88 | ||
+ | * <color #22b14c>G_MV_L2</color> = 0x8a | ||
+ | * <color #22b14c>G_MV_L3</color> = 0x8c | ||
+ | * <color #22b14c>G_MV_L4</color> = 0x8e | ||
+ | * <color #22b14c>G_MV_L5</color> = 0x90 | ||
+ | * <color #22b14c>G_MV_L6</color> = 0x92 | ||
+ | * <color #22b14c>G_MV_L7</color> = 0x94 | ||
+ | * <color #22b14c>G_MV_TXTATT</color> = 0x96 | ||
- | Note: In Super Mario 64, this is mainly used to load vector lighting ambient/diffuse RGBA values.\\ | + | Note: <color #22b14c>G_MV_TXTATT</color> is not used by any of the macros given to programmers. |
- | Example: Loads diffuse RGBA from 0x0 in Segment 0x0E; loads ambient RGBA from 0x08 in Segment 0x0E | + | |
- | 03 86 00 10 0E 00 00 00 | + | In Super Mario 64, this is mainly used to load vector lighting ambient/diffuse RGBA values. |
- | 03 88 00 10 0E 00 00 08 | + | |
+ | The ambient light is loaded using G_MV_L1 (0x88), and the segment address points to 8 bytes defining the ambient color RGB value. | ||
+ | |||
+ | 03 88 00 10 0E 00 00 00 // This loads the ambient light from segment address 0x0E000000. | ||
+ | |||
+ | At address 0x0E000000: | ||
+ | FF FF FF 00 FF FF FF 00 // Sets the ambient color to be white. The zeroes here don't matter. | ||
+ | |||
+ | Note 1: The last 4 bytes should match the first 4 since it is a copy of the RGB color. | ||
+ | Note 2: The 4th and 8th bytes are just padding; they don't represent the alpha value. | ||
+ | |||
+ | The diffuse light is loaded using G_MV_L0 (0x86), and the segment address points to 16 bytes defining the color RGB value and normalized direction that the light is coming from. | ||
+ | |||
+ | 03 86 00 10 0E 00 00 08 // This loads the diffuse light from segment address 0x0E000008. | ||
+ | |||
+ | At address 0x0E000008: | ||
+ | 7F 7F 7F 00 7F 7F 7F 00 // Sets the diffuse light color to be gray. | ||
+ | 28 28 28 00 00 00 00 00 // SM64 usually sets the normalized direction as (0x28, 0x28, 0x28) | ||
+ | |||
+ | Note: All the zeroes here are for padding, since diffuse lights are 16-byte aligned. | ||
+ | |||
+ | The normalized direction is calculated using the following formula: | ||
+ | First calculate variable 'd' as: d = 127/square_root(x*x + y*y + z*z) | ||
+ | Then the normalized direction is: Xn = x*d; Yn = y*d; Zn = z*d | ||
+ | |||
+ | Note: Xn, Yn, and Zn should be signed bytes. | ||
---- | ---- | ||
Line 82: | Line 111: | ||
==== B2: G_RDPHALF_CONT ==== | ==== B2: G_RDPHALF_CONT ==== | ||
Acts as an indicator that the command continues with the given lower word. This is used only when operators longer than 64bits are in use. | Acts as an indicator that the command continues with the given lower word. This is used only when operators longer than 64bits are in use. | ||
+ | |||
+ | Note: When this command gets executed, it will immediately send all the previous data (from RDPHALF_1 and/or RDPHALF_2) to the RDP. | ||
''B2 00 00 00 [<color #ff7f27>CC CC CC CC</color>]'' | ''B2 00 00 00 [<color #ff7f27>CC CC CC CC</color>]'' | ||
Line 236: | Line 267: | ||
Loads a new 32-bit value data to the location specified by index and offset. | Loads a new 32-bit value data to the location specified by index and offset. | ||
- | ''DB <color #00a2e8>ii</color> <color #22b14c>oo oo</color> <color #A946F2>dd dd dd dd</color>'' | + | ''BC <color #22b14c>oo oo</color> <color #00a2e8>ii</color> <color #A946F2>dd dd dd dd</color>'' |
- | | <color #00a2e8>i</color> | Index into DMEM pointer table(?) | | + | | <color #22b14c>o</color> | Offset from the indexed base address | |
- | | <color #22b14c>o</color> | Offset from the indexed base address(?) | | + | | <color #00a2e8>i</color> | Index into DMEM pointer table | |
| <color #A946F2>d</color> | New 32-bit value | | | <color #A946F2>d</color> | New 32-bit value | | ||
Line 256: | Line 287: | ||
==== BD: G_POPMTX ==== | ==== BD: G_POPMTX ==== | ||
- | Pops num matrices from the stack specified by modelview matrix stack. | + | Pops a matrix from the stack. |
- | ''D8380002 <color #00a2e8>aaaaaaaa</color>'' | + | ''BD000000 00 00 00 00'' |
- | + | ||
- | | <color #00a2e8>a</color> | The number of matrices to pop | | + | |
+ | Removes the top matrix from the matrix stack in dmem | ||
---- | ---- | ||
Line 453: | Line 483: | ||
Sets the scissoring rectangle. | Sets the scissoring rectangle. | ||
- | ''ED [<color #00a2e8>xx x</color>][<color #22b14c>y yy</color>] [<color #ff7f27>m</color>]0 [<color #ed1c24>vv v</color>][<color #B755FF>w ww</color>]'' | + | ''ED [<color #00a2e8>xx x</color>][<color #22b14c>y yy</color>] 0[<color #ff7f27>m</color>] [<color #ed1c24>vv v</color>][<color #B755FF>w ww</color>]'' |
| <color #00a2e8>x</color> | Upper-left X coordinate of rectangle | | | <color #00a2e8>x</color> | Upper-left X coordinate of rectangle | | ||
Line 509: | Line 539: | ||
Sets the texture coordinates and size | Sets the texture coordinates and size | ||
- | ''F2 00 00 00 00 [<color darkred>WW W</color>][<color darkgreen>H HH</color>]'' | + | ''F2 [<color darkred>SS S</color>][<color darkgreen>T TT</color>] 0[<color #00a2e8>I</color>] [<color purple>WW W</color>][<color darkcyan>H HH</color>]'' |
+ | | <color darkred>SSS</color> | Upper-left corner of texture to load, S-axis | | ||
+ | | <color darkgreen>TTT</color> | Upper-left corner of texture to load, T-axis | | ||
+ | | <color #00a2e8>I</color> | Tile descriptor to load into | | ||
| <color darkred>W</color> | (width - 1) << 2 | | | <color darkred>W</color> | (width - 1) << 2 | | ||
| <color darkgreen>H</color> | (height - 1) << 2 | | | <color darkgreen>H</color> | (height - 1) << 2 | | ||
Line 583: | Line 616: | ||
| <color #3F3FFF>pppp</color> | Which palette to use for colors (if relevant) | | | <color #3F3FFF>pppp</color> | Which palette to use for colors (if relevant) | | ||
| <color orange>cc</color> | Clamp and Mirror flags for the T axis | | | <color orange>cc</color> | Clamp and Mirror flags for the T axis | | ||
- | | <color darkred>aaaa</color> | Sets how much of T axis is shown before wrapping | | + | | <color darkred>aaaa</color> | T mask (Sets how much of T axis is shown before clamping) | |
| <color darkblue>ssss</color> | Sets the amount to shift T axis values after perspective division | | | <color darkblue>ssss</color> | Sets the amount to shift T axis values after perspective division | | ||
| <color darkgreen>dd</color> | Clamp and Mirror flags for the S axis | | | <color darkgreen>dd</color> | Clamp and Mirror flags for the S axis | | ||
- | | <color #8F3F10>bbbb</color> | Sets how much of S axis is shown before wrapping | | + | | <color #8F3F10>bbbb</color> | S mask (Sets how much of S axis is shown before clamping) | |
| <color darkcyan>uuuu</color> | Sets the amount to shift S axis values after perspective division | | | <color darkcyan>uuuu</color> | Sets the amount to shift S axis values after perspective division | | ||
Line 601: | Line 634: | ||
| 2 | 16-bit | RGBA, IA, and YUV | | | 2 | 16-bit | RGBA, IA, and YUV | | ||
| 3 | 32-bit | RGBA | | | 3 | 32-bit | RGBA | | ||
+ | |||
+ | |wraps/wrapt modes|| | ||
+ | | 0 | Wrap/No mirror | | ||
+ | | 1 | Mirror | | ||
+ | | 2 | Clamp | | ||
+ | |||
+ | |shifts/shiftt modes|| | ||
+ | | 0-10 | >> shift | | ||
+ | | 11-15 | << (shift-10) | | ||
Or simply | Or simply | ||
Line 801: | Line 843: | ||
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. | 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. | ||
+ | ===== Fast3D DMEM Map ===== | ||
+ | |0x000|Program data from compiler |0x110 bytes| | ||
+ | |0x110|RSP GFX State |0x050 bytes| | ||
+ | |0x160|RSP Memory segment table |0x040 bytes| | ||
+ | |0x1A0|Lights |0x180 bytes| | ||
+ | |0x320|Viewport |0x010 bytes| | ||
+ | |0x330|Fog factors |0x006 bytes| | ||
+ | |0x336|padding |0x002 bytes| | ||
+ | |0x338|Display list stack |0x028 bytes| | ||
+ | |0x360|Modelview matrix top of stack |0x040 bytes| | ||
+ | |0x3A0|Projection Matrix top of stack |0x040 bytes| | ||
+ | |0x3E0|MP Matrix (Modelview * Projection) |0x040 bytes| | ||
+ | |0x420|Points buffer |0x280 bytes| | ||
+ | |0x6A0|Input (display list) |0x140 bytes| | ||
+ | |0x7E0|Input (data) |0x100 bytes| | ||
+ | |0x8E0|setup tmp |0x060 bytes| | ||
+ | |0x940|clip tmp |0x0A0 bytes| | ||
+ | |0x9E0|Output to RDP |0x400 bytes| | ||
+ | |0xDE0|Scratch space |0x1E0 bytes| | ||
+ | |0xFC0|Task |0x040 bytes| | ||
+ | |||
+ | ===== Fast3D RSP Register Assignment ===== | ||
+ | |return |$31|| | ||
+ | |return_save|$30|| | ||
+ | |rsp_state |$29|| | ||
+ | |dlcount |$28|| | ||
+ | |dinp |$27|Pointer to current display list command in the input buffer in DMEM| | ||
+ | |inp |$26|Pointer to the current command block in RDRAM| | ||
+ | |gfx0 |$25|Display list command high word| | ||
+ | |gfx1 |$24|Display list command low word| | ||
+ | |outp |$23|| | ||
+ | |in_bufp |$22|| | ||
+ | |zero |$0 || | ||
+ | |||
---- | ---- | ||
===== References ===== | ===== References ===== | ||
Line 811: | Line 887: | ||
* http://wiki.cloudmodding.com/oot/F3DZEX/Opcode_Details | * http://wiki.cloudmodding.com/oot/F3DZEX/Opcode_Details | ||
* http://ultra64.ca/files/documentation/silicon-graphics/SGI_RDP_Command_Summary.pdf | * http://ultra64.ca/files/documentation/silicon-graphics/SGI_RDP_Command_Summary.pdf | ||
+ | * https://www.docdroid.net/NXMlF3s/grucode.pdf |