home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_03 / JAG_DOX.ZIP / blitter.txt < prev    next >
Text File  |  1996-01-28  |  35KB  |  894 lines

  1. # -------------------------------------------------------------------
  2. # BLITTER                               (c) Copyright 1996 Nat! & KKP
  3. # -------------------------------------------------------------------
  4. # These are some of the results/guesses that Klaus and Nat! found
  5. # out about the Jaguar with a few helpful hints by other people, 
  6. # who'd prefer to remain anonymous. 
  7. #
  8. # Since we are not under NDA or anything from Atari we feel free to 
  9. # give this to you for educational purposes only.
  10. #
  11. # Please note, that this is not official documentation from Atari
  12. # or derived work thereof (both of us have never seen the Atari docs)
  13. # and Atari isn't connected with this in any way.
  14. #
  15. # Please use this informationphile as a starting point for your own
  16. # exploration and not as a reference. If you find anything innacurate,
  17. # missing, needing more explanation etc. by all means please write
  18. # to us:
  19. #      nat@zumdick.rhein-main.de
  20. # or
  21. #      kkp@gamma.dou.dk
  22. #
  23. # If you could do us a small favor, don't use this information for
  24. # those lame flamewars on r.g.v.a or the mailing list.
  25. #
  26. # HTML soon ?
  27. # -------------------------------------------------------------------
  28. # $Id: blitter.txt,v 1.11 1996/01/28 20:23:19 nat Exp $
  29. # -------------------------------------------------------------------
  30.  
  31. Incomplete.
  32. Be wary that some stuff which sounds like we know what we're talking
  33. about, might be just a guess w/o a check :)
  34.  
  35.  
  36. The BLiTTER
  37. -----------
  38.  
  39. The Blitter is a little different to what you're used to
  40. on your ST (and you probably didn't get used to it very much
  41. anyway).
  42.  
  43. You can blit a scaled pixmap to an unscaled destination
  44. or you can blit an unscaled pixmap unto a scaled destination. Or you can
  45. rotate the source and the destination bitmap, and in some cases you
  46. can scale and rotate at the same time (I think scaling up and rotating
  47. without leaving holes isn't possible)
  48.  
  49. The former will probably be the most often used. The source or the
  50. destination can be arbitrarily 'angled' lines and need not be
  51. contigous addresses. Furthermore you can blit pixels of 1 bit, 2 bit
  52. 4 bit 8 bit 16 bit or 32bit depth.
  53.  
  54. The Blitter in broad outline works like this:
  55.  
  56. The blitter has two channels called A1 and A2, where it reads from and 
  57. writes data to.
  58. A1 is the sophisticated channel allowing fractional pixel treatment
  59. (like f.e. read pixel 1 twice, then pixel2 twice etc. for an effective
  60. scaling of 2.0), whereas A2 is a simple channel allowing only integer
  61. increments of the addresses. This means that A2 can only be used for
  62. straight or diagonal lines.
  63.  
  64. Picture in your mind that a channel is pointing to a square bitmap. 
  65. You define the width of this bitmap and the origin at which the blitter 
  66. should start fetching data. The origin might for example be the center 
  67. of your bitmap, or the upper left corner, you decide!.
  68. You then define the orientation (slope) of the line the blitter should
  69. 'draw' into (or 'fetch' from) this bitmap.
  70.  
  71.             .....width.......
  72. channel --> +----------------+
  73.             |                |
  74.             |  x  (origin)   | 
  75.             |   \            |
  76.             |    \  (slope)  |
  77.             |                |
  78.             +----------------+
  79.  
  80.  
  81. In a real life environment you might for example use A2 as the source
  82. of your texture, that is stored as a contigous block in memory and
  83. A1 is used to draw an arbitrary scaled and angled line of your polygon.
  84. Or you might use A1 to traverse the texture data at an arbitrary angle
  85. and update the destination pixmap in a scanline fashion horizontally
  86. left to right.
  87.  
  88. If you want to scale the bitmap you gotta figure out whether you want
  89. to shrink or to enlarge. If you want to enlarge, you need to use A1
  90. as the source and A2 as the destination, using fractional incrementing
  91. on the source, if you want to shrink you want to use A1 as the destination
  92. (also with fractional increments)
  93.  
  94.  
  95. You can do a few operations concurrently while blitting your data.
  96.  
  97. If you're drawing with a single color and outputting crycolor pixels 
  98. you can gouraudshade them at the same time at no extra cost. The 
  99. blitter will use the intensity of the pixel and add the contents of a 
  100. register to it (saturating add).
  101. The contents of this register are then updated for the next pixel.
  102. Since the update is fractional, you can achieve a smooth shaded
  103. line with this.
  104.  
  105. You can add an intensity factor to your incoming crycolor data.
  106.  
  107. ***********************************************************************
  108. Z-BUFFER DOC IS WRITTEN WITH NO KNOWLEDGE ABOUT THE SUBJECT WHATSOEVER 
  109. ***********************************************************************
  110. You can also use the Z-buffering capabilities of the blitter. 
  111. Your destination data is not just an array of pixel values, but rather a 
  112. combination of Z-data and pixel data. Consider the Z-data to be the 
  113. third coordinate providing depth. 
  114. The smaller the value, the nearer it is to the viewer. (usual convention)
  115. You set up the blitter with a starting Z-value for your line and a factor 
  116. that should be added for every pixel step, thereby possibly increasing 
  117. or decreasing the Z-position. 
  118.  
  119. That value is then compared to the Z-data of the destination pixel. 
  120. If the z-value (in the registers) is less than the the destination value, 
  121. the pixel will be written - else the pixel will not be written. The 
  122. destination pixel is then updated with the new Z-buffer value. 
  123. The Z-data is 8 bit large ?
  124.  
  125. Unfortunately Z-buffering in detail is still unknown.
  126.  
  127. You can probably do collision detection on background colors, and
  128. transparent blits...
  129.  
  130.  
  131. Phrasemode and Pixelmode. 
  132. ------------------------
  133.  
  134. The blitter can operate either in pixelmode or in phrasemode. Phrasemode
  135. is (in 16-bit crycolor) usually four times faster and is therefore much more
  136. desirable. But there are some limitations that are connected to phrasemode:
  137.  
  138. o  Both A1 and A2 must work in phrasemode, you can't have one running in
  139.    pixelmode and the other in phrasemode
  140.  
  141. o  Phrasemode implies linear address (or horizontally oriented) blits
  142.    It looks like phrasemode doesn't work with all resolutions. So
  143.    far only 16bit modes are known to work.
  144.  
  145. Scales and rotates aren't possible in phrasemode.
  146. [ Please note, that you can do (non rotated) sprite scaling also with an OP
  147. object, which might (or not) be more convenient ]
  148.  
  149. There's probably something wrong with my understanding of the blitter,
  150. because I have a problem with the source DMA channel of the blitter.
  151. Currently you gotta figure, that the machine takes
  152.  
  153.    time = 1 write + [4 cyles read source] + [1 cycle read destination]
  154.    
  155. regardless of pixelmode or phrasemode. Of course in phrasemode you usually
  156. speed up the blitting process in 16 bit pixel mode by a factor of four.
  157.  
  158. Maybe the delay in the read is needed to get the ROM timings (32bit
  159. organized and maybe needing one waitstate) correct. If this is rite
  160. then there should be a bit somewhere to turn this off. But where is it ? 
  161. It seems not to be in the CMD register.
  162.  
  163. But if the above is true this means, that the Blitter is capable of doing
  164. approximately about:
  165.  
  166.    Gouraud pixelmode  : 13.3 / 1 = 13.3 Mio pixels / second
  167.                               or ca. 222000 pixels / frame
  168.    Copyblit pixelmode : 13.3 / 5 =  2.7 Mio pixels / second 
  169.                                or ca. 44000 pixels / frame
  170.    XOR blit pixelmode : 13.3 / 6 =  2.2 Mio pixels / second
  171.                                or ca. 37000 pixels / frame
  172.  
  173. and in phrasemode (16 bit pixels)
  174.  
  175.    Gouraud phrasemode : 13.3 * 4 / 1 = 53.2 Mio pixels / second
  176.                                   or ca. 887000 pixels / frame
  177.    Copyblit pixelmode : 13.3 * 4 / 5 =  2.7 Mio pixels / second 
  178.                                   or ca. 177000 pixels / frame
  179.    XOR blit pixelmode : 13.3 * 4 / 6 =  2.2 Mio pixels / second
  180.                                   or ca. 148000 pixels / frame
  181.  
  182.  
  183. B_CMD:
  184. ----------
  185.  32       28        24        20       16       12        8        4        0
  186.   +-+------^--------+^--------+^------+-^-----+--^--+-----^----+---^--+-----+
  187.   | |   control     |   OP    | z-op  |  ity  | mode|A1ctl|misc| dst  | src |
  188.   +-+---------------+---------+-------+-------+-----+-----+----+------+-----+
  189.          30..25       24...21   20..18 17..14  13.11 10..8 7..6  5..3  2..0
  190.  
  191. Writing into the lower word activates the blitter! Reading this register
  192. gives the blitter status (bit #0 == blitter idle if set)
  193.  
  194.  
  195. src:
  196.         bit 0: SRCEN   source data read enable
  197.         bit 1: SRCENZ  source Z-data read enable
  198.         bit 2: SRCENX  source extra data read enable
  199.  
  200.    With this set of bits you tell the blitter what kind of
  201.    data accesses it needs to perform. It can not figure it out from the
  202.    way the other command bits are set and conclude what it needs to
  203.    do, you have to instruct the blitter yourself. If you're doing
  204.    straight copies from memory to memory, you will want to set bit0.
  205.    If you're using the Z-buffer capabilities you'd want to set bit1
  206.    as well.
  207.    If your source data spans more phrases than the destination data
  208.    then you need to set bit2 to tell the blitter to do that extra 
  209.    phrase read.
  210.  
  211. dst:
  212.         bit 3: DSTEN   destination data read enable
  213.         bit 4: DSTENZ  destination Z-data read enable
  214.         bit 5: DSTWRZ  destination Z write enable
  215.  
  216.    You'd want to set bit3, if you're doing read-write-modify cycles on
  217.    the destination, say f.e. you're doing DST &= SRC or somesuch. Else
  218.    you should clear this bit (or pay the price in speed decrease).
  219.    Likewise if you're not going to do Z-buffer blitting keep bits 4 and 5
  220.    clear, else set'em!
  221.    Note that you can not disable 'destination write' because, you'd just
  222.    not use the Blitter in this case, right ?
  223.  
  224. misc:
  225.         bit 6: CLIP_A1 enable A1 clipping
  226.         bit 7:         unused
  227.  
  228.    You can clip the pixmap that is handled with the A1 register set.
  229.    If this bit is set, then the information in the A1_CLIP register is
  230.    used to clip the A1 lines. See A1_CLIP for more information about
  231.    clipping.
  232.  
  233. A1-control (A1ctl):
  234.         bit 8: UPDA1   enable A1 update step fraction part
  235.         bit 9: UPDA1F  enable A1 update step integer part
  236.         bit10: UPDA2   enable A2 update step
  237.  
  238.   You hint the Blitter here, which step registers it should update.
  239.   If you're just doing linedrawings you don't need any of these bits
  240.   set. Only when you're blitting in two dimensions you need to consider
  241.   these bits. The idea behind them is probably not that you can
  242.   improve the blitter performance but rather the setup performance,
  243.   since you know which registers change and which not and need not
  244.   update all of them for consecutive blits.
  245.  
  246. mode:
  247.         bit11: DSTA2   use A2 as destination
  248.         bit12: GOURD   enable Gouraud shading
  249.         bit13: ZBUFF   enable Z-buffer handling
  250.  
  251.    Usually (bit11 cleared) you use A2 as the source and A1 as the
  252.    destination. You can reverse the roles by setting this bit.
  253.    Set bit12 to enable Gouraudshading. Gouraudshading will only
  254.    be "gouraud shading" if used on crycolor data. Use the intensity
  255.    counters/incrementers to specify the shading (see B_IINC for
  256.    further reference)
  257.    With bit13 you enable Z-buffer handling (look for the A1_FLAGS for
  258.    a small description of Z-buffer handling).
  259.  
  260.  
  261. intensity (ity) and other stuff:
  262.         bit14: TOPBEN   carry into nybble
  263.         bit15: TOPNEN   carry into byte
  264.         bit16: PATDSEL  use pattern data (instead of source)
  265.  
  266.   Bit14 and 15 will all be explained in the gouraud shading description
  267.   coming up soon. You can control with the bit 14 + 15 where the overflow
  268.   from the intensity addition should be stored (added to)
  269.   On a completely different note, if you just want to initialize a
  270.   memory region (or draw a line) in a single color, you don't need to
  271.   read the source data from memory. You can let the blitter pull the
  272.   color from one of its own registers (B_PATD). This saves you on
  273.   the average a read cycle for every phrase written, which is a good
  274.   thing. None of the logical blitter operations apply when using the 
  275.   pattern data register. You can't XOR your bitmap with the pattern data!
  276.  
  277. z-op:
  278.         bit18-20:
  279.  
  280.         bit18: ZMODELT  source < destination
  281.         bit19: ZMODEEQ  source = destination
  282.         bit20: ZMODEGT  source > destination
  283.  
  284.         or
  285.  
  286.         0:      unused
  287.         1:      src < dst
  288.         2:      src == dst
  289.         3:      src <= dst
  290.         4:      src > dst
  291.         5:      src != dst
  292.         6:      src >= dst
  293.         7:      unused
  294.  
  295.    You can tell the blitter how to decide, whether the source data should
  296.    overwrite the destination pixel or not when using the Z-buffer mode.
  297.    Usually you will want to put a 3 or a 1 here, so that you're
  298.    'nearer' pixels overwrite the 'farther' pixels. (Assuming that your
  299.    Z-buffer values are the higher, the farther away from the viewer
  300.    they are)
  301.  
  302. OP:     logical operation the Blitter should perform
  303.  
  304.         bit21: LFU_NAN  ! source & ! destination
  305.         bit22: LFU_NA   ! source &   destination
  306.         bit23: LFU_AN     source & ! destination
  307.         bit24: LFU_A      source &   destination
  308.  
  309.    or
  310.  
  311.          0: LFU_ZERO     DST = 0              (LFU_CLEAR)
  312.          1: LFU_NSAND    DST = ! SRC & ! DST
  313.          2: LFU_NSAD     DST = ! SRC & DST
  314.          3: LFU_NOTS     DST = ! SRC
  315.          4: LFU_SAND     DST = SRC & ! DST
  316.          5: LFU_NOTD     DST = ! DST
  317.          6: LFU_N_SXORD  DST = ! (SRC ^ DST)
  318.          7: LFU_NSORND   DST = ! SRC | ! DST
  319.          8: LFU_SAD      DST = SRC & DST
  320.          9: LFU_SXORD    DST = SRC ^ DST     (LFU_XOR)
  321.         10: LFU_D        DST = DST
  322.         11: LFU_NSORD    DST = ! SRC | DST
  323.         12: LFU_S        DST = SRC           (LFU_REPLACE)
  324.         13: LFU_SORND    DST = SRC | ! DST
  325.         14: LFU_SORD     DST = SRC | DST
  326.         15: LFU_ONE      DST = 1
  327.  
  328.    Just as on the Atari ST blitter you can have the usual set of
  329.    logical operations you can perform on your data. Use 12 for your
  330.    copying blits and 0 for your single color initilization. Note that
  331.    if you set bit16 (use pattern data), then the blitter will NOT
  332.    zero your buffer with OP==0, but fill it with the pattern color
  333.    instead.
  334.    The opcodes are ignored when bit16 is set.
  335.  
  336. control:
  337.       bit25: CMPDST   compare destination pixel with pattern pixel
  338.       bit26: BCOMPEN  bit compare write inhibit
  339.       bit27: DCOMPEN  data compare write inhibit
  340.       bit28: BKGWREN  unknown
  341.       bit29: BUSHI    hog the bus
  342.       bit30: SRCSHADE source shading
  343.  
  344.    bit25:   If you enable this the destination pixel (that will be 
  345.    overwritten) is compared with the value stored in the pattern-data 
  346.    register (B_PATD). 
  347.    If you enable this in conjuction with B_STOP this _maybe_ is used as 
  348.    a way to do hardware collision detection. (like in GTIA on the Atari
  349.    8 bit)
  350.  
  351.    bit26:   speculation: The lower 8 bit of the source value are examined.
  352.    If all bits are 0 then nothing will be written back, if all of them
  353.    are set then everything will be written back. Now what happens if there
  354.    are just a few bits set ? 
  355.    Imagine that the pixels of the destination pixmap are numbered from
  356.    7 to 0 wrapping at -1 back to 8.
  357.       
  358.      Start of line blit
  359.         \                    
  360.          7654321076543210765
  361.                ^
  362.                current pixel position     
  363.  
  364.      Source pixel value:   0xFF55  ->  11111111 01010101
  365.  
  366.          76543210
  367.          01010101
  368.                ^
  369.    
  370.      So this pixel value will not be written.
  371.    
  372.    Don't ask me what that might be good for.   
  373.  
  374.    
  375.    bit27:   used in conjunction with bit25. If you set bit25 and bit27 the
  376.    effect will be that only those destination values will be overwritten 
  377.    that do not match the value stored in B_PATD. 
  378.    So if you put the color 0x0000 into B_PATD only those pixels will be 
  379.    written, where there are not zerovalued pixels in the destination bitmap. 
  380.    You should have DSTEN on!
  381.  
  382.    bit28:   still no idea yet
  383.  
  384.    bit29:   seems to let the blitter hog the bus completely. This is not such
  385.    a good idea for extensive blits, since apparently the OP is also shut off
  386.    and you'll see garbage on the screen. For small blits this might yield
  387.    an overall system performance increase, when you're pushing the machine
  388.    to its limits.
  389.  
  390.    bit30:   Enable source shading. Yes it does work, although the setup is
  391.    a bit weird because you seem to have to set bit3 (destination read enable)
  392.    for real source shading to happen. Put the shade value into B_IINC. Looks
  393.    really cool.
  394.    You can get some funky albeit as yet unpredictable (?) effects putting
  395.    a value in B_DSTD and disabling the destination read. F.e. put the 
  396.    B_IINC to $40000 and blit repeatedly incrementing B_DSTD (and delaying
  397.    a little between blits). It's psychedelic!
  398.  
  399.  
  400. B_COUNT:
  401. --------
  402.  
  403.   32      28        24        20       16       12        8        4        0
  404.   +--------^---------^---------^--------+--------^--------^--------^--------+
  405.   |                n_lines              |               n_pixels            |
  406.   +-------------------------------------+-----------------------------------+
  407.                    16 bit                               16 bit
  408.  
  409.    n_pixels:   number of pixels to draw in a line
  410.    n_lines:    number of lines to draw 
  411.  
  412.    You need to draw at least one line of size one pixel. After n_pixels are 
  413.    drawn the STEP registers are applied to the current pixel position and
  414.    blitting resumes.
  415.  
  416.  
  417. B_IINC + B_I0-3:
  418. ---------------
  419.  
  420.  32       28        24        20       16       12        8        4        0
  421.   +--------+---------+---------^--------+--------^--------^--------^--------+
  422.   |chroma.i|chroma.f |  intensity.i     |             intensity.f           |
  423.   +--------+---------+------------------+-----------------------------------+
  424.      4 bit    4 bit          8 bit                       16 bit
  425.  
  426.   chroma.i:             delta for chroma change, integer part
  427.   chroma.f:             delta for chroma change, fractional part
  428.   intensity.i           delta for gouraud shading, integer part
  429.   intensity.f:          delta for gouraud shading, fractional part
  430.   
  431.   This register is used for chroma changes and gouraud shading (or 
  432.   both operations together). Chroma changes are like gouraud shades,
  433.   but with an intensity delta of zero. Pure gouraud shadings have a chroma
  434.   delta value of zero.
  435.   This register is added to either B_PATD in pixelmode or B_I0 to B_I3 in 
  436.   phrasemode. The intensity is saturation added, meaning that you can't 
  437.   have an intensity wrap around. The chroma change on the other hand does
  438.   wrap around. The integer part is by the way sign extended.
  439.   So normally chroma and intensity are two seperate entities that don't 
  440.   influence each other. If you want you can set in the B_CMD register
  441.   either TOPBEN or TOPNEN. 
  442.   If you set TOPNEN then the carry of the saturation add will be added to
  443.   the upper nyblle (chroma.i) of the current source data value.
  444.   If you set TOPBEN then there will be _no_ saturation for the addition 
  445.   of the intensity delta. Instead the carry is added to the top byte of 
  446.   the current source data value. 
  447.   
  448.   B_I0, B_I1, B_I2, B_I3 are used in phrasemode instead of B_IINC, 
  449.   which used in pixelmode.
  450.  
  451.  
  452. B_DSTD:
  453. ------
  454.  32       28        24        20       16       12        8        4        0
  455.   +--------^---------^---------^--------^--------^--------^--------^--------+
  456. 0 |                                 pixelvalue                              |
  457.   +-------------------------------------------------------------------------+
  458.  
  459.  64       60        56        52       48       44       40       36        32
  460.   +--------^---------^---------^--------^--------^--------^--------^--------+
  461. 1 |                                 pixelvalue                              |
  462.   +-------------------------------------------------------------------------+
  463.    
  464.   pixelvalue:
  465.   
  466.   If you're doing RMW-cycles with the blitter and have not enabled data
  467.   reads, then this register will be used as input for the logical operations
  468.   instead.
  469.   
  470.   Depending on the blittermode (pixelmode or phrasemode) there is either
  471.   only one pixel kept in here (phrase 0) rightside aligned by the way,
  472.   or as many pixels that can fit in a phrase.
  473.   
  474.   Experiments show that the value in DSTD is NOTed before being used as
  475.   a logical operation. Curious.
  476.   
  477.   f.e.
  478.     move.l    #(1<<16)|WIDTH,B_COUNT
  479.     move.l    #PITCH1|PIXEL16|WID320|XADDPIX,A1_FLAGS
  480.     move.l    #PITCH1|PIXEL16|WID320|XADDPIX,A2_FLAGS
  481.       move.l    #$00000FFFF,B_DSTD
  482.     move.l    #SRCEN|LFU_XOR,d0
  483.  
  484.     is actually a straight replacement, although one would expect
  485.     
  486.         S ^ 0xFFFF to yield ~S and not S
  487.   
  488.     
  489.  
  490. B_SRCD:
  491. ------
  492.  32       28        24        20       16       12        8        4        0
  493.   +--------^---------^---------^--------^--------^--------^--------^--------+
  494. 0 |                                 pixelvalue                              |
  495.   +-------------------------------------------------------------------------+
  496.  
  497.  64       60        56        52       48       44       40       36        32
  498.   +--------^---------^---------^--------^--------^--------^--------^--------+
  499. 1 |                                 pixelvalue                              |
  500.   +-------------------------------------------------------------------------+
  501.    
  502.   pixelvalue:
  503.   
  504.    This is probably just the same as B_DSTD but for those case when you
  505.    did not have source read enabled (bit #0 of the CMD register) and
  506.    when you haven't selected the pattern as the source of your blit.
  507.  
  508.  
  509.  
  510. B_STOP:
  511. ------
  512.   32      28        24        20       16       12        8        4        0
  513.   +--------^---------^---------^--------^--------^--------^--------^-+------+
  514.   |                                  unused                          | stop |
  515.   +------------------------------------------------------------------+------+
  516.  
  517.    stop: 
  518.       bit 0:
  519.       bit 1:
  520.       bit 2:
  521.  
  522.    Uses 3 bits to resume or stop after a write inhibit occures. Inhibit 
  523.    will occure when painting pixel-pixel mode, Xadd=1, BKGWREN=0, and one 
  524.    of the BCOMPEN, DCOMPEN or Zmodem0-2 are set, with matching conditions.
  525.  
  526.    ?????????????????????????
  527.  
  528.  
  529. A1_BASE:
  530. -------
  531.  
  532.   32      28        24        20       16       12        8        4        0
  533.   +--------^---------^---------^--------^--------^--------^--------^--------+
  534.   |                                  address                                |
  535.   +-------------------------------------------------------------------------+
  536.  
  537.    address:
  538.  
  539.    Pointer to the bitmap. The bitmap must (probably) be phrase aligned.
  540.    For pixel positioning use A1_PIXEL
  541.  
  542.  
  543.  
  544. A1_FLAGS:
  545. --------
  546.  
  547.   32      28        24        20       16       12        8        4        0
  548.   +--------^---------^--------+---------+--+-----^-----+--^---+----^-+------+
  549.   |            unused         | addctl  |  |   width   | z-off| depth| pitch|
  550.   +---------------------------+---------+--+-----------+------+------+------+
  551.                                 20...16       14...9     8..6    5..3  2..0
  552.                                           ^
  553. pitch:                                    +---- unused 
  554.       bit0-bit2: 
  555.  
  556.       0: 1 phrase
  557.       1: 2 phrases
  558.       2: 4 phrases
  559.       3: 8 phrases
  560.  
  561.    The amount of phrases the blitter should add to the address when
  562.    accessing the next phrase. Usually set to zero eh ?
  563.  
  564. depth:
  565.       bit3-bit5:
  566.  
  567.          colors         bitplanes           bits
  568.        ------------+-------------------+-------------
  569.       0: 2                 1                 1
  570.       1: 4                 2                 2
  571.       2: 16                4                 4
  572.       3: 256               8                 8
  573.       4: 32768/65536       16/CrY           16
  574.       5: 16 mio            24               32
  575.       6: unused
  576.       7: unused
  577.  
  578.    The pixel size the blitter should move. Remember all pixels on the
  579.    Jaguar are chunky (meaning the bits to a pixel are adjacent, not like
  580.    on the Amiga or the ST)
  581.  
  582. z-offset (z-off):
  583.  
  584.       bit6-bit8 gives the number of phrases the Z-data is offset from
  585.       your pixel phrase. Or so...
  586.       Apparently 0 and 7 are unusable values
  587.  
  588. width:
  589.    bit9-14:
  590.  
  591.       This is the width in pixels of a scanline of the area pointed
  592.       to by A1. Or in different words A1 points to a rectangular
  593.       block of pixels. The pixels are organized in horizontal strips.
  594.       You give the width of such a strip with this value.
  595.  
  596.       The number is not an integer value but rather a floating point
  597.       value (no kidding). It is made up like this:
  598.  
  599.       1.[bit14-13] * 2^[bit12-9] so for example
  600.  
  601.       01 0101   would be 1.25 * 2^5 = 40     or
  602.       10 1000   would be 1.5  * 2^8 = 384
  603.  
  604.          (1.00bin -> 1.00dec  1.01bin -> 1.25dec  
  605.           1.10bin -> 1.5dec   1.11bin -> 1.75dec)
  606.  
  607.                   or you can think of it as:
  608.       
  609.       x   = 1 << [bit12-9] 
  610.       res = x + (bit14 ? (x >> 1) : 0) + (bit15 ? (x >> 2) : 0);
  611.       
  612.       01 0101   would be 
  613.          x   = 1 << 5                              /* 32 */
  614.          res = 32 + (0 ? 16 : 0) + (1 ? 8 : 0);    /* 40 */
  615.  
  616.       Some often used values are:
  617.  
  618.           value   width    value   width    value   width
  619.          -------+-------  -------+-------  -------+-------
  620.             4       2        8       4       10       6
  621.            12       8       13      10       14      12
  622.            15      14       16      16       17      20
  623.            18      24       19      28       20      32
  624.            21      40       22      48       23      56
  625.            24      64       25      80       26      96
  626.            27     112       28     128       29     160
  627.            30     192       31     224       32     256
  628.            33     320       34     384       35     448
  629.            36     512       37     640       38     768
  630.            39     896       40    1024       41    1280
  631.            42    1536       43    1792       44    2048
  632.            45    2560       46    3072       47    3584
  633.  
  634.          
  635. adding control (addctl)
  636.  
  637. ** please note that the bit descriptions are as an exception
  638. ** interleaved
  639.  
  640.    Xadd control
  641.    bit16-17:
  642.       0: XADDPHR   add phrase offset to X and truncate
  643.       1: XADDPIX   add pixelsize (1) to X
  644.       2: XADD0     add zero (for those nice vertical lines)
  645.       3: XADDINC   add the contents of the increment register
  646.  
  647.    bit19: XSIGNADD/XSIGNSUB  pixel add operation, 0 = add 1 = subtract
  648.                              when using "add pixelsize" mode
  649.  
  650.    If you don't set any of these bits (0) then you are using the blitter
  651.    in phrase mode. That means that pixels are grabbed in lots of phrases
  652.    updated concurrently (one step) and written back in lots of phrases.
  653.    (lots as in "quantitysize", not as "many"). Obviously you can use the
  654.    phrasemode only for horizontal line blitting operations. Else you
  655.    need to put the Blitter in pixel mode (in CryMode ~4x slower).
  656.  
  657.  
  658.    Yadd control
  659.    bit18: YADD0/YADD1        add zero (clear) or one (set) to Y
  660.    bit20: YSIGNADD/YSIGNSUB  add 1/sub1 to Y (when bit18 is set)
  661.  
  662.  
  663.  
  664. A1_CLIP:
  665. --------
  666.  
  667.   32      28        24        20       16       12        8        4        0
  668.   +--------^---------^---------^--------+--------^--------^--------^--------+
  669.   |                height               |               width               |
  670.   +-------------------------------------+-----------------------------------+
  671.  
  672.    Height is the height and the width that the blitter should clip at
  673.    starting from the base. It does work but seems to be buggy. (i.e. 
  674.    sometimes clips one pixel to early)
  675.    
  676.  
  677. A1_PIXEL:
  678. --------
  679.  
  680.   32      28        24        20       16       12        8        4        0
  681.   +--------^---------^---------^--------+--------^--------^--------^--------+
  682.   |                 Y.i                 |               X.i                 |
  683.   +-------------------------------------+-----------------------------------+
  684.    
  685.    X.i:         horizontal position (integer part)
  686.    Y.i:         likewise vertical pixel offset 
  687.    
  688.         horizontal and vertical pixel offset from A1_BASE where the 
  689.         blitting operation should begin. Note that for the calculation
  690.         of the proper address offset, the blitter needs to know the
  691.         pixel size and the width of one line
  692.         
  693.  
  694. A1_FPIXEL:
  695. ---------
  696.  
  697.   32      28        24        20       16       12        8        4        0
  698.   +--------^---------^---------^--------+--------^--------^--------^--------+
  699.   |                 Y.f                 |                X.f                |
  700.   +-------------------------------------+-----------------------------------+
  701.  
  702.    X.i:         horizontal position (fractional part)
  703.    Y.i:         likewise vertical pixel offset 
  704.  
  705.   You can position the pixel value at a fractional pixel value using this
  706.   register. If you're using fractional steping rates, this register will
  707.   be updated as well as the integer A1_PIXEL register.
  708.  
  709.   Guess: 0.FFFF will still address pixel 0 and will not round up
  710.   to 1.
  711.  
  712.  
  713. A1_INC:
  714. ------
  715.  
  716.   32      28        24        20       16       12        8        4        0
  717.   +--------^---------^---------^--------+--------^--------^--------^--------+
  718.   |               unused                |          increment.i              |
  719.   +-------------------------------------------------------------------------+
  720.  
  721.   increment.i:          integer delta added to pixel position
  722.   
  723.      offset to add to A1_PIXEL after a pixel has been blitted.
  724.      this register is used only, if a certain addressing mode 
  725.      (bit16... of A1_FLAGS) is used.
  726.      Please also note the update A1 bits in the blitter command
  727.      for proper operation.
  728.              
  729.      The size is not yet known, but believed to be 16 bit
  730.    
  731.  
  732. A1_FINC:
  733. -------
  734.  
  735.   32      28        24        20       16       12        8        4        0
  736.   +--------^---------^---------^--------+--------^--------^--------^--------+
  737.   |               unused                |            increment.f            |
  738.   +-------------------------------------+-----------------------------------+
  739.  
  740.   increment.f:          fractional delta added to pixel position
  741.          As above but this is the fractional part of the stepper.
  742.          
  743.  
  744. A1_STEP:
  745. -------
  746.  
  747.   32      28        24        20       16       12        8        4        0
  748.   +--------^---------^---------^--------+--------^--------^--------^--------+
  749.   |               y_step.i              |               x_step.i            |
  750.   +-------------------------------------+-----------------------------------+
  751.  
  752.   x_step.i:     value to be added to A1_PIXEL.x
  753.   y_step.i:     value to be added to A1_PIXEL.y
  754.   
  755.   Values added to the pixelpointer after a line has been drawn.
  756.   You must set a bit in the control register to allow this update to happen.
  757.   
  758.  
  759. A1_FSTEP:
  760. --------
  761.  
  762.   32      28        24        20       16       12        8        4        0
  763.   +--------^---------^---------^--------+--------^--------^--------^--------+
  764.   |               y_step.f              |               x_step.f            |
  765.   +-------------------------------------+-----------------------------------+
  766.  
  767.   x_step.f:     value to be added to A1_FPIXEL.x
  768.   y_step.f:     value to be added to A1_FPIXEL.y
  769.   
  770.   Values added to the pixelpointer after a line has been drawn.
  771.   You must set a bit in the control register to allow this update to happen,
  772.   which is different than the control bit used for integer step updates!
  773.  
  774.  
  775.  
  776.  
  777. A2_BASE:
  778. -------
  779.  
  780.   32      28        24        20       16       12        8        4        0
  781.   +--------^---------^---------^--------^--------^--------^--------^--------+
  782.   |                                  address                                |
  783.   +-------------------------------------------------------------------------+
  784.  
  785.    See A1_BASE
  786.  
  787.  
  788.  
  789. A2_FLAGS:
  790. --------
  791.  
  792.   32      28        24        20       16       12        8        4        0
  793.   +--------^---------^--------+^--------+--+-----^-----+--^---+----^-+------+
  794.   |            unused         | addctl  |  |   width   | z-off| depth| pitch|
  795.   +---------------------------+---------+--+-----------+------+------+------+
  796.                                 20...16       14...9     8..6    5..3  2..0
  797.  
  798.    See A1_FLAGS
  799.  
  800.  
  801.  
  802. A2_PIXEL:
  803. --------
  804.  
  805.   32      28        24        20       16       12        8        4        0
  806.   +--------^---------^---------^--------+--------^--------^--------^--------+
  807.   |                 Y.i                 |               X.i                 |
  808.   +-------------------------------------+-----------------------------------+
  809.  
  810.    See A1_PIXEL
  811.         
  812.  
  813. A2_MASK:
  814. ------
  815.  
  816.   32      28        24        20       16       12        8        4        0
  817.   +--------^---------^---------^--------+--------^--------^--------^--------+
  818.   |               mask.y                |              mask.x               |
  819.   +-------------------------------------+-----------------------------------+
  820.  
  821.    mask.x:              x modulo value
  822.    mask.y:              y modulo value
  823.  
  824.    A2_MASK is probably used to mask off the pixel value of A2 creating
  825.    thereby a circular buffer
  826.  
  827.  
  828. A2_STEP:
  829. -------
  830.  
  831.   32      28        24        20       16       12        8        4        0
  832.   +--------^---------^---------^--------+--------^--------^--------^--------+
  833.   |               y_step.i              |               x_step.i            |
  834.   +-------------------------------------+-----------------------------------+
  835.  
  836.    See A1_STEP
  837.  
  838.   
  839.  
  840.  
  841. BUGS:
  842. -----
  843.  
  844. It seems that when the blitter is done with blitting it is so happy that
  845. it's done, it forgets to update the PIXEL registers with the STEP 
  846. registers (UPDA1 UPDA2 UPDA1F).
  847.  
  848. Therefore this:
  849.  
  850.    move.l   #$00400040,B_COUNT
  851.    move.l   #VALUE,B_CMD
  852.  
  853.         is not equivalent to this
  854.  
  855.    moveq    #$3F,d1
  856. .loop:
  857.    move.l   #$00010040,B_COUNT
  858.    move.l   #VALUE,B_CMD
  859. .wait:
  860.    move.l   B_CMD,d0
  861.    ror.w    #1,d0
  862.    bcc.b    .wait
  863.  
  864.    dbra     d1,.loop
  865.   
  866.  
  867.  
  868. Clipping seems to be buggy, occasionally clipping too early. (??)
  869.  
  870.  
  871. DISCUSSION:
  872. ----------
  873.  
  874. The designers of the Jaguar thought a lot about what makes a good
  875. blitter and not. Important for a good blitter is that the setup time
  876. is minimal. One of the reasons the Atari ST Blitter wasn't that successful
  877. was that in the time needed to setup the chip - and you did have to 
  878. setup and calculate quite a lot of values - you were typically just 
  879. about done doing the blit in software (a small exaggeration).
  880.  
  881. The Jaguar blitter needs minimal setting up, because the hardware does a
  882. lot of the calulations for you. For doing a memory clear f.e. you need to
  883. write only five registers:
  884.  
  885.    A1_BASE
  886.    A1_PIXEL
  887.    A1_FLAGS
  888.    A1_CMD
  889.    B_PATD
  890.  
  891.  
  892. With a little imagination you will find a lot of uses for this nice
  893. piece of hardware, that go way outside of just drawing and filling.
  894.