



'The full source version of this program with all data files 

'can be found in the SOURCE_CODE drawer on thisdisk.  

'This excellent tutorial was sent to me by Alan Carter, the programmer 
'behind the top F1 programs Art School and Touch `N Go.
'See reviews and F1 catalogue for more details.
'STEVE. 
 
'=========================================================================
'  A VERY simple proggy written to demonstrate features to some people new 
'  to AMOS.  Ignore any patronising remarks if your past this stage! 
'  
'
Close Workbench 
Close Editor 
'
'  Open two low resolution screens.  Screen 0 is used as the main drawing  
'  screen.  Screen 1 is for holding temporary images that can be copied back 
'  to Screen 0 when the undo feature is used.  
'
Screen Open 0,320,276,64,Lowres : Paper 0 : Curs Off : Flash Off : Cls 
Screen Open 1,320,276,64,Lowres : Paper 0 : Curs Off : Flash Off : Cls 
'
'  Set the drawing pointer to screen 0 
'
Screen 0
'
'  Change the mouse image to a clock to tell the user to wait  
'
Change Mouse 3
'
'  Load the colour palette of our menu panel into Screen 0 
'    
Get Sprite Palette 
'
'  Set the drawing pointer to screen 1 
'
Screen 1 : 
'
'  And load the colour palette into this screen  
'
Get Sprite Palette 
'
'  Now bring screen 0 back to the front of the display, and set the drawing  
'  pointer back to screen 0, ready to use for drawing  
'
Screen To Front 0 : Screen 0
'
'  Tell the computer to bring a menu bank stored in bank 6 and put it into 
'  our menu.  Then switch the menu on. 
'
Bank To Menu 6
Menu On 
'
'  Now we dimension some arrays that will be used for fairly important 
'  tasks later in the program.   
'
Dim FAME$(50),C(7),C2(7),C3(7),SX(7),ST(7),NC(7),RGB(63),REZ$(7),OK$(1)
Dim TPAL(15),AN$(20),O$(1)
'
'  Because we are using some procedures, any variables that need to be used  
'  by other parts of the program must be shared, so we use 'Shared' to let 
'  the computer know that they shouldn't be kept by the procedures.  
'
Shared FAME$(),HFLIP,VFLIP,BX,BY,BX1,BY1,FIN$,PAGE,F2TYPE,F5TYPE,F6TYPE,F7TYPE,F8TYPE
Shared XB,YB,BO,T,F2,F5,F6,F7,F8,F9,F13,CROSS,COORDS,I,PROG,FRESH,COUNT,FILENAME$,FC,BC
Shared WIDTH,HEIGHT,PAGE$,DENSITY
'
'  And now just set up some variables that will be needed elsewhere. 
'  e.g. The variable I is the starting ink colour and is set to colour 4 
'
COORDS=0 : I=4 : COUNT=1 : FILENAME$="" : Dir$="df0:" : PAGE=0 : NTS=-Ntsc
NCOLS=32 : XSIZE=32 : YSIZE=32 : FC=1 : BC=2 : DENSITY=50
'
'  This simple command limits the mouse to the dimensions of your T.V display
'
Limit Mouse 129,42 To 444,304
'  
'  Now we call our first procedure.  This holds all the information that will
'  draw the menu and title bars, and set up the various zones for these bars.
'    
Proc SETUPSCREEN
'
'  This line simply puts the starting message on the title bar in ink a
'  black ink colour. We do this now because the next lines will take a 
'  few seconds to complete, and the user must know that the program is working 
'
Ink 0 : Text 7,7,"EasyPaint   Initialising"
'
'  This copies an exact replica of the starting screen to screen 1 
'
Screen Copy 0 To 1
'
'  And the next 2 lines copy an exact replica of the starting screen to
'  memory banks 14 and 15.  The only difference from above is that we are  
'  packing (compressing) the image, instead of just copying it.  This will 
'  save a substantial amount of memory because the banks don't need a screen 
'  opening for them.  The banks are used to store information that can be used 
'  as a spare page for the using to flick between. 
'
'Spack 0 To 14 
'Spack 0 To 15 
'
'  Now that done we can print our message a message to the user saying the 
'  program is ready to use.
'
Ink 0 : Text 7,7,"EasyPaint   "+PAGE$+"    "
'  
'  And change the mouse back from the clock to a cross-hair. 
'
Change Mouse 2
'
'  Earlier we brought our menu from Memory bank 6, now we tell the computer
'  what to do with this menu.  e.g.  The three titles - Picture, brush and 
'  prefs are numbered 1,2 and 3.  So when the user chooses an option from  
'  picture, the computer recognises this a choice from number 1.  It then  
'  checks this next line to see what it should do. The procedure for these - 
'  MECHECK1 etc are explained later.  It does this automatically - 
'  (under interrupt) ... 
'
On Menu Proc MENCHECK1,MENCHECK2,MENCHECK3
'
'  ... After its been activated with this line 
'
On Menu On 
'
'  Now we come to what could be called the main program loop !  The beauty 
'  of using procedures is it makes your program so much simpler to handle. 
'  All this line does is call the procedure that checks the zones for tools
'  like circle and line, and if they are selected, jumps to that procedure.
'  It then starts all over again.
'
1 Proc CHECKZONES
Goto 1
'  
'  This is where all the little parts of the program are hidden away.  We
'  call them procedures!  But you already knew that, right ?  If you are   
'  reading this for the first time then the procedures will be closed -  
'  that is, you will only see the title of the procedure.  To open them up 
'  simply position the cursor on the procedures name with the mouse, and 
'  then click up there ^^ the control panel where it says 'Fold/Unfold'
'  This will open up the procedure for you to examine.  Just click it again
'  to close, but make sure the cursor is somewhere inside the opened 
'  procedure.
'
'  This procedure is responsible for drawing dotted freehand.  The next  
'  line tells the computer that the following lines will all be part of the
'  the procedure called FREHANDDOT until it encounters an 'End Proc' command.  
'
Procedure FREHANDDOT
'
'  This line check to see if the procedure has got by this part before.
'  If it has then T will have been set to 1. If T doesn't equal 0 then it  
'  pastes the bob highlighted in blue on the menu bar to show that the 
'  dotted freehand tool has been selected.  Otherwise (else) jump to the 
'  label 'BEGIN' 
'
   If T<>1 Then Paste Bob XB,YB,BO Else Goto BEGIN
'
'  Paste the highlighted freehand bob on the menu bar
'
   Paste Bob 292,36,20
'
'  Now its time just to store the X and Y locations of the bob location, the 
'  bob number and set T to 1 to stop what we just mentioned above
   XB=292 : YB=36 : BO=2 : T=1
'
'  And begin ... with a label. 
'
   BEGIN:
'
'  'Repeat' is used to start a piece of program looping,  further down you will
'  see another command - 'Until'.  Basically it will just repeat until the 
'  conditions we specify after the 'Until' command are met.
'
   Repeat 
'
'  While we are repeating, we will check to see if the left mouse key (1)
'  is pressed at the same time the mouse pointer is off the drawing area - 
'  (zone 0): If it is then we will jump to the end of this procedure,  
'  signified by the label - FINISHED, which will then end this procedure 
'  and go back to the main loop. 
'
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
'
'  Here is the 'Until' part of the 'Repeat' loop.  You can see that all we 
'  are waiting for is for the mouse pointer to enter the drawing area- Zone 0  
'  We do this as a check that the users selection is going to be used, and   
'  not just deselected straight away.
'
   Until Mouse Zone=0
'
'  Next is a simple call to a simple procedure for a simple purpose!  This 
'  makes a quick copy of the current picture into screen 1.  The purpose 
'  being,  should the user draw something he doesn't like, he can simply 
'  press the Undo button on the menu bar, and return the picture to the
'  state it was it before he started before we just copied it into screen 1. 
'  Jumping ahead of ourselves for a moment, all the undo procedure does is 
'  copy screen 1 to screen 0 (the one the user sees). Simple eh ?
'
   _SCOPY
'
'  This is just a mid-procedure label, useful if you dont want to go through 
'  all of the above again, or 'none of the above!!' in other words 
'
   BEGIN2:
'
'  Here we come across the PROG Variable.  We are setting it to 2.  Please 
'  see the varible list for this program for more information. 
'
   PROG=2
'
'  Time to set another loop off, but this one is unconditional, i.e. it
'  wont stop for nobody unless some line inbetween jumps out of it.  You 
'  could use a Repeat/Until in here, but it's really being wasted if you 
'  do.  The format it takes is simple ...
'  'Do' is the start point of the loop 
'
   Do 
'
'  Then comes any program lines you want to cycle through indefinately.
'  We are checking here to see if the COORDS variable is set to 1.  If it
'  is then do a quick jump to the COORDS procedure.  The COORDS procedure only 
'  prints the mouse co-ordinates on the menu bar once,  but in this loop 
'  it gives the illusion of being constant!
'
      If COORDS=1 Then Proc COORDS
'
'  Now we do the same for the CROSS variable.  If it is set to one then do 
'  a quick jump to the CROSSHAIRS procedure.  Again this just draws the  
'  crosshairs on the screen once and comes straight back here.  You could
'  pop down to these procedure now if you want, just for a quick look to 
'  see what they are doing ! 
'
      If CROSS=1 Then Proc CROSSHAIRS
'
'  This line checks to see if you have pressed the mouse button on the 
'  drawing area of the screen (zone 0).  When the program is running this
'  is the time when you press the left button to start drawing.  So, if the
'  user has pressed the button, we do a quick copy of the screen and put it
'  in screen 1 ( yes, same as before), and then jump out of this loop to 
'  the label BEGIN3
'
      If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
'
'  Another check on the mouse position here, this time to see if the mouse 
'  has left the drawing area.  If it has then its time not only to leave this
'  loop, but to leave this procedure.  It's a pretty good bet that the user
'  has left the drawing area to select another function or change the ink
'  colour etc. Either way, if he's out of the drawing area it's time to jump 
'  to the end of the Dotted Freehand procedure, and the lable is the same
'  for all of our procedures - FINISHED. 
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  'Loop' is the other part of the 'Do' command.  As you can see, it has no
'  conditions and will continue looping until the program inbetween jumps out. 
'
   Loop 
'
'  Another mid-procedure label, saves us from going through the above again. 
'  But this is the actual output part of this procedure.  Coming up is 
'  what puts the dotted line on yout t.v.
'
   BEGIN3:
'
'  Hey!  Yet another loop already, and a different one at that.  This one  
'  is the 'While'/'Wend' type, and this one is conditional, but the  
'  conditions go after the 'While'.  You could use a 'Repeat'/'Until', but 
'  for what we want to do that could prove to be a bit vague,  because this
'  loop will only loop while the conditions are being met.  In other words 
'  as soon as you stop pressing the left mouse key (key 1) the loop will 
'  finish. 
'  So we start the loop, and tell the computer that the conditions of the loop 
'  will be - only repeat if the left mouse key is pressed ...
'
   While Mouse Key=1
'
'  You've seen the next line before, if the COORDS variable is set to 1 then 
'  we do a quick jump to the COORDS procedure to print the co-ordinates
'
      If COORDS=1 Then Proc COORDS
'
'  Here it is, simplicity itself.  Remember, the computer wouldn't be  
'  executing these lines if the user wasn't pressing the left mouse key. 
'  So we make sure the ink colour is set to variable responsible for ink.
'  And then plot a single pixel at the screen co-ordinates of the mouse. 
'  If your unsure about screen co-ordinates, then see the Chapter in the 
'  manual regarding SCREEN/HARDWARE co-ordinates.
'
      Ink I : Plot X Screen(X Mouse),Y Screen(Y Mouse)
'
'  And now a quicker than quick check to see if the user is being naughty. 
'  We dont want him/her drawing all over our nice menu bar do we ?  So if
'  the mouse pointer leaves the drawing area (zone 0) then we will end this
'  procedure by jumping to the FINISHED label. 
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  The next line is as we said previously, it sends the computer back to 
'  the beginning of this loop - the 'While' command, but only if the user  
'  is pressing the left mouse button.  If he/she isn't then the computer 
'  will move on to the next line ... 
'  
   Wend 
'
'  Okay, so far so good ?  But what if the user isn't currently pressing 
'  the left mouse button ?  Simple, just look at where we are.  The user 
'  hasn't left the drawing area,  he/she is just waiting or positioning the
'  mouse ready to draw.  So we simply jump back into the middle of this
'  procedure and keep checking.  We do this by jumping to the lable BEGIN2 
'
   Goto BEGIN2
'
'  Here is the FINISHED label. 
'
   FINISHED:
'
'  And the end of this particular procedure is signified by the command .. 
'
End Proc
'
'  This procedure is responsible for the continouse freehand option.  Again, 
'  the next line tell the computer that all following lines will be part of  
'  the procedure called CONTINUOUSFREEHAND until it encounters an 'End Proc' 
'  command.
'
Procedure CONTINUOUSFREEHAND
'
'  A quick note about this procedure.  If you click twice on the continuous
'  freehand icon on the menu bar you will see a filled shape.  The tells us
'  that any shape drawn from then on will be filled with the current ink 
'  colour.  This option will be referred too herewith as a multiple option.
'  It means that the initial part of a multiple option procedure is slightly 
'  more complex than usual, but not overly so.  Stick with me. 
'
'  The same as the previous Procedure,  if the variable T doesn't equal 2
'  then paste the highlighted bob on the menu bar to show the user that the  
'  feature has been selected 
'  
   If T<>2 Then Paste Bob XB,YB,BO
'
'  Please see the Variable table regarding EasyPaint for descriptions of 
'  the following variables.
'
   If F2=1 and F2TYPE=1 Then Goto B
   If F2=1 and F2TYPE=0 Then Goto A
   If F2=2 and F2TYPE=0 Then Goto A
   If F2=2 and F2TYPE=1 Then Goto B
'
   A:
'
'  Here we paste the highlighted bob for un-filled freehand
'
   Paste Bob 305,36,21
'
'  And set the co-ordinates and bob numbers into the same variables as 
'  the last procedure.  It should be worth noting at this point, that most 
'  of the actual drawing procedures share the same format and variables. 
'  So it's wasteful repeating things all the time.  But where things are 
'  similair, I'll bring them to your attention.
'
   XB=305 : YB=36 : BO=3 : T=2 : F2=1
'
'  We dont want to execute the next bit of program so we jump to the label 
'  BEGIN, otherwise we will always end up pasting the filled freehand bob! 
'
   Goto BEGIN
'
   B:
'
'  Here we paste the highlighted bob for filled freehand 
'
   Paste Bob 305,36,22
'
'  And set up the variables again.  If you've forgotten what they are used 
'  for, don't forget the Variable tables supplied with this package !
'
   XB=305 : YB=36 : BO=3 : T=2 : F2=2
'
'  Another label to show where the main body of the procedure lies.
'
   BEGIN:
'
'  Again, and you will see repeated in all of these procedures, the 'Repeat/ 
'  Until' loop.  Its main purpose being to check until the mouse enters the
'  drawing area or another choice from the menu bar is selected. 
'
   Repeat 
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
   Until Mouse Zone=0
   _SCOPY
'
'  Another label 
'
   BEGIN2:
'
'  Initialise a 'Do/Loop' loop with the next command.
'
   Do 
'
'  Check for crosshairs, if the CROSS variable is set to one then jump to
'  the CROSSHAIRS procedure. 
'
      If CROSS=1 Then Proc CROSSHAIRS
'
'  Has the user began to draw ?  Yes ?  Then make a copy of the screen with
'  the _SCOPY procedure and jump to the BEGIN3 label.  
'
      If Mouse Click and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
'
'  Again, check if the mouse has left the drawing area.  If it has then end
'  the procedure by jumping to the finished label, otherwise continue with 
'  the next line.
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  Same as the last procedure.  Check to see if the co-ordinates have been 
'  been switched on by looking at the COORDS variable.  If it is set to one
'  then jump to the COORDS procedure to display them.
'
      If COORDS=1 Then Proc COORDS
'
'  The next command sends the program back up there to the 'DO' command to 
'  continue the loop.
'
   Loop 
'  Another label.
'
   BEGIN3:
'
'  And now we will set the drawing mode to normal.  This means that anything 
'  the user draws will be fixed onto the display.  We do this because other  
'  parts of the program like the CROSSHAIRS procedure use a drawing mode 
'  called 'GR WRITING 2'.  This is a command that uses another drawing method
'  whereby anything drawn once and then drawn over again will be removed.
'  That's why the crosshairs dont destroy anything the user has drawn.  It 
'  is also known as the Exclusive Or mode - XOR.  We set it to normal here 
'  incase a procedure such as LINE has to be left early and maybe still in 
'  the XOR mode, its just a safegurad. 
'
   Gr Writing 1
