1VDU 23,128,255,255,255,255,255,255,255,255 2MODE0 3DIM xlo 3: DIM ylo 3: !xlo = 0:!ylo = 0 4DIM buttons 3:!buttons=0 10max=5 20next=0 30DIM lastx(max),lasty(max) 40FOR I%=0 TO max:lastx(I%)=0:lasty(I%)=0:NEXT 50LX=0:LY=0 60moveabs=4 70linerel=1 80TRIrel=linerel+80 90moverel=0 100DIM ox 3,oy 3 110DIM Code 511 120PROCassemble 121PROCgenmouse 122QQ%=USR(initmouse) 130PROC_init 140PROC_main 150END 160DEFPROC_cursor 170 MOVE !ox,!oy 180 VDU 128 190ENDPROC 200 210DEFPROC_init 220OX = 0:OY = 0:X = 0:Y = 0:!ox=OX:!oy=OY 240 VDU 5,18,3,1,23,128,0,24,60,126,24,24,24,0 250ENDPROC 260 270DEFPROC_track 280LOCAL I% 290 X=FNmouseX + 512:Y=FNmouseY + 512 300 X = (X * 1280 DIV 1024) 310 X = X DIV 16 * 16: Y = Y DIV 20 * 20 320DX=X-LX:DY=Y-LY 330lastx(next)=DX:lasty(next)=DY 340DX=0:DY=0 350FOR I%=0 TO max 360 DX = DX+lastx(I%) 370 DY = DY+lasty(I%) 380NEXT 390DX=DX DIV (max+1):DY=DY DIV (max+1) 400X=LX+DX:Y=LY+DY 410LX=X:LY=Y 420X=X-(X MOD 8):Y=Y-(Y MOD 4) 430ENDPROC 440 450DEFPROC_main 460ZX=0:ZY=600 463!ox=ZX:!oy=400 464A%=USR(cursor) 465!ox=ZX:!oy=800 466A%=USR(cursor) 467!ox=ZX:!oy=ZY 468A%=USR(cursor) 470down=FALSE 480 REPEAT 490 PROC_cursor:REM A%=USR(cursor) 500 !ox = X:!oy = Y 510 REPEAT PROC_track 520 IF ((buttons?0) AND 7)<>0 AND (NOT down) THEN PROCdraw:down=TRUE 530IF((buttons?0)AND 7) = 0 THEN down=FALSE 540UNTIL X<>!ox OR Y<>!oy 550 PROC_cursor:REM A%=USR(cursor) 560 !ox = X:!oy = Y 570 UNTIL FALSE 580ENDPROC 590DEFPROCassemble 600FOR Pass=0 TO 2 STEP 2 610OSWRCH=&FFEE 620P%=Code 630[OPT Pass 640.cursor 650] 660PROCplot(moveabs):PROCvar(ox):PROCvar(oy) 670PROCplot(linerel):PROCconst(50):PROCconst(0) 680PROCplot(linerel):PROCconst(0):PROCconst(-50) 690PROCplot(linerel):PROCconst(-50):PROCconst(0) 700PROCplot(linerel):PROCconst(0):PROCconst(50) 710 [OPT Pass:Rts:] 720NEXT Pass 730ENDPROC 740 750DEFPROCvar(Addr) 760[OPT Pass 770 Lda Addr 780 Jsr OSWRCH 790 Lda Addr+1 800 Jsr OSWRCH 810] 820ENDPROC 830 840DEFPROCvdu(C%) 850[OPT Pass 860 Lda #C% 870 Jsr OSWRCH 880] 890ENDPROC 900 910DEFPROCplot(plotcode) 920 PROCvdu(25) 930 PROCvdu(plotcode) 940ENDPROC 950 960DEFPROCconst(X%) 970X% = (X% AND &FFFF) 980 PROCvdu(X% MOD 256) 990 PROCvdu(X% DIV 256) 1000ENDPROC 1010DEFPROCdraw 1011dd=!ox:FF=!oy 1020oldx=LX:oldy=LY 1030LX=ZX:LY=ZY 1040FOR J%=0 TO 20 1050!ox=LX:!oy=LY:A%=USR(cursor) 1060 X = oldx:Y=oldy 1070DX=oldx-LX:DY=oldy-LY 1080lastx(next)=DX:lasty(next)=DY 1090DX=0:DY=0 1100FOR I%=0 TO max 1110 DX = DX+lastx(I%) 1120 DY = DY+lasty(I%) 1130NEXT 1140DX=(DX) DIV (max+1):DY=(DY) DIV (max+1) 1150X=LX+DX:Y=LY+DY 1160LX=X:LY=Y 1170A%=USR(cursor) 1180NEXT 1181!oy=FF:!ox=dd 1182A%=USR(cursor) 1190ENDPROC 2000 2010DEFPROCgenmouse 2020FOR Pass = 0 TO 2 STEP 2 2030[OPT Pass 2040.sample 2050 Lda &FC57 2060 Sta buttons 2070 Lda &FC52: Sta xlo 2080 Lda &FC53: Sta xlo+1 2090 Lda &FC54: Sta ylo 2100 Lda &FC55: Sta ylo+1 2110 Rts 2120.initmouse 2130 Lda #0 2140 Sta &FC50 2150 Lda #16+&D 2160 Sta &FC50 2170 Lda &FC57 2180 Rts 2190] 2200NEXT 2210ENDPROC 3000 3010DEFFNmouseX 3020QQ%=USR(sample) 3021IF (!xlo AND &8000)<>0 THEN = !xlo OR &FFFF0000 3030 =!xlo 3040 3050DEFFNmouseY 3051IF (!ylo AND &8000)<>0 THEN = !ylo OR &FFFF0000 3060 = !ylo