Jump to content

Photo

BASIC / XB Translator (TidBit)


218 replies to this topic

#26 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Mon Nov 22, 2010 12:56 PM

I see what you are saying. I may be able to hack that in there, but at the point where I'm joining lines, I'm not actually scanning the tokens (remember, I was going to cheap and easy the first time around.) This "auto double colon" thing would only work inside of an IF construct though, and the ENDIF would be required.

I'll see what I can do later tonight.

Matthew

#27 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Tue Nov 23, 2010 10:22 AM

Motivation... Aside from the "that's neat" factor, is anyone seriously interested in using this? I was working on getting it on my website, followed by a Windows GUI version, but if I end up being the only one who would use it, I'll just keep it in its current form (command line PHP script.)

It was fun to hack out, but I'm not going to keep spending time on it if there is no real benefit or interest. I have a video chip to get done. :)

Matthew

#28 jchase1970 OFFLINE  

jchase1970

    Moonsweeper

  • 340 posts
  • Location:Newburgh IN

Posted Tue Nov 23, 2010 10:53 AM

I think I could use it, but some people wont see the benefit from it until they try it and for them to try it .You need to push on a bit, make it simple with a windows IDE and a decent amount of functions to be able to do something with. You don't have to get everything in there yet, like don't worry about files support for now. Then people can get a good try on it and see if they like it, once people start using it then you can futher develop it as people notice things that would improve it.

You know for myself, I like using basic it's fast to get something working in, powerful commands but I just hate the line numbers. So I can see a real plus to using this.

#29 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 8,261 posts
  • Location:Cookeville, TN

Posted Tue Nov 23, 2010 10:58 AM

I'm not much of a coder, but having support for this kind syntax could really be beneficial in getting new programmers to work with the TI... I've always programmed in BASIC, because in the two years I've been programming, BASIC (and XB) is all I've known (with the exception of my hack and slash attempts at assembly). This also seems like it would make porting games from other languages easier... Does that make sense?



#30 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 2,814 posts
  • Location:Eagan, MN, USA

Posted Tue Nov 23, 2010 11:13 AM

There is already a BASIC/XB converter out there I believe programmed by a German TIer. As a matter of fact I found it on a CD distributed by Berry Harmsen a couple of years ago. What it does is take a plain text file and convert it into a program. I will play with it tonight and see if it still requires line numbers or not.
It looks like you are going beyond a straight converter though with some potentially nice enhancements, and I'm looking forward to the final product.

#31 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Thu Nov 25, 2010 1:05 PM

Ok, I added a web version to my CHC site. Let's see how it holds up. Go give it a try and let me know how it goes...

http://codehackcreate.com/archives/237

Matthew

#32 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 8,261 posts
  • Location:Cookeville, TN

Posted Thu Nov 25, 2010 3:43 PM

Just tried it out.... That's pretty amazing, man. :)

Very cool...

#33 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Fri Feb 11, 2011 8:29 AM

So I'm wondering, is anyone using this? I never heard any feedback (other than Owen of course ;) ), and subsequently I have not done anything with it beyond this initial implementation. Online version is here:

http://codehackcreate.com/archives/237

#34 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 2,814 posts
  • Location:Eagan, MN, USA

Posted Fri Feb 11, 2011 9:31 AM

So I'm wondering, is anyone using this? I never heard any feedback (other than Owen of course ;) ), and subsequently I have not done anything with it beyond this initial implementation. Online version is here:

http://codehackcreate.com/archives/237

I have to admit that I had completely forgotten about it... I gave it a very quick try and I can see how BASIC code immediately becomes much more readable, especially with the long labels and the indentations. Kind of reminds me of Microsoft's QBasic a bit. This will be very valuable for big projects. Are you planning a standalone version usable under Windows?
One potential annoyance though would be having to switch back and forth between Classic 99 and the translator for every edit, but I suspect the much improved readability and ease of editing will more than offset that minor issue, especially if one has a large enough screen real estate to keep both Classic 99 and the translator open at the same time.

Edited by Vorticon, Fri Feb 11, 2011 9:37 AM.


#35 unhuman OFFLINE  

unhuman

    Stargunner

  • 1,158 posts
  • Location:Vienna, VA

