APPLICATIONSCREATION GRAPHIQUE ★ Speed your grand designs ★

Pattern Fill (Computing with the Amstrad)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 ★ 

IAN SHARPE's pattern fill packs power into your grapnics

TO make up for the lack of a fill facility on the CPC464 several routines have appeared here

and elsewhere, but all have one drawback - they only fill an area with a single colour, which hardly exploits the Amstrad's potential.

Now you can put some life into the graphics of any model of CPC with this enhanced routine which fills an area with a pattern of your own design. You can get superb results with this utility and it will become an essential part of your graphics toolkit.

Type in, save and run Program I. Move the graphics cursor to a point within the shape to be filled (use the MOVE command) and to fill the area:

CALL &9000,pw,pd,@pat$

where pw is the width of the pattern in pixels, pd is its depth and pat$ contains the pattern as detailed further on. Note the @ before pat$ - it is essential on the CPC464 but on the CPC6128 you can omit it or even call the routine like this:

CALL &9000,2,2,"1221"

As mentioned earlier, filling starts at the current graphics cursor position. The first thing the routine does is to look at the colour of the screen at this point. It will then fill all points connected vertically and horizontally until it meets another colour.

The fill pattern is stored in pat$. Ideally it would be stored in a rectangular array, but I couldn't find a simple way of passing this to a machine code routine short of poking its contents into a known area of memory. This would be slow, and not particularly convenient.

Imagine a pattern in a rectangular block composed of individual dots (or pixels), each with an ink number. In Mode 0 the maximum ink value is 15, in Mode 1 it can range from 0 to 3 and in Mode 2 it can be either 0 or 1.

As an example, let's assume the pattern to be two dots wide by three high. To store the pattern in a form that can be passed to the machine code, we write down the ink values of the dots in the top row followed by the values for the second and third rows, giving a list of six numbers.

So using the default colours when you switch on, if the top row was coloured yellow, red, the second row red, blue and the third yellow, blue pat$ would be 133212.

Follow that through - pen 1 is yellow, pen 3 is red, pen 3 again, pen 2 is blue and so on. If you're working in Mode 0 and want the inks 10 to 15 you must use hexadecimal format. In other words 10 is A, 11 is B up to F which is 15. Now all you need to do is:

pat$="133212" :CALL &9000,2,3,@pat$

If that sounds a bit too much like hard work, never fear, Program II is a utility to let you plot your pattern on a grid and generate the string afterwards. It's the minimum required to get you going and isn't too difficult to develop and improve. A string can be up to 255 characters long, but to keep things simple this designer only caters for 15 x 15 dots.

The first thing it will do is prompt you for the screen mode - 0, 1 or 2. Then you'll be presented with a box containing a flashing cursor which can be moved about with the arrow keys. Press the spacebar to plot a point and use Shift plus the up and down cursor keys to change the plotting colour.

If the box is bigger than your pattern, make sure you plot from the top left hand corner working to the right and downwards.
Press Tab to finish editing. The next thing is to remove superfluous space to the right and below the pattern if it is smaller than the box. To this end, you will see flashing horizontal and vertical lines. Move them around with the cursor keys to a position where the area to be saved is above and to the left of the lines.

When you've done that, press Tab again. Now you'll be asked what you want to call the string - remember to type in the $ symbol after the name -for example fred$. This is going to be written as a two or three line program to a file so you'll be prompted for the first line number and the filename.

A line can be a maximum of 255 characters, so if the string with its name and line number is too long it'll be split on to an extra line. Also, the width and depth of the pattern are written to a REM statement. These lines can then be added to your own program by loading it into memory and using MERGE"filename"

Writing a pattern fill presents more problems than for a single colour. This routine is quite fast because it bypasses the firmware and deals directly with the screen memory. The price for this and keeping the program a manageable size is that there are a few rules and restrictions on how it can be used:

  • The graphics origin should be at 0,0.
  • The routine works in any mode but must only be used when the screen hasn't been scrolled since switching on or the last Mode command.
  • It doesn't check for the edges of the screen and will have unpredictable results if you don't make sure there's a different colour surrounding the area to be filled. It won't crash your machine if it leaks out but it will create a mess which will be rather difficult to tidy up.
  • The main difficulty is when the background colour of the area to be filled appears in the pattern. It's very easy for the routine to lose track of where it's up to and get stuck in a loop trying to fill areas it's already covered.

To avoid this you must obey a simple rule: At no point in the pattern must the background colour appear in a column of two or more pixels -remember the top and bottom rows fall next to each other when the pattern is repeated.

Be warned, if you ignore this your micro will lock up when you attempt a fill and the Escape key is not checked
for. If in doubt, make sure you've saved everything before trying it.

You may also encounter this if you define a pattern in say. Mode 0, using colours that aren't available in Mode 1 and then use the pattern in Mode 1. Some of the illegal colours may turn out as the background colour and cause problems.

Another point to bear in mind when the background colour appears in the pattern: If there are a lot of pixels set to the background colour, you may find the routine only fills simple shapes before aborting, and requires several attempts to complete the job. With normal patterns this shouldn't be a problem.

Here are a few possibilities to think about. Firstly, you can achieve a single colour fill by having a block of only one pixel, for instance:

a$="1":CALL &9000,1,1, @a$

This provides you with a way of changing the background colour should the existing one prove troublesome and avoids having to have two fill routines in memory.

Secondly, on Mode 1 and 2 screens you can get extra colours by alternating two inks such as 0,1 on the top row and 1,0 on the second. This is more successful with some combinations than others. Thirdly, when defining a pattern, if you're careful you can hide the fact that it's based on a rectangle by making one edge a continuation of what's happening on the opposite edge.

CWTA

★ PUBLISHER: Computing With The Amstrad
★ YEAR: 1988
★ CONFIG: ???
★ LANGUAGE:
★ LICENCE: LISTING
★ AUTHOR: Ian C. Sharpe

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
  » Pattern  Fill    (Computing  with  the  Amstrad)    ENGLISHDATE: 2020-07-30
DL: 1 fois
TYPE: ZIP
SIZE: 6Ko
NOTE: 40 Cyls
.HFE: NON

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Graphic - Fast Screen Filler (CPC Amstrad International)
» Applications » Fill (Computing with the Amstrad)
» Applications » CPC464 Fill Subroutine
» Applications » Pattern Fill (Computing with the Amstrad)
» Applications » RSX Pattern-Copy (Schneider Magazin)
» Applications » RSX-Fill (Happy Computer)

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