background image

Summary of Contents for CPC464

Page 1: ......

Page 2: ...anual 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 Scanning and OCRing from the original by David Wykes Typeset and cleaned up by Kevin Thacker Proofreading by Martyn Lycett ...

Page 3: ...into three sections The first is the beginners Foundation Course written specifically to introduce computing concepts and terminology to the novice If you have not previously owned or used a personal computer to the point at which you have written a small program of your own then we advise that you work through the Foundation Course Those of you with previous experience should enter at Chapter 1 W...

Page 4: ...rs or omissions in this manual A list of details of any amendments or revisions to this manual can be obtained by sending a stamped self addressed envelope to AMSOFT Technical Enquiries We ask that all users take care to submit their reply paid user registration and guarantee cards AMSOFT welcome comments and suggestions relating to the product or this manual All correspondance should be addressed...

Page 5: ...e by leading manufacturers providing that they are not CR 02 or metal tape and are no longer than 90 minutes C 90 To enable you to locate programs recorded on the tape more easily we suggest that you use C 12 cassettes 6 minutes per side 7 Note that cassettes containing programs from other types of computer cannot be run or loaded on the CPC464 8 If the cassette you are using has had the safety ta...

Page 6: ...acorder 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 PRINT and display formatting 4 Variables operators and data Display formatting Data and arrays Dimensioning Locate 5 Graphics primer The principles of AMSTRAD CPC464 co...

Page 7: ...cters The relationship between the machine code subroutines and the high level BASIC commands 10 Interrupt features The real time features AFTER EVERY and REMAIN Appendices I A newcomers guide to what you can and can t expect a computer to do Glossary of computing terms II Bits and bytes binary and hexadecimal tutorial III ASCII codes and the character set Character definitions and grids Keyboard ...

Page 8: ...s WARNING Disconnect the Mains Plug from the Supply Socket when not in use 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 in a new Plug must NOT be used If any other Plug is used a 5 Amp Fuse must be fitted either in the Plug or Adaptor or at the D...

Page 9: ...v AC Socket Now switch on the monitor and then switch on the computer using the slide switch marked POWER on the right hand end The red ON lamp at the top centre of the computer keyboard unit should be illuminated and the monitor will display the following picture Amstrad 64K Microcomputer v1 1984 Amstrad Consumer Electronics plc and Locomotive Software Ltd BASIC 1 0 Ready Cursor To avoid unnecess...

Page 10: ...e OFF position Connect the Mains Plug from the monitor into the Mains Supply 240v AC socket Now switch on the monitor and then switch on the computer using the slide switch marked POWER on the right hand end 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 su...

Page 11: ...ng picture Amstrad 64K Microcomputer v1 1984 Amstrad Consumer Electronics plc and Locomotive Software Ltd BASIC 1 0 Ready Cursor To avoid unnecessary eye strain adjust the control at the side of the monitor marked BRIGHTNESS until the display is adequately bright for comfortable viewing without glare or blurring of the writing ...

Page 12: ...s to the inside of the equipment Figure 2 The MP1 modulator and power supply 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 in a new Plug must NOT be used If any other Plug is used a 5 Amp Fuse must be fitted either in the Plug or Adaptor or at the...

Page 13: ...g the slide switch marked POWER on the right hand end The red ON lamp at the top centre of the computer keyboard unit should be illuminated and you must now tune in your TV set to receive the signal from the computer If you have a TV with push button channel selection press a channel button to select a spare or unused channel Adjust the corresponding tuning control in accordance with the TV set ma...

Page 14: ...OCKET FOR SECOND JY1 Joystick controller 1 5 Welcome Cassette Packed into one of the polystyrene end caps in your computer packaging you will have found the Welcome cassette tape Open the door on the Datacorder unit by pressing the key marked STOP EJECT and then insert the cassette into the Datacorder of the computer as shown in figure 3 make sure that the SIDE 1 printing is uppermost Figure 3 The...

Page 15: ...ly so when you have finished watching press the ESC key twice This stops the program and you can now STOP and eject the cassette then turn it over to run side two After turning the cassette over ready for Side 2 once again remember to press the REW ind button on the datacorder to ensure that the tape is rewound to the start Press down the key marked CTRL Control and AT THE SAME TIME press the smal...

Page 16: ... the following instructions indicates that you must press either of the two keys marked ENTER do not type the word ENTER The symbol is obtained by pressing either SHIFT key together with the 2 key on the top row of the keyboard Type in Load ENTER The computer asks you to Press PLAY then any key Now press the PLAY key in the row at the front of the Datacorder until it locks down firmly followed by ...

Page 17: ...til the exact program title that you have typed in is found or until you press the ESC key to stop the computer searching the tape When the program has been found you will see this message appear on the screen Loading title block 1 The block numbers will continue to increase until the tape has finished loading and the message Ready will appear on the screen Then type run ENTER and the program you ...

Page 18: ...remembering to press the STOP EJECT button when the tape stops Type in save program title ENTER The computer will respond with Press REC and PLAY then any key Now press the REC and PLAY keys on the Datacorder until they lock down firmly followed by any key letter number space or ENTER keys The computer will then respond with Saving program title block 1 When the program has been saved the cassette...

Page 19: ... d removed If you press DEL and continue to hold it down the letters a b c will also be removed SHIFT There are two SHIFT keys If you press either of these and hold it down whilst typing a character a capital letter or upper case symbol will appear on the screen Type in the letter a then hold down the SHIFT key and type in the letter a again On the screen you will see aA Now type in a few spaces b...

Page 20: ...n be carried out by holding down the CTRL key then pressing CAPS LOCK key once Now type in abcdef123456 On the screen you will see ABCDEF It is still possible to type in numbers while CTRL and CAPS LOCK are in operation by using the number keys to the right of the main keyboard Holding down the CTRL key and pressing CAPS LOCK once will return you to the mode that you were previously in CAPS LOCK o...

Page 21: ...ou reach the right hand edge of the display by entering more than 40 characters on the screen the next character will automatically appear on the next line at the left edge of the screen This means that you should NOT press ENTER as those of you accustomed to typewriters might press a carriage return towards the right edge of a page The computer does this automatically for you and will react to an...

Page 22: ...r 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 CLS Type in cls clear screen You can use either upper case capital or lower case small letters Then press ENTER You will notice that the screen clears and the word Ready with the cursor will appear at the top left of the s...

Page 23: ...ped in by listing the program Type List ENTER and on the screen you will see 10 PRINT hello which is the program stored in the memory Notice how the word PRINT is now in capitals This means that the computer has accepted PRINT as a known BASIC keyword Type in cls ENTER to clear the screen Note that although the screen is cleared when you type in cls ENTER your program is not erased from the comput...

Page 24: ...up exceeds 12 the next character will be displaced forward by another 13 columns Again to escape from this program press ESC twice To clear the computer s memory completely hold down the SHlFT CTRL and ESC keys in that order and the computer will reset INPUT This command is used to let the computer know that it is expecting something to be typed in for example the answer to a question Type the fol...

Page 25: ... 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 Now we will combine the above 2 examples into one program Reset the computer by pressing CTRL SHIFT and ESC Type in the following 5 cls ENTER 10 input what is your name a ENTER 20 input what is your age b ENTER 30 print I m...

Page 26: ... is the edit method and finally there is the copy cursor method EDIT METHOD To correct the mistake in line 5 type edit 5 ENTER Line 5 will then be printed with the cursor superimposed over the 5 To edit out the extra s in clss press the cursor right key until the cursor appears over the last s then press the CLR key You will see the s disappear Now press ENTER and line 5 will now be corrected in t...

Page 27: ...extend the previous program with the use of the if and then comands Type in the following Notice that we have added two symbols means less than and is next to the M key means greater than and is next to the less than key 5 cls ENTER 10 input what is your name a ENTER 20 input what is your age age ENTER 30 if age 13 then 60 ENTER 40 if age 20 then 70 ENTER 50 if age 19 then 80 ENTER 60 print So a Y...

Page 28: ...ollowing note that the symbol means multiply 5 cls ENTER 10 for a 1 to 20 ENTER 20 print a 12 a 12 ENTER 30 next a ENTER run ENTER You will notice the columns look untidy so type in 5 cls ENTER 10 for a 1 to 9 ENTER 20 print a 12 a 12 ENTER 30 next a ENTER 40 for a 10 to 20 ENTER 50 print a 1 2 a 12 ENTER 60 next a ENTER run ENTER Try this program for multiplication tables using other numbers For ...

Page 29: ...type in the equals sign Type 8 4 ENTER 12 SUBTRACTION use unshifted key for minus Type 4 3 ENTER 1 Type 8 4 ENTER 4 MULTIPLICATION Use SHIFT and keys for multiply means X Type 3 3 ENTER 9 Type 8 4 ENTER 32 DIVISION use unshifted key for divide means Type 3 3 ENTER 1 Type 8 4 2 ...

Page 30: ...s 84 4094 CUBE ROOT You can quite easily calculate cube roots by using a similar method to the last example under square roots To find the cube root of 27 3 27 Type 27 1 3 ENTER 3 To find the cube root of 125 Type 125 1 3 ENTER 5 MIXED CALCULATIONS MOD Mixed calculations are understood by the computer but they are calculated within certain priorities First priority is given to multiplication and d...

Page 31: ... to the multiplication etc outside the brackets Prove this by typing in the calculation including brackets Type 3 7 2 7 4 ENTER FURTHER EXPONENTS If you want to use very large or very small numbers in calculations it is sometimes useful to use scientific notation The letter E is used for the exponent of numbers to the base 10 You may use either lower case e or upper case E For example 300 is the s...

Page 32: ...or you can type 3e1 1e1 ENTER 300 2 3000x1000 Type 3e3 1e3 ENTER 3000000 3 3000x0 001 Type 3e3 1e 3 ENTER 3 ...

Page 33: ...e number of 1 s on a line you will see there are 20 This means that in mode 0 there are 20 columns Press ENTER again Now type in mode 2 ENTER You will see that this is the smallest mode and if you type in a row of 1 s you will count 80 This means that in mode 2 there are 80 columns To recap Mode 0 20 columns Mode 1 40 columns Mode 2 80 columns Finally press ENTER once more COLOURS There is a choic...

Page 34: ...lue 25 Pastel Yellow 12 Yellow 26 Bright White 13 White Table one The INK numbers and colours As explained earlier when the computer is first switched on it is in Mode 1 To return to Mode 1 type in mode 1 ENTER The colours of BORDER PAPER and PEN at switch on are Border Colour number 1 blue Paper screen Colour number 1 blue Pen characters Colour number 24 bright yellow The BORDER is the area surro...