Posted Fri Feb 11, 2011 9:48 AM

Once we get the outstanding contests resolved, you should make a "best thingie written with my tool" contest. That'll get you traction. Might even get me to stay up past 10 these days.

This may, however, increase the amount of code I have to paste into classic99... That would make it a difficult tool to use. Repasting entire project instead of smaller ranges (depending on how the line numbers re-allocate with changes) for minor updates could slow down my dev time.... But just theorizing here.

Edited by unhuman, Fri Feb 11, 2011 9:49 AM.


#36 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,072 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Fri Feb 11, 2011 9:53 AM

I had not seen this, but will put it to some use as I continue the re-writing of some of my programs. Is it specific to XB multiple statement lines, or can it be used to define TI BASIC blocks?

I have some other thoughts, but I think the simplicity of this translator may work well to defeat the complexity of what I am thinking.

#37 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Fri Feb 11, 2011 10:31 AM

Yeah, I understand the problems about having to copy-and-paste. It is a bit of a pain. However, personally, when I program in BASIC, I do the bulk of it in a text editor on a PC, then move the thing to an emulator. It would suck for those debugging sessions where you want a fast code, run, debug cycle.

Is it specific to XB multiple statement lines, or can it be used to define TI BASIC blocks?


It has no knowledge of XB vs BASIC. If you use XB specific commands or syntax, then it will require XB. Otherwise it will work equally well with BASIC. The current implementation is simply a scanner, there is no syntax parsing beyond what is needed to recognize a label and line concatenation.

This was really more and a test to see if BASIC could be made more readable and manageable, without actually writing a new interpreter. If it actually gets some use, feedback, user requests, etc. then I'll work on it. Otherwise it will just remain as is. I had initially planned on a native desktop GUI version, but without interest that won't happen. Also, it may be possible to work out some way to interface with the emulators to make getting to code into the emulators easier. The first thing that comes to mind would be to export the code in a "merge" format, saving to, for example, the DSK1 directory of Classic99. Then your development cycle might go like this:

1. Editing in text editor.
2. Save.
3. Hit "convert" button in the translator.
4. In the emulator:
4a. NEW
4b. MERGE DSK1.xxxxxx
4c. RUN

This works well for assembly language with Classic99 because Classic99 does not cache any files and opens/reads them every time you reference the file. This is a very good thing.

It all comes down to money really. ;) And "money" around here is basically participation and feedback. Anyone who works on a tool for our community gets their drive and motivation from the rest of us saying "cool, this is awesome!", etc. Without that sense of need or interest, people stop working on stuff. Just something to keep in mind. For a while we had a lot of good threads going where people were making layout screen and graphics editors, and all kinds of cool stuff. I have not seen much of that lately though, which is too bad because we have a lot of new people and those tools are really great! I might go bump some of them. ;)

Anyway, I feed on that participation and feedback mojo, so "show me the money!" :)

#38 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 8,261 posts
  • Location:Cookeville, TN

Posted Fri Feb 11, 2011 6:33 PM

Matthew--- I have sent this program to Codex, since he isn't on here much anymore... Hope he gets it and has a chance to play with it. Using conventions of a high level modern language and applying them to an antiquated line-based number system is pretty genius, actually. :)

#39 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,072 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Fri Feb 11, 2011 8:14 PM

I was thinking macros and operator expansions, interpreter variables, loop controls, things like that.

Macros
Spoiler


Operator expansions
Spoiler


Interpreter variables
Spoiler


Loop controls
Spoiler


That is all I have right now. It might all be too much or cause undue complexity, but seems like it would be a neat factor. In any case, I have a severe headache right now so I completely disavow and deny any responsibility for errors or quirkiness, but take full credit for anything that looks like a good idea. :)

(Edited to fix some errors and make some concepts more clear.)

Edited by OLD CS1, Sat Feb 12, 2011 2:25 AM.


#40 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,538 posts
  • Location:Germany

Posted Sat Feb 12, 2011 2:43 AM

ok, here are my thoughts:

1) You would need some kind of standalone version, without having to connect to the internet.
I'm a web guy, but for this type of application a standalone version would be cooler.

2) If going the web way, some kind of repository feature could be added where code can be exchanged or loaded
from the internet and then pumped directly into classic99.