'
'  Now we use the next command to tell the computer only to execute the lines
'  inside the 'While/Wend' loop while the left mouse key is being pressed. 
'  The key is recognised by the computer as key 1. 
'
   While Mouse Key=1
'
'  Here we load the variable X and Y with the current mouse co-ordinates.
'  The use of the command 'X Screen(X Mouse)' is because the actual co-ords
'  of the mouse (hardware co-ordinates) are very much different from the 
'  co-ordinates you see on the screen (screen co-ordinates).  So we use
'  this command to make the conversion for us. 
'
RANGECHECK: X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
 If Y<11 or X>289 Then Goto RANGECHECK
'  
'  Next we instruct the computer to Wait 1, or 1/50th of a second
'
      Wait 1
'
'  Now we load more variables with the current mouse co-ordinates.  Again, 
'  note the use of the 'X Screen(Xmouse)' commands etc.  If you are wondering
'  why we have got the co-ordinates again then let me explain.  Although 
'  when you use this procedure and draw freehand it seems as though you are
'  just quickly plotting points on the screen it is actually drawing straight
'  lines from one point to another - very quickly admittedly, but none the 
'  less, they are straight lines.  We have to do it this way to keep the 
'  lines continuous, and hence the reason why we need two set of variables.  
'  One set (X and Y) hold the initial or starting point of the line, and the 
'  other set (X1 and Y1) hold the target point of the line 
'
 X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
 If Y1<11 or X1>290 Then Goto RANGECHECK
'
'  And here is the command that draws the lines between our two sets of
'  variables.  Of course we have to set the ink colour as well, and this 
'  is taken care of by the variable I. 
'
      Ink I : Draw X,Y To X1,Y1
'
'  Yes, we check the mouse position again to see if it has left the drawing  
'  area (Zone 0).  If it has, then end this procedure by jumping the label 
'  called FINISHED.
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  And update the co-ordinate display - if its turned on.
'
      If COORDS=1 Then Proc COORDS
'
'  Next we return the 'While' command with its counterpart 'Wend'
'
   Wend 
'
'  Here is another check on a variable.  This one is checking to see which 
'  part of this procedure has been activated.  Remember this procedure is a
'  multiple option procedure, where the options are either a normal freehand 
'  line or and filled freehand shape.  We can tell what option has been
'  selected by reading the variable F2TYPE, if its 0 then we should ignore 
'  the next line - 0 denotes a normal line.  But if it is set to 1 then
'  we should fill inside the shape the user has drawn with the command 'Paint' 
'  But how do we know where to fill ?  Well, we know the last position of
'  the mouse, we stored it in the variables X and Y, so a good guess would 
'  be to add 2 pixels to the Y co-ordinate, and this should put us some where  
'  inside the users shape.  Please note however that this isn't definate, and  
'  for this to work fully we need to hope the user always finishes his shape 
'  roughly at the top of the screen or else we will end up filling the whole 
'  screen !
'  
   If F2TYPE=1 Then Paint X,Y+2
'
'  Now we go directly to the mid procedure label to save us going through
'  the initial checks again. 
'
   Goto BEGIN2
'
'  And here again as before is the FINISHED label just before the 'End Proc' 
'  command that is used in the procedure when the user has finished with this  
'  tool and wished to re-select. 
'
   FINISHED:
'
'  And we terminate this procedure with the following command... 
'
End Proc
'
'  Next we come to the STRAIGHTLINE procedure.  A very simple piece of   
'  program, and no multiple options.  It simply draws a line between two 
'  co-ordinates. 
'
Procedure STRAIGHTLINE
'
'  The same initial checks as all the previous procedures. Remember that 
'  the variable T will only be set if this procedure has been called before. 
'  So we check if T doesn't equal 3, and if it doesn't we paste the  
'  un-highlighted bob on the menu bar, otherwise we go to the next line. 
'
   If T<>3 Then Paste Bob XB,YB,BO Else Goto BEGIN
'
'  And paste the highlighted bob.
'  
   Paste Bob 292,49,27
'
'  Then load the variable with the positions of the newly pasted bob and 
'  set the variable T to 3, to signify that this procedure has been used.
'
   XB=292 : YB=49 : BO=6 : T=3
'
'  Another label.
'
   BEGIN:
'
'  And we initialise another loop, checking to see if the user has selected
'  ant other options while still on the menu bar.  The loop is terminated as 
'  soon as the mouse enters the drawing area (zone 0). 
'
   Repeat 
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
   Until Mouse Zone=0
'
'  Another loop now, this time doing many things, let me explain...
'
   Do 
'
'  Here we repeatedly load the variables X and Y with the mouse co-ordinates.
'  We do this now because other checks in this loop await the pressing of the
'  left mouse button.  This press will signify the user wishes to draw a line
'  from that point (which we have in X and Y) to another point - which we get
'  later.
'
RANGECHECK: X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
If Mouse Zone<>0 and Mouse Key=1 Then Goto FINISHED
 If Y<11 or X>289 Then Goto RANGECHECK
'
'  The next two lines, as before, check to see if either the Crosshairs or 
'  co-ordinates have been activated, and if so, do a quick call to the 
'  relevant procedures.
'
      If CROSS=1 Then Proc CROSSHAIRS
      If COORDS=1 Then Proc COORDS
'
'  The next line checks for a left mouse button press.  If it finds what it
'  is looking for i.e a value of 1, then it quickly copies the current screen
'  using the _SCOPY procedure and jumps to the BEGIN2 label. 
'
      If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN2
'
'  And here we check to see if the mouse has left the drawing area.  If it 
'  has, then jump to the label FINISHED. 
'
      If Mouse Zone<>0 Then Goto FINISHED
'  And complete the 'Do/Loop' loop, with the command 'Loop'
'
   Loop 
'
'  Another label!
'
   BEGIN2:
'
'  Another loop!  Only to be executed while the left mouse button is pressed.
'
   While Mouse Key=1
'
'  Check the co-ordinates variable.
'
      If COORDS=1 Then Proc COORDS
'
'  Load the variables X1 and Y1 with the current screen co-ordinates of the
'  the mouse.  These will be used as a 'target' for the line drawing command.
'  Remember that we stored the initial (starting) point of the drawing 
'  operation in the variables X and Y. 
'
RANGECHECK2: X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
 If Y1<11 or X1>289 Then Goto RANGECHECK2
'
'  Now we set the drawing mode to XOR using the following command.  This 
'  allows the user to 'stretch' the line over his drawing with destroying
'  any of his work.  This technique is also known as rubber banding. 
'
      Gr Writing 2
'
'  And we drawn a line in the current ink colour (I) between our co-ordinates, 
'  the variables X,Y and X1,Y1.  
'
      Ink I : Draw X,Y To X1,Y1
'
'  And now we draw the exact same line again.  The reason ?  Well, as we said
'  earlier, when you are using the XOR mode (GR Writing 2), anything you draw
'  and then draw over again will be removed without any ill effects to things
'  already there.  This is a very simplistic way of describing its effects,  
'  and I suggest you try it for yourself to see the effect.  It is more than 
'  useful for tasks such as these and is well worth remembering.  In fact it 
'  is extensively used throughout this program.  You can see it in action
'  whenever you see a stretching effect - in this procedure, and the box 
'  procedure you will see it to its best effect. 
'
      Draw X,Y To X1,Y1
'
'  And now finish the loop with the following command. 
'
   Wend 
'
'  Now we are here the user has obviously released the button to draw his  
'  line.  So we must set the drawing mode back to normal to fix the image on 
'  the screen by using the following command.  
'
   Gr Writing 1
'
'  And then re-draw the line proper in the current ink colour.  We still have
'  the old co-ordinates, so there is no need to get them again.  
'
   Ink I : Draw X,Y To X1,Y1
'
'  And now jump back to the label BEGIN to do it all again ! 
'
   Goto BEGIN
'
'  Here we set the FINISHED label for earlier parts of the program to jump 
'  to should the user require another option.
'
   FINISHED:
'
'  And end the procedure!  Not to difficult eh ?  Good.
'
End Proc
'
'  NOTE,  the following procedure is incomplete and un-documented. 
'
Procedure F4
   If T<>4 Then Paste Bob XB,YB,BO Else Goto FINISHED
   Paste Bob 305,49,28
   XB=305 : YB=49 : BO=7 : T=4
   FINISHED:
   Print "hi"
End Proc
'
'  Now comes another multiple choice procedure.  The choices being either
'  a filled or un-filled circle.  Note the name of the procedure - FCIRCLE 
'  is named such for no other reason other than AMOS commands can't be 
'  used as names or labels.  So we stick the letter F in front of Circle 
'  to get away with it for the sake of clarity.
'
Procedure FCIRCLE
'
'  If you missed it earlier, T is a variable that tells us whether the 
'  procedure has been used before.  If it doesn't equal 5 then we paste
'  an inactive bob on the menu bar.
'
   If T<>5 Then Paste Bob XB,YB,BO
'
'  Please see the Variable table regarding EasyPaint for descriptions of 
'  the following variables.
'
   If F5=1 and F5TYPE=1 Then Goto B
   If F5=1 and F5TYPE=0 Then Goto A
   If F5=2 and F5TYPE=0 Then Goto A
   If F5=2 and F5TYPE=1 Then Goto B
'
   A:
'
'  We paste the highlighted bob for an empty circle on the menu bar. 
'
   Paste Bob 292,62,25
'
'  And as before, load the following variables with the co-ordinates at
'  which these bobs will be pasted.
'
   XB=292 : YB=62 : BO=4 : T=5 : F5=1
'
'  And then jump to the label BEGIN
'
   Goto BEGIN : 
'
'  We paste the highlighted bob for a filled circle on the menu bar. 
'
   B:
   Paste Bob 292,62,23
'
'  And load up the variables.  If your unsure about these, then please se
'  the supplied variable table regarding the Easy Paint program. 
'
   XB=292 : YB=62 : BO=4 : T=5 : F5=2
'
'  And then jump the label BEGIN 
'
   BEGIN:
'
'  Now to initialise a 'Repeat/Until' loop with the following command. 
'
   Repeat 
'
'  Note that we are checking inside this loop to see if the user has selected
'  another option while still on the menu bar.  The loop will end as soon as 
'  its conditions have been met i.e. when the mouse enters the drawing area
'  also known as (zone 0)
'
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
'
'  And here is the conditional part of the loop. 
'
   Until Mouse Zone=0
'
'  The user has entered the drawing area, so we'll copy the screen now in case 
'  he draws something he doesn't want.  Then, if he presses the undo button
'  we can copy an image of the screen as it was, back to the drawing area. 
'
   _SCOPY
'
'  And a label follows.
'
   BEGIN2:
'
'  Now we start off another loop.  We dont want any conditions to this one 
'  because it shouldn't until a line inside jumps out.  So we use the 'Do/Loop'
'  loop. 
'
   Do 
'
'  The next two lines check too see if either the co-ordinates or the  
'  cross-hairs have been activated, and if they have, they jump out to the 
'  relevant procedures.
'
      If COORDS=1 Then Proc COORDS
      If CROSS=1 Then Proc CROSSHAIRS
'
'  Now we load the variables X and Y with the current screen co-ordinates of 
'  the mouse in preparation for drawing the circle.  These variables will act
'  as the centre of the eventual circle. 
'
RANGECHECK: X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
      If Mouse Zone<>0 and Mouse Key=1 Then Goto FINISHED
 If Y<11 or X>288 Then Goto RANGECHECK
'
'  A quick check of the mouse to see if the left button has been pressed.
'  If it has then we copy the screen using the _SCOPY procedure, and jump out
'  of this loop to the BEGIN3 label.  Remember, we copy the screen in case 
'  the user makes an error during a drawing operation and wants to undo it.
'  The copied screen is held in screen 2 which we opened at the beginning of 
'  this program, and is simply copied back when the undo button is pressed.
'
      If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
'
'  Also checking here to see if the mouse has left the drawing area, and if
'  so we tell the computer to jump to the label FINISHED.
'
      If Mouse Zone<>0 Then Goto FINISHED
'  
'  And return the loop with the next command.
'
   Loop 
'
'  Here is the label that marks the start of the actual drawing part of this 
'  procedure.
'
   BEGIN3:
'
'  And we check to see if the left mouse key is pressed with the next line.  
'  If it is then we start to cycle through the program contained inside the
'  'While/Wend' loop.  As soon as the left mouse key is released, the loop 
'  will terminate. 
'
   While Mouse Key=1
'
'  Another check on the COORDS variable. 
'
      If COORDS=1 Then Proc COORDS
'
'  Here we continually load the X1 variable with the X co-ordinate of the
'  the mouse. We do this because the diameter of the circle is measured by 
'  calculating the distance from the initial starting point (X) and the  
'  current X co-ordinate stored in X1 - the next line. 
'
RANGECHECK2: X1=X Screen(X Mouse)
 If X1>288 Then Goto RANGECHECK2
'
'  And then, as before, we set the drawing mode to XOR because the user needs
'  to see where to position the circle without actually drawing tens of them 
'  all over his work.  The next command enables this mode. 
'
      Gr Writing 2
'
'  And here we draw the circle.  Note that X and Y variables hold the centre 
'  point of the circle, and the diameter is calculated by subtracting X+1 from 
'  X1.  We add the one to X because AMOS doesn't allow you to use negative   
'  values when drawing circles, and if we didn't, as soon as the user started to 
'  draw his circle an error would be generated due to the diameter being 
'  calculated at exactly 0, or the value you would get by subtracting X1-X 
'  Please also note that if your not sure of how the variables are being 
'  calculated at any point in the program, try using the command 'Follow' at 
'  certain key places.  More information on how to use this command for your 
'  benefit can be found in the variables table for Easy Paint. 
'
      Ink I : Circle X,Y,X1-X+1
'
'  Now we re-draw an exact copy of the previous circle.  Remember, because we
'  are in XOR mode, this circle will remove the last one from the display
'  without drawing over anything else, thus giving the illusion of being able  
'  to stretch the circle.
'
      Circle X,Y,X1-X+1
'
'  A quick check on the mouse to make sure the mouse is still on the drawing 
'  area.  If it isn't then we jump to the FINISHED label to end this 
'  procedure.
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  And complete the 'While/Wend' loop with the 'Wend' command. 
'
   Wend 
'
'  Now we set the ink colour.  Switch the drawing mode back to normal and
'  draw in the final circle. 
'
   Ink I : Gr Writing 1 : Circle X,Y,X1-X+1
'
'  The variable F5TYPE tells us which options in this procedure have been  
'  selected.  If the variable is set to 1, we know that the filled circle  
'  option is in use.  So we check, and if it is we fill the circle with
'  the paint command.  Remember that we still have the centre point of the 
'  circle stored in the variables X and Y, so we just use these in the paint 
'  command so it knows where to start filling! 
'
   If F5TYPE=1 Then Paint X,Y
'
'  And now just to jump back to the BEGIN2 label to do it all again. Phew! 
'
   Goto BEGIN2
'
'  Here is the finished label again, just before the 'End Proc' command so 
'  any part of the above can jump here to finish.
'
   FINISHED:
'
'  And finally,  the end of the FCIRCLE procedure. 
'
End Proc
'
'  Yet another multiple choice procedure!  Not to worry, only two more after 
'  this one. Again, the name has an F before it simply because it's an AMOS  
'  command, that's all.  The options, as before, are for either a filled or
'  un-filled box.
'
Procedure FBOX
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
'
'  Again, as in other procedures selectable from the menu bar, if this 
'  procedure is different from the last one called we need to paste a normal 
'  bob on the menu bar to show the user that the last option selected is no
'  longer in use.  This is done by checking the variable T.  If this 
'  procedure has been by this point before then it will have set the 
'  variable to its procedure number - i.e. 6.  So if we check the variable 
'  T and find it doesn't equal 6 then we need to paste a bob over the last 
'  one that was highlighted.  How ?  Well, the last procedure that was in  
'  use will have set the variables XB,YB and BO with its co-ordinates and bob
'  number, so all we now do is use these to paste an un-highlighted bob at 
'  these positions!
'
   If T<>6 Then Paste Bob XB,YB,BO
'
'  Please see the supplied variables table regarding Easy Paint for details
'  on the following variables and there functions. 
'
   If F6=1 and F6TYPE=1 Then Goto B
   If F6=1 and F6TYPE=0 Then Goto A
   If F6=2 and F6TYPE=0 Then Goto A
   If F6=2 and F6TYPE=1 Then Goto B
   A:
'
'  Here we are pasting a highlighted bob for the unfilled box on the menu bar
'
   Paste Bob 305,62,26