Page 35: ...to bright cyan Now type in Cls ENTER to clear the screen again to the new PAPER colour To see the PEN colour change type in PEN 3 ENTER You will see that the PEN colour has changed and the word Ready is printed in bright red Now type in cls ENTER You will find it easier to understand what has happened here if you refer also to Table 2 When the computer is first switched on the PAPER used is number...

Page 36: ...de 1 Mode 2 0 1 1 1 1 24 24 24 2 20 20 1 3 6 6 24 4 26 1 1 5 0 24 24 6 2 20 1 7 8 6 24 8 10 1 1 9 12 24 24 10 14 20 1 11 16 6 24 12 18 1 1 13 22 24 24 14 Flashing 1 24 20 1 15 Flashing 16 11 6 24 Table two PAPER PEN MODE INK reference ...

Page 37: ...colour that the PEN or PAPER is to be changed to Look at Table 1 for the colour numbers As an example we will show how to change the colour of PAPER 2 to black and the colour of PEN 3 to bright white In Table 1 you will see that the colour number for black is 0 and the colour number for bright white is 26 Now type in ink 2 0 ENTER As explained 2 is the current PAPER number and 0 is black Now type ...

Page 38: ...e in ink 0 9 24 ENTER In this case 0 is the PAPER number while 9 is the colour green and 24 is the alternate colour bright yellow Now reset the computer CTRL SHIFT ESC Note that in mode 0 two of the PENs numbers 14 and 15 together with two of the PAPERs numbers 14 and 15 are default flashing colours In other words it is not necessary to add an extra number to the INK command type in the following ...

Page 39: ...e following program then run it We have included some sound in the program This will be explained in a later section 10 mode 0 ink 0 2 ink 1 24 paper 0 ENTER 20 pen 1 for b 0 to 26 border b ENTER 30 locate 3 12 print BORDER COLOUR B ENTER 40 sound 4 40 b ENTER 50 for t 1 to 600 next t next b cls ENTER 60 for p 0 to 15 paper p pen 5 p rint paper p print ENTER 70 for n 0 to 15 pen n print pen n ENTE...

Page 40: ...20 next n run For your reference the range of characters together with their respective reference numbers appear in Appendix III at the back of this book LOCATE This command is used to reposition the character cursor to a specified part of the screen Unless changed by the locate command the character cursor starts at the top left corner of the screen which corresponds to x y co ordinates 1 1 x is ...

Page 41: ...where on the screen Just for example type in Locate 20 12 print chr 240 You will see an arrow in the centre of the screen Note that in this instruction 20 was the horizontal x co ordinate in the range 1 to 40 12 was the vertical y co ordinate in the range 1 to 25 240 was the character symbol number in the range 32 to 255 To get the character symbol 250 to be repeated across the screen type in the ...

Page 42: ...all bd19 80 print chr 251 85 next x 90 for n 1 to 300 next n 95 goto 10 run Try this interesting small program We have added some other commands that will be explained in later chapters For now just type in new 10 mode 1 20 locate 21 14 print chrS 244 30 tag 40 for x 0 to 624 step 2 50 mover 16 0 60 if x 308 or x 340 x 340 then y 196 goto 90 70 if x 324 then y x 104 goto 85 80 y 536 x 85 sound 1 0...

Page 43: ...f the screen Now change the mode by typing mode 0 plot 320 200 You will see the dot is still in the centre but is now larger Change the mode again and type in the same command to see the effect in mode 2 Type in mode 2 plot 320 200 The dot is still in the centre but it is now much smaller Plot several dots over the screen in various modes in order to accustom yourself with this command When you ha...

Page 44: ... plot 20 20 70 draw 20 380 80 draw 620 380 90 draw 620 20 100 draw 20 20 200 goto 10 run Press ESC twice to break from this program CIRCLES Circles can either be plotted or drawn One method of forming a circle is to plot the x y co ordinates of each point on the circumference of a circle Refer to the figure below and you will see that point p on the circumference can be plotted using x and y co or...

Page 45: ...rogram to draw a circle would then be like this Type in new 5 cls 10 for a 1 to 360 15 deg 20 plot 320 200 30 plot 320 190 cos a 200 190 sin a 40 next run The radius of the circle can be reduced by lowering the 190 figure 190 refers to pixels To see the effect of the circle being plotted differently in radians delete line 15 from the program by typing in 15 To see a solid circle drawn by lines fro...

Page 46: ...t four smaller circles on the screen type in the following program new 5 cls 10 for a 1 to 360 15 deg 20 origin 196 282 30 plot 50 cos a 50 sin a 40 origin 442 282 50 plot 50 cos a 50 sin a 60 origin 196 116 70 plot 50 cos a 50 sin a 80 origin 442 116 90 plot 50 cos a 50 sin a 100 next run Once again you can remove line 15 and modify lines 30 50 70 and 90 to use the DRAW command GOSUB RETURN If th...

Page 47: ...arry out instruction 120 which is only required when called by gosub To conclude this section try the following program which incorporates a lot of the programming commands and keywords that you should now understand Type in new 10 mode 0 border 6 paper 0 ink 0 0 20 gosub 160 for x 1 to 19 locate x 3 30 pen 15 print chr 238 40 for t 1 to 50 next t sound 2 x 100 50 next x gosub 50 for b 3 b 3 to 22...

Page 48: ...ope noise period In the following examples we will type in 1 as the channel status in other words its reference number TONE PERIOD Refer to Appendix VII and you will see that the note middle c has a tone period of 478 Type in new 10 sound 1 478 run You will hear a short note which is middle c lasting 0 2 second DURATION When no duration of the sound is specified it will last 0 2 second The unit of...

Page 49: ...olume levels are the same as those in the sound command However the step can be adjusted from 128 to 127 so that you can not only vary the amplitude up or down in the obvious way but can vary it by using numbers higher than 15 to give some strange effects The range of amplitude of step numbers is 128 to 127 STEP TIME This number specifies the time between steps in 0 01 second 1 100th s of a second...

Page 50: ...of up to 5 optional envelope sections available We are only using one of these here Further explanation will appear in Chapter 6 ent envelope number number of steps tone period of step step time ENVELOPE NUMBER This is the number given to a particular envelope so that it can be specified in the sound command The range of envelope numbers is 1 to 15 NUMBER OF STEPS This is used in conjunction with ...

Page 51: ...s tone envelope number 1 consisting of 100 steps increasing the tone period reducing the frequency by 2 every 0 02 second 2 100th s of a second Now change line 5 in each of the following ways and then run each time to hear the effect of changing the tone envelope 5 ent 1 100 2 2 5 ent 1 10 4 20 5 ent 1 10 4 20 Now replace the sound command and the tone envelope by typing in 5 ent 1 2 17 70 10 soun...

Page 52: ...nd of the sound command A range of noise is available in the range 1 to 31 Try this by adding the noise number at the end of the sound command still using the envelope command Replace lines 5 and 20 by typing in 5 env 1 100 3 1 20 sound 1 200 100 1 1 1 5 run Again try to get some unusual sounds by modifying the volume envelope and the sound command with and without noise ...

Page 53: ...keyboard and text that forms part of the program listing the following conventions are used from here onwards in this user guide ENTER Keys that do not have a corresponding printed character on the screen are shown in this form surrounded by square brackets QWERTYUIOP Keys that have a corresponding printed character are shown in this form without square brackets 10 FOR N 1 t o 1000 Text that eithe...

Page 54: ...multaneously CTRL SHIFT and ESC ape pressed in sequence and held down simultaneously try it now before you enter anything else Adjust the BRIGHTNESS control on the right hand side of the monitor The colour is preset at the factory so if you want to change the colour of the display gold lettering on a blue background this must done by program instructions and you will have to skip to the graphics p...

Page 55: ... between the brightest and dullest parts of the display and the Vertical HOLD adjustment that enables the user the lock the display and prevent unwanted vertical rolling of the display The Vertical HOLD will not require frequent adjustment and once initially set may be forgotton The BRIGHTNESS and CONTRAST may be adjusted from time to time to suit the lighting conditions in the room where the CPC4...

Page 56: ...u find a combination you like stop the program using the ESC key twice a Break message will occur From here on the guide will be making many references that are specific to the colour monitor option Programs that display interesting colour and graphics effects may appear nearly invisible on the monochrome monitor although great care has been taken to produce a range of colours with a progression o...

Page 57: ...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 The red ON lamp at the top centre of the computer keyboard unit should be illuminated and you must now tune in your TV set to receive the signal from the computer If you have a TV with push button channel sele...

Page 58: ...esults that are not perfectly clear in which case you should use mode 1 for text entry whenever convenient 1 2 First steps You are now plugged in the power supply should be connected the video lead hooked up to either of the monitors or the modulator option and you have switched on Your computer is now waiting for an input The switch on screen display ie the Wake Up message is the only built in te...

Page 59: ...itional characters available on the CPC464 and their numeric codes Some of the other unprintable characters can be displayed by using a combination of the CONTROL marked on the keyboard as CTRL key and the other keys on the keyboard but don t worry about that just yet since until you understand the control key function you can do more harm than good by testing it at random 1 2 2 To see exactly wha...

Page 60: ... the computer and then asking the computer to process the in struction contained on that line or if the line began with a number then to store it away as part of your program ENTER is also sometimes referred to as the carriage return or simply return which is a reference to the early forms of computer terminals which were based on mechanical typewriter principles The term has remained and is enshr...

Page 61: ...ted to PRINT abcdefghijklmn etc it is asked to PRINT CHR N N just happens to be a convenient shorthand note for a variable the choice of the letter is arbitrary it just happens to be the mathematicians favourite in such applications a variable is an item of computer information that varies according to the instructions given in the program A number like 5 is fixed it occurs between the numbers 4 a...

Page 62: ... process is known as looping and this is one of the most vital and fundamental aspects of computer programming and operation This FOR loop is one of the most fundamental features of computing it occurs in all programming lanuages in one shape or form It saves typing in long repetitious sequences manually and you will quickly come to use it in your own programming When this FOR loop reaches the lim...

Page 63: ...t once you do many things about computing will fall into place and the elegant structure of the numbering system will become apparent Once the computer has translated the striking of the A key into the type of number it understands it looks into that part of the memory indicated and the result is another series of numbers that define the character That is to say the character you see displayed on ...

Page 64: ...ing language namely that it does not matter in which order you enter the program line numbers and you don t actually need to have the program displayed to add to it once it s been entered into the memory The computer always sorts the line numbers into strict numerical sequence before it starts to execute the program Check by using the LIST instruction 1 2 6 LISTing You can easily check to see what...

