★ AMSTRAD CPC ★ GAMESLIST ★ STARDODGER (AMSTRAD COMPUTER USER) (c) AMSTRAD COMPUTER USER ★

Amstrad Computer User
★ 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 ★ 

★ AMSTRAD CPC ★ Amstrad Computer User 88/9 : Stardodger I — The Basic version ★
Stewart Russell shows you how to program the same game three times, in three very different languages

STARDODGER is a very simple game that remains challenging despite the lack of fiddley bits. It was produced as a test exercise to determine the suitability of three languages - Basic, BCPL and Assembly language - for writing a simple game.

The gameplay is about as simple as is humanly possible. The player guides a zig-zag line towards a goal on the other side of the screen, avoiding static objects placed in its path. The higher the level, the more objects are placed on the screen, until the player collides with an object or the white edge of the screen, ending the game.

The game is made even simpler for both .programmer and player by the use of the Shift key as the only means of control. If the Shift key is pressed, the line climbs; if it is released, the line falls.

Basic was used to write the original program as it has the advantage of instant access. This allows a deal of experimentation and correction while testing without lengthy recompilation sessions.

Despite its speedy reputation, Locomotive Basic is a little slow for this sort of thing, so the game was later rewritten in a compiled language for speed.

Subprograms

The Basic program was written as a series of simple subprograms tacked together with that most marvellous keyword, GOTO. This keyword gives rise to cheers from some and hisses from others - generally computer scientists who have been bitten by a rabid GOTO at an early age.

The most complex part of the game is the check on whether the pixel in front of the player's free is white; if it is, the game ends. A test is also nade to determine whether the right-hand edge of the screen has been reached; this results in the next screen being drawn.

It was found that the game was very slow when written in this manner since two independent tests - TESTR and XPOS - were required every game loop.

This was solved by drawing a vertical line in a different ink to the rest of the game graphics at the right-hand edge of the screen. Now all that was required was one ink test per loop, using TESTR, to see if the player had hit the line or had hit something nasty.

There were plans to include sound - these were shelved when it was discovered that sound programming is not one of my strongest points. This programming technique is know among the cognoscenti as The Cop Out.

As the variable names used are not descriptive, a table of their function may help (see Figure I). These variables hold integer values only, so it could be an interesting (and simple?) exercise to use a Basic compiler on the program.

  • Next month we'll look at the BCPL version.

★ AMSTRAD CPC ★ Amstrad Computer User 88/10 : Stardodger II — the BCPL ★
Stewart Russell shows you how to program the same game three times, in three very different languages

ONCE the Basic version of Stardodger worked to my satisfaction - which took longer than expected - the program was rewritten using Amor's BCPL compiler. BCPL was the forerunner of the oh-so-trendy C language beloved by computer scientists and other deviants. Unlike C, BCPL is quite readable, yet it still enforces a carefully structured programming style.

This is due to its syntax and the lack of error checking. Care must be taken or the compiler will merrily churn out guff without a single beep of displeasure.

The BCPL Stardodger took far less time to write than the Basic version, mainly because all the program logic had already been worked out.

Arnor BCPL compiler Output file name? STARBCPL
->OPTION S-,B-
->GET"ALIBHDR"
-> GET"ALIBHDRT
-> GET"AMSDOS"
-> GET"STARDOJ.B"
->.
Phase 1 complete. Tree size 15652
Phase 1 errors: 0
Phase 2 complete. Code size 9631
Phase 2 errors: 0
Code origin 370

Compiling the BCPL version - the dialogue

Dynamic elegance

A particularly neat feature of BCPL is the case structure - SWITCHON..INTO..CASE, used here in the collision detection routine - which is similar to, but more elegant than, Basic's ON..GOTO.

Nearly all the variables used in this program are static variables; this means they are always available to any part of the program. Dynamic variables - such as t used in the pause procedure - disappear after being finished with. Unlike Basic, ail BCPL variables and constants, known as manifests, have to be defined before use.

Also unlike Basic, which has string, integer and real variables, BCPL has only one type of variable - the "word", or 16 bits. This makes it ideal for implementation on a home micro.

It does have some odd conventions though. For instance, the asterisk is thought of as a control character. It cannot be represented as simply * but has to be written as ** before it is accepted. Gripes aside, BCPL is a lovely language to use.

