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
>print 4*atn(1)


Or you can write a line-numbered program:

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

** DONE **


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.


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


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

  1. 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! :)

  2. 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?

  3. 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.

  4. 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!

  5. 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.

  6. 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.

  7. 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?

  8. 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…

  9. 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.

  10. 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.

  11. 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…

  12. Six years late, but thank you for posting this as I KNEW the days of the TI, ZX, Commodore, and solid state/prom basic would be coming back. I have been feverishly trying to code a Win/Linux implementation of CoCo2’s Color Extended Basic for the same purposes.

    Do let me know how the project is fairing as I am digesting all the resources you have provided!


Leave a Reply to Jonathan Hoyle Cancel reply