Page 65: ... 13 mode2 ink1 0 ink0 9 chr 13 you only have to press the smaller of the two ENTER keys the one on the number keypad and you can get back to base with a combination of colours that are visible You will not lose the program in memory User defined key codes are reset with the rest of the machine since they have to be made available to program instructions so once you have worked out your favourites ...

Page 66: ... whole line irrespective of the cursor position 3 You can also take the cursor back to the character immediately to the right of the one that you wish to delete 10 FOR N 332 TO 255 Now press DEL short for DELETE the character to the left of the cursor is deleted and the cursor pulls the line along behind it without affecting the character within the cursor Press ENTER and the line will be stored a...

Page 67: ...er in the line 5 CLS 10 FOR N 32 TO 255 20 PRINT CHR N 30 NEXT N Ready If you were to take the main cursor to the line to modify using the cursor keys without the SHIFT held down the computer would not recognise this as a valid action since only the characters entered directly after the main cursor will be recognised as valid instructions If you do try and overwrite the line in this way you can ea...

Page 68: ... short while Finally you can edit by typing EDIT 20 The computer responds with 20 PRINT CHR N Simply use the main cursor keys together with the CLR and DEL keys as instructed above and when you are satisfied with the result press ENTER as before If you get in a tangle press ESC and LIST once again The line where the ESC ape was pressed will not have been overwritten Now enter LIST once again and y...

Page 69: ...rminology 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 non volatile storage medium such as the optional disk system 2 1 Cassette controls At the right hand end of the keyboard unit you will find the cassette datacorder figure 2 1 The mechanics of this cassette mechanism are essentially the s...

Page 70: ... mechanical trip in the mechanism when the cassette tape reaches its end REW REW ind the tape from the right hand spool to the left hand spool There is no mechanical cancellation of this function at the tape end so you should not leave the machine running in rewind mode or the tape drive motor may overheat when stalled F F Fast Forward will advance the tape rapidly winding from the left hand spool...

Page 71: ...ing the tape supplied with your CPC464 The cassette should be fully rewound from the right hand to the left hand spool so if it is not press the REW key until the motor stalls at the tape end If the tape is accidentally looped out of the aperture on the front of the cassette then you should rewind the tape into the body of the cassette before inserting into the cassette machine or the cassette tap...

Page 72: ...n and then pressed the ENTER key but it is easier to use just 2 keystrokes to achieve the same results For most purposes the two ENTER keys perform the same task but there are circumstances where the smaller of the two keys can be altered redefined to some other operation using instructions from programs The subject of User Defined Keys will be covered in more detail later on The PLAY key you are ...

Page 73: ...ed in Appendix VIII that advises the nature of the problem It is not generally possible to do anything other than attempt to run the program again until it loads without an error Assuming that your tape is loading read the instructions on the screen and your Welcome tape will do the rest 2 5 Supersafe and Speedload The CPC464 offers two speeds to the user a Supersafe speed of 1000 baud bits of dat...

Page 74: ...e object of our SAVE command The file name can be any combination of 16 keyboard characters including spaces If you try to enter a longer name the 17th and subsequent characters will be discarded With the program in the computer s memory type SAVE CHARACTERS The computer responds with the prompt message Press REC and PLAY then any key Remember the qualification of the term any key the tape will st...

Page 75: ...pate wanting to edit or alter the program you should also keep a copy for yourself in unprotected form 2 6 4 SAVE filename B start address length entry point This option allows you to perform a binary save where a complete block of the data stored in the computer s RAM is stored onto the cassette exactly as it occurs in the internal memory It is necessary to instruct the computer where the section...

Page 76: ...ified as being block 1 of the program it first tried to load unsuccessfully This means that after a read error you can stop the tape using the cassette STOP EJECT key REW ind the tape to the beginning and press PLAY again The computer will then have another try at loading the program in which it found the read error and with luck this time you will be successful Read errors arise from a number of ...

Page 77: ...am concerned 2 8 Cassette considerations Although the Datacorder will happily accept all types of cassette up to C90 you should only use Cl2 6 minutes per side and C30 at the most Programs stored at the end of long cassettes are hard to locate unless you are prepared to wait for them to be found and you can remember the filename you gave them or you are meticulous about using the tape counter in y...

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 It is organised with clearly defined words and grammar and operates completely logically as long as you understand the rules AMS...

Page 79: ...rator which is either a space mathematical operator etc or other recognised character This is because it is permissable to use variables where a keyword or reserved word forms part of the variable obviously a reserved word cannot be a variable unless surrounded to prevent the computer from recognising the start and end of the instruction Keywords may be entered either as lower case letters un SHIF...

Page 80: ...iring at least one digit would appear digit digit Such an expression might be 34 or 344 or 345678 etc In many places a list of items separated by commas is used A short form is used which is best illustrated by example thus list of expression means expression expression or list of number means number number an example of which is 3 4 or 3 4 4 or 3 4 5 6 7 8 etc The list may be a single object If t...

Page 81: ...the computer to put the results of a command onto a specific output stream where a stream is identified by a number from 0 to 9 which is described in the analysis of BASIC as a stream expression which is the number that defines the particular stream to be used 0 7 are text streams to text windows that have been previously set up with the WINDOW command 8 is the parallel printer port and can only b...

Page 82: ...e 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 BASIC will print anything you put inside the double quotes without taking any notice of it Reserved words may be used in the print list PRINT 4 4 and the computer responds with ...

Page 83: ...ositive numbers preceded by a space negative numbers preceded by a sign All numbers are followed by a space The decimal point is omitted if there is no significant fractional part of the item to be printed 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...

Page 84: ...ble for the print item following which may be a variable of course and if this item exceeds the allocated space to the left of the decimal point it still displays but uses the to indicate that an overflow has occured Next the comma after 12 3 4 5 6 caused the following number to be printed at the start of the next print zone If it had been a semi colon the number would have been printed alongside ...

Page 85: ...ou to imbed keywords into variable names A variable in AMSTRAD BASIC is a name that you assign to a specific element It can be as simple as a single letter variables must always start with a letter not a number although its easier to read and understand a long program if you use variable names that reflect what s going on ANSWER 4 4 print ANSWER Variables in AMSTRAD BASIC may contain up to 40 char...

Page 86: ...same works in program lines but it s not a good habit to get into since if you subsequently go back to the line and add to it you will probably forget to close the quotes again 4 3 Multi statement lines and Mixed calculations You can perform a number of operations on a single line of BASIC in fact as many as you like up to the maximum line length of 255 characters As usual statements should be sep...

Page 87: ...o the direct command prompt Ready whenever it encounters an END even if it s the first line of the program The direct or immediate mode allows you to enter a number of program steps by separating the commands with a colon However once you execute the line press the ENTER key the instructions are processed and the line is discarded You can always re run it using the copy cursor feature assuming it ...

Page 88: ...uter automatically adds the question mark when it wants you to respond with an input of data Answer the question using only numbers not letters currency signs or commas and enter your answer with the ENTER key Add line 5 below by simply typing after the end of the above operation when the Ready prompt reappears 5 CLS RUN again to wipe the screen If your first answer was less than 10000 make this r...

Page 89: ... in which BASIC allows you to build programs as you go along is its most convenient feature Purists will argue that this convenience leads to sloppy and unstructured programming techniques with programs being tacked together as ideas occur realists may consider it s the best way to retain the interest of the student who has the means of checking progress in easy stages Take our example program aga...

Page 90: ... instruct the computer to clear it out using a NEW command or you issue a full reset command by holding down the CTRL SHIFT and ESC keys simultaneously Thus there should be no need to provide a safety net for those who inadvertently reset the machine The action of clearing out the current program memory is very deliberate and very permanent Save anything on to the cassette if you are in any doubt ...

Page 91: ...AILY RATE a day 70 FOR n 1 to 5000 NEXT n GOTO 5 run Note a space has been added after fiver or the name would be butted hard up against fiver Try it if you don t believe us The semicolon at the end of PRINT or INPUT statement supresses the computer s desire to start a new line at the end of each such statement unless told otherwise We can also work in the subject of integers by adding line 61 Jus...

Page 92: ...ble with the same name as the integer variable the difference being identified by the symbol Also see how the computer display wraps lines that are too long to fit on a single line it happens in all three modes Use MODE 2for writing long programs since it s much easier to read programs that are not for ever running over the ends of the lines To get to MODE 2 type MODE 2 And to produce black on whi...

Page 93: ... turning the line from a command into a REMark 10 CLS 20 INPUT What is your name NAME 30 INPUT WHAT IS YOUR SALARY SALARY 40 IF SALARY 10000 THEN GOT0 50 ELSE 60 50 PRINT ASK FOR A PAY RISE END 60 PRINT ASK FOR A BIGGER CAR 70 IF SALARY 30000 THEN PRINT and get a good accountant 80 IF SALARY 25000 THEN PRINT and lend me a fiver NAME 90 DAILY RATE SALARY 365 PRINT that s DAILY RATE a day 100 INTEGE...

Page 94: ...eady message further down the screen 120 And then run the program again or suppress Ready altogether bv typing 120 GOTO 120 Once you run this version the only way out is to ESC ape Remember that is a quick means of typing PRINT Now LIST to check the results so far 10 CLS 15 MODE 1 20 INPUT What is your name NAME 25 PRINT PRINT 30 INPUT WHAT IS YOUR SALARY SALARY 40 IF SALARY 10000 THEN GOT0 50 ELS...

Page 95: ...ates on the screen planners listed in Appendix 6 If you want all the questions and comments to appear on the same line then you should precede each LOCATE by a CLS to avoid confusion with the remains of the last entry Note that the co ordinates of LOCATE may be variables themselves generated from within the program We ve worn the salary program out by now so the next example will be based on a dif...

Page 96: ... the colour of the border so that it is set to the value of AMSTRAD by line 30 List the program again 1 MODE 1 10 AMSTRAD 0 20 PRINT AMSTRAD CPC464 colour personal computer 30 AMSTRAD AMSTRAD 1 34 BORDER AMSTRAD 35 LOCATE 1 20 PRINT AMSTRAD LOCATE 1 AMSTRAD 36 FOR n l TO 500 NEXT 40 IF AMSTRAD 10 GOTO 20 run And no doubt you all want to see all the colours available on the CPC464 so alter line 40 ...

Page 97: ...is would be to assign a variable to each card and then set the variable according to the card s location say 1 to signify that it has been dealt and 0 to signify that it is still in the deck Evidently this will involve 52 separate variables unless you re playing with a fixed deck and you have to remember which variable refers to which card this is where the array comes in useful Firstly we need to...

