AMSTRAD CPC464 User Manual

AMSTRAD CPC464 User Manual

Cpc464 colour personal computer 64k
Hide thumbs Also See for CPC464:
Table of Contents

Advertisement

Advertisement

Table of Contents
loading

Summary of Contents for AMSTRAD CPC464

  • Page 2 This manual is a Portable Document Format (PDF) version of the Amstrad Colour Personal Computer (CPC) 464 User Manual. This manual is © Copyright Amstrad plc, All rights reserved. Website: www.amstrad.com Permission has been granted for this manual to be distributed in an electronic form on the internet.
  • Page 3 Features of computer hardware and software have advanced far more rapidly than even existing users are able to follow, and to attempt to show owners of the CPC464 all the available power and subtlety of its BASIC, operating system and hardware attributes would require several thousands of pages.
  • Page 4 We wish you every success - you could not have chosen finer value for money, nor a computer with a greater potential for developing your understanding of all aspects of the subject. There is no finer way of finding out about computing than by using a computer - and the CPC464 is particularly ‘ user friendly’ .
  • Page 5 Do not block or cover the ventilation slots on the top or back of the computer keyboard, monitor, or power supply/modulator. Turning off the power will lose all that is stored in the CPC464 memory. If you wish to save a program, read Chapter 2 after having first completed the ‘ Foundation Course’ .
  • Page 6 Editing the display 2 Cassette Datacorder Loading and saving with the cassette Datacorder The ‘ Welcome’ cassette tape 3 BASIC primer An introduction to the principles of CPC464 BASIC Syntax of AMSTRAD BASIC Variables, operators Simple BASIC exercises User defined keys...
  • Page 7 Connecting a parallel printer 8 Concise reference guide to AMSTRAD BASIC A concise summary of the BASIC language and keywords used for programming the CPC464, listed in alphabetical order 9 Further programming information The internal organisation of programs - firmware...
  • Page 8 Foundations 1: SETTING UP Initial instructions on the unpacking, interconnecting and switching on your CPC464 system. The AMSTRAD CPC464 colour personal computer can be set up using either: AMSTRAD GT64 Green Tube Monitor AMSTRAD CTM640 Colour Monitor AMSTRAD MP1 Modulator/Power supply and a domestic (UHF) TV receiver.
  • Page 9 No internal connections need to be made, therefore no attempt should be made to gain access to the inside of the equipment. The computer should be positioned in front of the Monitor on a suitable table close to the Mains Supply Socket.
  • Page 10 1.2 AMSTRAD CTM640 Colour Monitor Unpack the monitor and connect a Mains Power Plug to the Mains Lead as follows: IMPORTANT The wires in this Mains Lead are coloured in accordance with the following code: Blue: Neutral Brown: Live If a 13 Amp (BS1363) Plug is used, a 5 Amp Fuse must be fitted. The 13 Amp Fuse supplied on a new Plug must NOT be used.
  • Page 11 The red ON lamp at the top centre of the computer keyboard unit should be illuminated, and the monitor will display the following picture: A m s t r a d 6 4 K M i c r o c o m p u t e r < v 1 > ©...
  • Page 12 The MP1 is an additional item that you may wish to purchase if you are currently using your CPC464 computer with the GT64 green tube monitor. The MP1 enables you to use the computer with your domestic colour TV and thereby enjoy the full colour facilities of your CPC464 computer.
  • Page 13 The modulator/power supply (MP1) should be positioned to the right of the computer on a suitable table close to the TV set and the Mains Supply socket. As shown in figure 2, connect the lead with the larger (6 pin DIN) plug from the MP1 to the socket marked MONITOR on the back of the computer.
  • Page 14 ‘ firing’ within the game. The JYl can be plugged into the back of your computer using the 9-way socket marked USER PORTS (I/O). The Amstrad CPC 464 computer can be used with two joysticks. The second JY1 joystick should be plugged into the socket on the first joystick.
  • Page 15 Press down the key marked [CTRL] (Control), and AT THE SAME TIME press the small [ENTER] key at the bottom right of the number-only keypad next to the Datacorder. The screen will respond with the instructions: R U N " P r e s s P L A Y t h e n a n y k e y : Now press the [PLAY] key in the row at the front of the Datacorder until it locks down firmly, followed by pressing any letter, number, or either [ENTER] key - or the space bar.
  • Page 16 1.6 LOADING OTHER SOFTWARE CASSETTES THE WELCOME TAPE CAN ONLY BE LOADED AND RUN as described in the previous section (1.5). Unprotected BASIC programs can be loaded by the following alternative methods. Rewind the tape that you have inserted by pressing the key on the datacorder until the spools stop [REW] turning, when you must immediately press the...
  • Page 17 The computer asks you to..P r e s s P L A Y t h e n a n y k e y : Now press the [PLAY] key in the row at the front of the Datacorder until it locks down firmly, followed by pressing any letter, number, or either [ENTER] key - or the space bar.
  • Page 18 1.7 Loading pre-recorded software cassettes The instructions given so far will allow you to load any of the many titles of software available for the CPC 464 computer. However, please also refer to the correct loading instructions printed in each software package. 1.8 SAVE A program can be saved (recorded) for later use.
  • Page 19 Foundations 2: KEYBOARD FAMILIARISATION We will now explain the functions of some of the keys on the computer. Those who are experienced in using computers may skip this section. [ENTER] There are two [ENTER] keys. Either of these keys enter the information that you have typed into the computer.
  • Page 20 a b c d e f 1 2 3 4 5 6 On the screen you will notice that although all the letters are shifted to capitals, the numbers have not been shifted to symbols. If you wish to type in a shifted symbol while [CAPS LOCK] is in operation, simply hold down the [SHIFT] key before pressing a character key.
  • Page 21 Notice how the letter E is still visible within the cursor. Press the [CLR] key once and you will see that the letter E has been cleared and the letters F G H have each moved one space to the left with the letter F now appearing within the cursor.
  • Page 22 An introduction to AMSTRAD BASIC keywords In Chapter 8 you will find an illustrated description of all the BASIC keywords found in the AMSTRAD BASIC. We will introduce some of the more commonly used BASIC keywords in this section. Type in: cls (clear screen). You can use either upper case (capital) or lower case (small) letters. Then press [ENTER].
  • Page 23 The previous example showed a single line program. Most programs have many lines. In front of each line, a number is first typed in. These numbers tell the computer the order in which to run the program. When [ENTER] is pressed, the line is stored in the memory until the program is run. Type: 1 0 p r i n t “...
  • Page 24 Type in [ENTER] to clear the screen. To see the word hello printed continuously on each line, one next to another filling the whole of the screen, type in the previous program but with a semi-colon ; after the quotation marks ” Type: 1 0 p r i n t “...
  • Page 25 If your name was Fred you will see on the screen: h e l l o F r e d m y n a m e i s A r n o l d (As a point of interest, Arnold was the codename for the AMSTRAD CPC464 during its development.) Although we used name$ in the above for the name string variable, we could have just as easily used a letter, for example a$.
  • Page 26 EDITING A PROGRAM If any of the lines in the program had been typed incorrectly, resulting in a Syntax error or other error message, it would be possible to edit that line rather than type it out again. To show this you can type the previous program out incorrectly.
  • Page 27 The main cursor has moved but the copy cursor stayed where it was. Now press the [COPY] key until the whole of line 10 is printed. Press [ENTER] and this new line 10 will be stored in the memory. The copy cursor disappears and the main cursor positions itself under the new line 10. To correct the second mistake, hold down [SHIFT] and press cursor up key [ t ] until the copy cursor appears over the very beginning of line 30.
  • Page 28 FOR in Chapter 8. SIMPLE ARITHMETIC Your CPC464 can be used as a calculator quite easily. To understand this carry out the following examples. We will use the ? symbol instead of typing print in this section. The answer will be printed as soon as the key is pressed.
  • Page 29 ADDITION (use [SHIFT] and ; keys for plus) Type: ? 3 + 3 [ENTER] (note that you do not type in the equals sign =) Type: ? 8 + 4 [ENTER] SUBTRACTION (use unshifted = key for minus) Type: ? 4 - 3 [ENTER] Type: ? 8 - 4 [ENTER] MULTIPLICATION...
  • Page 30: Square Root

    SQUARE ROOT To find the square root of a number type in sqr( ). The number you want the square root of should be typed inside the brackets. Type: ? sqr (16) (this means ? 16) [ENTER] Type: ?sqr (100) [ENTER] EXPONENTIATION (use unshifted E for exponentiation)
  • Page 31 If the calculation was: 3+7-2*7/4 You may think this would be calculated as 3+7 -2 *7 /4 8 *7 /4 56/4 In fact it is calculated as 3+7 -2*7/4 =3+7 -14/4 =3+7 -3.5 = 1 0 -3 .5 =6.5 Prove this by typing in this calculation as it is written: Type: [ENTER] ?3+7 -2*7/4...
  • Page 32 or you can type: ? 3 e 1 * 1 e 1 [ENTER] 2. 3000x1000 Type: ? 3 e 3 * 1 e 3 [ENTER] 3 0 0 0 0 0 0 3. 3000x0.001 Type: ? 3 e 3 * 1 e-3 [ENTER]...
  • Page 33 Foundations 3: Graphics, modes and Sound The Amstrad CPC 464 Colour Personal Computer has three modes of screen display operation: Mode 0, Mode 1, and Mode 2. When the computer is first switched on, it is automatically in Mode 1.
  • Page 34 The 27 colours available are listed in Table 1, each with their INK reference number. MASTER COLOUR CHART Ink Number Colour/lnk Ink Number Colour/lnk Black Pastel Blue Blue Orange Bright Blue Pink Pastel Magenta Magenta Bright Green Mauve Sea Green Bright Red Bright Cyan Purple...
  • Page 35 To explain this further, we can associate the PEN and PAPER on the monitor screen to an actual PEN and piece of notepaper. As the colour of the INK in a PEN can be changed, so the colour of the characters on the screen can be changed.
  • Page 36 Ink Colour Paper/Pen No. Mode 0 Mode 1 Mode 2 Flashing 1,24 Flashing 16,11 Table two: PAPER/PEN/MODE/INK reference...
  • Page 37 The PEN used when the computer is first switched on, is number 1. Look at Table 2 and you will see in the mode 1 column, that PEN number 1 is colour number 24. If you now refer to Table 1, you will see that colour number 24 is bright yellow, which is the colour of the characters (PEN) when the computer is first switched on.
  • Page 38 FLASHING COLOURS It is possible to make the colour of the characters flash between one colour and another. This can be achieved by adding an extra colour number to the INK command of the PEN. To see the characters on the screen flashing between bright white and bright red, type in: i n k 1 , 2 6 , 6 [ENTER] In this case, 1 is the PEN number, while 26 is the colour bright white, and 6 is the alternate colour, bright red.
  • Page 39 In this case 15 is the PEN number, while 0 is the colour black, and 26 is the alternate colour bright white. Finally, it is possible to make the BORDER flash between two colours by adding an extra colour number to the BORDER command. Type in: b o r d e r 6 , 9 [ENTER] You will now see that the BORDER is flashing between bright red and green.
  • Page 40 GRAPHICS From this point on, we will not ask you to press the [ENTER] key after each line. We will just assume that you will do it automatically. There are a number of character symbols in the computer’ s memory. To print any one of these, use the key word chr$().
  • Page 41 In mode 0, there are only 20 columns, but the same 25 lines. If you now type in: mode 0 You will see that the man now appears at the top right corner of the screen. This happens because the x co-ordinate 20, is the last column in mode 0. In mode 2, there are 80 columns and 25 lines.
  • Page 42 Now type in: To improve the movement of the character across the screen, add the following line: 3 0 c a l l &bd19 This program can be further enhanced to improve the movement by adding some delay loops and by using a different returning character symbol.
  • Page 43 PLOT Unlike the locate command, plot is used to determine the position of the graphics cursor, using pixel co-ordinates. (A pixel is an extremely small segment of the screen). Note that the graphics cursor is not visible and is different to the character cursor. There are 640 horizontal pixels by 400 vertical pixels.
  • Page 44 Type in: 5 cls 1 0 p l o t 1 0 , 1 0 2 0 d r a w 1 0 , 3 9 0 3 0 d r a w 6 3 0 , 3 9 0 4 0 d r a w 6 3 0 , 1 0 5 0 d r a w 1 0 , 1 0 6 0 g o t o 1 0...
  • Page 45 We have now started to use the keyword new before typing in the program itself. This tells the computer to fully clear the memory in a similar way to reset ([CTRL] [SHIFT] [SHIFT] and [ESC] keys). However, it differs in that the screen is not cleared; only the memory. This is useful if you want to keep the old program on the screen for reference when writing a new program.
  • Page 46 ORIGIN In the previous program we used the plot command to plot the centre of a circle, then added the x,y co-ordinates to this centre position. Instead of adding these centre co-ordinates to the point plotted, we can use the origin command. This will position the centre of the circle, then position the x,y co- ordinates of all the points on the circumference (in 1 degree steps) from the origin.
  • Page 47 In the previous program, the instruction plot 50*cos(a),50*sin(a) was repeated 4 times. This instruction can be typed in as a sub-routine; and called into action each time it is needed by using the word gosub. Type in the following: 5 cls 1 0 f o r a = 1 t o 3 6 0 15 deg 2 0 o r i g i n 1 9 6 , 2 8 2...
  • Page 48 S O U N D Sound effects are generated by a loudspeaker within the computer itself. If you are using the MP1 modulator power supply and a domestic television, turn the TV’ s volume control to a minimum. The level of sound can be adjusted by use of the VOLUME control on the right hand end of the computer.
  • Page 49 VOLUME ENVELOPE The volume envelope command is env. This normally has 4 parameters: The last 3 parameters may appear in any of up to 5 optional envelope sections available. We are only using one of these here. Further explanation will appear in chapter 6. env envelope number, number of steps, amplitude (size) of step, step time.
  • Page 50 5 e n v 1 , 1 0 0 , 1 , 1 0 5 e n v 1 , 1 0 0 , 2 , 1 0 5 e n v 1 , 1 0 0 , 4 , 1 0 5 e n v 1 , 5 0 , 2 0 , 2 0 5 e n v 1 , 5 0 , 2 , 2 0 5 e n v 1 , 5 0 , 1 5 , 3 0...
  • Page 51 STEP TIME This number specifies the time between steps in 0.01 second (1/100th’ s of a second). The range of a step time number is 0 to 255. The longest time between steps therefore, is 2.55 seconds. To experiment with the tone envelope, type in the following program: 5 e n t 1 , 1 0 0 , 2 , 2 1 0 s o u n d 1 , 2 8 4 , 2 0 0 , 7 , 0 , 1 Line 10 specifies a sound with a tone period of 284 (interntional a) lasting for 2 seconds with a start...
  • Page 52 Now replace all the lines by typing in: 5 e n v 1 , 1 0 0 , 2 , 2 1 0 e n t 1 , 1 00, -2,2 2 0 s o u n d 1 , 2 8 4 , 2 0 0 , 1 , 1 , 1 Try some more variations for yourself.
  • Page 53 1. Starters: If those of you who skipped the beginners’ introduction, (which included details of connecting up, switching on and keyboard familiarisa tion) find the terminology used here confusing then go back to the introduction section for the Foundation Course. Subjects covered in this chapter: * Conventions used in this user guide * Switching on...
  • Page 54 IMPORTANT Please refer to the Setting Up instructions detailed at the start of this User Guide describing the wiring up of the Mains Plug to the Mains Lead of your equipment. With the computer correctly connected as shown in switch on the monitor, and Foundation 1, then the computer, using the slide switch on the right hand end.
  • Page 55 Adjust the BRIGHTNESS control to provide an adequately lit display without the ‘ dots’ that make up the lines in the characters of the display becoming excessively blurred. To setup in the 80 column mode, type the following brief program listing into the CPC464. You get a choice of display:...
  • Page 56 7 0 a $ = I N K E Y $ 8 0 I F a $ = " " G O T 0 7 0 90 NEXT 1 0 0 G O T O 20 The above illustrates a further important point concerning the representation of style in this manual.
  • Page 57 TV set and the Mains Supply socket. As shown in figure 2, above. Now reduce the volume control on your TV set to a minimum - the CPC464 has its own internal loudspeaker, so the hiss from the TV with the volume turned up and the computer switched on is quite normal, Switch on your TV, and then switch on the computer using the slide switch marked POWER on the right hand end.
  • Page 58: First Steps

    If you are familiar with the BASIC programming language then there’ s a good chance that you will already have entered a brief program to ‘ get aquainted’ . AMSTRAD BASIC will be familiar in many respects, and just to get you going, we will show you a brief program that you can enter that will display all the built-in characters that are available from the computer.
  • Page 59 But as the computer has to use at least one whole byte per character stored (whether we want it to or not, it’ s the smallest denomination that the CPC464 appreciates), we might as well use all 256 possible combinations,,rather than simply be satisfied with the 96 or so standard characters that are printed on most typewriters - and throw away the spare 160 possibilities.
  • Page 60 Figure 4: The keyboard of the CPC464 Pressing [ENTER] has the effect of [ENTER]ing the command or program line you have just typed into the.computer, and then asking the computer to process the in-struction contained on that line -...
  • Page 61 1.2.7 and see how to resolve the problem. Assuming that all is well, and you have the required result, we’ ll examine what lies behind the displayed characters - it will help you understand exactly how your CPC464 communicates through its range of characters.
  • Page 62 Simply by using N in this way, we have told the computer that N is a variable. The definition of the FOR statement in BASIC requires that it should be followed by a variable - so the computer assumes that whatever follows FOR is just that. We have also told the computer that N = 32 t o 255..
  • Page 63 - each dot is determined by data stored in the computer’ s memory. There are 8 rows and 8 columns in each character cell on the CPC464 display and if you don’ t find a...
  • Page 64 2 0 P R I N T C H R $ ( N ) ; 3 0 NEXT N Ready This program will stay in CPC464’ s memory until you either: Switch off RESET - by pressing in sequence and holding each down after it has [CTRL][SHIFT][ESCAPE] been pressed until the reset occurs.
  • Page 65 You will inevitably make mistakes when typing in the program. Welcome to this section all those of you who skipped here from 1.2.2 ! The CPC464 has tried to make correcting these errors as simple as possible, at the same time avoiding the problems of accidentally overwriting characters that you don’ t mean to change.
  • Page 66 1. You may hit [ENTER] and retype the whole line. The incorrect line will be erased from memory and then be overwritten by the next line to be typed that starts with the same line number. 2. You can press the [<-] key and move the cursor block back to the incorrect entry: 1 0 FOR N = 332 TO 255 Note that the character underneath the cursor is displayed in reverse video.
  • Page 67 1.2.9 Copy Cursor Editing First list the program using LIST. (We’ ll continue to assume that you’ re working on the short trial program that fits onto a single screen) 5 CLS 10 FOR N = 3 2 T O 2 5 5 2 0 P R I N T C H R $ ( N ) ;...
  • Page 68 Now enter LIST once again, and you will see the corrected version of the program displayed. If it’ s not correct, try again! Thus far we’ ve only begun to explore the groundwork for CPC464. To take a look at the other two modes, type in:...
  • Page 69 * Read errors The CPC464 memory is only able to store data as long as the power is connected to the computer - and the unit itself is switched on - in computer terminology it is a ‘ volatile’ storage medium . If you want to store programs or data when the power is switched off - then this must be stored onto the cassette (or other ‘...
  • Page 70 It should not be used to pause during either a data read or data write operation, or an error will occur. All pauses during play and record operations are handled by internal instructions in the CPC464 software, leaving the mechanical pause facility largely unused.
  • Page 71 (while the program is safe in the CPC464 memory), and throw the damaged tape away before you are tempted to try and re-use it.
  • Page 72 LOAD and RUN commands. To make operation of the computer as simple as possible, the CPC464 includes a number of special functions that simplify the keyboard entry until you’ ve had some practice with the keyboard. If you have switched the computer on and are looking at the ‘...
  • Page 73 2.5 Supersafe and Speedload The CPC464 offers two speeds to the user: a Supersafe speed of 1000 baud (bits of data per second), and a Speedload rate of 2000 baud. The Speedload rate thus writes and reads data at twice the...
  • Page 74 The most straightforward method of saving data onto the cassette is to use the command SAVE when the CPC464 is displaying the Ready prompt after executing or listing a program. Using the example of a brief program that lists the displayable characters discussed in Chapter 1 as the object of our SAVE command.
  • Page 75 There are four ways in which files may be SAVEd by the CPC464. You have just seen the most general method, but there are three alternative formats for more specialised purposes. <filename>” , 2.6.2 SAVE " The procedure is the same as above, except that the suffix ,A instructs the computer to save the program or data in the form of an ASCII text file, rather than the shorthand notation the computer uses by default.
  • Page 76 2.7 Read errors If you get the message displayed that a Read error has occured while the CPC464 has been trying to load a program or data from the cassette, then the tape will continue to play, and the computer will continue to read the blocks that it finds after the error - except that it will not attempt to LOAD them unless they are identified as being block 1 of the program it first tried to load (unsuccessfully).
  • Page 77 NOTE that cassettes containing programs from other types of computer cannot be read or loaded on the CPC464. They may look the same - they may even make similar ‘ sounds’ if played through an audio cassette playback system - but they will not load and run. If you do find any that appear to load and run - then we would be pleased to hear from you giving details of the computer type and program concerned.
  • Page 78 – although the more of the rules you learn, the easier it will all become. BASIC is the language that comes supplied ‘ built-in’ with your CPC464. It’ s right there when you switch on, and makes it’ s presence felt with the prompt word: Ready BASIC is the simplest language to learn.
  • Page 79 3.2 The structure of a BASIC program Program instructions are presented to BASIC on lines. A line may comprise several commands, separated by colons, limited only by the maximum line length of 255 characters. A ‘ character’ is a number, letter, space. In Direct Mode lines are typed in from the keyboard and must not commence with a number.
  • Page 80 These items are represented by the various terms, and enclosed in angle brackets q >. For example, in various places an expression which yields a numeric result is required, this is represented by : <numeric expression> Anything not enclosed by angle brackets is required as given. For example the S T 0 P command takes the form : STOP Where there is an optional part in a definition, the optional part is enclosed in square brackets.
  • Page 81 PRINT FRE("") To get the CPC464 to give you the answer to a question, you must tell it three things: 1. Where you want the answer to appear - ie the screen, the printer or ‘ elsewhere’ 2. You must give the computer the ‘ data’ to work with 3.
  • Page 82 4 is as yet unused. The sign-o message used stream 0 (the default), so the text was sent to the stream that appeared after the characters already displayed there. This feature of AMSTRAD BASIC is particularly powerful, since it allows complex screen displays to be built using simple commands and definitions, that contribute towards ease of producing a tidily formatted screen display.
  • Page 83 AMSTRAD BASIC does not support the [TAB] key as a column tab, since there is considerable lack of unity on the meaning and function of this feature in various dialects of BASIC. Pressing the [TAB] key prints a right arrow character *(the same as [CTRL] and the I key together), but otherwise has no purpose in AMSTRAD BASIC.
  • Page 84 The PRINT USING form is used to format the results of calculations where real number results would produce an untidy array of decimal places. It is a complicated concept that is best appreciated through practical examples, since the technical form: PRINT [#stream expression,, I [<print list)][using clause,][separator,] Could be justly described as non-user-friendly, especially since the using clause, further divides down to:...
  • Page 85 A N S W E R = 4 * 4 : p r i n t A N S W E R Variables in AMSTRAD BASIC may contain up to 40 characters (the first must be a letter), and all 40 are significant.
  • Page 86 4.2 Short cuts It’ s tedious typing PRINT every time, so you can use a ? instead, and BASIC will understand this means PRINT (so long as it is not placed inside any phrase within quotation marks “” ). Note that the ? option does not require to be de-limited using a space like the word PRIN T If you write the line as a program rather than a direct command:...
  • Page 87 Anything contained within brackets ( ) is dealt with first of all, and if the contents of the brackets are themselves in the form a mixed calculation, then these will be handled in the order outlined above - including any further brackets within the brackets. You must always end up with as many right hand brackets as left hand brackets in such an expression or a Syntax Error will result.
  • Page 88 Here comes a brief program to demonstrate these operators, based on subject very dear to our hearts. If you are not already looking at the switch on screen message: A m s t r a d 6 4 k M i c r o c o mp u t e r ( v 1 ) c 1 9 8 4 A m s t r a d C o n s u m e r E l e c t r o n i c s a n d L o c o m o t i v e S o f t w a r e L t d .
  • Page 89 Note that the new line, and other lines that have been added, have been entered in lower case to remind you that AMSTRAD BASIC understands the difference between a variable name, and keyword. Press [ESC] twice to break from this program, then LIST the program and see how the...
  • Page 90 Line 70 introduces a delay loop as the computer counts ‘ n’ from 1 to 900 before executing the next statement - G 0 T 0 5. Thus the program re-cycles itself without ending. The only way out is to [ESC]ape using the [ESC] key provided.
  • Page 91 ! declares a variable to be real - which means the integer part, and the portion to the right, of the decimal point. Variables default to being real upon switch on. Real variables can take any value in the range 2.9E-39 to 1.73+38. $ indicates a string variable, where the contents may be a mixture of numbers, letters etc.
  • Page 92 5 CLS 6 I N P U T " W h a t i s y o u r n a m e " ; N A M E $ 1 0 I N P U T " W H A T I S Y O U R S A L A R Y " ; S A L A R Y 2 0 I F S A L A R Y <...
  • Page 93 10 CLS 2 0 I N P U T " W h a t i s y o u r n a m e " ; N A M E $ 3 0 I N P U T " W H A T I S Y O U R S A L A R Y " ; S A L A R Y 4 0 I F S A L A R Y <...
  • Page 94 Now RUN the program and respond: W h a t i s y o u r n a m e ? B o b W H A T I S Y O U R S A L A R Y ? 4 0 0 0 0 ASK FO R B I G G E R C A R a n d g e t a g o o d a c c o u n t a n t …a n d l e n d m e a fi v e r B o b...
  • Page 95 So far, most BASIC commands have been written using the universal BASIC syntax that can be understood by most machines that include any sort of BASIC interpreter. LOCATE is one of the dialect features of AMSTRAD BASIC (and several others) that allows you to position the text cursor anywhere on the screen: L O C A T E 1 O , 4 .
  • Page 96 3 4 B O R D E R A M S T R A D This line switches the colour of the border so that it is set to the value of AMSTRAD by line 30. List the program again:...
  • Page 97 And you will see that the border alternates between colours 14 and 6. You will have to wait until the next chapter to get more explanation of the way graphics and colours work. To round off this sub- section, enter: i n k 1 , 1 8 , 1 6 then...
  • Page 98 We can now write the framework for a subroutine to deal a card: 1 0 D I M P A C K ( 5 2 ) 2 0 F O R X = 1 T O 5 2 3 0 L E T P A C K ( X ) = 0 4 0 N E X T X .
  • Page 99 Concluding this brief introduction to BASIC, here’ s a program that enables you to play pontoon with the CPC464 (blackjack and 21 are the other well known names for variations). It demonstrates the use of many features of BASIC, and should be readily understood thanks to the use of renresentative variable names.
  • Page 100 80 S U I T $ ( l ) = " C L U B S " 9 0 S U I T $ ( 2 ) = “ H E A R T S ” 1 0 0 S U I T $ ( 3 ) = “ S P A D E S ” 1 1 0 S U I T $ ( 4 ) = “...
  • Page 101 Enter T for a ‘ twist’ (your next card to add to those originally dealt to you), or S to stick and play the house. We don’ t claim that this is the last word in card games for your CPC464, but it will provide you with a substantial bone upon which to add the meat of graphics and sound.
  • Page 102 P R I N T 1 0 A N D 12 Results in 8. P R I N T 1 0 A N D 1 0 0 0 Results in 8 again.
  • Page 103 This is because the numbers 10 and 1000 have been converted to binary representation: 1010 1 1 1 1 1 0 1 0 0 0 The AND operation checks each corresponding bit at a time, and where the bit in the top and the bottom row is 1, the answer is 1: 0 0 0 0 0 0 1 0 0 0 .
  • Page 104 7 0 P R I N T ( m o n t h = 1 2 O R m o n t h = 1 ) And when the program is run, entering 29 for the day and, say, 5 for the month will produce the answer in line 50, and the actual values returned by the logical expressions in lines 60 and 70 will be displayed beneath..
  • Page 105: Colour Selection

    ‘ dialect’ of BASIC to another however, the BASIC commands that control the graphics (and the text cursor locations) are more specifically dedicated to the way in which the CPC464 hardware controls the screen display and must be carefully understood to get the most from your micro.
  • Page 106 5.1.2 Transparent option and the relationship of PEN, INK and PAPER. Except for the conditions where the flashing alternate colours are specified, two INKs are used when writing to the screen; one INK determines the colour of the PEN , while the other determines the colour of the PAPER .
  • Page 107 5.2.2 MODE 1 is the ‘ standard’ or default mode. MODE 1 is pre-set when the CPC464 is turned on. 4 of the 27 colours may be displayed simultaneously - although you can switch rapidly through all 27 if you want. The display is 320 pixels wide, by 200 high.
  • Page 108 Now RUN the program. Hit ‘ any key’ on the keyboard, to get another pattern. This demonstrates several important features of the CPC464’ s hardware and software: the CPC464 ‘ writes the screen’ very smoothly without judder or ‘ tearing’ , and the software includes commands that permit very sophisticated effects to be achieved with the minimum of effort.
  • Page 109 Both are basically doing some sums on randomly generated ‘ seed’ numbers to ensure that each pattern is different in some way, and displaying the results as random lines. Your CPC464 is excellent electronic graph paper, and one of the most classic geometrical patterns is a sine wave:...
  • Page 110 (pixel) on the screen for each calculation it makes in the FOR NEXT loop (lines 80-l 10) - and the result is displayed on your screen. The CPC464 has many simple and powerful commands - you can add to the effect of the above progam by simply adding: 1 5 B O R D E R 6 , 9 RUN again.
  • Page 111 52.5 The graphics cursor and drawing lines You have now tried some of the ways you can translate programs into graphic displays - and several of the program commands and concepts have been given a chance to perform. When drawing lines at the screen, there are some important considerations to watch out for to avoid confusion.
  • Page 112 See how the first line (10) sets up the colour and ink conditions to make sure that whatever was in the memory of the CPC464 at the time is reset to produce the expected results: 1 0 I N K 0 , 0 :I N K 1 , 2 6 : I N K 2 , 6 : I N K 3 , 1 8 : B O R D E R 0...
  • Page 113 To see what you have done, look up the E V E R Y command in Chapter 8, it’ s one of the most useful features in AMSTRAD BASIC. One interesting effect of the E V E R Y command is the way it stacks up requests to do something if the program is interrupted by pressing the [ESC] key - only ONCE.
  • Page 114 5.3 Windows The user can select up to eight text windows into which characters are written, and also a graphics window into which plotting may be performed. Windows are reset to defaults when the screen mode is set. See the keyword description in Chapter 8. NB: If the text window is equivalent to the entire screen (default), then rapid rolling is achieved by hardware.
  • Page 115 And go no further..but you will be missing some of the most interesting and rewarding features of the CPC464, so this section is a primer that ranges across an overall view of the subject followed by a detailed look at the keywords and how to specify them. It will furnish the programmer with the basics on how to build a scale of notes, invent various types of musical instruments, and structure tunes using them.
  • Page 116 1000Hz (1kHz) note. Either of these could be used to set the pitch, but Amstrad BASIC chooses to use the <tone period>. Don’ t be mislead by the fact that as the period goes up in value, the pitch goes down. The pitch appears in the keyword description of SOUND as <tone period>.
  • Page 117 Volume is simply the measure of how loud the sound is. To set the initial volume level of each SOUND on the CPC464, there is a straightfoward scale : increase in value = increase in volume level, set by an integer number in the range 0..15 (0...7 if no volume envelope is specified).
  • Page 118 TO DO, DRAW THIS PAGE...
  • Page 119 Most pieces of music are written with at least two ‘ clefs’ , bass and treble. To enable this approach on the CPC464 there have been three SOUND channels provided -A,B and C. These can all play independently, or be timed to coincide when required. Selection of channels is made in the SOUND command parameter channel status.
  • Page 120: Parameter Descriptions

    <mandatory entry> In the CPC464 it is possible to play up to three different SOUNDs at once. This is achieved by having three SOUND channels (or queues), referred to as A, B and C. The input integer range is...
  • Page 121 When the flush bit is activated with a channel(s) the SOUND put through with the flush is excecuted immediately leaving the queue empty and the head of the channel inactive. Any SOUNDs currently being played are terminated. H: Tone Period Value range 0..4095 default if omitted : none ( mandatory entry ) Enters a period that sets the frequency of the SOUND to be played (pitch of the note).
  • Page 122 L: Tone Envelope An integer value in the range 0… 15 default if omitted : 0 The value used specifies a pre-defined envelope. To define an envelope use the ENT command, A permanent definition is tone <envelope number> 0, this cannot be changed by the ENT command and is set to the ‘...
  • Page 123 Form of the command: E N V N , P l , Q l , R l , P 2 , Q 2 , R 2 , P 3 , Q 3 , R 3 , P 4 , Q 4 , R 4 , P 5 , Q 5 , R 5 N: Envelope Number value range 1..15 Pl..
  • Page 124 W1..5 : Pause Time (sec. 1..5) value range 0..255 (l/l00ths second) S is mandatory, and completion of each individual section is also mandatory. When an <envelope number> is defined, all previous settings are overruled. Specifying an envelope of either type without any sections will reset the settings of that <envelope number> to zero. 6.13 Other associated functions and commands SQ(X) x is the channel number : 1,2 or 4...
  • Page 125 R E L E A S E R E L E A S E z indicates the channel number(s), an integer value in the range 1..7, which is bit significant. As described in the SOUND command parameter channel status) it is possible to flag a hold on a channel with a particular SOUND command.
  • Page 126 The second joystick should be plugged into the socket on the first joystick. There are no special points to consider when connecting a joystick to the CPC464: the AMSOFT JYl will plug directly into the 9 pin socket provided at the rear of the computer, marked USER PORTS (l/O).
  • Page 127 Fire 1 Bit 5 Note that when the second joystick is interrogated the CPC464 cannot tell the difference between the joystick and the indicated keyboard keys. In practice it is most unlikely that a conflict of interpretation will exist. Indeed the keyboard could be used as a substitute for the second joystick.
  • Page 128 5 0 G O T O 1 0 0 The CPC464 issues a line feed CHR$(10) and a carriage return CHR$(13) at the end of the line. The printer will usually contain a preset switch for selecting the appropriate form of input, and it will be immediately obvious what the default standard is once you attempt to print.
  • Page 129 The key to compatibility is the standard parallel interface. Amstrad DMP-1 The Amstrad DMP-1 printer is a low cost printer, supplied complete with the necessary cable to connect directly to the printer port on the CPC464. 50 CPS print speed...
  • Page 130 * All AMSTRAD BASIC keywords in alphabetical order This chapter contains a concise summary of the functions in the BASIC supplied in ROM with the CPC464. The range of features available represents an industry-standard implementation of the language with specific extensions to complement the hardware features of the CPC464.
  • Page 131 LIST ed. Keywords are delimited by separators, since AMSTRAD BASIC allows you to ‘ bury’ keywords into variable names: eg end2 and LI STCODE are acceptable as variables in AMSTRAD BASIC.
  • Page 132 numeric expression>) (< P R I N T A B S (-67.98) 67.98 FUNCTION: Returns the abso lute value of the given expression -which primarily means that negative numbers are returned as positive. Associated keywords: SGN AFTER integer expression>[,<integer expression>] GOSUB <line number>. <...
  • Page 133 ATN (<n u m e r i c e x p r e s s i o n > ) P R I N T A T N ( 1 ) 0 . 7 8 5 3 9 8 1 6 3 FUNCTION: Calculates the arc-tangent (forcing the numeric expression) to a real number ranging from -PI/2 to +PI/2) of the value specified.
  • Page 134 CALL CALL < a d d r e s s e x p r e s s i o n > , [ < l i s t o f : < p a r a m e t e r > ] C A L L &...
  • Page 135 CHR$ (<i n t e g e r e x p r e s s i o n > ) PRINT CH R $ ( 1 0 0 ) FUNCTION: Converts a numeric value to its character equivalent, (using the AMSTRAD CPC464 character set in Appendix III)
  • Page 136 CLEAR CLEAR CLEAR COMMAND: Clears all variables and files. CL G [ < m a s k e d i n k > ] COMMAND: To clear the graphics screen. Associated keywords: C L S , O R I G I N CLOSEIN C L O S E I N C L O S E I N...
  • Page 137 C L S [ # < s t r e a m e x p r e s s i o n > ] COMMAND: To clear the given screen window to its Paper Ink. CONT CONT CONT COMMAND: Continue program execution after a * B r e a k *, STOP or END , as long as the program has not been altered.
  • Page 138 CREAL C R E A L ( < n um e r i c e x p r e s s i o n > ) 5 D E F I N T n 1 0 n = 7 5 . 7 6 5 2 0 d = n / 3 4 .
  • Page 139 DEF FN DEF FN <n a m e > ( < f o r m a l p a r a m e t e r s > ) ] = < g e n e r a l e x p r e s s i o n > 1 0 D E F F N i n t e r e s t ( p r i n c i p l e ) = l .
  • Page 140 DELETE D E L E T E < l i n e n u m b e r r a n g e > D E L E T E 1 0 0-200 COMMAND: A command that removes part of the current program as defined in the line number range, expression.
  • Page 141 D I M < l i s t o f : s u b s c r i p t e d v a r i a b l e > 1 0 C L S : P R I N T " E n t e r 5 n a m e s .." : P R I N T 2 0 D I M B $ ( 5 ) 3 0 F O R N = l T O 5 4 0 P R I N T "...
  • Page 142 COMMAND: To Enable Interrupts disabled by a DI command. Associated keywords: DI COMMAND: End of program. An END is implicit in AMSTRAD BASIC as the program passes the last line of instruction. END closes all cassette files and returns to the direct mode. Sound queues will continue until empty.
  • Page 143 Up to five <envelope sections may be supplied, and each may take one of the forms : step count,step sizep,qpause time> or: =&one periodp,(pause time> The first form specifies an incremental change relative to the current tone period setting. The second form specifies an absolute setting for the tone period.
  • Page 144 The <envelope number is an <integer expression, yielding a value in the range 1..15 specifying the volume envelope toset. Up to five (envelope sections, may be given. Each may take one of the forms: step count,step size,,cpause time, * or: =chardware envelopeb,<envelope period, The first form specifies an envelope section under software control, where parameters are : step count gives the number of steps in the section - an integer expression in the range 0..127.
  • Page 145 P R I N T E O F FUNCTION: Tests to see if the cassette input is at the end of the file. Returns – 1 (true) at the end, otherwise 0 (false). Associated keywords: OPENIN ERASE ERASE li s t o f ; < v a r i a b l e n a m e > , E R A S E A , B % COMMAND: When an array is no longer required, it may be ERASE and the memory used be...
  • Page 146 E V E R Y 5 0 0 , 2 G O S U B 50 COMMAND: The CPC464 maintains a real time clock. The EVERY command allows a BASIC program to arrange for subroutines to be called at regular intervals. Four delay timers are available, specified by the 2nd <integer expression>...
  • Page 147 F O R < s i m p l e v a r i a b l e > = s t a r t T 0 < e n d > [ S TEP < size>] F O R D A Y = 1 t o 5 S T E P 2 COMMAND: Execute a body of program a given number of times, stepping a control variable between a start and an end value.
  • Page 148 HEX$ H E X $ ( < u n s i g n e d i n t e g e r e x p r e s s i o n > [ , < i n t e g e r e x p r e s s i o n > ] ) P R I N T H E X $ ( 6 5 5 3 4 ) F F F E FUNCTION: Converts the number given into Hexadecimal form.
  • Page 149 I N K < i n k > , < c o l o u r > [ , < c o l o u r > ] INK 0,1 COMMAND: Depending on the current Screen Mode (Chapter 5), a number of IN Ks are available. The colour, or colours, used for an INK may be changed by an INK command, according to the table of colour values in Appendix IV.
  • Page 150 I N P ( < p o r t n u m b e r > ) P R I N T I N P ( & F F 7 7 ) FUNCTION : A function that returns the input value from the I/O port specified in the address. Associated keywords: O U T , W A I T INPUT INPU T...
  • Page 151 INSTR I N S T R ( [ < i n t e g e r e x p r e s s i o n > , < s t r i n g e x p r e s s i o n > , < s t r i n g e x p r e s s i o n >...
  • Page 152 K E Y < i n t e g e r e x p r e s s i o n > , < s t r i n g e x p r e s s i o n > K E Y 1 4 0 , "...
  • Page 153 COMMAND: A remnant from early BASICS where variable assignments had to be ‘ seen coming’ . No use apart from providing compatibility with the programs supplied in early BASIC training manuals. The above example need only be typed: x=100 using AMSTRAD BASIC. LINE INPUT LI N E I N P U T [ <...
  • Page 154 LOAD L O A D < f i l e n a m e > [ , < a d d r e s s e x p r e s s i o n > ] L O A D " I N V E N T " COMMAND: To read a BASIC program from cassette into memory, replacing any existing program, or if using the optional address expression, to load a binary tile into memory.
  • Page 155 LOG10 L O G 1 0 ( <n u m e r i c e x p r e s s i o n > ) ? L O G 1 0 ( 9 9 9 9 ) 3 . 9 9 9 9 5 6 5 7 FUNCTION: Calculates the base 10 logarithm of numeric expression).
  • Page 156 MERGE M E R G E [ < f i l e n a m e > ] M E R G E " P L A N " COMMAND: Merge a program from cassette into the current program memory. It adds the contents of a file to the current program in memory.
  • Page 157 MODE M O D E < i n t e g e r e x p r e s s i o n > M O D E 1 COMMAND: To change the screen mode (0,1 or 2), and clear the screen to INK 0 , which may not be the current PAPER INK .
  • Page 158 NEXT N E X T [ < l i s t o f : < v a r i a b l e > ] F O R n = 1 T O 1 0 0 0 : N E X T COMMAND: Delimits the end of a FOR loop.
  • Page 159 ON BREAK STOP O N B R E A K S T O P 1 0 O N B R E A K G O S U B 4 0 2 0 P R I N T " p r o g r a m r u n n i n g " 3 0 G O T 0 2 0 4 0 C L S 5 0 P R I N T "...
  • Page 160 OPENIN O P E N I N < f i l e n a m e > 1 0 0 O P E N I N “ ! I N F O R M A T I O N ” COMMAND: Opens an input file from cassette which contains information for use in the current program in the computer’...
  • Page 161 ORIGIN O R I G I N < x > , <y > [ < l e f t > , < r i g h t > , < t o p > , < b o t t o m > ] 1 0 C L S : B O R D E R 1 3 2 0 O R I G I N 0 , 0 , 5 0 , 5 9 0 , 3 5 0 , 5 0 3 0 D R A W 5 4 0 , 3 5 0...
  • Page 162 FUNCTION: Examine the contents of a memory location. The above ‘ utility’ program allows you to browse through the RAM of the CPC464. It reads the RAM under the lower (&0000-&3FFF) and upper (&C000-&FFFF) ROM - not the ROM .
  • Page 163 P E N [ # < s t r e a m e x p r e s s i o n > , ] < m a s k e d i n k > P E N 1,2 COMMAND: PEN sets the ink to be used when drawing at the given screen stream, defaulting to screen # 0.
  • Page 164 PLOT P L O T < x c o-o r d i n a t e > , < y c o-o r d i n a t e > [ , < m a s k e d i n k ] 1 0 M O D E 2 : P R I N T "...
  • Page 165 POKE P O K E < a d d r e s s e x p r e s s i o n > , < i n t e g e r e x p r e s s i o n > P O K E &...
  • Page 166 R A D R A D COMMAND: Set Radians Mode Associatedkeywords: DEG,SIN,COS,TAN,ATN RANDOMIZE R A N D O M I Z E [ < n u m e r i c e x p r e s s i o n > ] 1 0 R A N D O M I Z E 2 3 2 0 P R I N T R N D ( 6 ) COMMAND: BASIC’...
  • Page 167 RELEASE R E L E A S E < s o u n d c h a n n e l s > R E L E A S E 4 COMMAND: When a sound is placed on a sound queue it may include a ‘ hold’ state. If any of the channels specified in this channel are in ‘...
  • Page 168 RENUM R E N U M [ < n e w l i n e n u m b e r > ] [ , [ < o l d l i n e n u m b e r > ] [ , < i n c r e m e n t > ] R E N U M R E N U M 1 0 0 , , 1 0 0 COMMAND: Renumber program lines from the line specified, using the increment specified.
  • Page 169 RETURN RETURN RETURN COMMAND: Signals the end of a subroutine. BASIC returns to continue processing at the point after the GOS UB which invoked it. Associated keywords: G O S U B , O N x G O S U B , O N S Q G O S U B , A F T E R n G O S U B , E V E R Y n G O S U B , O N B R E A K G O S U B RIGHT$ R I G H T $ ( <...
  • Page 170 ROUND R O U N D ( <n u m e r i c e x p r e s s i o n > [, < i n t e g e r e x p r e s s i o n > ] ) 1 0 x = 0 .
  • Page 171 SAVE S A V E < f il e n a m e > [ , < f i l e t y p e > ] [ , < b i n a r y p a r a m e t e r s > ] S A V E "...
  • Page 172 S O U N D 1 , 2 0 0 , 1 0 00 , 7 , 0 , 0 , 1 COMMAND: The SOUND features of the CPC464 is one of the most complex extensions to BASIC and is introduced in chapter 6.
  • Page 173 S P E E D K E Y 2 0 ,3 COMMAND: If held down continuously, the keys on the CPC464 auto repeat at the <repeat period> after the given <start delay> period. The setting is made in 1/50 sec units, in the range 1..255. The default rate is set to 30,2 Very small start delays will interact with keyboard de-bounce routines.
  • Page 174 S Q ( < c h a n n e l > ) 1 0 M O D E 1 2 0 F O R n = 2 0 T O 0 S T E P-l 3 0 P R I N T n ; 4 0 S O U N D 1 , 1 0 + n , l 0 0 , 7 5 0 W H I L E S Q ( 1 ) >...
  • Page 175 SYMBOL AFTER command. The character number, is chosen from the available ASCII or other characters from the CPC464’ s standard character set, and the following entries define the new character on an 8x8 pixel matrix. A 0 in the row indicates the paper colour to be used and a 1 indicates that the pixel is to be set to the current ink colour.
  • Page 176 SYMBOL AFTER S Y M B O L A F T E R < i n t e g e r e x p r e s s i o n > S Y M B O L A F T E R 9 0 COMMAND: The number of user definable characters is set by the SYMBOL AFTER command.
  • Page 177 TAN (<n u m e r i c e x p r e s s i o n > ) P R I N T T A N ( 4 5 ) FUNCTION: Calculates the tangent for the angles given in <numeric expression>, which must be in the range -200,000..+200,000, defaulting to radian measure unless declared otherwise by a DEG command.
  • Page 178 TRON TROFF TRON TR OFF T R O N COMMAND: BASIC includes the facility to trace the execution of a program, by reporting the number of each line in square brackets [ ] , just before it is executed. TRON enables the feature, TROFF turns it off.
  • Page 179 VPOS V P O S ( # < s t r e a m e x p r e s s i o n > ) P R I N T V P O S ( # 0 ) FUNCTION: Returns the vertical position of the text cursor for the stream expression Associated keywords: POS WAIT WAIT <...
  • Page 180 WEND WEND 1 0 M O D E 1 : R E M B A S I C C L O C K T I M E R O U T I N E 2 0 I N P U T " E n t e r t h e c u r r e n t h o u r , m i n u t e , a n d s e c o n d ( h , m , s ) "...
  • Page 181 WIDTH WI D T H < i n t e g e r e x p r e s s i o n > W I D T H 8 6 COMMAND: Tells BASIC how wide the printer is in characters, this information allows BASIC to insert carriage returns as required when printing.
  • Page 182 XPOS XPOS P R I N T X P O S FUNCTION: Establishes the horizontal position of the graphics cursor. Associated keywords: YPOS, MOVE, MOVER, ORIGIN YPOS YPOS P R I N T Y P O S FUNCTION: Establishes the vertical position of the graphics cursor. Associated keywords: XPOS, MOVE, M OVER, ORIGIN ZONE Z O N E <...
  • Page 183 PRINT P R I N T [ # < s t r e a m e x p r e s s i o n > , ] [ < p r i n t l i s t > ] [ < U S I N G c l a u s e >...
  • Page 184 PRINT (continued...) PRINT USING “ < F o r m a t F i e l d S p e c i f i e r s > ” NUMERIC Specifier Possible Field Definition Example Digits Characters #### Numeric field Decimal Point Print leading or trailing sign...
  • Page 185: Control Characters

    9 Further programming information Subjects covered in this chapter * Text Legal Position * Control Characters * The Machine Operating System * Interrupt structures 9.1 Cursor locations and control code extensions In a variety of applications programs, the text cursor may be positioned outside the current window. Various operations force the cursor to a legal position before they are performed, these are : ? ?writing a character ? ?drawing the cursor ‘...
  • Page 186 Additional control character commands: not generally accessible via the keyboard CTRL key Value Name Parameter Meaning &00 0 No effect. Ignored. &01 1 0..255 Print the symbol given by the parameter value. This allows the symbols in the range 0..31 to be displayed. &02 2 Turn off text cursor.
  • Page 187 window. Fills affected cells with the current Paper Ink. &13 19 * Clear from start of window to, and including, the current character position. Fills affected cells with the current Paper Ink. &14 20 * Clear from, and including, the current character position to the end of window.
  • Page 188 9.2 Machine Operating System The housekeeping of the CPC464 is provided by a sophisticated real time operating system. The operating system ‘ directs the traffic’ through the computer from the input to the output.
  • Page 189 9.3 Interrupts The CPC464 makes extensive use of the Z8O interrupt structure to provide an operating system that includes several multitasking features as exemplified by the AFTER and EVERY structure described in chapter 8. The precedence of the interrupts is:...
  • Page 190: The Master Clock

    * EVERY * REMAIN * The master clock If you haven’ t already noticed, a major innovation in the software of the CPC464 is its unique ability to handle interrupts from - which means that is capable of performing a...
  • Page 191 When the time specified has passed, the subroutine is called automatically, just as if a GOSUB had been issued at the current position in the program. When the subroutine finishes, using a normal RETURN command, the main program continues running where it was interrupted. The timers have different interrupt priorities.
  • Page 192 The timers have different interrupt priorities. Timer 3 has the highest priority and timer 0 the lowest. Immediately the timer expires, the count is reset and the count down to the next call of the subroutine begins. commands may be issued at any time, resetting the subroutine and time associated with the EVERY given delay timer.
  • Page 193 Zap the wotsit! Even if the only reason you bought your CPC464 was to take advantage of the sophisticated computer games available to run on the ‘ hardware’ , you may still probably be wondering about several aspects of the computer that come under the heading of ‘...
  • Page 194 ‘ dialects’ . The version in the CPC464 is one of the most widely compatible dialects of BASIC, and will run many of the common BASIC programmes written for operation under the CP/M disk operating system.
  • Page 195 We hope that you will try them all to make the most of your computer. Why can’ t? With all the power of modern technology, users frequently wonder why even a machine as advanced as the CPC464 is apparently unable to display the sort the type of pictures seen on any TV set.
  • Page 196 Q Why, for instance, can’ t a computer animate a picture of someone walking across the screen in a natural fashion - why do all computers represent movement with ‘ matchstick’ figures? The answer is simple yet complex. The simple answer is that you must not beguiled into believing that the screen of your computer has anything of the subtlety of the screen of a TV set.
  • Page 197 Until you tell it to the contrary, the computer will try and interpret all the characters that you type at the keyboard as being program instructions. When you press the [ENTER] key, the computer will look through what has been typed and if it doesn’ t make sense to the built in BASIC, it will reject the input with the comment: Syntax error However, it may just happen that the program presently residing in your computer is a Word...
  • Page 198: Glossary Of Terms

    Arithmetic Logic Unit. The part of a microprocessor that carries out arithmetical and logical operations - not of direct concern except in machine code programming. AMSOFT AMSTRAD's specialist computer support division, supplying software, peripherals, publications specifically to enhance the CPC464 and its many applications.
  • Page 199 American Standard Code for Information Interchange. A commonly used way of representing the numbers, letters and other symbols that can be entered from the computer's keyboard or invoked using a variety of other commands. The CPC464 codes are listed in Appendix III.
  • Page 200 (See Base) The number system with base 2, in which all numbers are made up from the two binary digits 0 and 1. Binary number A number represented in binary notation. Signified in the CPC464 programming by the prefix &X. eg &X0101 (decimal) 5.
  • Page 201 A group of connections either within the computer, or connecting it to the outside world that carries information on the state of the CPU, the RAM and other hardware features. The CPC464 bus is presented on the larger of the two circuit board connector strips, accessible through the holes in the rear of the case.
  • Page 202 Cartridge A specially packaged memory integrated circuit containing software which can be plugged directly into a socket specifically provided for the purpose on the computer. Cartridge software loads and runs more quickly and easily, but costs considerably more than software supplied on cassette. Cassette Apart from the obvious recording tape variety, a generic term that encompasses a variety of 'packages'-including ROM software etc.
  • Page 203: Cursor Control Keys

    Compiler A complex program that converts complete programs written in a high level interpretive languages like BASIC into a the direct instruction code of the microprocessor, thereby enabling operation at much greater speeds. Computer generations Technological landmarks have delineated several distinct steps in computer technology, and the groupings within these various strata are known as the 'generations'of design technologies.
  • Page 204: Disk Drive

    Decimal notation Also known as the Denary system, for numbers with base 10, using the digits 0 to 9, representing numbers of units, tens, hundreds, thousands and so on. Diagnostic A message automatically produced by a computer to indicate and identify an error in a program. Digital Describes the expression of a changing quantity in terms of discrete steps rather than by a continuous process.
  • Page 205 Dumb terminal A computer terminal that simply acts as a medium for input and output without any processing of the information passing through. Note that a mindless terminal is one where even the display drive electronics are absent, and that the screen display information is fed in as pure video.. Editing Correcting or making changes to data, a program or text.
  • Page 206: Floppy Disk

    A key on the keyboard that has been assigned a specific task -which may in addition to, or instead of the main purpose inscribed upon it. The CPC464 has a number of keys that may be defined as function keys, whereupon a single keystroke can issue up to 32 characters of text in the form of commonly used instructions, or instructions controlling peripheral equipment, such as modems or printers.
  • Page 207 The electronic and mechanical parts of a computer system -anything that isn't software or firmware. Hexadecimal notation Numbers based on 16. See Appendix II. Signified in the CPC464 by the prefix & or &H. High-level language Languages which are written in 'near literal' form, where the actual language does most of the work of interpreting.
  • Page 208: Instruction Set

    Interface The way in and out of a computer, both in electrical and human terms. The CPC464 interface is the keyboard (input), and the screen (output) - as well as the facility at the rear for the connection of user peripherals to the interface bus.
  • Page 209 Joystick An input device that generally replaces the function of the cursor keys, and makes games playing faster and easier. A shortform of the metric measure prefix for 1000, 'kilo' - which in computing has come to be widely used to refer to a 'kilobyte' - which is actually 1024 (decimal) in view of the binary association of 2 raised to the power of 10.
  • Page 210 Large Scale Integration. The development of integrated circuits, packing more functions onto ever smaller pieces of silicon. Machine Code The programming language that is directly understood by a microprocessor, since all its commands are represented by patterns of binary digits. Machine readable A medium of data or any other information that can be immediately input to a computer without additional work on keyboarding etc.
  • Page 211: Numeric Keypad

    Half a byte: a four bit binary expression. Each of the hexadecimal digits in the expression &F6 representsone nibble'. Noise The CPC464 sound facility includes a facility to inject a variable amount of random noise by using the SOUND command to create effects such as explosions. Numeric keypad...
  • Page 212 Operating system The attendant in the parking lot referred to under the entry for Memory. Software that allocates precedence and timing to the operations of the computer.
  • Page 213: Parallel Interface

    Parallel interface The CPC464 printer interface supports a parallel printer: which means that each data line from the bus is connected to a corresponding input on the printer. Data is transfered more quickly using a parallel interface than a serial interface since the serial interface must first format each byte, and ftame it with synchronisation information.
  • Page 214: Qwerty Keyboard

    POKE The statement in BASIC that is used to place a value in a specified memory location - see chapter Port A specifically addressable point on the interface for input or output of data. Portability Other than the literal use, means the ability for software to operate on different makes of computer - usually as a result of a compatible operating system, such as the Digital Research CP/M Primer...
  • Page 215 Random Access Memory. Memory that may be both read from, and written to, using the internal circuitry of the computer during the normal course of program execution. Random number A number that is generated by the computer program that is neither repeatable, nor predictable. Raster A system of 'writing' on the screen where the images are built from a number of horizontal scan lines.
  • Page 216: Screen Editor

    Resolution The ability to determine where one element of the display ends, and the next one begins. Also loosely applied to the ability of a computer to perform arithmetical manipulations on large numbers. Reverse Polish notation (RPN) A method of describing arithmetical operations favoured by some calculator manufacturers, where the operators /) are placed behind the values to which they apply.
  • Page 217 Si-m ullation A technique for emulation of real life interactive processes using the computer, such as flight simulation, driving simulation etc. Soft key See UDK (user defined key). Software Programs. Software engineering A grandiose expression meaning computer programming, implying a structured and considered approach, as opposed to arbitrary techniques.
  • Page 218 1 or 0, and the truth table lists the possible results of a logical operation (IF A> B THEN C) accordingly. User defined keys. The CPC464 has up to 32 keys which may be redefined to perform a variety of tasks, including strings of up to 32 characters.
  • Page 219 actual value may be made to vary during the execution of a program.
  • Page 220 Appendix II An introduction to the background of computing Whose afraid of the jargon? As with all ‘ specialist’ industries, computing has developed its own jargon as a short-hand form of communicating complicated concepts that require many words of ‘ plain language’ explanation. It’ s not just the high technology business that’...
  • Page 221 Basics of BASIC Virtually all home computers provide a language known as BASIC, which allows programs to be written in the nearest thing to plain language presently available. BASIC is an acronym of ‘ Beginners All-purpose Symbolic Instruction Code - it no longer has any particular significance as to the degree of the sophistication of the languages, and many extremely complex and powerful programs are written using BASIC.
  • Page 222 Through the medium of the program, the computer breaks down every task into a simple series of Yes/No operations. The process of multiplication is performed using multiple additions - the BASIC instruction to multiply 35 by 10 (35*10) gets to the answer by adding 35 to itself ten times. Part of the Central Processor Unit (CPU) is loaded with the numeric data for 10, and another part of the CPU is loaded with 35.
  • Page 223: Bits And Bytes

    If the ultimate answer is either 0 or 1, then there is no possibility of it being ‘ nearly’ correct. The fact that computers can sometimes appear to make errors when handling numeric data is due to the limitation of the size of numbers it can process requiring ‘ oversize’ data to be squeezed down to fit the space available, or truncated, leading to rounding errors.
  • Page 224 This array can locate up to (10x10) items of information using address numbers that lie in the range 1 to 9. The item stored at position 3,5 is a ‘ 1’ - as is the item at 5,5. So a binary array of 256x256 can handle 65,536 individual locations using 8 bit addresses for the vertical and horizontal axes of the array.
  • Page 225 1111 binary. The first block indicates the number of complete units of ‘ 15’ , and the second indicates the ‘ remainder’ - and this is where the elegance of binary begins to emerge. Reconsidering the table that introduced binary notation Decimal Binary CPC464-ese Hexadecimal *flfl *fl* **fl...
  • Page 226 It’ s the same process you use when you read a decimal (also known as a Denary number) number such as ‘ 89’ - ie (8x10)+(9). It just happens that multiplying by ten is a great deal simpler unless you’ ve had a lot of practise at multiplying by 16. If you’...
  • Page 227 Appendix III The ASCII characters, and the graphics characters of the CPC464 III.1 ASCII For convenient reference, we reproduce here the standard ASCII reference character set using decimal, octal and hex notation, together with the ASCII code where appropriate. Each of the CPC464 character cells is also represented in detail.
  • Page 228 The characters reproduced here are plotted on the standard 8x8 cell matrix used to write the screen of the CPC464. User Defined Characters may be grouped for special effects and butted close against each other - see the SYMBOL command descriptiongiven in Chapter 8.
  • Page 229 A generous amount of RAM is supplied as standard, over 42K of which is actually available to the user, thanks to the implementation of ROM overlay techniques when implementing the BASIC. Screen The CPC464 supports three basic screen handling modes, including 80 column text, a palette of 27 colours, and resolution up to 640x200 pixels.
  • Page 230: Elapsed Time

    Real Keyboard A full feature ‘ typewriter-style’ keyboard, with a logical cursor key cluster and standard numeric entry keypad which doubles use for function key purposes. Built-in cassette Local cassette storage is available as a built-in feature, thus providing operation with no additional user complications with hookup, level setting etc.
  • Page 231: Printer Port

    The cursor is represented by an inverse square of colour. Polyphonic Sound The sound facilities of the CPC464 are generated using the industry standard sound generator device from General Instrument’ s AY8910 family. The device operates with 3 channels (voices), each of which can be independently set for tone and amplitude.
  • Page 232 Overview: A brief summary of the main features of the hardware and firmware of the CPC464. 1) Hardware 1.1) Inside the main CPC464 case. Computer, keyboard, cassette datacorder and loudspeaker. RGB and luminance outputs. 1.1.1) LSI chips Z80A processor running at 4MHz.
  • Page 233 1.2) Outside the case. The CPC464 system comes with a choice of two types of direct input video monitor, each includes a 5v power supply for the computer, designed to suit local mains voltage standards in the country of sale.
  • Page 234 PINK MAGENTA PASTEL MAGENTA MAUVE BRIGHT GREEN BRIGHT RED SEA GREEN PURPLE BRIGHT CYAN BRIGHT MAGENTA LIME GREEN GREEN PASTEL GREEN CYAN PASTEL CYAN SKY BLUE BRIGHT YELLOW YELLOW PASTEL YELLOW BRIGHT WHITE 1.4) Memory Map The 64K of RAM is allocated as follows. Note that part of the ROM overlays the screen RAM, thereby releasing the maximum possible area to user RAM during BASIC operations.
  • Page 235 1.5.2) Additional RAM Additional RAM can be switched in place of any part of the on-board RAM. The address arbitration and bank selection logic will be contained in a module connected to the expansion bus, but all the signals required are brought to the expansion bus. This memory will be read-only and a special scheme involving I/O mapping will be required to write to this additional RAM from the computer.
  • Page 236 Appendix V: Rear panel connection to the CPC 464 PADDLE PORT CONNECTOR (9 PIN D) VIEWED FROM REAR PIN 1 PIN 6 FIRE 2 PIN 2 DOWN PIN 7 FIRE 1 PIN 3 LEFT PIN 8 COMMON PIN 4 RIGHT PIN 9 COM 2 PIN 5...
  • Page 237 EXPANSION PORT 50 WAY 0.1 EDGE CONNECTOR VIEWED FROM REAR PIN 1 SOUND PIN 18 PIN 35 /INT PIN 2 PIN 19 PIN 36 /NMI PIN 3 PIN 20 PIN 37 /BUSRD PIN 4 PIN 21 PIN 38 /BUSAK PIN 5 PIN 22 PIN 39 READY...
  • Page 238 Appendix VI: TEXT and WINDOW planner MODE 0 20 columns...
  • Page 239 Text and WINDOW planner Mode 1 40 columns...
  • Page 240 Text and WINDOW planner Mode 2 80 Columns...
  • Page 242 Appendix VII: Notes and Tone Periods. The table which follows gives the recommended Tone Period settings for notes in the usual even tempered scale for the full eight octave range. The frequency produced is not exactly the required frequency because the period setting has to be an integer.
  • Page 243 NOTE FREQUENCY PERIOD RELATIVE ERROR 1 3 0 . 8 1 3 + 0 . 0 4 6 % 1 3 8 . 5 9 1 + 0 . 0 0 7 % 1 4 6 . 8 3 2 -0.037% 1 5 5 .
  • Page 244 NOTE FREQUENCY PERIOD RELATIVE ERROR These values 32.703 -0.374% are all 34.648 + 0 . 2 2 9 % calcula 36.708 -0.390% 38.891 -0.441% from 41.203 + 0 . 2 0 6 % 43.654 -0.543% Interna Octave 2 46.249 -0.548% tional 48.999 + 0 .
  • Page 245 Sound envelope/Music planner sheet...
  • Page 246 As with most things, you will learn most readily from your mistakes, so make the most of the fact that the CPC464 is the most tolerant of tutors: you will tire of trying long before the CPC464 loses its patience! All errors generated by BASIC are listed here, in error number order.
  • Page 247 1 U n e x p e c t e d N E X T A NEXT command has been encountered while not in a FOR loop, or the control variable in the NEXT command does not match that in the FOR. 2 S y n t a x E r r o r BASIC cannot understand the given line because a construct within it is not legal.
  • Page 248 1 3 T y p e m i s m a t c h A numeric value has been presented where a string value is required. and vice versa, or an invalidly formed number has been found in READ or INPU 1 4 S t r i n g s p a c e f u l l many strings have been created that there is no further room available, even after ‘...
  • Page 249 A B S , A F T E R , A N D , A S C , A T N , A U T O B I N $ , BORDER C A L L , C A T , C H A I N , C H R $ , C I N T , C L E A R , C L G , C L O S E I N , C L O S E O U T , C L S , C O N T , C O S , C R E A L D A T A , D A T A , D E F , D E F I N T , D E F R E A L , D E F S T R , D E G , D E LETE, D I , D I M , D R A W , D R A W R...

Table of Contents