'
'  And here, as mentioned above, we load some variables with the co-ordinates  
'  of the bob, and load the variable BO with the bob number for the normal,
'  un-highlighted box bob.  This is so that when we leave this procedure, the
'  next one can simply read these variables and paste over our highlighted one.
'  Simple eh ?  We also set the variable T to this procedures number - 6 - to  
'  also make sure that if this procedure is reselected for any reason, we dont 
'  want to paste an un-highlighted bob on the menu bar while this is still in
'  use.  Also see above for the check on the T variable.   
'
   XB=305 : YB=62 : BO=5 : T=6 : F6=1
'
   Goto BEGIN
   B:
'
'  Here we paste the highlighted bob for the filled box on the menu bar
'
   Paste Bob 305,62,24
'
'  And again load the variables for our bob position and number in preperation 
'  for when this procedure is left.  We also set the variable T in here as 
'  well because the previous section will obviously get skipped if the user  
'  selects the filled box option.
'
   XB=305 : YB=62 : BO=5 : T=6 : F6=2
'
'  Next comes a label to signify the main body of this procedure.
'
   BEGIN:
'
'  We initiate a loop until the mouse enters the drawing area, while always
'  checking to see if the left mouse key is being pressed while the mouse
'  is outside the drawing area.
'
   Repeat 
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
'
'  The condition of the 'Repeat/Until' loop is to repeat until the mouse 
'  enters the drawing area.
'
   Until Mouse Zone=0
'
'  Now we set up another conditional loop that waits until a mouse key is
'  pressed.  The user will be positioning the mouse at this point, in  
'  preparation for drawing a box.
'
   While Mouse Key=0
'
'  As before, we check for both the crosshairs and co-ordinates, and if they 
'  have been selected, if either variable holds a value of 1, then we do a 
'  jump to the relevant procedures.
'
      If COORDS=1 Then Proc COORDS
      If CROSS=1 Then Proc CROSSHAIRS
'
'  We also make a provision in here, rather than outside the loop, to check  
'  if the left mouse key is pressed in the drawing area.  If it is, then 
'  we copy the screen using the _SCOPY procedure and leave the loop by 
'  jumping to the BEGIN3 label 
'  
      If Mouse Key=1 and Mouse Zone=0 Then Goto BEGIN3
'
'  We must also check to see if the mouse has left the drawing area, and if
'  so, then we must end this procedure by jumping to the FINISHED label. The   
'  chance existing that the user wished to select another option or ink colour 
'  from the menu bar.
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  The next line loads the variables X and Y with the current mouse co-
'  ordinates as long as the loop is cycling.  When we leave the loop this
'  will give us the top left point of the box. 
'
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
'
'  Now we return the loop with the 'Wend' command
'
   Wend 
_SCOPY
'
'  Another label.
'
   BEGIN3:
'
'  And another loop, this time containing the program that will generate   
'  the stretching or rubber banding effect while the left mouse key is being 
'  pressed.
'
   While Mouse Key=1
'
'  We set the drawing mode to XOR so the stretching box will not destroy any 
'  existing drawings.
'
      Gr Writing 2
'
'  And wait 1/50th of a second, purely to slow down the screen update to 
'  help get rid of any flicker will be box is being stretched. 
'
      Wait 1
'
'  Now we load the variables X1 and Y1 with the current screen co-ordintes 
'  of the mouse.  The will be used shortly as target points for the box to 
'  be drawn to.
'
      X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
'
'  And now we set the ink colour to the variable I and draw the box from our 
'  old X and Y variables to the current X1 and Y1 variables. 
'
      Ink I : Box X,Y To X1,Y1 : Wait Vbl 
'
'  As with all rubber banding, we now need to draw an exact image of the last
'  box over the top of the old one to remove it from the drawing area. 
'
      Box X,Y To X1,Y1
'
'  And return the loop with a 'Wend' command.
'
   Wend 
'
'  The next line sets the drawing mode back to normal, ready to draw the final 
'  box on the screen.
'
   Gr Writing 1
'
'  Which is accomplished by drawing a box of the current ink colour at the 
'  last co-ordinates obtained in the above program.
'
   Ink I : Box X,Y To X1,Y1
'
'  The variable F6TYPE holds a number which tells us which of the multiple 
'  choices this procedure possesses has been selected. If this variable holds
'  a value of 1, we know the user wants the box to be filled after it is 
'  drawn.  Note that we have used this method to best show the way options 
'  can be read and acted on.  It would be perfectly acceptable to check for
'  the filled box option above and use the 'Bar' command to draw a filled box
'  'real time'.
'
   If F6TYPE=1 and X1<X Then Bar X1,Y1 To X,Y
   If F6TYPE=1 and X1>X Then Bar X,Y To X1,Y1
'
'  Here we jump back into this procedure to do it again. 
'
   Goto BEGIN
'
'  And the next label is used just before the 'End Proc' command to allow  
'  earlier parts of this procedure to exit immediately.
'
   FINISHED:
'
'  The end of this procedure.
'
End Proc
'
'  Another multiple choice procedure using exactly the same format as the
'  FCIRCLE procedure for filled and unfilled ellipses.  In fact, the only
'  difference is the use of the 'Ellipse' command intead of 'Circle', but I  
'  shant skimp! And I'll detail just whats happening.
'
Procedure FELLIPSE
'
'  This next line checks the T variable to see if this procedure has just
'  been called.  If it hasn't then the T variable will have been set by  
'  another procedure, as well as the variables XB,YB and BO.  Should T not 
'  equal 7 then we paste a bob at the preset co-ordinates stored in these  
'  variables.
'
   If T<>7 Then Paste Bob XB,YB,BO
'
'  Please see the supplied variables list regarding the uses of the following
'  variables.  The lines just determine what choices have been selected and
'  then jump to the relevant label to past the correct highlighted bob on  
'  the menu bar. 
'
   If F7=1 and F7TYPE=1 Then Goto B
   If F7=1 and F7TYPE=0 Then Goto A
   If F7=2 and F7TYPE=0 Then Goto A
   If F7=2 and F7TYPE=1 Then Goto B
'
   A:
'  Here we paste the bob for the unfilled ellipse on the menu bar. 
'
   Paste Bob 292,75,39
'  
'  And then set the variables used by this and other procedures to switch  
'  off the selection on the menu bar by pasting an unhighlted ellipse, also
'  known as bob 16.
'
   XB=292 : YB=75 : BO=16 : T=7 : F7=1
'  
'  Then we jump to the begin label.
'
   Goto BEGIN : 
'
   B:
'
'  He we paste the bob for the filled ellipse on the menu bar. 
'
   Paste Bob 292,75,38
'
'  And then set the variables used by this and other procedures to switch  
'  off the selection on the menu bar by pasting an unhighlted ellipse, also
'  known as bob 16.
'
   XB=292 : YB=75 : BO=16 : T=7 : F7=2
'
   BEGIN:
'
'  Now we initialise a conditional loop that will wait for the mouse to enter
'  the drawing area. 
'
   Repeat 
'
'  But inside we also check to see if the left mouse key has been pressed
'  while the mouse is off the drawing area (zone 0).  If it has then we must 
'  terminate this procedure by jumping to the label FINISHED so that the 
'  user can select another option. 
'
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED : 
'
'  And complete the 'Repeat/Until' with the following command and conditions.
'  So this will return the computer back to the 'Repeat' command until the 
'  mouse enters the drawing area (zone 0)
'
   Until Mouse Zone=0
'
'  Quickly copy the screen now by calling the _SCOPY procedure.
'
   _SCOPY
'
'  And label the start of the procedure proper by the following ...
'
   BEGIN2:
'
'  Initiate another conditional loop now.  We want this is to loop until the 
'  mouse key is pressed. 
'
   While Mouse Key=0
'
'  You should be better either pretty familiar with the procedures layout by 
'  now or very, very annoyed with the repetitiveness.  However !  The next 
'  two lines check to see whether the crosshairs or co-ordinates have been 
'  activated by checking their associated variables.  If either is positive (
'  has a value of 1) then we do a quick jump to the relevant procedure.
'
      If COORDS=1 Then Proc COORDS
      If CROSS=1 Then Proc CROSSHAIRS
'
'  Then load the current mouse co-ordinates into the variables X and Y.  We
'  do this in here so we have a continuous stream of data going into these 
'  variables from the mouse position.  The X and Y variables will eventually 
'  hold the centre point of our ellipse. 
'
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
'
'  A check to see if the user has started drawing.  If the left mouse key
'  has been pressed and the mouse is in the drawing area then we copy the
'  screen and jump to the BEGIN3 label, ready to start drawing.  
'
      If Mouse Key=1 and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
'
'  If the mouse leaves the drawing area (zone 0) we need to end this procedure 
'  and return to check the zones of the menu bar.  We do this with the next
'  line that will jump to the label FINISHED should the conditions be met. 
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  And finish the loop with the next command.
'
   Wend 
   Wait 1
   BEGIN3:
   While Mouse Key=1
      If COORDS=1 Then Proc COORDS
      X1=X Screen(X Mouse)
      Y1=Y Screen(Y Mouse)
      Gr Writing 2
      Ink I : Ellipse X,Y,X1-X+1,Y1-Y+1
      Ellipse X,Y,X1-X+1,Y1-Y+1
   Wend 
   Gr Writing 1 : Ink I : Ellipse X,Y,X1-X+1,Y1-Y+1
   If F7TYPE=1 Then Paint X,Y
   Goto BEGIN2
   FINISHED:
End Proc
'
'  Yes, this is the last of the multiple option procedures.  This next one 
'  is used to draw polygons, with the end result having the option of being
'  either filled or un-filled. 
'
Procedure FPOLYGON
'
'  The following lines share the same format as all the others previously. 
'  We check the T variable first to see if this procedure was the last one 
'  called, and if not, we use the variables set in the previous procedure
'  to paste an un-highlighted bob on the menu bar. 
'
   If T<>8 Then Paste Bob XB,YB,BO
'
'  Look at the variable table to find the meanings of the following variables. 
'  Depending on their contents we know which part of this procedure to jump
'  to. 
'
   If F8=1 and F8TYPE=1 Then Goto B
   If F8=1 and F8TYPE=0 Then Goto A
   If F8=2 and F8TYPE=0 Then Goto A
   If F8=2 and F8TYPE=1 Then Goto B
'
'
   A:
'
'  Here we paste the highlighted bob for the un-filled polygon tool on the 
'  menu. 
'
   Paste Bob 305,75,30
'
'  And then set the following variables so any other procedure like this one 
'  knows where to paste the de-selected bob on the menu bar - bob number (9).  
'
   XB=305 : YB=75 : BO=9 : T=8 : F8=1
'
'  Now we jump to the BEGIN label to enter the procedure proper. 
'
   Goto BEGIN
'
   B:
'
'  Here we paste the highlighted bob for the filled polygon tool on the menu 
'  bar.
'
   Paste Bob 305,75,31
'
'  And then set the following variables so any other procedure like this one 
'  knows where to paste the de-selected bob on the menu bar - bob number (9).  
'
   XB=305 : YB=75 : BO=9 : T=8 : F8=2
'
'  Next comes the label that marks the actual or proper part of this 
'  procedure.
'
   BEGIN:
'
'  Now we initialise a conditional loop that will wait for the mouse to
'  enter the drawing area, otherwise known to us and the computer and zone 0 
'
   Repeat 
'
'  All the while this loop is cycling we check here to see if the left mouse 
'  key is pressed while the mouse is out of the drawing area, this is so any 
'  other option can be selected. If we find that this action has been met  
'  then we must leave this procedure by jumping to the FINISHED label. 
'
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
'
'  And complete the loop with our conditions.  This will now cycle until the 
'  conditions are met ...
'
   Until Mouse Zone=0
'
'  Upon which we jump out to this next line.  Simply a label.
'
   BEGIN2:
'
'  Initialise another loop now.
'
   Repeat 
'
'  Same as before, the next lines check to see if either the cross-hairs 
'  or co-ordinates have been selected, and if either variable holds a value
'  of 1 then we jump to the relevant procedures. 
'
      If COORDS=1 Then Proc COORDS
      If CROSS=1 Then Proc CROSSHAIRS
'
'  The next two lines load the variables X, Y, X1 and Y1 with the current
'  x and y co-ordinates of the mouse.  I load all the variables here so as 
'  to give the procedure a full set of points to draw from initially.  If
'  I didn't then as soon as the mouse key was pressed, a line would be drawn 
'  from the top left of the screen because there was no start point.  This 
'  is so as to 'anchor' the start point when the left button is pressed. 
'
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
      X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
'
'  Checking again to see if the mouse has left the drawing area, and if it 
'  has then we need to end the procedure by jumping to the finished label. 
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  And define the conditions of this loop with the following line.  We want  
'  the above loop to cycle until the mouse key is pressed. 
'
   Until Mouse Key=1
'
'  A very short wait of a 1/50th of a second now, just to give the computer
'  a bit of breathing space. 
'
   Wait 1
'
'  And now we label the drawing part of this procedure.
'
   BEGIN3:
'
'  We use the next loop to tell the computer to cycle through the contents 
'  of the loop until the mouse key is press.  We have already 'anchored' the 
'  starting point of our polygon so now we need to 'rubber band' the line
'  until the user sees it how he wants it. 
'
   While Mouse Key=0
'
'  Yet again we check the cross-hairs and co-ordinates, if either have a 
'  value of 1, then we quickly jump to the relevant procedures.
'
      If COORDS=1 Then Proc COORDS
      If CROSS=1 Then Proc CROSSHAIRS
'
'  The next line sets up the XOR drawing mode so can give the illusion of
'  stretching (rubber banding).
'
      Gr Writing 2
'
'  And re-load the X1 and Y1 variable with the new target location of the
'  mouse.  These hold the point at which the line will be drawn to.
'
      X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
'
'  Next we set the ink colour the current value stored in I, and then draw 
'  the actual line between X and Y (the 'anchored' points) and X1 and Y1, the
'  current co-ordinates of the mouse.
'
      Ink I : Draw X,Y To X1,Y1
'
'  We now wait another 1/50th of a second to ease up on the flickering of
'  the display.
'
      Wait 1
'
'  And then draw an exact duplicate of the last line to remove it from the 
'  display.  Remember, anything drawn in XOR mode and then drawn over will be
'  removed without destroying any graphics underneath. 
'
      Draw X,Y To X1,Y1
'
'  Next is a check to see if either the mouse has left the drawing area or 
'  the right mouse key has been pressed.  We give the option for the right 
'  mouse button here to avoid having to leave the drawing area just to finish
'  drawing a polygon.  And of course, should the mouse leave the drawing area
'  then we must end this procedure by jumping to the FINISHED label. 
'
      If Mouse Key=2 or Mouse Zone<>0 Then Goto FINISHED
'
'  And return the loop with the next command.
'
   Wend 
'
'  So we are now at the point whereby the user has pressed the mouse key.
'  We know that this means he wishes to fix the last line onto his display 
'  so we revert back to the normal drawing mode with the next command, ready 
'  to draw in the line with ...
'
   Gr Writing 1
'
'  ... this next line, first setting the ink colour to the current value.  
'
   Ink I : Draw X,Y To X1,Y1
'
'  Now as we are drawing a polygon, the last point in this line becomes the
'  the start point of the next.  So we load the X and Y variables with these 
'  values held in X1 and Y1. 
'
   X=X1 : Y=Y1
'
'  And jump to the BEGIN3 label to begin stretching the next part of this
'  polygon.
'
   Goto BEGIN3
'
'  As with every other procedure in this program, we place our FINISHED label
'  just before the End Proc command in case any part of the procedure needs
'  to end immediately, e.g if the mouse leaves the drawing area to select  
'  another option. 
'
   FINISHED:
'
'  The end of this procedure.
'
End Proc
'
'  Phew, I am almost as relieved to be documenting this next procedure as
'  you will be to be reading it.  Only thirteen lines long!  But then
'  again, all it does it set the cross-hairs variable to on or off.
'
Procedure FCROSS
'
'  Here we check to see what state this procedure is in.  We know if it is 
'  currently active by reading the F9 variable.  If the value of F9 is 1 
'  then we know that the cross-hairs are activated, if not then this line
'  is ignored. 
'
   If F9=1 Then Goto B
'
'  A simple label next.
'
   A:
'  
'  Now we paste the highlighted bob on the menu bar to show that the cross-
'  hairs are activated.
'
   Paste Bob 292,88,32
'
'  Then comes the setting of the F9 variable to let the computer know that 
'  the cross-hairs have been switched on.
'
   F9=1
'
'  And set the CROSS variable to let the other procedures know whether or
'  not to call the cross-hairs procedure (CROSSHAIRS)
'
   CROSS=1
'
'  Then we jump out of this procedure because that's all there is to it! 
'
   Goto FINISHED
