Home » CEEFAX disks » telesoftware12.adl » 10-02-89/T\Pen04

10-02-89/T\Pen04

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » CEEFAX disks » telesoftware12.adl
Filename: 10-02-89/T\Pen04
Read OK:
File size: 3D7F bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
Using a light pen with the BBC microcomputer - by - Gordon Horsington
---------------------------------------------------------------------

Module 4. Using a light pen for graphics input
----------------------------------------------


The calculation of graphics coordinates is very similar to the calculation
used in module 3 to determine text coordinates except that the full
resolution of the light pen can be used in the graphics modes. A light pen
is capable of resolving a single 6845 CRTC character and the calculation
demonstrated in this module will return the graphics coordinates of the
middle of any CRTC character seen by the light pen. This calculation can
be made in all the graphics modes but it is not very meaningful to
calculate graphics coordinates in the non-graphics modes. Mode 7 has
graphics of a sort but I think they are best understood as an alternative
character set rather than as true graphics. If the algorithm described in
this module, and demonstrated in the program GRAPHIC, is used in a
non-graphics mode it will give a misleading answer. I don't this is really
a problem because there can not be any correct answer for graphics
coordinates in a non-graphics screen mode.

The table in figure 1 shows the values of the variables used in the
calculation of graphics coordinates. The values assigned to the screen
start address in this table can only be used if the screen has not been
scrolled. If the screen is scrolled the start address changes from the
values shown in figure 1. The current screen start address should
therefore be read from &350 (low byte) and &351 (high byte).


         Mode  start addr  trim    width   resolution
        -----+-----------+-------+-------+------------
          0  |   &3000   |  &06  |  &50  | 80 x 32
          1  |   &3000   |  &06  |  &50  | 80 x 32
          2  |   &3000   |  &06  |  &50  | 80 x 32
          4  |   &5800   |  &04  |  &28  | 40 x 32
          5  |   &5800   |  &04  |  &28  | 40 x 32
        -----+-----------+-------+-------+------------

Figure 1. The start address, trim, and width for each graphics mode
-------------------------------------------------------------------


The first stage in calculating the light pen position is to determine the
value of the offset. The offset in all graphics modes is given by:

  offset = trim + (screen start address DIV 8)

The CRCT X and Y coordinates can then be calculated using the appropriate
value of offset.

  Y = (light pen register - offset) DIV width

  X = (light pen register - offset) MOD width

A CRCT Y coordinate can be converted into a graphics Y coordinate by
multiplying it by 32 and then subtracting the product from 1008.

A CRCT X coordinate can be converted into a graphics X coordinate in modes
0 to 2 by multiplying it by 8 and then adding 8. In modes 4 and 5 a CRCT X
coordinate can be converted into a graphics coordinate by multiplying it
by 16 and then adding 16.

The values of trim and width used in these calculations are those
appropriate to the screen mode in use at the time. The screen mode
(ignoring shadow) can be read from &355. The values used for trim will, as
the name suggests, need to be trimmed as described in the earlier modules.
The values of trim used in the demonstration program GRAPHIC are those I
found to be most suitable for my light pen. You might like to edit the
program to use the values best suited to your light pen but you can also
trim the values I have used with the left and right cursor keys when the
program is running. The label offsetlow is used for the table of values
assigned to trim.

The range of the X and Y coordinates made available by this algorithm is
independant of the screen mode. The point 0,0 is always in the bottom left
of the screen and 1279,1023 is always in the top right but, because the
coordinates correspond with the centre of CRTC characters, the range
available is from 8,8 to 1271,1015 in modes 0, 1 and 2, and from 16,16 to
1263,1008 in modes 4 and 5. A maximum of two bytes are required to store
each coordinate but the machine code routine in the program GRAPHIC uses 4
bytes per coordinate so that the coordinates can be read using the BASIC !
indirection operator. The routine always returns the coordinates 0,0 if it
is called in a non-graphics mode.

The machine code routine in the demonstration program checks that the
coordinates it produces are within the expected range. This is a good idea
with non-interrupt light pen drivers because, if the pen has not been
used, the algorithm gives a very misleading answer. This is not a problem
that can occur with interrupt driven software because, by definition, the
light pen must be used to generate the light pen interrupt.

The maximum resolution of the light pen graphics coordinates is 80x32 in
modes 0, 1 and 2, but a rather chunky 40x32 in modes 4 and 5 - and
describing this as chunky is being quite generous. If you use a light pen
to draw on a graphics screen this poor resolution gives a quite shakey
looking line drawing, especially with diagonal lines. In spite of this
apparent problem it is possible to produce very smooth lines and to draw
with an acceptable level of accuracy for freehand work. If you want to use
your computer for very accurate drawing then you should use a mouse as an
input device and not a light pen.

Smooth line drawing with a light pen can be achieved by allowing the line
being drawn to lag behind the current light pen position but to always
approach the current position of the pen. This is achieved by storing the
coordinates of the last plotted position and calculating the next position
to be plotted as a fraction of the difference between the last plotted
position and the current position of the pen. This is much more simple
than it sounds and it is achieved in the program GRAPHIC in lines 210 and
220. The BASIC variables oldx and oldy are the last position plotted and
the variables newx and nexy are the next pair of coordinates to be
plotted. The variables newx and newy are always approaching xcoord and
ycoord, the current position of the light pen. The ammount of lag, and the
resultant smoothness, depends on the size of the BASIC variable divisor
(line 100). The larger the value of the divisor (used in lines 210 and
220) the greater the lag and the smoother the line. The divisor must be
the same for both X and Y otherwise circles will be drawn as elipses.

Chain the program GRAPHIC which will allow you to draw with a light pen in
any graphics screen mode. The screen modes can be selected with the up and
down cursor keys and the offset can be trimmed with the left and right
cursor keys. The size of the divisor used to smooth the line drawing can
be altered with H, for a higher value, and L for a lower value. It is
quite interesting to experiment with different divisor values. You will
probably find that a high value is required in modes 4 and 5 but a lower
value will work quite well in modes 0, 1 and 2. When divisor = 1 this is
the same as using the raw graphics coordinates. You can scroll the screen
with the Return key and change the paper and ink colours with P and I
respectively. The program is not Tube compatible but you should be able to
modify it to make it work with a second processor.

The program GRAPHIC illustrates a possible solution to the problem caused
by the occasional incorrect interpretation of the coordinates at the
extreme left and right edges of the screen. This effect was demonstrated
in module 1 but if it occurs when drawing smoothed lines it can make the
drawing look a real mess. The problem is not cured in the demonstration
program but it is suppressed by not plotting any points when the pen is at
either the extreme left edge or the extreme right edge of the screen. The
BASIC function FNswitch (lines 2330 to 2350) is used to make this
suppression. The pen is only seen as switched on if fire button 2 is open
(you might need to modify this condition) and if the current pen positon
is not at either the exteme left or the extreme right of the screen. I
will not claim that the best way of curing a problem is to suppress it in
this way but it does seem to work reasonably well if you can accept a
small reduction in the available screen area. If you remove the tests on
the X coordinate from FNswitch you will probably see the dreadful mess
this apparently trivial problem can make when you are drawing at the edge
of the screen.


   10 REM> GRAPHIC
   20 ON ERROR VDU23,1,1;0;0;0;:END
   30 A%=&EA
   40 X%=0
   50 Y%=&FF
   60 IF ((USR(&FFF4)AND&FF00)DIV&100)<>0 END
   70 DIM mcode &100
   80 PROCmcode
   90 mode=2
  100 divisor=4
  110 paper=6
  120 ink=4
  130 MODE mode
  140 PROCnewmode
  150 REPEAT
  160 REPEAT
  170 oldx=newx
  180 oldy=newy
  190 CALL mcode
  200 PRINTTAB(11,1);!xcoord;"   "TAB(11,2);!ycoord;"   "
  210 newx=newx+((!xcoord-newx)DIV divisor)
  220 newy=newy+((!ycoord-newy)DIV divisor)
  230 IF FNswitch PLOT69,oldx,oldy:PLOT69,newx,newy
      ELSE PLOT13,newx,newy
  240 UNTIL FNswitch
  250 IF INKEY(-58) PROCup:MODE mode:PROCnewmode
  260 IF INKEY(-42) PROCdown:MODE mode:PROCnewmode
  270 IF INKEY(-85) PROChigh
  280 IF INKEY(-87) PROClow
  290 IF INKEY(-56) PROCpaper
  300 IF INKEY(-38) PROCink
  310 IF INKEY(-26) PROCleft
  320 IF INKEY(-122) PROCright
  330 IF INKEY(-74) PROCscroll
  340 UNTIL FALSE
  350 :
  360 DEFPROCscroll
  370 PRINTTAB(0,31)
  380 PROCdelay
  390 ENDPROC
  400 :
  410 DEFPROCup
  420 mode=mode+1
  430 IF mode=3 mode=4
  440 IF mode>5 mode=5
  450 ENDPROC
  460 :
  470 DEFPROCdown
  480 mode=mode-1
  490 IF mode=3 mode=2
  500 IF mode<0 mode=0
  510 ENDPROC
  520 :
  530 DEFPROCleft
  540 IF offsetlow?mode=12 ENDPROC
  550 offsetlow?mode=offsetlow?mode+1
  560 PROCdelay
  570 ENDPROC
  580 :
  590 DEFPROCright
  600 IF offsetlow?mode=0 ENDPROC
  610 offsetlow?mode=offsetlow?mode-1
  620 PROCdelay
  630 ENDPROC
  640 :
  650 DEFPROCnewmode
  660 VDU23,1,0;0;0;0;
  670 VDU19,0,paper;0;
  680 VDU19,1,ink;0;
  690 GCOL3,1
  700 COLOUR1
  710 newx=-1
  720 newy=-1
  730 oldx=-1
  740 oldy=-1
  750 PROCdelay
  760 ENDPROC
  770 :
  780 DEFPROClow
  790 IF divisor>1 divisor=divisor DIV 2
  800 PROCdelay
  810 ENDPROC
  820 :
  830 DEFPROChigh
  840 IF divisor<8 divisor=divisor*2
  850 PROCdelay
  860 ENDPROC
  870 :
  880 DEFPROCdelay
  890 PRINTTAB(1,0)"Mode ";mode;SPC(8)
  900 PRINTTAB(1,1)"X coord = "
  910 PRINTTAB(1,2)"Y coord = "
  920 PRINTTAB(1,3)"divisor = ";divisor;"  "
  930 PRINTTAB(1,4)"offsetlow = ";offsetlow?mode
  940 time=TIME+20
  950 REPEAT UNTIL time<TIME
  960 ENDPROC
  970 :
  980 DEFPROCink
  990 ink=ink+1
 1000 IF ink=paper ink=ink+1
 1010 IF ink>7 ink=0
 1020 VDU19,1,ink;0;
 1030 PROCdelay
 1040 ENDPROC
 1050 :
 1060 DEFPROCpaper
 1070 paper=paper+1
 1080 IF paper=ink paper=paper+1
 1090 IF paper>7 paper=0
 1100 VDU19,0,paper;0;
 1110 PROCdelay
 1120 ENDPROC
 1130 :
 1140 DEFPROCmcode
 1150 xcoord=&70 :REM: &70-&73
 1160 ycoord=&74 :REM: &74-&77
 1170 start=&350 :REM: screen start address
 1180 screen=&355 :REM: screen mode
 1190 sheila=&FE00
 1200 FOR pass=0 TO 2 STEP 2
 1210 P%=mcode
 1220 [       OPT pass
 1230         LDA #&00
 1240         LDX #&07
 1250 .initloop
 1260         STA xcoord,X  \ &70-&77 = #&00
 1270         DEX
 1280         BPL initloop
 1290         LDY screen    \ screen mode into Y register
 1300         CPY #&06      \ is this mode 6 or 7?
 1310         BCS return    \ exit if non-graphics mode
 1320         CPY #&03      \ is this mode 3?
 1330         BNE carryon   \ exit if non-graphics mode
 1340 .return
 1350         RTS           \ return to BASIC if non-graphics mode
 1360 .carryon
 1370         LDA start     \ screen start address, low byte
 1380         STA ycoord
 1390         LDA start+1   \ screen start address, high byte
 1400         STA ycoord+1
 1410         LSR ycoord+1
 1420         ROR ycoord    \ start address DIV 2
 1430         LSR ycoord+1
 1440         ROR ycoord    \ start address DIV 4
 1450         LSR ycoord+1
 1460         ROR ycoord    \ start address DIV 8
 1470         LDA offsetlow,Y \ trim the offset
 1480         CLD           \ clear decimal flag
 1490         CLC           \ prepare for addition
 1500         ADC ycoord    \ add trim to offset
 1510         STA ycoord
 1520         LDA #&00
 1530         ADC ycoord+1
 1540         STA ycoord+1
 1550         SEC           \ prepare to subtract offset from light pen
                            \ register
 1560         LDX #&11      \ light pen register, low byte
 1570         STX sheila    \ 6845 address register
 1580         LDA sheila+1  \ 6845 data register
 1590         SBC ycoord    \ subtract offset, low byte
 1600         STA ycoord    \ low byte - offset
 1610         DEX           \ X = #&10
 1620         STX sheila    \ 6845 address register
 1630         LDA sheila+1  \ 6845 data register
 1640         SBC ycoord+1  \ subtract offset, high byte
 1650         STA ycoord+1  \ high byte - offset
 1660 .next
 1670         ASL ycoord    \ shift dividend/quotient left
 1680         ROL ycoord+1  \ shift dividend/quotient left
 1690         ROL xcoord    \ shift bits into partial dividend
 1700         LDA xcoord    \ load partial dividend
 1710         SEC           \ prepare for subtraction
 1720         SBC width,Y   \ subtract divisor
 1730         BCC done      \ branch if dividend < divisor
 1740         INC ycoord    \ increment quotient
 1750         STA xcoord    \ save new partial dividend
 1760 .done
 1770         DEX           \ decrement bit counter
 1780         BNE next      \ branch for 16 bits
 1790         LDA xloop,Y   \ prepare for multiplication
 1800         TAX           \ X=4 modes 0-3, X=5 modes 4-7
 1810 .multx
 1820         ASL xcoord    \ low byte * 2
 1830         ROL xcoord+1  \ high byte * 2
 1840         DEX           \ count number of multiplications
 1850         BNE multx     \ go back if not finished
 1860         LDA xadd,Y    \ A=8 modes 0-3, A=16 modes 4-7
 1870         CLC           \ prepare for addition
 1880         ADC xcoord
 1890         STA xcoord
 1900         LDA #&00
 1910         ADC xcoord+1
 1920         CMP #&05      \ max value = 4
 1930         BCC inrange
 1940         LDA #&02      \ dummy value
 1950 .inrange
 1960         STA xcoord+1
 1970         LDX #&05      \ prepare for y coordinate multiplication
 1980 .multy
 1990         ASL ycoord    \ low byte * 2
 2000         ROL ycoord+1  \ high byte * 2
 2010         DEX           \ count number of multiplications
 2020         BNE multy     \ go back if not finished
 2030         SEC           \ prepare for subtraction
 2040         LDA #&F0      \ low byte of decimal 1008
 2050         SBC ycoord    \ ycoord-#&F0
 2060         STA ycoord
 2070         LDA #&03      \ high byte of decimal 1008
 2080         SBC ycoord+1  \ (ycoord+1)-#&03
 2090         AND #&03      \ max value = 3
 2100         STA ycoord+1
 2110         RTS           \ return to BASIC
 2120 .offsetlow
 2130         EQUB &04      \ mode0, untrimmed = &06
 2140         EQUB &04      \ mode1, untrimmed = &06
 2150         EQUB &04      \ mode2, untrimmed = &06
 2160         EQUB &00      \ mode3, dummy value
 2170         EQUB &03      \ mode4, untrimmed = &04
 2180         EQUB &03      \ mode5, untrimmed = &04
 2190 .xloop
 2200         EQUD &00040404 \ modes 3-0
 2210         EQUW &0505    \ modes 5-4
 2220 .xadd
 2230         EQUD &00080808 \ modes 3-0
 2240         EQUW &1010    \ modes 5-4
 2250 .width
 2260         EQUD &00505050 \ modes 3-0
 2270         EQUW &2828    \ modes 5-4
 2280 .lastbyte
 2290 ]
 2300 NEXT
 2310 ENDPROC
 2320 : 
 2330 DEFFNswitch
 2340 IF (ADVAL(0)AND3)=0 IF !xcoord>16 IF !xcoord<1248 =FALSE
 2350 =TRUE
