Jump to content
OLD CS1

TI BASIC performance tips?

Recommended Posts

Are there any good tips for helping increase the performance of TI BASIC programs?

 

I have whipped out several of my old TI BASIC programs from ages past with the intention of cleaning them up and applying more of what I have learned over the years. Though, what I have learned has come from other platforms.

 

In particular, in Microsoft BASIC on the Commodore 64 and 128 I was taught to use a "jump" table at the beginning of the program (consisting of GOTOs at static locations) to use for subroutines, along with the subroutines at lower line numbers than the main portions of the programs. The idea being first that having a static "jump" (probably taken from JMP tables used in ML) locations were easier to track and maintain in code than GOSUBs which could move around, and that GOSUBs and GOTOs search from the beginning of the program for their targets, thus having subroutines at the beginning of the program supposedly made things run a little faster.

 

Now, my understanding of the inner-workings of TI BASIC is that a table of line numbers is kept which point to the line's location in memory. In theory, searching a table would be faster than to search through a program which is constructed from a linked list. Which would be correct for TI BASIC?

 

Another thing I have done is try to reduce the amount of math the program has to do, by changing IF-THENs with things like "IF S=0 THEN" to "IF S THEN", or ON-GOTOs, etc.

 

I have also decided to pick up where I left off with machine language. I programmed some simple support routines using the line-by-line editor with MiniMemory for a couple of TI BASIC games, but I think I will like to convert them fully to ML at some point.

 

(A quick special thanks to Tursi for Classic99, which has been indispensable in re-writing my programs, as well as the authors of CS1er and Tape994A for helping me get my programs into the emulated environment, and even back to the real TI-99/4A.)

Share this post


Link to post
Share on other sites

I don't know if this interests you, but there is a TI Basic compiler that takes your BASIC code and converts it into machine code. Increases speed (in some cases) up to 30-40 times faster. Usually you will have to add delay loops to make your games even playable. :) Check out TIGameshelf.net. Look in the assembly section for a game called TI Puck by W. Maalouli. It is just this... Wilhelm's compiler can be downloaded there. Welcome to our forum. :)

Edited by Opry99er

Share this post


Link to post
Share on other sites

I don't know if this interests you, but there is a TI Basic compiler that takes your BASIC code and converts it into machine code. Increases speed (in some cases) up to 30-40 times faster. Usually you will have to add delay loops to make your games even playable. :) Check out TIGameshelf.net. Look in the assembly section for a game called TI Puck by W. Maalouli. It is just this... Wilhelm's compiler can be downloaded there. Welcome to our forum. :)

 

Thanks for the welcome. I'll check the BASIC compiler, as well. I like the idea very much, and used Blitz! on the Commodore 64.

 

Later in my programming days I started using CALL SOUND statements to program my waits to allow for more accuracy. Though most games rely on the inherent slowness of TI BASIC to give it playability, so I will definitely have to compensate in ML. I don't suppose the compiler optimizes shoddy BASIC programming? heheheh Many of the games I wrote were between 8 and 14 years of age, some later even though I had pretty much already transitioned to the Commodore 64. So, I am looking at my code and were it not for my age at the time of writing I would be pretty embarrassed!

 

As I work on them, I'll post them into my profile files, if those are public. I don't mind people perusing my crappy old code. The majority of them are conversions from COMPUTE! Magazine after it dropped the TI-99/4A from its monthly program listings. I wrote to COMPUTE! and received permission to write and distribute conversions (actually from ABC Publications, IIRC.) I have the letter in storage somewhere, need to find it and scan it.

Share this post


Link to post
Share on other sites

That's so cool, that you wrote to Compute! to ask permission for the conversions. I love that kind of stuff. Welcome to the group! There's a lot of various shenanigans going on around here, from me still plugging away writing BASIC games to these other guys doing note-perfect Pitfall! and Tutankham clones, sound digitizers, new programming languages, you name it. This community is small, but it's mighty.

 

Another way you can share pieces of BASIC code is to just cut and paste them right here in a message. Just about everyone here's using an emulator and, with Classic99 at least, we can just paste it in and type RUN. (not as sure about the other emulators; I have only used the one.) There are special hash tags to make code more readable - they look like greater-than and less-than signs in the toolbar of the HTML message editor.

 

Again, welcome, looking forward to your old-school code!

 

Keith

Share this post


Link to post
Share on other sites

Yea man... If you've got Classic99, all you need is TI-99Dir, a free program that has many features--- one of which is the ability to "look" at a program listing stored in DSKx.. You can copy and paste from there onto this forum and we can give you real help, if you need it. Also, straight TI BASIC programs can be put onto cartridge. :). I use Extended BASIC mainly.... SPRITEs are a necessity for most of the games I write. Chek out the "Development Resources" thread at the top of this forum.... Tons of brilliant materials to help move your code forward.

 

In addition--- you can zip up one of your programs an attach it to this thread. Using "full editor", you can simply click "attach file" and we will be able to DL it like that, in case you'd rather do that than paste code.

 

Posting in a code box is cool, though.

