
                            ASSEMBLY SPRITE TUTORIAL
                            ========================

                                     PART 2

                         BEATING THE 16 PIXEL BOUNDARY



     PRDUCED FOR:    ICTARI USER GROUP
     (C) Nick  Bates 1994

     Last month,  I  described  the  theory  behind  beating  the  16 pixel
     boundary and this month I have  written a subroutine that demonstrates
     the points I made. I  hope  you  all  had  your  own  go at doing this
     yourselves, as this will help you to learn the principles involved.

     The source included with this document includes several library files.
     Most of these are  provided  to  enable  the  main  program to run and
     therefore present no new items code,  or  certainly nothing you do not
     know all ready, else  otherwise  this  tutorial  is  not  for you. The
     important library is the sprite  library,  which contains 1 subroutine
     which is a routine to draw  a  16x16 sprite, with masking, but without
     clipping.

     The main program calls this subroutine and passes the required values,
     as you can see from the example,  you can pass any required values for
     x and y co-ordinates and any sprite number value. Remember 0 is sprite
     1 and 1 is sprite 2, etc ...

     The PAC.OBJ file contains about 6  sprites  all  of which are the same
     size. This file was produced in  much  the way I explained last month,
     however the file does not contain the headers, and therefore cannot be
     loaded back into Neochrome Master.  I  have therefore included another
     file called PAC_HD.OBJ which does contain  these headers. The reason I
     prefer to save without the headers is that in the final version of the
     program it's best not  to  include  any  unnecessary  stuff. However I
     always save the file with the headers in  case I need to check or edit
     the sprites with either  Neochrome  Master  or  Peter Hibbs own Sprite
     Check program (ICTARI #7).

     The latter is a very nice program  to  use to display your sprites for
     the first time and get an  impression  of  what  they look like on the
     screen without having to do any code,  it is also useful to check that
     all sprites are of equal size.

     With this routine, or preferably your own version, you can now display
     any 16x16 sprite anywhere on  the  screen.  The  sprite will be masked
     with the current backgroud, try this  by  loading a Degas picture into
     the background first. The only problem  with  this routine is that you
     will get problems trying to  display  the  sprite  near the edges. You
     need to add some sort of  clipping  routine  that detects for this and
     display only part of the sprite, i.e the part that is visible.

     So, your homework for this  month  is  to  have  a  go at loading in a
     background, with the sprites, try drawing  your  own sprites - of both
     the same size and perhaps  bigger.  Write  a version of the subroutine
     that works for a 32x32 sprite for example. Try and make the subroutine
     detect if the co-ordinates are on  the screen, and clip appropriately,
     in order to avoid a crash.  If  you're feeling very adventurous have a
     go at making the sprite move to  responses from either the joystick or
     the mouse. The code to do  this  has  been  included in past issues of
     Ictari Magazines.


     Next Month, I shall include some  source  with some answers to some of
     the above. Until then, have fun ......

     <Nick Bates>