00000000  55 73 69 6e 67 20 61 20  6c 69 67 68 74 20 70 65  |Using a light pe|
00000010  6e 20 77 69 74 68 20 74  68 65 20 42 42 43 20 6d  |n with the BBC m|
00000020  69 63 72 6f 63 6f 6d 70  75 74 65 72 20 2d 20 62  |icrocomputer - b|
00000030  79 20 2d 20 47 6f 72 64  6f 6e 20 48 6f 72 73 69  |y - Gordon Horsi|
00000040  6e 67 74 6f 6e 0d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |ngton.----------|
00000050  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000080  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 0d 0d 4d 6f 64  |-----------..Mod|
00000090  75 6c 65 20 34 2e 20 55  73 69 6e 67 20 61 20 6c  |ule 4. Using a l|
000000a0  69 67 68 74 20 70 65 6e  20 66 6f 72 20 67 72 61  |ight pen for gra|
000000b0  70 68 69 63 73 20 69 6e  70 75 74 0d 2d 2d 2d 2d  |phics input.----|
000000c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000000e0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 0d 0d 0d 54 68 65  |----------...The|
000000f0  20 63 61 6c 63 75 6c 61  74 69 6f 6e 20 6f 66 20  | calculation of |
00000100  67 72 61 70 68 69 63 73  20 63 6f 6f 72 64 69 6e  |graphics coordin|
00000110  61 74 65 73 20 69 73 20  76 65 72 79 20 73 69 6d  |ates is very sim|
00000120  69 6c 61 72 20 74 6f 20  74 68 65 20 63 61 6c 63  |ilar to the calc|
00000130  75 6c 61 74 69 6f 6e 0d  75 73 65 64 20 69 6e 20  |ulation.used in |
00000140  6d 6f 64 75 6c 65 20 33  20 74 6f 20 64 65 74 65  |module 3 to dete|
00000150  72 6d 69 6e 65 20 74 65  78 74 20 63 6f 6f 72 64  |rmine text coord|
00000160  69 6e 61 74 65 73 20 65  78 63 65 70 74 20 74 68  |inates except th|
00000170  61 74 20 74 68 65 20 66  75 6c 6c 0d 72 65 73 6f  |at the full.reso|
00000180  6c 75 74 69 6f 6e 20 6f  66 20 74 68 65 20 6c 69  |lution of the li|
00000190  67 68 74 20 70 65 6e 20  63 61 6e 20 62 65 20 75  |ght pen can be u|
000001a0  73 65 64 20 69 6e 20 74  68 65 20 67 72 61 70 68  |sed in the graph|
000001b0  69 63 73 20 6d 6f 64 65  73 2e 20 41 20 6c 69 67  |ics modes. A lig|
000001c0  68 74 20 70 65 6e 0d 69  73 20 63 61 70 61 62 6c  |ht pen.is capabl|
000001d0  65 20 6f 66 20 72 65 73  6f 6c 76 69 6e 67 20 61  |e of resolving a|
000001e0  20 73 69 6e 67 6c 65 20  36 38 34 35 20 43 52 54  | single 6845 CRT|
000001f0  43 20 63 68 61 72 61 63  74 65 72 20 61 6e 64 20  |C character and |
00000200  74 68 65 20 63 61 6c 63  75 6c 61 74 69 6f 6e 0d  |the calculation.|
00000210  64 65 6d 6f 6e 73 74 72  61 74 65 64 20 69 6e 20  |demonstrated in |
00000220  74 68 69 73 20 6d 6f 64  75 6c 65 20 77 69 6c 6c  |this module will|
00000230  20 72 65 74 75 72 6e 20  74 68 65 20 67 72 61 70  | return the grap|
00000240  68 69 63 73 20 63 6f 6f  72 64 69 6e 61 74 65 73  |hics coordinates|
00000250  20 6f 66 20 74 68 65 0d  6d 69 64 64 6c 65 20 6f  | of the.middle o|
00000260  66 20 61 6e 79 20 43 52  54 43 20 63 68 61 72 61  |f any CRTC chara|
00000270  63 74 65 72 20 73 65 65  6e 20 62 79 20 74 68 65  |cter seen by the|
00000280  20 6c 69 67 68 74 20 70  65 6e 2e 20 54 68 69 73  | light pen. This|
00000290  20 63 61 6c 63 75 6c 61  74 69 6f 6e 20 63 61 6e  | calculation can|
000002a0  0d 62 65 20 6d 61 64 65  20 69 6e 20 61 6c 6c 20  |.be made in all |
000002b0  74 68 65 20 67 72 61 70  68 69 63 73 20 6d 6f 64  |the graphics mod|
000002c0  65 73 20 62 75 74 20 69  74 20 69 73 20 6e 6f 74  |es but it is not|
000002d0  20 76 65 72 79 20 6d 65  61 6e 69 6e 67 66 75 6c  | very meaningful|
000002e0  20 74 6f 0d 63 61 6c 63  75 6c 61 74 65 20 67 72  | to.calculate gr|
000002f0  61 70 68 69 63 73 20 63  6f 6f 72 64 69 6e 61 74  |aphics coordinat|
00000300  65 73 20 69 6e 20 74 68  65 20 6e 6f 6e 2d 67 72  |es in the non-gr|
00000310  61 70 68 69 63 73 20 6d  6f 64 65 73 2e 20 4d 6f  |aphics modes. Mo|
00000320  64 65 20 37 20 68 61 73  0d 67 72 61 70 68 69 63  |de 7 has.graphic|
00000330  73 20 6f 66 20 61 20 73  6f 72 74 20 62 75 74 20  |s of a sort but |
00000340  49 20 74 68 69 6e 6b 20  74 68 65 79 20 61 72 65  |I think they are|
00000350  20 62 65 73 74 20 75 6e  64 65 72 73 74 6f 6f 64  | best understood|
00000360  20 61 73 20 61 6e 20 61  6c 74 65 72 6e 61 74 69  | as an alternati|
00000370  76 65 0d 63 68 61 72 61  63 74 65 72 20 73 65 74  |ve.character set|
00000380  20 72 61 74 68 65 72 20  74 68 61 6e 20 61 73 20  | rather than as |
00000390  74 72 75 65 20 67 72 61  70 68 69 63 73 2e 20 49  |true graphics. I|
000003a0  66 20 74 68 65 20 61 6c  67 6f 72 69 74 68 6d 20  |f the algorithm |
000003b0  64 65 73 63 72 69 62 65  64 20 69 6e 0d 74 68 69  |described in.thi|
000003c0  73 20 6d 6f 64 75 6c 65  2c 20 61 6e 64 20 64 65  |s module, and de|
000003d0  6d 6f 6e 73 74 72 61 74  65 64 20 69 6e 20 74 68  |monstrated in th|
000003e0  65 20 70 72 6f 67 72 61  6d 20 47 52 41 50 48 49  |e program GRAPHI|
000003f0  43 2c 20 69 73 20 75 73  65 64 20 69 6e 20 61 0d  |C, is used in a.|
00000400  6e 6f 6e 2d 67 72 61 70  68 69 63 73 20 6d 6f 64  |non-graphics mod|
00000410  65 20 69 74 20 77 69 6c  6c 20 67 69 76 65 20 61  |e it will give a|
00000420  20 6d 69 73 6c 65 61 64  69 6e 67 20 61 6e 73 77  | misleading answ|
00000430  65 72 2e 20 49 20 64 6f  6e 27 74 20 74 68 69 73  |er. I don't this|
00000440  20 69 73 20 72 65 61 6c  6c 79 0d 61 20 70 72 6f  | is really.a pro|
00000450  62 6c 65 6d 20 62 65 63  61 75 73 65 20 74 68 65  |blem because the|
00000460  72 65 20 63 61 6e 20 6e  6f 74 20 62 65 20 61 6e  |re can not be an|
00000470  79 20 63 6f 72 72 65 63  74 20 61 6e 73 77 65 72  |y correct answer|
00000480  20 66 6f 72 20 67 72 61  70 68 69 63 73 0d 63 6f  | for graphics.co|
00000490  6f 72 64 69 6e 61 74 65  73 20 69 6e 20 61 20 6e  |ordinates in a n|
000004a0  6f 6e 2d 67 72 61 70 68  69 63 73 20 73 63 72 65  |on-graphics scre|
000004b0  65 6e 20 6d 6f 64 65 2e  0d 0d 54 68 65 20 74 61  |en mode...The ta|
000004c0  62 6c 65 20 69 6e 20 66  69 67 75 72 65 20 31 20  |ble in figure 1 |
000004d0  73 68 6f 77 73 20 74 68  65 20 76 61 6c 75 65 73  |shows the values|
000004e0  20 6f 66 20 74 68 65 20  76 61 72 69 61 62 6c 65  | of the variable|
000004f0  73 20 75 73 65 64 20 69  6e 20 74 68 65 0d 63 61  |s used in the.ca|
00000500  6c 63 75 6c 61 74 69 6f  6e 20 6f 66 20 67 72 61  |lculation of gra|
00000510  70 68 69 63 73 20 63 6f  6f 72 64 69 6e 61 74 65  |phics coordinate|
00000520  73 2e 20 54 68 65 20 76  61 6c 75 65 73 20 61 73  |s. The values as|
00000530  73 69 67 6e 65 64 20 74  6f 20 74 68 65 20 73 63  |signed to the sc|
00000540  72 65 65 6e 0d 73 74 61  72 74 20 61 64 64 72 65  |reen.start addre|
00000550  73 73 20 69 6e 20 74 68  69 73 20 74 61 62 6c 65  |ss in this table|
00000560  20 63 61 6e 20 6f 6e 6c  79 20 62 65 20 75 73 65  | can only be use|
00000570  64 20 69 66 20 74 68 65  20 73 63 72 65 65 6e 20  |d if the screen |
00000580  68 61 73 20 6e 6f 74 20  62 65 65 6e 0d 73 63 72  |has not been.scr|
00000590  6f 6c 6c 65 64 2e 20 49  66 20 74 68 65 20 73 63  |olled. If the sc|
000005a0  72 65 65 6e 20 69 73 20  73 63 72 6f 6c 6c 65 64  |reen is scrolled|
000005b0  20 74 68 65 20 73 74 61  72 74 20 61 64 64 72 65  | the start addre|
000005c0  73 73 20 63 68 61 6e 67  65 73 20 66 72 6f 6d 20  |ss changes from |
000005d0  74 68 65 0d 76 61 6c 75  65 73 20 73 68 6f 77 6e  |the.values shown|
000005e0  20 69 6e 20 66 69 67 75  72 65 20 31 2e 20 54 68  | in figure 1. Th|
000005f0  65 20 63 75 72 72 65 6e  74 20 73 63 72 65 65 6e  |e current screen|
00000600  20 73 74 61 72 74 20 61  64 64 72 65 73 73 20 73  | start address s|
00000610  68 6f 75 6c 64 0d 74 68  65 72 65 66 6f 72 65 20  |hould.therefore |
00000620  62 65 20 72 65 61 64 20  66 72 6f 6d 20 26 33 35  |be read from &35|
00000630  30 20 28 6c 6f 77 20 62  79 74 65 29 20 61 6e 64  |0 (low byte) and|
00000640  20 26 33 35 31 20 28 68  69 67 68 20 62 79 74 65  | &351 (high byte|
00000650  29 2e 0d 0d 0d 20 20 20  20 20 20 20 20 20 4d 6f  |)....         Mo|
00000660  64 65 20 20 73 74 61 72  74 20 61 64 64 72 20 20  |de  start addr  |
00000670  74 72 69 6d 20 20 20 20  77 69 64 74 68 20 20 20  |trim    width   |
00000680  72 65 73 6f 6c 75 74 69  6f 6e 0d 20 20 20 20 20  |resolution.     |
00000690  20 20 20 2d 2d 2d 2d 2d  2b 2d 2d 2d 2d 2d 2d 2d  |   -----+-------|
000006a0  2d 2d 2d 2d 2b 2d 2d 2d  2d 2d 2d 2d 2b 2d 2d 2d  |----+-------+---|
000006b0  2d 2d 2d 2d 2b 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----+-----------|
000006c0  2d 0d 20 20 20 20 20 20  20 20 20 20 30 20 20 7c  |-.          0  ||
000006d0  20 20 20 26 33 30 30 30  20 20 20 7c 20 20 26 30  |   &3000   |  &0|
000006e0  36 20 20 7c 20 20 26 35  30 20 20 7c 20 38 30 20  |6  |  &50  | 80 |
000006f0  78 20 33 32 0d 20 20 20  20 20 20 20 20 20 20 31  |x 32.          1|
00000700  20 20 7c 20 20 20 26 33  30 30 30 20 20 20 7c 20  |  |   &3000   | |
00000710  20 26 30 36 20 20 7c 20  20 26 35 30 20 20 7c 20  | &06  |  &50  | |
00000720  38 30 20 78 20 33 32 0d  20 20 20 20 20 20 20 20  |80 x 32.        |
00000730  20 20 32 20 20 7c 20 20  20 26 33 30 30 30 20 20  |  2  |   &3000  |
00000740  20 7c 20 20 26 30 36 20  20 7c 20 20 26 35 30 20  | |  &06  |  &50 |
00000750  20 7c 20 38 30 20 78 20  33 32 0d 20 20 20 20 20  | | 80 x 32.     |
00000760  20 20 20 20 20 34 20 20  7c 20 20 20 26 35 38 30  |     4  |   &580|
00000770  30 20 20 20 7c 20 20 26  30 34 20 20 7c 20 20 26  |0   |  &04  |  &|
00000780  32 38 20 20 7c 20 34 30  20 78 20 33 32 0d 20 20  |28  | 40 x 32.  |
00000790  20 20 20 20 20 20 20 20  35 20 20 7c 20 20 20 26  |        5  |   &|
000007a0  35 38 30 30 20 20 20 7c  20 20 26 30 34 20 20 7c  |5800   |  &04  ||
000007b0  20 20 26 32 38 20 20 7c  20 34 30 20 78 20 33 32  |  &28  | 40 x 32|
000007c0  0d 20 20 20 20 20 20 20  20 2d 2d 2d 2d 2d 2b 2d  |.        -----+-|
000007d0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2b 2d 2d 2d 2d 2d  |----------+-----|
000007e0  2d 2d 2b 2d 2d 2d 2d 2d  2d 2d 2b 2d 2d 2d 2d 2d  |--+-------+-----|
000007f0  2d 2d 2d 2d 2d 2d 2d 0d  0d 46 69 67 75 72 65 20  |-------..Figure |
00000800  31 2e 20 54 68 65 20 73  74 61 72 74 20 61 64 64  |1. The start add|
00000810  72 65 73 73 2c 20 74 72  69 6d 2c 20 61 6e 64 20  |ress, trim, and |
00000820  77 69 64 74 68 20 66 6f  72 20 65 61 63 68 20 67  |width for each g|
00000830  72 61 70 68 69 63 73 20  6d 6f 64 65 0d 2d 2d 2d  |raphics mode.---|
00000840  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000880  0d 0d 0d 54 68 65 20 66  69 72 73 74 20 73 74 61  |...The first sta|
00000890  67 65 20 69 6e 20 63 61  6c 63 75 6c 61 74 69 6e  |ge in calculatin|
000008a0  67 20 74 68 65 20 6c 69  67 68 74 20 70 65 6e 20  |g the light pen |
000008b0  70 6f 73 69 74 69 6f 6e  20 69 73 20 74 6f 20 64  |position is to d|
000008c0  65 74 65 72 6d 69 6e 65  20 74 68 65 0d 76 61 6c  |etermine the.val|
000008d0  75 65 20 6f 66 20 74 68  65 20 6f 66 66 73 65 74  |ue of the offset|
000008e0  2e 20 54 68 65 20 6f 66  66 73 65 74 20 69 6e 20  |. The offset in |
000008f0  61 6c 6c 20 67 72 61 70  68 69 63 73 20 6d 6f 64  |all graphics mod|
00000900  65 73 20 69 73 20 67 69  76 65 6e 20 62 79 3a 0d  |es is given by:.|
00000910  0d 20 20 6f 66 66 73 65  74 20 3d 20 74 72 69 6d  |.  offset = trim|
00000920  20 2b 20 28 73 63 72 65  65 6e 20 73 74 61 72 74  | + (screen start|
00000930  20 61 64 64 72 65 73 73  20 44 49 56 20 38 29 0d  | address DIV 8).|
00000940  0d 54 68 65 20 43 52 43  54 20 58 20 61 6e 64 20  |.The CRCT X and |
00000950  59 20 63 6f 6f 72 64 69  6e 61 74 65 73 20 63 61  |Y coordinates ca|
00000960  6e 20 74 68 65 6e 20 62  65 20 63 61 6c 63 75 6c  |n then be calcul|
00000970  61 74 65 64 20 75 73 69  6e 67 20 74 68 65 20 61  |ated using the a|
00000980  70 70 72 6f 70 72 69 61  74 65 0d 76 61 6c 75 65  |ppropriate.value|
00000990  20 6f 66 20 6f 66 66 73  65 74 2e 0d 0d 20 20 59  | of offset...  Y|
000009a0  20 3d 20 28 6c 69 67 68  74 20 70 65 6e 20 72 65  | = (light pen re|
000009b0  67 69 73 74 65 72 20 2d  20 6f 66 66 73 65 74 29  |gister - offset)|
000009c0  20 44 49 56 20 77 69 64  74 68 0d 0d 20 20 58 20  | DIV width..  X |
000009d0  3d 20 28 6c 69 67 68 74  20 70 65 6e 20 72 65 67  |= (light pen reg|
000009e0  69 73 74 65 72 20 2d 20  6f 66 66 73 65 74 29 20  |ister - offset) |
000009f0  4d 4f 44 20 77 69 64 74  68 0d 0d 41 20 43 52 43  |MOD width..A CRC|
00000a00  54 20 59 20 63 6f 6f 72  64 69 6e 61 74 65 20 63  |T Y coordinate c|
00000a10  61 6e 20 62 65 20 63 6f  6e 76 65 72 74 65 64 20  |an be converted |
00000a20  69 6e 74 6f 20 61 20 67  72 61 70 68 69 63 73 20  |into a graphics |
00000a30  59 20 63 6f 6f 72 64 69  6e 61 74 65 20 62 79 0d  |Y coordinate by.|
00000a40  6d 75 6c 74 69 70 6c 79  69 6e 67 20 69 74 20 62  |multiplying it b|
00000a50  79 20 33 32 20 61 6e 64  20 74 68 65 6e 20 73 75  |y 32 and then su|
00000a60  62 74 72 61 63 74 69 6e  67 20 74 68 65 20 70 72  |btracting the pr|
00000a70  6f 64 75 63 74 20 66 72  6f 6d 20 31 30 30 38 2e  |oduct from 1008.|
00000a80  0d 0d 41 20 43 52 43 54  20 58 20 63 6f 6f 72 64  |..A CRCT X coord|
00000a90  69 6e 61 74 65 20 63 61  6e 20 62 65 20 63 6f 6e  |inate can be con|
00000aa0  76 65 72 74 65 64 20 69  6e 74 6f 20 61 20 67 72  |verted into a gr|
00000ab0  61 70 68 69 63 73 20 58  20 63 6f 6f 72 64 69 6e  |aphics X coordin|
00000ac0  61 74 65 20 69 6e 20 6d  6f 64 65 73 0d 30 20 74  |ate in modes.0 t|
00000ad0  6f 20 32 20 62 79 20 6d  75 6c 74 69 70 6c 79 69  |o 2 by multiplyi|
00000ae0  6e 67 20 69 74 20 62 79  20 38 20 61 6e 64 20 74  |ng it by 8 and t|
00000af0  68 65 6e 20 61 64 64 69  6e 67 20 38 2e 20 49 6e  |hen adding 8. In|
00000b00  20 6d 6f 64 65 73 20 34  20 61 6e 64 20 35 20 61  | modes 4 and 5 a|
00000b10  20 43 52 43 54 20 58 0d  63 6f 6f 72 64 69 6e 61  | CRCT X.coordina|
00000b20  74 65 20 63 61 6e 20 62  65 20 63 6f 6e 76 65 72  |te can be conver|
00000b30  74 65 64 20 69 6e 74 6f  20 61 20 67 72 61 70 68  |ted into a graph|
00000b40  69 63 73 20 63 6f 6f 72  64 69 6e 61 74 65 20 62  |ics coordinate b|
00000b50  79 20 6d 75 6c 74 69 70  6c 79 69 6e 67 20 69 74  |y multiplying it|
00000b60  0d 62 79 20 31 36 20 61  6e 64 20 74 68 65 6e 20  |.by 16 and then |
00000b70  61 64 64 69 6e 67 20 31  36 2e 0d 0d 54 68 65 20  |adding 16...The |
00000b80  76 61 6c 75 65 73 20 6f  66 20 74 72 69 6d 20 61  |values of trim a|
00000b90  6e 64 20 77 69 64 74 68  20 75 73 65 64 20 69 6e  |nd width used in|
00000ba0  20 74 68 65 73 65 20 63  61 6c 63 75 6c 61 74 69  | these calculati|
00000bb0  6f 6e 73 20 61 72 65 20  74 68 6f 73 65 0d 61 70  |ons are those.ap|
00000bc0  70 72 6f 70 72 69 61 74  65 20 74 6f 20 74 68 65  |propriate to the|
00000bd0  20 73 63 72 65 65 6e 20  6d 6f 64 65 20 69 6e 20  | screen mode in |
00000be0  75 73 65 20 61 74 20 74  68 65 20 74 69 6d 65 2e  |use at the time.|
00000bf0  20 54 68 65 20 73 63 72  65 65 6e 20 6d 6f 64 65  | The screen mode|
00000c00  0d 28 69 67 6e 6f 72 69  6e 67 20 73 68 61 64 6f  |.(ignoring shado|
00000c10  77 29 20 63 61 6e 20 62  65 20 72 65 61 64 20 66  |w) can be read f|
00000c20  72 6f 6d 20 26 33 35 35  2e 20 54 68 65 20 76 61  |rom &355. The va|
00000c30  6c 75 65 73 20 75 73 65  64 20 66 6f 72 20 74 72  |lues used for tr|
00000c40  69 6d 20 77 69 6c 6c 2c  20 61 73 0d 74 68 65 20  |im will, as.the |
00000c50  6e 61 6d 65 20 73 75 67  67 65 73 74 73 2c 20 6e  |name suggests, n|
00000c60  65 65 64 20 74 6f 20 62  65 20 74 72 69 6d 6d 65  |eed to be trimme|
00000c70  64 20 61 73 20 64 65 73  63 72 69 62 65 64 20 69  |d as described i|
00000c80  6e 20 74 68 65 20 65 61  72 6c 69 65 72 20 6d 6f  |n the earlier mo|
00000c90  64 75 6c 65 73 2e 0d 54  68 65 20 76 61 6c 75 65  |dules..The value|
00000ca0  73 20 6f 66 20 74 72 69  6d 20 75 73 65 64 20 69  |s of trim used i|
00000cb0  6e 20 74 68 65 20 64 65  6d 6f 6e 73 74 72 61 74  |n the demonstrat|
00000cc0  69 6f 6e 20 70 72 6f 67  72 61 6d 20 47 52 41 50  |ion program GRAP|
00000cd0  48 49 43 20 61 72 65 20  74 68 6f 73 65 20 49 0d  |HIC are those I.|
00000ce0  66 6f 75 6e 64 20 74 6f  20 62 65 20 6d 6f 73 74  |found to be most|
00000cf0  20 73 75 69 74 61 62 6c  65 20 66 6f 72 20 6d 79  | suitable for my|
00000d00  20 6c 69 67 68 74 20 70  65 6e 2e 20 59 6f 75 20  | light pen. You |
00000d10  6d 69 67 68 74 20 6c 69  6b 65 20 74 6f 20 65 64  |might like to ed|
00000d20  69 74 20 74 68 65 0d 70  72 6f 67 72 61 6d 20 74  |it the.program t|
00000d30  6f 20 75 73 65 20 74 68  65 20 76 61 6c 75 65 73  |o use the values|
00000d40  20 62 65 73 74 20 73 75  69 74 65 64 20 74 6f 20  | best suited to |
00000d50  79 6f 75 72 20 6c 69 67  68 74 20 70 65 6e 20 62  |your light pen b|
00000d60  75 74 20 79 6f 75 20 63  61 6e 20 61 6c 73 6f 0d  |ut you can also.|
00000d70  74 72 69 6d 20 74 68 65  20 76 61 6c 75 65 73 20  |trim the values |
00000d80  49 20 68 61 76 65 20 75  73 65 64 20 77 69 74 68  |I have used with|
00000d90  20 74 68 65 20 6c 65 66  74 20 61 6e 64 20 72 69  | the left and ri|
00000da0  67 68 74 20 63 75 72 73  6f 72 20 6b 65 79 73 20  |ght cursor keys |
00000db0  77 68 65 6e 20 74 68 65  0d 70 72 6f 67 72 61 6d  |when the.program|
00000dc0  20 69 73 20 72 75 6e 6e  69 6e 67 2e 20 54 68 65  | is running. The|
00000dd0  20 6c 61 62 65 6c 20 6f  66 66 73 65 74 6c 6f 77  | label offsetlow|
00000de0  20 69 73 20 75 73 65 64  20 66 6f 72 20 74 68 65  | is used for the|
00000df0  20 74 61 62 6c 65 20 6f  66 20 76 61 6c 75 65 73  | table of values|
00000e00  0d 61 73 73 69 67 6e 65  64 20 74 6f 20 74 72 69  |.assigned to tri|
00000e10  6d 2e 0d 0d 54 68 65 20  72 61 6e 67 65 20 6f 66  |m...The range of|
00000e20  20 74 68 65 20 58 20 61  6e 64 20 59 20 63 6f 6f  | the X and Y coo|
00000e30  72 64 69 6e 61 74 65 73  20 6d 61 64 65 20 61 76  |rdinates made av|
00000e40  61 69 6c 61 62 6c 65 20  62 79 20 74 68 69 73 20  |ailable by this |
00000e50  61 6c 67 6f 72 69 74 68  6d 20 69 73 0d 69 6e 64  |algorithm is.ind|
00000e60  65 70 65 6e 64 61 6e 74  20 6f 66 20 74 68 65 20  |ependant of the |
00000e70  73 63 72 65 65 6e 20 6d  6f 64 65 2e 20 54 68 65  |screen mode. The|
00000e80  20 70 6f 69 6e 74 20 30  2c 30 20 69 73 20 61 6c  | point 0,0 is al|
00000e90  77 61 79 73 20 69 6e 20  74 68 65 20 62 6f 74 74  |ways in the bott|
00000ea0  6f 6d 20 6c 65 66 74 0d  6f 66 20 74 68 65 20 73  |om left.of the s|
00000eb0  63 72 65 65 6e 20 61 6e  64 20 31 32 37 39 2c 31  |creen and 1279,1|
00000ec0  30 32 33 20 69 73 20 61  6c 77 61 79 73 20 69 6e  |023 is always in|
00000ed0  20 74 68 65 20 74 6f 70  20 72 69 67 68 74 20 62  | the top right b|
00000ee0  75 74 2c 20 62 65 63 61  75 73 65 20 74 68 65 0d  |ut, because the.|
00000ef0  63 6f 6f 72 64 69 6e 61  74 65 73 20 63 6f 72 72  |coordinates corr|
00000f00  65 73 70 6f 6e 64 20 77  69 74 68 20 74 68 65 20  |espond with the |
00000f10  63 65 6e 74 72 65 20 6f  66 20 43 52 54 43 20 63  |centre of CRTC c|
00000f20  68 61 72 61 63 74 65 72  73 2c 20 74 68 65 20 72  |haracters, the r|
00000f30  61 6e 67 65 0d 61 76 61  69 6c 61 62 6c 65 20 69  |ange.available i|
00000f40  73 20 66 72 6f 6d 20 38  2c 38 20 74 6f 20 31 32  |s from 8,8 to 12|
00000f50  37 31 2c 31 30 31 35 20  69 6e 20 6d 6f 64 65 73  |71,1015 in modes|
00000f60  20 30 2c 20 31 20 61 6e  64 20 32 2c 20 61 6e 64  | 0, 1 and 2, and|
00000f70  20 66 72 6f 6d 20 31 36  2c 31 36 20 74 6f 0d 31  | from 16,16 to.1|
00000f80  32 36 33 2c 31 30 30 38  20 69 6e 20 6d 6f 64 65  |263,1008 in mode|
00000f90  73 20 34 20 61 6e 64 20  35 2e 20 41 20 6d 61 78  |s 4 and 5. A max|
00000fa0  69 6d 75 6d 20 6f 66 20  74 77 6f 20 62 79 74 65  |imum of two byte|
00000fb0  73 20 61 72 65 20 72 65  71 75 69 72 65 64 20 74  |s are required t|
00000fc0  6f 20 73 74 6f 72 65 0d  65 61 63 68 20 63 6f 6f  |o store.each coo|
00000fd0  72 64 69 6e 61 74 65 20  62 75 74 20 74 68 65 20  |rdinate but the |
00000fe0  6d 61 63 68 69 6e 65 20  63 6f 64 65 20 72 6f 75  |machine code rou|
00000ff0  74 69 6e 65 20 69 6e 20  74 68 65 20 70 72 6f 67  |tine in the prog|
00001000  72 61 6d 20 47 52 41 50  48 49 43 20 75 73 65 73  |ram GRAPHIC uses|
00001010  20 34 0d 62 79 74 65 73  20 70 65 72 20 63 6f 6f  | 4.bytes per coo|
00001020  72 64 69 6e 61 74 65 20  73 6f 20 74 68 61 74 20  |rdinate so that |
00001030  74 68 65 20 63 6f 6f 72  64 69 6e 61 74 65 73 20  |the coordinates |
00001040  63 61 6e 20 62 65 20 72  65 61 64 20 75 73 69 6e  |can be read usin|
00001050  67 20 74 68 65 20 42 41  53 49 43 20 21 0d 69 6e  |g the BASIC !.in|
00001060  64 69 72 65 63 74 69 6f  6e 20 6f 70 65 72 61 74  |direction operat|
00001070  6f 72 2e 20 54 68 65 20  72 6f 75 74 69 6e 65 20  |or. The routine |
00001080  61 6c 77 61 79 73 20 72  65 74 75 72 6e 73 20 74  |always returns t|
00001090  68 65 20 63 6f 6f 72 64  69 6e 61 74 65 73 20 30  |he coordinates 0|
000010a0  2c 30 20 69 66 20 69 74  0d 69 73 20 63 61 6c 6c  |,0 if it.is call|
000010b0  65 64 20 69 6e 20 61 20  6e 6f 6e 2d 67 72 61 70  |ed in a non-grap|
000010c0  68 69 63 73 20 6d 6f 64  65 2e 0d 0d 54 68 65 20  |hics mode...The |
000010d0  6d 61 63 68 69 6e 65 20  63 6f 64 65 20 72 6f 75  |machine code rou|
000010e0  74 69 6e 65 20 69 6e 20  74 68 65 20 64 65 6d 6f  |tine in the demo|
000010f0  6e 73 74 72 61 74 69 6f  6e 20 70 72 6f 67 72 61  |nstration progra|
00001100  6d 20 63 68 65 63 6b 73  20 74 68 61 74 20 74 68  |m checks that th|
00001110  65 0d 63 6f 6f 72 64 69  6e 61 74 65 73 20 69 74  |e.coordinates it|
00001120  20 70 72 6f 64 75 63 65  73 20 61 72 65 20 77 69  | produces are wi|
00001130  74 68 69 6e 20 74 68 65  20 65 78 70 65 63 74 65  |thin the expecte|
00001140  64 20 72 61 6e 67 65 2e  20 54 68 69 73 20 69 73  |d range. This is|
00001150  20 61 20 67 6f 6f 64 20  69 64 65 61 0d 77 69 74  | a good idea.wit|
00001160  68 20 6e 6f 6e 2d 69 6e  74 65 72 72 75 70 74 20  |h non-interrupt |
00001170  6c 69 67 68 74 20 70 65  6e 20 64 72 69 76 65 72  |light pen driver|
00001180  73 20 62 65 63 61 75 73  65 2c 20 69 66 20 74 68  |s because, if th|
00001190  65 20 70 65 6e 20 68 61  73 20 6e 6f 74 20 62 65  |e pen has not be|
000011a0  65 6e 0d 75 73 65 64 2c  20 74 68 65 20 61 6c 67  |en.used, the alg|
000011b0  6f 72 69 74 68 6d 20 67  69 76 65 73 20 61 20 76  |orithm gives a v|
000011c0  65 72 79 20 6d 69 73 6c  65 61 64 69 6e 67 20 61  |ery misleading a|
000011d0  6e 73 77 65 72 2e 20 54  68 69 73 20 69 73 20 6e  |nswer. This is n|
000011e0  6f 74 20 61 20 70 72 6f  62 6c 65 6d 0d 74 68 61  |ot a problem.tha|
000011f0  74 20 63 61 6e 20 6f 63  63 75 72 20 77 69 74 68  |t can occur with|
00001200  20 69 6e 74 65 72 72 75  70 74 20 64 72 69 76 65  | interrupt drive|
00001210  6e 20 73 6f 66 74 77 61  72 65 20 62 65 63 61 75  |n software becau|
00001220  73 65 2c 20 62 79 20 64  65 66 69 6e 69 74 69 6f  |se, by definitio|
00001230  6e 2c 20 74 68 65 0d 6c  69 67 68 74 20 70 65 6e  |n, the.light pen|
00001240  20 6d 75 73 74 20 62 65  20 75 73 65 64 20 74 6f  | must be used to|
00001250  20 67 65 6e 65 72 61 74  65 20 74 68 65 20 6c 69  | generate the li|
00001260  67 68 74 20 70 65 6e 20  69 6e 74 65 72 72 75 70  |ght pen interrup|
00001270  74 2e 0d 0d 54 68 65 20  6d 61 78 69 6d 75 6d 20  |t...The maximum |
00001280  72 65 73 6f 6c 75 74 69  6f 6e 20 6f 66 20 74 68  |resolution of th|
00001290  65 20 6c 69 67 68 74 20  70 65 6e 20 67 72 61 70  |e light pen grap|
000012a0  68 69 63 73 20 63 6f 6f  72 64 69 6e 61 74 65 73  |hics coordinates|
000012b0  20 69 73 20 38 30 78 33  32 20 69 6e 0d 6d 6f 64  | is 80x32 in.mod|
000012c0  65 73 20 30 2c 20 31 20  61 6e 64 20 32 2c 20 62  |es 0, 1 and 2, b|
000012d0  75 74 20 61 20 72 61 74  68 65 72 20 63 68 75 6e  |ut a rather chun|
000012e0  6b 79 20 34 30 78 33 32  20 69 6e 20 6d 6f 64 65  |ky 40x32 in mode|
000012f0  73 20 34 20 61 6e 64 20  35 20 2d 20 61 6e 64 0d  |s 4 and 5 - and.|
00001300  64 65 73 63 72 69 62 69  6e 67 20 74 68 69 73 20  |describing this |
00001310  61 73 20 63 68 75 6e 6b  79 20 69 73 20 62 65 69  |as chunky is bei|
00001320  6e 67 20 71 75 69 74 65  20 67 65 6e 65 72 6f 75  |ng quite generou|
00001330  73 2e 20 49 66 20 79 6f  75 20 75 73 65 20 61 20  |s. If you use a |
00001340  6c 69 67 68 74 20 70 65  6e 0d 74 6f 20 64 72 61  |light pen.to dra|
00001350  77 20 6f 6e 20 61 20 67  72 61 70 68 69 63 73 20  |w on a graphics |
00001360  73 63 72 65 65 6e 20 74  68 69 73 20 70 6f 6f 72  |screen this poor|
00001370  20 72 65 73 6f 6c 75 74  69 6f 6e 20 67 69 76 65  | resolution give|
00001380  73 20 61 20 71 75 69 74  65 20 73 68 61 6b 65 79  |s a quite shakey|
00001390  0d 6c 6f 6f 6b 69 6e 67  20 6c 69 6e 65 20 64 72  |.looking line dr|
000013a0  61 77 69 6e 67 2c 20 65  73 70 65 63 69 61 6c 6c  |awing, especiall|
000013b0  79 20 77 69 74 68 20 64  69 61 67 6f 6e 61 6c 20  |y with diagonal |
000013c0  6c 69 6e 65 73 2e 20 49  6e 20 73 70 69 74 65 20  |lines. In spite |
000013d0  6f 66 20 74 68 69 73 0d  61 70 70 61 72 65 6e 74  |of this.apparent|
000013e0  20 70 72 6f 62 6c 65 6d  20 69 74 20 69 73 20 70  | problem it is p|
000013f0  6f 73 73 69 62 6c 65 20  74 6f 20 70 72 6f 64 75  |ossible to produ|
00001400  63 65 20 76 65 72 79 20  73 6d 6f 6f 74 68 20 6c  |ce very smooth l|
00001410  69 6e 65 73 20 61 6e 64  20 74 6f 20 64 72 61 77  |ines and to draw|
00001420  0d 77 69 74 68 20 61 6e  20 61 63 63 65 70 74 61  |.with an accepta|
00001430  62 6c 65 20 6c 65 76 65  6c 20 6f 66 20 61 63 63  |ble level of acc|
00001440  75 72 61 63 79 20 66 6f  72 20 66 72 65 65 68 61  |uracy for freeha|
00001450  6e 64 20 77 6f 72 6b 2e  20 49 66 20 79 6f 75 20  |nd work. If you |
00001460  77 61 6e 74 20 74 6f 20  75 73 65 0d 79 6f 75 72  |want to use.your|
00001470  20 63 6f 6d 70 75 74 65  72 20 66 6f 72 20 76 65  | computer for ve|
00001480  72 79 20 61 63 63 75 72  61 74 65 20 64 72 61 77  |ry accurate draw|
00001490  69 6e 67 20 74 68 65 6e  20 79 6f 75 20 73 68 6f  |ing then you sho|
000014a0  75 6c 64 20 75 73 65 20  61 20 6d 6f 75 73 65 20  |uld use a mouse |
000014b0  61 73 20 61 6e 0d 69 6e  70 75 74 20 64 65 76 69  |as an.input devi|
000014c0  63 65 20 61 6e 64 20 6e  6f 74 20 61 20 6c 69 67  |ce and not a lig|
000014d0  68 74 20 70 65 6e 2e 0d  0d 53 6d 6f 6f 74 68 20  |ht pen...Smooth |
000014e0  6c 69 6e 65 20 64 72 61  77 69 6e 67 20 77 69 74  |line drawing wit|
000014f0  68 20 61 20 6c 69 67 68  74 20 70 65 6e 20 63 61  |h a light pen ca|
00001500  6e 20 62 65 20 61 63 68  69 65 76 65 64 20 62 79  |n be achieved by|
00001510  20 61 6c 6c 6f 77 69 6e  67 20 74 68 65 20 6c 69  | allowing the li|
00001520  6e 65 0d 62 65 69 6e 67  20 64 72 61 77 6e 20 74  |ne.being drawn t|
00001530  6f 20 6c 61 67 20 62 65  68 69 6e 64 20 74 68 65  |o lag behind the|
00001540  20 63 75 72 72 65 6e 74  20 6c 69 67 68 74 20 70  | current light p|
00001550  65 6e 20 70 6f 73 69 74  69 6f 6e 20 62 75 74 20  |en position but |
00001560  74 6f 20 61 6c 77 61 79  73 0d 61 70 70 72 6f 61  |to always.approa|
00001570  63 68 20 74 68 65 20 63  75 72 72 65 6e 74 20 70  |ch the current p|
00001580  6f 73 69 74 69 6f 6e 20  6f 66 20 74 68 65 20 70  |osition of the p|
00001590  65 6e 2e 20 54 68 69 73  20 69 73 20 61 63 68 69  |en. This is achi|
000015a0  65 76 65 64 20 62 79 20  73 74 6f 72 69 6e 67 20  |eved by storing |
000015b0  74 68 65 0d 63 6f 6f 72  64 69 6e 61 74 65 73 20  |the.coordinates |
000015c0  6f 66 20 74 68 65 20 6c  61 73 74 20 70 6c 6f 74  |of the last plot|
000015d0  74 65 64 20 70 6f 73 69  74 69 6f 6e 20 61 6e 64  |ted position and|
000015e0  20 63 61 6c 63 75 6c 61  74 69 6e 67 20 74 68 65  | calculating the|
000015f0  20 6e 65 78 74 20 70 6f  73 69 74 69 6f 6e 0d 74  | next position.t|
00001600  6f 20 62 65 20 70 6c 6f  74 74 65 64 20 61 73 20  |o be plotted as |
00001610  61 20 66 72 61 63 74 69  6f 6e 20 6f 66 20 74 68  |a fraction of th|
00001620  65 20 64 69 66 66 65 72  65 6e 63 65 20 62 65 74  |e difference bet|
00001630  77 65 65 6e 20 74 68 65  20 6c 61 73 74 20 70 6c  |ween the last pl|
00001640  6f 74 74 65 64 0d 70 6f  73 69 74 69 6f 6e 20 61  |otted.position a|
00001650  6e 64 20 74 68 65 20 63  75 72 72 65 6e 74 20 70  |nd the current p|
00001660  6f 73 69 74 69 6f 6e 20  6f 66 20 74 68 65 20 70  |osition of the p|
00001670  65 6e 2e 20 54 68 69 73  20 69 73 20 6d 75 63 68  |en. This is much|
00001680  20 6d 6f 72 65 20 73 69  6d 70 6c 65 0d 74 68 61  | more simple.tha|
00001690  6e 20 69 74 20 73 6f 75  6e 64 73 20 61 6e 64 20  |n it sounds and |
000016a0  69 74 20 69 73 20 61 63  68 69 65 76 65 64 20 69  |it is achieved i|
000016b0  6e 20 74 68 65 20 70 72  6f 67 72 61 6d 20 47 52  |n the program GR|
000016c0  41 50 48 49 43 20 69 6e  20 6c 69 6e 65 73 20 32  |APHIC in lines 2|
000016d0  31 30 20 61 6e 64 0d 32  32 30 2e 20 54 68 65 20  |10 and.220. The |
000016e0  42 41 53 49 43 20 76 61  72 69 61 62 6c 65 73 20  |BASIC variables |
000016f0  6f 6c 64 78 20 61 6e 64  20 6f 6c 64 79 20 61 72  |oldx and oldy ar|
00001700  65 20 74 68 65 20 6c 61  73 74 20 70 6f 73 69 74  |e the last posit|
00001710  69 6f 6e 20 70 6c 6f 74  74 65 64 20 61 6e 64 0d  |ion plotted and.|
00001720  74 68 65 20 76 61 72 69  61 62 6c 65 73 20 6e 65  |the variables ne|
00001730  77 78 20 61 6e 64 20 6e  65 78 79 20 61 72 65 20  |wx and nexy are |
00001740  74 68 65 20 6e 65 78 74  20 70 61 69 72 20 6f 66  |the next pair of|
00001750  20 63 6f 6f 72 64 69 6e  61 74 65 73 20 74 6f 20  | coordinates to |
00001760  62 65 0d 70 6c 6f 74 74  65 64 2e 20 54 68 65 20  |be.plotted. The |
00001770  76 61 72 69 61 62 6c 65  73 20 6e 65 77 78 20 61  |variables newx a|
00001780  6e 64 20 6e 65 77 79 20  61 72 65 20 61 6c 77 61  |nd newy are alwa|
00001790  79 73 20 61 70 70 72 6f  61 63 68 69 6e 67 20 78  |ys approaching x|
000017a0  63 6f 6f 72 64 20 61 6e  64 0d 79 63 6f 6f 72 64  |coord and.ycoord|
000017b0  2c 20 74 68 65 20 63 75  72 72 65 6e 74 20 70 6f  |, the current po|
000017c0  73 69 74 69 6f 6e 20 6f  66 20 74 68 65 20 6c 69  |sition of the li|
000017d0  67 68 74 20 70 65 6e 2e  20 54 68 65 20 61 6d 6d  |ght pen. The amm|
000017e0  6f 75 6e 74 20 6f 66 20  6c 61 67 2c 20 61 6e 64  |ount of lag, and|
000017f0  20 74 68 65 0d 72 65 73  75 6c 74 61 6e 74 20 73  | the.resultant s|
00001800  6d 6f 6f 74 68 6e 65 73  73 2c 20 64 65 70 65 6e  |moothness, depen|
00001810  64 73 20 6f 6e 20 74 68  65 20 73 69 7a 65 20 6f  |ds on the size o|
00001820  66 20 74 68 65 20 42 41  53 49 43 20 76 61 72 69  |f the BASIC vari|
00001830  61 62 6c 65 20 64 69 76  69 73 6f 72 0d 28 6c 69  |able divisor.(li|
00001840  6e 65 20 31 30 30 29 2e  20 54 68 65 20 6c 61 72  |ne 100). The lar|
00001850  67 65 72 20 74 68 65 20  76 61 6c 75 65 20 6f 66  |ger the value of|
00001860  20 74 68 65 20 64 69 76  69 73 6f 72 20 28 75 73  | the divisor (us|
00001870  65 64 20 69 6e 20 6c 69  6e 65 73 20 32 31 30 20  |ed in lines 210 |
00001880  61 6e 64 0d 32 32 30 29  20 74 68 65 20 67 72 65  |and.220) the gre|
00001890  61 74 65 72 20 74 68 65  20 6c 61 67 20 61 6e 64  |ater the lag and|
000018a0  20 74 68 65 20 73 6d 6f  6f 74 68 65 72 20 74 68  | the smoother th|
000018b0  65 20 6c 69 6e 65 2e 20  54 68 65 20 64 69 76 69  |e line. The divi|
000018c0  73 6f 72 20 6d 75 73 74  20 62 65 0d 74 68 65 20  |sor must be.the |
000018d0  73 61 6d 65 20 66 6f 72  20 62 6f 74 68 20 58 20  |same for both X |
000018e0  61 6e 64 20 59 20 6f 74  68 65 72 77 69 73 65 20  |and Y otherwise |
000018f0  63 69 72 63 6c 65 73 20  77 69 6c 6c 20 62 65 20  |circles will be |
00001900  64 72 61 77 6e 20 61 73  20 65 6c 69 70 73 65 73  |drawn as elipses|
00001910  2e 0d 0d 43 68 61 69 6e  20 74 68 65 20 70 72 6f  |...Chain the pro|
00001920  67 72 61 6d 20 47 52 41  50 48 49 43 20 77 68 69  |gram GRAPHIC whi|
00001930  63 68 20 77 69 6c 6c 20  61 6c 6c 6f 77 20 79 6f  |ch will allow yo|
00001940  75 20 74 6f 20 64 72 61  77 20 77 69 74 68 20 61  |u to draw with a|
00001950  20 6c 69 67 68 74 20 70  65 6e 20 69 6e 0d 61 6e  | light pen in.an|
00001960  79 20 67 72 61 70 68 69  63 73 20 73 63 72 65 65  |y graphics scree|
00001970  6e 20 6d 6f 64 65 2e 20  54 68 65 20 73 63 72 65  |n mode. The scre|
00001980  65 6e 20 6d 6f 64 65 73  20 63 61 6e 20 62 65 20  |en modes can be |
00001990  73 65 6c 65 63 74 65 64  20 77 69 74 68 20 74 68  |selected with th|
000019a0  65 20 75 70 20 61 6e 64  0d 64 6f 77 6e 20 63 75  |e up and.down cu|
000019b0  72 73 6f 72 20 6b 65 79  73 20 61 6e 64 20 74 68  |rsor keys and th|
000019c0  65 20 6f 66 66 73 65 74  20 63 61 6e 20 62 65 20  |e offset can be |
000019d0  74 72 69 6d 6d 65 64 20  77 69 74 68 20 74 68 65  |trimmed with the|
000019e0  20 6c 65 66 74 20 61 6e  64 20 72 69 67 68 74 0d  | left and right.|
000019f0  63 75 72 73 6f 72 20 6b  65 79 73 2e 20 54 68 65  |cursor keys. The|
00001a00  20 73 69 7a 65 20 6f 66  20 74 68 65 20 64 69 76  | size of the div|
00001a10  69 73 6f 72 20 75 73 65  64 20 74 6f 20 73 6d 6f  |isor used to smo|
00001a20  6f 74 68 20 74 68 65 20  6c 69 6e 65 20 64 72 61  |oth the line dra|
00001a30  77 69 6e 67 20 63 61 6e  0d 62 65 20 61 6c 74 65  |wing can.be alte|
00001a40  72 65 64 20 77 69 74 68  20 48 2c 20 66 6f 72 20  |red with H, for |
00001a50  61 20 68 69 67 68 65 72  20 76 61 6c 75 65 2c 20  |a higher value, |
00001a60  61 6e 64 20 4c 20 66 6f  72 20 61 20 6c 6f 77 65  |and L for a lowe|
00001a70  72 20 76 61 6c 75 65 2e  20 49 74 20 69 73 0d 71  |r value. It is.q|
00001a80  75 69 74 65 20 69 6e 74  65 72 65 73 74 69 6e 67  |uite interesting|
00001a90  20 74 6f 20 65 78 70 65  72 69 6d 65 6e 74 20 77  | to experiment w|
00001aa0  69 74 68 20 64 69 66 66  65 72 65 6e 74 20 64 69  |ith different di|
00001ab0  76 69 73 6f 72 20 76 61  6c 75 65 73 2e 20 59 6f  |visor values. Yo|
00001ac0  75 20 77 69 6c 6c 0d 70  72 6f 62 61 62 6c 79 20  |u will.probably |
00001ad0  66 69 6e 64 20 74 68 61  74 20 61 20 68 69 67 68  |find that a high|
00001ae0  20 76 61 6c 75 65 20 69  73 20 72 65 71 75 69 72  | value is requir|
00001af0  65 64 20 69 6e 20 6d 6f  64 65 73 20 34 20 61 6e  |ed in modes 4 an|
00001b00  64 20 35 20 62 75 74 20  61 20 6c 6f 77 65 72 0d  |d 5 but a lower.|
00001b10  76 61 6c 75 65 20 77 69  6c 6c 20 77 6f 72 6b 20  |value will work |
00001b20  71 75 69 74 65 20 77 65  6c 6c 20 69 6e 20 6d 6f  |quite well in mo|
00001b30  64 65 73 20 30 2c 20 31  20 61 6e 64 20 32 2e 20  |des 0, 1 and 2. |
00001b40  57 68 65 6e 20 64 69 76  69 73 6f 72 20 3d 20 31  |When divisor = 1|
00001b50  20 74 68 69 73 20 69 73  0d 74 68 65 20 73 61 6d  | this is.the sam|
00001b60  65 20 61 73 20 75 73 69  6e 67 20 74 68 65 20 72  |e as using the r|
00001b70  61 77 20 67 72 61 70 68  69 63 73 20 63 6f 6f 72  |aw graphics coor|
00001b80  64 69 6e 61 74 65 73 2e  20 59 6f 75 20 63 61 6e  |dinates. You can|
00001b90  20 73 63 72 6f 6c 6c 20  74 68 65 20 73 63 72 65  | scroll the scre|
00001ba0  65 6e 0d 77 69 74 68 20  74 68 65 20 52 65 74 75  |en.with the Retu|
00001bb0  72 6e 20 6b 65 79 20 61  6e 64 20 63 68 61 6e 67  |rn key and chang|
00001bc0  65 20 74 68 65 20 70 61  70 65 72 20 61 6e 64 20  |e the paper and |
00001bd0  69 6e 6b 20 63 6f 6c 6f  75 72 73 20 77 69 74 68  |ink colours with|
00001be0  20 50 20 61 6e 64 20 49  0d 72 65 73 70 65 63 74  | P and I.respect|
00001bf0  69 76 65 6c 79 2e 20 54  68 65 20 70 72 6f 67 72  |ively. The progr|
00001c00  61 6d 20 69 73 20 6e 6f  74 20 54 75 62 65 20 63  |am is not Tube c|
00001c10  6f 6d 70 61 74 69 62 6c  65 20 62 75 74 20 79 6f  |ompatible but yo|
00001c20  75 20 73 68 6f 75 6c 64  20 62 65 20 61 62 6c 65  |u should be able|
00001c30  20 74 6f 0d 6d 6f 64 69  66 79 20 69 74 20 74 6f  | to.modify it to|
00001c40  20 6d 61 6b 65 20 69 74  20 77 6f 72 6b 20 77 69  | make it work wi|
00001c50  74 68 20 61 20 73 65 63  6f 6e 64 20 70 72 6f 63  |th a second proc|
00001c60  65 73 73 6f 72 2e 0d 0d  54 68 65 20 70 72 6f 67  |essor...The prog|
00001c70  72 61 6d 20 47 52 41 50  48 49 43 20 69 6c 6c 75  |ram GRAPHIC illu|
00001c80  73 74 72 61 74 65 73 20  61 20 70 6f 73 73 69 62  |strates a possib|
00001c90  6c 65 20 73 6f 6c 75 74  69 6f 6e 20 74 6f 20 74  |le solution to t|
00001ca0  68 65 20 70 72 6f 62 6c  65 6d 20 63 61 75 73 65  |he problem cause|
00001cb0  64 0d 62 79 20 74 68 65  20 6f 63 63 61 73 69 6f  |d.by the occasio|
00001cc0  6e 61 6c 20 69 6e 63 6f  72 72 65 63 74 20 69 6e  |nal incorrect in|
00001cd0  74 65 72 70 72 65 74 61  74 69 6f 6e 20 6f 66 20  |terpretation of |
00001ce0  74 68 65 20 63 6f 6f 72  64 69 6e 61 74 65 73 20  |the coordinates |
00001cf0  61 74 20 74 68 65 0d 65  78 74 72 65 6d 65 20 6c  |at the.extreme l|
00001d00  65 66 74 20 61 6e 64 20  72 69 67 68 74 20 65 64  |eft and right ed|
00001d10  67 65 73 20 6f 66 20 74  68 65 20 73 63 72 65 65  |ges of the scree|
00001d20  6e 2e 20 54 68 69 73 20  65 66 66 65 63 74 20 77  |n. This effect w|
00001d30  61 73 20 64 65 6d 6f 6e  73 74 72 61 74 65 64 0d  |as demonstrated.|
00001d40  69 6e 20 6d 6f 64 75 6c  65 20 31 20 62 75 74 20  |in module 1 but |
00001d50  69 66 20 69 74 20 6f 63  63 75 72 73 20 77 68 65  |if it occurs whe|
00001d60  6e 20 64 72 61 77 69 6e  67 20 73 6d 6f 6f 74 68  |n drawing smooth|
00001d70  65 64 20 6c 69 6e 65 73  20 69 74 20 63 61 6e 20  |ed lines it can |
00001d80  6d 61 6b 65 20 74 68 65  0d 64 72 61 77 69 6e 67  |make the.drawing|
00001d90  20 6c 6f 6f 6b 20 61 20  72 65 61 6c 20 6d 65 73  | look a real mes|
00001da0  73 2e 20 54 68 65 20 70  72 6f 62 6c 65 6d 20 69  |s. The problem i|
00001db0  73 20 6e 6f 74 20 63 75  72 65 64 20 69 6e 20 74  |s not cured in t|
00001dc0  68 65 20 64 65 6d 6f 6e  73 74 72 61 74 69 6f 6e  |he demonstration|
00001dd0  0d 70 72 6f 67 72 61 6d  20 62 75 74 20 69 74 20  |.program but it |
00001de0  69 73 20 73 75 70 70 72  65 73 73 65 64 20 62 79  |is suppressed by|
00001df0  20 6e 6f 74 20 70 6c 6f  74 74 69 6e 67 20 61 6e  | not plotting an|
00001e00  79 20 70 6f 69 6e 74 73  20 77 68 65 6e 20 74 68  |y points when th|
00001e10  65 20 70 65 6e 20 69 73  20 61 74 0d 65 69 74 68  |e pen is at.eith|
00001e20  65 72 20 74 68 65 20 65  78 74 72 65 6d 65 20 6c  |er the extreme l|
00001e30  65 66 74 20 65 64 67 65  20 6f 72 20 74 68 65 20  |eft edge or the |
00001e40  65 78 74 72 65 6d 65 20  72 69 67 68 74 20 65 64  |extreme right ed|
00001e50  67 65 20 6f 66 20 74 68  65 20 73 63 72 65 65 6e  |ge of the screen|
00001e60  2e 20 54 68 65 0d 42 41  53 49 43 20 66 75 6e 63  |. The.BASIC func|
00001e70  74 69 6f 6e 20 46 4e 73  77 69 74 63 68 20 28 6c  |tion FNswitch (l|
00001e80  69 6e 65 73 20 32 33 33  30 20 74 6f 20 32 33 35  |ines 2330 to 235|
00001e90  30 29 20 69 73 20 75 73  65 64 20 74 6f 20 6d 61  |0) is used to ma|
00001ea0  6b 65 20 74 68 69 73 0d  73 75 70 70 72 65 73 73  |ke this.suppress|
00001eb0  69 6f 6e 2e 20 54 68 65  20 70 65 6e 20 69 73 20  |ion. The pen is |
00001ec0  6f 6e 6c 79 20 73 65 65  6e 20 61 73 20 73 77 69  |only seen as swi|
00001ed0  74 63 68 65 64 20 6f 6e  20 69 66 20 66 69 72 65  |tched on if fire|
00001ee0  20 62 75 74 74 6f 6e 20  32 20 69 73 20 6f 70 65  | button 2 is ope|
00001ef0  6e 0d 28 79 6f 75 20 6d  69 67 68 74 20 6e 65 65  |n.(you might nee|
00001f00  64 20 74 6f 20 6d 6f 64  69 66 79 20 74 68 69 73  |d to modify this|
00001f10  20 63 6f 6e 64 69 74 69  6f 6e 29 20 61 6e 64 20  | condition) and |
00001f20  69 66 20 74 68 65 20 63  75 72 72 65 6e 74 20 70  |if the current p|
00001f30  65 6e 20 70 6f 73 69 74  6f 6e 0d 69 73 20 6e 6f  |en positon.is no|
00001f40  74 20 61 74 20 65 69 74  68 65 72 20 74 68 65 20  |t at either the |
00001f50  65 78 74 65 6d 65 20 6c  65 66 74 20 6f 72 20 74  |exteme left or t|
00001f60  68 65 20 65 78 74 72 65  6d 65 20 72 69 67 68 74  |he extreme right|
00001f70  20 6f 66 20 74 68 65 20  73 63 72 65 65 6e 2e 20  | of the screen. |
00001f80  49 0d 77 69 6c 6c 20 6e  6f 74 20 63 6c 61 69 6d  |I.will not claim|
00001f90  20 74 68 61 74 20 74 68  65 20 62 65 73 74 20 77  | that the best w|
00001fa0  61 79 20 6f 66 20 63 75  72 69 6e 67 20 61 20 70  |ay of curing a p|
00001fb0  72 6f 62 6c 65 6d 20 69  73 20 74 6f 20 73 75 70  |roblem is to sup|
00001fc0  70 72 65 73 73 20 69 74  20 69 6e 0d 74 68 69 73  |press it in.this|
00001fd0  20 77 61 79 20 62 75 74  20 69 74 20 64 6f 65 73  | way but it does|
00001fe0  20 73 65 65 6d 20 74 6f  20 77 6f 72 6b 20 72 65  | seem to work re|
00001ff0  61 73 6f 6e 61 62 6c 79  20 77 65 6c 6c 20 69 66  |asonably well if|
00002000  20 79 6f 75 20 63 61 6e  20 61 63 63 65 70 74 20  | you can accept |
00002010  61 0d 73 6d 61 6c 6c 20  72 65 64 75 63 74 69 6f  |a.small reductio|
00002020  6e 20 69 6e 20 74 68 65  20 61 76 61 69 6c 61 62  |n in the availab|
00002030  6c 65 20 73 63 72 65 65  6e 20 61 72 65 61 2e 20  |le screen area. |
00002040  49 66 20 79 6f 75 20 72  65 6d 6f 76 65 20 74 68  |If you remove th|
00002050  65 20 74 65 73 74 73 20  6f 6e 0d 74 68 65 20 58  |e tests on.the X|
00002060  20 63 6f 6f 72 64 69 6e  61 74 65 20 66 72 6f 6d  | coordinate from|
00002070  20 46 4e 73 77 69 74 63  68 20 79 6f 75 20 77 69  | FNswitch you wi|
00002080  6c 6c 20 70 72 6f 62 61  62 6c 79 20 73 65 65 20  |ll probably see |
00002090  74 68 65 20 64 72 65 61  64 66 75 6c 20 6d 65 73  |the dreadful mes|
000020a0  73 0d 74 68 69 73 20 61  70 70 61 72 65 6e 74 6c  |s.this apparentl|
000020b0  79 20 74 72 69 76 69 61  6c 20 70 72 6f 62 6c 65  |y trivial proble|
000020c0  6d 20 63 61 6e 20 6d 61  6b 65 20 77 68 65 6e 20  |m can make when |
000020d0  79 6f 75 20 61 72 65 20  64 72 61 77 69 6e 67 20  |you are drawing |
000020e0  61 74 20 74 68 65 20 65  64 67 65 0d 6f 66 20 74  |at the edge.of t|
000020f0  68 65 20 73 63 72 65 65  6e 2e 0d 0d 0d 20 20 20  |he screen....   |
00002100  31 30 20 52 45 4d 3e 20  47 52 41 50 48 49 43 0d  |10 REM> GRAPHIC.|
00002110  20 20 20 32 30 20 4f 4e  20 45 52 52 4f 52 20 56  |   20 ON ERROR V|
00002120  44 55 32 33 2c 31 2c 31  3b 30 3b 30 3b 30 3b 3a  |DU23,1,1;0;0;0;:|
00002130  45 4e 44 0d 20 20 20 33  30 20 41 25 3d 26 45 41  |END.   30 A%=&EA|
00002140  0d 20 20 20 34 30 20 58  25 3d 30 0d 20 20 20 35  |.   40 X%=0.   5|
00002150  30 20 59 25 3d 26 46 46  0d 20 20 20 36 30 20 49  |0 Y%=&FF.   60 I|
00002160  46 20 28 28 55 53 52 28  26 46 46 46 34 29 41 4e  |F ((USR(&FFF4)AN|
00002170  44 26 46 46 30 30 29 44  49 56 26 31 30 30 29 3c  |D&FF00)DIV&100)<|
00002180  3e 30 20 45 4e 44 0d 20  20 20 37 30 20 44 49 4d  |>0 END.   70 DIM|
00002190  20 6d 63 6f 64 65 20 26  31 30 30 0d 20 20 20 38  | mcode &100.   8|
000021a0  30 20 50 52 4f 43 6d 63  6f 64 65 0d 20 20 20 39  |0 PROCmcode.   9|
000021b0  30 20 6d 6f 64 65 3d 32  0d 20 20 31 30 30 20 64  |0 mode=2.  100 d|
000021c0  69 76 69 73 6f 72 3d 34  0d 20 20 31 31 30 20 70  |ivisor=4.  110 p|
000021d0  61 70 65 72 3d 36 0d 20  20 31 32 30 20 69 6e 6b  |aper=6.  120 ink|
000021e0  3d 34 0d 20 20 31 33 30  20 4d 4f 44 45 20 6d 6f  |=4.  130 MODE mo|
000021f0  64 65 0d 20 20 31 34 30  20 50 52 4f 43 6e 65 77  |de.  140 PROCnew|
00002200  6d 6f 64 65 0d 20 20 31  35 30 20 52 45 50 45 41  |mode.  150 REPEA|
00002210  54 0d 20 20 31 36 30 20  52 45 50 45 41 54 0d 20  |T.  160 REPEAT. |
00002220  20 31 37 30 20 6f 6c 64  78 3d 6e 65 77 78 0d 20  | 170 oldx=newx. |
00002230  20 31 38 30 20 6f 6c 64  79 3d 6e 65 77 79 0d 20  | 180 oldy=newy. |
00002240  20 31 39 30 20 43 41 4c  4c 20 6d 63 6f 64 65 0d  | 190 CALL mcode.|
00002250  20 20 32 30 30 20 50 52  49 4e 54 54 41 42 28 31  |  200 PRINTTAB(1|
00002260  31 2c 31 29 3b 21 78 63  6f 6f 72 64 3b 22 20 20  |1,1);!xcoord;"  |
00002270  20 22 54 41 42 28 31 31  2c 32 29 3b 21 79 63 6f  | "TAB(11,2);!yco|
00002280  6f 72 64 3b 22 20 20 20  22 0d 20 20 32 31 30 20  |ord;"   ".  210 |
00002290  6e 65 77 78 3d 6e 65 77  78 2b 28 28 21 78 63 6f  |newx=newx+((!xco|
000022a0  6f 72 64 2d 6e 65 77 78  29 44 49 56 20 64 69 76  |ord-newx)DIV div|
000022b0  69 73 6f 72 29 0d 20 20  32 32 30 20 6e 65 77 79  |isor).  220 newy|
000022c0  3d 6e 65 77 79 2b 28 28  21 79 63 6f 6f 72 64 2d  |=newy+((!ycoord-|
000022d0  6e 65 77 79 29 44 49 56  20 64 69 76 69 73 6f 72  |newy)DIV divisor|
000022e0  29 0d 20 20 32 33 30 20  49 46 20 46 4e 73 77 69  |).  230 IF FNswi|
000022f0  74 63 68 20 50 4c 4f 54  36 39 2c 6f 6c 64 78 2c  |tch PLOT69,oldx,|
00002300  6f 6c 64 79 3a 50 4c 4f  54 36 39 2c 6e 65 77 78  |oldy:PLOT69,newx|
00002310  2c 6e 65 77 79 0d 20 20  20 20 20 20 45 4c 53 45  |,newy.      ELSE|
00002320  20 50 4c 4f 54 31 33 2c  6e 65 77 78 2c 6e 65 77  | PLOT13,newx,new|
00002330  79 0d 20 20 32 34 30 20  55 4e 54 49 4c 20 46 4e  |y.  240 UNTIL FN|
00002340  73 77 69 74 63 68 0d 20  20 32 35 30 20 49 46 20  |switch.  250 IF |
00002350  49 4e 4b 45 59 28 2d 35  38 29 20 50 52 4f 43 75  |INKEY(-58) PROCu|
00002360  70 3a 4d 4f 44 45 20 6d  6f 64 65 3a 50 52 4f 43  |p:MODE mode:PROC|
00002370  6e 65 77 6d 6f 64 65 0d  20 20 32 36 30 20 49 46  |newmode.  260 IF|
00002380  20 49 4e 4b 45 59 28 2d  34 32 29 20 50 52 4f 43  | INKEY(-42) PROC|
00002390  64 6f 77 6e 3a 4d 4f 44  45 20 6d 6f 64 65 3a 50  |down:MODE mode:P|
000023a0  52 4f 43 6e 65 77 6d 6f  64 65 0d 20 20 32 37 30  |ROCnewmode.  270|
000023b0  20 49 46 20 49 4e 4b 45  59 28 2d 38 35 29 20 50  | IF INKEY(-85) P|
000023c0  52 4f 43 68 69 67 68 0d  20 20 32 38 30 20 49 46  |ROChigh.  280 IF|
000023d0  20 49 4e 4b 45 59 28 2d  38 37 29 20 50 52 4f 43  | INKEY(-87) PROC|
000023e0  6c 6f 77 0d 20 20 32 39  30 20 49 46 20 49 4e 4b  |low.  290 IF INK|
000023f0  45 59 28 2d 35 36 29 20  50 52 4f 43 70 61 70 65  |EY(-56) PROCpape|
00002400  72 0d 20 20 33 30 30 20  49 46 20 49 4e 4b 45 59  |r.  300 IF INKEY|
00002410  28 2d 33 38 29 20 50 52  4f 43 69 6e 6b 0d 20 20  |(-38) PROCink.  |
00002420  33 31 30 20 49 46 20 49  4e 4b 45 59 28 2d 32 36  |310 IF INKEY(-26|
00002430  29 20 50 52 4f 43 6c 65  66 74 0d 20 20 33 32 30  |) PROCleft.  320|
00002440  20 49 46 20 49 4e 4b 45  59 28 2d 31 32 32 29 20  | IF INKEY(-122) |
00002450  50 52 4f 43 72 69 67 68  74 0d 20 20 33 33 30 20  |PROCright.  330 |
00002460  49 46 20 49 4e 4b 45 59  28 2d 37 34 29 20 50 52  |IF INKEY(-74) PR|
00002470  4f 43 73 63 72 6f 6c 6c  0d 20 20 33 34 30 20 55  |OCscroll.  340 U|
00002480  4e 54 49 4c 20 46 41 4c  53 45 0d 20 20 33 35 30  |NTIL FALSE.  350|
00002490  20 3a 0d 20 20 33 36 30  20 44 45 46 50 52 4f 43  | :.  360 DEFPROC|
000024a0  73 63 72 6f 6c 6c 0d 20  20 33 37 30 20 50 52 49  |scroll.  370 PRI|
000024b0  4e 54 54 41 42 28 30 2c  33 31 29 0d 20 20 33 38  |NTTAB(0,31).  38|
000024c0  30 20 50 52 4f 43 64 65  6c 61 79 0d 20 20 33 39  |0 PROCdelay.  39|
000024d0  30 20 45 4e 44 50 52 4f  43 0d 20 20 34 30 30 20  |0 ENDPROC.  400 |
000024e0  3a 0d 20 20 34 31 30 20  44 45 46 50 52 4f 43 75  |:.  410 DEFPROCu|
000024f0  70 0d 20 20 34 32 30 20  6d 6f 64 65 3d 6d 6f 64  |p.  420 mode=mod|
00002500  65 2b 31 0d 20 20 34 33  30 20 49 46 20 6d 6f 64  |e+1.  430 IF mod|
00002510  65 3d 33 20 6d 6f 64 65  3d 34 0d 20 20 34 34 30  |e=3 mode=4.  440|
00002520  20 49 46 20 6d 6f 64 65  3e 35 20 6d 6f 64 65 3d  | IF mode>5 mode=|
00002530  35 0d 20 20 34 35 30 20  45 4e 44 50 52 4f 43 0d  |5.  450 ENDPROC.|
00002540  20 20 34 36 30 20 3a 0d  20 20 34 37 30 20 44 45  |  460 :.  470 DE|
00002550  46 50 52 4f 43 64 6f 77  6e 0d 20 20 34 38 30 20  |FPROCdown.  480 |
00002560  6d 6f 64 65 3d 6d 6f 64  65 2d 31 0d 20 20 34 39  |mode=mode-1.  49|
00002570  30 20 49 46 20 6d 6f 64  65 3d 33 20 6d 6f 64 65  |0 IF mode=3 mode|
00002580  3d 32 0d 20 20 35 30 30  20 49 46 20 6d 6f 64 65  |=2.  500 IF mode|
00002590  3c 30 20 6d 6f 64 65 3d  30 0d 20 20 35 31 30 20  |<0 mode=0.  510 |
000025a0  45 4e 44 50 52 4f 43 0d  20 20 35 32 30 20 3a 0d  |ENDPROC.  520 :.|
000025b0  20 20 35 33 30 20 44 45  46 50 52 4f 43 6c 65 66  |  530 DEFPROClef|
000025c0  74 0d 20 20 35 34 30 20  49 46 20 6f 66 66 73 65  |t.  540 IF offse|
000025d0  74 6c 6f 77 3f 6d 6f 64  65 3d 31 32 20 45 4e 44  |tlow?mode=12 END|
000025e0  50 52 4f 43 0d 20 20 35  35 30 20 6f 66 66 73 65  |PROC.  550 offse|
000025f0  74 6c 6f 77 3f 6d 6f 64  65 3d 6f 66 66 73 65 74  |tlow?mode=offset|
00002600  6c 6f 77 3f 6d 6f 64 65  2b 31 0d 20 20 35 36 30  |low?mode+1.  560|
00002610  20 50 52 4f 43 64 65 6c  61 79 0d 20 20 35 37 30  | PROCdelay.  570|
00002620  20 45 4e 44 50 52 4f 43  0d 20 20 35 38 30 20 3a  | ENDPROC.  580 :|
00002630  0d 20 20 35 39 30 20 44  45 46 50 52 4f 43 72 69  |.  590 DEFPROCri|
00002640  67 68 74 0d 20 20 36 30  30 20 49 46 20 6f 66 66  |ght.  600 IF off|
00002650  73 65 74 6c 6f 77 3f 6d  6f 64 65 3d 30 20 45 4e  |setlow?mode=0 EN|
00002660  44 50 52 4f 43 0d 20 20  36 31 30 20 6f 66 66 73  |DPROC.  610 offs|
00002670  65 74 6c 6f 77 3f 6d 6f  64 65 3d 6f 66 66 73 65  |etlow?mode=offse|
00002680  74 6c 6f 77 3f 6d 6f 64  65 2d 31 0d 20 20 36 32  |tlow?mode-1.  62|
00002690  30 20 50 52 4f 43 64 65  6c 61 79 0d 20 20 36 33  |0 PROCdelay.  63|
000026a0  30 20 45 4e 44 50 52 4f  43 0d 20 20 36 34 30 20  |0 ENDPROC.  640 |
000026b0  3a 0d 20 20 36 35 30 20  44 45 46 50 52 4f 43 6e  |:.  650 DEFPROCn|
000026c0  65 77 6d 6f 64 65 0d 20  20 36 36 30 20 56 44 55  |ewmode.  660 VDU|
000026d0  32 33 2c 31 2c 30 3b 30  3b 30 3b 30 3b 0d 20 20  |23,1,0;0;0;0;.  |
000026e0  36 37 30 20 56 44 55 31  39 2c 30 2c 70 61 70 65  |670 VDU19,0,pape|
000026f0  72 3b 30 3b 0d 20 20 36  38 30 20 56 44 55 31 39  |r;0;.  680 VDU19|
00002700  2c 31 2c 69 6e 6b 3b 30  3b 0d 20 20 36 39 30 20  |,1,ink;0;.  690 |
00002710  47 43 4f 4c 33 2c 31 0d  20 20 37 30 30 20 43 4f  |GCOL3,1.  700 CO|
00002720  4c 4f 55 52 31 0d 20 20  37 31 30 20 6e 65 77 78  |LOUR1.  710 newx|
00002730  3d 2d 31 0d 20 20 37 32  30 20 6e 65 77 79 3d 2d  |=-1.  720 newy=-|
00002740  31 0d 20 20 37 33 30 20  6f 6c 64 78 3d 2d 31 0d  |1.  730 oldx=-1.|
00002750  20 20 37 34 30 20 6f 6c  64 79 3d 2d 31 0d 20 20  |  740 oldy=-1.  |
00002760  37 35 30 20 50 52 4f 43  64 65 6c 61 79 0d 20 20  |750 PROCdelay.  |
00002770  37 36 30 20 45 4e 44 50  52 4f 43 0d 20 20 37 37  |760 ENDPROC.  77|
00002780  30 20 3a 0d 20 20 37 38  30 20 44 45 46 50 52 4f  |0 :.  780 DEFPRO|
00002790  43 6c 6f 77 0d 20 20 37  39 30 20 49 46 20 64 69  |Clow.  790 IF di|
000027a0  76 69 73 6f 72 3e 31 20  64 69 76 69 73 6f 72 3d  |visor>1 divisor=|
000027b0  64 69 76 69 73 6f 72 20  44 49 56 20 32 0d 20 20  |divisor DIV 2.  |
000027c0  38 30 30 20 50 52 4f 43  64 65 6c 61 79 0d 20 20  |800 PROCdelay.  |
000027d0  38 31 30 20 45 4e 44 50  52 4f 43 0d 20 20 38 32  |810 ENDPROC.  82|
000027e0  30 20 3a 0d 20 20 38 33  30 20 44 45 46 50 52 4f  |0 :.  830 DEFPRO|
000027f0  43 68 69 67 68 0d 20 20  38 34 30 20 49 46 20 64  |Chigh.  840 IF d|
00002800  69 76 69 73 6f 72 3c 38  20 64 69 76 69 73 6f 72  |ivisor<8 divisor|
00002810  3d 64 69 76 69 73 6f 72  2a 32 0d 20 20 38 35 30  |=divisor*2.  850|
00002820  20 50 52 4f 43 64 65 6c  61 79 0d 20 20 38 36 30  | PROCdelay.  860|
00002830  20 45 4e 44 50 52 4f 43  0d 20 20 38 37 30 20 3a  | ENDPROC.  870 :|
00002840  0d 20 20 38 38 30 20 44  45 46 50 52 4f 43 64 65  |.  880 DEFPROCde|
00002850  6c 61 79 0d 20 20 38 39  30 20 50 52 49 4e 54 54  |lay.  890 PRINTT|
00002860  41 42 28 31 2c 30 29 22  4d 6f 64 65 20 22 3b 6d  |AB(1,0)"Mode ";m|
00002870  6f 64 65 3b 53 50 43 28  38 29 0d 20 20 39 30 30  |ode;SPC(8).  900|
00002880  20 50 52 49 4e 54 54 41  42 28 31 2c 31 29 22 58  | PRINTTAB(1,1)"X|
00002890  20 63 6f 6f 72 64 20 3d  20 22 0d 20 20 39 31 30  | coord = ".  910|
000028a0  20 50 52 49 4e 54 54 41  42 28 31 2c 32 29 22 59  | PRINTTAB(1,2)"Y|
000028b0  20 63 6f 6f 72 64 20 3d  20 22 0d 20 20 39 32 30  | coord = ".  920|
000028c0  20 50 52 49 4e 54 54 41  42 28 31 2c 33 29 22 64  | PRINTTAB(1,3)"d|
000028d0  69 76 69 73 6f 72 20 3d  20 22 3b 64 69 76 69 73  |ivisor = ";divis|
000028e0  6f 72 3b 22 20 20 22 0d  20 20 39 33 30 20 50 52  |or;"  ".  930 PR|
000028f0  49 4e 54 54 41 42 28 31  2c 34 29 22 6f 66 66 73  |INTTAB(1,4)"offs|
00002900  65 74 6c 6f 77 20 3d 20  22 3b 6f 66 66 73 65 74  |etlow = ";offset|
00002910  6c 6f 77 3f 6d 6f 64 65  0d 20 20 39 34 30 20 74  |low?mode.  940 t|
00002920  69 6d 65 3d 54 49 4d 45  2b 32 30 0d 20 20 39 35  |ime=TIME+20.  95|
00002930  30 20 52 45 50 45 41 54  20 55 4e 54 49 4c 20 74  |0 REPEAT UNTIL t|
00002940  69 6d 65 3c 54 49 4d 45  0d 20 20 39 36 30 20 45  |ime<TIME.  960 E|
00002950  4e 44 50 52 4f 43 0d 20  20 39 37 30 20 3a 0d 20  |NDPROC.  970 :. |
00002960  20 39 38 30 20 44 45 46  50 52 4f 43 69 6e 6b 0d  | 980 DEFPROCink.|
00002970  20 20 39 39 30 20 69 6e  6b 3d 69 6e 6b 2b 31 0d  |  990 ink=ink+1.|
00002980  20 31 30 30 30 20 49 46  20 69 6e 6b 3d 70 61 70  | 1000 IF ink=pap|
00002990  65 72 20 69 6e 6b 3d 69  6e 6b 2b 31 0d 20 31 30  |er ink=ink+1. 10|
000029a0  31 30 20 49 46 20 69 6e  6b 3e 37 20 69 6e 6b 3d  |10 IF ink>7 ink=|
000029b0  30 0d 20 31 30 32 30 20  56 44 55 31 39 2c 31 2c  |0. 1020 VDU19,1,|
000029c0  69 6e 6b 3b 30 3b 0d 20  31 30 33 30 20 50 52 4f  |ink;0;. 1030 PRO|
000029d0  43 64 65 6c 61 79 0d 20  31 30 34 30 20 45 4e 44  |Cdelay. 1040 END|
000029e0  50 52 4f 43 0d 20 31 30  35 30 20 3a 0d 20 31 30  |PROC. 1050 :. 10|
000029f0  36 30 20 44 45 46 50 52  4f 43 70 61 70 65 72 0d  |60 DEFPROCpaper.|
00002a00  20 31 30 37 30 20 70 61  70 65 72 3d 70 61 70 65  | 1070 paper=pape|
00002a10  72 2b 31 0d 20 31 30 38  30 20 49 46 20 70 61 70  |r+1. 1080 IF pap|
00002a20  65 72 3d 69 6e 6b 20 70  61 70 65 72 3d 70 61 70  |er=ink paper=pap|
00002a30  65 72 2b 31 0d 20 31 30  39 30 20 49 46 20 70 61  |er+1. 1090 IF pa|
00002a40  70 65 72 3e 37 20 70 61  70 65 72 3d 30 0d 20 31  |per>7 paper=0. 1|
00002a50  31 30 30 20 56 44 55 31  39 2c 30 2c 70 61 70 65  |100 VDU19,0,pape|
00002a60  72 3b 30 3b 0d 20 31 31  31 30 20 50 52 4f 43 64  |r;0;. 1110 PROCd|
00002a70  65 6c 61 79 0d 20 31 31  32 30 20 45 4e 44 50 52  |elay. 1120 ENDPR|
00002a80  4f 43 0d 20 31 31 33 30  20 3a 0d 20 31 31 34 30  |OC. 1130 :. 1140|
00002a90  20 44 45 46 50 52 4f 43  6d 63 6f 64 65 0d 20 31  | DEFPROCmcode. 1|
00002aa0  31 35 30 20 78 63 6f 6f  72 64 3d 26 37 30 20 3a  |150 xcoord=&70 :|
00002ab0  52 45 4d 3a 20 26 37 30  2d 26 37 33 0d 20 31 31  |REM: &70-&73. 11|
00002ac0  36 30 20 79 63 6f 6f 72  64 3d 26 37 34 20 3a 52  |60 ycoord=&74 :R|
00002ad0  45 4d 3a 20 26 37 34 2d  26 37 37 0d 20 31 31 37  |EM: &74-&77. 117|
00002ae0  30 20 73 74 61 72 74 3d  26 33 35 30 20 3a 52 45  |0 start=&350 :RE|
00002af0  4d 3a 20 73 63 72 65 65  6e 20 73 74 61 72 74 20  |M: screen start |
00002b00  61 64 64 72 65 73 73 0d  20 31 31 38 30 20 73 63  |address. 1180 sc|
00002b10  72 65 65 6e 3d 26 33 35  35 20 3a 52 45 4d 3a 20  |reen=&355 :REM: |
00002b20  73 63 72 65 65 6e 20 6d  6f 64 65 0d 20 31 31 39  |screen mode. 119|
00002b30  30 20 73 68 65 69 6c 61  3d 26 46 45 30 30 0d 20  |0 sheila=&FE00. |
00002b40  31 32 30 30 20 46 4f 52  20 70 61 73 73 3d 30 20  |1200 FOR pass=0 |
00002b50  54 4f 20 32 20 53 54 45  50 20 32 0d 20 31 32 31  |TO 2 STEP 2. 121|
00002b60  30 20 50 25 3d 6d 63 6f  64 65 0d 20 31 32 32 30  |0 P%=mcode. 1220|
00002b70  20 5b 20 20 20 20 20 20  20 4f 50 54 20 70 61 73  | [       OPT pas|
00002b80  73 0d 20 31 32 33 30 20  20 20 20 20 20 20 20 20  |s. 1230         |
00002b90  4c 44 41 20 23 26 30 30  0d 20 31 32 34 30 20 20  |LDA #&00. 1240  |
00002ba0  20 20 20 20 20 20 20 4c  44 58 20 23 26 30 37 0d  |       LDX #&07.|
00002bb0  20 31 32 35 30 20 2e 69  6e 69 74 6c 6f 6f 70 0d  | 1250 .initloop.|
00002bc0  20 31 32 36 30 20 20 20  20 20 20 20 20 20 53 54  | 1260         ST|
00002bd0  41 20 78 63 6f 6f 72 64  2c 58 20 20 5c 20 26 37  |A xcoord,X  \ &7|
00002be0  30 2d 26 37 37 20 3d 20  23 26 30 30 0d 20 31 32  |0-&77 = #&00. 12|
00002bf0  37 30 20 20 20 20 20 20  20 20 20 44 45 58 0d 20  |70         DEX. |
00002c00  31 32 38 30 20 20 20 20  20 20 20 20 20 42 50 4c  |1280         BPL|
00002c10  20 69 6e 69 74 6c 6f 6f  70 0d 20 31 32 39 30 20  | initloop. 1290 |
00002c20  20 20 20 20 20 20 20 20  4c 44 59 20 73 63 72 65  |        LDY scre|
00002c30  65 6e 20 20 20 20 5c 20  73 63 72 65 65 6e 20 6d  |en    \ screen m|
00002c40  6f 64 65 20 69 6e 74 6f  20 59 20 72 65 67 69 73  |ode into Y regis|
00002c50  74 65 72 0d 20 31 33 30  30 20 20 20 20 20 20 20  |ter. 1300       |
00002c60  20 20 43 50 59 20 23 26  30 36 20 20 20 20 20 20  |  CPY #&06      |
00002c70  5c 20 69 73 20 74 68 69  73 20 6d 6f 64 65 20 36  |\ is this mode 6|
00002c80  20 6f 72 20 37 3f 0d 20  31 33 31 30 20 20 20 20  | or 7?. 1310    |
00002c90  20 20 20 20 20 42 43 53  20 72 65 74 75 72 6e 20  |     BCS return |
00002ca0  20 20 20 5c 20 65 78 69  74 20 69 66 20 6e 6f 6e  |   \ exit if non|
00002cb0  2d 67 72 61 70 68 69 63  73 20 6d 6f 64 65 0d 20  |-graphics mode. |
00002cc0  31 33 32 30 20 20 20 20  20 20 20 20 20 43 50 59  |1320         CPY|
00002cd0  20 23 26 30 33 20 20 20  20 20 20 5c 20 69 73 20  | #&03      \ is |
00002ce0  74 68 69 73 20 6d 6f 64  65 20 33 3f 0d 20 31 33  |this mode 3?. 13|
00002cf0  33 30 20 20 20 20 20 20  20 20 20 42 4e 45 20 63  |30         BNE c|
00002d00  61 72 72 79 6f 6e 20 20  20 5c 20 65 78 69 74 20  |arryon   \ exit |
00002d10  69 66 20 6e 6f 6e 2d 67  72 61 70 68 69 63 73 20  |if non-graphics |
00002d20  6d 6f 64 65 0d 20 31 33  34 30 20 2e 72 65 74 75  |mode. 1340 .retu|
00002d30  72 6e 0d 20 31 33 35 30  20 20 20 20 20 20 20 20  |rn. 1350        |
00002d40  20 52 54 53 20 20 20 20  20 20 20 20 20 20 20 5c  | RTS           \|
00002d50  20 72 65 74 75 72 6e 20  74 6f 20 42 41 53 49 43  | return to BASIC|
00002d60  20 69 66 20 6e 6f 6e 2d  67 72 61 70 68 69 63 73  | if non-graphics|
00002d70  20 6d 6f 64 65 0d 20 31  33 36 30 20 2e 63 61 72  | mode. 1360 .car|
00002d80  72 79 6f 6e 0d 20 31 33  37 30 20 20 20 20 20 20  |ryon. 1370      |
00002d90  20 20 20 4c 44 41 20 73  74 61 72 74 20 20 20 20  |   LDA start    |
00002da0  20 5c 20 73 63 72 65 65  6e 20 73 74 61 72 74 20  | \ screen start |
00002db0  61 64 64 72 65 73 73 2c  20 6c 6f 77 20 62 79 74  |address, low byt|
00002dc0  65 0d 20 31 33 38 30 20  20 20 20 20 20 20 20 20  |e. 1380         |
00002dd0  53 54 41 20 79 63 6f 6f  72 64 0d 20 31 33 39 30  |STA ycoord. 1390|
00002de0  20 20 20 20 20 20 20 20  20 4c 44 41 20 73 74 61  |         LDA sta|
00002df0  72 74 2b 31 20 20 20 5c  20 73 63 72 65 65 6e 20  |rt+1   \ screen |
00002e00  73 74 61 72 74 20 61 64  64 72 65 73 73 2c 20 68  |start address, h|
00002e10  69 67 68 20 62 79 74 65  0d 20 31 34 30 30 20 20  |igh byte. 1400  |
00002e20  20 20 20 20 20 20 20 53  54 41 20 79 63 6f 6f 72  |       STA ycoor|
00002e30  64 2b 31 0d 20 31 34 31  30 20 20 20 20 20 20 20  |d+1. 1410       |
00002e40  20 20 4c 53 52 20 79 63  6f 6f 72 64 2b 31 0d 20  |  LSR ycoord+1. |
00002e50  31 34 32 30 20 20 20 20  20 20 20 20 20 52 4f 52  |1420         ROR|
00002e60  20 79 63 6f 6f 72 64 20  20 20 20 5c 20 73 74 61  | ycoord    \ sta|
00002e70  72 74 20 61 64 64 72 65  73 73 20 44 49 56 20 32  |rt address DIV 2|
00002e80  0d 20 31 34 33 30 20 20  20 20 20 20 20 20 20 4c  |. 1430         L|
00002e90  53 52 20 79 63 6f 6f 72  64 2b 31 0d 20 31 34 34  |SR ycoord+1. 144|
00002ea0  30 20 20 20 20 20 20 20  20 20 52 4f 52 20 79 63  |0         ROR yc|
00002eb0  6f 6f 72 64 20 20 20 20  5c 20 73 74 61 72 74 20  |oord    \ start |
00002ec0  61 64 64 72 65 73 73 20  44 49 56 20 34 0d 20 31  |address DIV 4. 1|
00002ed0  34 35 30 20 20 20 20 20  20 20 20 20 4c 53 52 20  |450         LSR |
00002ee0  79 63 6f 6f 72 64 2b 31  0d 20 31 34 36 30 20 20  |ycoord+1. 1460  |
00002ef0  20 20 20 20 20 20 20 52  4f 52 20 79 63 6f 6f 72  |       ROR ycoor|
00002f00  64 20 20 20 20 5c 20 73  74 61 72 74 20 61 64 64  |d    \ start add|
00002f10  72 65 73 73 20 44 49 56  20 38 0d 20 31 34 37 30  |ress DIV 8. 1470|
00002f20  20 20 20 20 20 20 20 20  20 4c 44 41 20 6f 66 66  |         LDA off|
00002f30  73 65 74 6c 6f 77 2c 59  20 5c 20 74 72 69 6d 20  |setlow,Y \ trim |
00002f40  74 68 65 20 6f 66 66 73  65 74 0d 20 31 34 38 30  |the offset. 1480|
00002f50  20 20 20 20 20 20 20 20  20 43 4c 44 20 20 20 20  |         CLD    |
00002f60  20 20 20 20 20 20 20 5c  20 63 6c 65 61 72 20 64  |       \ clear d|
00002f70  65 63 69 6d 61 6c 20 66  6c 61 67 0d 20 31 34 39  |ecimal flag. 149|
00002f80  30 20 20 20 20 20 20 20  20 20 43 4c 43 20 20 20  |0         CLC   |
00002f90  20 20 20 20 20 20 20 20  5c 20 70 72 65 70 61 72  |        \ prepar|
00002fa0  65 20 66 6f 72 20 61 64  64 69 74 69 6f 6e 0d 20  |e for addition. |
00002fb0  31 35 30 30 20 20 20 20  20 20 20 20 20 41 44 43  |1500         ADC|
00002fc0  20 79 63 6f 6f 72 64 20  20 20 20 5c 20 61 64 64  | ycoord    \ add|
00002fd0  20 74 72 69 6d 20 74 6f  20 6f 66 66 73 65 74 0d  | trim to offset.|
00002fe0  20 31 35 31 30 20 20 20  20 20 20 20 20 20 53 54  | 1510         ST|
00002ff0  41 20 79 63 6f 6f 72 64  0d 20 31 35 32 30 20 20  |A ycoord. 1520  |
00003000  20 20 20 20 20 20 20 4c  44 41 20 23 26 30 30 0d  |       LDA #&00.|
00003010  20 31 35 33 30 20 20 20  20 20 20 20 20 20 41 44  | 1530         AD|
00003020  43 20 79 63 6f 6f 72 64  2b 31 0d 20 31 35 34 30  |C ycoord+1. 1540|
00003030  20 20 20 20 20 20 20 20  20 53 54 41 20 79 63 6f  |         STA yco|
00003040  6f 72 64 2b 31 0d 20 31  35 35 30 20 20 20 20 20  |ord+1. 1550     |
00003050  20 20 20 20 53 45 43 20  20 20 20 20 20 20 20 20  |    SEC         |
00003060  20 20 5c 20 70 72 65 70  61 72 65 20 74 6f 20 73  |  \ prepare to s|
00003070  75 62 74 72 61 63 74 20  6f 66 66 73 65 74 20 66  |ubtract offset f|
00003080  72 6f 6d 20 6c 69 67 68  74 20 70 65 6e 0d 20 20  |rom light pen.  |
00003090  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000030a0  20 20 20 20 20 20 20 20  20 20 5c 20 72 65 67 69  |          \ regi|
000030b0  73 74 65 72 0d 20 31 35  36 30 20 20 20 20 20 20  |ster. 1560      |
000030c0  20 20 20 4c 44 58 20 23  26 31 31 20 20 20 20 20  |   LDX #&11     |
000030d0  20 5c 20 6c 69 67 68 74  20 70 65 6e 20 72 65 67  | \ light pen reg|
000030e0  69 73 74 65 72 2c 20 6c  6f 77 20 62 79 74 65 0d  |ister, low byte.|
000030f0  20 31 35 37 30 20 20 20  20 20 20 20 20 20 53 54  | 1570         ST|
00003100  58 20 73 68 65 69 6c 61  20 20 20 20 5c 20 36 38  |X sheila    \ 68|
00003110  34 35 20 61 64 64 72 65  73 73 20 72 65 67 69 73  |45 address regis|
00003120  74 65 72 0d 20 31 35 38  30 20 20 20 20 20 20 20  |ter. 1580       |
00003130  20 20 4c 44 41 20 73 68  65 69 6c 61 2b 31 20 20  |  LDA sheila+1  |
00003140  5c 20 36 38 34 35 20 64  61 74 61 20 72 65 67 69  |\ 6845 data regi|
00003150  73 74 65 72 0d 20 31 35  39 30 20 20 20 20 20 20  |ster. 1590      |
00003160  20 20 20 53 42 43 20 79  63 6f 6f 72 64 20 20 20  |   SBC ycoord   |
00003170  20 5c 20 73 75 62 74 72  61 63 74 20 6f 66 66 73  | \ subtract offs|
00003180  65 74 2c 20 6c 6f 77 20  62 79 74 65 0d 20 31 36  |et, low byte. 16|
00003190  30 30 20 20 20 20 20 20  20 20 20 53 54 41 20 79  |00         STA y|
000031a0  63 6f 6f 72 64 20 20 20  20 5c 20 6c 6f 77 20 62  |coord    \ low b|
000031b0  79 74 65 20 2d 20 6f 66  66 73 65 74 0d 20 31 36  |yte - offset. 16|
000031c0  31 30 20 20 20 20 20 20  20 20 20 44 45 58 20 20  |10         DEX  |
000031d0  20 20 20 20 20 20 20 20  20 5c 20 58 20 3d 20 23  |         \ X = #|
000031e0  26 31 30 0d 20 31 36 32  30 20 20 20 20 20 20 20  |&10. 1620       |
000031f0  20 20 53 54 58 20 73 68  65 69 6c 61 20 20 20 20  |  STX sheila    |
00003200  5c 20 36 38 34 35 20 61  64 64 72 65 73 73 20 72  |\ 6845 address r|
00003210  65 67 69 73 74 65 72 0d  20 31 36 33 30 20 20 20  |egister. 1630   |
00003220  20 20 20 20 20 20 4c 44  41 20 73 68 65 69 6c 61  |      LDA sheila|
00003230  2b 31 20 20 5c 20 36 38  34 35 20 64 61 74 61 20  |+1  \ 6845 data |
00003240  72 65 67 69 73 74 65 72  0d 20 31 36 34 30 20 20  |register. 1640  |
00003250  20 20 20 20 20 20 20 53  42 43 20 79 63 6f 6f 72  |       SBC ycoor|
00003260  64 2b 31 20 20 5c 20 73  75 62 74 72 61 63 74 20  |d+1  \ subtract |
00003270  6f 66 66 73 65 74 2c 20  68 69 67 68 20 62 79 74  |offset, high byt|
00003280  65 0d 20 31 36 35 30 20  20 20 20 20 20 20 20 20  |e. 1650         |
00003290  53 54 41 20 79 63 6f 6f  72 64 2b 31 20 20 5c 20  |STA ycoord+1  \ |
000032a0  68 69 67 68 20 62 79 74  65 20 2d 20 6f 66 66 73  |high byte - offs|
000032b0  65 74 0d 20 31 36 36 30  20 2e 6e 65 78 74 0d 20  |et. 1660 .next. |
000032c0  31 36 37 30 20 20 20 20  20 20 20 20 20 41 53 4c  |1670         ASL|
000032d0  20 79 63 6f 6f 72 64 20  20 20 20 5c 20 73 68 69  | ycoord    \ shi|
000032e0  66 74 20 64 69 76 69 64  65 6e 64 2f 71 75 6f 74  |ft dividend/quot|
000032f0  69 65 6e 74 20 6c 65 66  74 0d 20 31 36 38 30 20  |ient left. 1680 |
00003300  20 20 20 20 20 20 20 20  52 4f 4c 20 79 63 6f 6f  |        ROL ycoo|
00003310  72 64 2b 31 20 20 5c 20  73 68 69 66 74 20 64 69  |rd+1  \ shift di|
00003320  76 69 64 65 6e 64 2f 71  75 6f 74 69 65 6e 74 20  |vidend/quotient |
00003330  6c 65 66 74 0d 20 31 36  39 30 20 20 20 20 20 20  |left. 1690      |
00003340  20 20 20 52 4f 4c 20 78  63 6f 6f 72 64 20 20 20  |   ROL xcoord   |
00003350  20 5c 20 73 68 69 66 74  20 62 69 74 73 20 69 6e  | \ shift bits in|
00003360  74 6f 20 70 61 72 74 69  61 6c 20 64 69 76 69 64  |to partial divid|
00003370  65 6e 64 0d 20 31 37 30  30 20 20 20 20 20 20 20  |end. 1700       |
00003380  20 20 4c 44 41 20 78 63  6f 6f 72 64 20 20 20 20  |  LDA xcoord    |
00003390  5c 20 6c 6f 61 64 20 70  61 72 74 69 61 6c 20 64  |\ load partial d|
000033a0  69 76 69 64 65 6e 64 0d  20 31 37 31 30 20 20 20  |ividend. 1710   |
000033b0  20 20 20 20 20 20 53 45  43 20 20 20 20 20 20 20  |      SEC       |
000033c0  20 20 20 20 5c 20 70 72  65 70 61 72 65 20 66 6f  |    \ prepare fo|
000033d0  72 20 73 75 62 74 72 61  63 74 69 6f 6e 0d 20 31  |r subtraction. 1|
000033e0  37 32 30 20 20 20 20 20  20 20 20 20 53 42 43 20  |720         SBC |
000033f0  77 69 64 74 68 2c 59 20  20 20 5c 20 73 75 62 74  |width,Y   \ subt|
00003400  72 61 63 74 20 64 69 76  69 73 6f 72 0d 20 31 37  |ract divisor. 17|
00003410  33 30 20 20 20 20 20 20  20 20 20 42 43 43 20 64  |30         BCC d|
00003420  6f 6e 65 20 20 20 20 20  20 5c 20 62 72 61 6e 63  |one      \ branc|
00003430  68 20 69 66 20 64 69 76  69 64 65 6e 64 20 3c 20  |h if dividend < |
00003440  64 69 76 69 73 6f 72 0d  20 31 37 34 30 20 20 20  |divisor. 1740   |
00003450  20 20 20 20 20 20 49 4e  43 20 79 63 6f 6f 72 64  |      INC ycoord|
00003460  20 20 20 20 5c 20 69 6e  63 72 65 6d 65 6e 74 20  |    \ increment |
00003470  71 75 6f 74 69 65 6e 74  0d 20 31 37 35 30 20 20  |quotient. 1750  |
00003480  20 20 20 20 20 20 20 53  54 41 20 78 63 6f 6f 72  |       STA xcoor|
00003490  64 20 20 20 20 5c 20 73  61 76 65 20 6e 65 77 20  |d    \ save new |
000034a0  70 61 72 74 69 61 6c 20  64 69 76 69 64 65 6e 64  |partial dividend|
000034b0  0d 20 31 37 36 30 20 2e  64 6f 6e 65 0d 20 31 37  |. 1760 .done. 17|
000034c0  37 30 20 20 20 20 20 20  20 20 20 44 45 58 20 20  |70         DEX  |
000034d0  20 20 20 20 20 20 20 20  20 5c 20 64 65 63 72 65  |         \ decre|
000034e0  6d 65 6e 74 20 62 69 74  20 63 6f 75 6e 74 65 72  |ment bit counter|
000034f0  0d 20 31 37 38 30 20 20  20 20 20 20 20 20 20 42  |. 1780         B|
00003500  4e 45 20 6e 65 78 74 20  20 20 20 20 20 5c 20 62  |NE next      \ b|
00003510  72 61 6e 63 68 20 66 6f  72 20 31 36 20 62 69 74  |ranch for 16 bit|
00003520  73 0d 20 31 37 39 30 20  20 20 20 20 20 20 20 20  |s. 1790         |
00003530  4c 44 41 20 78 6c 6f 6f  70 2c 59 20 20 20 5c 20  |LDA xloop,Y   \ |
00003540  70 72 65 70 61 72 65 20  66 6f 72 20 6d 75 6c 74  |prepare for mult|
00003550  69 70 6c 69 63 61 74 69  6f 6e 0d 20 31 38 30 30  |iplication. 1800|
00003560  20 20 20 20 20 20 20 20  20 54 41 58 20 20 20 20  |         TAX    |
00003570  20 20 20 20 20 20 20 5c  20 58 3d 34 20 6d 6f 64  |       \ X=4 mod|
00003580  65 73 20 30 2d 33 2c 20  58 3d 35 20 6d 6f 64 65  |es 0-3, X=5 mode|
00003590  73 20 34 2d 37 0d 20 31  38 31 30 20 2e 6d 75 6c  |s 4-7. 1810 .mul|
000035a0  74 78 0d 20 31 38 32 30  20 20 20 20 20 20 20 20  |tx. 1820        |
000035b0  20 41 53 4c 20 78 63 6f  6f 72 64 20 20 20 20 5c  | ASL xcoord    \|
000035c0  20 6c 6f 77 20 62 79 74  65 20 2a 20 32 0d 20 31  | low byte * 2. 1|
000035d0  38 33 30 20 20 20 20 20  20 20 20 20 52 4f 4c 20  |830         ROL |
000035e0  78 63 6f 6f 72 64 2b 31  20 20 5c 20 68 69 67 68  |xcoord+1  \ high|
000035f0  20 62 79 74 65 20 2a 20  32 0d 20 31 38 34 30 20  | byte * 2. 1840 |
00003600  20 20 20 20 20 20 20 20  44 45 58 20 20 20 20 20  |        DEX     |
00003610  20 20 20 20 20 20 5c 20  63 6f 75 6e 74 20 6e 75  |      \ count nu|
00003620  6d 62 65 72 20 6f 66 20  6d 75 6c 74 69 70 6c 69  |mber of multipli|
00003630  63 61 74 69 6f 6e 73 0d  20 31 38 35 30 20 20 20  |cations. 1850   |
00003640  20 20 20 20 20 20 42 4e  45 20 6d 75 6c 74 78 20  |      BNE multx |
00003650  20 20 20 20 5c 20 67 6f  20 62 61 63 6b 20 69 66  |    \ go back if|
00003660  20 6e 6f 74 20 66 69 6e  69 73 68 65 64 0d 20 31  | not finished. 1|
00003670  38 36 30 20 20 20 20 20  20 20 20 20 4c 44 41 20  |860         LDA |
00003680  78 61 64 64 2c 59 20 20  20 20 5c 20 41 3d 38 20  |xadd,Y    \ A=8 |
00003690  6d 6f 64 65 73 20 30 2d  33 2c 20 41 3d 31 36 20  |modes 0-3, A=16 |
000036a0  6d 6f 64 65 73 20 34 2d  37 0d 20 31 38 37 30 20  |modes 4-7. 1870 |
000036b0  20 20 20 20 20 20 20 20  43 4c 43 20 20 20 20 20  |        CLC     |
000036c0  20 20 20 20 20 20 5c 20  70 72 65 70 61 72 65 20  |      \ prepare |
000036d0  66 6f 72 20 61 64 64 69  74 69 6f 6e 0d 20 31 38  |for addition. 18|
000036e0  38 30 20 20 20 20 20 20  20 20 20 41 44 43 20 78  |80         ADC x|
000036f0  63 6f 6f 72 64 0d 20 31  38 39 30 20 20 20 20 20  |coord. 1890     |
00003700  20 20 20 20 53 54 41 20  78 63 6f 6f 72 64 0d 20  |    STA xcoord. |
00003710  31 39 30 30 20 20 20 20  20 20 20 20 20 4c 44 41  |1900         LDA|
00003720  20 23 26 30 30 0d 20 31  39 31 30 20 20 20 20 20  | #&00. 1910     |
00003730  20 20 20 20 41 44 43 20  78 63 6f 6f 72 64 2b 31  |    ADC xcoord+1|
00003740  0d 20 31 39 32 30 20 20  20 20 20 20 20 20 20 43  |. 1920         C|
00003750  4d 50 20 23 26 30 35 20  20 20 20 20 20 5c 20 6d  |MP #&05      \ m|
00003760  61 78 20 76 61 6c 75 65  20 3d 20 34 0d 20 31 39  |ax value = 4. 19|
00003770  33 30 20 20 20 20 20 20  20 20 20 42 43 43 20 69  |30         BCC i|
00003780  6e 72 61 6e 67 65 0d 20  31 39 34 30 20 20 20 20  |nrange. 1940    |
00003790  20 20 20 20 20 4c 44 41  20 23 26 30 32 20 20 20  |     LDA #&02   |
000037a0  20 20 20 5c 20 64 75 6d  6d 79 20 76 61 6c 75 65  |   \ dummy value|
000037b0  0d 20 31 39 35 30 20 2e  69 6e 72 61 6e 67 65 0d  |. 1950 .inrange.|
000037c0  20 31 39 36 30 20 20 20  20 20 20 20 20 20 53 54  | 1960         ST|
000037d0  41 20 78 63 6f 6f 72 64  2b 31 0d 20 31 39 37 30  |A xcoord+1. 1970|
000037e0  20 20 20 20 20 20 20 20  20 4c 44 58 20 23 26 30  |         LDX #&0|
000037f0  35 20 20 20 20 20 20 5c  20 70 72 65 70 61 72 65  |5      \ prepare|
00003800  20 66 6f 72 20 79 20 63  6f 6f 72 64 69 6e 61 74  | for y coordinat|
00003810  65 20 6d 75 6c 74 69 70  6c 69 63 61 74 69 6f 6e  |e multiplication|
00003820  0d 20 31 39 38 30 20 2e  6d 75 6c 74 79 0d 20 31  |. 1980 .multy. 1|
00003830  39 39 30 20 20 20 20 20  20 20 20 20 41 53 4c 20  |990         ASL |
00003840  79 63 6f 6f 72 64 20 20  20 20 5c 20 6c 6f 77 20  |ycoord    \ low |
00003850  62 79 74 65 20 2a 20 32  0d 20 32 30 30 30 20 20  |byte * 2. 2000  |
00003860  20 20 20 20 20 20 20 52  4f 4c 20 79 63 6f 6f 72  |       ROL ycoor|
00003870  64 2b 31 20 20 5c 20 68  69 67 68 20 62 79 74 65  |d+1  \ high byte|
00003880  20 2a 20 32 0d 20 32 30  31 30 20 20 20 20 20 20  | * 2. 2010      |
00003890  20 20 20 44 45 58 20 20  20 20 20 20 20 20 20 20  |   DEX          |
000038a0  20 5c 20 63 6f 75 6e 74  20 6e 75 6d 62 65 72 20  | \ count number |
000038b0  6f 66 20 6d 75 6c 74 69  70 6c 69 63 61 74 69 6f  |of multiplicatio|
000038c0  6e 73 0d 20 32 30 32 30  20 20 20 20 20 20 20 20  |ns. 2020        |
000038d0  20 42 4e 45 20 6d 75 6c  74 79 20 20 20 20 20 5c  | BNE multy     \|
000038e0  20 67 6f 20 62 61 63 6b  20 69 66 20 6e 6f 74 20  | go back if not |
000038f0  66 69 6e 69 73 68 65 64  0d 20 32 30 33 30 20 20  |finished. 2030  |
00003900  20 20 20 20 20 20 20 53  45 43 20 20 20 20 20 20  |       SEC      |
00003910  20 20 20 20 20 5c 20 70  72 65 70 61 72 65 20 66  |     \ prepare f|
00003920  6f 72 20 73 75 62 74 72  61 63 74 69 6f 6e 0d 20  |or subtraction. |
00003930  32 30 34 30 20 20 20 20  20 20 20 20 20 4c 44 41  |2040         LDA|
00003940  20 23 26 46 30 20 20 20  20 20 20 5c 20 6c 6f 77  | #&F0      \ low|
00003950  20 62 79 74 65 20 6f 66  20 64 65 63 69 6d 61 6c  | byte of decimal|
00003960  20 31 30 30 38 0d 20 32  30 35 30 20 20 20 20 20  | 1008. 2050     |
00003970  20 20 20 20 53 42 43 20  79 63 6f 6f 72 64 20 20  |    SBC ycoord  |
00003980  20 20 5c 20 79 63 6f 6f  72 64 2d 23 26 46 30 0d  |  \ ycoord-#&F0.|
00003990  20 32 30 36 30 20 20 20  20 20 20 20 20 20 53 54  | 2060         ST|
000039a0  41 20 79 63 6f 6f 72 64  0d 20 32 30 37 30 20 20  |A ycoord. 2070  |
000039b0  20 20 20 20 20 20 20 4c  44 41 20 23 26 30 33 20  |       LDA #&03 |
000039c0  20 20 20 20 20 5c 20 68  69 67 68 20 62 79 74 65  |     \ high byte|
000039d0  20 6f 66 20 64 65 63 69  6d 61 6c 20 31 30 30 38  | of decimal 1008|
000039e0  0d 20 32 30 38 30 20 20  20 20 20 20 20 20 20 53  |. 2080         S|
000039f0  42 43 20 79 63 6f 6f 72  64 2b 31 20 20 5c 20 28  |BC ycoord+1  \ (|
00003a00  79 63 6f 6f 72 64 2b 31  29 2d 23 26 30 33 0d 20  |ycoord+1)-#&03. |
00003a10  32 30 39 30 20 20 20 20  20 20 20 20 20 41 4e 44  |2090         AND|
00003a20  20 23 26 30 33 20 20 20  20 20 20 5c 20 6d 61 78  | #&03      \ max|
00003a30  20 76 61 6c 75 65 20 3d  20 33 0d 20 32 31 30 30  | value = 3. 2100|
00003a40  20 20 20 20 20 20 20 20  20 53 54 41 20 79 63 6f  |         STA yco|
00003a50  6f 72 64 2b 31 0d 20 32  31 31 30 20 20 20 20 20  |ord+1. 2110     |
00003a60  20 20 20 20 52 54 53 20  20 20 20 20 20 20 20 20  |    RTS         |
00003a70  20 20 5c 20 72 65 74 75  72 6e 20 74 6f 20 42 41  |  \ return to BA|
00003a80  53 49 43 0d 20 32 31 32  30 20 2e 6f 66 66 73 65  |SIC. 2120 .offse|
00003a90  74 6c 6f 77 0d 20 32 31  33 30 20 20 20 20 20 20  |tlow. 2130      |
00003aa0  20 20 20 45 51 55 42 20  26 30 34 20 20 20 20 20  |   EQUB &04     |
00003ab0  20 5c 20 6d 6f 64 65 30  2c 20 75 6e 74 72 69 6d  | \ mode0, untrim|
00003ac0  6d 65 64 20 3d 20 26 30  36 0d 20 32 31 34 30 20  |med = &06. 2140 |
00003ad0  20 20 20 20 20 20 20 20  45 51 55 42 20 26 30 34  |        EQUB &04|
00003ae0  20 20 20 20 20 20 5c 20  6d 6f 64 65 31 2c 20 75  |      \ mode1, u|
00003af0  6e 74 72 69 6d 6d 65 64  20 3d 20 26 30 36 0d 20  |ntrimmed = &06. |
00003b00  32 31 35 30 20 20 20 20  20 20 20 20 20 45 51 55  |2150         EQU|
00003b10  42 20 26 30 34 20 20 20  20 20 20 5c 20 6d 6f 64  |B &04      \ mod|
00003b20  65 32 2c 20 75 6e 74 72  69 6d 6d 65 64 20 3d 20  |e2, untrimmed = |
00003b30  26 30 36 0d 20 32 31 36  30 20 20 20 20 20 20 20  |&06. 2160       |
00003b40  20 20 45 51 55 42 20 26  30 30 20 20 20 20 20 20  |  EQUB &00      |
00003b50  5c 20 6d 6f 64 65 33 2c  20 64 75 6d 6d 79 20 76  |\ mode3, dummy v|
00003b60  61 6c 75 65 0d 20 32 31  37 30 20 20 20 20 20 20  |alue. 2170      |
00003b70  20 20 20 45 51 55 42 20  26 30 33 20 20 20 20 20  |   EQUB &03     |
00003b80  20 5c 20 6d 6f 64 65 34  2c 20 75 6e 74 72 69 6d  | \ mode4, untrim|
00003b90  6d 65 64 20 3d 20 26 30  34 0d 20 32 31 38 30 20  |med = &04. 2180 |
00003ba0  20 20 20 20 20 20 20 20  45 51 55 42 20 26 30 33  |        EQUB &03|
00003bb0  20 20 20 20 20 20 5c 20  6d 6f 64 65 35 2c 20 75  |      \ mode5, u|
00003bc0  6e 74 72 69 6d 6d 65 64  20 3d 20 26 30 34 0d 20  |ntrimmed = &04. |
00003bd0  32 31 39 30 20 2e 78 6c  6f 6f 70 0d 20 32 32 30  |2190 .xloop. 220|
00003be0  30 20 20 20 20 20 20 20  20 20 45 51 55 44 20 26  |0         EQUD &|
00003bf0  30 30 30 34 30 34 30 34  20 5c 20 6d 6f 64 65 73  |00040404 \ modes|
00003c00  20 33 2d 30 0d 20 32 32  31 30 20 20 20 20 20 20  | 3-0. 2210      |
00003c10  20 20 20 45 51 55 57 20  26 30 35 30 35 20 20 20  |   EQUW &0505   |
00003c20  20 5c 20 6d 6f 64 65 73  20 35 2d 34 0d 20 32 32  | \ modes 5-4. 22|
00003c30  32 30 20 2e 78 61 64 64  0d 20 32 32 33 30 20 20  |20 .xadd. 2230  |
00003c40  20 20 20 20 20 20 20 45  51 55 44 20 26 30 30 30  |       EQUD &000|
00003c50  38 30 38 30 38 20 5c 20  6d 6f 64 65 73 20 33 2d  |80808 \ modes 3-|
00003c60  30 0d 20 32 32 34 30 20  20 20 20 20 20 20 20 20  |0. 2240         |
00003c70  45 51 55 57 20 26 31 30  31 30 20 20 20 20 5c 20  |EQUW &1010    \ |
00003c80  6d 6f 64 65 73 20 35 2d  34 0d 20 32 32 35 30 20  |modes 5-4. 2250 |
00003c90  2e 77 69 64 74 68 0d 20  32 32 36 30 20 20 20 20  |.width. 2260    |
00003ca0  20 20 20 20 20 45 51 55  44 20 26 30 30 35 30 35  |     EQUD &00505|
00003cb0  30 35 30 20 5c 20 6d 6f  64 65 73 20 33 2d 30 0d  |050 \ modes 3-0.|
00003cc0  20 32 32 37 30 20 20 20  20 20 20 20 20 20 45 51  | 2270         EQ|
00003cd0  55 57 20 26 32 38 32 38  20 20 20 20 5c 20 6d 6f  |UW &2828    \ mo|
00003ce0  64 65 73 20 35 2d 34 0d  20 32 32 38 30 20 2e 6c  |des 5-4. 2280 .l|
00003cf0  61 73 74 62 79 74 65 0d  20 32 32 39 30 20 5d 0d  |astbyte. 2290 ].|
00003d00  20 32 33 30 30 20 4e 45  58 54 0d 20 32 33 31 30  | 2300 NEXT. 2310|
00003d10  20 45 4e 44 50 52 4f 43  0d 20 32 33 32 30 20 3a  | ENDPROC. 2320 :|
00003d20  20 0d 20 32 33 33 30 20  44 45 46 46 4e 73 77 69  | . 2330 DEFFNswi|
00003d30  74 63 68 0d 20 32 33 34  30 20 49 46 20 28 41 44  |tch. 2340 IF (AD|
00003d40  56 41 4c 28 30 29 41 4e  44 33 29 3d 30 20 49 46  |VAL(0)AND3)=0 IF|
00003d50  20 21 78 63 6f 6f 72 64  3e 31 36 20 49 46 20 21  | !xcoord>16 IF !|
00003d60  78 63 6f 6f 72 64 3c 31  32 34 38 20 3d 46 41 4c  |xcoord<1248 =FAL|
00003d70  53 45 0d 20 32 33 35 30  20 3d 54 52 55 45 0d     |SE. 2350 =TRUE.|
00003d7f
10-02-89/T\Pen04.m0
10-02-89/T\Pen04.m1
10-02-89/T\Pen04.m2
10-02-89/T\Pen04.m4
10-02-89/T\Pen04.m5