This is non-commercial site, its content is based on Atari 8-bit home computer contents and references.
If you feel your rights are violated by showing/using any part of contents of your product represented on this page,
please contact me immediatelly so I can remove it!
|
-
Entry name:Joystick Position
-
Category:Utilities
-
Publisher/Developer:Rosetta Code
-
Year:2021
Listing 1
BYTE lastStick=[255]
BYTE lastTrig=[255]
PROC DrawCross(BYTE s)
BYTE size=[5]
CARD x
BYTE y
IF s>=9 AND s<=11 THEN
x=size
ELSEIF s>=5 AND s<=7 THEN
x=159-size
ELSE
x=79
FI
IF s=6 OR s=10 OR s=14 THEN
y=size
ELSEIF s=5 OR s=9 OR s=13 THEN
y=79-size
ELSE
y=39
FI
Plot(x-size,y)
DrawTo(x+size,y)
Plot(x,y-size)
DrawTo(x,y+size)
RETURN
PROC UpdateStatus(BYTE currStick,currTrig)
IF currStick#lastStick THEN
Color=0 DrawCross(lastStick)
Color=1 DrawCross(currStick)
lastStick=currStick
FI
IF currTrig#lastTrig THEN
Print("Button pressed: ")
IF currTrig THEN
PrintE("no ")
ELSE
PrintE("yes")
FI
Put(28) ;move cursor up
lastTrig=currTrig
FI
RETURN
PROC Main()
BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6,
CRSINH=$02F0 ;Controls visibility of cursor
BYTE currStick,currTrig
Graphics(7)
Color=1
COLOR1=$0C
COLOR2=$02
CRSINH=1 ;hide cursor
DO
currStick=Stick(0)
currTrig=STrig(0)
UpdateStatus(currStick,currTrig)
UNTIL CH#$FF
OD
CH=$FF
RETURN
References
Listing downloads
Copyright holder
