
This outliner uses the following algorithm :

     If the source pixel is white then do not plot a pixel at the
     destination.

     If any pixel surrounding the source pixel is white then plot
     a pixel at the destination.

     If all the pixels surrounding the source pixel are black then
     do not plot a pixel at the destination.

We can simplify this algorithm with the following pseudo-code routine.

     IF the source x,y pixel is white THEN do not plot a pixel
     IF the source x-1,y pixel is white THEN plot a destination pixel x,y
     IF the source x+1,y pixel is white THEN plot a destination pixel x,y
     IF the source x,y-1 pixel is white THEN plot a destination pixel x,y
     IF the source x,y+1 pixel is white THEN plot a destination pixel x,y

This  translates very well into machine code as the first condition  will 
be the most common statement to be true (assuming a white background) and 
so the next four conditions can simply be jumped over.  If the x,y  pixel 
is  black and one of the other conditions is true we can again jump  over 
the remaining conditions. This removes all redundant checks and so speeds 
up the main loop of the program.

The main problem with this program is that at the very minimum there will 
be  256,000  pixels checked on the monochrome screen.  If the  screen  is 
mainly  black then there may be up to 1 million checks  !  Obviously  the 
crucial part of the program is reading and plotting pixels.

At  any  one time the program must know the location of  five  pixels  at 
x,y/x-1,y/x+1,y/x,y-1 and x,y+1.  There are three bit positions in use at 
x-1, x and x+1 with the checks at y-1 and y+1 being the same bit position 
as  x.  We  can  use  three data registers to  represent  the  three  bit 
positions  and three address registers to represent the addresses of  the 
three  bit positions.  The y-1 and y+1 addresses will be the x,y  address  
-80 and +80 respectively.

At  the start of the screen we know the the left pixel position (x-1)  is 
bit  position 7 of the first screen byte,  the middle pixel (x) is bit  6 
and the right pixel (x+1) is bit 5.  By using a single BTST.B instruction 
we  can  check  any  pixel  and if a pixel  needs  to  plotted  a  BSET.B 
instruction is used. To check the next bit each bit position is decreased 
and  when  it becomes negative it is reset to position 7 and  the  screen 
address is increased.

The source code is commented and so you should be able to follow  exactly 
how  the program works.  I can't really see how the program speed can  be 
improved further, at the moment it takes around 3-4 to outline a screen.

