i itt se H ' oe i a . isk e a | HE a : . He id : x _ : : : es . oS By ae ; | . z if aN . : : : : | _ : : : ae : = _. oe : . : : : a
eae
eee peise
. . . : : y _ _ g : :
ree
eseceaeaee:
ee EE
_ : - _ |
SESEPSBE See air aeaoe re eee
| : | | i - ee : a | ~ 3 mee ce Mae ; Neate _ canersict ‘ < a Seen e _ . eee oo _ <— _ . ae : — oS _ | : : _ LS , cc : oe . ‘ % | \ 3 | a \ ' | | eae wat a — < . a \
co |. . =«.
LEARNING TO LEARN We consider several rudimentary learning systems and look at an evolutionary ‘rule-breeding’ system based on the ideas of ‘natural selection’ and named after the ship on which Darwin sailed
AHEAD OF TTS CLASS Produced by a company with a formidable reputation in the 132 education market, the RM Nimbus features sufficient ‘state of the art technology to
make it a contender in the business market
SAME AGAIN In examining CP/M’s ability to duplicate itself, we discuss the role 1374
of the main components of the system — the CCP, BIOS and BDOS
sti
| oo!
JIN | _ _
_ cS . . | — . . USEFUL SIDE-EFFECTS A look at how PROLOG incorporates ‘side effects’ and several 1376 ‘extralogical features’
FROM POKETO PRINTED CIRCUIT weekly glossary of computing terms
THE NEW WORLD II The second 4 instalment of a three-part complete listing of 1338 our simulation game. This week we provide
flavours for the BBC Micro
TREAM LINED Having looked at th ) pectrum O%S’s control of channels last week, 3 we now consider the streams of data
associated with them
SOUND SPECIFICATIONS Our introduction to a new project to design and 1335
build a MIDI interface focuses on the hardware specifications
REFERENCE CARD Another section of aad
the Commodore 64’s memory map COVER
‘Answers To Last Week’s Quiz
1) The ‘Freddy’ chip handles the bank switching required to access the additional 64 Kbytes of memory.
2) The Z80's CALL command will run a subroutine held at the | | address which is the argument of the op-code.
_3)A ‘wildcard’ is a character inserted in a filename, which (when
compared on the directory) can refer to any character in that - position. This effectively means that the operating system will _ ignore the character in that position. :
LEARNING
TO LEARN
There is a growing body of opinion that th only solution to many of the problems researchers are encountering in the field of _ ATis the development of a ‘child’ system — one that learns by itself. We examine here the criteria necessary to create such a system, and outline an evolutionary ‘rule- breeding’ system called BEAGLE.
If a computer system has improved its performance of a given task over a period of time without being re-programmed, it is valid to say that it has learned. It is important to note that this
implies an agreed yardstick, or standard, against which the system can be measured. In the absence of an agreed way of evaluating progress, it is meaningless to speak of learning.
Thus a learning algorithm attempts to do one or more of the following:
@ Cover a wider range of problems. @ Give more accurate solutions. @ Obtain answers at lower cost. @ Simplify codified knowledge.
The last point assumes that the simplification of stored knowledge is valuable, even if it does not result in improving the performance of the computer’s task. This may be true if the system begins with one set of rules and ends up with another, equally effective set that happens to be more easily comprehensible to us.
Machine learning can apply to many domains; but most successful learning systems have been applied to classification problems. The objective
1)a square has 4 sides
2) all sides are same
f OUTPUT | PERFORMER! = | LEARNER tts
| crmc
\™“" wrong, but SS, the rule is good-
1) a square has 4 sides
2)allsides are sane length a
wrong, but
bothrulesare good\ —\.-morerulesare / |
“needed 4
morerulesare J
—\ needed
fength 3) 2 sides are vertical »
~" wrong, your \ first two rules are || \ goodbutthe3rd. J —\Qismisleading 4
IAN McKINNELL ON THE MACINTOS
1) a square has 4 sides 2) all sides are same’
ke 3) all the angles are at 90°
THE HOME COMPUTER ADVANCED COURSE 1321
Charles Darwin (1809-1882) Darwin's theories of evolution hold that species adapt and improve themselves in response to their environment by natural selection; only the strongest and best adapted members Surviving to breed the next generation and pass on their characteristics. This
idea has been successfully used in the field of machine
learning, allowing Al systems to .
improve their performance in classification problems by - evolving sets of classification rules. Itis no coincidence that one such system is named BEAGLE, the name of Darwin's ship on this famous expedition to the Galapagos Islands
HULTON PICTURELIBRARY
of such a system is to look at input data and classify, identify or interpret it in some way. Several methods of achieving automatic performance improvement have been attempted. two of the simplest —7ore learning and parameter adjustment — were pioneered by Arthur Samuel in his classic studies of machine learning using the game of checkers. Even prior to this, Rosenblatt and Selfridge, among others, had devised pattern- recognition systems with rudimentary learning capabilities, such as the Perceptron (page 1221). Parameter adjustment, a method in which program coefficients and parameters are repeatedly adjusted in order to improve performance, is simply a kind of optimisation technique. It has been exhaustively studied in the literature of applied mathematics, and is consequently understood relatively well. Rote learning is entirely ‘uncreative’, and purely a storage compression technique, whereas the methods we consider here are capable of generalising, and hence learning, the appropriate response in a_ Situation not previously encountered. _ Any system designed to create new knowledge and thereby improve its performance must include the following major components:
e A set of data structures that represents the system’s present level of expertise (the rules).
e A task algorithm (the performer) that uses the rules to guide the problem-solving activity.
@ A feedback module (the critic) which compares actual results with the desired goals.
e The learning mechanism itself (the learner) which uses feedback from the critic to amend the rules.
THE DESCRIPTION LANGUAGE
The method of representation chosen to encode the system’s knowledge is at least as important as the details of the learning algorithm. So, before building a learning system, it is vital to ensure that the description language used within the system is capable of expressing the kinds of distinctions that will be needed — certainly not a trivial problem.
Assuming that we can solve the problem of devising an adequate description language, we are left with the problem of automating the generation of accurate descriptions within it.
One way of looking at the problem is as a search through all possible descriptions for those which are useful in a given context. An AI system which learns to classify may start with a series of parameters that are to be used in making a classification. In the learning phase, the system may generate and evaluate further descriptions by combining the original parameters in some way — keeping descriptions which assist correct classification and discarding those which do not. The number of syntactically valid descriptions generated may be astronomical; and the more expressive the description language, the more explosive this combinatorial problem will be.
1322 THE HOME COMPUTER ADVANCED COURSE
Clearly, some way must be found of guiding the search and thereby ignoring the vast majority of potential descriptions that are irrelevant.
A number of methods have worked well with ‘noise-free training instances, in which classifications are clear-cut, with few grey areas between classes. Dealing with ‘noisy’ data, however, is amore challenging problem. Let’s now look at a comparatively simple method that appears to work quite well in this second instance.
BEAGLE (Biological Evolutionary Algorithm Generating Logical Expressions) is a computer system that produces decision-rules by induction from a database. As such, it addresses the problem — frequently sidestepped — of where the rules ina rule-based system come from.
BEAGLE works on the principle of ‘natural selection’, whereby rules that do not suit the data are killed off and replaced by ‘mutations’ of better rules, or by new rulcs created by mating two better adapted rules. The rules are Boolean expressions represented by tree structures.
The original software consisted of two PASCAL programs, namely HERB (Heuristic Evolutionary Rule Breeder) and LEAF (Logical
Evaluator And Forecaster).
HERB requires three input files to be created by the user: a datafile, a payoff file and an oldrule file, which may be empty. It produces, as output, a new rule file which is at least as good as the old one. The datafile contains the training set, for which the correct category membership is known. The user also has to furnish a payoff matrix, which defines the value or cost of correct and incorrect classifications.
LEAF is simpler than HERB. It merely takes a datafile in the same format as the training set and runs a rule file over it. It can be requested to print out, among other things, an ordered list of items in the data file from those most likely to fit a given class (as defined by the rule file) to those least likely to fit the class.
The BEAGLE learning algorithm consists of repeating the following procedure for a number of ‘generations’ (a complete run through the training data is one generation).
1. Evaluate each rule on every sample in accordance with the payoff matrix, with a bonus given to shorter rules.
2. Rank the rules in descending order of merit and remove the bottom half.
3. Replace ‘dead’ rules by applying a mate procedure to a pair of randomly chosen survivors, thus re-combining portions of good rules.
4, Mutate a few randomly chosen rules (but not the top one) and apply a procedure TIDY to all new rules — ready for the next generation.
The TIDY procedure cuts down on certain syntactic redundancies that may be generated, such as double negatives and constant expressions, leaving the ‘pruned’ rule-tree with essentially the same set of rules except that it will be more succinctly expressed.
This method of generating new rules is based on
Darwinian ideas of evolution — only the fittest rules survive to breed the next generation. In this way, the rule file ‘evolves’ during successive training runs to produce a set of rules that can more accurately determine whether or not a given
node (as shown in this example), the underlying — search space isreallya network
item belongs to the class. In the second part of our look at machine
learning, we will consider the problems of implementing a simple BEAGLE-like learning method in BASIC.
a SRR SCRE
|. ae
THE HOME COMPUTER ADVANCED COURSE 1323
GABRIELLE IZEN
KEVIN JONES
Making Tracks
Although most of a CP/M data
disk is available for user files,
the outermost tracks are reserved for use by the operating system itself. Track zero holds the bootstrap loader, which loads CP/M automatically from power up and reset, while tracks one and two hold the CP/M system itself. Beyond that are the directory tracks, which hold the File Control Blocks showing exactly where the records that make up a file are
located
THE SAME AGAIN
By i issuing the transient command SYSGEN, v we can enable CP/M to copy itself from one disk to another. We illustrate this process by following the flow of information through the system, and introducing the workings of the COP, BIOS and BDOS functions.
So far in this series, we fave aieamlnee the Se of
commands available to CP/M, and we are now able to
perform all the functions that may be required inthe home or office. We can load, edit, save and transfer the various types of files that are defined by CP/M as well as examine their properties. However, there is one vital function we have not yet performed — namely, copying CP/M itself. Remember, CP/M is designed to be ‘transparent’ to the user — it will not show up on any normal directory listing and so cannot be accessed by the standard transient command operations.
Obviously, itis extremely important that we are able to transfer CP/M onto other disks; not only to provide us with a security copy in case the master disk becomes corrupted, but also because many applications require that a specially installed version of CP/M be placed onthe disk. An example of this is Dr Logo on the Amstrad, which
CP/M SYSTEM
x as . DIRECTORY WA TRACK(S)
RESERVED FOR THE USER FILES
incorporates a customised version of CP/M on the same side as the language which, in turn, contains extra procedures for editing and colouring.
Copying CP/M is quite simple. There is a transient command provided on the system disk known as SYSGEN, and by executing it the program will give you a series of prompts, depending onthe configurations of the system, which can be used to transfer CP/M to the destination disk.
This sounds easy enough. However, the operation raises a number of interesting questions about the nature of CP/M. Why do we need a special command? Why doesn't CP/M and its associated resident (built-in)
1324 THE HOME COMPUTER ADVANCED COURSE
commands appear on a DIRectory listing? And furthermore, how does CP/M in fact read a directory? To answer these questions, let’s turn our attention to the nuts and bolts of CP/M.
The operating system that is loaded into the computer can be divided into three parts, each of which handles a distinct part of disk operation. The part that you will be most familiar with is the Console Command Processor (CCP), which seems natural since this is the ‘front end’ of the system — the area sending information to the video monitor and interpreting commands that are typed in at the keyboard. Because of this, the CCP is the ‘public face of CP/M.
However, it does a great deal more behind the scenes. When information is typed in and entered at the keyboard, the CCP assumes that the information represents commands, and so they are transferred via another part of the system known as BIOS (Basic Input/ Cutput System, which we will discuss shortly) to the CCP buffer area. The CCP then does a check of the resident commands to see if your command corresponds to one of them. If so, that command will be executed immediately. Ifthe command is not one of those ‘built-in’, CCP will then assume that the command is transient and will search for it on the system disk.
Once located, the command will be loaded into memory and executed. If CCP still fails to find the command, it will, of course, generate a ‘file not found’ error message. In the case of CP/M, the CCP will display the name of the command in capital letters, followed by a question mark. The reason the command is displayed in capitals is that one of the functions of the CCP is to convert all lower-case commands to upper-case, to conform with the CP/M system of naming files.
BASIC INPUT/OUTPUT SYSTEM
The BIOS is a collection of routines (known as peripheral drivers) which handle all the input/output functions of CP/M. Its fundamental purpose is to manage the peripherals that are currently connected to the system (including the keyboard and monitor — the CCP merely sends and interprets information via the BIOS). The system uses parameters provided for it by the CCP. should you wish to ‘customise’ CP/M to run on another machine, it is the BIOS that will have to be altered to enable the program to run correctly. The reason for this (aside from CP/M _ having certain hardware requirements), is that the method of peripheral management can vary widely between different machines. Therefore, it is necessary to alter the BIOS to take into account these differences.
The third part of CP/M is the section that deals directly with disk management. This is the BDOS (Basic Disk Operating System). This is the least ‘visible’ of the CP/M components, and without it CP/M would not be able to achieve its primary purpose. BDOS is the software that
a ee
manages the files on disk, allocates areas for storage and maintains the directory. As a prelude to a more detailed examination of how BDOS works, lets take a look at how storage space is arranged on a floppy disk.
SOFT AND HARD SECTORS
In hardware terms, a disk is divided into 40 tracks. Modern versions of CP/M will further divide the tracks into ‘soft sectors’ (so-named because it is the software that determines the sectors). Older types of floppy disk systems subdivided tracks into ‘hard sectors’, which were read mechanically by the hardware. Naturally, there will be more sectors available on the outer tracks of a disk than the inner ones. Most of the tracks on a disk will be used to store information.
However, there are three tracks (on a 5zin disk) which are reserved for use by CP/M. These outermost tracks (numbered 0 to 2) will contain the short ‘bootstrap loader’ (also known as the ‘resident monitor’) program, which enables CP/M to load itself into the computer with no disk operating system present. Also contained on these tracks is the CP/M system itself. It is the information on these three tracks that is installed on the disk by the SYSGEN command.
The sectors (referred to in CP/M terms as ‘records’) contain 128 bytes of information. Records can be grouped together to form a ‘unit’; one unit can contain up to 128 records. A CP/M file can hold up to 16 of these units. Thus a file can consist of amaximum of 128 by 128 by 16 bytes (256 Kbytes).
Unless the file is very small indeed, it will not be possible to hold it on a single record. Neither will it be possible, in practical terms, to arrange all the records of a file in sequential order on a disk. Thus a disk operating system must have some method of knowing which sectors on a disk are being utilised for particular files.
In CP/M, this information is known as a File Control Block (FCB). These FCBs are held on the fourth track (which is known as the directory track) of a 5zin disk. This method of indexing files is read, written, altered and managed by BDOS. A File Control Block is made up of 33 bytes of information and holds all the data necessary to allow BDOS to identify and locate any file on a disk.
The FCB consists of, first of all, the ‘entry type’, asingle byte that holds the identity of the disk drive in which the disk containing the file is currently resident. The next eight bytes contain the file name foilowed by three bytes that are reserved for the extension. Bytes 12 to 14 are used to hold the total extent of the file, while the fifteenth byte holds the record count (indicating how many records are in the file). The next 15 bytes contain the file’s disk allocation map which indicates the sectors that are being occupied by that file. Finally, the last byte will hold the next record number to be accessed (should the file take up more than the 16 Kbytes that can be described by a single FCB).
When a file has been opened by the execution of a command, the CCP will create a version of the FCB in the area of memory usually reserved for transient commands. Extra information about the file — such as its length, number of records and sector allocation — will be supplied by BDOS when it finds the file with a name matching that created by CCP. The reason for placing an FCB in memory is so that the data held in it can be quickly
updated by BDOS as the file is manipulated by CP/M commands. At the end of these operations, the final version of the FCB, taking into account the altered record length and sector allocation, will be written onto disk by BDOS.
We can now step back and take an overview of how CP/M retrieves its files. When the CCP receives a command from the terminal, itinterprets the first word as the instruction. If the command is not resident in memory, the CCP will send the filename to the BDOS via the BIOS ‘messenger’ system (see page 1304). The BDOS will then search the directory track of the disk until it finds a matching occurrence of the filename in one of the FCBs. If the file is a COMmand file, the BDOS will examine the disk allocation map to discover which sectors on the disk are occupied by the file, find them on the disk and copy them into memory, at which point the command will be executed.
OTHER 1/0 PERIPHERALS
This may mean that BDOS will be required to find another file to be acted upon and will find and load that into memory as well. When a file is loaded into memory, the BDOS will also supply the appropriate FCB data to an empty version of an FCB that has been set up by the CCP. This FCB will be updated as execution progresses. At the end ofthe command program, the updated version will be copied back to the disk by BDOS.
Inthe next, and final, part of this series, we shall take a look at how the components of CP/M are arranged in the memory ofthe computer and how this space is organised to take maximum advantage of the limited space that may be available. |
es . _
KEVIN JONES
THE HOME COMPUTER ADVANCED COURSE 1325
USEFUL SIDE-EFFECTS
Because of PROLOG’s predicate logic, procedural operations cannot be performed without certain compromises. In this instalment, we'll examine how PROLOG incorporates ‘side-effects’, as well as several ‘extralogical’ features — such as the ‘cut’? and ‘fail’ operations.
PROLOG, as we have seen, is essentially a logical language, but certain
functions that a programming language needs to perform, such as reading and writing files and performing arithmetic calculations, are essentially procedural and will not fit very comfortably into predicate logic. In order to cope with these, PROLOG has a number of built-in predicates. Some of these work through side-effects — write (Term), for instance, will always succeed but, as a side-effect, will perform some useful function (in this case, writing the value of Term onto the current output channel).
Allinput and output in PROLOG is handled through side-effects. Although this offends the purists, who would rather see a strictly logical language, the job gets done; it is one of the compromises necessary for a practical and useful language. =
Writing to files in PROLOG is just the same as writing to the screen. A predicate, tell (Filename), instructs PROLOG to send all future output to the
| specified file; told closes the file. Similarly, see (Filename) tells PROLOG to _read from the named file and ‘seen’ restores the status quo. PROLOG can send ASCII codes using ‘put(Code), while get reads in ASCII values.
To perform arithmetic, PROLOG has a number of built-in predicates that are really functions and are evaluated by the interpreter. One such ‘evaluable’ predicate is is. This is used in the following way:
ClisC+1. Which is equivalent to the Basic: C1=C+1.
Note that C is C+ 1 would always fail in PROLOG , while BAsic’s C = C + 1 works
perfectly well. This is because languages like BASIC, FORTRAN, PASCAL, ALGOL and C use destructive assignment. That is, in assigning the result of the expression (on the right of an assignment statement) to the variable (on the left), any value that had been held in that variable will be over-written. So it does not matter that the same variable had appeared on the right.
PROLOG does not use assignment at all. Instead, it uses unification. That is, once a variable has been instantiated, every other instance of the same variable in the whole clause takes the same value. So saying that Cis C + 1 would be like trying to give C two different values at once.
The built-in predicate not is used to introduce negative information and is defined so that not(X) will be true if X is false and vice versa, just like BAsic’s Boolean NOT. For not(X) to be true, PROLOG must first show that X is false. It does this in a rather simple-minded way; a thing is false if it cannot be shown to be true! Imagine we had the following PROLOG program:
Standard PROLOG version:
language(pascal,hard) language (cobol, hard) language (basic,simple) language (prolog, simple)
MICRO-PROLOG version:
(language Pascal hard) (language Cobol hard) (language BASIC simple) (language Prolog simple)
which lists a few facts about the ease of programming in various languages. We could ask questions such as:
language(basic, DIFFICULTY).
where DIFFICULTY is a variable, and PROLOG will reply:
DIFFICULTY = simple. But, 1f we ask: language(basic, easy).
PROLOG tells us no. ‘The reason is that the goal we have set cannot be proved because it is neither explicitly stated in
1326 THE HOME COMPUTER ADVANCED COURSE
the database nor derivable from other facts and rules. PROLOG, of course, does not understand the meaning of words, so it cannot tell that simple and easy mean the same thing. Furthermore, it assumes its database is a ‘closed world’. That is, everything that can be known is known, so anything that cannot be proved to be: true must be false.
This idea of ‘negation as failure’ is one Of PROLOG’s weakest features and is due to the logical proof method that the interpreter uses. This is called resolution and cannot handle negative information directly. For instance, consider this rule:
not(A):— B, C, D.
(which says that X is not the case if B, C and D are true). This cannot be written in PROLOG because a negative cannot be in the head of a clause.
EXTRALOGICAL FEATURES
PROLOG is not a purely declarative language. We have already seen how the ordering of clauses in the source code can affect the way the program works, especially for recursive procedures. In fact, the purity of its logic can be further diluted by the use of the so-called ‘extralogical’ features, fail and cut.
The first of these, fail, is quite easily explained. It is a predicate which, whenever it is encountered, will always fail. Why do we need fail? The main reason is to keep pRoLoG working! If we are using our languages program and ask:
language(Lang,simple). PROLOG would reply: Lang = basic
and stop. It finds the first clause in its database that matches the goal we have set it and, having proved the goal, looks no further. Yet we may have wanted to get a list of all the simple languages. We can force PROLOG to do this if we add a rule such as: 3
Standard PROLOG version: simplelist :— language(Lang,simple),
write (Lang), nl, fail MICRO-PROLOG version:
((simplelist) (language X simple) (PX) PP FAIL)
Now if we type simplelist, PROLOG will reply: | basic
prolog no
What happened was that proLoc tried to prove the goal simplelist by first proving language(Lang,simple). It found the fact language(basic, simple) and set the variable Lang to the value basic. So the first sub-goal was proved. It went on to the next, and with Lang being basic, it found write(basic). Because write automatically succeeds (writing basic as a side-effect) it passed on to the last sub-goal, which is fail. This, of course, failed, so PROLOG backtracked to write. Since write (and the other evaluable predicates) will not succeed again on backtracking, PROLOG backed up further to language(Lang,simple) and tried to find another way to prove it to be true.
The other feature, cut (written !), is also used to control backtracking. A cut is a predicate that always succeeds. However, as a side-effect, it prevents the interpreter from backtracking over it. This effectively freezes any choices about the values of variables taken earlier in a procedure. It also prevents alternative clauses in the same procedure from being tried. An important use of cut is in conjunction with fail, to ensure that a deliberately failed clause is not tried again. We might define a predicate missing using ! and fail as follows:
Standard PROLOG version:
missing(Clause):—Clause, !, fail. missing(Clause).
MICRO-PROLOG version:
((missing X) (?X)/FAIL (missing X)
which is true if the clause given as its argument is missing from the database, and false otherwise. Trying this on the language program, we might ask:
missing(language(basic,simple)).
To prove missing(language _ (basic,simple)), we must prove language (basic,simple). This is true because it exists as a fact in the database. Moving on to the cut, this succeeds
automatically, but then fail causes the entire clause to fail.
Without the cut, PROLOG would have backtracked and tried to find another way to satisfy Clause. However, the cut stands like an impenetrable wall in its way and, as there is no other way to satisfy the goal, it must all fail. Also, because of the cut, PROLOG will not look for alternative clauses, so missing(Clause) ends up false (because Clause was true) and we did not waste effort looking for alternatives.
This particular example illustrates a very important aspect of PROLOG: it can treat its own program as data. This makes it an ideal choice for artificial intelligence programming. This, and other advanced programming techniques in PROLOG, will be discussed in the next instalment.
From Place To Place
In our final article on PROLOG we will devise a program to move a robot about the room illustrated above. Positions in the room are stored in the format place(door) etc. and the robot moves about using the procedure go(Place1,Place2). This first involves proving the sub-goal place(Place1) — i.e. establishing that Place1 exists and can be moved from. What other Sub-goals would need to be proved before the program can begin|planning a route from one place to another?
THE HOME COMPUTER ADVANCED COURSE 1327
KEVIN JONES
Conquering New Ground
The RM Nimbus is something of a departure for its manufacturers, Research Machines. Based around the Intel 80186 processor, which is capable of addressing up to a megabyte of memory, the machine suggests that the company Is looking beyond its well established education base into the highly lucrative business field
HARDWARE’ kM NIMBUS
AHEAD OF ITS CLASS
Within the educational market, Research Machines Ltd has had much success with its 380Z and 480Z eight-bit micros. Now, with its 16-bit Nimbus technologically advanced and exceptionally well-priced — the company hopes to break into the business market.
Research Machines Ltd is a name not widely known outside educational circles. Over the past few years the company has established itself as a supplier of quality eight-bit microcomputers to schools and colleges. The expandable 380Z computer and the 480Z network machine each made a great impact during the government’s Microcomputers in Education Project, providing Acorn’s BBC Micro with its only serious competition.
Despite the fact that computers like the 380Z were considered revolutionary at the time of their launches, the demand now is for greater processing power, and this can only be provided by 16-bit processors. In response to this demand, Research Machines has launched a new 16-bit micro known as the Nimbus.
Obviously, the industry has developed considerably since the appearance of the 380Z. The top end of the market is now dominated by the IBM PC and a multitude of ‘compatibles’, most of which are based around the 8088 processor. Although the 8088 is faster than the Z80, it is already beginning to look somewhat dated. It is to the company’s credit that, in developing the Nimbus, it has not taken the easy option of producing yet another IBM clone. It has, rather, chosen to base the machine on the much faster 80186 chip, a true 16-bit procesor that can execute up to a million instructions per second. The result is a computer that leaves most of the competition far behind.
Although the Nimbus is not an IBM- compatible, the 80186 is a close relative of the 8088, and runs under the standard MS-DOS operating system. The keyboard can also be configured to the IBM format, as well as the more familiar Research Machines system used on the 380/480Z. Thus, the keyboard is fitted with 10 programmable function keys, a numeric keyboard and an ALTernate character set key. The keys
themselves have an excellent feel to them,
CHRIS STEVENS
comparable to any on the market.
The version presented here is the Nimbus PC2. It is equipped with twin Sony-format 33in disk drives, although a single-drive version, known as the PC1, is available. These disks can each store up to 720 Kbytes of information and are currently being adopted by an increasing number of ‘leading edge technology’ products.
The decision to incorporate these drives, as well as several other advanced features, probably persuaded RM away from producing an IBM- compatible machine towards making a computer more at the ‘leading edge’. The IBM machine uses the older 5zin format, which is more delicate and has less storage capacity than its Sony counterpart. It would have seemed strange had RM installed disk drives that are becoming increasingly out of date and would have hampered the performance of its machine, considering its other advanced features.
This presents the problem of software compatibility between earlier Research Machines computers, which used 5jin disks, and the Nimbus. This has been solved by the company
providing facilities to enable further disk drives to be added, including, of course, a 5iin drive. This means that 5iin drives in PC-DOS, MS-DOS or CP/M format can be read by the Nimbus, a tremendous selling point to owners of computers with different formats whod rather not abandon all their current software.
Beneath the drives are tvo ROM cartridge sockets. These are compatible with the cartridge port fitted on the 480Z, although there is little ROM-based software yet available. To the left is a socket to enable a ‘dongle’ to be fitted. This is a software protection device that prevents users running a program without one, even though they may have a copy of the software.
The software provided with the Nimbus includes an MS-DOS systems disk, Microsoft’s. Wordplan and Multiplan, as well as RM’s own Loco and Basic. When the software is loaded, you begin to appreciate what an excellent machine the Nimbus really is. In particular, the graphics facilities provided from BAsic are outstanding.
THE RM BASIC
The Basic that is bundled with the Nimbus is a development of RM’s Version 5. Bearing in mind that RM has its main base in the educational market, it is not surprising that the language has a number of commands designed to encourage structured programming, although not as many as the later Version 6 Basic. The RM Basic on the Nimbus contains command structures such as REPEAT .. UNTIL, PROC . . ENDPROC and GLOBAL, but lacks the later DO . . WHILE.
On the other hand, Research Machines has added some useful commands that are designed to be of use to games programmers. The optional joystick and mouse can be used by the JOYX, JOYY and MOUSE commands — the BUTTON command initiates the effects produced by these devices.
Graphics, sound and other attributes are selected from Basic by using the SET command followed by any parameters that may be required. By using this instruction, it is possible to select foreground and background colours (defined by the PAPER, BRUSH and PEN commands), draw lines and circles and select character founts, directions and sizes. It is also possible to choose what the manual describes as ‘styles and ‘dithering patterns’. These are essentially patterns that can be placed on the foreground or background, adding texture to a picture or, in the case of the ‘dithering patterns’, producing the effect of a colour that is a combination of the dots within the area.
Apart from the wide range of effects that can be produced on the Nimbus, the speed at which the graphics are drawn on the screen from BASIC is very impressive, and comparable: to many 16-bit computers programmed in machine code.
The disks are organised into directories and sub-directories. This means, for example, that in order to enter BASIC, you have to enter the BASIC directory from the main one. This is performed from MS-DOS and basic itself by the CHange
RM NIMBUS, HARDWARE
SEES ee : : Sunes nee cone
DiRectory command, or CD for short. Following this command, you must specify the pathnames that are required in order to obtain the required directory. This may sound a bit complicated, but it enables (and encourages) you to organise your directories in a systematic manner. New paths and directories can be created from the operating system and new pathways between existing directories can be established.
Keeping in line with its design philosophy for the Nimbus, Research Machines has opted for ‘state of the art’ technology rather than established standard peripheral ports. The Nimbus has three separate power-output lines from the main computer unit. A 2A output from the main power
THE HOME COMPUTER ADVANCED COURSE 1329
Sy aS
SN
ha
In order to be able to read and process RM disks formatted foruse with 3802/4802 Sts ‘computers, Research = =—ts Machines have included the familiar Z80Aasasecond
this add-on board _
The standard V rsion of the CS equipped with
| wn as a dongle Ort, thisinterfaceensures
= that unauthorised copying of S programs is impossible when 7 ) ) 3 adongleisnotfitted = — oo = Lo Sound Chij "sloppy Disk Control = JO transformer is positioned in the top left-hand =~ _ Thediskdrivesarecontrolled 9 —_ A a i = oe corner of the computer, and two smaller outputs, ——s=Pythis board, whichisfitted = = |= 7 salty Il) i et 12v and 5v, are along the rear panel. —_ IMO one of the expansion slots t-te fo. l= Among the other interfaces provided is a Piconet port, which is installed as a BT-standard telephone jack. The Piconet enables up to 30 _ separate peripherals, each connected via an external module, to be governed from a single port. The interfacing is serial and constructed to _ the RS422 standard. It is this new high-speed connection that enables the Nimbus to control the 30 devices. Unfortunately, the RS422 is not directly : compatible, in many cases, with the earlier RS232 standard, so if you want to use these devices, you will have to obtain suitable interfaces. Also provided is a network capability enabling the | : , = || “== Nimbus to be connected to a network of other oe >. ~~ — » Research Machines computers via the co-axial — : = jack socket. ___ Disk Drives | Ihe Nimbus PC2 is fitted with PRINTER INTERFACE __ a pair of Sony format disk
; é ; ‘ a : ; rive A curious inclusion is the printer interface. This a
~ has been installed as a BT telephone jack identical to the Piconet port, and is somewhat non- standard. Furthermore, the port is serial only and
1330 THE HOME COMPUTER ADVANCED COURSE
oi
is designed to the RS422 standard.
The remaining interfaces that are provided are more familiar. There is a nine-pin D socket that : facilitates a joystick or, more likely, a mouse tobe | PC1 connected to the computer in order to run Macintosh-type applications (the demonstration programs contain a drawing program, which, apart from the colour graphics, looks remarkably like a Macintosh screen, though lacking many of the MacPaint facilities).
Two monitor sockets are provided, one of which, for RGB monitors, runs the Cub colour monitor that has been ‘badge engineered’ by RM. The other is a composite video socket intended for monochrome ‘green screen’ monitors. Finally, there is a DIN plug for the keyboard.
On the far left (looking at the back of the machine), are four expansion ports into which you can add extra boards. These would include additional banks of RAM, digital/analogue interfaces and so on. Unlike many other - manufacturers who insist that this sort of work should only be carried out by authorised dealers, Research Machines has provided full instructions in the User Guide to enable owners to fit their own boards.
COMPLETE DOCUMENTATION
The manuals provided with the Nimbus are well up to the high standard the public has come to expect from RM. The information contained includes a beginners guide to MS-DOS and the disks, right through to a detailed look at the ports. The only obvious omission is an examination of the 80186 processor chip, which, although not likely to be of use to the vast majority of customers, could be to programmers intending to develop their own software on the machine.
It is, as yet, too early to say whom the Nimbus will appeal to most. It is definitely a high-quality machine which, at entry level, is almost half the price of its only serious rival, the IBM PC/ AT. The computer will undoubtedly sell, but how well it sells depends on RM’s marketing strategy.
Universities and other large educational establishments already having good relationships with RM will probably buy the machine, and will not worry a great deal about software support — they will probably wish to write their own and can | transfer the RM software they already possess.
The speed and easy programming facilities will obviously represent big selling points as well as the number of peripherals that can be fitted.
However, if the Nimbus is to fulfill its potential in the business market (which the computer obviously possesses) Research Machines will have to convince business users that suitable software will be forthcoming. RM may also have to tailor the interfaces to the Centronics and RS232- standard used in most offices. If Research Machines can break into the business sector, the Nimbus could prove a considerable challenge to
the current market leaders — ACT/ Apricot and IBM.
a U C
CHRIS STEVENS
THE HOME COMPUTER ADVANCED COURSE 1331
STRMS =>
STREAM LINED
Having shown how the _ Spectrum’s operating system selects and controls its input/output channels in the previous instalment (see page 1317), we now take a look at the streams of data that it sends down these channels to the printer and screen, or receives from the keyboard.
See You will recall from our previous discussion that whenever we turn the Spectrum on or reset it, certain streams are associated with particular channels in the initialisation process. The following table shows these associations:
However, there are other streams available to us that are not used in a standard Spectrum. It should be noted that the following description refers to a Spectrum without the Interface 1 device fitted; everything is altered when we use local area networks, Microdrives or the serial interface.
ty pets: tyty a etectaseteheseeeatereeecereeeeeeee
Pada Pa Fe Te Pasa rocurueqeeser ye ee Se SESE IE ST Oe Oe b 5% on t; Been tae ha bh bt. a
oh at ah ah ah o'h ot ah
1332 THE HOME COMPUTER ADVANCED COURSE
These devices will be discussed in a later part of the course. The other streams are numbered 4 to 15, and they can also be associated with any I/O channels that we may want to interface.
The Spectrum operating system keeps a record of which streams are associated with each channel that is being used. This information is kept in a 38- byte table called STRMS, which can be found in the area reserved for system variables at address 23568. There are six bytes at the head of the table which are used by the Spectrum OS for its own purposes. Following these, each of the 16 streams is represented by a two-byte entry. The arrangement of the table is shown in our diagram.
The following piece of BAsic code will print out the contents of this area of memory for you to examine:
10 FOR l=23568 TO 23604 STEP 2 20 PRINT PEEK I+256*PEEK (1+1) 30 NEXT |
This prints out all the two-byte entries. The first three are the details of the Spectrum’s internal streams, and then we see the entries for streams 0 to 15. The values in this latter portion of the table act as pointers to different entries in another table, located elsewhere in memory and pointed to by a
‘system variable called CHANS. This is found at
address 23631, and the address of the CHANS table can be found using:
PRINT PEEK 23631+256*PEEK 23632
This system variable should never be poked. The expression we have just used gives you the start of the channel record table, which holds various items of information for each channel. The value read from the STRMS table is used to index this channel record table. A STRMS table entry gives the (offset+1) from the beginning of the channel record table of the information about the channel that 1s to be used with a particular stream. Thus, the STRMS table entry for Stream 3 (to the printer) is 16. Subtract one from this and we obtain an offset of 15. Therefore, the data regarding channel P will be found at address:
(PEEK 23631+256* PEEK 23632)+15
(assuming you've just turned the computer on and haven't altered the stream and _ channel associations after initialisation).
If the data in a given STRMS table entry is zero, then it indicates that the stream has not been associated with any channel. On an unexpanded Spectrum, this is the case with streams 4 to 19 after initialisation.
Each entry in the CRT is of the form:
A STRMS table entry points to the second byte in each channel record table entry — hence the need to subtract one before we can use it. This table is at the heart of the Spectrum’s input/output system. If a channel is not able to perform one or other of the I/O operations, then the appropriate address entry in the CRT table will point to a routine in the Spectrum ROM that generates the Invalid I/O Device error message. So for a channel capable of output only — such as channel S — the input routine address entry will point to this error routine. Otherwise, the appropriate ROM routine for output or input will be pointed to be these table entries.
Let’s examine channel P’s entry in the channel record table. Remember that under normal circumstances this is an output only channel, sending data to the ZX printer. The data for this channel in the CRT entry 1s:
++ ++
+ Oe
NSS
st Mp,
The entry for channel S is at (CHANS)+5, and the channel K data is at (CHANS)+0 — (CHANS) is the address held in the CHANS system variable.
By using the OPEN# and CLOSE# commands, we can associate unused streams with one of the channels that we've looked at so far. But the real use of these two commands is to associate streams with other channels in an expanded system, such as those provided by Interface 1. However, we'll take a brief look at the use of these commands without Interface 1 connected. For example:
OPEN #4,"S”
will associate stream 4 with channel S. If you issue this command and then examine the STRMS table, youll find that an entry has been made in the
arate Tetetetatetetete ee erent en OO: SMP aratteteret
Points to GP Print Out routine at address O09F 4
in ROM
Points to error generating routine at address 15C4 in ROM
ASCII code for “P*
position that refers to stream 4. Variables are also allowed in such a statement, such as:
10 LET n=4 20 LET c$="S” 30 OPEN #n,c$
which will perform exactly the same operation as the preceding OPEN command. Once we've opened a channel in this way, the PRINT# and LIST# commands will enable you to send data to the channel via this new stream. So you can add:
40 PRINT #4;“Hello”
which will print to the screen. LIST#4 will list the © program on the screen in the usual way. Ifa stream had been attached to a channel that permitted input as well as output, then the INPUT# command could also be used. These extended PRINT and INPUT statements are only really useful when the additional channels provided by Interface 1 are available — as we shall see later in the course.
Once weve finished with a_ particular combination of stream and channel, and we want to ‘dissolve the partnership’ between them, we use the CLOSE# command. Thus, after our previous OPEN command, a CLOSE #4 command would > dissociate stream 4 from channel S. Once this is done, any attempt to send data to this ‘closed’ stream will generate an error message.
The PRINT#, LIST#, INPUT# and INKEYS# commands can also be used with streams 0 to 3. These streams are effectively permanently open — as you'll find out if you issue these commands:
10 CLOSE #2:REM should close channel $ 20 PRINT #2; “Hello”
No error message is generated — the OS makes sure to open the channel again before passing information to it. Now let’s consider the LIST # command.
LIST #3
is the same, under normal circumstances, as LLIST — the program is listed to stream 3, which as we have seen is usually associated with channel P. LIST #0 and PRINT #0 are quite interesting commands, as these print to the lower part of the screen (which is normally ‘out of bounds’ to PRINT statements). Note that anything printed to this part of the screen will be overwritten when the Spectrum OS prints a prompt or error message. PRINT #3 is identical to LPRINT under normal circumstances.
Finally, it is possible to modify the behaviour of a channel on the Spectrum to make it do something else rather than what it has been initialised to do. For example, channel P is often modified to enable a Centronics printer to be driven by the Spectrum and a suitable interface. If we alter the ‘output routine entry of the appropriate channel record table entry, then LPRINT and LLIST will now send the data to a routine that handles the Centronics printer. Of course, it need not be a printer; it could be an output port or any other output device.
THE HOME COMPUTER ADVANCED COURSE 1333
Hi-Res Print Program
address (which is 65068). You will now be expected to type in hex coding, and this can be
The Program Hi-Res Print given here intercepts data sent along the P channel on the Spectrum and diverts it to a routine that provides the user with a high- resolution print facility. The
For example, the line of code:
listing can be entered using a els0re
standard assembler (CHAMP, would need to be typed in as: DevPac or Picturesque, for
example). If you do not have an . ae
assembler then you will have to FE (ENTER)
enter the hex coding directly, either by using a monitor or the Hex Loader given here. After you have typed in the Hex Loader program and run it, you will be asked to type in the start
When all the code has been entered, type S and the program will finish. You will then be prompted for the checksum (which is 29155), and this will
Hex Loader
10 CLEAR 43999 15 POKE 234658,8
entered only two digits at a time.
indicate whether you have made a typing error.
The new command provided by the program has the format:
LPRINT AT X, Y;“MESSAGE”
where X must be between 0 and 168, and Y must be in the range 0 to 248. The “MESSAGE” can be a string variable or a number. Note that when the string being printed using the new command runs over the edge of the screen, it will ‘wrap round’ but will not move down a line. The X and Y co-ordinates work in exactly the same way as they would for the Spectrum’s PLOT command
17 DEF FN H(H$)=146* (CODE (H#)—48-7% (HS (1)>"9"))+(CODE (H#(2))-48-7% (HE (2) >"9")
) <0 INPUT “Start address "sa 25 LET Z=A 30 INPUT (a), LINE a 30 IF At="S" THEN GO TO 90
40 PRINT a,a#: POKE 23492,255
30 FOR Z=1 TO LEN A%/2
60 POKE a,FN H(la#(((z¥2)-1) TO )):
a=atl
70 NEXT z
80 GO TO 30
90 INPUT “CHECKSUM: ":D
100 LET C=0: FOR B=Z TO @-1: Ek Bs NEXT B
110 IF C=D THEN PRINT
“es STOR
120 PRINT “Oh dear , ect": STOP
Assembly Listing
LET
LET C=C+PE "The code is OK!
the code is incorr
"Make the data tn CHANS point to gure routine”
"Check to see if a haldsan AT contral code"
"Check for end of print data (signified by 13)"
ORG 65048 PIXAD EQU 22AAH UDG ERU 23475 CHARS EQU 23406 5 SA4FS5SC ENABL LD HL, (23631) Q010F00 LD BC,15 a9 _ ADD HL,BC O1ZAFE LD BC,DO-IT Zi LD (HL).c 23 INC HL 70 LD HL) eB co RET ES DO-IT PUSH HL cs PUSH BC DS PUSH DE FS PUSH AF CD44FE CALL DOIT1 F1 POP AF D1 POP DE Ci POP BC E1 POP HL cy RET 3 FS DOIT1 PUSH AF SA1LDFF LD A, (ATFLG) FEOO ep 8 200B JR NZ,GETXP F1 POP AF FE16 ATCH@ CP 22 201D JR NZ,CRCHG SEFF LD 4,255 321DFF LD (ATFLGE),A co. RET FEFE GETXP CP 254 2809 JR 7Z,GETYP F1 POP AF 3214FF LD (XPOSI),A 211DFF LD HL,ATFLG 35 DEC (HL) c9 RET Fi GETYP POP AF 3217FF LD (YPOSI),A 3E00 ip ALO 321DFF LD (ATFLG),A ce RET 5 FEOD CRCH@ CP 13
NZ, VCHR@
FEZO 380C FESO S381C FE9O 3804 FEAS SB04
SE3F 1B10
D&90 210000
SA1LGFF FEF9 D231FF SA1L7FF FEAQ 3078 ED4B1 GFF CDAAZ2 S21AFF 221BFF
SALAFF FEOO CAEGFE
FEOO CAFAFE 13
1A
AC
12
1B 2ZALBFF
SALGFF C4608
UDGCG CP
FCHR LD
PRNIT LD
PRNLP PUSH
ROTLP SRL
5 PUTIT LD
PST LD
ae an
STAIT LD
XPOSI DEFB YPOSI DEFB DFADD DEFW PIXPO DEFB CHRAD DEFW ATFLG DEFB
3 ULINE PUSH
END
3 ERRB
ERRS
DEFB FINIS END
"If the code in ais "it is a UDG code then
C,FUDGC
"For all other codes a ?will be printed"
A, 43 FCHR "Find the data for the
DE,HL HL, (CHARS) HL, DE BC,7 HL,BC (CHRAD) ,HL
between 32 % 128 or if" find its data in memory"
UDG or character in mem"
i
"Check to see that the X& Y positions are valid"
A, (XPOSI) 249
NC ,ERRB
A, (YPOSI) 149
NC, ERRS BC, (XPOSI) FPIXAD (PIXPO) ,A (DFADD) «HL
"Get the first pixel slice ot char being printed"
B,8 BC
HL, (CHRAD) A, (HL)
HL
(CHRAD) ,HL LA
"If the pixel slice doesn’t need moving within"
"the display byte then A, (PIXPQO)
(a)
Z,PUTIT
jump forward"
"Move the slice along in the display bytes to" "the correct pixel position"
B,A H,9O
L
H
A
ROTLP
"Put the slice at the
DE, (DFADD) A, (DE) L
(DE) ,A A, (PIXPO)
HL, (DFADD) ULINE (DFADD) ,HL BC
PRNLP
right screen location"
"Add 8 to-the X positionso that the next char"
"1S printed in a clear A, (XFOST) 8
space"
"If the end of the line is reached go back to"
"the start BUT DO NOT 249
C,StHIT
A,O
(XPOSI) .A
Z4NIDD
PIOPOrws sa imp ra o
ea
"Create various errors"
4
move down a line"
ave the address in HL one pixel up the screen"
SOUND SPECIFICATIONS
begin a new project in Workshop: designing and building a MIDI interface for the BBC Micro and Commodore 64, which will allow them to communicate with many digital electronic instruments. We begin by outlining the MIDI concept and explaining t
The Musical Instrument Digital Interface (MIDI |
specification outlines the hardware and software necessary for a system that allows digital instruments equipped with the interface to communicate with each other. As_ the communication is of a digital nature, we can also introduce a home micro into the MIDI system to control other instruments or to store data in its memory — on tape or on disk. The hardware specification of the interface allows us to build an inexpensive (around £20) and easy to construct,
plug-in circuit board.
Once the interface has been built, the computer can then be programmed to interact with other devices on the MIDI system by writing the appropriate software. We shall be including such listings later in this project.
Since the introduction of the first MIDI specification in August 1983, the electronic music world has been filled with confusion and misapprehension as to what the MIDI interface can and cannot do. This is because the nature of communication between pieces of electronic equipment is of no concern to musicians, most of whom are (rightly) interested only in what a particular system can offer them in terms of musical performance.
In the course of the project we will explain the MIDI specification in terms more familiar to programmers than musicians, and hence provide you with the same basic information that is used by
THE HOME COMPUTER ADVANCED COURSE 1335
equipment designers who intend their products to be compatible with the standard.
First of all, we need to get some idea of the nature of the data communicated by MIDI. It is best understood by regarding the various parts of an electronic music system as computer peripherals. ‘The distinctions between these parts may not be immediately obvious — for example, a typical modern polyphonic synthesiser is really two separate parts, although they are usually contained in the same box. The two components are the keyboard (the input device) and the sound generation circuitry (the output device). The normal mode of operation has the input device connected directly to the output device — depressing a key immediately produces a sound output.
This is a similar situation to that of a sophisticated electronic typewriter, in which the two components — the keyboard and the printer mechanism — can be connected together so that the input data will be immediately reproduced. However, the keyboard and printer are easily recognisable as potential peripherals to a central computer, which will read the input data and process it before sending it to the output device.
1336 THE HOME COMPUTER ADVANCED COURSE
This is, of course, familiar to all of us by now as a word processor.
In the case of the synthesiser, it is important to
note that the (internal) interface between the keyboard and sound generators is purely digital. The keyboard simply acts as a controller for the synthesiser in the same way the typewriter keyboard acts as a controller for the printing mechanism. The link can similarly be broken, with a computer inserted between the two devices, forming a ‘music processor’ system.
The music in this case is not represented as a pattern of air pressure variations (as produced bya gramophone record or compact disc on which the music is digitally encoded), but as a sequence of ‘events’ inputted at the music keyboard and subsequently transmitted to the output device. Itis the function of the sound generation circuits to convert these events into electronic signals that will be reproduced as sound by an amplifier/
speaker system. As a consequence, MIDI
introduces for the first time the serious prospect of non-keyboard controllers, such as string or wind instruments, provided their respective outputs can be made to comply with the MIDI specification.
A good example of a well known, albeit crude,
KEVIN JONES
|
—fi—
music processing system dates back to long before the modern computer age. The pianola was a special type of piano that could play a piece of music recorded as a pattern of holes in a roll of paper. As the paper was rolled through the piano at a constant speed, a sensing mechanism detected the sequence and combination of the holes, each of which represented a particular note. The
_ piano’s mallets then struck the appropriate strings.
Thus the music was encoded on the paper as a sequence of keypress events.
The distance of a hole across the paper represented the pitch of the note, and the distance along the paper represented the time at which the note was to be played. It was then conceivable to edit the music! For example, if a wrong note was punched, it could be located and covered, while the correct note could be punched into the roll. Encoding data in this way has many direct analogies to the first computer data storage systems that used punched cards.
A modern music processor can be seen as an updated version of the pianola system. The paper is replaced by computer memory and magnetic storage media, and the piano is replaced by a synthesiser with a computer interface. Editing is now simply a matter of processing the data in the computer’s memory by means of a suitable program.
Before we can do this — indeed even before we can get the data into the computer — we need to know two fundamental things about MIDI. The first is the type of data transmission used and the second is the format of the data. These two factors correspond to the hardware and_ software components of the interface specification; this instalment will deal with the hardware required for our project.
SERIAL DATA TRANSMISSION The first thing we need to know is how a byte of data is transmitted over the link. MIDI operates as an asynchronous serial interface running at 31.25 Kbaud. This means that only one bit of data can be transmitted at a time, and that the receiver and transmitter are not synchronised to each other by common clock signals. The disadvantage of this method of data transmission is its low speed. However, because the link consists of just two wires, it requires very simple and inexpensive cables and connectors.
MIDI specifies that standard 180° five-pin DIN connectors be used (with three-pin XLR professional audio connectors as an option). This helps keep down the cost of the interface, encouraging its incorporation in_ low-cost instruments.
The main criticism of MIDI is in fact the low serial transmission speed and, as we shall see, transmission delays can become quite noticeable in a large system. On the positive side, however, the transfer rate is low enough for the limited processing speed of home computers to cope.
MIDI data is sent in groups of 10 bits, each
representing one byte of data plus a start bit anda stop bit. The line is normally set at a high voltage (+5v for MIDI) when no data is being sent. The start of a transmission is signalled by the line going low (Ov) for a one-bit period (the start bit). The eight data bits are then sent-MSB (most significant bit) first-followed by a one-bit period at a high level to signal the end of the data. Each byte therefore takes a total of 10 one-bit periods to transmit, which is equivalent to 10/31.25K = 320 microseconds. This is a very important number for budding MIDI programmers to bear in mind, as we shall see later in the project.
When the interface is idle, the line is at a high voltage level. The receiver continuously monitors the line for the first occurrence of a low level — the start bit of a transmission. The receiver then knows that a byte of data is being sent and can set its counter, which counts out one and a half bit periods from detection of the start bit. After this time period has elapsed, the receiver will be half- way through the bit period containing the MSB of the data and can thus reliably detect whether the bit is a one or zero. The remaining bits are received by successively counting seven one-bit periods and detecting the level each time.
Finally, the stop bit is checked for a high level to verify that the data was correctly ‘framed’ by the start and stop bits. Using this communication method, the clocks in the receiver and transmitter need not be precisely synchronised, further simplifying the interface. However, the difference should not be so large as to cause timing errors towards the end of the byte, and so MIDI specifies a tolerance of one per cent on the standard clock frequency.
The interface is relatively fast considering its serial nature (RS232 runs at a maximum rate of 19.2Kbaud) and thus the connecting cables should be a maximum length of 15m to prevent excessively slow rise and fall times.
TRANSMISSION DELAYS
At this point, it is convenient to discuss the fundamental limitation of MIDI — namely, transmission delays between instruments. In general, a note on/off message consists of a total of three bytes. The time taken to send this message is therefore 3 X 320 microseconds = 0.96ms. Now consider the situation of a multi-channel sequencer system where, say, 20 of these messages may need to be sent at one time. This means that the last note of the group is nearly 20ms later than intended. | |
Many sequencers using real-time recording utilise timing resolution down to three or four milliseconds to reproduce adequately the timing nuances of a human performance. Thus a 20ms delay could result in noticeably impaired timing when the recording is replayed.
In a forthcoming part of this series, we shall look at the software of the MIDI specification,and give the meaning of the byte values transmitted over MIDI.
THE HOME COMPUTER ADVANCED COURSE 1337
THE NEW WORLD II
We continue our round-up of the New World simulation game by giving the second part of the complete listing. We also discuss the alterations required to allow the program to run on the BBC Micro
The New World simulation game is written in minimal sasic and as such will run with minor alterations on the BBC Micro. The main alterations that need to be made to the listing given involve the command that clears the screen and the method of pausing for a keypress. Where the command PRINT CHRS$(147) is found in the listing, BBC Micro owners should replace this with CLS.
The code used to await a keypress in the Commodore 64 version of New World (which is the version listed here) involves setting up a loop to GET characters from the keyboard. The loop is terminated when a character other than the null
1338 THE HOME COMPUTER ADVANCED COURSE
string is received. This type of construction occurs in many places within the program listing as follows: j
<line no> GET IS:IF IS=“" THEN <line no>
BBC basic has a special command that has the same effect as the above, but is much simpler. BBC Micro owners should replace occurrences of this construct with the following:
<line no> IS=GETS
Different display modes on the BBC Micro have different memory requirements. In order to
_ release the maximum amount of BAsic memory for
the program, BBC Micro owners should select mode 7. This is the mode automatically selected when the computer is first turned on. However, to make sure, BBC Micro owners may wish to add an extra line at the beginning of the program:
9 MODE 7
SIMULATION GAME/PROGRAMMING PROJECTS
io
Oo
Oo OF. 0 > oF 1°
°
3246 REM EVENT 1 - MAN OVERBOARD! 2698 REM EVENT & - GOOD WEATHER
5542 PRINT © 3855 PRINT
2043 S$=" DURING THE WEEK*" :GOUSUB?166 9866 S#="GO0D WEATHER ALL WEEK#" :GOSUB?1 66
3545 PRINT :GOSUB?266 3865 PRINT: GOSUBY288
32446 S#=" 1 PERSON WAS LOST OVERBOARD#" :GOSUB?146 5870 S#="THE CREW IS FEELING HAPPIER*" :GOSUB?1446 s2498 St=" IN A STORM#" :GOSUBS1 46 5875 GOSUB? 264
5556 PRINT: GOSUBS2aa 3886 S$ $=" AND HEALTHIER! *" :GOSUBS166 Ssso92 St="YOUR CREW IS NOW REDUCED TO*" :GOSUB?1 48 S882 FORT=1TO16
5554 PRINTCN-1; "MEMBERS" GS84 IFTS¢T,2)=6 OR TS¢T,2)=-999THENSSSs
soo8 FORT=1TO146 S886 TS(T,2.=TS¢T,2)+INTCRND( 1d e#119+5
sao? REM SEARCH FOR CREW MEMBER TO LOSE 2388S NEXT
Jo6H LFTSt(T, 2 )=80ORTS(T, 23=-779THENSS45 3887 GOTOSS34@
Saé2 TStT,23=-999:REM DEAD
3964 T=16
Sa66 NEXT
2268 GOTOS536
moe REM EVENTS 2 10 S — PROVISIONS LUST
€ 55/2 “=x-1:REM * NOW POINTS TO PROWISION(C 1-43 sa/74 [TFPACxX3=6 OR PACs o=-899 THENRETURH D788 REM EVENT 16 - LOSE MEDICINE sa74 REM NO ACTION IF THIS PROVISION ALREADY EXHAU S765 IF O4¢1)=6 GR OAC 1 I=—-S9FTHENRETURN STED S16 PRINT Sa°8 PRINT S715 St="YOU DISCOVER THAT HALF YOUR*" :GOSUB?S166 5586 Ss" DURING THE WEEK#" :GOSUBS1 48 S726 St="MEDICINE BOTTLES HAVE BROKEN" : GOSUBS145 5582 PRINT: GOSUBS 2646 DF25 GACLISINTCOACLIY 2) : 52984 PRINT" SOME GF YOUR "sPé¢x> 3736 PRINT: GOSUBS 246 S586 S¢=" WAS WASHED OVERBOARD*" :GOSUBS1 44 5335 St="YOU NOW HAVE ONLY": GOSUBS1 46 So8S PRINT: GOSUBS?2a4 574@ PRINTOAC1):"BOTTLES LEFT" S594 St="OU NObl HAVE APPROXIMATELY" :GOSUB?1 46 5945 GOTOS534 DS92 PACMISPACHKI-INTCPACK IVC INTCRNDC 1) e3)+2)) 5556 REM EVENT 11 — RUSTY GUNS S593 REM REDUCE PROV AMOUNT BY i-v2 1/3 ORI/“4 S955 1F O@¢2)=6 OR O8¢ 2)=-9S99THENRETURN pa°4 PRINTINTCPACZ 4 CCNe PAC 90: 539466 PRINT sors PRINT"WEEKS ";P#¢x)3;" LEFT" 5765 S#="YOU DISCOVER THAT HALF YOUR®" :GOSUBS1a4 oars GOTOSS3o 3778 St="GUNS HAVE GONE RUSTY#" :GOSUB?146
27/2 S$="AND NO LONGER WORK#®" : GOSUBS1 48 3779 OAC ZIS=INTCOAC 2) 2)
S786 PRINT :GOSUBS246
3785 S$="YOU NOW HAVE ONLY#" :GOSUBS1 Bt 3798 PRINTOAC 2) ;"GUNS LEFT"
56a@ REM EVENT 6 — CATCH SOME FiSH 5995 GOTOSS3a 5605 x=6 4004 REM EVENT 12 - LOSE CLOTH 5414 FORT=1TO16 4005 IF OAC4)=6 OR OAC 4)=-999THENRETURN 5615 IFTS¢T,2)=-999THENK=*+ 1 6418 PRINT 5626 REM COUNT DEAD THIS WEEK 4015 S#="YOU DISCOVER THAT HALF YOUR*":GOSUB?148 S625 NEXT 6020 S$="BALES OF CLOTH HAWE BEEN*";:GOSUB?148 5638 IFCN-X%<1THENRETURN 4822 S#="GNAWED BY MICEs" :GOSUB91a0 546435 REM NO ACTION IF ALL CREW DEAD 4024 S$="AND ARE NOW WORTHLESS*" :GOSUB?1 a6 — 5444 PRINT 4625 OAC4)=INTCOAC4) 72) 5645 S#=" DURING THE WEEKS" :GOSUB?148 6038 PRINT: GOSUBS204 S646 PRINT: GOSUB?249 4035 S$="YOU NOW HAVE ONLY*":GOSUB91 68 5650 S#="O0NE OF THE CREW CAUGHT*":GOSUB sia 6448 PRINTOAC4);"BALES LEFT" 5455 X=INTCRND(1)¥*1@)+11 4945 GoOTOSS30 5468 REM 18 TO 28 KILOS 405@ REM EVENT 13 To —- ALBATROSS 5662 PRINTX:"KILOS OF FISH" 6055 PRINT:Ag="¥" 5465 PRINT: GOSUBS2a4 4068 S$="AN ALBATROSS FLIES OVER THE SHIP*" :GOSUBS S674 S#="YOUR MEAT SUPPLY IS NOW*" :GOSUB91a8 100 5475 S$="ENOUGH FOR APPROXIMATELY *" :GOSUB iad 6062 GOSUBy204 5678 1FPAC3)=-9?9THENPA( 3) =8 6065 St="THIS IS A GOOD OMEN=":GOSUB9144 S660 PAC SIS=PACSI+% 6448 S$="AND THE CREW 15 HAPPY*" :GOSUB91a4 5685 PRINTINT( PACS) “¢CN#PN(3))) 3 "WEEKS" 4978 PRINT: GOSUB9206 5498 GOTOSS30 6075 IFPAC3) ¢¢CN*#PNC3)#¢JL-WK+L) ) THENS& 74
4636 REM NOT SHORT OF MEAT
69285 GOTO61 22
44694 St="OU"RE RUNNING SHORT OF MEAT*" :GOSUBS1 66 46°5 St="AND THE BIRD WEIGHS 1@ KILOS! *" :GOSUBY14u 6166 PRINT: GOSUBS 266
6165 St="WOULD YOU LIKE TO CATCH IT?#" :GOSUBS1 66 4116 INPUTI&
S112 PRINT :GOSUB? 246
S115 [FLEFIS¢(1¢,1)="vy"THENSI1 32
6126 St="PROBABLY JUST AS WELL! *" :GOSUB?1 be
2/788 REM EVENT ¢ - CATCH SOME WATER Si22 FPRINT: GOSUBS 246 S765 PRINT : 6125 St="THE ALBATROSS FLIES AWAY....*" :GOSUB?1 44 SiH St=" DURING THE WEEK*" :GOSUB?S1i 46 4136 GOTOSS36 3715 PRINT :GOSUBY 266 6133 IFOAC2)=80R0A( 2)=-979THENS! 36 S726 St="4 RAINSTORM REFILLED YOLIR®" :GOSUBS146 4135 S#="G SHOT IS FIRED... ....ccuaes *" :- GOSUBS146 S725 S¢="WATER BARRELS#" :GOSUB9164 6138 GOSUB?S246 :GOSUBS 244 & S73H PRINT :GOSUBS 244 6146 IFRNDC1)<.5THENS1 56 5735 M=INTCRND(1)*1659+11 6145 S#=".........-BUT MISSES! ©" :GOSUBS1 608 of 35 REM 16 TO 28 BARRELS 6148 GOTO6122 : S746 S#="YOQUR WATER SUPPLY IS NOLJe" :GOSUB?1 44 4156 S$="QND THE BIRD FALLS TO THE DECK! #":GOSUBS1 3°45 S#="ENOQUGH FOR APPROXIMATELY #" :GOSUBS1 44 aa j 3°48 ITFPAC 4)=-9279THENPAC 49=8 4155 PRINT: GOSUB? 266 S756 PAC 4FI=PAC4I +e 46146 IFPAC3)=-?979THENPAS 3) =6 5755 PRINTINT( PACS)“ 0 CN¥PN( 4979: "WEEKS" 6162 PACSI=PAC3)+10:B¢="7" 3°68 GOTOS5S3a 461465 Sé="YOU NOW HAVE 14 MORE KILOS*" :GOSUB?1 46 39368 REM EVENT 8 - GOOD WINDS 6167 St="GF MEAT...... *" : GOSUBS1 406 a PRINT 4176 Sé="BUT YOU MAY NOT HAVE MUCH#" :GOSUB?71 44 St="STRONG FULLOWING WINDS ALL WEEES" :G0SUEF1 4172 S#="GOO0D LUCK FROM NOW ON! !*":GOSUB?146 6174 GOTOSS36 FRIWNT : GOSUBS 2668 4188 Sé="YOU CAN’T - YOU HAVE NO GUNS" :GOSUBS1 44 S$="YOQU HAVE MADE GOOD SPEED*" :GOSUBS1 4b 4178 GOTU61 22 Sé="AND YOUR JOURNEY TIME IS" :GOSUB?164 S#="REDUCED BY 1/2 A WEEK*#" : GOSUB?1 46 EW=EW-.5 GOTOSS36
4568 REM MAJOR CONTINGENCIES
6568 X=INTCRNDC1)#16)+1
45914 ON * GOSUBS6536 6760 ,68604,é6766,7H4H0, 7856 6524 RETURN
THE HOME COMPUTER ADVANCED COURSE 1339
POKE
POKE is a command issued from a high-level language, such as BAsic, which loads an absolute number into an address in memory — usually a register. To implement this command, you type
POKE, followed by an address and then the number.
to be inserted.
POKE is used for a wide variety of functions. One of its principal uses is to perform operations for which there are no corresponding commands in the high-level language. The Commodore 64, for example, despite excellent sound and graphics capabilities, has no BASIC commands to utilise them. Thus, in order to use these hardware features, the addresses on the VIC (video) and SID (sound) chips have to be POKEd with the chosen parameters.
POKEs can also beof use when we wish to enter machine-level language via a high-level language. The machine code will be held within data statements that can then be read and POKEd into the appropriate addresses.
POLISH NOTATION
This is a method of formulating mathematical expressions devised by a Polish mathematician named Jan Lukasiewicz. Polish notation (also known as ‘prefix notation’) places the operator before the operands, for example +xy instead of
. the more familiar x+y. The reason for notating in
Miniature Art
The development of ‘printed circuit’ technology has enabled a far greater track density than would have been possible using
older methods. Because prinied | circuits are designed as artwork
and then photographed onto the board, itis possible to scale the image down to fit the area designated
this manner is that computers operate in the same
way, with the operator (+) preceding the data to be
operated on. Furthermore, it accelerates the process of error checking as well as the operating speed: after decoding the + sign, the computer ‘knows’ that what follows should be real numbers that are to be added. Related to Polish notation is ‘reverse Polish notation’ (known as RPN or ‘postfix notation’ — see page 649), in which the operator is placed at the end of the expression. ‘This system was popular
in early calculators and in early computer
languages, such as FORTH, which were designed to match closely the computer’s internal processes.
POLYNOMIAL
This is a mathematical expression in which a number of powers and multiples, each based around a single constant variable, are added together. An example of a polynomial series is:
5X°4+2X2+2X+8
where the variable X 1s ‘indeterminate’.
Polynomial techniques are widely used in computing. For example, they can be used to code and decode data in order to detect transmission errors.
PORT
This is the connecting socket through which a signal from a peripheral input/output device can be fed into a computer. Although the port is generally connected directly to the computer’s
known as the
1340 THE HOME COMPUTER ADVANCED COURSE
circuitry, the signals may need to be modified before they can be acted upon by the processor. Thus a chip known as a PIA (peripheral interface adaptor) is usually associated with the CPU (see page 1280), and this ‘translates’ signals passing between the processor and the peripheral. The type of functions a PIA chip might perform are converting parallel data transfer into a serial system as well as increasing and decreasing the baud rate of transfer.
Ports are, of course, necessary for a computer to communicate beyond its own circuitry. Ports on microcomputers include RF modulators to support a television signal, and Centronics and RS232C interfaces.
PRINTED CIRCUIT
A printed circuit is the board-mounted wiring pattern used for a particular electrical circuit. It is constructed by etching a circuit pattern onto a
sheet of copper, which is then fixed onto a hard
supporting surface such as fibreglass. Holes can then be drilled through the board into which solid state and other components can be soldered (on the front or back), either manually or mechanically, by dip soldering, to complete the circuit. Often circuits will be attached to both sides of the board with connections made between them. These are known as double-sided printed circuit boards (PCBs).
The invention of the PCB initialised the mass production of electronic devices. It is doubtful that we would have the inexpensive transistor radio, let alone the home microcomputer, without its emergence. However, development of PCB technology has not yet ceased. Modern techniques of etching printed circuits onto plastic have enabled several layers of circuit to be connected together. These methods have made possible the ‘credit card’ calculators that are now available.
E ‘, 4 a . 2
a a 4 ae
4 . a a
o0D4 oe
|| Ore
a
HEX ©
| ADDRESS ~ o _toc
: 0003
‘0007
, 0009 -00F2
: 00F3—00F4 a
| ooFs- ors |
- || oorr-« -O0F8 8 00F9- -00FA
a 00FB—00FE -
_ “orc 00-013E | 0200-0258 ‘| 0259- “0262,
: 0260. 026¢ 611-620 © oe
| 0277-0280
: | 1 Physical Screen Li ne 1. |
_ 6 —
21 7 -242 245-246 | 27-248 | 249-250
ae Free O-Page Space for. a
5i2 cco 601-610 |
621-630
| 631-640 ©
_DESCRIPTION -
| Cursor Column on y Current
Line
bee Editor j in Quote.
_Mede, $00 = 'NO-
Length
ee Cursor Physical
Line Number
emp Data Area _ ‘Flag: Insert Mode, cl.
#- INSTs-
| Gereaa: Line Link Table /
Editor Temps"
. Foe Current Screen.
Color RAM loc.
| Vector: Keyboard siateaes
Table
Rs. 232 Input Buffer
Pointer
| rs. 232 Output Buffer | fi Pointer
Tape | Input Error. oe | System INPUT. Buffer - -KERNAL Table: Active Log-
ical File No’s. 2
| KERNAL Table: Device No. :
for Each File _
| KERNAL Table: Second
Add ress Each File
| lee Buffer Queve
ea