Previous column ComputerAnswers
Next column ComputerAnswers
ComputerAnswers Column 4
COMPUTER ANSWERS APRIL 1985
Copyright 1984-1989 Simon N Goodwin
GRAPHICS AND TEXT
I am a CBM 64 user and have been exploring the machine's graphics. I can handle sprites and hi-res but I have struck a problem - I don't know how to mix graphics and text. I have many books and not one of them mentions how this is done.
P. Feely, Houston, Renfrew
There are two popular ways of designing the display of a computer. In each case an area of memory is reserved so that it contains a representation of the screen display. This area is commonly called 'video memory'.
In the first case, character mapping, every time you change one of the values stored in the video memory a character on the display changes: from a space to an asterisk, for example, or from one letter to another, depending on the valu concerned.
In the other case, a change in video memory causes a much smaller change on the screen: a dot on the display may change colour, or a few dots in a row may be altered. This system is called 'pixel' mapping (a dot on the screen is technically known as a picture element, or pixel) or 'hi-res' - the term 'high resolution' implies that small changes can be shown, or resolved.
The Commodore 64 can use either character or hi-res mapping. Character mapping is used for listings and simple business programs - it has the advantage that it is fast (since one change in video memory changes a whole character, not just a few dots) but it is not very flexible since - generally - you are restricted to a maximum of 256 different character shapes on the screen at a time.
It is hard to produce attractive moving graphics with character mapping, since you it doesn't allow you to move a character smoothly from one position to the next - a symbol can be in one position, or the other, but not midway between the two. You can get around this limitation to some extent by defining a pair of characters, each containing one side of the symbol you want to move, but you reach the limit of 256 distinct characters quite quickly.
When you switch to pixel mapping things become much easier. Each bit (or small group of bits, depending on the computer you're using) in the video memory controls one dot. Thus, to move a dot from one place on the screen to another you just change - and restore - successive bits in the video memory. If you want to move a line, you change and restore the value of a group of bits, once again moving steadily through memory.
Pixel mapping gives you fine control but it uses a lot of memory, since the computer must store the status of every dot, rather than every character. The big bonus is that you can make use of arbitrarily complicated shapes - musical notes, or gothic letters, for example - by setting and resetting groups of dots.
A character is nothing more than a group of dots on the display, whether it is produced using character or pixel mapping. In character mapping the computer just assembles the group for you, using some electronics and a table of dot values called a FONT.
For instance, the equals sign might be displayed using eight lines of the display. In the font there would be an entry for each line. The first three lines would be represented by 'OFF' values, then would come a line of 'ON' values, then a line of 'OFF' (for the gap between the two horizontal bars in an equals sign) then another line of 'ON' values and two 'OFF' lines. The exact number of lines in the font for each character will vary from one computer to the next, depending upon the level of detail with which characters are displayed.
To print text on the hi-res screen you must explicitly set each dot of every character you wish to display. This is a chore - you'll need to make a table of values for each row in a character, and then set the dots one by one. This is too slow for most purposes from BASIC, but it can be done quite quickly from machine code - indeed the display circuit in the Acorn Electron can only use pixel mapping, so characters must always be printed by setting groups of dots, yet the machine will LIST and PRINT very quickly.
If you're very clever it is possible to switch the computer between character and pixel mapping as the display is generated, giving you one area of text and another of hi-res graphics. Unfortunately there's not room here to explain such a trick, but if the idea excites you, you should investigate the workings of 'raster interrupts' (a raster is a display line) by reading one of the books on advanced Commodore 64 machine-code.
EKING OUT AN APRICOT
I have an Apricot Xi with 10 megabyte hard disk and 256 kilobytes of RAM. I want to expand the Apricot to increase the RAM, and I would also like to get an internal modem board. Unfortunately the hard disk takes up one of the two expansion slots on my machine.
Although I could use an external modem, I sometimes take my Apricot home, and in any event a built in modem is more attractive, smaller footprint etc. Is there any way in which I could expand the RAM without using up an expansion slot?
My father has an Apricot with 256 kilobytes of RAM, two single sided floppy disks, a 512 kilobyte RAM expansion board, and a built in modem. He now wants to add an external hard disk. Is there any way that he can do so? His RAM expansion board and the built in modem board are using up his two expansion slots.
Is there a product that could increase the number of slots available for expansion?
J. Elman, London W11.
It sounds as if the pair of you are engaged in some kind of technological race! ACT, the makers of the Apricot, have produced an 'Expansion Box' which is designed to provide extra slots for the new F1 system. It should work with your father's floppy-based system but - according to ACT technical staff - it is not compatible with hard disks, and there are no plans to remedy this problem. It seems that you have reached the practical limits of expansion for an Apricot system, unless you get out a soldering iron and start re-designing the machine.
If you want to take that approach, your best bet is to add extra memory on the main processor board, in addition to the 256K already there. This is not, in design terms, a very difficult task but you'll invalidate your warranty and you could run into problems providing sufficient power to keep everything going at once.
Unless you're very skilled, or know someone who is, I'd recommend that you opt for an external modem and use your two expansion slots for the hard disk and extra memory. This may be less aesthetically pleasing, but it's more likely to work.
In the December issue of PCW there was a financial program by Mr. J McCartney. This is the sort of program I have been searching for for ages, never finding exactly what I want. Unfortunately my brain is only conversant with Sinclair Basic and as hard as I try I cannot translate the program. I don't expect anyone to translate the whole program, but would it be possible to supply the formulae that have been used in all twelve calculations?
W.Wallis, Taylor Hill, Huddersfield
Jim McCartney's program was written for the ACT Sirius; it's a shame that it used quite a lot of idiosyncratic commands, especially in connection with display handling. As you suggest, it is not worth translating such a program line by line - you just get bogged down trying to convert parts of the program which aren't really important. The key routines are between lines 30,000 and 41,000 - you will obviously need to alter the line numbers to fit the program into your Sinclair computer.
Those routines should work in Sinclair Basic if a few small changes are made. Many of the variable-names are followed by 'pound' signs. These tell the Sirius to use double-precision arithmetic, and should be missed out on a Sinclair computer, which always uses a level of precision mid-way between that of single and double-precision on the Sirius. The circumflex signs in line 30,040 and elsewhere should be typed as upward arrows on the Spectrum: press Symbol Shift and H. Type 100 in place of C%.
The rest of the program is rather verbose, and is concerned mainly with keyboard and display handling. In essence the only subroutines you need are those at line 1000 (to read input values into the array IN$), line 600 (to print the value of the answer, A) and line 800 (to process inflating withdrawals). You'll also need to set up FN I, which is defined in line 20050; again, type 100 in place of C%.
#Once you've got those routines working you're best advised to add your own 'bells and whistles' to make the program user-friendly.
BBC DISK DILEMMA
I have been the owner of a BBC 'B' since it was first launched onto the market, but I must confess to being one of those people commonly referred to as 'computer illiterate'.
I am trying to upgrade my computer with disk drives, a sideways ROM expansion board, and perhaps at a later date a second 6502 processor.
I am undecided about which disk interface to buy. Will I also need to buy a disk filing system when I buy a disk interface? Is there any difference between the two? After reading several reports on double density disk interfaces I would hope to purchase one of the said interfaces as it appears to be a sensible upgrade. However, which double density interface is compatible with the tube and the ROM board. Are Acorn intending to launch a double density disk interface, and if so, is it worth waiting for?
S.Rawal, London N3.
A disk system consists of three components. First, you need the drive, to spin the disk around and detect the data recorded on it. Drives are made by a number of manufacturers, to a standard design developed by an American firm called Shugart.
Then you need a controller, to tell the disk when to start and stop and act as an electronic link between the drive and the computer. The controller determines the precise way data is recorded on a disk - the number of bytes a disk can store on a given track, for example.
Finally, you need some software to tell the controller what to do - obviously the software will vary depending upon the type of controller you've chosen. This software is called the DFS, or Disk Filing System - it keeps track of the bytes on the disk so that you can load and save files without having to worry about exactly where on the disk they are recorded.
Disk drives are fairly standard, although the precise mechanical design and speed may vary between models. There are basically two types of disk controller. With a single density system, each bit of information is stored as an ON signal, followed by an OFF. Double density systems store each bit as a change - from ON to OFF, or vice versa. This gives tighter packing, but it is harder to control. The timing of bits determines whether the value recorded is a '1' or a '0'.
When Acorn designed the BBC Micro they made a point of using 'proven' technology, though the design itself was quite advanced. Back in 1982 the standard component used to control disk interfaces was called (in the usual unimaginative fashion) the 8271. Even then there were a number of newer, more sophisticated devices available, but Acorn opted for the tried-and-tested 8271: a single density component.
After a while the 8271 became obsolescent, expensive and hard to obtain, as more modern devices became the market leaders. Acorn persisted in using the component, leading to a shortage of disk interfaces and a relatively high price.
Other manufacturers stepped into the breach with interfaces using newer, cheaper chips. Some of these could use double density recording to pack extra data onto a disk. The new devices can generally read and write using the old single density system if required. So far as we know, Acorn have no plans to produce a double density system, for reasons which we explain later. Anyhow, it doesn't seem a very good idea to wait for Acorn to produce anything - in the past they have not been particularly punctual in their supply of new products.
In performance terms a double density disk interface is a good buy, especially if you write your own programs. You get almost twice as much information on a given disk and drive, with (in my experience) no loss of reliability.
You'll need a special DFS which will be available from the supplier of the interface - a controller is fairly useless without an appropriate filing system. But problems may appear if you use a double density system to try to load some commercial software which has been 'protected' against copying.
In principle, protected software is recorded in a non-standard way, so that parts of it can only be read from within the program - not by the DFS or a 'disk copier' routine. Since protection involves using techniques unavailable to the DFS, it can only be achieved if the software communicates directly with the disk controller... but, as we said earlier, the exact workings of a controller will vary from one model to the next, so different software (normally the DFS) is needed to use each model.
Many popular programs, such as Elite from Acornsoft, are protected against copying in this way. You can't use Elite unless you've got an 8271 controller, since the program tries to communicate with it directly, and other controllers don't recognise the 8271 instructions. The best solution is to get a system which contains two controllers - an 8271 and a double-density model - but this is expensive and can still leave some incompatibilities.
There's no reason why your disk controller should interfere with the workings of a ROM board, sideways RAM, or second processor, but it is always best to get the vendor to demonstrate an add-on working in harmony with the rest of your system, just in case.
AGE OF AQUARIUS?
I would like to know if any books on the Aquarius computer system are available, as books and software for the Aquarius seem to be as common as ZX-81's with colour.
Can you tell me if it is possible to use the games paddles in your own programs? Are they only able to be used in cartridge games?
The only book about the Aquarius that we can trace is 'The Aquarius and how to get the most from it', written by the ubiquitous Ian Sinclair. It's published by Granada Publishing (01 493 7070) and costs about six pounds. Hopefully information about the paddle controls will be in the book, since they are not mentioned in the computer's manual.
If you're still stuck after reading the book, try printing the value read with the IN function, using parameters between 0 and 255. Look for a parameter value that gives a changing result as the paddles are manipulated. The paddles are almost certainly port-mapped, which means that they will be connected in such a way as to alter the value at a given port as they are adjusted.
IT'S NOT WHAT YOU'VE GOT...
I am seriously considering buying my family a 'basic' computer costing about 200 pounds. My wife has recently undertaken an evening course which consists of micro processing in its initial stages. She will almost certainly get up to a standard where she is able to write a straight-forward program.
My eldest son of nine has used models such as the Commodore 64. I feel a machine could be useful to him for the future. The school he attends has a BBC Micro and consequently my wife wishes to make the purchase an Acorn Electron.
Finally I have other, younger children and would like to think that the item purchased would be able to be extended so as to cope for the next three to five years.
With so many machines on the market and the pressurised selling and advertising they are being given I feel that expert help in making the right choice is essential.
M.J.Moore, Luton, Beds.
This letter is typical of many we receive. In practice most people will no doubt have gone out and bought a computer before they read our reply, but - in view of the regularity with which such questions arrive - some general points are in order.
Home computers are much of a muchness. The difference between having a computer, and not having one, is much greater than that between models, even between those which differ wildly in price. Much of the 'pressurised advertising' you refer to appears for exactly this reason - if the manufacturers didn't shout loudly about the quirks and special features of their own machines, first-time buyers might catch on and realise that there's not much real difference between models.
The advertising is really aimed at second-time buyers, who are more selective than beginners. Home computing is still a fashion, and surveys which estimate that the market is saturated ignore the fact that most enthusiasts are collectors - as the price and power of machines change they buy a new model and keep their old one because its resale value would be small. Fashions change, though the real power and attraction of computing may not. Computers are also like puzzles, in the sense that people buy them, learn all about them, and then buy another to analyse in the same way.
To make the point by analogy, there's more variety among modern four cylinder four wheel cars than there is in eight bit home computers (a set which includes all the home machines up to a price of about 400 pounds). As with cars, you get roughly what you pay for. When you buy your first car, the need to get from A to B - regardless of style - is paramount; later you take an interest in turbochargers, auto-reverse cassette players, nodding dogs and furry dice.
The Acorn Electron has the same Basic as the BBC Micro, and this is a superficial advantage of the machine. You should bear in mind that the vast majority of computers use differing versions of Basic; your family will have to learn how to cope with a variety of 'dialects' sooner or later, so precise compatibility with the language used at school may not be important. Microcomputer Basic's have a lot in common, and the move from one to another is educational rather than traumatic - it will certainly demonstrate the advantages of standardisation to your family!
It doesn't really matter which computer you buy, in your chosen price-range. They are all reasonably well supported by books, magazines, add-ons and recorded software, although the Spectrum and Commodore 64 score especially highly in this regard. The link between the Acorn machines and schools means that plenty of educational software is available for the Electron - but much educational software is rubbish.
Go out and experiment with a few machines in High Street stores. Beware of very old and very new machines, which may not be well supported in future years. Any machine that has been extensively advertised in the past is likely to have a reasonable long-term following.
It's a good idea to choose a machine that you can easily return if it breaks down. A very large proportion of home computers break down in their first six months of use, but if a computer survives this period it is likely to go on working for a long time - computer components are very reliable once you've sifted out any which were defective in manufacture.
You should consider buying a second-hand computer unless you're desperate to keep up with the Jones's. An older computer will have gone through the 'burn in' period safely and will be sold at a bargain price, often with a 'redundant' collection of books, magazines and programs at no extra charge.
To find out more, go along to your local computer club and talk to people there. They will be helpful, eager to demonstrate their machines and let you experiment with them. They will also be ridiculously partisan - remember the motoring analogy. Enrol on your wife's evening course. Buy your computer from someone who seems to understand the machine, whether a shop assistant or an enthusiast. And don't worry, because it's almost impossible to make a bad choice.
Link to the top of this document
Link to the main index
Previous column ComputerAnswers
Next column ComputerAnswers