# TrueReality - RDP documentation                                       #
# Copyright (C) 1999 Niki W. Waibel                                     #
#                                                                       #
# This program is free software; you can redistribute it and/           #
# or modify it under the terms of the GNU General Public Li-            #
# cence as published by the Free Software Foundation; either            #
# version 2 of the Licence, or any later version.                       #
#                                                                       #
# This program is distributed in the hope that it will be use-          #
# ful, but WITHOUT ANY WARRANTY; without even the implied war-          #
# ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         #
# See the GNU General Public Licence for more details.                  #
#                                                                       #
# You should have received a copy of the GNU General Public             #
# Licence along with this program; if not, write to the Free            #
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,         #
# USA.                                                                  #
#                                                                       #
# Information about me (the author):                                    #
#   Niki W. Waibel, Reichenau 20, 6890 Lustenau, Austria - EUROPE       #
#   niki.waibel@gmx.net                                                 #


=========================================================================
 This is some sort of the RDP (Reality Display Processor?) documentation.
=========================================================================


All of this stuff was figured out by disassembling/emulating various demos
with TrueReality.
All things which I'm not sure about are marked with a '?'.





modes:
        1cycle  0       00
        2cycle  1       01
        copy    2       10
        fill    3       11 ... the bits are stored in bit 20 and 21 in mode_h
                               which is set by HLE RDP command RDPSETMODE_H.

        In the last 2 modes you can draw normally.
        In the first 2 you must not draw the right and bottom edges.
        This might be used for aliasing stuff.





rdp format/size combinations:

  /================================================\
 ||  format| RGBA  |  YUV  |  CI   |  IA   |   I   ||
 ||==bit==/+=======================================||
 ||   4   ||   -   |   -   |   X   |   -   |   X   ||
 ||-------||-------+-------+-------+-------+-------||
 ||   8   ||   -   |   -   |   X   |   X*  |   X   ||
 ||-------||-------+-------+-------+-------+-------||
 ||  16   ||   X   |   ?   |   ?   |   X*  |   ?   ||
 ||-------||-------+-------+-------+-------+-------||
 ||  32   ||   X   |   ?   |   ?   |   ?   |   ?   ||
  \================================================/

        RGBA: RGBA format. Red is the MSB. 5551 for 16bit and 8888 for 32bit.
        YUV:  YUV format.
        CI:   Color indexed format.
        IA:   Intensity and alpha format.
        I:    Intensity format.

        X:    This combination is valid.
        -:    Not valid.

        *:    The 16/8 bit value is divided into 2 8/4bit values.
              One for intensity - one for alpha.





rsp dmem (this might depend on the lib which is used):

        mem     offset  name            content

        0070: MOVEWORD CLIP mem
           ?    ?       ?
           ?: end

        00bc: Pointer to RSP COMMANDS
          bc    0       DMA             13c4
          be    2       DMA (not used)  10a8
          c0    4       IMM             11f8
          c2    6       RDP             1384
        00c4: end

        00d4: Pointer to RSP IMM COMMANDS
          d4    0       ?               10a8
          d6    2       ?TRI2           10a8
          d8    4       RDPHALF_CONT    1378
          da    6       RDPHALF_2       137c
          dc    8       RDPHALF_1       1370
          de    a       LINE3D          10a8
          e0    c       CLEARMATRIXMODE 1358
          e2    e       SETMATRIXMODE   1348
          e4    10      ENDDL           1328
          e6    12      SETOTHERMODE_L  12cc
          e8    14      SETOTHERMODE_H  12c4
          ea    16      TEXTURE         12a0
          ec    18      MOVEWORD        1288
          ee    1a      POPMATRIX       124c
          f0    1c      CULLDL          130c
          f2    1e      TRI1            1208
        00f4: end

        0110: r29
         110    0
         114    4       GEOMETRYMODE
         118    8       OTHERMODE_H
         11c    c
         120   10       TEXTURE (cmd0)
         124   14       TEXTURE (cmd1)
         128   18
         12c   1c
        ????: end

        012c: MOVEWORD NUMLIGHT mem
           ?    ?       ?
           ?: end

        0160: MOVEWORD SEGMENT mem
         160    0       seg00
         164    4       seg01
         168    8       seg02
         16c    c       seg03
         160    10      seg04
         164    14      seg05
         168    18      seg06
         16c    1c      seg07
         160    20      seg08
         164    24      seg09
         168    28      seg10
         16c    2c      seg11
         160    30      seg12
         164    34      seg13
         168    38      seg14
         16c    3c      seg15
        016e: end

        01f0: MOVEWORD LIGHTCOL mem (0xRRGGBB??: ?? ignored)
         1f0    0       lightcolor0
         1f4    4       lightcolor1
         1f8    8       lightcolor2
         1fc    c       lightcolor3
         1f0    10      lightcolor4
         1f4    14      lightcolor5
         1f8    18      lightcolor6
         1fc    1c      lightcolor7
        0200: end

        030e: Indices for MOVEWORD
                0       MATRIX          03e0
                2       NUMLIGHT        012c
                4       CLIP            0070
                6       SEGMEMT         0160
                8       FOG             0330
                a       LIGHTCOL        01f0
                c       POINTS          0420
                e       PERSPNORM       0110
        031e: end

        0330: MOVEWORD FOG mem
           ?    ?       ?
           ?: end

        03e0: MOVEWORD MATRIX mem
                0       0x0 (integer)
                2       0x1 (integer)
                4       0x2 (integer)
                6       0x3 (integer)
                8       1x0 (integer)
                a       1x1 (integer)
                c       1x2 (integer)
                e       1x3 (integer)
                10      2x0 (integer)
                12      2x1 (integer)
                14      2x2 (integer)
                16      2x3 (integer)
                18      3x0 (integer)
                1a      3x1 (integer)
                1c      3x2 (integer)
                1e      3x3 (integer)
                20      0x0 (fraction)
                22      0x1 (fraction)
                24      0x2 (fraction)
                26      0x3 (fraction)
                28      1x0 (fraction)
                2a      1x1 (fraction)
                2c      1x2 (fraction)
                2e      1x3 (fraction)
                30      2x0 (fraction)
                32      2x1 (fraction)
                34      2x2 (fraction)
                36      2x3 (fraction)
                38      3x0 (fraction)
                3a      3x1 (fraction)
                3c      3x2 (fraction)
                3e      3x3 (fraction)
        0420: end

        0420: MOVEWORD POINTS mem
                0       vertex0
                28      vertex1
                50      vertex2
                78      vertex3
                a0      vertex4
                c8      vertex5
                f0      vertex6
                118     vertex7
                140     vertex8
                168     vertex9
                190     vertex10
                1b8     vertex11
                1e0     vertex12
                208     vertex13
                230     vertex14
                258     vertex15
        06a0: end

        06a0: actual command -> r27=$6a0 r25=cmd0 r24=cmd1
        06a8: end

        07e0: MOVEMEM VIEWPORT -> v0
        07e0: MOVEMEM LIGHT x  -> v0
        07f0: end

        0ff0: Initial Display List Pointer
                0       DL
        0ff4: end