'
'  The other part of this procedure is to ... switch off the crosshairs, so  
'  we start with a label.
'
   B:
'
'  Next we set the CROSS variable to 0, just so the other procedures know not
'  to call the cross-hairs procedure.
'
   CROSS=0
'
'  And paste the un-highlighted bob on the menu bar with the next line.
'
   Paste Bob 292,88,10
'
'  Then we set the F9 variable to 0, to let this procedure know that the 
'  user has cancelled the cross-hairs.  Remember that this variable is the 
'  first one checked by this procedure.
'
   F9=0
'
'  And we are finished, so we label the end with the next line.
'
   FINISHED:
'
'  And end the procedure with the next command.
'
End Proc
'
'  NOTE, the next procedure is unfinished and un-documented. 
'
Procedure F10
   If T<>10 Then Paste Bob XB,YB,BO Else Goto FINISHED
   Paste Bob 305,88,33
   XB=305 : YB=88 : BO=11 : T=10
   FINISHED:
End Proc
'  
'  The next procedure is another very simple piece of program that we use
'  to fill in any shapes with the current ink colour.  Again, this one is
'  really quite short. 
'
Procedure FFILL
'
'  We start again by checking the T variable to see if this procedure has
'  been called last.  If the T variable doesn't equal 11 (this procedures
'  number) then we can use the variables XB,YB and BO to paste an un-high
'  lighted bob of the last called procedure on to the menu bar.
'
   If T<>11 Then Paste Bob XB,YB,BO Else Goto BEGIN
'
'  Otherwise we paste the highlighted bob for this procedure on the menu 
'  bar ... 
'
   Paste Bob 292,101,41
'
'  And load up the next variables with its counterpart, the un-highlighted 
'  bob and co-ordinates, so any other procedure knows where to paste it. 
'
   XB=292 : YB=101 : BO=18 : T=11
'
'  The following line is simply a label to show the actual working part of 
'  this procedure. 
'
   BEGIN:
'
'  A quick loop now to wait until the mouse enters the drawing area from 
'  the menu bar.  Inside the loop we will also check to see if the user has
'  made another selection to cancel this one by checking to see if the left
'  mouse key has been pressed while the mouse is not on the drawing area.
'  If it has then we must end this procedure by jumping to the FINISHED label
'
   Repeat 
      If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
   Until Mouse Zone=0
'
'  A quick copy of the screen would be helpful now in case the user happens
'  to fill the wrong part of his picture.  The undo feature will make use of 
'  this by copying the image we are about to copy back to the drawing area 
'
   _SCOPY
'
'  And now we come the final part of this procedure, labeled with the next 
'  line. 
'
   BEGIN2:
'
'  No fancy conditional loops here, just a simple 'Do/Loop' to keep cycling  
'  its contents. 
'
   Do 
'
'  Check the COORDS variable for a value of 1, and if we find it we want to
'  display the co-ordinates on screen by calling the COORDS procedure. 
'
      If COORDS=1 Then Proc COORDS
'
'  This next line is waiting for a mouse key press, any key, while the mouse 
'  pointer is in the drawing area.  If this happens then we make a copy of 
'  the screen (yes, for the undo feature!) then jump to the BEGIN3 label.
'
      If Mouse Click and Mouse Zone=0 Then _SCOPY : Goto BEGIN3
'
'  Because this is a closed loop that will loop indefinately, we need some 
'  way of getting out of this procedure.  The next line waits for the mouse
'  to leave the drawing area and then jumps to the label FINISHED, which as
'  you must know by now, is placed before every 'End Proc' command.
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  Then return the loop
'
   Loop 
'
'  We label the next line such so the above loop can jump here is the user 
'  presses a mouse key. i.e. when he wants to fill a shape.
'
   BEGIN3:
'
'  We take the precaution here of setting the fill pattern with the current
'  value held in the variable PATTERN.  It saves us wasting any more lines on  
'  something so trivial.  Next comes the current ink colour held in the  
'  variable I, and finally we use the command 'Paint' to fill from the current 
'  mouse position in screen co-ordinates.  If your unsure about screen co-ords 
'  and their uses then please read the notes that accompany this program!
'
   Set Pattern(PATTERN) : Ink I : Paint X Screen(X Mouse),Y Screen(Y Mouse) : Goto BEGIN2
'
'  The FINISHED label used to mark the end of the procedure. 
'
   FINISHED:
'
'  And the command to end this current mother ...
'
End Proc
'
'  Okay Program Pickers,  this next procedure is starting to move toward 
'  the hazy depths again but I'll try my darndest to keep it simple.  So 
'  please forgive the heavy documentation.  This procedure is responsible
'  for cutting and pasting flipped and not-flipped brushes.  So stick with 
'  me on this one, and it may help to know that some of the program lines
'  are a little larger than the screen display.  Lets GO !!  
'
Procedure FBRUSHCUTTER
'
'  First things first, and the next line checks the T variable for a value of
'  12 and if it doesn't find it pastes the un-highlighted bob for the last 
'  procedure the user used by reading the variables XB,YB and BO.  If the  
'  value equals 12 then we know the last procedure in use was this one, so we  
'  skip this bit by jumping to BEGIN label.
'
   If T<>12 Then Paste Bob XB,YB,BO Else Goto BEGIN
'
'  Next we paste the highlighted bob for this procedure on the menu bar... 
'
   Paste Bob 305,101,29
'
'  And load the following variables with the co-ordinates XB and YB.  BO will
'  hold the bob number for the un-highlighted bob of this procedure, and T is
'  the number of the procedure, same as was checked above. 
'
   XB=305 : YB=101 : BO=8 : T=12
'
'  And label the begin with, funnily enough, BEGIN 
'
   BEGIN:
'
'  Then we check with the next line for the mouse to leave the menu bar and
'  enter the drawing area (zone 0).  If the mouse key is pressed while the   
'  mouse is not on the drawing area then we should end the procedure by  
'  jumping to the end of this procedure labeled by the FINISHED label. 
'
   Repeat 
      If Mouse Zone<>0 and Mouse Key=1 Then Goto FINISHED
'
'  And of course, we must give the loop our conditions with the next line. 
'
   Until Mouse Zone=0
'
'  Now we move on, continually cycling through this next loop while the user 
'  is not pressing any buttons on the mouse. thus we use the 'While/Wend'
'  loop. 
'
   While Mouse Key=0
'
'  Check next the COORDS variable for a value of one (on) and if we find it
'  we display the current co-ordinates of the mouse by jumping to the COORDS 
'  procedure.
'
      If COORDS=1 Then Proc COORDS
'
'  Next we load the variables X and Y with current screen co-ordinates of the
'  mouse.  A description of screen and hardware co-ordinates can be found in 
'  notes relating to this program. 
'
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
'
'  And if the mouse leaves the drawing area - if it leaves zone 0, then we 
'  must end by jumping to the FINISHED label.
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  And return the loop with the next command ... 
'
   Wend 
'
'  Next we initialise another loop that will logically continue from the 
'  previous loop by checking for the left mouse key to be pressed. 
'
   While Mouse Key=1
'
'  If the key is pressed then we end up inside this loop to execute the
'  following lines.  The first one of which being a check on the COORDS  
'  variable for a value of 1.  If we find that the condition has been met
'  then we know the user has requested earlier that he wants the co-ordinates
'  to be displayed, so we jump to the co-ordinates procedure (COORDS)
'
      If COORDS=1 Then Proc COORDS
'
'  Again, if the mouse leaves the drawing area we terminate this procedure 
'  so we can check for an alternate selection from the menu bar.  We do this 
'  by jumping to the FINISHED label. 
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  Now we set up the XOR drawing mode as described in earlier procedure.  This 
'  is so we can display a stretchable box that will cut out the correct brush. 
'
      Gr Writing 2
'
'  And wait 1/50th second to steady the display - yes, a Wait VBL will do  
'  exactly the same, but I use this line for the sake of clarity.
'
      Wait 1
'
'  Now we load the variables X1 and Y1 with the new co-ords of the mouse.  
'  These hold the values that will be used to draw the box to, remember the  
'  last loop stored the start points of our box in the variables X and Y.
'
      X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
'
'  And then we set the ink colour to the value stored in the variable I.  Now
'  comes the actual drawing of the box between our values stored in the
'  variables X, Y, X1 and Y1.
'
      Ink I : Box X,Y To X1,Y1 : Wait 1
'
'  Remember that we are now in XOR drawing mode, so anything we redraw will
'  be removed from the display without damaging any existing graphics.  This 
'  is what we do next - draw the exact same box as the last line.
'
      Box X,Y To X1,Y1
'
'  And return the loop with the next command.  Do please remember that the 
'  above will only be executed while the mouse key is being pressed ...
'
   Wend 
'
'  Once it is released we need to set the graphics mode back to normal with  
'  the next line.
'
   Gr Writing 1 : Wait 2
'
'  Now comes a very simple part of this procedure.  When we loaded the X and 
'  Y variables with our start point, those values remain fixed.  AMOS will 
'  not allow you to use negative values when grabbing a bob, it will halt the  
'  program and generate an error.  By negative values I mean, if the X1  
'  variable becomes less than the starting point - X.  We can get around this
'  by checking these variables ourselves before we get the bob, or brush as
'  art programs call them, and if X1 is less than X we simply swap the 
'  contents, the result being exactly the same.  The method is already taken 
'  care of in AMOS with the command 'Swap'.  The next lines do this with both
'  the X and Y type variables.  Simple eh? Ha ha.
'
   If X1<X Then Swap X,X1
   If Y1<Y Then Swap Y,Y1
'
'  Another 1/50 of a second pause. 
'
   Wait 1
'
'  And we grab the bob (brush) with the next line.  We are using bob 80 just 
'  to be on the safe side but any number other than bobs used by the program 
'  are equally well available - up to the limit you have defined in your 
'  AMOS configuration. The same line also sets the hot-spot of our bob.  This
'  blockbusters sounding command simply positions a point on the newly cut 
'  bob that the computer uses to position it on the screen, and by using the 
'  value $0 (hex) we tell the computer that we want the hot spot positiong 
'  at the top-left corner.  A table of preset positions can be found in the
'  AMOS manual, as well as instructions on how to place the Hot-Spot at any
'  X,Y location. 
'
   Get Bob ,80,X,Y To X1,Y1 : Hot Spot 80,$0
'
'  The next line puts all of the above variables into a new set, a copy, if  
'  you will, that will stay static, unlike the above that will change as soon
'  as the mouse is moved.  These are used by the computer so it can remember 
'  the point at which the bob (brush) was cut from .. more later ! 
'
   BX=X : BY=Y : BX1=X1 : BY1=Y1
'
'  A label.
'
   BEGIN2:
'
'  Dont be put off by the next few lines, there is nothing complex here, but I 
'  will go through them singly so you can grasp what each line is doing. It
'  may also help you to understand what we are doing if you what state this
'  procedure is currently at.  Well, at this point the user has just cut out 
'  his brush and is locating a point at which he is going to paste it into his 
'  picture.  From the above label onwards this part will continually move the
'  bob number 80 (the brush) to the current mouse co-ordinates, but we also
'  have to check if the user has selected any other command that will alter
'  the appearance of the brush...
'    
'  First we can check if the user wants the brush flipped horizontally by
'  reading the variable HFLIP.  This variable will hold a value of 1 if the
'  brush is to be flipped.  If this isn't the case then we just move the brush 
'  to the current mouse co-ordinates without any change.  Just as a precaution 
'  we set the hot-spot to the top left corner of the bob again as flipping the 
'  brush will also flip the hot-spot, and we always want to handle this brush
'  from the top-left corner. 
'
   If HFLIP=0 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),80 : Hot Spot 80,$0
'
'  If the HFLIP variable holds a value of 1 then we must flip the bob on its 
'  horizontal axis.  This again is a command of AMOS' and couldn't be simpler
'  to implement.  When we display the bob with the 'Bob' command, the last 
'  number in the line holds the number of the bob to be displayed.  If we
'  use the command 'Hrev' instead of a lone bob number, the bob number in
'  brackets will be flipped horizontally.  Again we reset the Hot-Spot.
'
   If HFLIP=1 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),Hrev(80) : Hot Spot 80,$0
'
'  Next we have to check if the brush is to be displayed flipped vertically
'  as well as horizontally, i.e should the brush be reversed ?  We already 
'  have seen that the HFLIP variable holds the status of the horizontal flip 
'  so it should only follow that the VFLIP variable should hold the status of
'  the vertical.  Again, AMOS makes this easy for us by supplying the command
'  'Rev'.  When used, this command will reverse the bob number in brackets.
'  This is what the next line does, and of course, resets the Hot-Spot.
'
   If HFLIP=1 and VFLIP=1 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),Rev(80) : Hot Spot 80,$0
'
'  Now we check for just the vertical flip.  If the conditions at the start of 
'  the next line are met, then we simply use another AMOS command to flip the
'  bob vertically - 'Vrev', again, the image to be flipped is placed in  
'  brackets. 
'
   If HFLIP=0 and VFLIP=1 Then Bob 1,X Screen(X Mouse),Y Screen(Y Mouse),Vrev(80) : Hot Spot 80,$0
'
'  And next, probably the most popular line in Easy Paint.  A simple check to
'  see if the mouse has left the drawing area, and if it has, we leave this
'  procedure by jumping to the FINISHED label. 
'
   If Mouse Zone<>0 Then Goto FINISHED
'
'  Now we come to the part of this procedure that allows the user to fix his 
'  brush on to the picture, as well as drawing with it.  So to enable this 
'  we set up a loop that will only cycle while the left mouse key is pressed 
'
   While Mouse Key=1
'
'  Inside this loop, we also check to see if the co-ordinates have been  
'  requested by reading the COORDS variable.  If we find a value of 1 (on) 
'  then we jump to the COORDS procedure to display them. 
'
      If COORDS=1 Then Proc COORDS
'
'  Yes, again !  Check for the mouse to leave the drawing area (zone 0) and
'  if it does then we leave this procedure by jumping to the FINISHED label
'  with the next line. 
'
      If Mouse Zone<>0 Then Goto FINISHED
'
'  Now we turn off the bob we cut from the display (80) with the next command. 
'  We do this just to remove it from the display, this command does not  
'  delete the bob from memory. 
'
      Bob Off 1
'
'  And reset the hot-spot - just in case.
'
      Hot Spot 80,$0
'
'  Next, as before, we have got to know what state the bob is in, i.e. is it 
'  reversed or flipped ?  The next four lines do exactly the same as the 
'  others except that these are pasting-fixing-the brush on to the display.  
'
      If HFLIP=0 and VFLIP=0 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),80
      If HFLIP=1 and VFLIP=0 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),Hrev(80)
      If HFLIP=1 and VFLIP=1 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),Rev(80)
      If HFLIP=0 and VFLIP=1 Then Paste Bob X Screen(X Mouse),Y Screen(Y Mouse),Vrev(80)
'
'  And return the loop with the next line. 
'
   Wend 
'
'  But of course, if no button is pressed, we still want to display the bob
'  on our screen.  So the next line jumps back up to the label BEGIN2. 
   Goto BEGIN2
'
'  And label the end of this procedure with ...
'
   FINISHED:
'
'  Then turn off any bobs that may have slipped through the net. 
'
   Bob Off 
'
'  Now end the procedure. Thankity fuck for thatity that twat. 
'
End Proc
'
'  Next up is the procedure responsible for magnifying portions of the 
'  screen.  There's a little bit of maths involved but nothing heavy.  If
'  you would care to read the notes supplied regarding Easypaint then you
'  will see a graphical representation of what is actually happening when
'  we use this procedure.  Other than the actual magnifying command (Zoom) 
'  the procedure adheres to exactly the same format as all the previous  
'  procedures.  I also haven't documented it because its shit at the moment  
'
Procedure F13
'
'  This beginning is terribly fucked at the moment.
'12
   If T<>13 Then Paste Bob XB,YB,BO
   Paste Bob 292,114,34
   XB=292 : YB=114 : BO=12 : T=13
Get Block 1,8,8,176,176
   BEGIN:
   Repeat 
      If COORDS=1 Then Proc COORDS
If Mouse Key=1 and Mouse Zone<>0 Then Goto FINISHED
 Until X Screen(X Mouse)<240
   Gr Writing 2
Ink I
Wait Vbl 
While Mouse Key=0
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
X=(X/8)*8
Y=(Y/8)*8
Wait 5
       Ink I : Box X,Y To X+40,Y+40
Wait 5
       Ink I : Box X,Y To X+40,Y+40
      If Mouse Zone<>0 Then Gr Writing 1 : Goto FINISHED
   Wend 
   BEGIN2:
