|★ AMSTRAD CPC ★ GAMESLIST ★ SPACE EGGS (c) YOUR COMPUTER ★|
Christopher Leigh presents a new version of a favourite shoot-em-up using sprites in glorious colour.
HERE'S A colourful asteroids-style game for the Amstrad CPC-464. While using Mode 1 it manages to give a whole range of colours and provides Mode 0 size text printing on the screen using a ROM indirection. Get yourself a high score by shooting the eggs and aliens but watch the bonus. Quick shots will score well but be slow and the bonus will turn against you!
The game features 44 sprites of different sizes with up to 25 on the screen at any one time. These are controlled by a machine-code routine that can easily be adapted for your own purposes. In fact, most of the action is controlled by machine-code making the main Basic game loop very short and speedy.
The main program appears in listing 1 and may be typed in directly. It should be saved — with Goto 20000 — before running as any mistakes in the data may cause the system to crash. The machine-code is in five routines, three of which are listed so that you can used them in your own programs. The first one — listing 2 — is for wide printing mimicking mode 0 printing.
In fact, it will work in any mode with suitable changes to the final few bytes to reset the cursor position. It works by altering the high byte of the ROM indirection at &BDD5 using Poke so that instead of pointing to the ROM routine at &134A, it points to our routine at &A34A.
We can then use the usual Print command including the Print Using format. The colour of the printing is given by the pen mask — changing this can give striped writing or mixed colours. Note that the indirection supplies the screen position as a physical position — top left = 0, 0 — whilst the cursor must be reset to the logical position — top left = 1, 1 — hence the extra increment instructions.
The second and third routines control the sprites and are called using Resident System Extension (RSX) commands. Move and Erase must be preceded by the elongated colon — shift @ — and 1 Erase must be followed by a comma and its parameter which is the address of the first byte of the move data for the sprite.
The screen is 80 bytes wide and the sprite routines divide it into 50 half lines high, so that each sprite unit is a quarter of a Mode 1 character. These routines can cope with sprites of any size and — with slight alterations — of any shape. All our sprites will be set in a square sprite shape definition, bur since zero bytes are not written to the scrccn — making the sprite transparent — the sprite can be any shape within that framework.
As written the procedure allows full wraparound, adjusting for sprites being partly off a screen edge. Again fairly simple alterations will allow sprites to bounce.
|Erase simply erases a sprite and turns it off. |Move works by calculating the old sprite position and then writing it with an ink mask of zero to rub it out, then calculating the new position and writing with the ink mask given in the move data.
This ink mask can be set to produce pure colours or colour mixtures for a whole sprite. The new position is calculated by adding the speed components to the old position and then ensuring it is on the screen. The move data also includes the address of the shape data for a particular sprite and a collision byte. This collision byte is the last non zero byte read off the screen when writing the sprite. This allows us to know if it is on top of anything and also what it is n top of.
The move data consists of nine bytes formatted thus: on/off flag, right position, down position, right speed, down speed, ink mask, shape address low, shape address high, collision byte. |Move will, in fact, move every sprite, whose on/off tag is one, in the block of move data and the routine is stopped by a value of two. The shape data address can be altered to change the shape of a sprite during the game as is done to rotate your space ship.
The first byte of the shape data is the size of the sprite in quarters. The rest of the shape data comprises bytes made up in the same way as characters are plotted on the screen in Mode 1.
As already suggested, |Move only needs to be called once a game cycle to move everything. Printing of score and bonus is done once a second by calling the routine at line 200. All that remains is to read the keys, produce sound effects, check for collisions and keep the bullets firing.
For the sake of speed the last two requirements are covered by two routines tailored for this game. Collision checking is done by reading the collision flags of each sprite and by checking for identical positioning. The latter is only needed for a stationary sprite.
Eight bullets are allowed on screen at any time so as each is fired the one eight back must be erased. Key checking is left in Basic so that you can easily change the program to suit your fingers, and the speed can be changed using p% in 1070 and 4010.
Note that your subspace thrusters always work in the direction you are pointing so thai once moving you need to turn round in order to slow down. Remember your hyper space dive is kaput so using it could well land you in the middle of one of those eggs or in the firing line of your own bullets. The faster you shoot the aliens the larger the bonus — if you take too long your bonus will become negative having a disastrous effect on your score!
Should you wish to start firing immediately without typing in the lengthy data, you should send £3 for a tape to C.J. Leigh. Ask for Space Eggs and don't forget your name and address.
L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!
CPCrulez[Content Management System] v8.7-desktop/cache
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.