APPLICATIONSDISQUE ★ SQUASH ★

Squash (Amstrad Computer User)Applications Disque
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

The problem of saving a screen dump on the CPC 464 is that it requires 16K of memory to save any type of display - either text, or mixed text and graphics. With a cassette the problem is one of the amount of time that it takes to load the screen dump back to memory - even though the cassette speed is quite reasonable when compared with other micros. Speed is no problem if you have a disc set-up, but at 16K a time, your disc will not take that long to fill up.

SQUASH is a machine code program designed to reduce the amount of memory needed to hold all the information required to reproduce the original screen picture. This is accomplished in three ways:-

  1. The current MODE, SCREEN OFFSET, BORDER and INK COLOURS are copied to tape. If possible it is preferable to make sure that the SCREEN OFFSET is set to zero (by issuing a MODE command), or you may find a small part of the display (one line) different from when it was saved.
  2. The 200 Horizontal lines are compared in order to see if any are the same
  3. The 80 memory locations for each of the 200 lines are checked to see if there are any sequences of repeating numbers.

The three programs as shown in listings 1, 2 and 3 work as follows:-

Listing 1

This is the program that does all the hard work of checking and compressing. MEMORY is set to &5000 in line 10. This is to allow enough room for the compressed data which is stored from &9000 downwards. The data may not reach anywhere near &5000 but it is necessary to set this figure just in case it should. The actual machine code program is located at &9030 onwards. The locations between &9000 and &9030 are used to hold the information for the Mode, Border and Ink colours. The machine code program is split up into 9 different sections which will make it easier for you to key in. Each section also has a checksum number to make sure that you get the data right. If you enter any data wrong then the Basic program will tell you which section the error is in. Section 1 clears all the various buffers that are used, to zero. Section 2 checks all 16000 screen locations to find out what numbers are being used on the screen. It does this by zeroing a block of256 memory locations and then using the number from the screen as the LSB address of the block. The screen number is then copied to this address in the block. At the end of the check, any numbers in the block that still remain at zero are therefore not being used on the screen. Section 3 then checks through this block to count how many 'free' numbers are available. The reason for all this is that the SQUASH program requires two numbers which it uses as 'markers'to signal lines that are the same, and sequences of characters that are the same. Obviously if all 266 possible 8 bit numbers are being used on the screen, then there are no numbers that can be used as markers. About the only time that this would happen is if you were to deliberately poke all 256 numbers to the screen memory. Even with the most complex of pictures there are usually several dozen free numbers available. If there are not two markers available, then the program will now return back to Basic, otherwise it will continue to section 4.

Section 4 first sounds a BEEP to let you know that two markers are available. These are then placed at &9001/3. Section 5 then fetches the current values for the SCREEN OFFSET, MODE, BORDER and INK COLOURS, and these are stored from &9004 to &902C. Sections 6 and 7 create a couple of blocks'which contain data for helping with the checking of the lines.

Section 8 then compares the 200 screen lines to see if any are the same. Lines that are the same will only use up two bytes - the marker number, followed by the number of the similar line.

Section 9 will then check each individual line of 80 bytes (unless it starts with the 'same as'marker) and see if there is any repetition of numbers. If there are more than three consecutive numbers the same then these are represented as :-

Marker (2) number

The amount of numbers that are the same. The number itself.

As this uses up three bytes then it is only worth doing if there are more than three numbers the same. For example, a complete line of 80 numbers all the same - let's say 99

— would be compressed to:-

128099

Assuming that 12 represents the second marker number.

This section also stores these numbers and markers from &9000, working its way towards low memory. The address of the final location used is stored at &9008/9 to enable the length of the squashed file to be calculated. As you may well gather, rather a lot of work has to be done by the program -one reason why it is in machine code.

Listing 2

wish - or just clear the screen - and then type:-

CALL &9200