3) Writing such a tool without knowing if the community will actually use it, can be *very* frustrating.
I kinda get the same feeling with spectra2. The motivation that keeps me going is that I'm convincing myself I'll
get use of it for my future stuff, sooner or later :|

4) The value of such translator could be improved if there is a more easy way to get the code into the emulators.
Perhaps Tursi could help out there for classic99 (see 2)
Ofcourse the idea of macro expansion mentioned earlies also sound very cool.

#41 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,072 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sat Feb 12, 2011 3:08 AM

ok, here are my thoughts:

1) You would need some kind of standalone version, without having to connect to the internet.
I'm a web guy, but for this type of application a standalone version would be cooler.

If it is a PHP script, the script itself can be written to run stand-alone with a PHP interpreter. hrmmmm an interpreter interpreting and interpreted language. Insane, I tell ya! INSANE!

2) If going the web way, some kind of repository feature could be added where code can be exchanged or loaded
from the internet and then pumped directly into classic99.

Neat. We could become code-hippies.

3) Writing such a tool without knowing if the community will actually use it, can be *very* frustrating.
I kinda get the same feeling with spectra2. The motivation that keeps me going is that I'm convincing myself I'll
get use of it for my future stuff, sooner or later :|

I suspect that as more homebrewers see the power of your library, it will get used for other games. "Pitfall!" is just a start to demonstrate its power. As I invest more time in expanding my knowledge of TMS-9900 assembly and the TI itself, I have some games I would love to work out on the TI, and an existing library as a game-oriented operating system available is very valuable.

4) The value of such translator could be improved if there is a more easy way to get the code into the emulators.
Perhaps Tursi could help out there for classic99 (see 2)
Ofcourse the idea of macro expansion mentioned earlies also sound very cool.


More so than copy-n-paste?

#42 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,072 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sat Feb 12, 2011 12:05 PM

Hey, matthew,

I put "32010" as my starting line number and the translator changed it back to "100".

EDIT:

Also, this block
Spoiler

Did not give "SetJ" a line number, so the output is
Spoiler

Edited by OLD CS1, Sat Feb 12, 2011 1:31 PM.


#43 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Sat Feb 12, 2011 5:00 PM

ok, here are my thoughts:

1) You would need some kind of standalone version, without having to connect to the internet.
I'm a web guy, but for this type of application a standalone version would be cooler.

2) If going the web way, some kind of repository feature could be added where code can be exchanged or loaded
from the internet and then pumped directly into classic99.


Yes, you do need a desktop version, unless the editor and emulator were also web-based. I've thought about that a lot with HTML5's promises, as well as JavaScript's power. Heck, my kids play full-blown first-person games "in the browser" (currently via Flash), but I have seen some impressive HTML5 too.)

3) Writing such a tool without knowing if the community will actually use it, can be *very* frustrating.
I kinda get the same feeling with spectra2. The motivation that keeps me going is that I'm convincing myself I'll
get use of it for my future stuff, sooner or later :|


Ahhh. Here is the biggest problem. I wrote the web based version for two reasons. 1. I know PHP really well and it came together quickly. 2. Making the web version was a lot faster and easier than a desktop version. Plus, *everyone* can use the web version (Win, Mac, Unix). If there was enough interest, then I was going to move forward with a desktop version. I'm still not sure if there is enough interest to warrant the work.

As for something like Spectra2, personally I think it is an excellent piece of work, but I'm not sure how many people in our small community will actually take advantage of it? Unfortunately, I think the people who want to make games want to use a higher level language.

I have come to the conclusion that, if you do something for a retro-computer, you better be doing first and foremost because you *want* to use whatever it is you are making. Then if people get excited about it or use it too, then that is a bonus. I made the BASIC translator because I hate having to deal with line numbers and the lack of indentation or labels. I also did it because I like to make tools and because I want to make a full-blown interpreted language, eventually.

4) The value of such translator could be improved if there is a more easy way to get the code into the emulators.
Perhaps Tursi could help out there for classic99 (see 2)
Ofcourse the idea of macro expansion mentioned earlies also sound very cool.


There definitely has to be a better, faster, easier way to get the code into an emulator.

