Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: KermMartian on January 24, 2012, 07:29:22 pm

Title: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: KermMartian on January 24, 2012, 07:29:22 pm
Note: crossposted from the Cemetech topic (http://www.cemetech.net/forum/viewtopic.php?t=7339), which will hold updates and such.
For many years, perhaps since I first designed the fledgling version of SourceCoder 2.5 (http://sc.cemetech.net/), I have wanted to make a Javascript graphing calculator emulator.  SourceCoder has a keypad that lets you enter tokens and symbols into its editor, but imagine if you could have a real calculator emulator right on the page to test your programs! Imagine if you could do BASIC development and testing online without having to touch an offline emulator or real calculator! This was my dream, but a combination of limited technology, limited experience, and legal hurdles restricted me from following through.

No longer.

First, the legal hurdles.  It is illegal to distribute ROM images, so I couldn't make an emulator with a ROM image hosted on Cemetech.  I couldn't even let people upload their own ROM images, or in any way let ROM images touch the Cemetech server.  HTML 5 offers a solution to this conundrum in the form of what is called DOM Storage (https://developer.mozilla.org/en/DOM/Storage).  Cemetech gives the javascript for my z80 core to clients, and they load their (legal, I hope) ROM image from their own personal calculator into their browser, but still entirely client-side.  No ROMs are distributed in any form.

Second, the technical hurdles.  The canvas element (http://en.wikipedia.org/wiki/Canvas_element) of HTML4/5 is powerful and fast enough to be manipulated and display a smooth image of a calculator screen in real-time.  Modern computers and modern Javascript implementations are fast enough to run the massive code required for an emulated 6MHz CPU at faster than realtime.  In addition, tools such as Google's Closure Compiler (http://code.google.com/p/closure-compiler/) exist to optimize and compress Javascript for speed and size.

In a total of about four days separated by two months, I have put together jsTIfied, pronounced "justified", a Javasdript TI-83+ emulator.  It is not ready for any public testing or release, and thus is sitting happily offline and not anywhere on Cemetech, but I'm proud to announce that it is fully-functional.  As you can see from the screenshots below, I can do math, run applications, and I assure you, almost everything else an emulator such as PindurTI (http://sgate.emt.bme.hu/patai/pindurti/) can do.  Indeed, I owe a debt of thanks to Gergely Patai (or Patai Gergely), the author of the original PindurTI, for swathes of C code that I studied for jsTIfied, and for the key layout that I used for jsTIfied.  In homage to PindurTI, I made the appearance resemble that much-loved emulator.  I also owe thanks to JSSpeccy (http://jsspeccy.zxdemo.org/), a Javascript ZX Spectrum emulator that heavily contributed to my understanding of emulating a z80 processor, and some segments of code from which found their way into jsTIfied, especially in helping me to wrap my head around emulating interrupts.

I have great plans for jsTIfied, including letting you somehow test programs from the archives, run SourceCoder projects, and much more straight from your browser.  Before that can happen, there are plenty of tweaks and changes for smoothness to be made and features to be added, so for now, enjoy the screenshots below!

(http://www.cemetech.net/img/news/jstified1_1.png) (http://www.cemetech.net/img/news/jstified1_2.png)
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: Juju on January 24, 2012, 08:54:33 pm
I can't wait to see this, Kerm! And for the legal hurdles, you could use a free and open-source ROM?
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: KermMartian on January 24, 2012, 10:15:07 pm
I can't wait to see this, Kerm! And for the legal hurdles, you could use a free and open-source ROM?
Sure, but the way this is designed, if you read the legal paragraph, even if a user uses a ROM from their real TI calculator, the ROM doesn't leave their computer, so everything is above-board.
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: shmibs on January 25, 2012, 02:51:34 am
true, but an open source solution still might be worth looking into at some point down the line, as many of the people who would look for a solution like this one are likely to be people who don't know how to dump a ROM, or don't have a linking cable.

i love the idea of integrating it into the site's archives! something that coule fetch and execute files from ticalc would be very useful as well.
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: Juju on January 25, 2012, 03:34:31 am
I can't wait to see this, Kerm! And for the legal hurdles, you could use a free and open-source ROM?
Sure, but the way this is designed, if you read the legal paragraph, even if a user uses a ROM from their real TI calculator, the ROM doesn't leave their computer, so everything is above-board.
Well, I mean, if you don't want to make the user choose a ROM.

But still, the user could choose a ROM, then the files get uploded to the newly created calc automatically, it still sounds good.
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: JosJuice on January 25, 2012, 11:31:30 am
I can't wait to see this, Kerm! And for the legal hurdles, you could use a free and open-source ROM?
The problem is that fully usable FOSS OSes are pretty much non-existent. WFRNGOS might work, but it might not be very useful to emulate it :P
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: DJ Omnimaga on January 25, 2012, 03:31:16 pm
That is great and looks pretty promising. I'm happy you figured out a way to not have the ROM file land on the server on which the emulator runs. How goes cross-browser compatibility and bandwidth usage? I remember Netham45 made an emulator which was online for a while, but the problem is that the ROM was hosted by him (even though it was from his own calc it was not very legal) and every screen frame (around 5 per second), the produced GIF image was downloaded from the server to your computer. Basically after using it for several minutes, you wasted several megabytes of bandwidth. Due to both these problems, he didn't leave it online for very long (around 2 weeks).
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: KermMartian on January 25, 2012, 05:03:32 pm
Cross-browser compatibility seems fine to me so far.  It uses about 150KB of download to send the emulator to the client, then nothing else.  Again, it's almost entirely client-side.
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: FinaleTI on January 25, 2012, 07:26:46 pm
This sounds really cool! I can't wait to see it in action.
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: TIfanx1999 on January 27, 2012, 03:07:55 am
This sounds very promising Kerm. Like others, I'm anticipating playing around with this. :)
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: KermMartian on February 06, 2012, 02:24:01 pm
As either a general update or a potential newsy thing, public beta of jsTIfied:

http://www.cemetech.net/news.php?id=501

(http://www.cemetech.net/img/news/jstified2_1.jpg) (http://www.cemetech.net/img/news/jstified2_2.jpg)
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: Juju on February 06, 2012, 02:36:05 pm
Awesome Kerm! That emulator is working pretty fine, it doesn't support 84+ ROMs though.
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: DJ Omnimaga on February 06, 2012, 05:05:24 pm
Pretty great. I'll have to give it a try on my next visit to Cemetech. Btw the layout reminds me greatly of PindurTI :P
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: parserp on February 06, 2012, 05:11:39 pm
wait, will this have the ability to take screenshots?
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: KermMartian on February 06, 2012, 05:32:09 pm
DJ_O: Yes, the skinless mode is an homage to PTI, which I mentioned in the first news article I wrote about jsTIfied
Parser: Just right-click the screen and choose "save image" in most browsers.
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: parserp on February 06, 2012, 05:38:04 pm
well, yes, but what about animated screenshots?
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: DJ Omnimaga on February 06, 2012, 07:52:49 pm
Oh I meant how the icons above the calculator screen area, along with the Aqua borders, were pretty similar to PTI style :D, but yeah I see about the skinless mode now lol. Now to see how well this runs Zelda Dark Link Quest (that thing almost runs in nothing <_<)
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: TIfanx1999 on February 07, 2012, 08:13:55 am
Hey a beta! I'll have to play with it when I have some time. :)
Title: Re: [InDev] jsTIfied, a Javascript TI-83+ Emulator
Post by: Stefan Bauwens on February 14, 2012, 02:59:25 pm
Somehow I had missed this topic, which caused me to probably be even more surprised than anyone else when I saw this in the news. :P

I tried this and I was pleasantly surprised. I had looked already for online emulators but never found one.
Once more Good job Kerm. :)
I'm looking forward to the moment I can try ticalc.org games . ;)