Squash Demo  -  Demonstrates desktop colour display

by Alan Wrigley

This application was first published on last month's RISC User disc as an example of the use of the Squash module. Because the program also makes use of the colour handling and sprite display routines described in the Wimp Topics article in this month's magazine, it is supplied again on this month's disc as a demonstration of those techniques. The application allows you to display sprites in a window on the desktop, by dragging either sprite files or Squash files containing sprites to the application.

Acorn's Squash application is widely used for compressing and decompressing files. The module which performs the compression and decompression can be used separately from within your own programs, offering a simple way to compress and decompress files on the fly. The Wimp Topics article in last month's RISC User magazine explains how to do this, and the SquashDemo application presented here is a simple example of how these techniques can be used. The program loads either squashed or unsquashed sprite files, and displays them having first decompressed in memory any that are squashed.

The method used to display the sprites ensures that the size and colour of the sprite are always correct regardless of the screen mode in which the sprite was created and the screen mode currently used on the desktop. This month's Wimp Topics article gives a full explanation of the techniques involved.

The program is run in the usual way from the RISC User menu system or by double-clicking on its icon in a directory viewer. An icon is placed on the icon bar. Dragging a sprite file or a squashed sprite to the icon will open the main window and display the sprite. If it is a Squash file, the file is first checked to see that the original file was a sprite, and if so it is unsquashed in memory using the Squash SWI calls as described in the Wimp Topics article. The window will be resized to fit the sprite.

Once a sprite file has been loaded, it can be saved out again in Squash format. Simply open the icon bar menu and move across the Save option, and a standard RISC OS save box will appear allowing you to save the file.

The decompression process is fairly quick for all but the very largest sprites, but you should note that sometimes when loading in a new file after a previous one has been loaded, the process appears to take a few seconds. This is not due to the decompression process, but is a recently-discovered fault in the RISC User Heap Manager routine which is used by the program (see RISC User 7:5).

Copyright  RISC User 1996
