Tim Hentenaar's Blog

Nov 16, 2009 16:08

TI Basic Simulator

Recently I wrote a TI Basic (not Extended Basic) simulator as a proof of concept to determine whether or not such a simulator would be feasable in Javascript. Why TI Basic? Because it was the first programming language I ever learned. Yes, I still have a working TI-99/4A to this day. :-)

PRINT is implemented enough to print simple values, and expressions. the ";" modifier isn't implemented. However, statements such as LET, IF-THEN-ELSE, FOR-NEXT, GOSUB-RETURN, DIM, most math functions, RANDOMIZE/RND, the CHAR subroutines, and most other commands have been implemented.

Timing in Javascript is often inexact. This is the primary problem when developing any sort of simulation in Javascript. I can't wait until HTML 5 becomes fully adopted and a worker thread can be utilized to separate the UI from the rest of the simulation. A concept like this (and even more complex concepts) would be much easier to implement.

Below, you can try it out for yourself. I've only tested this in Firefox 3.5, and lightly in Opera 10.01 (Note: It actually seems to execute faster in Opera, which is no surprise, but the cursor display is a little quirky at the end of a line.), so I'm uncertain whether it will work in other browsers at the moment. I just wanted to put this out there, and share it with the world. Perhaps I'll optimize this eventually, and implement the other pieces. It'd be interesting to see some of those old programs running right in the browser. :-P

As far as I know, I'm the first to ever create such a thing...

Simply click on the "screen" below, or just start typing. The left and right arrow keys move the cursor in the respective direction, backspace works like a charm, and you don't have to worry about remembering the TI's keyboard layout. :-P

Update: 11/25/2012 - The arrow keys and backspace don't seem to work in Chrome, but they do in Firefox 17.0. I'll investigate when I get some time. :P