#
#  Nintendo64 RDP Info Text, Copyright (C) 1998 by Michael Tedder
#  --------------------------------------------------------------
#
#  Includes a description of the RDP and some of its commands.
#

Important Things:
-----------------

) Most of the parameters for the RDP (like locations, sizes, etc) are 12 bits,
  in a 10.2 fixed point format.

) The first 8 bits of the 64 bit instruction for the RDP is a command.  This
  value ranges between C0h and FFh.

) An RDP full sync is *required*, even on the N64.  The RDP generates a DP
  interrupt upon executing this command.

) The RDP has 4k of texture memory native to itself.  It is not mapped into the
  N64's address space in any way.

) The RDP can only load 2k of data at once.  In order to load a full 4k, a
  halfword transfer must be used.  The ucode transparently does this by
  saying a texture is 2k of 16bpp even if it's only 8bpp.  This is why there
  is more than one 'set tile' command per render.

) A 'tile' is marked as a section of the RDP's texture memory.  This tile can
  map to the entire 4k, or multiple tiles can be specified with their own
  pointers into TMEM.  (Mortal Kombat did this on the second screen --
  unfortunately Project UnReality never had this support added by the time
  I realized what it was...)

) Some RDP commands use one generalized bitmask for parameter passing.  I have
  not yet been able to filter out the "unimportant" parameters for some of the
  commands except for LoadTLUT.  The following commands use the 'Load tile'
  block: G_LOADBLOCK, G_SETTILESIZE, and G_LOADTLUT.  I will have to filter
  through the RSP DL creation to decide which parameters are necessary and
  which ones aren't.  (Which is how I figured out G_LOADTLUT; see GBI.H,
  line 3463: gDPLoadTLUTCmd(pkt, G_TX_LOADTILE, 255); )

) Most RDP commands are 64 bits in size.  The only exception to this rule
  (thus far) is E4 and E5 (draw textured rectangle) which are 128 bits.  I
  have heard that the triangle draw commands are *much* larger (but I have
  yet to see them myself.)

) SGI/N uses 'S' and 'T' to signify texture coordinates (bleah).  I prefer
  'U' and 'V', but anyway...

) The RDP apparently processes commands while the RSP is writing them to DMEM.
  There are checks to ensure that the RDP CMD current isn't about to get
  stomped over in the ucode.  Also, the RSP writes the new command to DMEM
  before advancing the RDP CMD end.

) The RSP makes no attempt to tell the RDP it has completed a display list or
  task.

) All of the RDP's coordinates appear to be flipped.  For example, a fill
  rectangle command renders with the coordinates (319, 239), (0, 0) to clear
  the frame buffer.

===============================================================================

Commands:
---------

C0) No-op: does nothing.

C8) TriFill: draws a filled triangle.

C9) TriFillZBuf: draws a z-buffered filled triangle.

CA) TriTxtr: draws a textured triangle.

CB) TriTxtrZBuf: draws a z-buffered textured triangle.

CC) TriShade: draws a filled, shaded triangle.

CD) TriShadeZBuf: draws a z-buffered filled, shaded triangle.

CE) TriShadeTxtr: draws a textured, shaded triangle.

CF) TriShadeTxtrZBuf: draws a z-buffered, textured shaded triangle.

E4) Draw textured rectangle: draws a tile to the current frame buffer.

E5) Draw flipped textured rectangle: draws a flipped tile to the current
    frame buffer.

E6) RDP load sync: synchronizes the RDP's texture loader, ensuring any
    current texture load op has been completed.

E7) RDP pipe sync: synchronizes the RDP's pipeline, ensuring any rendering
    or load TLUT (texture lookup) has been completed.

E8) RDP tile sync: synchronizes the RDP's tile cache, ensuring a previous
    set tile command has been completed.

E9) RDP full sync: flushes and immediately completes all pending operations
    and generates a DP interrupt.

EA) SetKeyGB: Sets a chroma key to a green/blue color???

EB) SetKeyR: Sets a chroma key to a red color???

EC) Set convert: ???

ED) Set scissor: sets a 2D clipping plane for all rendering operations.  all
    renders will be placed within this area of memory.  (extremely useful for
    split screens)

EE) Set prim depth: ???

EF) Set other mode: ???

F0) Load TLUT: loads a 16 or 256 color index lookup table for palettized
    textures.  a previous set texture image is used as the raw data for the
    palette.

F2) Set tile size: sets the X and Y size of a tile through parameters SH and
    TH.

F3) Load block: loads a block into the RDP's texture memory.  I'm not sure
    how this differs from load tile...

F4) Load tile: loads a tile into the RDP's texture memory.  SH and TH are the
    X and Y size of the tile to load.  note that the RDP only has 4k of texture
    memory and it can only load 2k at once.  (see Important Things above)

F5) Set tile: sets up flags for a tile to-be-loaded or already-loaded.  this
    specifies the type of the tile (RGBA, YUV, CI [color index via a palette]),
    the size (also known as bitdepth, which is usually G_IM_SIZ_16b for RGBA
    and G_IM_SIZ_8b for CI), the offset of this tile into texture memory (tmem),
    and other bitflags that control texture clamping and/or mirroring.

F6) Fill rectangle: draws a filled rectangle to the current frame buffer, using
    the current fill color.

F7) Set fill color: sets the color to be used for fill operations (like F6).

F8) Set fog color: sets the fog color?

F9) Set blend color: sets the texture blender color?

FA) Set prim color: sets the primary color?

FB) Set env color: sets the environment color?

FC) Set combine mode: ??? messes with the RDP's color combiner ???

FD) Set texture image: sets the pointer, format, and size of a texture map,
    most commonly used before a load operation.  this appears to be changed
    by a set tile command later which is incorrect.  the valid parameters for
    format and size are passed into to this command.

FE) Set z-buffer image: sets the pointer, format, and size of the Z-buffer
    to use for triangle drawing.

FF) Set frame buffer: sets the pointer, format, and size of the frame buffer
    for the RDP to use.