Page 98: ...his is achieved by simply adding further reference numbers to the variable For example a 10x10x10 array or matrix can be set up by the command DIM ARRAY 10 10 10 This technique is useful for dividing data into smaller subsets within a large group In our example we could split the pack into four suits of thirteen cards which can then be accessed separately by using the format DIM PACK 4 13 Now if w...

Page 99: ...ain information which is to be PRINTed when read numeric values in a DATA statement can for example be read into a SOUND command Type in 10 FOR n 1 TO 30 20 READ s 30 SOUND 1 s 40 5 40 NEXT n 50 DATA 100 90 100 110 120 110 100 0 60 DATA 130 120 110 0 120 110 100 0 70 DATA 100 90 100 110 120 110 100 0 80 DATA 130 0 100 0 120 150 If you cannot hear anything adjust the volume control at the right han...

Page 100: ...ES CACES 1 360 REM INPUT OPTION TWIST T OR STICK S 370 X INKEY IF X S AND X T THEN 370 380 IF X S THEN 560 390 LOCATE 3 YC 5 400 YC YC 1 410 GOSUB 740 420 S S F S S F 430 IF F 11 THEN ACES ACES l 440 REM CHECK SCORE AND ACES 450 IF S 22 THEN 370 460 IF ACES 0 THEN 500 470 ACES ACES 1 480 S S 10 490 GOT0 450 500 LOCATE 12 19 510 PRINT YOU RE BUST 520 PRINT PRINT ANOTHER GAME Y N 530 X INKEY IF X Y ...

Page 101: ...s the computer s ability to handle logical operations in applications like the conditional IF THEN sequence To do this the logical operators treat the values to which they are applied as bit patterns bitwise and operate on the individual bits The description and use is entirely well er logical but it is notoriously difficult to describe logic in simple terms without the precision of the concise de...

Page 102: ...PRINT 10 AND 12 Results in 8 PRINT 10 AND 1000 Results in 8 again ...

Page 103: ...r 1111101010 And in the program example 10 CLS 20 INPUT The number of month month 30 IF month 12 OR month 1 OR month 2 GOTO 50 40 CLS GOTO 10 50 PRINT It must be winter 10 CLS 20 INPUT The number of the month month 30 IF NOT month 6 OR month 7 OR OR month 8 GOTO 50 40 CLS GOTO 10 50 PRINT It can t be summer The final major feature to consider is the fact that you can add together a number of logic...

Page 104: ...ions in lines 60 and 70 will be displayed beneath Finally XOR exclusive OR produces a true result as long as both arguments are different The following summarises all these features in what is known as a truth table which is a convenient way of illustrating what happens in a bitwise logical operation Argument A 1 0 1 0 Argument B 0 1 1 0 AND result 0 0 1 0 OR result 1 1 1 0 XOR result 1 1 0 0 ...

Page 105: ...n displayed in the special computer display style typeface further examples and a concise description of the keyword and its use can be found by reference to the appropriate entry in chapter 8 5 1 1 Colour Selection Black ie no colour or illumination is considered as a colour for the purposes of all following descriptions that describe the attributes of the colours and the various commands associa...

Page 106: ...ide useful extensions to the major BASIC graphics commands With the transparent option you can either ignore the paper colour and overwrite the graphics or completely overwrite the background This brief program illustrates the effect available CTRL SHIFT ESC 10 MODE 1 20 INK 2 19 30 DRAW 200 200 2 40 LOCATE 1 21 50 PRINT 1 NORMAL 60 PRINT CHR 22 CHR 1 70 ORIGIN 0 0 80 DRAW 500 200 2 90 LOCATE 12 1...

Page 107: ...d graphics windows the same effect as a CLS and CLG command but does not affect the contents of the program memory Mode changes may be invoked from BASIC programs or they may be entered using the direct commands 5 2 1 MODE 0 is the multicolour graphics display 16 of the 27 colours available can be displayed simultaneously The display consists of 160 pixels in each horizontal row and 200 in each ve...

Page 108: ...200 SIN a c 3 REM DRAW THE LINE 91 IF INKEYS THEN 20 100 NEXT REM BACK TO 60 UNLESS INTERRUPTED AT 91 110 GOTO 20 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 sophisticat...

Page 109: ...RAW x 300 DRAW 0 600 160 MOVE 0 0 170 DRAW x 300 DRAW 0 600 180 a INKEY 190 IF a THEN THEN 30 REM INTERRUPT THE LOOP BY PRESSING ANY KEY 200 NEXT x 210 GOT0 10 This and the preceding program illustrate simple mathematical concepts in a colourful and very visual way Both are basically doing some sums on randomly generated seed numbers to ensure that each pattern is different in some way and display...

Page 110: ... and set the border to bright blue press ESC twice then change line 15 to 15 BORDER 2 RUN the program and the flashing stops To change the colour of the curve and the background you must change the colour of the INK in lines 30 and 40 When you LIST the program it should then look like 10 REM DRAW SINE WAVE 15 BORDER 2 20 MODE 2 30 INK 1 2 40 INK 0 20 50 CLS 60 DEG 70 ORIGIN 0 200 80 FOR n 0 TO 720...

Page 111: ... specified 100 100 The GRAPHICS CURSOR is an invisible concept that indicates the point at which the next graphics operation will occur To find out where it is you must use the functions XPOS and YPOS Type in PRINT XPOS The answer is 100 which is the same for YPOS at this point Note that if the text goes down to the bottom of the screen and causes the display to be moved up scrolled up the graphic...

Page 112: ... Calculating 105 IF p 3 THEN ORIGIN 0 50 0 640 0 400 ELSE ORIGIN 0 0 0 640 0 400 110 DIM cx 5 cy 5 r 5 lc 5 120 DIM np 5 130 DIM px 5 81 py 5 81 140 st l 150 cx l 320 cy l 200 r l 80 160 FOR st l TO 4 170 r st l r st 2 180 NEXT st 190 FOR st l TO 5 200 lc st 0 np st 0 210 np st np st l 220 px st np st r st SIN lc st 230 py st np st r st COS Lc st 240 lc st lc st 360 r st 245 IF lc st MOD 60 0 THEN...

Page 113: ... that it is still thinking to itself and confirm that the program is still running The subroutines called by lines 300 320 flash the different coloured inks at the rates determined by the E V E R Y command If you want to slow down the flashing E D I T lines 300 320 to read 300 EVERY 250 l GOSUB 510 310 EVERY 150 2 GOSUB 550 320 EVERY 50 3 GOSUB 590 To see what you have done look up the E V E R Y c...

Page 114: ...you get lost in some invisible combinations of PEN and PAPER The following program draws a series of windows across the screen and illustrates two major points 5 MODE 0 10 FOR n 0 TO 7 20 WINDOW n n l n 6 n l n 6 30 PAPER n n 4 40 CLS n 50 FOR c l c l TO 200 NEXT TO 200 NEXT 60 NEXT The first point is that each new screen overwrites the one before and the second is to emphasise that the messages a...

Page 115: ...he philosophy behind the timing structures Subjects covered in this chapter Tone periods Sound command Enveloping Queuing and synchronisation If all you want to do is to make the computer bleep then type PRINT CHR 7 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 subjec...

Page 116: ...riod of 1000 would result in a 125 Hz tone and a tone period of 125 would result in a 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 The range of tone periods available is extensiv...

Page 117: ...d a decrease in volume at the end of the note called the decay The different forms of attack and decay for each type of musical instrument can be simulated on the computer by adjusting the volume characteristics within a volume envelope 6 4 Length of the note The length of note is a basic feature of any musical construction the unit of musical note length is the crotchet and there are minims semiq...

Page 118: ...TO DO DRAW THIS PAGE ...

Page 119: ...OUND channel has a queue of SOUND s to play There is space in this queue for five separate SOUND commands one active and four waiting The operating system of the CPC464 can continue with other tasks while playing out the sound queue only returning when necessary to pick up more SOUND commands 6 8 Channel status The keyword SQ is used to determine the state of the channel that you wish to interroga...

Page 120: ... bit significant result the active bits specify the following commands DECIMAL BIT COMMAND 1 0 LSB send SOUND to channel A 2 1 send SOUND to channel B 4 2 send SOUND to channel C 8 3 rendezvous with channel A 16 4 rendezvous with channel B 32 5 rendezvous with channel C 64 6 hold 128 7 MSB flush LSB and MSB signify Least Significant Bit and Most Significant Bit in the table above integer entry exa...

Page 121: ...ue entered represents the duration in l 100ths second When equal to zero the duration is governed by the length of the volume envelope specified Where the duration is less than zero the positive value of this number gives the number of times the volume envelope specified should be repeated J Volume An integer value in the range 0 15 0 7 where no volume envelope is specified default if omitted 12 4...

Page 122: ...ore attempting to describe the shape to the computer using the numeric instruction sequence to sketch out your requirement on paper See example below Figure 3 Volume envelope example The shape must be plotted in numbers so that it can be formatted into a command statement To do this subdivide the shape into sections you may have up to 5 But in each section the shape must be a straight line Now div...

Page 123: ...e note s frequency sketch it as before and divide into sections and steps see example below Figure 4 Characteristics of a tone envelope The major difference between volume envelopes and tone envelopes is that tone envelopes have no effect on the duration of a note previously defined either in the SOUND command or in a volume envelope If the tone envelope finishes before the note then the final ton...

Page 124: ... 0 2 number of free spaces in the queue tested value 0 4 Bit 3 rendezvous with channel A showing at head Bit 4 rendezvous with channel B showing at head Bit 5 rendezvous with channel C showing at head Bit 6 hold at head of queue Bit 7 channel currently playing Bits 3 to 6 rendezvous and hold were described in the channel status section The only other facility of this test is to disable the ON SQ G...

Page 125: ...parameter channel status it is possible to flag a hold on a channel with a particular SOUND command The RELEASE command is simply to remove these holds The channel input is bit significant and when decoded gives the combination of channels to be released Release of a channel not held has no effect Bit 0 Channel A Bit 1 Channel B Bit 2 Channel C ...

Page 126: ...ould 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 A second joystick may be fitted if required into the socket provided in the base of the first JYl joystick The connections of this device are listed i...

Page 127: ...he AMSOFT JY1 the second joystick is identical to the first and plugs into the socket on the side of the first joystick No special wiring is required to allow use of the second joystick The 9 pin socket marked USER PORTS I O will accept standard joysticks that work with other personal computers athough these do not allow a second joystick to be fitted unless a special adaptor is used However you s...