#44 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Sat Feb 12, 2011 5:01 PM

Hey, matthew,

I put "32010" as my starting line number and the translator changed it back to "100".


I will look into those errors. Thanks for the feedback!

#45 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,072 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sat Feb 12, 2011 9:04 PM

Ahhh. Here is the biggest problem. I wrote the web based version for two reasons. 1. I know PHP really well and it came together quickly. 2. Making the web version was a lot faster and easier than a desktop version. Plus, *everyone* can use the web version (Win, Mac, Unix). If there was enough interest, then I was going to move forward with a desktop version. I'm still not sure if there is enough interest to warrant the work.


Is there a "distributable" PHP interpreter? I have a number of administration scripts I wrote in PHP which use the command line interpreter.

As for something like Spectra2, personally I think it is an excellent piece of work, but I'm not sure how many people in our small community will actually take advantage of it? Unfortunately, I think the people who want to make games want to use a higher level language.


I think this is sadly true. There is a BASIC programming environment for the Atari 2600, and I bet digging a little bit turns up several BASIC-type languages for other console platforms. Having said that, I think that programmers who want real power, especially on the TI, will be quite accepting of Spectra2. As well, having a framework available may just entice new programmers to the realm.

#46 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,072 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sat Feb 12, 2011 9:16 PM

I will look into those errors. Thanks for the feedback!


The code block which was not producing the line number for one of the labels now works. It have one last suggestion: the ability to define starting line numbers for certain blocks. Kind-of like an AORG directive, giving the ability to assign specific blocks starting as specific numbers. Perhaps
#NUM 1500,5
with the ,5 being the optional increment.

I am using it to put together test blocks as I work on "Tiles." (Since a lot of my development notes are in essentially compatible pseudo-code, I could probably convert my entire program, now.) I think I am going to use it fully with my next rewrite.