If all is well, your original picture should be displayed within one second. If the program does not work correctly then check all the data in the lists to see that you have entered it properly. Checksums are not foolproof -after all, you may enter two values the wrong way around. The checksum will still be the same but two values the wrong way around in the machine code program spell disaster. When the two programs are working, enter listing 3 and SAVE the compressed file to tape (or disc). If you are just creating and saving pictures onto tape then the program in listing 2 does not need to be in memory. Likewise, if you are reloading the files back into memory to be re-displayed, the program in listing 1 does not need to be in memory. They are both quite happy to work together or separately if required.

Let's assume that you have a Basic program for creating some fancy pictures that you want to save in compressed form. This is what you need to do:-

Firstly, load in listing 1 and RUN it to put the machine code program into memory. Load in your Basic program for creating the pictures and then MERGE the subroutine in listing 3 into your Basic program. Insert the following line into this subroutine:-

10005 CALL &9030

When you have created your picture then GOSUB 10000, enter the file name that you wish to give to the picture, and the file will be saved to tape as a Binary file. Repeat this process if you require to save more pictures.

To re-display the pictures then load the program in listing 2 and RUN it. If you had saved 5 pictures on tape then these could be displayed one after the other by using a program such as:-

10 FOR DISPLAY = 1 TO 5
20 LOAD "!"
30 CALL &9200
40 NEXT DISPLAY

Each picture will then be loaded in and displayed.

Just how much memory is saved though?

On average, the saving will be about 50%, which in computer terms is a considerable saving. Very simple pictures may use up only IK of memory whilst complex pictures may use 12K or more. Many of my pictures seem to use up about 8K so you'll be able to get twice as many pictures onto tape or disk, and take half the time required for loading them in.

In some instances your program to create the pictures will be much smaller than the compressed file. However, if the drawing routine is a complex 3D shape, using many

Compared with the program to compress the screen data, the program to 'un-compress'this data is relatively simple. The MODE, OFFSET and INK COLOURS are set up first. The numbers stored from &9000 downwards are then checked. If a marker number is found then the relevant action is taken with the following numbers, otherwise the number is copied out to the screen. The machine code program in listing 2 is stored at &9200 onwards.

Listing 3

This program is designed to be used as a subroutine for calculating the length of the squashed file, and for saving this file to tape as will be explained shortly.

Using the programs

Type out listing 1 and when the program runs without any errors in the data then SAVE it to tape. RUN the Basic program which will POKE the machine code program to memory. The Basic program can then be NEWed as it is no longer needed. It is, however, wise to keep a copy on tape as a back-up.

Type out listing 2 - SAVE it - RUN it - NEW it.

Now you are ready to see if the program works.

Set the OFFSET to zero by typing MODE 0, MODE 1, or MODE 2.

Now type or draw something on the screen

— be careful not to scroll the screen as this will change the OFFSET from its present value of 0. To save the screen picture as a compressed file then type:-

CALL &9030

If all is well you will hear the BEEP and Ready will reappear within 1 to 10 seconds, depending upon the complexity of the screen.

To check if the decoding program (listing 2) works correctly; first change the MODE and the BORDER and INK colours if you mathematical formulae, the time it takes to draw the picture can be considerable -sometimes hours - even though the CPC464 is no sloth. This is the sort of situation where this compression technique is at its most useful.

ACU #8511

★ PUBLISHER: Amstrad Computer User
★ YEAR: 1985
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LiCENCE: LISTING
★ COLLECTION: AMSTRAD COMPUTER USER 1985
★ AUTHOR: Dave ELLIS

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Squash    (Dave  Ellis-Amstrad  Computer  User)    ENGLISH    LISTINGDATE: 2023-12-04
DL: 25
TYPE: PDF
SiZE: 144Ko
NOTE: 4 pages/PDFlib v1.6

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Squash (Amstrad Computer User)
» Applications » Screen Squash (Amstrad Action)
Je participe au site:
» Pour ce titre nous ne disposons de fichier executable sur CPC (Dump, Saisie du listing) , alors si vous avez ça dans vos cartons ou vous désirez usé vos petit doigts boudinés sur votre clavier faites le nous savoir.
» Vous avez des infos personnel ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 374 millisecondes et consultée 1675 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.