RosettaCodeData/Task/Joystick-position/Commodore-BASIC/joystick-position-1.basic

25 lines
837 B
Plaintext

5 rem joystick - commodore vic-20 (expanded)
6 rem for rosetta code
10 print chr$(147);:poke 37154,peek(37154) and 127
15 j1=37137:j2=37152:sc=4118:co=37910:x=11:y=11
20 poke sc+x+y*22,43:poke co+x+y*22,0
25 j=(not peek(j1) and28)/4
30 j=j+(not peek(j1) and32)/2
35 j=j+(not peek(j2) and128)/16
40 print chr$(19);"joy: ";
45 get k$:if k$="q" then print chr$(147):poke 37154,peek(37154)or128:end
50 ox=x:oy=y
60 if(j and 1) then y=1:ud$="u"
61 if(j and 2) then y=21:ud$="d"
62 if(j and 3)=0 then y=11:ud$=" "
63 if(j and 4) then x=0:lr$="l"
64 if(j and 8) then x=21:lr$="r"
65 if(j and 12)=0 then x=11:lr$=" "
66 if(j and 16) then f$="fire!":c=24
67 if(j and 16)=0 then f$=" ":c=43
70 print tab(5);ud$;tab(7);lr$;tab(9);f$;
75 poke sc+x+y*22,c:poke co+x+y*22,0
80 if (ox=x) and (oy=y) then goto 100
85 poke sc+ox+oy*22,32
100 goto 25