TI-99/4A BASIC as a Scripting Language

It is a good time for statically recompiled versions of BASIC from old computers.  First there was Apple I BASIC.  Then came Commodore BASIC.  Now, due to overwhelming demand, we’re proud to release TI-99/4A BASIC. For those unfamiliar the TI-99/4A was a home computer by Texas Instruments released in 1981. Unusually for the time it had a 16-bit CPU: the TMS9900.

Download the program from the project page on SourceForge. Binaries for Windows and Mac OS X are available and the source should compile on most POSIX-like systems. If you port it to a new platform please drop us a line; we’d love hear about it.

It supports the same interfaces as the previous projects.  You can use it interactively in direct mode:

$ tibasic
TI BASIC READY
>print 4*atn(1)
 3.141592654

>bye

Or you can write a line-numbered program:

$ tibasic
>10 FOR I=1 TO 10
>20 PRINT TAB(I);"Hello, world!"
>30 NEXT I
>RUN
Hello, world!
 Hello, world!
  Hello, world!
   Hello, world!
    Hello, world!
     Hello, world!
      Hello, world!
       Hello, world!
        Hello, world!
         Hello, world!

** DONE **

>BYE

You can also run programs from a file:

$ cat name.bas
10 INPUT "What is your name? ":N$
20 PRINT "Hello, ";N$;"!"

$ tibasic.exe name.bas
What is your name? James
Hello, James!

There are a few sample programs available on the homepage that you can run in this manner.

How it works

This program works much like the already mentioned Commodore BASIC project. The original program is statically recompiled to produce a new native binary. The recompiler is the work of Michael Steil and the  support for the TI-99/4A is by James Abbatiello.

The output of the recompiler is tibasic.c which is platform independent. The support functions are in runtime_functions.c and it is this file that you would edit to port to a new system or to add new features.

There are a couple quirks of the TI-99/4A which made this a bit trickier to support than the C64 version:

  • The BASIC interpreter was not written in assembly language as you might expect. Instead it was programmed in something called Graphics Programming Language (GPL). GPL was much like an assembly language with some high-level primitives for commonly needed functions. A program written in GPL would be assembled to bytecode and then run on an interpreter that was written in TMS9900 assembly language. This made BASIC programs on the machine rather slow. The CPU would execute the GPL interpreter. The GPL interpreter would run the BASIC interpreter. Finally, the BASIC interpreter would run your program. Only the TMS9900 code is statically recompiled in this program. The GPL still runs interpreted just as it did on the original machine. While it would theoretically be possible to statically recompile the GPL code as well this would be significantly more difficult since GPL was never officially documented by TI. The only definitive reference is the original interpreter.
  • C64 BASIC outputs characters to the screen via one function (CHROUT) which was easy to trap. TI-99/4A BASIC outputs to the screen with direct writes to video memory from multiple different places in the code. This requires some ugly hacks to get anything approximating reasonable on stdout.

Limitations

The Cassette, Disk, and Sound devices are not currently emulated. Contributions in these areas are most welcome.

Links

19 thoughts on “TI-99/4A BASIC as a Scripting Language

  1. sgt_burns

    you want a TI-99 hack?

    Came up with this when I was young! lol

    You know (with out extended basic) its possible to get sprites to appear?

    That its also possible to crash the computer….

    With a remark statement!

    10 REM

    edit the line when your done (if I remember rite ctrl-u= with programing word ramdomize keep going past the last ramdomize statement (will take a while) and youi’ll reach what you think is the end…. the (trying to remember) hold down either space or enter or the down or right arrows…. and the system will start freaking out! :)

    Reply
  2. Jonathan Hoyle

    I was able to get this to work well on both my Mac OS X 10.4 PowerMacs, but on neither of my Mac OS X 10.5 Intel-based Macs. Is there something I am doing incorrectly?

    Reply
  3. Jonathan Hoyle

    The problem with the binary you have is the 64-bit side fails. If you strip the 64-bit target (x86_64) with lipo, leaving only a 32-bit universal binary (PPC & Intel), it works fine.

    I recommend recompiling the binary without the 64-bit portion until you have resolved your bug. Otherwise, most Intel Mac users (who typically have 64-bit ready machines) will not be able to run your app.

    Reply
  4. ti99_forever

    Cool! Windows 7 was made for me! Oh wait, I mean “TI Basic as a scripting language was made for me!”.
    When I first saw the CBM and Apple Basics, I asked for this, and now I have it!
    Wonderful!

    Reply
  5. Michael Steil

    Yes, the 64 bit piece is broken on Mac OS X. If it does not work for you, prepend “arch -arch i386″ to your command line for now.

    Reply
  6. Jonathan Hoyle

    Sadly, there has been no change in this program in the year since its first release. The Mac version continues to crash on Intel 64-bit machines. What started out so promising has atrophied into irrelevance. Very bummed.

    Reply
  7. FTG

    If I’m not mistaken didn’t the BASIC on TI-99/4A have PEEK and POKE omitted so a hobbyist could never run machine code on it? What a howler! Crippling a potentially very impressive home computer (for the time).

    I’ve always thought it must have been a deliberate strategy to make people buy the expensive game cartridge ROMs (that were coded in machine language and often very good, e. g. Parsec). I think the system might have flourished otherwise. Anyone who was at TI in that era shed any light?

    Reply
  8. MiaM

    If I remember correct PEEK were added if you had “extended basic” but still no POKE. Bummer, a perfect way to make sure almost noone writes any good software (especially games) for your machine…

    Reply
  9. Canada Goose

    With the Extended Basic and a 32 KB memory extension one could PEEK and POKE from Basic (with the LOAD subprogram), so programming the TI 99 in machine code was possible. Yet, the assembler sold by TI also required a disk drive. As an alternative, you could assemble by hand or write your own assembler in Basic.

    Reply
  10. Jonathan Hoyle

    I’d be interested to see if the Extended Basic source could be obtained to port, as the original TI-99 Basic here was. It probably wouldn’t require a lot of work to reverse engineer.

    Reply
  11. Pingback: [download movies][download games][download music][forum warez][game full download][download scripts][watch online movies][movis][games][software][scripts]

  12. Pingback: Portal Jezykow Obcych

  13. Gordon

    Why have an emulator when I have my original computer. Nice to see the work some people are prepared to do to keep things alive.
    I’m transferring some programs from tape to minidisc, saves having to ff and rw a tape.

    Kudos and well done.

    Now, where’s my Parsec cartridge…

    Reply
  14. Pingback: Why is my TI-99/4A in Black and White? « pagetable.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>