CWTA Issue 29 - May 1987 - Type-Ins

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search

The following listings were published in the May 1987 issue of Computing_with_the_Amstrad:

Type-Ins

  • CPC Fractals (Chris Ratcliffe)
  • Mandelbrot Set (Roland A Waddilove) - screen.bin on the dsk image
  • Ball (Ian Sharpe)
  • Rom off (Ian Sharpe)
  • Faster Disc (Ian Sharpe)
  • Relocator (Martin Ridout) NB machine code listing, not included on the dsk image
  • Crane Crawl (Robin Nixon)
  • Procedures (Robin Nixon)
  • Mastermind (Robin Nixon)
  • Help (Roland A Waddilove)
  • Sultan's Rings (William Ussher)
  • Roulette (Richard Pearce)
  • Data64 (Ian Sharpe)

Notes

  • Rom off (Ian Sharpe) - Call &A000,a,b,c where a,b and c are roms you want to leave on. Basic will be reinitialised with only the selcted roms in action. Be careful as any program in memory will be load. Call &A000 by istelf will leave no active expansion roms at all and the same HIMEM as a bare CPC464.
  • The Postbag contained two routines by John Gray - screen fade and explosion. Both are included on the dsk image.
  • The Postbag also had another improvement for Paul Goodings' Backgammon listing, as well as a modification to allow printing records from Ranbir Randhawa's Minifile listing.

CPC Fractals

This is how the program works:

First select a range of values to be examined for x and y. Each pixel on the screen is then plotted in the appropriate colour depending on whether the loop gives result one or two for the corresponding x and y values.

To add some variety to the picture. instead of just using white the pixel is plotted in a colour which depends on how last a and b are heading off towards infinity. This gives a lovely halo of colour around the black edge of the Mandelbrot set.

A good way to decide whether a and b are converging to fixed values is to put a check in the loop to see if the sum of their squares exceeds four.

The number of times the loop has to execute for this to happen can then be used as a measure of how quickly a and b are heading towards infinity. If four isn't exceeded after 100 times round the loop they have almost certainly settled at fixed values.

A program to do all this can be written in Basic fairly easily but the large number of calculations needed, especially the 100 calculations for values in the Mandelbrot set, means that the process would be very slow.

To get good results in a reasonable time the main calculation and plotting loops are written in machine code, with some Basic attached to set up tables and so on.

This allows most patterns to be produced in a few hours. Considering the program works in Mode 1 and calculates the colour of some 58000 pixels, this is good going.

The machine code is held in data statements and if you make any mistakes typing it in you will be told which line contains the error - though it is still a good idea to save a copy of the program before testing it for the first time.

When the program is run it will Spend a few seconds initialising, then you will see a menu at the bottom of the screen. The available options are:

  • SAVE - saves the current pattern to disc or tape. Colour and parameter information is also saved with the pattern.
  • LOAD - loads a previously saved pattern.
  • RUN - draws a pattern using parameters entered from the keyboard. The last y value will be calculated by the program to keep the pattern correctly proportioned.
  • ZOOM - allows you to zoom in on an area of the current pattern. Define the bottom left and top right corners using the cursor keys, pressing Enter to confirm. The program keeps the proportions of the area correct.
  • INK - pressing the 1,2 or 3 keys on the main keyboard will cycle the corresponding inks through the whole range of colours.

A good way to explore the Mandelbrot set is to first use the Run option to get a picture of the whole set. Enter x1=-2.3 x2=1.1 y1=±1.19 and when it has finished save it.

This pattern will act as your map of the fractal terrain, so you can magnify interesting areas with the Zoom option.

In general, areas close to the Mandelbrot set are the most attractive, so try and include some black in the picture.

Also it is best to make the difference between x1 and x2 greater than about 0.002 to avoid spoiling the shapes with rounding errors in the calculations. Some good spots to try are shown in Table 1 (suggested values below).

Due to the nature of fractals the program can be used to look at literally millions of interesting areas around the Mandelbrot set.

When you have created and saved fractal pictures Program II can be used to produce fascinating animated displays. It will load a pattern and cycle the ink values so that the fibres appear to flow into the screen.

Table 1 - suggested starting values:

  • x1=-1.7910 x2=-1.7387 y1=-0.0183
  • x1=-0.5094 x2=+0.2687 y1=-1.1630
  • x1=-0.5757 x2=-0.5630 y1=-0.5663
  • x1=-1.2998 x2=-1.2913 y1=-0.0760


Download

Screenshots