Gr Writing 1
Ink 0 : Bar 12,28 To 147,162
Ink I
Box 14,30 To 145,161
'  These hold the position of the area to be zoomed
WIDTH=(X/8)*8
HEIGHT=(Y/8)*8
Repeat 
A$=Inkey$
LLKKOO=Scancode
 FASTZOOM
If LLKKOO=79 Then WIDTH=WIDTH-8
If LLKKOO=78 Then WIDTH=WIDTH+8
If LLKKOO=76 Then HEIGHT=HEIGHT-8
If LLKKOO=77 Then HEIGHT=HEIGHT+8
MZZ=Mouse Zone
If MZZ=22 and Mouse Key=1 Then I=Point(X Screen(X Mouse),Y Screen(Y Mouse)) : Proc ZCOLBAR : Ink I
While Mouse Key=1
TX=(X Screen(X Mouse)/4)+WIDTH-4 : TY=(Y Screen(Y Mouse)/4)+HEIGHT-8
Wait 2
TX1=(X Screen(X Mouse)/4)+WIDTH-4 : TY1=(Y Screen(Y Mouse)/4)+HEIGHT-8
FASTZOOM
NULL:
A$=Inkey$
If A$=" " Then Goto FINISHED
X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
MZZ=Mouse Zone
If MZZ=22 and Mouse Key=1 Then I=Point(X Screen(X Mouse),Y Screen(Y Mouse)) : Proc ZCOLBAR : Ink I
If X<14 or X>145 or Y<30 or Y>161 Then Goto NULL
Draw TX,TY To TX1,TY1
Wend 
SET=0
Until A$=" "
   FINISHED:
Put Block 1
End Proc
'
'  Nothing in the next procedure 
'
Procedure F14
   If T<>14 Then Paste Bob XB,YB,BO Else Goto FINISHED
   Paste Bob 305,114,35
   XB=305 : YB=114 : BO=13 : T=14
   FINISHED:
End Proc
'
'  Nothing in the next procedure 
'
Procedure F15
   If T<>15 Then Paste Bob XB,YB,BO Else Goto FINISHED
   Paste Bob 292,127,73
   XB=292 : YB=127 : BO=72 : T=15
   If PAGE=0 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 14 : Unpack 15 To 0 : PAGE=1 : Proc SETUPSCREEN : Change Mouse 2
   FINISHED:
End Proc
'
'  Nothing in the next procedure 
'
Procedure F16
   If T<>16 Then Paste Bob XB,YB,BO Else Goto FINISHED
   Paste Bob 305,127,40
   XB=305 : YB=127 : BO=17 : T=16
   If PAGE=1 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 15 : Unpack 14 To 0 : PAGE=0 : Proc SETUPSCREEN : Change Mouse 2
   FINISHED:
End Proc
'
'  Next comes the procedure that belongs to the 'UNDO' button.  It's very  
'  simple, just copying screen 1 to the current drawing screen - screen 0
'  whenver it is called
'
Procedure FUNDO
'
'  We check here if the last procedure called was this one, and if not 
'  we paste the un-highlighted bob on the menu bar for the last used pro-
'  cedure. 
'
'
'  Now we paste the highlighted bob for this procedure on the menu bar.
'
   Paste Bob 292,140,36
'
'
'  Label the 'doing' part of this procedure next.
'
   BEGIN:
'
'  And set the skip variable to one.  The tells the procedure that checks
'  the various screen zones that this procedure has been used and not to 
'  come here again until some kind of drawing operation has been done that 
'  will justify coming here again. 
'
   SKIP=1
'
'  Then we copy the drawing area from screen 1 back to screen 0.  The numbers
'  just tell the computer ONLY to copy to drawing area and not the title and 
'  menu bars.
'
   Screen Copy 1,1,11,290,263 To 0,1,11
'
'  Then we bring the newly copied image to the front of the display with the 
'  next line.
'
   Screen To Front 0
   Paste Bob 292,140,14
'
'  And end the procedure ... 
'
End Proc
'
'  Next up is the screen clearing procedure and this must be the simplest  
'  ever.  It simply uses the AMOS command 'Cls' with the dimensions of our 
'  drawing area to clear both screen 0 and 1.  
'
Procedure FCLS
'
'  I wont bother boring you with the next lines as we've gone over them
'  seventeen times already and these are no different. 
'
   Paste Bob 305,140,37
   BEGIN:
'
'  Here we just set the graphics pointer to screen 0 and then clear it 
'  will the 'Cls' command and the dimensions of our screen.
'
   Screen 0 : Cls 0,1,11 To 290,263
'
'  Same again for screen 1 
'
   Screen 1 : Cls 0,1,11 To 290,263
'
'  And reset the graphics pointer back to screen 0 for further drawing.
'
   Screen 0
'
'  We paste the un-highlighted bob for this procedure on the menu bar our
'  selves, because this procedure ends immediately.
'
   Paste Bob 305,140,15
'  
'  And end it with the next line.
'
End Proc
'
'
'  Down here is the procedures that actually do something, the ones that 
'  do the hard work.  All of procedures above are just responsible for 
'  calling the ones down here.  Some do seem a little daunting, but as before
'  if you stick with me as we plough through them, you'll soon see that there
'  is nothing in them that will bring out a sweat.  As it goes, Easypaint  
'  was a very simple program to write, the hardest part being writing this 
'  documentation!  So don't lose heart now.
'
Procedure RAYLINE
   While Mouse Key=0
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
   Wend 
   BEGIN:
   While Mouse Key=1
      X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
   Wend 
   Draw X,Y To X1,Y1
   X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
   If Mouse Key=2 Then Goto FINISHED
   Goto BEGIN
   FINISHED:
End Proc
Procedure AIRBRUSH
PROG=20
   BEGIN:
Repeat 
If Mouse Key=2 or Mouse Zone<>0 Then Goto FINISHED
If Mouse Zone=22 and Mouse Key=1
I=Point(X Screen(X Mouse),Y Screen(Y Mouse))
Ink I
Proc ZCOLBAR
End If 
Until Mouse Key<>0
_SCOPY
While Mouse Key=1
   If Mouse Zone<>0 and Mouse Zone<>22 Then Goto FINISHED
      X1=Rnd(10) : Y1=Rnd(10)
      X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
If X<6 or X>284 or Y<16 or Y>257 Then Goto BEGIN
Ink I : Plot X-5+X1,Y-5+Y1
      If DENSITY=0 Then Goto FINISHED Else For LOP=1000 To DENSITY*10 Step -1 : Next LOP
      MIDDLE:
   Wend 
   Goto BEGIN
   FINISHED:
End Proc
'
'  Here's the cross-hairs procedure - those horizontal and vertical lines
'  that cross through the mouse pointer.  Again, extremely easy to implement.
'
Procedure CROSSHAIRS
'
'  First of all we don't want the cross-hairs to be writing over any of the
'  users graphics so we set the drawing mode to XOR.  This is the term also
'  known as 'Exclusive Or', loosely translated means that anything drawn twice 
'  in the same place will be removed without harming existing graphics.
'
   Gr Writing 2
'
'  And we mark the actual 'doing' part of this procedure with the popular
'  label 'Begin' 
'
   BEGIN:
'
'  Now we load the X and Y variable with the current mouse position on the 
'  screen because we will need these positions to draw our cross-hairs.
'
   X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
'
'  Next up comes a check on variables.  First we check the X variable to see 
'  if it is less than 0 or greater than 289.  The numbers are the left and 
'  right borders of the drawing area, and if the X variable exceeds either one 
'  then we dont want to past that point do we, otherwise the menu bar and top  
'  title line will become all messy! Otherwise we jump to the FINISHED label 
'  if the next line checks out.  
'
'  If X<0 or X>289 Then Goto FINISHED
'
'  Same now for the Y variable.  Remember the Y variable holds the vertical  
'  position of the mouse, so we check if Y is less than 12 (the top of the 
'  drawing area) or greater than 263 (the bottom of the drawing area).  If 
'  either proves to be true then we jump to the FINISHED label to end this 
'  procedure.  You could just Run this program now to see the effect when
'  the cross-hairs are switched on and you leave the drawing area. 
'
   If Y<12 or Y>263 Then Goto FINISHED
'
'  Now we simply draw to straight lines using the position of the mouse we 
'  just put into the variables X and Y.  First we draw the vertical line the 
'  size of the screen X pixels horizontally.  Note that there is a graphic 
'  description of these two lines in the notes supplied in the package, look 
'  under Easypaint.
'
   Draw X,13 To X,263
'
'  Then we draw the horizontal line the size of the drawing area using the 
'  Y variable as a starting point. 
'
   Draw 0,Y To 289,Y
'
'  Another label now.  This one preceeds the next line for a good purpose. 
'  If the user stops moving the mouse then we dont want to keep drawing the
'  cross-hairs all the time do we ?  Not only is it pointless but it also
'  generated an annoying flicker, this label stops this by giving this 
'  procedure somewhere to go without re-drawing the lines. 
'
   BEGIN2:
'
'  Here's the check that will see if the mouse is stationary.  It does this
'  by checking the current position of the mouse with the last positions we
'  previously stored in X and Y.  If both match then we jump to the above
'  label. Since this is a potentially close loop we must also check for the
'  mouse to leave to drawing area
'
If Mouse Zone<>0 or Mouse Key=1 Then Goto BEGIN3 : 
   If X Screen(X Mouse)=X and Y Screen(Y Mouse)=Y Then Goto BEGIN2
BEGIN3:
'
'  Next is a wait for a vertical blank.  This is the time it takes the 
'  beam in your TV or monitor to return to the top of the picture to start 
'  burning phospur again.  Pointless info maybe, but it helps to reduce the
'  flicker when drawing the cross-hairs. 
'
   Wait Vbl 
'
'  And now we draw the cross-hairs again, exactly the same as before to remove 
'  them from the display.  We are still in XOR mode so nothing will be 
'  destroyed on the users picture. 
'
   Draw X,12 To X,263
   Draw 0,Y To 289,Y
'
'  And we set the drawing mode back to normal with the next command
'
   Gr Writing 1
'
'  We still use the FINISHED label to mark the end of this procedure should
'  any line above want to end. 
'
   FINISHED:
'
'  Of course, 'End Proc' tells the computer that this is the end of this 
'  procedure.  NOTE, you will have probably noticed that this procedure only 
'  draws the cross-hairs once and then ends, it is the reponsibility of other
'  procedure to call this procedure in their main loop, as I'm sure you can  
'  remember !
'
End Proc
'
'  Now the smallest procedure in this program, three lines that simply copy  
'  an exact image of the drawing area into screen 1.   
'
Procedure _SCOPY
'
'  The next line does the copying, the numbers are the co-ordinates of the 
'  drawing area.  A screen chart is available in the notes that accompany
'  this program, and don't forget that command formats can be found in the 
'  AMOS user guide you got with your AMOS package. 
'
   Screen Copy 0,1,11,290,263 To 1,1,11
'
'  Now we set the graphics pointer back to Screen 0, just to make sure that
'  our drawing operations will take place on our drawing, and not some spare 
'  screen. 
'
   Screen 0
'
'  And end this procedure. 
'
End Proc
'
'  Another small procedure now.  This one prints the co-ordinates of the 
'  mouse on the top menu bar.
'
Procedure COORDS
'
'  We start by loading the co-ordinates of the mouse into the variables XX 
'  and YY.   
'
   XX=X Screen(X Mouse)
   YY=Y Screen(Y Mouse)
'
'  The next line may seem a little alien ?  What we are doing is loading the 
'  variable C$ with a string conversion of the variables XX and YY.  Why ?   
'  Well we need to convert the numeric variables into strings because of the 
'  way we need to display the information with the 'Text' command. It's best 
'  to put the information into a single string variable (C$) than have lots
'  of conditions in the 'Text' command, otherwise we will have lots and lots 
'  of hassle.
'
   C$=Str$(XX)+" "+Str$(YY)+" "
'
'  Now we set the ink colour to 0 (black) regardless of the ink colour the 
'  program is currently using.  We use the 'Text' command instead of a 'Print' 
'  for the benefit of being able to position our text to the nearest pixel 
'  rather than character position.  The numbers the pixel position on the
'  top title bar.
'
Gr Writing 1 : Ink 0 : Text 232,7,C$
'
'  And end the procedure.
'
End Proc
'
'  The next three procedure are used to read the pull-down menus.  It may
'  help you to understand what each one is doing by reading the notes  
'  supplied for the Easy Paint program that explain the menu' layout.
'  Due to the length of the program lines, it has also been necessary for  
'  this and other reasons to explain these procedures in the notes.  I 
'  apologise for any inconvenience this may cause, but I'm sure you'll 
'  see it is the better way of doing it. 
'
Procedure MENCHECK1
'
'  The way pull down menus are created is a bit like a family tree, with 
'  each option having options leading from it, and those also having options 
'  leading from them.  We can check which option has been selected by using
'  the 'Choice' command with a value in brackets denoting which part of the
'  'tree' we want to read.  So the next line reads each tree into three
'  variables A, B and C.  More information is available in the AMOS manual 
'  and the notes supplies with this program
'
   A=Choice(1) : B=Choice(2) : C=Choice(3)
'
'  Now we come to read the variables to find which menu option has been  
'  selected, there is no quick way around this, so each option has to be 
'  read individually.  What we do know though, is that we wouldn't be in   
'  this procedure unless an option had been selected from the Picture
'  menu.  Remember a long while back at the start of this program we set 
'  up an interrupt that read the pull-down menus full time ?  Well, we also
'  told the computer to jump to the respective procedures, these being 
'  MENCHECK1, MENCHECK2 and MENCHECK3 which relate to the menu options of
'  'Picture', 'Brush' and 'Prefs'.  It's really quite pointless explaining 
'  every line as you can see what is being done, the variables A, B and C
'  hold numbers that relate to the option selected.  We just check these 
'  numbers and jump to the procedure that relates that option. 
'
'  The FILESELECTOR has three types to it - LOAD, SAVE and DELETE, the number
'  in brackets holds the type we wish to use.
'
   If A=1 and B=1 Then Proc FILESELECTOR[1] : Screen 0
   If A=1 and B=2 Then Proc FILESELECTOR[2] : Screen 0
   If A=1 and B=3 Then Proc FILESELECTOR[3] : Screen 0
'
'  The procedure SELECTPALETTE is the palette selector.  
'
   If A=1 and B=4 and C=1 Then Proc SELECTPALETTE
'
'  The procedure DEFPALETTE is responsible for setting the pallete back to 
'  its default values. 
'
   If A=1 and B=4 and C=2 Then Proc DEFPALETTE
'
'  The next 6 lines are much larger than this display so you may need to 
'  scroll the display to read them fully.  The next two are used to copy 
'  the spare page between the memory banks and screen 0.  The 'Spack'
'  command is used to compress a screen display into a given memory bank 
'
   If A=1 and B=5 and C=1 and PAGE=0 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 14 : Unpack 15 To 0 : PAGE=1 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
   If A=1 and B=5 and C=1 and PAGE=1 Then Change Mouse 3 : On Error Proc SWERROR : Spack 0 To 15 : Unpack 14 To 0 : PAGE=0 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
   If A=1 and B=5 and C=2 and PAGE=0 Then Change Mouse 3 : Spack 0 To 15 : Proc SETUPSCREEN : PAGE=1 : Change Mouse 2 : Goto FINISHED
   If A=1 and B=5 and C=2 and PAGE=1 Then Change Mouse 3 : Spack 0 To 14 : Proc SETUPSCREEN : PAGE=0 : Change Mouse 2 : Goto FINISHED
   If A=1 and B=5 and C=3 and PAGE=0 Then Change Mouse 3 : Erase 15 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
   If A=1 and B=5 and C=3 and PAGE=1 Then Change Mouse 3 : Erase 14 : Proc SETUPSCREEN : Change Mouse 2 : Goto FINISHED
   If A=1 and B=6 Then Edit 
   FINISHED:
   On Menu On 
End Proc
Procedure MENCHECK2
   A=Choice(1) : B=Choice(2) : C=Choice(3)
   If A=2 and B=1 and C=1 and BY1>BY Then Proc BHALF
   If A=2 and B=1 and C=2 and BY1>BY Then Proc BDOUBLE
   If A=2 and B=1 and C=3 and BY1>BY Then Proc BDOUBLEHORIZ
   If A=2 and B=1 and C=4 and BY1>BY Then Proc BDOUBLEVERT
   If A=2 and B=2 and C=1 and HFLIP=0 Then HFLIP=1 : Goto FINISHED
   If A=2 and B=2 and C=1 and HFLIP=1 Then HFLIP=0 : Goto FINISHED
   If A=2 and B=2 and C=2 and VFLIP=0 Then VFLIP=1 : Goto FINISHED
   If A=2 and B=2 and C=2 and VFLIP=1 Then VFLIP=0 : Goto FINISHED
   If A=2 and B=3 and C=1 Then Proc FLIP180
   FINISHED:
   On Menu On 