Page 128: ...ly wrap around line endings if the output reaches the end of a line check the printer manual AMSTRAD BASIC will also wrap the output as directed by a WIDTH command The default value of printer width is 132 and may be set to a new value as required eg WIDTH 80 If set to the special value of 255 then AMSTRAD BASIC will not wrap the output and relies completely on the printer to check for line ending...

Page 129: ...er port on the CPC464 50 CPS print speed Plain paper operation Cable and ribbon supplied Dot graphics Tractor fed paper The DMP 1 is an impact dot matrix printer using plain paper with a maximum print speed of 50 characters per second The customised software in the DMP 1 includes dot graphics ability with the capability to print complete screen dumps The low cost versatility and features specifica...

Page 130: ... constant X Prefix for binary constant Separates statements typed on the same line Prefix for stream director Data types Strings may be from 0 to 255 characters long and are expressed as string expression Strings may be appended to one another using the operator as long as the resulting string expression is less than 255 characters long Numeric data can be either Integer or real Integer data is he...

Page 131: ... description are for the purposes of the description and should not be typed as part of the line enclose optional items enclose various expressions which are described in the subsequent description Quotes Only form part of the actual BASIC program structure are used to emphasise or highlight certain aspects of the description should not appear in any part of the syntax Function or Example entries ...

Page 132: ...320 COMMAND Invoke a subroutine after a given time period has elapsed The first integer expression indicates the period of the delay in units of 1 50 second and the second integer expression in range 0 3 indicates which of the four available delay timers should be used See also Chapter 10 Associated keywords EVERY REMAIN ASC ASC string expression PRINT ASC X 88 FUNCTION Gets the numeric value of t...

Page 133: ...not specified Where an existing program line is in danger of being overwritten BASIC inserts a star after the line number generated as a warning BIN BIN unsigned integer expression integer expression PRINT BIN 64 8 01000000 FUNCTION Produces a string of binary digits that represents the value of the unsigned integer expression filling with leading zeros to the number of digits instructed by the se...

Page 134: ...ociated keywords UNT CAT CAT COMMAND Causes BASIC to start reading the cassette and to display the names of all files found This does not affect the program currently in memory and so may be used to verify a program that has just been saved before altering the program memory The Command asks you to play the cassette and on finding a program responds FILENAME BlockNumber Flag Ok Flags indicate the ...

Page 135: ...ered on tape If the first character of the filename is a then it is removed from the filename and suppresses the usual messages generated by the cassette reading process CHAIN MERGE retains all current variables although User Functions and open files are discarded ON ERROR GOTO is turned off a RESTORE is implemented and the DEFINT DEFREAL DEFSTR settings are reset and all active FOR WHILE and GOSU...

Page 136: ...hics screen Associated keywords CLS ORIGIN CLOSEIN CLOSEIN CLOSEIN COMMAND Close the cassette input file Commands such as NEW and CHAIN MERGE will abandon any open files Associated keywords OPENIN CLOSEOUT CLOSEOUT CLOSEOUT CLOSEOUT COMMAND Close the output cassette file Associated keywords OPENOUT CLOSEIN ...

Page 137: ...s may be entered COS COS numeric expression COS 34 0 848570274 and deg cos 34 0 829037573 FUNCTION Calculates the COSINE of a given value The function defaults to radian measure unless specifically instructed otherwise by the DEG command Note in the above example the use of shortform for PRINT and the use of lowercase entry for keywords a feature fully compatible with AMSTBAD BASIC Associatedkeywo...

Page 138: ...M ProoferSurname 5 40 FOR n l to 5 50 READ Proofer n 60 READ ProoferSurname n 65 PRINT Proofer n ProoferSurname n 70 DATA Bob Smith Dicky Jones Malcolm Green Alan Brown Ivor Curry 90 NEXT COMMAND Declares constant data for use within a program One of the most widely used features of BASIC that lumps constant data in DATA statements for retrieval as required The data type must be consistent with th...

Page 139: ...out the program Variable types must be consistent and the DEF FuNction command should be written in part of the program outside the execution loop DEFINT DEFSTR DEFREAL DEF type range s of letters DEFINT I N DEFSTR A W 2 DEFREAL COMMAND Define default variable types where type is integer real or string The variable will be set according to the first letter of the variable s name which may be eithe...

Page 140: ... X2 STEP 2 70 DI PLOT 320 0 1 MOVE X 2 Y PRINT MOVE X Y EI 80 NEXT 90 GOTO 40 100 MOVE 320 0 110 DRAW X 8 Y 16 0 120 RETURN COMMAND Disable interrupts other than the Break interrupt until re enabled explicitly by EI or implicitly by the RETURN at the end of an interrupt GOSUB routine Used when the program wishes to get on literally without interruption for example when two routines within a progra...

Page 141: ...tistorey car park and the subsequent numbers the number of parking bays etc A full understanding of arrays is a major element in advanced BASIC programming The size of an array is limited only by available memory and the programmers ability to keep track of the entries in the dimension list Associated keywords ERASE DRAW DRAW x co ordinate y co ordinate masked ink DRAW 200 200 13 COMMAND Draws a l...

Page 142: ...eturns to the direct mode Sound queues will continue until empty Associated keywords STOP ENT ENT envelope number envelope sections 10 ENT 1 100 2 20 20 SOUND 1 100 1000 4 0 1 COMMAND While a sound is being generated it is possible to vary its tone A tone envelope defines how the tone is to be varied See Chapter 6 and Appendix VII for a fuller description of sound and its operation The envelope nu...

Page 143: ... sound A tone envelope has no effect on the duration of the sound If there are steps remaining in the tone envelope when the sound finishes they are simply abandoned A repeating tone envelope will be restarted each time it finishes until the sound terminates The expressions in the tone envelope are evaluated when the command is executed and the results stored away for future use Using the tone env...

Page 144: ...lope period is the value to be set into the envelope period registers registers 13 14 octal Hardware envelope settings do not have an associated pause time so the next section of the envelope is immediately executed It is advisable therefore that the next step should have a pause of a suitable length If there is no next step then a pause of 2 seconds is taken The SOUND command sets the initial vol...

Page 145: ...er use Associated keywords DIM ERR ERL ERR ERL 10 CLS 20 ON ERROR GOTO 1000 30 DATA SALLY EMMA JOANNE HELEN GEMMA 40 READ A 50 PRINT A 60 GOT0 40 70 REM error detection starts here 1000 IF ERR 4 THEN PRINT I have spotted a DATA EXHAUSTED error 1010 IF ERL 70 AND ERL 20 THEN PRINT in lines 30 60 1020 END VARIABLES These variables are used in error handling subroutines to discover the error number a...

Page 146: ...RY 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 in the range 0 3 each of which may have a subroutine associated with it See also Chapter 10 Associated keywords AFTER REMAIN EXP EXP numeric expression PRINT EXP 6 876 968 743625 FUNCTION Calculates E to the power given in numeric ex...

Page 147: ...NEXT WHILE FRE FRE numeric expression FRE string expression PRINT FRE 0 PRINT FRE FUNCTION Establishes how much meinory remains unused by BASIC The form FRE forces a garbage collection before returning a value for available space GOSUB GOSUB line number GOSUB 210 COMMAND Call a BASIC subroutine by branching to the specified line number See RETURN Associated keywords RETURN GOTO GOTO line number GO...

Page 148: ...turn to the previous memory capacity by issuing the command MEMORY mm Associated keywords FRE MEMORY IF IF IF logical expression THEN option part ELSE option part IF logical expression GOTO line number ELSE option part IF A B THEN A C ELSE A D IF A B GOT0 1000 ELSE 300 COMMAND A very widely used command that is used to conditionally determine branch points in a program The logical part is evaluate...

Page 149: ...f shift is not required according to one of the interpretation options The above example detects when SHIFT and V are pressed together Shift and control are identified according to Value returned SHIFT CTRL KEY 1 UP 0 UP UP DOWN 32 DOWN UP DOWN 128 UP DOWN DOWN 160 DOWN DOWN DOWN Associated keywords INPUT INKEY INKEY INKEY 10 CLS 20 PRINT Are you clever y or n 30 a INKEY IF a GOTO 30 40 IF a N OR ...

Page 150: ...then BASIC will prompt with Redo from start and the original prompt text that you entered All responses must be terminated with an ENTER The semicolon immediately after the stream expression has the effect of suppressing the carriage return typed at the end of the line being entered leaving the cursor at the end of the text just entered Where a cassette stream is indicated no prompt is generated I...

Page 151: ... MID LEFT RIGHT INT INT numeric expression PRINT INT 1 995 2 FUNCTION Rounds the number to the nearest lower integer removing any fractional part The same as FIX for positive numbers but returns one less than FIX for negative numbers not already integers Associated keywords CINT FIX ROUND JOY JOY integer expression 10 IF JOY 0 AND 8 THEN GOT0 100 FUNCTION The JOY function reads a bit significant r...

Page 152: ... DEF 46 1 63 COMMAND Associates the value as defined in Appendix III to a key on the keyboard The above example converts the N key to print the question mark character Character number 63 To return the key to its normal function KEY DEF 46 1 110 where the character number 110 is the lower case n Associated keywords KEY LEFT LEFT string expression integer expression 10 CLS 20 A AMSTRAD 30 B LEFT A ...

Page 153: ... an entire line from the stream indicated The first optional semicolon suppresses the echo of carriage return line feed The default stream expression is as always 0 screen Associatedkeywords READ INPUT INKEY INPUT LIST LIST line number range strea m expression LIST 100 1000 1 COMMAND List program lines to the given stream 0 is the default screen 8 is the printer LISTing may be suspended by pressin...

Page 154: ...ATE stream expression l x coord y coord 10 MODE 1 20 LOCATE 20 12 30 PRINT CHRS 249 COMMAND Moves the text cursor at the stream indicated to the position specified by the x and y co ordinates which are relative to the origin of the stream WINDOW Stream 0 is the default stream Associated keywords WINDOW LOG LOG numeric expression LOG 9999 9 21024037 FUNCTION Calculates the natural logarithm of nume...

Page 155: ... case Useful for processing input where the answers may come in mixed upper lower case Associated keywords UPPER MAX MAX list of numeric expression 10 n 66 20 PRINT MAX 1 n 3 6 4 3 FUNCTION Extracts the largest value from the list of numeric expressions Associated keywords MIN MEMORY MEMORY address expression MEMORY 20AA COMMAND Beset BASIC memory parameters to change the amount of memory availabl...