You can use any Ascii text editor for producing the source code. Indenting the text is not necessary, but helps to show the levels of the program. After saving the text - call it STARDOJ.B - it may be an idea to dry run it through the compiler without GETting any of the libraries. As long as only Undefined identifier errors are produced the text should be OK. But beware of spelling mistakes in procedure names, as these cannot be checked for until the final compilation stage.

You must first invoke the compiler from disc, using RUN"DISC and then |BCPL. Follow the compiler dialogue in the panel, but note that minor differences may occur in the numeric values produced.

RoutineBasic
lines
BCPL
procs
Initialisation20-70start
Print title screen90-170start
Draw game screen180-450drawscr
Main game logic470-530start
Print game over screen550-600start
Print success screen620-680start
Wait for keypress routine700-760waitkey
The main routines - a comparison

  • Next month, in the final part of this series, we'll look at the assembly language version.

★ AMSTRAD CPC ★ Amstrad Computer User 88/11 : Stardodger III — The assembler version ★
Stewart Russell shows you how to program the same game three times in three very different languages

BCPL produced a game that would be fast enough for anyone, but was about 10k long. This seemed quite excessive, so a non-singing, non-dancing compact game in Z80 code was developed in Assembly language.

Assembly language programming is quite a different kettle of fish from Basic or BCPL, with absolutely no safety net provided for the unwary. Simple housekeeping tasks such as printing a string have to be written by the author and these can frequently prove to be the most difficult bits.

Again, the Basic Stardodger served as the template for this model, with slight differences. The screen numbers in this version are printed in hexadecimal simply because a hex routine is shorter to write than a decimal one.

Reasonable care has been taken that each routine does not corrupt registers unnecessarily. This wastes space in the form of PUSHes and POPs, but the approach is preferable to a possible system crash.

The random routine and the screen drawing
routine could both be made shorter, but they work, this being of the utmost importance. Results of tests were not generally returned in registers but in memory locations, because it is all too easy to corrupt a register by mistake.

The listing was produced using the Maxam rom, so the long label names may cause problems for ADAM , Devpac, Zapp and Code Machine users, but are there to increase readability. Check your manuals to see how label names should be entered into your particular assembler.

Your reward for all of this effort? A paltry 937 bytes of code. This can be saved by hopping into
Basic and typing:

SAVE"STARDOJ",B,&5080,&3A9,&5000

Some people may find this Assembler version a bit fast. Remedy this by changing part of the START subroutine from LD A,3:CALL HAUDON to LD A,value:CALL HAUDON where value can take any value from zero to 255 - 3 (default), 4,5 or 6 {very slow) are the best ones to use. HAUDON, incidentally, is Glaswegian for "hold on".

Conclusions
If there has to be a conclusive winner in the general niceness stakes, BCPL would take it by a short head. It was as simple as the Basic version to write, yet ran as quickly as the Assembly version. Its only drawback was the length of the object file produced.

Producing the Assembly version was certainly challenging, but the effort involved doesn't really justify the result.

Although coming last in the race, Basic provided the slow, good-natured workhorse from • which the tetchy thoroughbreds were descended.

My current record on both the BCPL and the Assembly versions is Screen 11. I've made it through Screen 19 on the Basic one. Can you get further? Go forth, and dodge them stars!

ACU

STARDODGER (AMSTRAD COMPUTER USER) [Stardodger III]
(c) AMSTRAD COMPUTER USER

Author: Stewart C.RUSSELL

★ NOTE: Written in BCPL/ASM/BASIC

★ YEARS: 1987 , 1988
★ LANGUAGE:
★ GENRE: INGAME MODE 1 , ARCADE
★ LiCENCE: ???
★ COLLECTION: AMSTRAD COMPUTER USER 1988

  

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listings:
» Stardodger    (ASM  Source)    (Amstrad  Computer  User)    ENGLISHDATE: 2023-12-07
DL: 20
TYPE: PDF
SiZE: 379Ko
NOTE: 3 pages/PDFlib v1.6

» Stardodger    (Basic  Source)    (Amstrad  Computer  User)    ENGLISHDATE: 2023-12-07
DL: 18
TYPE: PDF
SiZE: 76Ko
NOTE: 2 pages/PDFlib v1.6

» Stardodger    (BCPL  Source)    (Amstrad  Computer  User)    ENGLISHDATE: 2023-12-07
DL: 19
TYPE: PDF
SiZE: 131Ko
NOTE: 1 page/PDFlib v1.6

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 147 millisecondes et consultée 1048 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.