APPLICATIONSDIVERS ★ ★

Multi-Mode (Amstrad Computer User)Applications Divers
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Those with good memories or a large collection of back issues might remember an article titled Events and screen dumps in the March 1985 ACU. To prove what a fast moving industry this is, Cliff Lawson brings you the much awaited follow-up.

There can't be many CPC owners who haven't got a copy of Sorcery secreted about their person somewhere. (Don't you just love double negatives). One of the features that made it such a notable game was the way in which the action took place in a multi-coloured play area while score and status were shown in an area using the more sedate Mode 1 because it offers higher resolution and hence more readable text than the chunky Mode 0.
How many people, I wonder, have been longing to incorporate such a feature into their own programs. What, none of you? Oh well here's a program to do it anyway.

Stolen secrets

Before user club members who were a party to the application notes that used to be produced cry "plagiarist"' this program is indeed very similar to one that appeared in application note. It's OK though. I wrote that, so I think I've got every right to rip-off my own work. (And get paid for it twice? - Ed) I won't bore you with the technicalities of how it works just yet, I'll do that in a bit. I'm sure you would much rather see the finished result.

Now in the past I have used all sorts of different loader programs and loading schemes all of which seem to generate no end of confusion. So to make it as simple as possible there is just one Basic program to type in -Listing I. As always with a program that uses machine code, any attempt to run it will inevitably cause the machine to crash if there is even one typing error (and there is bound to be). So unless you like a lot of typing practice SAVE the program to tape or disc first. Because it is Basic you don't need a complicated SAVE command - SAVE "FRED" will do fine.

In future, assuming you want to use the program again, wind the tape to the right place or insert the correct disc and type RUN "FRED". If all is well you should see the message MODES, INKS and NORMAL now active. If the message DATA error appears then guess what that means -go back and check all those DATA statements. Look out for O (Oh) and 0 (zero) mistyped and B (Bee) and 8 (eight). Spacing is also critical. After the word DATA there should be one space then two digits then one space then two digits and so on along each line.

Once the "active" message appears you should have three RSX commands added to Basic. An RSX command is just like any other except that it has a bar, |, at the front. Users of disc systems or any sideways roms will already be familiar with commands like |CPM, |DISC, |MAXAM and so on. The bar symbol can be produced from the keyboard by holding down ' key.

Try typing INORMAL followed by Enter. This should have the same effect as the command Mode 2. Not very exciting was it? OK try lMODES,2,2,2,2 (don't forget Enter). Now was that exciting? No? Well what do expect from a magazine listing?
Just in case it hasn't, the border should have gone stripey red, orange, yellow, green, blue, magenta and the text should have changed to green on
black. If this hasn't happened then it's check the DATA time again.

Try: |INKS,2,2. The yellow stripe in the border should turn blue. Stripey borders is not the only thing you can do though. First, to set all of the border to black type FOR i=0 to 5:|INKS,i,0:NEXT. Now try |ModeS,0,2,2,1. The top five lines on the screen will become multi-coloured and quite unreadable. This is because the top quarter of the screen is actually in Mode 0, even though the next bit (where the cursor is, is in Mode 2). Move the cursor down the screen till it turns blue. This section is in Mode 1. Try typing a little text. Once again it is unreadable.
Move the cursor back up the screen in to one of the Mode 2 sections and type the command |MODES,2,2,2,2. All the bits which were unreadable have now re-appeared.

Odd behaviour

Basics Mode command will no longer operate exactly as you might expect. Try the command Mode 1. Unlike normal, the screen is not cleared, however the cursor is moved to the top of scren and the word "Ready" is printed in Mode 1 text. Because the screen is still displayed as if it were all in Mode 2 the word "Ready" looks a bit stripey. Type the command CLS. The Mode 2 text disappears and a stripey "Ready" is printed at the top of the screen.

To turn the whole screen to Mode 1 type |MODES,1,1,1,1. The "Ready" and the |MODES command now appear all right.

So the moral of this is that you should always use a Basic Mode command before you start to Print text in an area that is being displayed in a particular mode. The IMODES command is now only used to tell the system how to write characters. If you want the screen cleared use CLS and if you want to change the displayed mode use the new |MODES command.

In case you hadn't guessed it already, the |MODES command is followed by four numbers which set the displayed mode for four sections of the screen.

There are in fact six separate sections (remember the six coloured stripes in the border). However two of the places where a mode switch could be made occur within either the top or the bottom border, so there is no point in having six parameters for the |MODES command.

The numbers after the other new command, |INKS, have the following meaning. The first number is between 0 and 5 and identifies which of the six sections of the screen is to be changed.

The next number sets the border colour and can be from 0 to 26. The numbers for any particular colour are shown in the table on page F3.2 of the 464 manual (or on top of the disc drive of a 664/6128).

The border colour can be followed by up to 16 other numbers which set the colours for pens 0 to 15. If you want to leave the border or any of the pens the same colour as before then give a value greater than 26 (I use 99).

To show how UNKS can be used to change pen colours first, well make the six sections visible again by turning the border stripey. Type FOR i=0 TO 5:|INKS,i,i*4:NEXT. You'll see a black stripe in the top border and a pastel yellow stripe in the bottom border. The mauve, cyan, orange and bright cyan stripes show the four areas that are affected by the |MODES command.

Now type Mode0:lMODES,0,0,0,0: CLS. That will do everything that just Mode 0 would have done before. Now type PEN 2 and the next turns red. Type FOR i=0 TO 10:PRINT "hello":next.

All those "hello"s are printed in pen 2 and are therefore all red (because the ink for pen 2 is set to red).

Try |INKS,2,99,99,99,19 - some of the "hello"s in section 2 will turn sea green. This is because the ink for pen 2 in section 2 has been set to 19. If you type |INKS.3,99,26 the background in section 3 will turn white.

Help!

When everything gets really confused or you want to switch back to normal it's time for the third new command, |NORMAL.
If you just type this on its own the screen is put back to normal in Mode 2. If you follow it with either 0 or 1, the screen is reset into that mode. For example, |NORMAL, 1 will put things back to normal in Mode 1.

Pork pies

Although I said there was only one Basic program to type in, I lied. There is a second relatively simple demonstration which shows several of the things that can be achieved with the RSXs. Type it in, SAVE it and then RUN it and count how many different coloured squares there are (and you thought there could only be 16 !). The editor is bound to delete this bit, but I'll assume there might be a handful of people who are interested in how this mode/palette switching works.

The boring bit

In computing terms the length of time taken to scan a complete screen (l/50th of a second) seems like an eternity. Humans see what looks like a constant picture although it is being changed once every 50th of a second.
Now every 300th of a second the processor gets an interrupt that reminds it to do things like updating the clock, and every now and again to give the keyboard a quick scan. It can also run one of your own routines once every 300th of a second if you ask it to nicely.

I'm sure it doesn't take Einstein to work out that your routine (once every 300th remember) will actually be run six times during the lifetime of one frame on the screen (one 50th).

If this routine tells the hardware to change the scanning of the screen memory to another mode or with a different palette of colours, this change will become apparent at one of six points on the screen.

For the budding assembler programmers among you, the source code is given here. This will allow you to see how it all works and modify it to your own needs. For instance, if the address I have picked for the code (#A000) is too high for your requirements the code could be reassembled with a different ORG. There are liberal comments which should make its operation pretty self-evident.

Basically, to let the operating system know that you've got a routine to be run on the 300th second tick, you pass its address to a firmware routine- at #BCE0 called KL—NEW—FAST-TICKER.

In this case the routine keeps a count of which section it is in (in a variable called section), uses it to look up a list of the modes for each section (a list called modevec) and switches to the desired mode.

It then multiplies the section number by 17 to give an offset in a table called ivecs. This contains six lots of 17 bytes where the first byte in each is the border colour and the next 16 are the pen colours. These numbers are hardware colour numbers (not the grey scale numbers that most people are used to). When they are first entered a routine called convert is called to translate from grey scale to h/w numbers.

The modes command modifies the list of modes (modevec), removes any pending ticker events then adds a new ticker event using the above routine.
The |INKS command does nothing more than modify one of the six entries in the ivecs table. It calculates the necessary offset then converts each parameter before moving it into place.

And that's all there is to it. I can't for the life of me think of any practical application for all this, but it's quite pretty and I'm sure youH think of something.

Amstrad User January 87

★ PUBLISHER: Amstrad Computer User
★ YEAR: 1987
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LiCENCE: LISTING
★ AUTHOR: Cliff LAWSON

★ AMSTRAD CPC ★ DOWNLOAD ★

Aucun fichier de disponible:
» Vous avez des fichiers que nous ne possédons pas concernent cette page ?
★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Multigraf/v5 (Amstrad Manía)
» Applications » Multiface Cat (Amstrad Action)
» Applications » Multicopy
» Applications » Multiface to Amsdos Screens Converter (CPC Attack)
» Applications » MultiRam (Amstrad Action)
» Applications » RSX Multicol (CPC Magazin)
Je participe au site:
» Pour ce titre nous ne disposons de fichier executable sur CPC (Dump, Saisie du listing) , alors si vous avez ça dans vos cartons ou vous désirez usé vos petit doigts boudinés sur votre clavier faites le nous savoir.
» Vous avez des infos personnel ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 410 millisecondes et consultée 1800 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.