EDIT: Okay, I was wrong. I have another suggestion: forced REMarks in the output. This would allow for program or section headers, and ease of finding blocks within the output. Something like
Begin:
CALL CLEAR
CALL SCREEN(<img src='http://www.atariage.com/forums/public/style_emoticons/<#EMO_DIR#>/icon_cool.gif' class='bbc_emoticon' alt='8)' />
#REM ASK USER FOR NAME
AskName:
INPUT "WHAT IS YOUR NAME?":NAME$
IF NAME$<>"OLD CS1" THEN NotLying
PRINT "YOU'RE LYING!  TRY AGAIN!"
GOTO AskName
NotLying:
#REM USER ENTERED A CORRECT NAME
PRINT "I AM HAPPY TO SEE THE TRUTH."
...

I am not going to show the expected output, as I suspect it is fairly obvious.

Thanks for all the work. I see this as a quite powerful tool.

Edited by OLD CS1, Sat Feb 12, 2011 9:25 PM.


#47 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Sat Feb 12, 2011 9:43 PM

The problem with the line numbers was, I had the max limit set to 32000. XB imposes a 32767 line number limit, which the code now supports. If the program tries to number higher than that, it will dump out an error.

The other problem the the label not being assigned a line number was due to there not being a space after the SNG() function and the word "THEN". I tested on real XB and if you type:
100 IF SGN(X) THEN 200

XB will suck out the space and produce:

* Space gets sucked out here
100 IF SGN(X)THEN 200

* Space is left alone here
200 IF X=1 THEN 300

Gotta love those nuances... Anyway, I made the converter aware of expressions (anything in parens), which includes functions, and it corrected the problem. Thanks for finding that problem!

I might be able to add the "block" ability, let me see how easily that will go in. I had thought of that originally, but I figured I would never really work with the line-number version of the code, it really didn't matter.

As for running on Windows, yes you can get PHP for Windows and run the script. I think there is even some sort of tool for making a GUI with PHP. It has been a long time since I looked in to it though. But I would probably just use C for a native GUI solution. I don't know, maybe not. In the mean time, does anyone want the code to run on their own machine?

#48 OLD CS1 OFFLINE  

OLD CS1

    River Patroller

  • 4,072 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sat Feb 12, 2011 10:26 PM

The problem with the line numbers was, I had the max limit set to 32000. XB imposes a 32767 line number limit, which the code now supports. If the program tries to number higher than that, it will dump out an error.

The other problem the the label not being assigned a line number was due to there not being a space after the SNG() function and the word "THEN". I tested on real XB and if you type:

100 IF SGN(X) THEN 200

XB will suck out the space and produce:

* Space gets sucked out here
100 IF SGN(X)THEN 200

* Space is left alone here
200 IF X=1 THEN 300

Gotta love those nuances... Anyway, I made the converter aware of expressions (anything in parens), which includes functions, and it corrected the problem. Thanks for finding that problem!


You are welcome. Yeah, TI BASIC does that, too. The output is directly from Classic99 LIST "CLIP" paste-job (well, with minor modifications.)

As for running on Windows, yes you can get PHP for Windows and run the script. I think there is even some sort of tool for making a GUI with PHP. It has been a long time since I looked in to it though. But I would probably just use C for a native GUI solution. I don't know, maybe not. In the mean time, does anyone want the code to run on their own machine?


I have PHP installed on my machines. I was thinking more in terms of like a simple redistributable like Microsoft provides for VC++, etc. I thought there might be a CLI-only installation for Windows: nope. Then I looked at PHP compilers: I found a couple, but nothing free. Ah, well.

I would be interested in looking at the source. If you put a link to the file on your site with a .phps extension, the server *should* expose the source. That way we can see it "live."

For example, I have a map script I wrote with the file name of "map.php" then a link "map.phps" pointing to the .php file. So, if you access map.php, it runs the script. If you access map.phps, it shows the source.

#49 matthew180 OFFLINE  

matthew180

    River Patroller

  • Topic Starter
  • 2,414 posts
  • Location:Castaic, California

Posted Sun Feb 13, 2011 1:27 AM

Ok, I made some changes:

1. Remarks. Instead of having a "special" remark token like #REM, I figured I would just retain any existing REM statements, and remove the C/C++ style // remarks. So, any comments you want to "go away", use //. Any you want in your final code, use REM.

2. Forced line numbers. I added support for recognizing existing line numbers to override the internal counter. So, every line can start with a line number now if you want. This will make it easier to convert existing code, as well as support the forced line numbers for subroutines or other code sections.

Here is an example of forcing the line numbers:

REM TI BASIC Translator Example
A=1
Loop:
    GOSUB disp
    A=A+1
    IF A<10 THEN Loop
// Loop End
END

1000 disp:
    PRINT A
RETURN

100 REM TI BASIC Translator Example
110 A=1
120 GOSUB 1000
130 A=A+1
140 IF A<10 THEN 120
150 END
1000 PRINT A
1010 RETURN

EDIT: I added the source code to the first post in this thread.

Edited by matthew180, Sun Feb 13, 2011 1:42 AM.


#50 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 8,261 posts
  • Location:Cookeville, TN

Posted Tue Feb 15, 2011 11:05 PM

Hey Matthew... quick question. I tried to input the following:

   A=1
B  PRINT A:
   A=A+1
   GOTO B

and received the following code output:

100 A=1
110 B  PRINT A:
120 A=A+1
130 GOTO B

Then I tried using a number for a "label" instead of B and the following was the resulting code:

Code In:

   A=1
1  PRINT A:
   A=A+1
   GOTO 1

Code Out:

100 A=1
1 PRINT A:
11 A=A+1
21 GOTO 1

So... Neither of these was my intended output... The first try (label B) would be a syntax error in XB or BASIC because of line 110. The second try (label 1) started with line number 100 and then went to 1,11,21.... Now, I am 100% positive that this is just me not knowing how to input this code properly. I don't REALLY understand indention all that well, so I'm wondering if there is a short lesson somewhere (other than the one on TIdBiT) that I can read to learn? I noticed the default example and I want to know "why." I'm really using this particularly because I have a concept in my head that is probably much better suited to this kind of language. In other words, I don't know the best way to do what I want to do in BASIC or XB code... I'm creating a menu system for my RPG, and the line numbers are killing me. I feel like I'm running a bunch of electrical wires everywhere with no real plan.... Spaghetti would be an understatement. I'd like to use TIdBiT for this part of my project, I just need to learn a bit more about the syntax, that's all. =) Great program though... I can't wait until I know how to use it better.




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users