Screen Editor And Mode Changer|Amstrad Computer User)Applications Creation Graphique
★ 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 ★ 

Dick Sargent sorts out some screens to make conversion easier

THE Amstrad screen - the Video-ram, not the monitor - is a fascinating piece of the computer, and never more so when you have inadvertently loaded a Mode 0 screen picture into a Mode 2 screen or vice-versa.
The kaleidoscope or black-and-white venetian-blind effect reminds you that you've gone wrong and it's a case of typing Mode 2, 1 or 0 and reloading the file. Strangely enough, some screens are acceptable when seen in the wrong mode.

The program in this article is designed to let you play around with screen artwork with a mini-editor, change modes without destroying the screen's contents and convert between modes so that, for example, a piece of artwork drawn in Mode 2 will be able to exist on a Mode 1 screen without looking strange.

Why convert between modes? Well, you may have a superb screen designed in Mode 1 to which you would like to add lots of text. If the design is strong, you can lose two of the screen's four colours, pop it into mode 2 and add reams of Mode-2 text.

Alternatively, you may want to add a splash of colour to a Mode 2 design by adding (in Mode 1) extra colour details. Or, if you're really feeling adventurous, you may want to merge one screen on to another - and to do that both screens must be in the same mode.

The mini-editor works on screens residing at their normal address of &C000, but it keeps a copy of the screen in RAM at &4000. The program starts up in mode 2 and asks for a screen-file to be loaded from tape or disc. The screen loaded may not match the mode and if that is the case the result will look wondrous, weird or just plain silly.

It is for this reason the program asks you which mode the screen should really be in. If you are uncertain, try any mode at random. If the picture still looks wrong try another mode - you'll get it right by the third attempt. Ail experiments use the original screen from &4000, so you don't need to wait while the screen reloads.

Colours are set when the mode is chosen. Mode 0 inks are set to the Amstrad default values, except inkl4 and ink 15 which usually flash. Mode 1 inks are set to white, grey, red, black and mode 2 inks are set to white and black. You can change these colours if you wish by altering lines 290-300 in the Basic listing.

When editing a screen, the command B allows you to backup your efforts into RAM at &4000. This should be done frequently so that, if any editing disaster occurs, the backup screen can be reclaimed from &4000 using command T. Whole screens can be saved to tape or disc by the command S and even back-up work at &4000 can be saved, should that ever be necessary.

Changing mode 1 artwork to appear in a sensible form on a mode 2 screen is an exercise which can have a high success rate - it doesn't take too long to

decide how the four inks of a mode 1 screen should be changed into the two inks of the mode 2 screen. Converting mode 0 to mode 2 involves reducing 16 colours to two and is not always possible.

The mini-editor therefore only has a set of machine-code programs tailor-made for Mode 2-Mode 1 conversions -you can use them for Mode 1-Mode 0 conversions but the results are not predictable.

Tackling the impossible

There are 640 dots across a mode 2 screen on the X axis, and each dot or screen "pixel" relates to a single bit in the Amstrad's screen memory (VRAM). Mode 2 is therefore the straightforward screen mode.

Mode 1 gives 320 pixels and mode 0 gives 160 pixels across the screen and all text and graphics produced on these screens looks chunky. All modes provide 200 bits up the screen on the Y axis, but the computer's video chip plots each bit twice so we see 400 pixels and the Amstrad manual likes to pretend (for reasons of screen symmetry) that the Y axis runs from 0 to 399.

We, the humble computer users, are seeing "pixel-stretching" on the Y axis and it happens in all screen modes. Stretching is also used on the X axis, but only in modes 1 and 0. Basic isn't troubled by any of these stretching techniques and this makes it extremely easy to write a graphics screen editor which works on any screen-mode artwork.

The cursor happily glides across the screen on the imaginary grid of 0-399Y 0-639X, ignorant of the fact that the mode 1 screen has only 320 plot-able points and the mode 1 screen has just 160 plot-able points on the horizontal axis. Machine code, however, needs to know the truth and nothing but the truth.

For the curious, the machine-code represented in data lines 500-715 disassembles easily enough, but anyone following it will need to know the composition of a mode 1 VRAM byte. It is ABCDabcd, where A is bit 7 and d is bit 0. Bits Aa give the colour of plot-able point 0. Bb does the same for point 2, Cc for point 4, Dd for point 6.

Note that mode 1 doesn't admit the existence of odd X-axis points and that mode 0 likes to ignore three out of every four X points! Converting between modes involves sorting that lot out.

Changing down

Changing gear from mode 2 to 1 involves losing every other X point along the 640 length of the mode 2 screen. Command U performs the conversion by losing the odd points while command V does the same conversion but loses the even points. You can't predict which command will give the better result, so try them both. Don't forget the editor works on the image in the &4000-ram area, putting the result in &C000-video RAM.

As with all conversions and the merge routine, the computer will bleep when the complete conversion is in VRAM. Press N for no if you don't like what you see. The image will not be saved and the editor's cursor will appear on the screen. You may then edit the image, recall the un-converted picture from &4000, or load a new screen from tape or disc.

