Jump to content

Photo

mystified about Input command


19 replies to this topic

#1 Ranger03 OFFLINE  

Ranger03

    Moonsweeper

  • 462 posts

Posted Sat Jul 7, 2018 6:42 PM

On your average Apple II or C64, Input allows you to enable player input. Here, there is no such thing. 

 

2 problems: 

 

1. How the hell do you make a game with no input statement? and

2. what the **** was TI thinking?

Attached Files



#2 jrhodes OFFLINE  

jrhodes

    Chopper Commander

  • 153 posts
  • RUN "CS1"

Posted Sat Jul 7, 2018 7:11 PM

Instead of INPUT, try CALL KEY(0,K,S) where K is the variable of what ascii key value was pushed and S is the state; 0=no key being pressed at time of scan, 1=new key pressed, -1=same key pressed.

To detect joystick input, use CALL JOYST(1,X,Y) or CALL JOYST(2,X,Y) to read the X and Y position joystick's 1 or 2.

INPUT is designed for interactive user input, for example at a menu where they push 1 for easy or 2  for hard, or say in text adventure, to get the next string of text to interpret from the player.

If using Extended Basic, a better way to get input from the user is ACCEPT AT, which you read about in the attached XBref.pdf

Attached File  basicref_ti99.pdf   226.83KB   3 downloads

Attached File  XBref.pdf   513.74KB   4 downloads


Edited by jrhodes, Sat Jul 7, 2018 7:19 PM.


#3 marc.hull OFFLINE  

marc.hull

    Stargunner

  • 1,297 posts
  • Location:Oklahoma CIty.

Posted Sat Jul 7, 2018 7:44 PM

On your average Apple II or C64, Input allows you to enable player input. Here, there is no such thing. 
 
2 problems: 
 
1. How the hell do you make a game with no input statement? and
2. what the **** was TI thinking?


BASIC has an input statement. It may be different from what your used to. It's called INPUT in TI BASIC as apposed to other languages that use the term INPUT, INPUT or more rarely INPUT. Are you sure you didn't mean INKEY ?🙃

#4 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,504 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sat Jul 7, 2018 7:47 PM

I always lamented the lack of a GET or INKEY command on the TI.



#5 marc.hull OFFLINE  

marc.hull

    Stargunner

  • 1,297 posts
  • Location:Oklahoma CIty.

Posted Sat Jul 7, 2018 8:00 PM

I always lamented the lack of a GET or INKEY command on the TI.


CALL KEY is INKEY more or less. Maybe better/maybe worse. IIRC get is a record command ?
  • RXB likes this

#6 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,504 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sun Jul 8, 2018 1:06 AM

CALL KEY is INKEY more or less. Maybe better/maybe worse. IIRC get is a record command ?

 

The syntax is:

 

10 GET A$

 

or

 

10 A$=INKEY$

 

IIRC, GET is a "blocking" command (in some dialects) which will wait for a key press while in others it and INKEY$ just return a null string if no key is pressed.

 

To me the benefit of both is the immediate conversion to a character versus CALL KEY's ASCII value. I was exposed to them before CALL KEY and I was just used to using them but adapt and survive, we do.

 

Oh, I believe there is a GET# command for file operations, but I never used such a construct so I have no knowledge of its operation. (EDIT: I lied, seriously lied, I actually used GET# quite a lot for character-by-character in file handling. DUH!)



#7 RXB OFFLINE  

RXB

    River Patroller

  • 3,304 posts
  • Location:Vancouver, Washington, USA

Posted Sun Jul 8, 2018 11:22 AM

 

The syntax is:

 

10 GET A$

 

or

 

10 A$=INKEY$

 

IIRC, GET is a "blocking" command (in some dialects) which will wait for a key press while in others it and INKEY$ just return a null string if no key is pressed.

 

To me the benefit of both is the immediate conversion to a character versus CALL KEY's ASCII value. I was exposed to them before CALL KEY and I was just used to using them but adapt and survive, we do.

 

Oh, I believe there is a GET# command for file operations, but I never used such a construct so I have no knowledge of its operation. (EDIT: I lied, seriously lied, I actually used GET# quite a lot for character-by-character in file handling. DUH!)

Hmm how do you get only things like CALL KEY(3,K,S) and how do you get status?

Also XB has CALL KEY(1,K,S) or CALL KEY(2,K,S) for split keyboard scans.

And isn't CALL KEY(4,K,S) for Pascal?

 

RXB has things that kick the crap out of GET A$ or A$=INKEY$ as

CALL KEY("",0,K,S) ! does nothing till you press any key

CALL KEY("YNyn",0,K,S) ! will only respond to the keys listed in the string and ignores all others.

CALL ONKEY("YyNn",0,K,S) GOTO 210,210,280,280 ! similar to normal keyscan but if keys in string are used it uses the GOTO lines per the letter pressed.



#8 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,504 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sun Jul 8, 2018 1:15 PM

Hmm how do you get only things like CALL KEY(3,K,S) and how do you get status?

Also XB has CALL KEY(1,K,S) or CALL KEY(2,K,S) for split keyboard scans.

And isn't CALL KEY(4,K,S) for Pascal?

 

RXB has things that kick the crap out of GET A$ or A$=INKEY$ as

CALL KEY("",0,K,S) ! does nothing till you press any key

CALL KEY("YNyn",0,K,S) ! will only respond to the keys listed in the string and ignores all others.

CALL ONKEY("YyNn",0,K,S) GOTO 210,210,280,280 ! similar to normal keyscan but if keys in string are used it uses the GOTO lines per the letter pressed.

 