Page 156: ...is turned off a RESTORE is implemented and the DEFINT DEFREAL DEFSTR settings are reset Protected files will not merge Associatedkeywords LOAD CHAIN CHAIN MERGE MID MID string integer expression integer expression A AMSTRAD PRINT MID A 2 4 MSTR A AMSTRAD b MID A 2 4 PRINTb MSTR COMMAND and FUNCTION MID specifies part of a string a sub string which can be used either as the destination of an assign...

Page 157: ...y the absolute co ordinates YPOS and XPOS are the corresponding functions to establish the current graphics cursor position Associated keywords MOVER PLOT PLOTR DRAW DRAWR ORIGIN TEST TESTR XPOS YPOS MOVER MOVER x offset y offset MOVER 34 34 COMMAND To move the graphics cursor to a position relative to the current co ordinates YPOS and XPOS are the corresponding functions to establish the current ...

Page 158: ...e or GOTO the statement as directed by the result of the integer expression If the result is 1 then the first line number in the list is chosen if 2 then the second etc In the above line 10 when DAY 1 the subroutine at line 100 would be visited DAY 2 would cause a branch to line 200 and so on Associated keywords GOTO GOSUB ON BREAK GOSUB ON BREAK GOSUB line number 10 ON BREAK GOSUB 40 20 PRINT pro...

Page 159: ...N ERROR GOT0 ERROR GOT0 80 20 CLS 30 PRINT if there is an error I would 40 PRINT like the program listed so that 50 PRINT I can see where I went wrong 60 FOR t l TO 4000 NEXT 70 GOTO 200 80 CLS PRINT THERE IS AN ERROR IN LINE ERL PRINT 90 LIST COMMAND Go to a specified line number in the program on detecting an error In this example an error will be found in line 70 Associated keywords ERR ERL RES...

Page 160: ...eady for processing Associated keywords CLOSEIN OPENOUT OPENOUT OPENOUT filename OPENOUT FACTS COMMAND Opens an output file onto cassette for use with the current program in the computer s memory If the first character in the file name is then the displayed cassette processing messages are suppressed The program creates the first block of data in the file with the given name Each block consists of...

Page 161: ...el addressing technique employed The ORIGIN is the point with co ordinates 0 0 co ordinates grow up and right If any of the window edges are specified to a position that is off the screen they are assumed to represent the furthest visible position in the given direction Associated keywords WINDOW OUT OUT port number integer expression OUT F8F4 10 COMMAND Sends the value in the integer expression w...

Page 162: ...lected For PAPER MODE colour correlation see Table 2 page F3 4 Associated keywords INK WINDOW PEN PEEK PEEK address expression 10 MODE 2 20 INK 1 0 INK 0 12 BORDER 12 30 INPUT Start address for examination first 40 INPUT End address for examination last 50 FOR n first TO last 60 VALUE HEX PEEK n 2 70 PRINT VALUE 80 PRINT at HEX n 4 90 NEXT FUNCTION Examine the contents of a memory location The abo...

Page 163: ... BORDER 9 70 FOR N 1 TO 200 80 ORIGIN 420 0 90 DRAW 0 200 100 REM draw angles from vanishing point 110 DRAW 30 N SIN N PI 4 SIN PI 2 N SIN N 120 NEXT 130 MOVE 0 200 140 DRAWR 0 50 150 DRAWR 40 0 160 WINDOW 1 40 1 10 170 PRINT Now you can finish the you can finish the Hangman program FUNCTION The value of the ratio between the circumference and the diameter of a circle It is used extensively in gra...

Page 164: ...ine of the circle by repeated running around the perimeter Remember that this program has not reset the RAD ian mode of angular calculation so the angle in each step is considerably more than one degree Enter the command 25 DEG and run again Associated keywords DRAW DRAWR PLOT PLOTR MOVE MOVER ORIGIN TEST TESTR XPOS YPOS PLOTR PLOTR x co ordinate y co ordinate masked ink 5 DEG 10 MODE 2 PRINT Ente...

Page 165: ...stream expression and omitting it will result in a Syntax error message Screen Returns the current X co ordinate of the text cursor relative to the current window origin The top left corner is represented as 1 1 Printer Returns the carriage position where 1 is the left margin All characters with ASCII reference numbers greater than lF 31 are included Cassette output stream As for the printer Assoc...

Page 166: ...er generator either to a given value or to a value entered by the operator RANDOMIZE TIME will produce a sequence that will be difficult to repeat Associated keywords RND READ READ list of variable 10 FOR X 1 TO 4 20 READ N 30 PRINT N 40 DATA ADAM DANNY JAMIE RICHARD 50 NEXT COMMAND READ fetches data from the list of constants supplied in the corresponding DATA statements and assigns it to variabl...

Page 167: ...OFT 20 REM Copyright AMSOFT 1984 COMMAND Used to place REM arks or REM inders in programs without affecting the program operation in any way The line separator is also ignored everything from the REM to the line end is ignored A single quote character in a line not part of a string expression is equivalent to REM other than in a DATA command where it is treated as part of an unquoted string REMAIN...

Page 168: ...number RESTORE 300 10 FOR N 1 TO 6 20 READ A 30 PRINT A 40 DATA restored data can be read again 50 NEXT 60 PRINT 70 RESTORE 80 GOT0 10 COMMAND Restores the position of the reading pointer back to the beginning of the DATA statement specified in the optional line number Omitting line number restores the position of the pointer back to the beginning of the first DATA statement Associated keywords RE...

Page 169: ...er expression from the right of the string expression If the string expression is shorter than the required length the whole string expression is returned Associated keywords MID LEFT RND RND numeric expression 10 RANDOMIZE 23 20 PRINT RND FUNCTION Fetches a random number which may be the next in sequence a repeat of the last one or the first in a new sequence The RANDOMIZ E command in the above p...

Page 170: ...COME COMMAND Load a program from cassette and start executing it If the string expression is empty BASIC attempts to load and execute the first file it encounters on the tape If the first character of the string expression is then the displayed cassette processing messages are suppressed NB BASIC effectively executes an implied NEW immediately a filename is read on the tape Associated keywords LOA...

Page 171: ...10 INPUT What s your current Bank Balance CASH 20 IF SGN CASH 1 GOTO 30 ELSE 40 30 PRINT Oh dear oh dear END 40 PRINT You ve got more money than me FUNCTION Determines the sign of the numeric expression Returns 1 if numeric expression is less than 0 returns 0 if numeric expression 0 and returns 1 if numeric expression is greater than zero Associated keywords ABS SIN SIN numeric expression PRINT SI...

Page 172: ...D INK integer expression integer expression 5 INK 0 9 12 INK 1 0 26 10 BORDER 12 9 20 SPEED INK 50 20 COMMAND The INK and BORDER commands allow two colours to be associated with each Ink in which case the INK alternates between the two colours The first integer expression specifies the time for the first INK specified to be used and the second integer expression sets the time for the second INK Ti...

Page 173: ...d will allow the user to redefine the particular attributes of a given key Associated keywords KEYDEF SPEED WRITE SPEED WRITE integer expression SPEED WRITE 1 COMMAND The cassette can be witten at either 2000 baud where integer expression is 1 or the default of 1000 baud where the integer expression is 0 When loading a file from tape the CPC464 automatically establishes the correct reading speed f...

Page 174: ... of free entries in the queue 3 4 5 indicate the Rendezvous state at the head of the queue if any 6 is set if the head of the queue is held 7 is set if the channel is currently active Associated keywords SOUND ON SQ GOSUB SQR SQR numeric expression PRINT SQR 9 3 FUNCTION Returns the square root of numeric expression Associated keywords PRINT STOP STOP 300 IF n 0 THEN STOP COMMAND To stop execution...

Page 175: ...OL 93 80 40 20 10 8 4 2 1 30 FOR n 1 TO 2000 40 PRINT CHR 93 50 NEXT 60 GOT0 60 COMMAND The SYMBOL command redefines the representation of a given character that has first been specified in the 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 m...

Page 176: ...50 IF n 70 GOTO 60 ELSE 70 60 PRINT Hello GOTO 80 70 PRINT Farewell 80 NEXT 90 GOTO 20 COMMAND Text sent to a given stream may be redirected to be written at the graphics cursor position This allows text and symbols to be mixed with graphics The stream expression defaults to 0 if omitted The top left of the character cell is tagged to the graphics cursor and non printing control characters will di...

Page 177: ... of the ink currently at the specified graphics screen location Associated keywords TEST R MOV E MOVER PLOT PLOTR DRAW DRAWR TESTR TESTR x offset y offset TESTR 5 5 FUNCTION Moves the graphics cursor to the specified location and reports the value of the ink there Associated keywords TEST MOVE MOVER PLOT PLOTR DRAW DRAWR TIME TIME 10 DATUM INT TIME 300 20 TICKER TIME 300 DATUM 30 PRINT TICKER 40 G...

Page 178: ...er in the range 0 65535 Returns an integer value in the range 32768 32767 Associatedkeywords INT FIX CINT ROUND UPPER UPPER string expression PRINT UPPER amstrad AMSTRAD FUNCTION Returns a new string expression the same as the input string expression but in which all lower case characters are converted to upper case Associated keywords LOWER VAL VAL string expression 10 A 7 is my lucky numbe r 20 ...

Page 179: ...operation until a given I O port returns a particular value in the range 0 255 BASIC loops whilst reading the I O port The value read is Exclusive ORed with the inversion and then ANDed with the mask until a non zero result occurs BASIC will get stuck in a WAIT loop if the required condition does not occur If you type in the above example you will have to fully reset the computer to escape Associa...

Page 180: ...ILE WEND loop repeatedly executes a body of program until a given condition is true The illustration here uses the WHILE WEND loop to demonstrate the elegance of programs constructed using this approach The body of the features of a variety of different clocks can now be added The WEND command terminates the WHILE loop Associated keywords WHILE WHILE WHILE logical expression WHILE DAY 0 see exampl...

Page 181: ...ND Sets a text window for a given screen stream Associated keywords ORIGIN WINDOW SWAP WINDOW SWAP stream expression stream expression WINDOW SWAP 0 2 COMMAND Exchanges the text windows For example BASIC messages sent to stream O may be swapped with another window to highlight aspects of program development and operation Associatedkeywords WINDOW PEN PAPER TAG WRITE WRITE stream expression write l...

Page 182: ...ishes the vertical position of the graphics cursor Associated keywords XPOS MOVE M OVER ORIGIN ZONE ZONE integer expression 10 PRINT 1 2 3 20 ZONE 19 30 PRINT 4 5 6 COMMAND Changes the width of the Print Zone used in PRINT from the default value of 13 to a new value in the range 1 255 Reset by NEW LOAD CHAIN and RUN file n ame commands Associated keywords PRINT WIDTH ...

