{"id":288,"date":"2009-08-24T19:28:09","date_gmt":"2009-08-25T03:28:09","guid":{"rendered":"http:\/\/www.pagetable.com\/?p=288"},"modified":"2009-08-24T19:28:09","modified_gmt":"2009-08-25T03:28:09","slug":"ti-994a-basic-as-a-scripting-language","status":"publish","type":"post","link":"https:\/\/www.pagetable.com\/?p=288","title":{"rendered":"TI-99\/4A BASIC as a Scripting Language"},"content":{"rendered":"<p>It is a good time for statically recompiled versions of BASIC from old computers.\u00c2\u00a0 First there was <a href=\"\/?p=35\">Apple I BASIC<\/a>.\u00c2\u00a0 Then came <a href=\"\/?p=48\">Commodore BASIC<\/a>.\u00c2\u00a0 Now, due to overwhelming demand, we&#8217;re proud to release <a href=\"http:\/\/ti99basic.sourceforge.net\/\">TI-99\/4A BASIC<\/a>.  For those unfamiliar the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Texas_Instruments_TI-99\/4A\">TI-99\/4A<\/a> was a home computer by Texas Instruments released in 1981.  Unusually for the time it had a 16-bit CPU: the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Texas_Instruments_TMS9900\">TMS9900<\/a>.<\/p>\n<p>Download the program from the <a href=\"http:\/\/sourceforge.net\/projects\/ti99basic\/\">project page on SourceForge<\/a>.  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&#8217;d love hear about it.<\/p>\n<p>It supports the same interfaces as the previous projects.\u00c2\u00a0 You can use it interactively in direct mode:<\/p>\n<pre>$ tibasic\nTI BASIC READY\n&gt;print 4*atn(1)\n 3.141592654\n\n&gt;bye<\/pre>\n<p>Or you can write a line-numbered program:<\/p>\n<pre>$ tibasic\n&gt;10 FOR I=1 TO 10\n&gt;20 PRINT TAB(I);\"Hello, world!\"\n&gt;30 NEXT I\n&gt;RUN\nHello, world!\n Hello, world!\n  Hello, world!\n   Hello, world!\n    Hello, world!\n     Hello, world!\n      Hello, world!\n       Hello, world!\n        Hello, world!\n         Hello, world!\n\n** DONE **\n\n&gt;BYE<\/pre>\n<p>You can also run programs from a file:<\/p>\n<pre>$ cat name.bas\n10 INPUT \"What is your name? \":N$\n20 PRINT \"Hello, \";N$;\"!\"\n\n$ tibasic.exe name.bas\nWhat is your name? James\nHello, James!<\/pre>\n<p>There are a few sample programs available on the <a href=\"http:\/\/ti99basic.sourceforge.net\/\">homepage<\/a> that you can run in this manner.<\/p>\n<h3>How it works<\/h3>\n<p>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\u00c2\u00a0 support for the TI-99\/4A is by James Abbatiello.<\/p>\n<p>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.<\/p>\n<p>There are a couple quirks of the TI-99\/4A which made this a bit trickier to support than the C64 version:<\/p>\n<ul>\n<li>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.<\/li>\n<li>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.<\/li>\n<\/ul>\n<h3>Limitations<\/h3>\n<p>The Cassette, Disk, and Sound devices are not currently emulated.  Contributions in these areas are most welcome.<\/p>\n<h3>Links<\/h3>\n<ul>\n<li><a href=\"ftp:\/\/ftp.whtech.com\/datasheets%20and%20manuals\/99-4A%20Computer\/99-4A%20User%20Reference%20Guide.pdf\">User Reference Guide<\/a> (The original TI-99\/4A manual)<\/li>\n<li><a href=\"http:\/\/www.nouspikel.com\/ti99\/titech.htm\">The TI-99\/4A Tech Pages<\/a><\/li>\n<li><a href=\"http:\/\/www.99er.net\/download2\/index.php?act=view&amp;id=102\">TI-99\/4A Intern<\/a> contains a commented listing of the TI-99\/4A ROM and GROM<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>It is a good time for statically recompiled versions of BASIC from old computers.\u00c2\u00a0 First there was Apple I BASIC.\u00c2\u00a0 Then came Commodore BASIC.\u00c2\u00a0 Now, due to overwhelming demand, we&#8217;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 &#8230; <a title=\"TI-99\/4A BASIC as a Scripting Language\" class=\"read-more\" href=\"https:\/\/www.pagetable.com\/?p=288\" aria-label=\"Read more about TI-99\/4A BASIC as a Scripting Language\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,17],"tags":[],"class_list":["post-288","post","type-post","status-publish","format-standard","hentry","category-basic","category-hacks"],"_links":{"self":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288"}],"version-history":[{"count":0,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/288\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}