End Proc
Procedure MENCHECK3
   A=Choice(1) : B=Choice(2) : C=Choice(3)
   If A=3 and B=1 Then Bell : If COORDS=0 Then COORDS=1 Else COORDS=0 : Text 232,7,"        "
   If A=3 and B=2 Then Proc AIRPOWER
   On Menu On 
End Proc
'
'  Next comes a small procedure that simply amends variables and has nothing   
'  at all to do with any graphic operations straight to the screen.  What we 
'  are doing inside this procedure is simply switching variable quantities 
'  if our conditions are met - if either HFLIP or VFLIP = 1 then we set them 
'  to 0.  Likewise if either equal 0 when we enter this procedure then we set
'  them to 1.  The variables themselves are fairly self explanatry, HFLIP  
'  holds a value that tells us if the current brush is flipped (1) or not  
'  horizontally, and VFLIP holds a value that tells us if the current brush
'  is also flipped (1) or not vertically.  Not much else really. 
'
Procedure FLIP180
   If HFLIP=0 Then HFLIP=1 : Goto BEGIN
   If HFLIP=1 Then HFLIP=0 : Goto BEGIN
   BEGIN:
   If VFLIP=0 Then VFLIP=1 : Goto FINISHED
   If VFLIP=1 Then VFLIP=0 : Goto FINISHED
   FINISHED:
End Proc
'
'  Here is the procedure that reads the directory of a disc into the array 
'  we dimensioned a long time ago at the start of this program.  Nothing at
'  all special in here apart from a couple of AMOS commands you might not be 
'  familiar with - 'Dir First$()' and 'Dir Next$'.  I'll explain them as 
'  we come to them.
'
Procedure GDIR
'
'  Taking the next variables in order, the first is simply a counter used by 
'  this procedure and the zone checking procedure to show that this procedure
'  has been called succesfully, the same for the next variable.  The variable
'  XX is used to hold the start point in the array FAME$ that the directory
'  will be loaded into.
'
   FRESH=1
   XYZ=1
   XX=1
'
'  Okay, the first of the AMOS commands.  What 'Dir First$()' does is to 
'  first check the path (Disk Drive) it will look at, we simply tell it to 
'  look at the current path held in the command 'Dir$' - this is always
'  loaded with some information because AMOS itself reads this variable when 
'  you click on the file selector.  Then it reads the length and name of the 
'  first file on the disk ('Dir$') and puts it into the array FAME$ at 
'  position 1 (the variable XX holds this value).  This command - 'Dir First$' 
'  also loads the entire directory into memory, which we then need to read 
'  into our array with the next few lines
'
   FAME$(XX)=Dir First$(Dir$)
'
'  So we start a simple 'For/Next' Loop using the same counter variable as 
'  before (XX) with a start value of 2.  Remember that the first position of 
'  the FAME$ array was filled in the previous line 
'
   For XX=2 To 50
'
'  And we use the command 'Dir Next$' to read each directory listing from  
'  memory and store it in the FAME$ array. 
'
      FAME$(XX)=Dir Next$
'
'  And we increment the XX variable in the loop with the next command. 
'
   Next XX
'
'  Before the command that will end this procedure I should point out that 
'  this procedure will only read 50 directory entries from any disc, this  
'  can be easily altered by changing the value at the start of this program
'  that dimensions the FAME$ array, and then altering the above loop to this 
'  new value.
'
End Proc
'
'  Yes you've guessed it, I've even used a procedure to move the path into 
'  a sub-directory, they are just so convenient!  Again though, nothing
'  difficult here apart from the first line, but then, that's nothing really 
'  hard as you'll see ...
'  
Procedure UPATH
'
'  Okay, from the beginning you see the variable PATH2$, this is where we
'  will set the string variable which will eventually tell the computer which
'  path we want to enter and is only temporary.  Next comes the 'Mid$' command 
'  that we use to snatch pieces of a string variable with.  A little insight 
'  would be useful here ... when the user clicks on a directory in the file
'  selector, this procedure checks which line the user has clicked and just
'  grabs the whole line from the FAME$ array, the problem with that is that
'  whatever it grabs also has things such as the length of the file held in
'  the string, so we need to strip this info out so we just have the name of 
'  the directory and nothing else - not even spaces.  We also don't want the 
'  asterixes that are displayed on the file selector (*) before a directory
'  listing.  So knowing this we know we want to start at the second character
'  of our string (to miss the *) and grab the whole string up to the 27th
'  character, as this is the width of the file selectors display, then we can
'  be sure of getting all the information.  Also, the part of the next line
'  that reads thus - (FAME$(XYZ+LINE-2) can be explained thus, thus !!  XYZ
'  is simply a dumb variable that holds a value of 1 full time and does
'  nothing else. The variable LINE is the line position on the file selector 
'  of which the user has selected a directory, by subtracting 2 from this
'  variable we get the position in the array of the directory! 
'
   PATH2$=Mid$(FAME$(XYZ+LINE-2),2,27)
'
'  Now we set a loop that will move through 1 to 27 so we can check each 
'  character of the PATH2$ variable for spaces.  If we find a space then we
'  mark the postion in the KI variable and end the loop.  Remember, this is
'  is so can remove any spaces from the string before we ask the computer to 
'  read the directory from our variable. 
'
   For LOP=1 To 27
      PL$=Mid$(PATH2$,LOP,1)
      If PL$=" " Then KI=LOP : LOP=27
   Next LOP
'
'  Next we set the variable PATH$ with the final draft of our task by using
'  a value of KI-1 so we dont have any spaces at all in the string.
'
   PATH$=Mid$(PATH2$,1,KI-1)
'
'  Then we need to set the actual directory that AMOS uses to our string 
'  while also adding the oblique character (/) so AMOS knows it is to access 
'  a directory and nothing else. 
'
   Dir$=Dir$+PATH$+"/"
'
'  Then get the directory again by calling the GDIR procedure. 
'
   Proc GDIR
'
'  And end this fucking twat of a procedure. 
'
End Proc
'
'  I can tell you that documenting this next baby wasn't exactly my idea of
'  a thrilling time, but please don't be put off.  This is the main body of
'  the fileselector and can load, save, delete and rename files so it's not
'  that long for what it does, and it isn't really difficult to grasp. 
'  Note that to call the various functions Load/Save/Delete you need to pass 
'  a number 1,2 or 3 into this procedure by using the TYPE variable. 
'
Procedure FILESELECTOR[TYPE]
'
'  We use a spare screen for the file selectors display so as not to over
'  complicate things with trillions of zones and windows all over the place
'  The next line does this screen opening. 
'
   Screen Open 3,320,276,64,Lowres : Paper 0 : Curs Off : Flash Off : Cls 
'
'  And we load the sprite palette
'
   Get Sprite Palette 
'
'  Bring the screen to the front 
'
   Screen To Front 3
'
'  And set the drawing pointer to here.
'
   Screen 3
'
'  Next we reserve the screen zones that will be used for the various buttons
'  and displays. 
'
   Reserve Zone 20
'
'  And set the FRESH variable to 0 to tell us that this procedure has just 
'  been freshly called.
'
   FRESH=0
'
'  We have reserved the zones so now we need to tell the computer at which 
'  co-ordinates to set the zones.  All the co-ordinates are held in the  
'  data statements.
'
   For LOP=1 To 20
      Read A,B,C,D
      Set Zone LOP,A,B To C,D
   Next LOP
   Data 254,55,265,68,253,137,265,150,77,158,257,168,77,174,257,184
   Data 82,189,133,201,149,189,200,201,212,189,263,200,18,189,69,201
   Data 16,55,247,62,16,64,247,70,16,72,247,78,16,80,247,86,16,88,247,94
   Data 16,96,247,102,16,104,247,110,16,112,247,118,16,120,247,126
   Data 16,128,247,134,16,136,247,142,16,144,247,150
'
'  Now we draw the boxes and bars that make up the components of the file
'  selector. 
'
   Ink 1
   Bar 12,35 To 268,156
   Ink 0 : Draw 12,50 To 268,50
   Draw 12,155 To 268,155
   Ink 0 : Bar 252,53 To 267,152
   Ink 1
   Bar 12,156 To 268,205
   Ink 0 : Bar 77,158 To 257,168
   Ink 0 : Bar 77,174 To 257,184
   Box 14,53 To 250,152
'
'  As I said earlier, this procedure is configurable to Save/Load/Delete 
'  so here we check the TYPE variable and display the relevant title.
'
   If TYPE=1 Then Locate 10,5 : Paper 1 : Pen 0 : Print "  Load Picture"
   If TYPE=2 Then Locate 10,5 : Paper 1 : Pen 0 : Print "  Save Picture"
   If TYPE=3 Then Locate 10,5 : Paper 1 : Pen 0 : Print " Delete Picture"
'
'  Next we just print the other information on the file selector.
'
   Locate 2,20 : Print "Drawer"
   Locate 2,22 : Print "File"
   Locate 2,7 : Pen 31 : Print "<DEV> DF0:"
   Locate 2,8 : Print "<DEV> DF1:"
'
'  I know some people will say its bad practice to use blitter objects (bobs)
'  for the various buttons in this program, but I belive it is best to show
'  the method in which the buttons are animated.  Of course you could just 
'  XOR a box over the buttons to show a depression.  None-the-less, this 
'  is what the next lines are doing, pasting bobs on the file selector to act
'  as buttons. You could go into direct mode now and paste the bobs yourself 
'  to see what is happening,  the bobs are listed in the supplied notes. 
'
   Paste Bob 254,56,43
   Paste Bob 254,137,44
   Paste Bob 18,189,48
   Paste Bob 82,189,47
'
'  We check the TYPE variable again here so we know which key bob to paste.
'  By key bob, I mean Save/Load/Delete buttons,  the others remain constant. 
'
   If TYPE=1 Then Paste Bob 149,189,46
   If TYPE=2 Then Paste Bob 149,189,59
   If TYPE=3 Then Paste Bob 149,189,60
   Paste Bob 212,189,45
'
'  Now we label the proper part of this procedure. 
'
   BEGIN:
'
'  Next we print the current path in the proper box on the file selector as
'  well as a number of spaces (with the Space$() command) to remove any
'  excess characters that may appear from time to time with different
'  directories.
'
   Locate 10,20 : Paper 0 : Print Dir$+Space$(20-Len(Dir$)) : Paper 1
'
'  So now we need to start scanning the mouse until the user presses a 
'  button.  We will use a 'Repeat/Until' loop for this, all the while
'  loading the MZONE variable with the current mouse zone. 
'
   Repeat 
      MZONE=Mouse Zone
   Until Mouse Key<>0
'
'  Now we need to check which zone, if any, the user selected, and then  
'  jump to the program or procedure that we require.  We can quickly check 
'  to see if the user has selected a function like 'Load' by checking the
'  MZONE variable for a value greater than 8, because all the zones other
'  than files are in zones less than 8.  The FRESH variable holds a value
'  which we can check to see if the selection requires a fresh directory.
'
   If MZONE>8 and FRESH=0 Then Gosub INIT : Goto BEGIN
   If MZONE>8 and FRESH=1 Then Gosub INIT2 : Goto BEGIN
'
'  If the value in MZONE was not trapped above then we know that MZONE will
'  hold a value less than 8, so we can use the next command to jump to the 
'  correct label relative to the value of MZONE
'
   On MZONE Gosub A,B,C,D,G,F,E,H
'
'  And if the user clicked the mouse on a null zone then we jump back to the 
'  BEGIN label to begin checking again.
'
   Goto BEGIN
'
'
   A:
'
'  ## Scroll Directory Display Up ## 
'
'  Here we simply paste a highlighted bob while the mouse key is being 
'  pressed.
'
   Paste Bob 254,56,49
   While Mouse Key=1 : Wend 
   Paste Bob 254,56,43
   If COUNT=1 Then Goto FINISHED
'
'  Decrement the count variable which is used by the PDIR procedure as a 
'  start point at which to display the directory in the file selector
'
   Dec COUNT : Proc PDIR
   FINISHED:
   Return 
'
   B:
'
'  ## Scroll Directory Display Down ## 
'
'  Here we simply paste a highlighted bob while the mouse key is being 
'  pressed.
'
   Paste Bob 254,137,50
   While Mouse Key=1 : Wend 
   Paste Bob 254,137,44
'
'  Check in here if there is anything in FAME$ to be displayed if we scroll
'  the display.
'
   If FAME$(COUNT+12)="" Then Goto FINISHED1
'
'  And increment the COUNT variable ready for the ...
'
   Inc COUNT
'
'  PDIR procedure to display the scrolled listing
'
   Proc PDIR
   FINISHED1:
   Return 
'
   C:
'
'  We have left this blank for you to experiment with, it's not vital though 
'  as the user can still select a drawer by clicking on the 'Discs' button 
'
   Return 
'
   D:
'
'  This is used to manually enter a filename for saves & stuff.  It simply 
'  calls the LININPUT procedure with the number in brackets representing 
'  X position, Y position and input length.  This procedure passes the result
'  out in the variable FIN$... 
'
   Proc LININPUT[10,22,22]
'
'  So we load our variable that holds filenames - FILENAME$ - with FIN$ - the
'  result of the line input from the last line.
'
   FILENAME$=FIN$
'
'  And return. 
'
   Return 
'
   E:
'
'  This is the 'Cancel' button subroutine.  It simply pastes a highlighted 
'  bob while the mouse key is being pressed and then jumps to the FINALEND 
'  label to end this procedure.
'
   Paste Bob 212,189,51
   While Mouse Key=1 : Wend 
   Paste Bob 212,189,45
   Goto FINALEND
   Return 
'
   F:
'
'  This subroutine is a little more complex because it has to handle three 
'  functions - Load/Save/Delete. 
'
   If TYPE=1 Then Paste Bob 149,189,52
   If TYPE=2 Then Paste Bob 149,189,65
   If TYPE=3 Then Paste Bob 149,189,66
   While Mouse Key=1 : Wend 
   If TYPE=1 Then Paste Bob 149,189,46
   If TYPE=2 Then Paste Bob 149,189,59
   If TYPE=3 Then Paste Bob 149,189,60
'
'  So here is the first function - Load.  Simply it loads an Iff picture into
'  screen 0 using the path of 'Dir$' and the filename in FILENAME$.
'
   If TYPE=1
      Screen 0 : Load Iff Dir$+FILENAME$
'
'  Then we set up the main screen display again, menu bar,title bar and screen 
'  zones, in case the picture exceeds the drawing area dimensions
'
      Proc SETUPSCREEN
'  And end this procedure by jumping to the FINALEND label 
'
      Goto FINALEND
   End If 
'
'  Now if the TYPE equals 2 (Save) we need to save the current screen, as
'  before using 'Dir$' and our FILENAME$.  The two 'Bar' commands simply 
'  clear out any out of date information from the file-selector. As before 
'  we set the screen up again and end this procedure by jumping to the 
'  FINALEND procedure. 
'
   If TYPE=2
      Screen 0
      Ink 0
      Bar 0,0 To 317,9
      Bar 292,10 To 316,263
      Save Iff Dir$+FILENAME$
      Proc SETUPSCREEN
      Goto FINALEND : 
   End If 
'
'  Finally we check the TYPE variable to see if we need anything deleting. 
'  Using the 'Kill' command to delete the required file and the 'Space$()' 
'  to clear out the text boxes.
'
      If TYPE=3
      Kill Dir$+FILENAME$
      For LINE=7 To 18
         Locate 2,LINE
         Paper 1 : Print Space$(29)
      Next LINE
      Locate 10,22 : Print Space$(22)
'
'  Then we get the directory again and print it out to show the user that
'  the task has been carried out successfully. 
'
      Proc GDIR
      Proc PDIR
   End If 
   Return 
'
   G:
'
'  In here we cater for the need to rename any file. 
'
   Paste Bob 82,189,53
   While Mouse Key=1 : Wend 
   Paste Bob 82,189,47
'
'  You can't rename nothing, so the next line checks the current filename
'  held in the FILENAME$ variable, and if nothing exists then we exit this 
'  subroutine (NOT this procedure) by jumping to the GEND label. 
'
   If FILENAME$="" Then Goto GEND
'
'  Quickly draw the rename box.  Try it !!!
'
   Ink 1 : Bar 12,210 To 268,245
   Ink 0 : Bar 22,230 To 266-8,241
   Draw 12,226 To 267,226
'
'  And display the name of the file to be renamed, limiting the display
'  to a maximum of 18 characters with the 'Mid$' command so we dont run
'  off the box ! 
'
   Locate 3,27 : Paper 1 : Print "Rename '";Mid$(FILENAME$,1,18);"' as -"
