TI99 Environment

CALL_JOYST


Syntax

CALL_JOYST(keyunit,x,y)

Description

This function scans for the gamepad controller's input. It is TI-99/4A's implementation of DarkBASIC's joystick() function.
Parameters "x" and "y" are unused; they are mandatory to maintain compatibility with TI programs copied directly from other sources. You can place two unused/dummy variables here.
A keyunit value of 1 checks for controller 1. A keyunit value of 2 checks for controller 2 (NOT IMPLEMENTED yet).

The global variables "joysty" and "joystx" hold the y,x return values of the controller's position (see image below).

on-off conditions

As with the TI-99/4A computer, to check for the fire button (button A) use the CALL_KEY function. When the A button is pressed, the TIAsc global variable will return the value of 18. TIKeyStatus global variable holds the actual fire button (A button) status of CALL_KEY (possible return values are -1,0,1). If the A button has not been pressed TIKeyStatus = 0. If the A button is pressed, TIKeyStatus = 1. If the same A button is being held from a previous call, TIKeyStatus = -1.


  Example Code
Example 1:
do
   call_screen(8)
   repeat
      fire = CALL_KEY(1,k,s) : display_at(11,1,"fire:"+Str$(fire),0)
      CALL_JOYST(1,x,y)
      display_at(10,1,"joystx:"+str$(joystx),0)
      display_at(10,15," joysty:"+str$(joysty),0)   
      display_at(12,1,"Fire button status: "+str$(TIKeyStatus),0)
      ti_sync()
   until fire > 0 or joystx > 0 or joysty > 0
   display_at(10,1,"joystx:"+str$(joystx),0)
   display_at(10,15," joysty:"+str$(joysty),0)   
   display_at(12,1,"Fire button status: "+str$(TIKeyStatus),0)
   if tikeystatus = 1 then call_screen(16)
   if tikeystatus = -1 then call_screen(11)
   tiwait(500)
LOOP

Example 2:
speed = 2
CALL_CLEAR() : call_char(128,rpt$("f",16)) : CALL_MAGNIFY(2)
CALL_SCREEN(16)
CALL_SPRITE(1,128,5,1,1,0,0)
randomize hitimer()
px = call_positionX(1) : py = call_positionY(1)
do    	    
    display_at(23,1,"joyst x:"+str$(x)+"  joyst y:"+str$(y),0)
    display_at(24,1,"Pos x:"+str$(px)+"  Pos y:"+str$(py),0)
    CALL_JOYST(1,X,Y) : x = joystx : y = joysty
    fire = CALL_KEY(1,k,s)
    if fire = 18 and TIKeyStatus = 1
       call_colorsprite(1,rnd(13)+2)
    endif
    CALL_MOTION(1,-Y * speed,X * speed)    
    ti_sync()  
    px = call_positionX(1) : py = call_positionY(1)
loop

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020