home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / comm / term33in.lha / Documentation / Tools / CpuBlit.doc next >
Text File  |  1992-08-23  |  14KB  |  288 lines

  1.  
  2.               CpuBlit V1.00 -- Uses CPU to perform blitter functions
  3.  
  4.            (c) Copyright Eddy Carroll, April 1991. Freely Distributable.
  5.  
  6.  
  7. GETTING STARTED
  8.  
  9.     In brief, CpuBlit makes your 68020/68030-equipped Amiga scroll text
  10.     about twice as fast as before. You can quickly try it out as follows.
  11.     Run CpuBlit (make sure you have the cache enabled). Now try Typing a
  12.     file in a CLI window. Look at the speed. Change the text colour to
  13.     colour 3. Type the file again. Look at the lack of flicker on the text
  14.     as it scrolls. Nice, eh?
  15.     
  16.     If you have Workbench 2.0, you can install CpuBlit permanently by
  17.     simply dragging its icon into your WBStartup drawer. Otherwise, you
  18.     need to call CpuBlit from your Startup-Sequence. I recommend using the
  19.     -2 or -s options for general use, though you may like to experiment
  20.     with the others.
  21.  
  22.     Now read on for a more detailed description.
  23.  
  24.  
  25. INTRODUCTION
  26.  
  27.     After upgrading from an A1000 to an A3000 a while ago, I was in Amiga
  28.     heaven. The display was great, the disk performance much improved, and
  29.     the speed awesome (at least compared to the A1000). But there was one
  30.     blemish on this otherwise perfect scene: the speed of text scrolling
  31.     in CLI windows. On a 704 x 560 screen, a snail wouldn't have much trouble
  32.     keeping up with a full size CLI window.
  33.  
  34.     Thus was born CpuBlit. It replaces the standard system BltBitMap routine
  35.     with a version that uses the 68030 where practical. The 68030 can
  36.     comfortably outrun the blitter for simple tasks like scrolling, although
  37.     the blitter still wins out if the data has to be bit shifted as well
  38.     (for example when scrolling sideways). Another benefit of using the CPU
  39.     is that it isn't constrained to operating on one bitplane at a time; it
  40.     can do them all simultaneously. So, the infamous "flicker" effect when
  41.     coloured text is scrolling disappears. This is particularly useful when
  42.     you're logged onto a bulletin board with colour ANSI menus.
  43.  
  44.     At this stage, I imagine some of you are getting ready to jump up and
  45.     complain about system throughput suffering, and how overall, the blitter
  46.     plus the CPU is faster than the CPU on its own. I certainly wouldn't
  47.     argue with that. So, CpuBlit can be setup to only use the CPU if no
  48.     other tasks are ready to use it. That way, you get improved performance
  49.     when you are single tasking, yet multiple tasks operate at full
  50.     efficiency.
  51.  
  52.     There is one caveat. CpuBlit will probably only be of use to you if you
  53.     have at least a 68020 installed in your Amiga; using the standard 68000
  54.     doesn't give any noticeable speed increase. In fact, even a standard
  55.     68020 Amiga may not give much speed increase since it only has a 16 bit
  56.     datapath into chip RAM. The A3000 on the other hand can access chip ram
  57.     32 bits at a time and CpuBlit takes advantage of this. The easiest way to
  58.     find out is to give it a try and see if you notice any other difference.
  59.     A3000 owners will certainly notice a difference -- an A3000-25 performs
  60.     blits about 2.8 times faster than the blitter, which results in text
  61.     scrolling at about twice the normal speed (actually displaying the text
  62.     to be scrolled takes a constant amount of time, regardless of what method
  63.     you use to scroll it).
  64.  
  65.     To get the best speed increase, use a non-overscanned screen of not
  66.     more than four colours, and ensure you have the CPU cache enabled (it
  67.     is disabled by default under Workbench 1.3 -- use SetCPU by Dave Haynie
  68.     to enable it). Both overscan and 8 or 16 colour screens will decrease
  69.     CpuBlit's efficiency, since the custom chips access CHIP ram more
  70.     frequently, leaving less time available for the CPU. Even with these
  71.     restrictions, you should still find CpuBlit about 50% faster than the
  72.     blitter on the A3000.
  73.  
  74.  
  75. USAGE
  76.  
  77.     You can start CpuBlit from either the CLI or the Workbench. There are
  78.     a number of parameters you can change, to alter CpuBlit's operation.
  79.     When you start CpuBlit, it automatically detaches itself from the CLI
  80.     window. Any combination of the following options can be given on the
  81.     command line or as Workbench ToolTypes. Note that each options has
  82.     two ways of specifying it. You can use whichever way you like best.
  83.  
  84.     BLITMODE=ALWAYS
  85.     -a
  86.         This is the default setting, so you normally don't need to give it
  87.         specifically. In this mode, CpuBlit always use the CPU where
  88.     possible. If you tend to only do one thing on your Amiga at a time,
  89.     this is probably the best option to use.
  90.  
  91.     BLITMODE=ONE
  92.     -1
  93.         In this mode, CpuBlit will only use the CPU for blits if there are
  94.         no other tasks ready to run at that time. The blitter is used at all
  95.     other times. Hence, you get fast blits whenever the CPU would be
  96.     otherwise idle, and normal processing speed when running multiple
  97.     tasks.
  98.  
  99.     There is one catch. When displaying text via the console device,
  100.     the program displaying the text is considered to be still running,
  101.     even though it's the console device that actually outputs the text.
  102.     For those interested, this is because the console device runs at
  103.     a higher priority than user applications and so preempts the task
  104.     before it has a chance to go to sleep. Hence, CpuBlit will think the
  105.     program is waiting to do work, and won't use the CPU for blitting.
  106.  
  107.     This means that the -1 option will only speed up scrolling when a
  108.     task scrolls the text directly, rather than indirectly via the
  109.     console device. Comms packages and text editors are the most likely
  110.     candidates for this. Standard CLI windows won't show any improvement.
  111.  
  112.     BLITMODE=2
  113.     -2
  114.         In this mode, CpuBlit will only use the CPU for blits if there is
  115.         at most one other task waiting to run. This results in everything
  116.     being speeded up (both applications and CLI output) but isn't quite
  117.     as system friendly as using -1. It should be more than adequate for
  118.     most people however.
  119.  
  120.     BROKEN=[YES|NO]
  121.     -b
  122.         Some programs don't initialise bitmap structures properly. By
  123.         default, CpuBlit passes such bitmaps on to the blitter and doesn't
  124.     attempt to handle them. Using this option tells CpuBlit to bypass the
  125.     validation checks it normally performs on bitmaps, and so may allow
  126.     broken programs like this to gain the benefits of faster blitting;
  127.     it may also cause problems. If you have a program that you think
  128.     should be sped up by CpuBlit and it seems to be showing no noticeable
  129.     change, then give this option a try; else, leave it alone.
  130.  
  131.     SINGLE=[YES|NO]
  132.     -o
  133.         This option tells CpuBlit to only handle blits where the source and
  134.         destination bitmaps are the same. Typically, this only happens when
  135.     a text window is scrolling. Normally you should not need to use this
  136.     option as CpuBlit should co-exist happily with every program that
  137.     uses the blitter. However, if CpuBlit seems to be incompatible with
  138.     some particular application, specifying `-o' will allow you to
  139.     continue using it. Don't forget to notify me about the problem, so
  140.     that it can be fixed! 
  141.  
  142.     MINTASKPRI=N
  143.     -pN
  144.         If you like to keep a program running in the background (like a
  145.     Mandelbrot generator) then you may find it counteracts the -1 and -2
  146.     options (since it is always ready to run). You can tell CpuBlit
  147.     to ignore all such tasks using this option; any task with a priority
  148.     less than N will not be considered ready to run.
  149.     
  150.     Normally, CpuBlit will ignore any tasks with a priority less than
  151.     zero, which is perfectly adequate for most cases. You can override
  152.     this with a different setting if you like. For example, setting
  153.     MINTASKPRI=-5 will cause your Mandelbrot program at priority -1 to
  154.     be considered, but not your CPU monitor at priority -20.
  155.  
  156.     BLITMODE=SHARE
  157.     -s
  158.         In this mode, CpuBlit attempts to share blits between the CPU and the
  159.     blitter. The CPU will be used for blits by default, but if a task
  160.     tries to blit some data while another task is already using the CPU
  161.     to blit data, the blitter is used for the former. The result is
  162.     better overall throughput.
  163.     
  164.     If you try experimenting with two CLI windows to see this effect in
  165.     action, you won't notice anything; this is because the console.device
  166.     used for scrolling CLI windows is single threaded and waits for a
  167.     blit in one window to finish before starting another. Hence, both
  168.     windows are scrolled using the CPU. It works fine in the case of
  169.     a CLI window and a program that bypasses the console device (such as
  170.     a comms package).
  171.  
  172.     HELP
  173.     -h
  174.         Prints out a brief help message, listing the valid options. In fact,
  175.         giving any invalid option will cause this message to be printed.
  176.  
  177.     QUIT
  178.     -q
  179.         This option asks any copy of CpuBlit already installed to remove
  180.         itself. If another program has patched BltBitMap since CpuBlit was
  181.     started, you'll get a message asking you to terminate that program
  182.     and then try again.
  183.  
  184.     If you run CpuBlit with no options, it behaves as if you had typed:
  185.  
  186.         CPUBLIT  BLITMODE=ALWAYS  SINGLE=NO  BROKEN=NO  MINTASKPRI=0
  187.  
  188.     You can pick a different mode of operation at any time by simply running
  189.     CpuBlit again with new options; it's not necessary to remove the previous
  190.     copy first. You can use -a to cancel the effect of the -b and -o options.
  191.     Note that only one of -a, -1, -2 and -s can be in effect at a time. Also,
  192.     the BROKEN and SINGLE options default to YES if you use them without
  193.     specifying a YES/NO value.
  194.  
  195.  
  196. WORKBENCH
  197.  
  198.     As mentioned above, CpuBlit can be started from Workbench. It doesn't
  199.     return to Workbench until it quits, so if you are starting it from your
  200.     WBStartup drawer (under 2.0) one of the tooltypes must be DONOTWAIT.
  201.     in the icon.
  202.  
  203.     When CpuBlit starts up, it parses all the ToolTypes in its own icon,
  204.     followed by the tooltypes in any project icons you specified. This
  205.     can be handy if you have several configurations of CpuBlit that you
  206.     like to switch between. Simply create a project icon for each one,
  207.     and set the appropriate tooltypes. Then set the default tool for each
  208.     icon to CpuBlit. Now, clicking on any of the icons will set the
  209.     corresponding CpuBlit options.
  210.  
  211.     To remove CpuBlit from Workbench, you need to start it from an icon
  212.     which has a QUIT tooltype. The standard CpuBlit distribution includes
  213.     such an icon that you can use. If CpuBlit cannot remove itself (perhaps
  214.     because someone else has patched into the BltBitMap routine ahead of
  215.     CpuBlit) then the screen will flash. You can type CpuBlit QUIT in
  216.     a CLI window for a more detailed explanation.
  217.  
  218.  
  219. IMPLEMENTATION
  220.  
  221.     This section gives a brief description of how CpuBlit works. It's not
  222.     necessary to read this to use CpuBlit, it's included merely for those
  223.     interested.
  224.  
  225.     CpuBlit only handles blits with a very specific set of characteristics.
  226.     First of all, the source and destination bitmaps must be aligned on the
  227.     same bit boundary within a longword. For example, a blit from 0,0 to
  228.     128,100 would be okay whereas a blit from 0,0 to 100,100 would fail.
  229.     In addition, only blitter functions of the form $Cx are supported
  230.     (i.e. plain replace operation). Also, the source and destination rows
  231.     must be different; if they are the same, a sideways blit is being
  232.     performed, and this is not supported.
  233.  
  234.     Assuming the blit fulfills all these criteria, CpuBlit then checks
  235.     system activity to see whether or not it is appropriate to use the
  236.     CPU at all. Exactly what is checked depends on the option selected
  237.     when CpuBlit was installed.
  238.  
  239.     Assuming everything is still okay, CpuBlit then works out how many
  240.     bitplanes there are in the bitmap, and calls one of four routines to
  241.     handle the actual scrolling. It also handles any bitplane pointers of
  242.     $FFFFFFFF or $00000000 at this time (new for Workbench 2.0, these
  243.     values are legal for bitplane pointers, and act as if they pointed to
  244.     either a solid or empty bitplane). If there are more than four
  245.     bitplanes, the blit is split into two operations; the first four planes
  246.     are moved, followed by the remaining planes. While this results in a
  247.     bit of colour flicker for deep bitmaps, it is still not as bad as when
  248.     the bitplanes are moved separately.
  249.  
  250.     The actual bitmap copying is done using optimised 68000 code. The bulk
  251.     of the data on each row is copied using a MOVE.L/DBF loop, and the uneven
  252.     bits at the sides are copied separately. No non-68000 instructions are
  253.     used (there wouldn't be any advantage to it anyway) so CpuBlit will still
  254.     run on a 68000 Amiga (not that there's much point). Due to a lack of
  255.     CPU registers (only 16 ... how DO people manage on Intel chips with a
  256.     mere 8 registers? :-) the routines for copying three and four bitplanes
  257.     aren't quite as efficient as those for copying one and two bitplanes.
  258.     However, they are still quite a bit faster than the blitter itself, and
  259.     the removal of colour flicker is more than worth the small loss in speed.
  260.  
  261.  
  262. ACKNOWLEDGEMENTS
  263.  
  264.     Thanks to Andy Mowatt for encouraging me to change CpuBlit from an idea
  265.     into a program. Thanks also to the following people who provided useful
  266.     feedback and bug reports for beta versions of CpuBlit: Steve Tibbett,
  267.     David Joiner, Mike Sinz, Dan Ten Ton, Robert Jenks, LeRoy Hutzenbiler,
  268.     Jim Biggs, Mike Meyer, Urban Mueller, Jamie Clark, Marc Jacobs and
  269.     Albert-Jan Brouwer. Their help is greatly appreciated.
  270.  
  271.  
  272. AUTHOR
  273.  
  274.     Eddy Carroll
  275.  
  276.     Email:     ecarroll@maths.tcd.ie
  277.     Phone:     +353-1-287-4540
  278.     Snailmail: The Old Rectory, Delgany, Co. Wicklow, Ireland.
  279.  
  280.  
  281. DISTRIBUTION
  282.  
  283.     CpuBlit may be freely distributed, as long as no charge is made other
  284.     than to cover time and copying costs. If you want to include CpuBlit
  285.     as part of a commercial package, contact the author listed above. Fred
  286.     Fish is specifically given permission to include CpuBlit in his fine
  287.     disk library.
  288.