100 CALL CLEAR
110 PRINT "WELCOME TO ATARIAGE!!"
120 FOR I=2 TO 16
130 CALL SOUND(200,220,30)
140 CALL SCREEN(I)
150 NEXT I
160 GOTO 120

 

Select the text and copy.... Open Classic99 to TI BASIC or TI Extended BASIC (under utility cartridges) and select Edit (dropdown menu) then select "Paste". Type RUN. Bam....

Edited by Opry99er

Share this post


Link to post
Share on other sites

Yea man... If you've got Classic99, all you need is TI-99Dir, a free program that has many features--- one of which is the ability to "look" at a program listing stored in DSKx.. You can copy and paste from there onto this forum and we can give you real help, if you need it. Also, straight TI BASIC programs can be put onto cartridge. :). I use Extended BASIC mainly.... SPRITEs are a necessity for most of the games I write. Chek out the "Development Resources" thread at the top of this forum.... Tons of brilliant materials to help move your code forward.

 

In addition--- you can zip up one of your programs an attach it to this thread. Using "full editor", you can simply click "attach file" and we will be able to DL it like that, in case you'd rather do that than paste code.

...snip..

Select the text and copy.... Open Classic99 to TI BASIC or TI Extended BASIC (under utility cartridges) and select Edit (dropdown menu) then select "Paste". Type RUN. Bam....

 

Thanks, guys! hehehe you guys make it sound like I had "real" development hardware back-in-the-day. Sadly, it was just me, the console, and a TI Program Recorder. Well, until 1990 when a guy in town loaned me one of his PEBs for a few months. I should have bought it from him, but I had spent my hard-earned paper route money on an SX-64. I did manage to develop one last program during that time which wound up on floppy (which brings me to a point later.)

 

Indeed, Classic99 is excellent! I actually use the CLIP device quite a bit to move listings, and the paste feature is definitely invaluable for prototyping (genius, Tursi!) Even though I could use TIDir, Tape994a or CS1er, I suppose. I do very much like the syntax highlighting the AA code tag provides. Don't worry, I'll be posting in whatever formats I can -- you guys are cool with 300 lines of BASIC posted in a message??

 

Quick point I mentioned above, I have a PEB now. I just purchased a WHT SCSI card for it, for which I am looking for a suitable drive (I, unfortunately, dumped all my small SCSI drives which I used with my Amigas thinking I would never need a 20MB drive again *sigh*) Anyway, my real point is that my PEB has two DSDD drives in it, and I am searching for a DSDD floppy controller to replace my stock PHP-1240. I have seen two pop up on eBay recently, one of which I got sniped on. If anyone has one they wouldn't mind parting with, I would gladly entertain an offer.

 

I like the idea of moving my TI BASIC games to cartridge -- it would fulfill my young dreams of writing a game good enough to do just that. (My last game actually has a line in the instruction screen "DISTRIBUTED BY ASGARD SOFTWARE", which it never was.)

 

I most likely won't be working on anything this weekend as I have test on Tuesday for which I need to prepare. But I will be posting my work as I take on each clean-up project. I would like to have polished listings available to contrast with my original horrible, horrible code.

 

Which brings me to one last question. My last game was "Block Battle," and I programmed three editions specifically for the Mini Memory and Extended BASIC: Mini Memory without ML, Mini Memory with ML support, and Extended BASIC, all for an unexpanded console. The problem is the ML support routines and code for the Mini Memory which are loaded using Easy Bug, for which you are limited to CS1. Is there a way for me to dump and load that to and from a disk file? It's not relocatable as the routines reference static memory locations and the character and screen definitions are expected to be in specific locations, as well as the "I'm here" marker the BASIC program checks to see if the routines are loaded. I would appreciate any thoughts on this.

Share this post


Link to post
Share on other sites

One nice thing you can do is add a hidden code box.

 

 

 

this way, you can post a million lines of code and it's only accessible if you click on the box.

100 CALL CLEAR
110 CALL SCREEN(7)
120 PRINT "ATARIAGE HAS SOME"
130 PRINT "COOL FEATURES"
140 GOTO 140

 

 

Edited by Opry99er

Share this post


Link to post
Share on other sites

What I usually do is write a piece of code and increment a variable in a loop for a minute or so. When the minute is up I stop the program and examine the value of the variable.

 

I will then re-write the code a few times with different ideas and do the same test. Sometimes I am very surprised by the results and can pick-up 20% speed from writing something differently, even though I thought the first code was pretty slick.

 

I am not sure how much difference this makes once the program is finished and is executed, but I guess as a cumulative effect throughout the program it should be noticeable.

  • Like 1

Share this post


Link to post
Share on other sites

What I usually do is write a piece of code and increment a variable in a loop for a minute or so. When the minute is up I stop the program and examine the value of the variable.

 

I will then re-write the code a few times with different ideas and do the same test. Sometimes I am very surprised by the results and can pick-up 20% speed from writing something differently, even though I thought the first code was pretty slick.

Very good idea for optimizing - actually on any level/stage of development. :thumbsup:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...