'
'  Then we call the line input procedure at 3,29 (X column/Y column) with
'  an input length of29 characters.
'
   Proc LININPUT[3,29,29]
'
'  Then rename the file to the new name held in FIN$ - remember that FIN$
'  holds the input we got from the LININPUT procedure. 
'
   Rename FILENAME$ To FIN$
'
'  Remove the rename box from the screen now by drawing a black bar over the 
'  top of it.  Crude but effective!
'
   Ink 0 : Bar 12,210 To 268,245
'
'  And now we clear out the old directory display by pasting a bar over that 
'  as well!  
'
   Ink 1 : Bar 16,55 To 247,150
'
'  And clear out the filename box with 22 spaces 
'
   Locate 10,22 : Pen 0 : Paper 0 : Print Space$(22) : Paper 1 : 
'
'  Then we get a new directory and print it out
'
   Proc GDIR
   Proc PDIR
   GEND:
   Return 
'
   H:
'
'  This subroutine does nothing except print device names(disk drives) on
'  the file selectors display, no checks are made to see if the devices
'  exist - perhaps you could check and only display the correct drives!
'
   Paste Bob 18,189,54
   While Mouse Key=1 : Wend 
   Paste Bob 18,189,48
'
'  This next loop is only used to clear out any directory listing that may 
'  be displayed on the file selector by simply print spaces in the hole
'
   For LINE=7 To 18
      Locate 2,LINE
      Print Space$(29)
   Next LINE
   Locate 2,7 : Pen 23 : Print "<DEV> DF0:"
   Locate 2,8 : Print "<DEV> DF1:"
   FRESH=0
   Return 
   Goto 2222
'
'
'  The next subroutine is called further up in this procedure when the user
'  clicks on a directory listing to display that directory listing in the
'  'file' text box.  It also does a check on the first character of the
'  listing for an asterix (*) that denotes a sub-directory, and if it finds
'  one it will get the new sub-directory or folder, by calling the PARDIR
'  subroutine. 
'
   INIT2:
   FILENAME$=Mid$(FAME$((MZONE-9)+COUNT),1,29)-" "
   If Mid$(FILENAME$,1,1)="*" Then Gosub PARDIR : Return 
   Locate 10,22 : Paper 0 : Print FILENAME$+Space$(22-Len(FILENAME$))
   Return 
'
'  Here the next subroutine actually gets the sub-directory listing and
'  displays it on the screen.  I wont waste your time by explaining what we
'  have already gone over, because we have, and there's nothing at all hard
'  here. 
'  
   PARDIR:
   L$=Mid$(FILENAME$,2,29)-" "
   L$=L$+"/"
   FILENAME$=L$
   Dir$=FILENAME$
   For LINE=7 To 18
      Locate 2,LINE
      Print Space$(29)
   Next LINE
   Proc GDIR
   Proc PDIR
   Return 
'
'  This next sub-routine is called when the file-selector is in a fresh state
'  and only the devices are displayed.  It checks which mouse zone was clicked 
'  and then sets the current directory to that drive.  Then we get a new 
'  directory and print it on the file-selector.
'
   INIT:
   If MZONE=9 Then Dir$="df0:"
   If MZONE=10 Then Dir$="df1:"
   Proc GDIR
   Proc PDIR
   Return 
'
'
   FINALEND:
'
'  We will need to close this screen when this procedure has finished to save
'  memory, so we do it now.
'
   Screen Close 3
'
'  And then bring our drawing screen back to the front of the display. 
'
   Screen To Front 0
'
'  And then end this procedure.
'
End Proc
'
'  The next procedure is the one that does the printing of the selected
'  directory on the screen.
'
Procedure PDIR
'
'  First we load the contents of the COUNT variable into the COUNT1 variable 
'  because we don't want to change the contents of COUNT.  If we did things
'  would get very messy because COUNT holds the point in the array at which
'  the current directory is displayed on the screen
'
   COUNT1=COUNT
'
'  And now we simply set a simple loop to count 11 positions.  We use the
'  values 7 to 18 so we can just take the position of the loop to print at 
'  the correct vertical position 
'
   For LINE=7 To 18
'
'  When printing the contents of the array note that we are filtering only 
'  the first 29 characters with the 'Mid$' command so we dont print more than
'  the width of the file selector. 
'
      Locate 2,LINE : Paper 1 : Print Mid$(FAME$(COUNT1),1,29)
'
'  And then we increment the COUNT1 variable next, which is used to retrieve 
'  the correct listing in the array FAME$
'
      Inc COUNT1
'
'  Then end the loop 
'
   Next LINE
'
'  And the whole procedure!  
'
End Proc
'
'  Next up is the procedure that places the palette selector on the screen 
'  Unfortunately, it is fairly long and uses a lot of numbers in places, and 
'  we do some poking about in memory.  On the whole though, fairly simple
'  and good for experience.
'
Procedure SELECTPALETTE
'
'  First we need to set up a few variables 
'
   Shared FC,BC,REZ,NCOLS,XS,TPAL,TPAL()
   Dim RGB(31)
   CL1=0 : CL2=NCOLS : SC=Screen
'
'  And then open a screen on which to display out palette selector 
'
   Screen Open 3,320,160,32,Lowres
   Curs Off : Flash Off : Get Palette 0 : Cls 0
'
'  Then set the drawing pointer to the new screen
'
   Screen 3
   Wait Vbl 
'
'  We will be needing some zones for the variuos buttons and colour areas
'  so we reserve them zones now. 
'
   Reserve Zone 43
'
'  Now we come to draw the actual palette selector on the screen with an 
'  assortment of bars and boxes, this also draws in the coloured bars that 
'  can be clicked on to select a colour to be changed.  I won't document 
'  these lines because they are just mostly screen co-ordinate calculations
'  and would be near impossible to understand.  The best way is to just try  
'  them out in direct mode to see what goes where. I also thought it was a 
'  good idea to set up the zones around the colour boxes as they were being
'  drawn so that we know exactly where the zones are going.  You will also 
'  notice a couple of maths commands - 'Mod' and 'Min', don't be put off by  
'  them, they are just tame little babies!  Let me explain here what they do 
'  so you don't have to go hunting through your AMOS User Guide, and as it 
'  happens, the 'Mod' function was not shown in my User Guide! 
'
'  'mod' is a command or function that will give you the remainder of a  
'  division.  e.g. A=7 mod 3 will place a value of 1 in the variable A.
'  A=50 mod 4 will place a value of 2 into the variable A, nothing fancy 
'  but it can come in useful, if as in this procedure, you need to know the
'  remainder of a calculation. 
'
'  'Min' on the other hand is listed in the AMOS User Guide.  This function
'  places the smallest value of two expressions into a variable.  The
'  expressions can be strings or numbers, but we only number the numbers.
'  e.g. A=Min(2,1) will place a value of 1 in the variable A, because 1 was
'  the smallest value in our expression.  A=Min(50,150) will place a value of
'  50 in the variable A.  Simple!  There is also an exact opposite of this 
'  command - 'Max'.  Do please remember them as they can come in useful. 
'
   Ink 0,0
   Bar 13,8 To 217,159
   Ink FC,BC
   Bar 8,3 To 212,159
   Ink BC,FC
   Box 9,4 To 211,158
   Box 12,108 To 208,155
   Ink BC,FC
   A=0
   Repeat 
      Bar 15+A*20,6 To 30+A*20,104
      Set Zone A+1,15+A*20,6 To 30+A*20,104
      Inc A
   Until A=3
   A=0
   Repeat 
      Draw 10,6+A*6 To 75,6+A*6
      Inc A
   Until A=17
   A=CL1
   Repeat 
      Ink A,A : X=A mod 8 : Y=A/8
      Bar X*16+80,Y*16+8 To X*16+95,Y*16+23
      Set Zone A+4,X*16+80,Y*16+8 To X*16+95,Y*16+23
      RGB(A)=Colour(A)
   Inc A : 
   Until A>=Min(32,CL2)
   Ink BC,FC
   Box 79,7 To 96+16*X,24+16*Y
'
'  It's here that we paste the bobs that represent our buttons.
'
   Paste Bob 85,90,45
   Paste Bob 151,90,55
   Paste Bob 24,137,56
   Paste Bob 84,137,57
   Paste Bob 144,137,58
'
'  And print a title above them
'
   Locate 2,15 : Print "Preset Palette Selection"
'
'  Then we set up some zones around our buttons. 
'
   Set Zone 36,80,90 To 140,100
   Set Zone 37,152,90 To 202,100
   Set Zone 41,24,137 To 74,149
   Set Zone 42,84,137 To 134,149
   Set Zone 43,144,137 To 184,149
   Ink SELCOL
   Bar 195,78 To 201,87
   Ink BC : Box 194,77 To 202,88
   RGB2[SELCOL]
'
'  Now we start the main program loop, which will cycle until the variable 
'  OK does not equal 0.
'
   OK=0
   While OK=0
'
'  Now we have another 'While/Wend' loop that will cycle until the user  
'  presses a key.  Then the rest of the line loads the YM variable with the
'  Y co-ordinate of the mouse, and Z with the mouse zone at the time of
'  clicking
'
      While Mouse Key=0 : Wend : YM=Y Screen(Y Mouse) : Z=Mouse Zone
'
'  Now we come to check to Z variable in turn. First checking for a value
'  of 41.
'
      If Z=41
'  
'  Firstly we paste the highlighted bob for the rainbow button because we
'  know the left mouse key has been pressed
'
         Paste Bob 24,137,62
'
'  Then we immediately start another loop that wait for the left mouse key 
'  to be released.  When it is released we paste an un-highlighted bob over
'  the last. 
'
         While Mouse Key=1 : Wend : Paste Bob 24,137,56
'
'  Now this next command holds the key to this function - creating a rainbow 
'  palette.  This is immensely easy, I simply loaded Photon Paint 2 (sorry EA) 
'  and wrote down the values for the range of colours I thought best 
'  represented a rainbow.  Then, as this program is strictly 64 colours (EHB)
'  I just put those numbers in the next line - 32 colours, becuase Extra Half
'  bright only generates the other 32 from the first 32.  Please note that the 
'  next line is considerably larger than the display and can be scrolled.
'
         Palette $0,$AAA,$555,$FFF,$F00,$F20,$F40,$F60,$0,$FB0,$FD0,$FF0,$DF0,$BF0,$9F0,$7F0,$0,$4F0,$2F0,$F0,$F2,$F2,$F6,$F9,$FB,$FD,$FF,$BF,$9F,$7F,$6F,$2F
'
'  And now we end with the next command.  Yes, this is an 'If/Endif' test, 
'  if your unfaimilier with them, then let me explain that they are exactly
'  the same as the conventional logical test of an 'If/Then' condition except
'  that you can put the whole test on multiple lines, even nest them inside
'  each other. 
'
      End If 
'
'  Now we come to the next check on the Z variable.
'
      If Z=42
'
'  This condition is used to change the palette to grey scales.  The same
'  method as above was used to get the colour values, and the rest is
'  identical.
'
         Paste Bob 84,137,63
         While Mouse Key=1 : Wend : Paste Bob 84,137,57
         Palette $0,$AAA,$555,$FFF,$111,$222,$333,$444,$0,$666,$777,$888,$999,$AAA,$BBB,$CCC,$0,$EEE
      End If 
'
'  The next Z variable check 
'
      If Z=43
'
'  @@@@  No random palette in  there yet AL !!!!!!!!!!!!!! 
'
         Paste Bob 144,137,64
         While Mouse Key=1 : Wend : Paste Bob 144,137,58
      End If 
'
'  Now we check for a value greater than 0 but less than 4.  This will tell
'  us if the user has clicked on either of the RGB colour slider to the left 
'  of the palette selector.
'
      If Z>0 and Z<4
'
'  If we get inside here by satisfying the above condition the we need to call 
'  the procedure that takes care of the RGB sliders.  Remember that variable   
'  descriptions can be found in the Easy Paint Literature. 
'
         RGB1[SELCOL,Z-1,YM]
         RGB2[SELCOL]
'
'  And then end
'
      End If 
'
'  Now if Z is less than 36 and greater than 3 then we know that the user has
'  clicked on one of the 32 colour boxes.
'
      If Z>3 and Z<36
'
'  We can of course now change the SELCOL (selected colour) variable to the
'  ink colour of the box the user clicked on by subtracting 4 from the Z 
'  variable. As the zone numbers of the colour boxes start at 4 this will give 
'  us the exact colour value.
'
        SELCOL=Z-4
'
'  Now we can change the current ink colour to the newly selected colour held
'  in the SELCOL variable. 
'
         Ink SELCOL
'
'  Then we draw a small box with the next command next to the hexadecimal
'  value of the colour, in the newly selected ink colour 
'
         Bar 195,78 To 201,87
'
'  Now a quick jump to the SFADERS procedure, passing the SELCOL variable
'  directly into the procedure.  This is used to refresh the palette 
'  selectors display, i.e. display the hexadecimal value of the new colour etc 
'
         RGB2[SELCOL]
         Ink SELCOL
'
'  And then end. 
'
      End If 
'
      If Z=37
'
'  If the user has clicked the 'Use' button on zone 37 then we know that he
'  wants to use the palette he has affected, so we simply end this check and 
'  indeed the whole procedure without further ado by first setting the OK
'  variable to 1 - remember this is the variable this procedure repeatedly 
'  checks to see if it should end itself...
'
         Paste Bob 151,90,61
         While Mouse Key=1 : Wend : Paste Bob 151,90,55
         OK=1
'
'  And then ending here. 
'
      End If 
'
'  Should the user wish to exit from the pallete selector without making a 
'  permanent palette change even though he may have altered a few colours we 
'  need to get the original palette back with the next test. 
'
      If Z=36
         Paste Bob 85,90,51
         While Mouse Key=1 : Wend : Paste Bob 85,90,45
         A=CL1
'
'  This 'Repeat/Until' loop will take care of this for us by repeatedly
'  calling the SPCOL procedure and grabbing the original palette from memory 
'  
Repeat 
            Colour A,RGB(A) : RGB3[A,RGB(A)]
         Inc A : 
Until A>=Min(32,CL2)
'
'  We also need to tell the procedure to end by setting the OK variable to 1 
'  in the next line ...
'
         OK=1
'
'  And end 
'
      End If 
'
'  Next is the other part of this procedures main 'While/Wend' loop.  Do 
'  please remember that when we send the program back up there with this next
'  command, it will check the OK variable, and if it equals 1 then it will 
'  jump straight back down to ...  
'
   Wend 
'
'  ... HERE !!! Hello again.  After all this we need get the palette back
'  into memory for future use with the following bit of program.  Read the 
'  variable list supplied with the package for information on these .. and 
'  other variable meanings.  The rest is easy ...
'
   Screen 0
   Get Palette 3
   T=TPAL : If NCOLS>16 : T=0 : End If 
   For A=0 To NCOLS-1
      RGB3[A+T*16,Colour(A)]
      If TPAL=1 and A<16
         Colour 16+A,Colour(A)
         RGB3[A,TPAL(A)]
      End If 
   Next A
   Screen Close 3
   Screen SC
'
'  The end .. of that! 
'
End Proc
'
'  And the next procedure is simply used to initialise variables that will 
'  be used by the other RGB* procedures.  Nothing to document really as the
'  variables are listed in the supplied variable table.
'
Procedure RGB1[S,F,YM]
   Dim R(2)
   C=Colour(S)
   R(0)=C/256
   R(1)=(C/16) mod 16
   R(2)=C mod 16
   V=Max(0,Min(15,15-(YM-7)/6))
   R(F)=V
   Screen 0
   Colour S,(R(0)*256+R(1)*16+R(2))
   Screen 3
   Colour S,(R(0)*256+R(1)*16+R(2))
   RGB3[S,Colour(S)]
End Proc
'
'  The next procedure prints the colour number and hex value on the screen 
'  as well as redrawing the colour slider.  It will also draw the three  
'  colour sliders at relative positions depending on the colour value we 
'  pass into the procedure in the variable S 
'
Procedure RGB2[S]
'
'  First we need to assign some variables, share and dimension them. 
'
   Shared RGBO,BC,FC
   Dim R(2)
   C=RGBO
   R(0)=C/256
'  
'  Remember that the mod funtion will return the remainder of a division 
'  only and is not listed in the AMOS User Guide 
'
   R(1)=(C/16) mod 16
   R(2)=C mod 16
   Ink BC,BC
'
'  We reset the A variable because it is used as a counter in the next loop
'
   A=0