Page 183: ... comma following the print item will send the printed item to start at the next print ZONE default to 13 A semi colon simply separates the expressions SPC integer expression prints the given number of spaces defaulting to zero if the numeric expression is less than 1 SPC does not require to be terminated by a comma or semi colon a semi colon is assumed at all times TAB integer expression prints sp...

Page 184: ...ng sign Prints if negative otherwise blank 2 2 Leading asterisk 1 2 Floating dollar sign is placed in front of the leading digit 2 3 Asterisk fill and floating dollar sign 1 1 Use comma every three digits left of decimal point only 0 4 Exponential format Number is aligned so leading digit is zero STRING First character only spaces Number of spaces specified plus a leading and trailing space charac...

Page 185: ...tmost column of the next line up c If the cursor is above the top edge then the window is rolled down a line and the cursor is set to the top line of the window d If the cursor is below the bottom edge then the window is rolled up a line and the cursor is set to the bottom line of the window The tests and operations are done in the order given The illegal cursor positions may be zero or negative w...

Page 186: ...ound Bleeper Note that this flushes the sound queues 08 8 BS Move cursor back one character 09 9 TAB Move cursor forward one character 0A 10 LF Move cursor down one line 0B 11 VT Move cursor up one line 0C 12 FF Clear text window and move cursor to top left corner Equivalent to a CLS command 0D 13 CR Move cursor to left edge of window on current line 0E 14 SO 0 15 Set Paper Ink Parameter taken MOD...

Page 187: ... Character Equivalent to a SYMBOL command Takes nine parameters The first parameter specifies which character s matrix to set The next eight specify the matrix The most significant bit of the first byte corresponds to the top left hand pixel of the character cell the least significant bit of the last byte corresponds to the bottom right hand pixel of the character cell 1A 26 SUB 1 80 1 80 1 25 1 2...

Page 188: ...r from the input to the output It primarily interfaces the hardware with the BASIC interpreter for example the ink flashing function where the BASIC passes the parameters and the OS gets on with the task with one part determining what is required and the other part determining the timing of these events The machine operating system is generally referred to as the firmware and comprises the machine...

Page 189: ...immunity from the effects mentioned above for the timer interrupt s structure When a sound queue s interrupt is enabled it will immediately interrupt if the sound queue for that channel is not full otherwise it will interrupt when the next sound starts and there is room for more in the queue The action of interrupting disables the event so the subroutine must re enable it if further interrupts are...

Page 190: ...e display and clocking the processor Where a function in the hardware is related to time this can be traced back to the quartz master clock The software implementation is the AFTER and EVERY command which in keeping with the user friendly approach of AMSTRAD BASIC do precisely what they say eg AFTER the time you have preset in the command line the program will divert to the designated subroutine a...

Page 191: ...rogram Lines 50 80 using independant cursor positioning from that used by the interrupt subroutines AFTER the time you have preset in the command line the program diverts to the designated subroutine and performs the task defined therein 10 2 EVERY The EVERY command allows a BASIC program to arrange for subroutines to be called at regular intervals Four delay timers are available each of which may...

Page 192: ... X 1 70 WEND 80 LOCATE 1 20 END 100 DI PEN P100 LOCATE 1 2 PRINT peripherals EI 105 IF P100 0 THEN P100 1 ELSE P100 0 110 RETURN 200 PEN P200 LOCATE 1 3 PRINT and software 205 IF P200 2 THEN P200 3 ELSE P200 2 210 RETURN NOTE the use of DI and EI commands which disable and enable timer and sound interrupts whilst the commands between them are executed This has the effect of delaying the higher pri...

Page 193: ...roduce specifically designed characters and shapes on the screen The hardware actually directs the beam of electrons at the electro luminescent surface on the inside of the screen of the TV tube to make it light up the software adds order and intelligence by telling the hardware when and how to perform It adds timing control and sequencing to produce the effect of a spaceship taking off or somethi...

Page 194: ...e a program that draws graphics patterns on the screen may call for many thousands of simple repetitive calculations the difference between 0 05 second and 0 075 of a second adds up to a considerable difference in performance You will frequently hear the term machine code being used Machine code is the raw form of instruction code that can be passed to the processor It takes less time to work out ...

Page 195: ...program from cassette and so its major advantage is one of sheer convenience A ROM cannot be used to store information to be taken out and stored or transported to another computer in the same way that the cassette Datacorder does Expansion is the means to ensure that your computer can make the most of future developments in software and peripherals The CPC464 system has a very complete and fully ...

Page 196: ...50 times each second It can be done but only by machines that cost a few thousand times more than a home computer at least for the time being Until the cost of high speed memory falls dramatically it will eventually small computers have to make do with a relatively small amount of memory available to control the screen display which results in lower resolution and jerkier movements Thoughtful hard...

Page 197: ...hich case you will be able to type random words press ENTER and carry on typing as if the system were operating an electronic piece of paper in an electronic typewriter But to do this you must first have loaded a wordprocessor program into the machine s memory using the datacassette input A computer seems to combine several items of equipment that have become familiar around the home and office th...

Page 198: ... in a computer s memory By means of its address a particular memory location can be selected so that its contents can be found and read in the case of RAM both read and written back after alteration Adventure game A cult with some and a bore to others A text based computer game in which the user playing is invited to participate in a series of pseudo random events based on trying to find a way aro...

Page 199: ...nd gobble up the unwary figures under the control of the user have to avoid all manner of unpleasant deaths Fun and generally good for the reflexes but of little educational benefit for the computer student Architecture The plan relationship of the databus peripheral and CPU handling aspects of a microcomputer Not a subject that will be concerning readers of this glossary yet Argument An independe...

Page 200: ...in almost all home computers BASIC was specifically designed to be easy to learn and simple to use since it allows for programs to be glued together and tested at any point in their development as opposed to compilers types where the complete program must be run before any aspect can be properly tested Baud A bit per second the unit for measuring the rate at which digital data is transmitted in se...

Page 201: ...or a printer Bug A problem on a scale ranging from an unexpected feature based on some obscure aspect of the use of a program eg if you press four keys at once the screen changes colour to a sequence that completely and irrevokably crashes a computer program and wipes the memory clean of all data Bus A group of connections either within the computer or connecting it to the outside world that carri...

Page 202: ...on of some of the dots See Appendix 11 Character set All the letters numbers and symbols available on a computer or printer The fact that a character exists on a computer does not imply it is accessible on any printer Character string A piece of variable data comprising a sequence of characters that can be stored or manipulated as a single unit e g a word or a collection of words Chip An misleadin...

Page 203: ...tions to the computer and causes them to be obeyed in a microcomputer the CPU is the microprocesor device itself Cursor A movable marker indicating where the next character is to appear on the screen Cursor control keys Keys that move the Cursor around the screen and are frequently used to control the direction of action in arcade games indicated by arrows printed on the top Daisy wheel printer A ...

Page 204: ...housed at all times in a square protective envelope or plastic box with access for the reading head provided by a window in the case Also see Floppy disk and Winchester Disk drive The unit that records information on the magnetisable surface of a spinning disk and reads recovers information recorded on it Documentation The manuals that are supplied with computers or software to explain how they ar...

Page 205: ...t may be electrically erased Expression A simple or complex formula used within a program to perform a calculation on data the expression will usually define the nature of the data it can handle Fifth generation computers Mainly large mainframe computers that are promised to arrive with the ability for self programming using the developments of artificial intelligence File A collection of informat...

Page 206: ...l equipment such as modems or printers Gate Logical gates permit the passage of data when certain conditions are fulfilled There are many different types OR AND XOR etc See the entry for Boolean algebra Graphics The part of the screen display of the computer that is not related to the display of characters eg drawing lines circles graphs etc In conjunction with an appropriate printer a paper print...

Page 207: ...H High level language Languages which are written in near literal form where the actual language does most of the work of interpreting Slower than machine code orientated programs but far simpler to understand like BASIC IEM One of the standard Interfaces for connecting devices to a microcomputer Similar to but not wholly compatible with the Centronics parallel interface in many respects Informati...

Page 208: ...en the terminal is off line Interactive Usually a reference to programs where the hardware computer prompts the user to provide various types of input ranging from controlling the spaceship in an arcade game to answering questions in educational programs The action of the user has an effect inreal time on the behaviour of the program Interface The way in and out of a computer both in electrical an...

Page 209: ...Significant Bit LSB is the bit at the extreme right hand end of the expression Light Pen Another alternative input method using a pen or wand Line number BASIC and some other languages use programs that are arranged in line number order Lisp The acronym formed from LISt Processor language Another high level computer language Logic The electronic components that carry out the elementary logical ope...

Page 210: ...ory The computer s parking lot for information and data neatly arranged in logical rows with each item individually accessible Either known as RAM random access memory where information can be both stored and retrieved or ROM where the information may be read but not re written in another form Disks and tape are example of bulk memory althouth the term has evolved to mean the memory that is direct...

Page 211: ...a and information either by wiring or via MODEMs Nibble 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 The area on the keyboard where number keys are grouped ...

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: ...ding 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 Pascal A high level structured programming language that must be compiled before it will execute and therefore runs very quickly Generally the next language that the keen BASIC student will ...

Page 214: ... from a simple machine code routine to a complete applications program such as a wordprocessor Programming language The medium through which the program is written being comprised of rigid rules on the use of words numbers and the sequence in which they are implemented PROM Programmable Read Only Memory An integrated memory circuit that once written with data cannot be erased Also see EPROM Prompt...

Page 215: ...of the process that produced them Recursion The series of repeated steps also sometimes imprecisely described as reciprocation within a program or routine in which the result of each repeated cycle of events is related to the previous one Refresh To update information either on the screen of a VDU or in the memory Need not be a destructive process but merely reinforcing whatever was already presen...

Page 216: ... eg A program to derive a 12 hour display from the system s clock may be considered as a routine RS232C A specific standard for serial data communications interfaces Devices at both ends of the data link using an RS232 interface require to be configured to the particular conditions of the RS232 data standard used Compare this with the Centronix parallel interface where the interconnection is a rig...

Page 217: ...en word into machine readable instructions Speech synthesis 1 Generation of simulated speech using a combination of hardware and software Spreadsheet A program that allows rows and columns of numbers to be entered and arithmetically manipulated Changing one entry causes all the associated calculations to be rerun and produces an updated result Sprite A screen character that moves freely around the...

