home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 487.lha / CpuBlit_v0.96 / CpuBlit.doc < prev    next >
Encoding:
Text File  |  1991-03-11  |  11.3 KB  |  225 lines

  1.  
  2.               CpuBlit V0.96 -- Uses CPU to perform blitter functions
  3.  
  4.          (C) Copyright Eddy Carroll, February 1991. Freely Distributable.
  5.  
  6.  
  7. NOTE
  8.  
  9.     This is a beta release. Please refrain from spreading it around until
  10.     I release version 1.0. If you come across any bugs, send bixmail to
  11.     dhanna or email to ecarroll@maths.tcd.ie. I'm hoping to make CpuBlit
  12.     runnable from Workbench for the official release, so if anyone can
  13.     come up with a good icon, I'd love to use it.
  14.  
  15.     Quick intro for those who don't like reading doc files: Run CpuBlit
  16.     on your 68020/68030 Amiga (make sure you have the cache enabled). Now
  17.     try Typing a file in a CLI window. Look at the speed. Change text
  18.     colour to colour 3. Type the file again. Look at the lack of flicker on
  19.     the text as it scrolls. Nice, eh? Read on for more details...
  20.  
  21.  
  22. INTRODUCTION
  23.  
  24.     After upgrading from an A1000 to an A3000 a while ago, I was in Amiga
  25.     heaven. The display was great, the disk performance much improved, and
  26.     the speed awesome (at least compared to the A1000). But there was one
  27.     blemish on this otherwise perfect scene: the speed of text scrolling
  28.     in CLI windows. On a 704 x 560 screen, a snail wouldn't have much trouble
  29.     keeping up with a full size CLI window.
  30.  
  31.     Thus was born CpuBlit. It replaces the standard system BltBitMap routine
  32.     with a version that uses the 68030 where practical. The 68030 can
  33.     comfortably outrun the blitter for simple tasks like scrolling, although
  34.     the blitter still wins out if the data has to be bit shifted as well
  35.     (for example when scrolling sideways). Another benefit of using the CPU
  36.     is that it isn't constrained to operating on one bitplane at a time; it
  37.     can do them all simultaneously. So, the infamous "flicker" effect when
  38.     coloured text is scrolling disappears. This is particularly useful when
  39.     you're logged onto a bulletin board with colour ANSI menus.
  40.  
  41.     At this stage, I imagine some of you are getting ready to jump up and
  42.     complain about system throughput suffering, and how overall, the blitter
  43.     plus the CPU is faster than the CPU on its own. I certainly wouldn't
  44.     argue with that. So, CpuBlit can be setup to only use the CPU if no
  45.     other tasks are ready to use it. That way, you get improved performance
  46.     when you are single tasking, yet multiple tasks operate at full
  47.     efficiency.
  48.  
  49.     There is one caveat. CpuBlit will probably only be of use to you if you
  50.     have at least a 68020 installed in your Amiga; using the standard 68000
  51.     doesn't give any noticeable speed increase. In fact, even a standard
  52.     68020 Amiga may not give much speed increase since it only has a 16 bit
  53.     datapath into chip RAM. The A3000 on the other hand can access chip ram
  54.     32 bits at a time and CpuBlit takes advantage of this. The easiest way to
  55.     find out is to give it a try and see if you notice any other difference.
  56.     A3000 owners will certainly notice a difference -- an A3000-25 performs
  57.     blits about 2.8 times faster than the blitter, which results in text
  58.     scrolling at about twice the normal speed (actually displaying the text
  59.     to be scrolled takes a constant amount of time, regardless of what method
  60.     you use to scroll it).
  61.  
  62.     To get the best speed increase, use a non-overscanned screen of not
  63.     more than four colours, and ensure you have the CPU cache enabled (it
  64.     is disabled by default under Workbench 1.3 -- use SetCPU by Dave Haynie
  65.     to enable it). Both overscan and 8 or 16 colour screens will decrease
  66.     CpuBlit's efficiency, since the custom chips access CHIP ram more
  67.     frequently, leaving less time available for the CPU. Even with these
  68.     restrictions, you should still find CpuBlit about 50% faster than the
  69.     blitter on the A3000.
  70.  
  71.  
  72. USAGE
  73.  
  74.     When you start CpuBlit, it automatically detaches itself from the CLI
  75.     window. You can give one of several options to finetune how it works.
  76.     Here's a list of each option, along with an explanation of how it affects
  77.     CpuBlit's operation. You can specify more than one option, but note that
  78.     only one of -a, -1, -2 and -s can be in effect at any one time.
  79.  
  80.     -a  This is the default setting, so you normally don't need to give it
  81.         specifically. In this mode, CpuBlit always use the CPU where
  82.     possible. If you tend to only do one thing on your Amiga at a time,
  83.     this is probably the best option to use.
  84.  
  85.     -1  In this mode, CpuBlit will only use the CPU for blits if there are
  86.         no other tasks ready to run at that time. The blitter is used at all
  87.     other times. Hence, you get fast blits whenever the CPU would be
  88.     otherwise idle, and normal processing speed when running multiple
  89.     tasks.
  90.  
  91.     There is one catch. When displaying text via the console device,
  92.     the program displaying the text is considered to be still running,
  93.     even though it's the console device that actually outputs the text.
  94.     For those interested, this is because the console device runs at
  95.     a higher priority than user applications and so preempts the task
  96.     before it has a chance to go to sleep. Hence, CpuBlit will think the
  97.     program is waiting to do work, and won't use the CPU for blitting.
  98.  
  99.     This means that the -1 option will only speed up scrolling when a
  100.     task scrolls the text directly, rather than indirectly via the
  101.     console device. Comms packages and text editors are the most likely
  102.     candidates for this. Standard CLI windows won't show any improvement.
  103.  
  104.     -2  In this mode, CpuBlit will only use the CPU for blits if there is
  105.         at most one other task waiting to run. This results in everything
  106.     being speeded up (both applications and CLI output) but isn't quite
  107.     as efficient as using -1. It should be more than adequate for most
  108.     people however.
  109.  
  110.     -b  Some programs don't initialise bitmap structures properly. By
  111.         default, CpuBlit passes such bitmaps on to the blitter and doesn't
  112.     attempt to handle them. Using this option tells CpuBlit to bypass the
  113.     validation checks it normally performs on bitmaps, and so may allow
  114.     broken programs like this to gain the benefits of faster blitting;
  115.     it may also cause problems. If you have a program that you think
  116.     should be sped up by CpuBlit and it seems to be showing no noticeable
  117.     change, then give this option a try; else, leave it alone.
  118.  
  119.     -o  This option tells CpuBlit to only handle blits where the source and
  120.         destination bitmaps are the same. Typically, this only happens when
  121.     a text window is scrolling. Normally you should not need to use this
  122.     option as CpuBlit should co-exist happily with every program that
  123.     uses the blitter. However, if CpuBlit seems to be incompatible with
  124.     some particular application, specifying `-o' will allow you to
  125.     continue using it. Don't forget to notify me about the problem, so
  126.     that it can be fixed! 
  127.  
  128.     -s  In this mode, CpuBlit attemps to share blits between the CPU and the
  129.     blitter. The CPU will be used for blits by default, but if a task
  130.     tries to blit some data while another task is already using the CPU
  131.     to blit data, the blitter is used for the former. The result is
  132.     better overall throughput.
  133.     
  134.     If you try experimenting with two CLI windows to see this effect in
  135.     action, you won't notice anything; this is because the console.device
  136.     used for scrolling CLI windows is single threaded and waits for a
  137.     blit in one window to finish before starting another. Hence, both
  138.     windows are scrolled using the CPU. It works fine in the case of
  139.     a CLI window and a program that bypasses the console device (such as
  140.     a comms package).
  141.  
  142.     -h  Prints out a brief help message, listing the valid options. In fact,
  143.         any invalid option causes this message to be printed, not just -h.
  144.  
  145.     -q  This option asks any copy of CpuBlit already installed to remove
  146.         itself. If another program has patched BltBitMap since CpuBlit was
  147.     run, you'll get a message asking you to terminate that program and
  148.     then try -q again.
  149.  
  150.     You can pick a different mode of operation at any time by simply running
  151.     CpuBlit again with the new option; it's not necessary to remove the
  152.     previous copy first. You can use -a to cancel the effect of the -b and
  153.     -o options.
  154.  
  155.  
  156. IMPLEMENTATION
  157.  
  158.     This section gives a brief description of how CpuBlit works. It's not
  159.     necessary to read this to use CpuBlit, it's included merely for those
  160.     interested.
  161.  
  162.     CpuBlit only handles blits with a very specific set of characteristics.
  163.     First of all, the source and destination bitmaps must be aligned on the
  164.     same bit boundary within a longword. For example, a blit from 0,0 to
  165.     128,100 would be okay whereas a blit from 0,0 to 100,100 would fail.
  166.     In addition, only blitter functions of the form $Cx are supported
  167.     (i.e. plain replace operation). Also, the source and destination rows
  168.     must be different; if they are the same, a sideways blit is being
  169.     performed, and this is not supported.
  170.  
  171.     Assuming the blit fulfills all these criteria, CpuBlit then checks
  172.     system activity to see whether or not it is appropriate to use the
  173.     CPU at all. Exactly what is checked depends on the option selected
  174.     when CpuBlit was installed.
  175.  
  176.     Assuming everything is still okay, CpuBlit then works out how many
  177.     bitplanes there are in the bitmap, and calls one of four routines to
  178.     handle the actual scrolling. It also handles any bitplane pointers of
  179.     $FFFFFFFF or $00000000 at this time (new for Workbench 2.0, these
  180.     values are legal for bitplane pointers, and act as if they pointed to
  181.     either a solid or empty bitplane). If there are more than four
  182.     bitplanes, the blit is split into two operations; the first four planes
  183.     are moved, followed by the remaining planes. While this results in a
  184.     bit of colour flicker for deep bitmaps, it is still not as bad as when
  185.     the bitplanes are moved separately.
  186.  
  187.     The actual bitmap copying is done using optimised 68000 code. The bulk
  188.     of the data on each row is copied using a MOVE.L/DBF loop, and the uneven
  189.     bits at the sides are copied separately. No non-68000 instructions are
  190.     used (there wouldn't be any advantage to it anyway) so CpuBlit will still
  191.     run on a 68000 Amiga (not that there's much point). Due to a lack of
  192.     CPU registers (only 16 ... how DO people manage on Intel chips with a
  193.     mere 8 registers? :-) the routines for copying three and four bitplanes
  194.     aren't quite as efficient as those for copying one and two bitplanes.
  195.     However, they are still quite a bit faster than the blitter itself, and
  196.     the removal of colour flicker is more than worth the small loss in speed.
  197.  
  198.  
  199. ACKNOWLEDGEMENTS
  200.  
  201.     Thanks to Andy Mowatt for encouraging me to change CpuBlit from an idea
  202.     into a program. Thanks also to the following people who provided useful
  203.     feedback and bug reports for beta versions of CpuBlit: Steve Tibbett,
  204.     David Joiner, Mike Sinz, Dan Ten Ton, Robert Jenks, LeRoy Hutzenbiler,
  205.     Jim Biggs, and Mike Meyer. Their help is greatly appreciated.
  206.  
  207.  
  208. AUTHOR
  209.  
  210.     Eddy Carroll
  211.  
  212.     Email:     ecarroll@maths.tcd.ie
  213.     Bixmail:   dhanna
  214.     Phone:     +353-1-874540
  215.     Snailmail: The Old Rectory, Delgany, Co. Wicklow, Ireland.
  216.  
  217.  
  218. DISTRIBUTION
  219.  
  220.     CpuBlit may be freely distributed, as long as no charge is made other
  221.     than to cover time and copying costs. If you want to include CpuBlit
  222.     as part of a commercial package, contact the author listed above. Fred
  223.     Fish is specifically given permission to include CpuBlit in his fine
  224.     disk collection.
  225.