'
'  We now initialise a loop that will draw the slider bars at positions
'  relative to the colour value.  Try not to get bogged down in the maths
'  and I wont try to explain it!  This part only erases the last boxes by
'  drawing bars in the background colour 
'
   Repeat 
      V=(15-R(A))*6 : Bar 17+20*A,7+V To 28+20*A,12+V
      Inc A
   Until A=3
'
'  The next line will return the amigas colour index from a given value -
'  which we pass into this procedure in the S variable.  Later we will use 
'  the new C variable to get the Hex value of a given colour.
'
   C=Colour(S)
'
'  And now we set some more variables
'
   RGBO=C
   R(0)=C/256
   R(1)=(C/16) mod 16
   R(2)=C mod 16
'
'  Change the ink and paper colours in one convenient command
'
   Ink BC,FC
'
'  And next we display our titles and values.  Note the hexadecimal conversion 
'  of the RGBO variable later in the line.  Remember that we got the RGBO  
'  variable from the C variable earlier in the program.
'
   Text 80,85," Col:"+Right$(" "+Str$(S),2)+"   $"+Right$("000"+Mid$(Hex$(RGBO),2),3)
   Ink FC,FC
'
'  Initialise the A variable again because we will be using it as a counter
'
   A=0
'
'  Now we start up a loop that will draw in the slider buttons in the correct
'  foreground colour 
'
   Repeat 
'
'  And here we set both paper and ink to the current foreground colour 
'
      Ink FC,FC
'
'  Next we draw a box around the slider bar
'
      V=(15-R(A))*6 : Box 17+20*A,7+V To 28+20*A,12+V
'
'  Now we change to the current ink colour RGB seperation
'
      Ink S
'
'  And fill inside the above box with a bar of colour
'
      Bar 18+20*A,8+V To 27+20*A,11+V
'
'  Then increment the A variable 
'
      Inc A
'
'  And check it
'
   Until A=3
'
'  Then end this procedure 
'
End Proc
'
'  The next procedure simply 'Doke's the palette into memory so we always have 
'  a copy that isn't immediately changeable. 
'
Procedure RGB3[A,B]
   If Length(1)>0
      Doke Start(1)+2+8*Length(1)+2*A,B
   End If 
End Proc
'
'  This procedure is very simple, when I started this project I wrote down 
'  all the values of the palette I was using and put them in here, so at any 
'  time the user can call this procedure and restore the palette to its
'  default standard
'
Procedure DEFPALETTE
'
   Palette $0,$AAA,$555,$FFF,$808,$F4A,$E00,$620,$0,$FA8,$FE0,$80,$D0,$CC,$6F,$A,$0,$EC8,$C60,$EA0,$27F,$49D,$5AE,$ADF
'
'  All the commas are simply representing the spaces of the above numbers
'  as we have just set them up we dont want to change them again.  Yes, you
'  could put all the values on one line. 
'
   Palette ,,,,,,,,,,,,,,,,,,,,,,,,$BDF,$CEF,$FFF,$408,$ADE,$E0E,$E08,$EEE
End Proc
'
'  This procedure halfs the size of the current brush by using the 'Zoom'
'  command to make an image on a seperate screen, and then grabbing the
'  brush again from the new co-ordinates.  Variable descriptions are listed
'  in the supplied variable table
'
Procedure BHALF
   Screen Open 3,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen Open 4,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen 3 : Paste Bob BX,BY,80
   Zoom 3,BX,BY,BX1,BY1 To 4,BX,BY,BX1/2+BX/2,BY1/2+BY/2
   Get Bob 4,80,BX,BY To BX1/2+BX/2,BY1/2+BY/2
   Screen Close 4
   Screen Close 3
End Proc
'
'  This procedure doubles the size of the current brush by using the 'Zoom'
'  command to make an image on a seperate screen, and then grabbing the
'  brush again from the new co-ordinates.  Variable descriptions are listed
'  in the supplied variable table
'
Procedure BDOUBLE
   Screen Open 3,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen Open 4,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen 3 : Paste Bob 0,0,80
   Zoom 3,0,0,BX1-BX,BY1-BY To 4,0,0,BX1*2-BX*2,BY1*2-BY*2
   Get Bob 4,80,0,0 To BX1*2-BX*2,BY1*2-BY*2
   Screen Close 4
   Screen Close 3
End Proc
'
'  This procedure doubles the size of the current brush horizontally by  
'  using the 'Zoom' command to make an image on a seperate screen, and then  
'  grabbing the brush again from the new co-ordinates.  Variable descriptions  
'  are listed in the supplied variable table 
'
Procedure BDOUBLEHORIZ
   Screen Open 3,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen Open 4,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen 3 : Paste Bob 0,0,80
   Zoom 3,0,0,BX1-BX,BY1-BY To 4,0,0,BX1*2-BX*2,BY1-BY
   Get Bob 4,80,0,0 To BX1*2-BX*2,BY1-BY
   Screen Close 4
   Screen Close 3
End Proc
'
'  This procedure doubles the size of the current brush vertically by  
'  using the 'Zoom' command to make an image on a seperate screen, and then  
'  grabbing the brush again from the new co-ordinates.  Variable descriptions  
'  are listed in the supplied variable table 
'
'
Procedure BDOUBLEVERT
   Screen Open 3,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen Open 4,320,256,64,Lowres : Cls 0
   Get Sprite Palette 
   Screen 3 : Paste Bob 0,0,80
   Zoom 3,0,0,BX1-BX,BY1-BY To 4,0,0,BX1-BX,BY1*2-BY*2
   Get Bob 4,80,0,0 To BX1-BX,BY1*2-BY*2
   Screen Close 4
   Screen Close 3
End Proc
'
'  This next procedure allows us to input any information at any position on 
'  the screen and of any set length - the variables we pass into it as A,  
'  B and LEANTH
'
Procedure LININPUT[A,B,LEANTH]
'
'  We start by setting the paper colour to 0 and locating the text cursor at 
'  the positions we passed into this procedure - A and B, and then printing
'  LEANTH number of spaces at this position to clear any text that may have
'  already been there. 
'
   Paper 0 : Locate A,B : Print Space$(LEANTH)
'
'  Then wait half a second 
'
   Wait 25
'
'  And clear the keyboard buffer.  Reason ? Well, everytime you press a key
'  on the keyboard, regardless of whether you are in this procedure or not,  
'  the key press gets put into a buffer ( a piece of memory ), and when we 
'  then read this buffer we get old information - which we don't want. 
'
Clear Key 
'
'  When this procedure has finished it places the information the user input 
'  into the variable FIN$ so it can be read by the calling procedure.  We  
'  also clear this variable for the same reasons by loading it with nothing
'
   FIN$=""
'
'  Now we relocate the text cursor to our location variables.
'
   Locate A,B
'
'  And set up our main loop to cycle until the required number of characters 
'  have been input.
'
   For LOP=A To LEANTH+A
'
'  We will also use the next label to jump back to in the event we do not
'  need or want to increment the main loop,e.g if the delete key is pressed
'
      LINE1:
'
'  Now we read the keyboard input into the N$ variable.  Inkey$ will only grab 
'  one key press at a time.
'
      N$=Inkey$
'
'  I have also taken any mouse key as a return press, so we can check that if
'  a mouse key has been pressed then we need to end this loop by jumping to  
'  the LINE2 label 
'
      If Mouse Key<>0 Then Goto LINE2 : 
'
'  Whereas if the N$ variable is empty we know that no key has been pressed
'  so we jump back to the LINE1 label until a key IS pressed ! 
'
      If N$="" Then Goto LINE1 : 
'
'  So here we know a key has been pressed and we need to know if it is an
'  important key like Delete/Back Space or Return.  The next line gets an
'  ASCII value of N$(the pressed key) and checks for a value of 8 which we 
'  know represents the delete key.  If this test is true then we need to 
'  print a space over the previous charater on the display, and then delete it 
'  from the FIN$ variable that holds the complete input.  We must also 
'  decrement the loop after checking that it is greater than the A variable  
'
      If Asc(N$)=8 and LOP>A Then LOP=LOP-1 : Locate LOP,B : Print " " : FIN$=Mid$(FIN$,1,Len(FIN$)-1) : Goto LINE1
'
'  Again we check the ASCII value of N$ for a content of 13.  If the test is 
'  true then we know the return key has been pressed to end the input, now we
'  must jump to the LINE2 label
'
      If Asc(N$)=13 Then Goto LINE2
'
'  Next we can check if the loop (LOP) is less than LEANTH+A (LEANTH+A giving  
'  us the correct user specified input length) and if this test is true we can 
'  add the last keypress (N$) to our output variable (FIN$)
      If LOP<LEANTH+A Then FIN$=FIN$+N$
'
'  Now if the loop counter is equal the the maximum user specified input 
'  length then we will have to decrement the loop counter so as not to 
'  exceed the correct input length.
'
      If LOP=LEANTH+A Then LOP=LOP-1
'
'  Then we display the last keypress LOP columns in and B Rows down. 
'
      Locate LOP,B : Print N$
'
'  We can also remember the last keypress by placing it into the LAST$ 
'  variable. 
'
      LAST$=N$
'
'  Then we can send the loop back again
'
   Next LOP
'
   LINE2:
'
'  Before we end we must place the last inputted character onto the end of 
'  our output string as the main program will not have had time to do this 
'
   If LOP=LEANTH+A Then FIN$=FIN$+LAST$
'
'  And then end this procedure.
'
End Proc
'
'   Next is a three liner that simply returns the program to the next  
'   instruction after an error is generated
'
Procedure SWERROR
'
'  The following command takes care of this for us.
'
   Resume Next 
'
End Proc
'
'  And the next procedure does all the drawing of the main drawing screen, 
'  pasting the buttons, setting zones and drawing the title bar. 
'
Procedure SETUPSCREEN
'
'  First we reserve the zones that will be used by the buttons on the menu 
'  bar 
'
   Reserve Zone 25
'
'  Then we draw the top title bar ...
'
   Ink 1 : Bar 0,0 To 316,9
   Ink 3 : Draw 0,0 To 0,9
   Ink 3 : Draw 0,0 To 316,0
   Ink 2 : Draw 0,9 To 316,9
   Ink 2 : Draw 316,9 To 316,0
'
'  And display the programs name 
'
If PAGE=0 Then PAGE$="Default " Else PAGE$="Scribble"
   Ink 0 : Text 7,7,"EasyPaint   "+PAGE$
'
'   Paste Menu Bobs and set up the respective zones
'
   Paste Bob 292,11,1
   Set Zone 1,292,11 To 318,35
   W=2
   For Y=36 To 140 Step 13
      For X=292 To 305 Step 13
         Set Zone W,X,Y To X+13,Y+13
         Read Z
         Paste Bob X,Y,Z
         Inc W
      Next X
   Next Y
'
'  I used a data statement here for order of bobs pasted 
'
   Data 2,3,6,7,4,5,16,9,10,11,18,8,12,13,72,17,14,15
   IK=0
   Set Zone 22,292,166 To 312,258
   Ink 60 : Bar 291,165 To 316,260
   Box 0,10 To 290,263 : Rem drawing area perimeter 
'
'  And here is a couple of loops (nested) that draw the coloured boxes on to 
'  the menu bar
'
   For X=292 To 312 Step 6
      For Y=166 To 258 Step 6
         Ink IK
         Inc IK
         Bar X,Y To X+5,Y+5
      Next Y
   Next X
   XB=-20 : YB=-20 : BO=2
Proc ZCOLBAR
'
'  That's it folks 
'
End Proc
'
'  The final procedure !!!!! Hey, I know - It's been great, but let me just  
'  explain.  This procedure checks the zones of each button on the menu bar
'  and then calls the relevant procedure.  If you read the variable table
'  you'll find that there is no need for more than what I've put in the
'  procedure.  It is simply checking the contents of variables and changeing 
'  some accordingly. 
'
Procedure CHECKZONES
'
'  But first we cycle through a loop until the left mouse key is pressed 
'
   Repeat 
'
'  While checing in here if the crosshairs have been activated and then  
'  jumping to the crosshairs procedure if they have. 
'
      If CROSS=1 Then Proc CROSSHAIRS
      Z=Mouse Zone
   Until Mouse Key=1
'
   11 If Z=2 Then PROG=2
   22 If Z=3 and PROG=3 and F2TYPE=0 Then F2TYPE=1 : PROG=3 : Goto 55
   If Z=3 and PROG=3 and F2TYPE=1 Then F2TYPE=0 : PROG=3 : Goto 55
   If Z=3 and PROG<>3 Then F2TYPE=0 : PROG=3
   If Z=4 Then PROG=4
   If Z=5 Then PROG=5
   77 If Z=6 and PROG=6 and F5TYPE=0 Then F5TYPE=1 : PROG=6 : Goto 88
   If Z=6 and PROG=6 and F5TYPE=1 Then F5TYPE=0 : PROG=6 : Goto 88
   If Z=6 and PROG<>6 Then F5TYPE=0 : PROG=6
   88 If Z=7 and PROG=7 and F6TYPE=0 Then F6TYPE=1 : PROG=7 : Goto 99
   If Z=7 and PROG=7 and F6TYPE=1 Then F6TYPE=0 : PROG=7 : Goto 99
   If Z=7 and PROG<>7 Then F6TYPE=0 : PROG=7
   99 If Z=8 and PROG=8 and F7TYPE=0 Then F7TYPE=1 : PROG=8 : Goto 55
   If Z=8 and PROG=8 and F7TYPE=1 Then F7TYPE=0 : PROG=8 : Goto 55
   If Z=8 and PROG<>8 Then F7TYPE=0 : PROG=8
   55 If Z=9 and PROG=9 and F8TYPE=0 Then F8TYPE=1 : PROG=9 : Goto 66
   If Z=9 and PROG=9 and F8TYPE=1 Then F8TYPE=0 : PROG=9 : Goto 66
   If Z=9 and PROG<>9 Then F8TYPE=0 : PROG=9
   66 If Z=12 Then PROG=12
   If Z<>18 and Z<>0 Then Screen Copy 0,0,11,289,263 To 1,0,11
   If Z=22 Then I=Point(X Screen(X Mouse),Y Screen(Y Mouse)) : Ink I
   Wait 3
   If Z<13 and PROG<>0 and Z<>10 and Z<>11 Then Z=PROG
If Z=0 and PROG=20 Then Z=PROG
Proc ZCOLBAR
On Z Proc CHECKZONES,FREHANDDOT,CONTINUOUSFREEHAND,STRAIGHTLINE,F4,FCIRCLE,FBOX,FELLIPSE,FPOLYGON,FCROSS,F10,FFILL,FBRUSHCUTTER,F13,F14,F15,F16,FUNDO,FCLS,AIRBRUSH
End Proc
'
'
'
Procedure FASTZOOM
MP=4 : Rem magnification power! 
      Dreg(1)=MP
      Dreg(2)=WIDTH : Dreg(3)=HEIGHT
      Dreg(4)=16 : Dreg(5)=32 : Rem these two hold the top left co-ords of the zoom too box
      Dreg(6)=32 : Dreg(7)=32 : Rem these hold the size of the zoom too box, the values are double each single pixel 
      Areg(0)=Screen Base
      Call 10
   Screen 0
End Proc
Procedure ZCOLBAR
Ink BC : Bar 292,153 To 316,163
Ink I : Bar 298,156 To 309,160
End Proc
Procedure AIRPOWER
Get Cblock 1,32,32,164,116
Ink 1 : Bar 32,32 To 164,116
Ink 3 : Polyline 32,116 To 32,32 To 164,32
Ink 2 : Polyline 164,33 To 164,116 To 33,116
Locate 5,5 : Paper 1 : Print "Airbrush Power"
Bob 75,DENSITY+42,90,74
Ink 0 : Bar 40,88 To 155,103
Box 38,86 To 157,105
Bar 47,61 To 81,73
Box 45,59 To 83,75
K$=Str$(DENSITY)-" "
Locate 6,8 : Paper 0 : Print K$ : Locate 9,8 : Print "%"
Paste Bob 100,61,55
BEGIN: While Mouse Key=1
If X Screen(X Mouse)>100 and Y Screen(Y Mouse)>61 and X Screen(X Mouse)<157 and Y Screen(Y Mouse)<73 Then Goto FINISHED
X1=X Screen(X Mouse) : If X1=X and Mouse Key=1 Then Goto BEGIN
X=X Screen(X Mouse) : Y=Y Screen(Y Mouse)
If X>142 or X<42 or Y<90 or Y>101 Then Goto BEGIN
Bob 75,X,90,74
Locate 6,8 : Print "    "
K$=Str$(X-42)-" "
Locate 6,8 : Paper 0 : Print K$ : Locate 9,8 : Print "%"
DENSITY=X-42
Wend 
Goto BEGIN : 
FINISHED:
Put Cblock 1
Del Cblock 
Proc AIRBRUSH
End Proc
