CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: JWinslow23 on November 11, 2016, 10:24:35 PM

Title: TI-BASIC terminal
Post by: JWinslow23 on November 11, 2016, 10:24:35 PM
I made a TI-BASIC terminal-style scheme for input and input processing.

(http://i.imgur.com/ekfmqhl.gif)

The input is already all taken care of. You can input letters, spaces, and numbers (I might revamp this, because on hindsight, I might not need numbers except for special cases). What I think is innovative about this is the scrolling and input processing.

The scrolling works like this: Str9 contains each line, with a boxplot character at the end (basically, any character I'm sure won't appear in the string), and L1 contains the x-positions of the text. Each are shifted as a new line is added, and the screen is redrawn.

The input processing is a little more clever: Str1 is stripped of extraneous spaces, and separated by keyword. If a keyword is found, a code (unique for each keyword) is added to Str2. Then, Str2 is searched for each combination of keywords that do commands, and then that command is done.

To add a keyword:
In CPROCESS, there are lines that go like this:
sub(Str1,A,Ans-A
{Ans="QUIT" or Ans="EXIT" or Ans="DONE" or Ans="BYE" or Ans="GOODBYE" or Ans="CYA",Ans="TEST" or Ans="TESTING",Ans="HI" or Ans="HELLO" or Ans="HEY" or Ans="HEYA" or Ans="HIYA" or Ans="YO",Ans="WHAT" or Ans="WHATS" or Ans="WHATZ" or Ans="WTF" or Ans="WOT" or Ans="WOTS" or Ans="WOTZ" or Ans="WAT" or Ans="WATS" or Ans="WATZ" or Ans="WUT" or Ans="WUTS" or Ans="WUTZ",Ans="UP",Ans="WASSUP" or Ans="WAZZUP" or Ans="SUP",Ans="HOW",Ans="ARE" or Ans="R",Ans="YOU" or Ans="YA" or Ans="U",Ans="WHO",Ans="YOUR" or Ans="UR" or Ans="YUR",Ans="NAME" or Ans="NAEM",Ans="CALLED" or Ans="CALLD",Ans="SMART",Ans="REAL",Ans="MALE" or Ans="MAN" or Ans="BOY" or Ans="DUDE",Ans="FEMALE" or Ans="WOMAN" or Ans="GIRL" or Ans="LADY",Ans="GENDER" or Ans="SEX",Ans="STUPID" or Ans="DUMB" or Ans="IDIOT" or Ans="MORON"
If max(Ans
Str2+sub("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZθ",1+sum(not(cumSum(Ans))),1→Str2

First, make sure there are enough characters in the giant string in the bottom. Add some if necessary.
In the expression in the second line, add a piecewise expression with the number of the keyword and the keyword itself like this:
Ans="KEYWORD",
The Nth character in that giant string in the bottom is the corresponding character for your keyword, so remember it.
Note: multiple words can be assigned to one code, but one code cannot match more than one word.

To add a command:
Commands are strings of keyword codes. For example, in the example program, "398C" represents "WHAT ARE YOU CALLED".
In CCOMMAND, add a section like this:
If inString(Str2,"command
Then
command code goes here
Goto E
End

To output a line of text, do this:
"OUTPUT→Str1
XPOS→L₁(9:IS_NEWLINE→L₁(10
prgmCSCROLL

OUTPUT is your output line, XPOS is the X-position of the line, and IS_NEWLINE is 0 if this line overwrites the last line, and 1 if it scrolls up.

Questions? Ask me, and I'll try to clarify. Keep in mind, however, this may not be bug-free or optimized fully. If anyone is willing to help, that would be swell.

Download attached.
Title: Re: TI-BASIC terminal
Post by: xMarminq_ on November 11, 2016, 10:43:47 PM
Trying to make Siri...
;)
Title: Re: TI-BASIC terminal
Post by: p2 on November 14, 2016, 10:17:23 AM
there's a Axe command to "move" the screen content upwards (what's off the upper border is shown on the buttom) which is affecting the entire calc (not just the graphics screen).
it should be possible in HEx, too, o you could implement it.
I think it sohould be faster than your current scrolling :)

But I'm really surprised how well your program works :)  :thumbsup:
Title: Re: TI-BASIC terminal
Post by: JWinslow23 on November 14, 2016, 11:02:11 PM
Quote from: p2 on November 14, 2016, 10:17:23 AM
there's a Axe command to "move" the screen content upwards (what's off the upper border is shown on the buttom) which is affecting the entire calc (not just the graphics screen).
it should be possible in HEx, too, o you could implement it.
I think it sohould be faster than your current scrolling :)

But I'm really surprised how well your program works :)  :thumbsup:
This is a TI-BASIC proof of concept; obviously Asm/Axe would be more capable ;) (I think the command you're referencing would be ZInterval? Not quite what I'd want, but good to know) . In fact, if this were entirely in Axe, all the better! The one problem is that string processing would be a bit more involved, because the language is low-level when it comes to any data processing. Who knows, though? If that's code-able, you could see CALSPEAK grace a full-fledged Asm program!

Thank you, by the way. I appreciate it!
Title: Re: TI-BASIC terminal
Post by: Dream of Omnimaga on November 14, 2016, 11:09:17 PM
So this is kinda like a chat bot? I kinda like it so far considering it's TI-BASIC. It looks nice too.
Title: Re: TI-BASIC terminal
Post by: Snektron on November 14, 2016, 11:16:47 PM
Looks pretty cool :) nice work

Quote from: JWinslow23 on November 14, 2016, 11:02:11 PM
Quote from: p2 on November 14, 2016, 10:17:23 AM
there's a Axe command to "move" the screen content upwards (what's off the upper border is shown on the buttom) which is affecting the entire calc (not just the graphics screen).
it should be possible in HEx, too, o you could implement it.
I think it sohould be faster than your current scrolling :)

But I'm really surprised how well your program works :)  :thumbsup:
This is a TI-BASIC proof of concept; obviously Asm/Axe would be more capable ;) (I think the command you're referencing would be ZInterval? Not quite what I'd want, but good to know) . In fact, if this were entirely in Axe, all the better! The one problem is that string processing would be a bit more involved, because the language is low-level when it comes to any data processing. Who knows, though? If that's code-able, you could see CALSPEAK grace a full-fledged Asm program!

Thank you, by the way. I appreciate it!
String processing is definitely capable in assembly, but it does require some work. Most functions are pretty trivial though (you could for examples take a look at KnightOS's string functions ;))
Title: Re: TI-BASIC terminal
Post by: JWinslow23 on November 15, 2016, 08:22:06 PM
Oh right, forgot to upload my latest version.

Latest version up there. It demonstrates the capabilities of this engine with a chatbot named "CALSpeak".
Basically, CALSpeak is a chabot using the Terminal engine that has answers to a few select phrases (and I'll update it to have some more, too). As it stands, it can give you a greeting, tell you what's up, tell you how it is, tell you its name, tell you its gender, tell you its intelligence, and reflect on its state of reality.

I have a screenshot right here.
(http://i.imgur.com/ekfmqhl.gif)

Perhaps someone can use this for a text adventure? That would certainly be welcome.
Title: Re: TI-BASIC terminal
Post by: Dream of Omnimaga on December 05, 2016, 07:37:21 AM
Cool, I'm definitively giving it a try when I get a chance. Is it me, though, or is text typing slow? I have the feeling that that part could probably be improved, but I'm unsure.