If the converted image is OK. then press Y and the image will be saved. The program then goes into edit mode. If the first key you press in edit mode is B, then the screen image will pass to &4000 before the picture is spoilt by the X-Y coordinates window.

Changing up

When you change up a mode, you gain plot-able points but lose colours. In order to reduce the number of colours in a mode 1 screen, a fair amount of machine-code trickery is needed. Rewording the INK command in Basic doesn't work. Thus INK 0,0: INK 1,26: INK 2,0: INK3,26 isn't sufficient - yes, the colours will change on the screen (giving a black-and-white screen in this example) but there will still be four INKS encoded in the computer's video RAM.

All that Basic has done is change a few values in the video-controller chip register, thus operating a fast colour-change technique known as palette switching - it hasn't so much as peeked at the video ram, let alone altered it.

A machine code routine is needed which looks at every byte in VRAM and changes any unwanted ink (specified as a number 0-3), into the paper ink or the pen ink (also specified). There are 16k bytes to look at, and encoded in each byte there are four inks for four pixels, so to change an ink in VRAM takes 65,536 separate operations. On the screen you can see the change take place in about two seconds.

The commands needed to reduce the number of inks are H. I, J and K. First use the comand H to designate which of the four inks is to be paper-ink. Next use command I to designate which of the three remaining inks is to be the pen-ink.

At this point you can colour-edit, or let the computer take over. The computer will convert to mode 2 by keeping your choice of PAPER and PEN, and shading the third and fourth INKS (whatever colour they may be) into two stipple patterns.

The problem is that the stipples will look pretty much the same, -so effectively the "third and fourth INKS will become a single shade. To see whether this will look acceptable, press the preview command Z. The screen will stay in the mode it is in, but the INKS that would have been stippled change to a third colour.

If this is satisfactory, press X to do the real conversion. If it isn't acceptable, recall the screen you're working on with T and tackle the problem manually using H and I again, or by using J and K to physically remove one or more inks.

The merge

The screen merge routine uses the OR method of merging pixels from one picture onto the pixels of another (refer to ink modes in the CPC manuls for further details on methods of combining pixels). A straightforward merge (that is, without stopping to edit anything on the way) would be to load the first screen with a G command, then immediately use the A command.

The second screen will load to &C000 (not to &4000), then the first screen will be merged on to it. As usual, a bleep will prompt for the Y/N response, and the result can be saved or edited in the usual way.

The editor

The graphics screen editor is used for tidying-up a screen of artwork, adding pixels and erasing them, adding or erasing captions and drawing lines. The X-Y coordinates of the cursor are shown at all times in a top-of-screen window.

Note that this window only finds its way on to the screen image at &4000 if you use the back-up command B. Mode 0 screens are given an additional bottom-of-screen window so that prompts and input can be more easily read.

  • A merge one screen on to another
  • B Back-up a picture to &4000
  • C plot a Character string
  • D draw a Dot (single pixel)
  • E Erase a dot (single pixel)
  • G Get a screen from disc/tape
  • H designate which ink is to be the "paper"
  • I designate which ink is to be the "pen"
  • J force an ink to change to the paper ink
  • K force an ink to change to the pen ink
  • L draw a Line from the cursor to the Mark
  • M Mark cursor position
  • O Over print character string
  • P Print a rectangle in pen-ink
  • R Rub-out (prints a rectangle in paper-ink)
  • S Save (whole screen) to disc/tape
  • T Transfer a picture from &4000
  • U convert Upwards eg:to mode 1
  • V convert upwards (alternative to U)
  • X convert downwards eg:to mode 2
  • Z preview
  • 0 view in mode 0
  • 1 view in mode 1
  • 2 view in mode 2

Figure I: Editor commande

The edit program is as short as I could make it and my apologies for the lack of REM statements. A few comments here will allow you to unravel it. GOSUB 270 (in line 120) starts the ball rolling by asking for the first screen which must come from tape or disc. The option of a blank screen is not given: This is not a drawing package so a clean sheet of canvas is not much good to anybody. You can always load a previously created blank screen.
Program lines 130 to 165 are the program loop. INSTR is used to interpret the key presses and the correct command is thus selected from the list of subroutines in line 140. Lines 1805-215 keep the cursor from wandering off the screen, while two GOSUB calls to line 175 actually draw the cursor.

Each command has its own subroutine, each of which is very straightforward and does things such as draw and write on to the screen.

However, be warned, once run this program can lead to mode madness.

ACU #8712

★ YEAR: 1987
★ AUTHOR: Dick Sargent


Je participe au site:
» Newfile(s) upload/Envoye de fichier(s)
★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

» Applications » Dessin (CPC Infos)
» Applications » CHR-Editor: Editor de Carateres (Mundo Amstrad)
» Applications » Mini - Movie
» Applications » Funktionsplotter TurboPlot
» Applications » Sprite Designer
» Applications » Aide à la Redéfinition (Amstrad Magaznie)


L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!

CPCrulez[Content Management System] v8.7-desktop/cache
Page créée en 087 millisecondes et consultée 847 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.