No preference for GET or INKEY$ over CALL KEY, just always wanted an easier way to do

 

CALL KEY(0,K,S)

A$=CHR$(K)

 

Nothing more, nothing less. I like how RXB extends the key detection paradigm in a way I would have liked all those years ago. Now it is more of a looking-back nostalgia for me as I clean up the last of my work in BASIC and commit myself to assembly.


  • RXB likes this

#9 Ranger03 OFFLINE  

Ranger03

    Moonsweeper

  • Topic Starter
  • 462 posts

Posted Mon Jul 9, 2018 11:37 AM

inkeys was always difficult for me to implement. Thus my abuse of the Input a$ command



#10 Casey OFFLINE  

Casey

    Moonsweeper

  • 292 posts

Posted Mon Jul 9, 2018 2:20 PM

TI BASIC has INPUT. The only difference between it and most other BASICs is the use of the : to separate a prompt from the variable rather than a ; or ,.

So you can either do:
10 PRINT “PLEASE ENTER SOMETHING”
20 INPUT A$

Or:

10 INPUT “PLEASE ENTER SOMETHING: “:A$

The various Extended BASICs also have LINPUT (for Line Input) which will allow any typeable character to be placed in the variable.
  • RXB likes this

#11 Ranger03 OFFLINE  

Ranger03

    Moonsweeper

  • Topic Starter
  • 462 posts

Posted Tue Jul 10, 2018 4:23 PM

so no need to DIM?



#12 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 9,797 posts
  • Location:Hustisford, WI

Posted Tue Jul 10, 2018 4:34 PM

Only if you're setting up an array.
  • RXB likes this

#13 Retrospect ONLINE  

Retrospect

    Stargunner

  • 1,057 posts
  • Location:Wakefield, England

Posted Wed Jul 11, 2018 6:28 AM

10 N=0

20 CALL KEY(0,K,S)

30 N=N+1

40 IF S=0 THEN 20

50 PRINT N

 

The above program waits for user to press any key, whilst it increments N by 1 each time it scans.

 

10 N=0

20 CALL KEY(1,K,S)

30 N=N+1

40 IF S=0 THEN 20

50 IF K=18 THEN 60 ELSE 20

60 PRINT N

70 CALL SOUND(256,110,30,110,30,650,30,-7,0)

 

This program waits for user to press FIRE on wired remote controller, incrementing N each time it scans, and when it shows value N it makes a fire sound.

 

As you see CALL KEY is the key to player input in games.  



#14 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,504 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Wed Jul 11, 2018 9:14 AM

As you see CALL KEY is the key to player input in games.  

 

Indeed.  I have a standard user input routine I use in my games now which makes use of both the split-keyboard scans for the directional keys and fire button and unit 3 for function keys. Handy.



#15 Retrospect ONLINE  

Retrospect

    Stargunner

  • 1,057 posts
  • Location:Wakefield, England

Posted Wed Jul 11, 2018 9:25 AM

 

Indeed.  I have a standard user input routine I use in my games now which makes use of both the split-keyboard scans for the directional keys and fire button and unit 3 for function keys. Handy.

Can you show me an example of Unit 3 for function keys? This would be good for some of my projects. 



#16 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,504 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Wed Jul 11, 2018 11:18 AM

Can you show me an example of Unit 3 for function keys? This would be good for some of my projects.

 
This is the Tidbit source of my user input routine. You can extend K$(1) for whatever keys you want to detect in unit 3, just bear in mind over-laps with units 1 and 2 will be detected first, so it is really only useful for FCTN or CTRL keys.
 
 

Spoiler


#17 Retrospect ONLINE  

Retrospect

    Stargunner

  • 1,057 posts
  • Location:Wakefield, England

Posted Wed Jul 11, 2018 1:25 PM

Thanks Old CS1 :)

 

I never knew the CHR$ or the Unit combination.  I'm gonna put that to use .  



#18 FarmerPotato OFFLINE  

FarmerPotato

    Chopper Commander

  • 110 posts
  • Location:Austin, TX

Posted Wed Jul 11, 2018 2:08 PM

For INKEY$ and the like on other platforms, here is an article by our friend Regena in late 1987.

 

https://www.atarimag...inners_Page.php

 

I'd like to think she wrote out the appropriate CALL KEY code for TI-99/4A, but that the Compute editor removed it.

 

For those who weren't around then: C. Regena was a legendary magazine author, whose mystique was built up by the editor of 99er magazine with tales of how her prolific manuscripts arrived mysteriously signed only "Regena", while actually she was a well known writer for other computer magazines. 

 



#19 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,504 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Wed Jul 11, 2018 2:53 PM

For those who weren't around then: C. Regena was a legendary magazine author, whose mystique was built up by the editor of 99er magazine with tales of how her prolific manuscripts arrived mysteriously signed only "Regena", while actually she was a well known writer for other computer magazines. 

 

 

I found a C. Regena book in my elementary school library, something about beginning with computers, that helped usher me into where I am today.



#20 OLD CS1 OFFLINE  

OLD CS1

    Technomancer

  • 5,504 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Wed Jul 11, 2018 3:43 PM

Thanks Old CS1 :)

 

I never knew the CHR$ or the Unit combination.  I'm gonna put that to use .  

 

Welcome.  I forgot to note in the comments that entering the routine with P negative only performs joystick and function key scan.  Conceivably, this could be used to do a full keyboard scan and not worry about the over-lap with the split keyboard movement keys functionality.  But it also skips the fire button.  For some games I removed the negative check which cleared up an ABS() in the CALL JOYST() and the initial IF/THEN.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users