★ APPLICATIONS ★ PROGRAMMATION ★ FILL (COMPUTING WITH THE AMSTRAD) ★![]() |
| Fill (Computing with the Amstrad) | Applications Programmation |
Add this neat machine code routine by CHRIS RATCLIFFE to your own programs and give your micro real painting power THE Amstrad CPC464 has a very comprehensive Basic for handling graphics, but unlike some lesser machines, it has no Paint or Fill command. But now CPC464 users need look no longer at other machines with envy, for here is a machine code routine that will do it for them. The demonstration. Program I consists of a Basic subroutine from line 9000 which sets up the necessary machine code, lowers the top of memory, and initialises the Basic variable to point to the start of the routine. This should be run at the beginning of your own program with a GOSUB 9000 statement as shown in line 40. Once this has been done all you need do to fill a shape is to enter: CALL paint,x,y,c As you can see, the routine must be given three parameters to work. These are the coordinates of the starting point to fill from (x,y), and the colour to use (c). So the instruction: CALL paint,320,209,2 will fill in the shape around the point 320,200 in the colour of INK 2. It is quite likely that you will make a few mistakes while typing in lines 9100 to 9680, so the program checks the data for you. If there are any mistakes you will be informed which lines are wrong, so correcting them should be quite easy. For simple shapes like circles and rectangles, painting is fairly straightforward, but more complex shapes with lots of nooks and crannies require the computer to "remember" to go back and fill in the fiddly bits. As the program stands, just under 2k of RAM is allocated for this purpose, so it can remember about 500 fiddly bits. This is more than enough for nearly all situations, but if the program is asked to remember more than this it will start forgetting things and may not fully colour in the shape. And that's all there is to it - happy painting!
|