Page 218: ...letype typewriter output system Truncated A number or string that has been shortened by removal of leading or trailing characters Where intentional the process may involve rounding the value Where unintentional the extra characters are simply discarded to enable the number or string to fit the available space Truthtable The results of a logical operation are either true or false The computer inter...

Page 219: ...actual value may be made to vary during the execution of a program ...

Page 220: ... as to minimize the complexity of the communication Don t be mislead by the plain language used in computing it is not a literary subject but a precise science and apart from the syntax of the wording the structure of the communication is very straightforward and not in the least confusing or ambiguous Teachers of computing have not yet managed to make an art form out of trying to analyse the exac...

Page 221: ...d Computer programs written using BASIC have to follow rigid rules concerning the use of these words The syntax is precise and any attempt to communicate with the computer using literal or colloquial expressions plain language will result in the cold and clinical message Syntax error This is not as restrictive as it first appears since the language of BASIC the Syntax is primarily designed to mani...

Page 222: ... or no represented in binary notation as 1 and 0 The representation in Boolean logic is simply true and false there s no such thing as a maybe or perhaps The process of switching between these two distinct states is the essence of the term digital and is sometimes referred to as toggling In the world of nature most processes move gradually from one completely stable state to another in a smooth pr...

Page 223: ...e used equally well as long as there is consistency throughout The relationship between bits and decimal notation is simple to understand It s actually conventional to declare the maximum number of binary digits being used by adding leading zeros to make up the number to the full number of bits decimal 7 becomes 00111 binary using 5 bit notation In the binary system the figures may be considered m...

Page 224: ...and it is quite possible to become a proficient programmer without a complete understanding of binary Although an appreciation of the significance of binary will help you spot the many magic or significant numbers that inevitably crop up as you work through the science of computing It s worth spending some effort to acquire an understanding of binary and the various significant numbers 255 1024 et...

Page 225: ...fl D 14 1110 fl E 15 1111 F 16 10000 flflflfl 10 An 8 bit number 11010110 can be subdivided and then considered as two 4 bit numbers known as nibbles Hex D6 Throughout this guide a hex based number will be introduced by the symbol eg D6 and this is the number base most commonly used by programmers using assembly language techniques An assembly language program is the nearest most programmers get t...

Page 226: ...ges very simple concepts and ideas it just happens to perform these tasks at great speed millions of times per second and with a huge capacity to remember both the data that has been input and the intermediate results of the many thousands of very simple sums along the way to the result If you want to pursue the theory of your computer there are literally thousands of books available on the subjec...

Page 227: ...70 p 13 015 D CR CTRL M 63 077 3F 113 161 71 q 14 016 E SO CTRL N 64 100 40 114 162 72 r 15 017 F SI CTRL O 65 101 41 A 115 163 73 s 16 020 10 DLE CTRL P 66 102 42 B 116 164 74 t 17 021 11 DC1 CTRL Q 67 103 43 C 117 165 75 u 18 022 12 DC2 CTRL R 68 104 44 D 118 166 76 v 19 023 13 DC3 CTRL S 69 105 45 E 119 167 77 w 20 024 14 DC4 CTRL T 70 106 46 F 120 170 78 x 21 025 15 NAK CTRL U 71 107 47 G 121 ...

Page 228: ...haracters 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: ...he many features supported by the CPC464 The major features of the system are Z80CPU The most widely used microprocessor found in home computers throughout the world and with the best supported software base especially since the CPC464 offers the potential for the implementation of CP M The unique interrupt handling structure has enabled the CPC464 to innovate with the BASIC features AFTER and EVE...

Page 230: ...nterrupts are generated by frame scans providing for elapsed time facilities User Defined Keys Up to 32 Keys may be user defined with up to 32 character strings Redefinition capability includes the repeat parameters A complete 255 character set all ASCII plus over 100 more optionally user re definable Subroutines Many assembler sub routines are available to be called from BASIC SCREEN MODES There ...

Page 231: ...evice from General Instrument s AY8910 family The device operates with 3 channels voices each of which can be independently set for tone and amplitude White noise may be added as required The three channels appear as left right and centre using the stereo extension jack The internal loudspeaker produces a mixed monaural output The software provides envelope control facilities for amplitude and ton...

Page 232: ...l 16K add on ROMs a certain amount of address decoding hardware must be employed externally to the base machine as part of the ROM expansion hardware 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...

Page 233: ...ck 14 9 pin D Type stereo sound output Xi video output 10 RGB and sync or composite video or luminance and sync 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 In addition there is an optional PSU and UHF TV modulator the MPl C...

Page 234: ...user RAM during BASIC operations 0000H ROM SECTION 0 3FFFH 4000H 7FFFH 8000H BFFFH C000H ROM SECTION 1 RAM Screen 3 FFFFH When there is both RAM and ROM at an address then READING accesses the ROM and WRITING accesses the RAM Either ROM section can be turned off allowing read access to the RAM at the same address 1 5 Add on ability 1 5 1 Sideways ROMS Provision is made for additional ROMS to be se...

Page 235: ...instructions which place the B register on the upper half of the address bus A15 A8 must be used 2 Keyboard A full reset is operated by CTRL SHIFT ESC pressed together Keys causing printing characters or cursor movement will auto repeat under firmware control excluding all keys on the numeric keypad ESC Suspends program execution Followed by a further ESC terminates execution Followed by any other...

Page 236: ...ORT CONNECTOR 9 PIN D VIEWED FROM REAR PIN 1 UP 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 SPARE VIDEO OUTPUT CONNECTOR 6 PIN DIN VIEWED FROM REAR PIN 1 RED PIN 4 SYNC PIN 2 GREEN PIN 5 GND PIN 3 BLUE PIN 6 LUM ...

Page 237: ...1O A8 PIN 27 5V PIN 44 RAMRD PIN 11 A7 PIN 28 MREQ PIN 45 RAMDIS PIN 12 A6 PIN 29 M1 PIN 46 CURSOR PIN 13 A5 PIN 30 RFSH PIN 47 L PEN PIN 14 A4 PIN 31 IORQ PIN 48 EXP PIN 15 A3 PIN 32 RD PIN 49 GND PIN 16 A2 PIN 33 WR PIN 50 F PIN 17 A1 PIN 34 HALT PRINTER PORT 34 WAY 0 1 EDGE CONNECTOR VIEWED FROM REAR PIN 1 STROBE PIN 19 GND PIN 2 D0 PIN 20 GND PIN 3 D1 PIN 21 GND PIN 4 D2 PIN 22 GND PIN 5 D3 PI...

Page 238: ...Appendix VI TEXT and WINDOW planner MODE 0 20 columns 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...

Page 239: ...8 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 ...

Page 240: ...Text and WINDOW planner Mode 2 80 Columns ...

Page 241: ......

Page 242: ...cy ie REQUIRED ACTUAL REQUIRED NOTE FREQUENCY PERIOD RELATIVE ERROR C 32 703 3822 0 007 C 34 648 3608 0 007 D 36 708 3405 0 007 D 38 891 3214 0 004 E 41 203 3034 0 009 F 43 654 2863 0 016 Octave 3 F 46 249 2703 0 009 G 48 999 2551 0 002 G 51 913 2408 0 005 A 55 000 2273 0 012 A 58 270 2145 0 008 B 61 735 2025 0 011 NOTE FREQUENCY PERIOD RELATIVE ERROR C 65 406 1911 0 007 C 69 296 1804 0 007 D 73 4...

Page 243: ...46 Middle C C 277 183 451 0 007 D 293 665 426 0 081 D 311 127 402 0 058 E 329 628 379 0 057 F 349 228 358 0 019 Octave 0 F 369 994 338 0 046 G 391 995 319 0 037 G 415 305 301 0 005 A 440 000 284 0 032 International A A 466 164 268 0 055 B 493 883 253 0 038 NOTE FREQUENCY PERIOD RELATIVE ERROR C 523 251 239 0 046 C 554 365 225 0 215 D 587 330 213 0 081 D 622 254 201 0 058 E 659 255 190 0 206 F 698 ...

Page 244: ...270 67 0 055 B 61 735 63 0 435 NOTE FREQUENCY PERIOD RELATIVE ERROR C 2093 004 60 0 462 C 2217 461 56 0 662 D 2349 318 53 0 390 D 2489 016 50 0 441 E 2637 021 47 0 855 F 2793 826 45 0 574 Octave 3 F 2959 955 42 0 548 G 3135 963 40 0 350 G 3322 438 38 0 992 A 3520 000 36 1 357 A 3729 310 34 1 417 B 3951 066 32 1 134 NOTE FREQUENCY PERIOD RELATIVE ERROR C 4186 009 30 0 462 C 4434 922 28 0 662 D 4698...

Page 245: ...Sound envelope Music planner sheet ...

Page 246: ...an error 10 ON ERROR GOTO 1800 program 1000 PRINT CHRS 7 MODE 2 INK 1 0 INK 0 9 CLS LIST Whereupon the CPC464 will beep clear the current screen change to a suitable colorir combination for the 80 column display and list the program ready for examination If the error is a Syntax error it will appear at the foot of the listing awaiting correction in the line edit mode although the Syntax error mess...

Page 247: ...ox Alternatively this may be the result of a failed attempt to change a floating point number to a 16 bit signed integer 7 Memory full The current program or its variables may be simply too big or the control structure is too deeply nested nested GOSUBs WHILEs or FOR A MEMORY command will give this error if an attempt is made to set the top of BASIC s memory too low or to an impossibly high value ...

Page 248: ...Processing Mode ie in an ON ERROR GOTO routine 20 Unexpected RESUME RESUME is only valid while in Error Processing Mode ie in an ON ERROR GOTO routine 21 Direct command found When loading a program from cassette a line without a line number has been found 22 Operand missing BASIC has encountered an incomplete expression 23 Line too long A line when converted to BASIC internal form becomes too big ...

Page 249: ...LEN LET LINE LIST LOAD LOCATE LOG LOG10 LOWER MAX MEMORY MERGE MID MIN MOD MODE MOVE MOVER NEXT NEW NOT ON ON BREAK ON ERROR BREAK ON ERROR GOTO GOTO ON SQ OPENIN OPENOUT OR ORIGIN OUT PAPER PEEK PEN PI PLOT PLOTR POKE POS PRINT RAD RANDOMIZE READ RELEASE REM REMAIN RENUM RESTORE RESUME RETURN RIGHT RND ROUND RUN SAVE SGN SIN SOUND SPACE SPC SPEED SQ SQR SPC STEP STOP STR STRING SWAP SYMBOL TAB TA...

Reviews: