Pixel Editor ============ Introduction ------------ The Pixel Editor can be used to create and edit graphics shapes. These could be anything from a letter in an alphabet, to a picture of a multi-coloured umbrella. We have used it to help produce the graphics in this program, and the screen that is shown while the program is loading is an example of what can be done. The graphics shapes that you create with the program can be saved in a cassette file and later used in either BASIC or machine code programs. Pixels are the dots on the display screen, and the Editor allows you to create multi-coloured characters at this level without the need to know how the display works or even how the colours are stored within the machine. In addition, there is a BASIC routine on the tape that can be inserted into your own programs, so that using the shapes you create is as easy as possible. For the more experienced programmer, a second version of the routine is provided in relocatable machine code to enable faster and more compact programs to be produced. You will also find a set of characters on the tape that can be loaded into the program and added to, or edited, as desired. One of these sets is a lowercase alphabet - a, b, c, etc - which can be used on the graphics screen. General Information ------------------- You will find four items on the tape: 1. The Pixel Editor itself, called PIXED 2. The GETPUT routine 3. The Multi-Colour Print routine 4. Collection of character sets We shall be looking at how to load and use each of these in the following sections. Before we do that, let's define some of the terminology we will be using. The Dragon Reference Manual will give you the details of the different graphics modes and the memory layout. We will be dealing with the blocks of store known as graphics pages, specifically pages 5 to 8 in the Dragon memory map. We use these pages of store to hold the shapes we are editing. A *pixel* is the term for each of the dots on a display screen; they are combined together in varying brightness and colour to make the picture. On the Dragon, they can be addressed at different levels, depending on the resolution required and the number of colours being used. We will be using Modes 3 and 4, and in these, it takes four pages to make up a screen. While you are editing shapes you will see that the page being edited takes up a quarter of the screen. It is important to note, before using the pixel editor, that whereas in normal computing one would expect to count from 1 upwards, in computing one counts from zero. This state has arisen because at the start of any counting in computing there is nothing, i.e. zero, so that is the first number. If, therefore, you want to have a block of memory accessed that is 12 columns wide, it would be addressed from 0 - 11, rather than 1 - 12 as you might expect. The pixel editor enables up to three sets of shapes to be edited at any one time, and holds each set in a separate page. The number of *addressable elements* in a page will depend on the mode in use. Mode 3 has 48 rows x 128 columns, giving 6144 addressable elements. Mode 4 has 48 rows x 256 columns. It therefore has twice the resolution, but has only two colours available. These addressable elements are grouped together into "grids" which are used whilst editing each character or shape. The *grid size* is the number of rows and columns used by each shape. For example, the grid size of the character sets supplied on tape is 8 rows x 6 columns. On a page, one can therefore fit 21 characters across (128 columns per page divided by 6 columns per character) with 6 down (48 rows per page divided by 8 rows per character line. This is shown in Fig 1, below). 0 1 2 18 19 20 21 22 23 39 40 41 105 106 etc. 123 124 125 [Fig 1] The numbers on the grid are the numbers used to reference each shape. If you define a grid size that does not fit the page exactly, there will be some room left at the edge. If, for example, you set a grid size of 24 rows of 12 columns, they will be held on the page as shown in Fig 2. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 19 [Fig 2] The Pixel Editor - How To Use It -------------------------------- If you have not already done so, load the Pixel Editor. The Pixel Editor control works on a standard method of repeated choice. On running the program, the user is presented with an immediate choice of whether to load, edit or save a character set and this is the Base Menu. Throughout this system of menus it is only necessary for the user to follow the instruction. The second selection, edit, will lead on to another menu - the Main Menu - and this has the eight basic selections available within the editor. In each of these eight options there will be further options and so the whole program structure can be thought of as a series of "levels" through which the user descends to arrive at a specific action. To return back up through the layers it is simply necessary to press the # key for each level ascended. Base Menu - Load, Edit, Save The Base Menu has three options available and these are as follows: 1. Load an old character set If there are three consecutive character or graphics sets on the cassette then the Auto Load function can be employed. This takes the first character set and places it into page 6, the second into page 7, and the third into 8. If only one character set is required, or if the sets are not consecutive, the manual option can be used to take named sets from the tape into a specified page of memory. If you have a tape with three sets on it, insert it into the cassette unit and, after selecting the Auto-load option, press PLAY. The sets will be loaded in one by one and the program reverts to the Main Menu when finished. 2. Edit The use of this option takes the user straight through to the Main Menu - see below. 3. Save This is used when a character set has been modified or created and it is now desired to save it on cassette for later use. Any of the three graphics pages can be saved under any name on the tape, but it is important to name sets sensibly and to save them in an appropriate place on the tape. Insert the tape to which you wish to save your character set into the cassette unit. After specifying the name of the set, start the tape by pressing the RECORD and PLAY keys and start the program saving the data by pressing Space. If you save more than one set, make sure you leave an adequate space between each. Main Menu - By selecting the Edit Option on Base Menu Select Graphics Mode The Graphics Mode selected will define the size of each addressable element in a shape. Mode 3 has larger elements and therefore less definition than Mode 4, but it has the advantage of being able to use four colours. If Mode 4 is chosen, the number of colours is reduced to two. The program starts in Mode 3. Select Colour Set There is an interdependency between the colours available and the graphics mode specified. Colours available for each combination are shown in the Fig 3. MODE 3 MODE 4 SET 0 Green (1) Yellow (2) Blue (3) Red(4) Black (0) Green (1) SET 1 Buff (1) Cyan (2) Magenta (3) Orange (4) Black (0) Buff (1) The number in brackets indicates the key to be used to select this colour. The program starts using Colour set 0. View Character Sets This option enables the user to look at the current state of any set of shapes, and after viewing enables any other set to be used until the # key is pressed. Set Working Graphics There are three graphics pages holding shapes that can be edited. In this option you can select the page you wish to use. The program starts using page 6. Set Background Colour When it is intended to create a new character or graphics set, the first thing to do is to choose a page and select a colour for it. This is done using this option. The keys for each colour are shown under 'Select Colour Set' above. Set Character Grid Size In the editor it is possible to vary the size of the shape being edited. Choose the number of rows and columns for each shape. The editor then splits the page into grids of the size you have chosen. The program starts with a grid size of 8 rows x 6 columns. Copy or Move Characters It is possible, if required, to copy a shape being edited to another position. It is important to remember when doing this that the size of the area being transferred is the drig size chosen easlier and so, if it is required to transfer a different sized area the grid size must be changed first. Edit Characters Having set the various parameters described above it only remains to actually edit the shape of the characters or graphics. The editor will ask which character number is required and this will depend on the grid size. On selection, the program shows the page being edited across thebottom of the screen and a large version of the current grid above this. One square, the cursor, is flashing and can be moved around the grid, using the four arrowed keys on the left and right of the keyboard. the colour of the flashing cursor can be changed by using the keys 1-4 or 0, 1 if in a two-colour mode only. The colours corresponding to each key are shown under "Select Colour Set" above. A square is painted by pressing ENTER. If a square is the wrong colour than it is simply necessary to repaint it. An Example Having seen the explanations, you will want to try it out. If you have not already done so, load the program. Unless you have a character set you wish to modify, type 2 to get to the Main Menu. As we are creating a new character set the first thing to do is to set the background colour (option 5). Now set the background colour of page 6 to yellow (value 2). There is now an odd display on the screen. What we see is pages 5, 6, 7 and 8. Page 5 is used as a palette by the program. Page 6 is the second quarter of the screen and is yellow which is what we wanted. Pages 7 and 8 are still unassigned and should be multi-coloured. Any key will now return us to the Main Menu. Page 6 is now ready to draw on as it is a blank yellow page. This can be validated by choosing option 3 to view a page. As usual typing # will return you back up towards the Main Menu - type # until you are there. Now try editing a character (option 8). The editor has split the page into grids, each of 8 rows x 6 columns. They are numbered from 0 to 125 and character 21 beneath it and so on. Type 0 to edit the first character. There should now be a copy of page 6 at the bottom of the screen and an expanded version of the character above it. Now try drawing a box around the outside of the square in blue by selecting 3 as the colour and using the ENTER and arrow keys as described in Edit Characters. You should now see this blue box in the top left hand corner of the copy on the bottom of the screen. When you've finished drawing one character, type # and the editor will invite you to edit another character. Try drawing an X in a different colour in character number 22 and then 0 in character 0. To do this just paint in the centre four squares and you have an 0. Obviously you could go on drawing characters like this as long as you wanted; with this grid size there is room for 126 characters in a page. We have drawn two characters:- Character 0 and character 22. Now let us see how to use these characters in another program. We shall first save them on a cassette. Use the # key to return to the Base Menu. Now selection Option 3 to save the character set. First make sure that the tape in the cassette unit is not the one with the Pixel editor on it. It is best to use a blank cassette which can be later used as a library of character sets. The Pixel Editor is now telling you that you have been working with page 6. You may have been working on several pages so you have the choice of which page to save. We want to save page 6, so type 6 followed by the ENTER key. It is now necessary to type a filename, and it is a good idea to try and use a meaningful filename. In this case it would therefore be sensible to try CHR-OX so type this and press the ENTER key. Now press the Record and Play buttons and make sure that the leader tape is past the tape heads. Now press ENTER and you should hear the page being saved (provided that the volumn on your TV is turned up!). The Getput Routine ------------------ The way the character set can be used in BASIC relies on two of the Dragon's Graphics commands GET and PUT. It will help you to understand the GETPUT listing (see Appendix A) if you have read Chapter 10 of the Dragon User Guide which deals with the GET and PUT statements. Firstly, load the GETPUT program in much the same way as the Pixel Editor, but in this case it is a BASIC program so you will type CLOAD "GETPUT" rather than CLOADM. Follow with the ENTER key, and press PLAY on your cassette unit. When the program has loaded, you will recieve the OK message. Insert the tape with your characters into the cassette unit. Now type RUN (ENTER). Start the cassette unit playing and press Space. You should now see your character set being loaded into page 5 at the top of the screen. When it has been loaded you should press Space to continue. You will be asked to type in your grid size - if you want the same size shapes as shown then type Y; if you want to change the size type in the new values, following each with ENTER. The GET and PUT areas now have to be selected and these are done as follows: The GET position is the position within page 5 to get the shape from. This is calculated in addressable elements and you have to remember that in Mode 3, page 5 will be made up of 48 rows or 128 columns. The top left hand element is referred to as (0,0) and will match up with shape 0. If your grid size is 8 rows of 6 columns, position (0,8) would give you the left hand character in the second row. The PUT position is worked out in the same way, but is the position in the graphics screen that the shape will be displayed. After you have typed in your GET and PUT coordinates, the character selected should appear on the screen. If you press Space, you can then move further areas into the graphics screen. Try building a house with the 0 and X characters you created earlier. By looking through the listing of the GETPUT routine, you will see how to use the shapes you have created, in your own programs. The Multi-Coloured Print Routine -------------------------------- The Multi-Coloured Print Routine - MCPR - uses Mode 3 character sets created with the Pixel Editor. It is provided in relocatable machine code which normally gets loaded into memroy at $2400. It provides a quicker method of displaying custom-built characters on the screen, and gives a straightforward interface to the user. Having understood how to use the subroutine, the user can access the internal parameters and extend its facilities still further. For a full description of MCPR and its parameters, their defaults, etc, see Technical Appendix B. Firstly, type PCLEAR8 to prevent the basic program overlapping MCPR and the character set. Then follow the standard loading procedure to load the routine into memory using a CLOADM"MCPR" command. The system will reply "OK" when it has loaded. Having loaded the multi-coloured print routine, load one of the character sets provided on the tape into graphics page 5 with the following command: CLOADM "name of character set", &H600. Now try typing in the following: For example: 10 REM MCPR TEST 20 PCLEAR8 30 A1=&H2400:PP$="":VPT=VARPTR(PP$) 40 POKE A1+4,INT(VPT/256):POKE A1+5,VPT AND 255 50 POKE A1+13,ASC("<") 60 PMODE 3,1:SCREEN 1,1:PCLS:COLOR 2,1 70 POKE A1+2,0:POKE A1+3,0 80 PP$="Would you like to