home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 47
/
047.d81
/
joystick
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
2KB
|
79 lines
1 poke88,.:poke89,192:poke90,.:poke91,192:poke781,33:poke782,.:sys41964
2 poke88,254:poke89,255:poke90,254:poke91,255:poke781,33:poke782,.:sys41964
3 poke59639,12:poke1,53
10 print"[147] press 'q' to quit[158]"
15 :
16 :
17 rem setup the sprite
25 v=53248
30 poke 53280,0:poke53281,0
40 fora=12288to12350:pokea,255:nexta
50 poke 2040,192:poke v+39,1:pokev+21,1
60 poke v,24:pokev+1,50:r=24:d=50
65 :
66 :
70 gosub850:rem one way to check the joystick (lines 850-895)
71 :
72 rem another way to check the joystick (lines 73-560)
73 joy=peek(56320):fire=joyand16: di=15-(joyand15)
74 if fire <> 16 thengosub730
75 ifpeek(203)=62then60000
76 if di=0 then 70
80 on di gosub150,200,250,300,350,400,450,500,550,560
90 goto 70
100 :
110 :
120 :
149 rem move the sprite in the direction of the joystick
150 d=d-1:gosub600:pokev+1,d:return
155 :
200 d=d+1:gosub600:pokev+1,d:return
210 :
250 return
255 :
300 r=r-1:gosub600:pokev,r:return
310 :
350 r=r-1:d=d-1:gosub600:pokev+1,d:pokev,r:return
355 :
400 r=r-1:d=d+1:gosub600:pokev+1,d:pokev,r:return
410 :
450 return
455 :
500 r=r+1:gosub600:pokev,r:return
510 :
550 r=r+1:d=d-1:gosub600:pokev+1,d:pokev,r:return
555 :
560 r=r+1:d=d+1:gosub600:pokev+1,d:pokev,r:return
565 :
590 :
595 rem keep sprite on screen
600 if d=251thend=0
610 if d=-1then d=250
620 if peek(v+16)=1then700
650 if r=-1 then pokev+16,peek(v+16)+1:r=88
655 if r=256 then r=0:pokev+16,peek(v+16)+1
660 return
700 if r=89 then poke v+16,peek(v+16)-1:r=0
710 if r=-1then poke v+16,peek(v+16)-1:r=255
720 return
730 c=c+1:ifc>15thenc=0
740 poke53280,c:poke53281,c:return
800 :
810 :
820 :
830 rem another way to check joystick
850 joy=peek(56320)and15:ok=0
855 print"";:if(peek(56320)and16)=.thenprint"";
860 if (joyor14)<>15 then print"up",:ok=1
870 if (joyor07)<>15 then print"right",:ok=1
880 if (joyor13)<>15 then print"down",:ok=1
890 if (joyor11)<>15 then print"left",:ok=1
893 if (ok) then print
895 return
10000 :
20000 :
30000 rem reconnect to loadstar
60000 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
60010 pokev+21,.:ifer<>63thenend
60020 poke1,55:load"hello connect",8