============================================================================ Squash a bob in AMOS! ============================================================================ This routine was originally written for a Fun School 3 program called LETTERS. Each letter in the alphabet was displayed as a single large sprite. This required a total of 52 separate images, taking up a massive 110k of memory. Since only a couple of images were displayed at a time, most of this space was actually wasted. So we asked our resident programming genius, Fran¨ois Lionet, to write us a small routine to pack the unused sprites into a spare memory bank. This allowed us to compress the entire sprite bank into just 26K! AMOS SQUASH is now available on the public domain. Feel free to use it in any of your own programs. It's especially useful for the massive Level Guardians in an arcade game. These can be compressed into a fraction of their normal size, and can be instantly retrieved at the appropriate point in your program. Have Fun, and do spread this routine to your friends! Using AMOS SQUASH ------------------- The packer program comes in two separate parts. The first program loads a sprite bank into memory and compacts your images. It can be found in the file Squash_a_bob.AMOS In order to use this routine, you need to perform the following simple procedure: * Load a sprite bank from the disc using the file-selector. * Enter the number of the first sprite you wish to pack. * Enter the number of the final sprite in your list. * Input the number of colours used by your sprite images. * Choose a new memory bank to hold your squashed images. The squasher routine will now be executed and your selected images will be quickly compressed. After it has concluded, you will be given an option to save your compacted images onto the disc. Note that no colour information is saved with these images. So you may need to make a note of the current colour settings before proceeding any further. Once you've squashed your images, you can load them into your AMOS Basic programs with the help of three small procedures. These can be found in the file Squash_procs.AMOS, and can be incorporated into your program using the MERGE command from the AMOS Editor menu. The squash routines are remarkably easy to use. The first stage is to load your original sprite bank from direct mode and delete the images you have just compressed. Use a line like: Del Sprite start TO finish This erases your old images from memory, saving you a considerable amount of storage space. You can now enter your packed images from the disc with the LOAD command. i.e Load "images.abk" At the start of your program, you should initialise the compaction system with a call to the PBOB_INIT procedure. PBOB_INIT[bank,cols,max_x,max_y] Where: bank: is the bank number containing your compressed images cols: hold the number of colours max_x: stores the maximum width of your images max_y: holds the maximum height of your images The action of this procedure is to prepare a temporary screen for the squasher utility. Your images can now be unpacked as and when they are required, using a simple call to the PBOB routine. PBOB[source,dest] source is the number of the image to be unpacked. This is the original image number from the sprite bank. dest is the number of the new image you wish to install in the sprite bank. Choose the number of the last sprite in the bank plus one. Once you've installed your image into memory, you can animate it directly with the various SPRITE or BOB commands. PBOB can be called as many times as you wish. So the same image number can be re-used again and again. Finally, add a call to the PBOB_END procedure towards the end of your program. This will erase the hidden screen created by PBOB_INIT. A long lost command! ---------------------- COLOUR BACK (Set background colour) Here's a useful AMOS instruction which was omitted from the Basic manual. COLOUR BACK $RGB Sets the background colour of the screen. This colour is used for areas of the screen which are unused, such as the top or bottom. Example: Colour Back Colour(0) : Rem Sets the entire screen to a single colour. COLOUR BACK and FADE ---------------------- The background colour cannot be faded. It is only updated when AMOS re-calculates the copper list. We've therefore included a small procedure called FAD_ALL which smoothly updates the background colours during a FADE operation.