Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Deep Toaster on September 16, 2011, 10:42:40 pm

Title: Jazz: JavaScript TI-83 Plus emulator
Post by: Deep Toaster on September 16, 2011, 10:42:40 pm
As some of you may know, I've decided to take on the project of a full TI-83 Plus emulator written in JavaScript. In other words, it'll be a webapp calculator that anyone could pull up whenever they're on a computer that's online.

First, I did the reality checks. There have been emulators in JavaScript already, including Two9A's (https://github.com/Two9A/jsGB) and Pedro Ladaria's (http://www.codebase.es/jsgb/) GameBoy emulators (with a GBZ80 engine) and JSSpeccy (http://matt.west.co.tt/spectrum/jsspeccy/), which uses a true Z80. The other major constraint is memory, and Eeems checked that for me with a benchmark too (http://eeems.dyndns.org:1337/benchmark.html) that shows that most browsers can handle far more than the 2 or so megabytes needed to emulate a TI-84 Plus. So it's definitely possible.

I finally started working on it today. It's located at http://clrhome.tk/resources/jazz/ (http://clrhome.tk/resources/jazz/), where I'll be testing individual instructions until I get all of them down. Right now it only has ADC (I'm working through the alphabet), but I'd really appreciate it if people who know ASM could help play around to see if all the flags are being emulated correctly. And if any of you with ASM and JS experience wants to help, please tell me! :)
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: DrDnar on September 16, 2011, 10:45:55 pm
Check out http://z80.info/ (http://z80.info/) for lots of information about the Z80. There's the Zilog Z80 CPU user manual (PDF) that describes every instruction (though it has errors), as well as articles about undocumented instructions. Pretty good resources.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Deep Toaster on September 16, 2011, 10:51:18 pm
I use that all the time, and even got 28D listed on the page :)
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Eeems on September 16, 2011, 10:58:34 pm
Btw, my benchmark script is now located on http://eeems.omnimaga.org/Files/benchmark.html if you want to be able to access it when my laptop is not online :P
I'm really looking forward to this :) Let me know if you need any help with anything at all, I'll be happy to provide whatever assistance I can :)
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: ralphdspam on September 16, 2011, 11:37:57 pm
Sounds like a great idea!  I would love to use a TI-83 Plus emulator on a public computer.  :)

What are you going to do about the copyrighted OS, though?
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Juju on September 17, 2011, 02:38:25 am
Yeah sounds like a great idea. Can't wait to see this.

I guess the page would ask for an OS file.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Netham45 on September 17, 2011, 02:42:07 am
Make it take a URL for an image too, so we can keep one on our servers so we don't have to have one on our phones, etc...
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Builderboy on September 17, 2011, 05:21:40 am
I mirror the question about how you are going to manage to bypass the OS copywrite issue o.O
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Lionel Debroux on September 17, 2011, 07:26:57 am
Users will somehow have to provide the OS image to the emulator.

With the powerful JIT engines built into the JS interpreters of modern browsers, JS is fast enough for emulating a PC running Linux: http://bellard.org/jslinux/ . Therefore, a 83+ emulator ought to be doable in JS :)
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Deep Toaster on September 17, 2011, 10:00:47 am
Yeah, you'll have to somehow provide the image yourself. I'll definitely have it support saving ROMs too.
With the powerful JIT engines built into the JS interpreters of modern browsers, JS is fast enough for emulating a PC running Linux: http://bellard.org/jslinux/ . Therefore, a 83+ emulator ought to be doable in JS :)
That is amazing.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Xeda112358 on September 17, 2011, 10:03:42 am
... Unless we use a community created OS... :D This sounds really cool! I won't need to use windows calculator anymore :D
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: apcalc on September 17, 2011, 11:38:11 am
This sounds very interesting!  I look forward to seeing future progress! :)
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Eeems on September 17, 2011, 02:53:18 pm
Users will somehow have to provide the OS image to the emulator.

With the powerful JIT engines built into the JS interpreters of modern browsers, JS is fast enough for emulating a PC running Linux: http://bellard.org/jslinux/ . Therefore, a 83+ emulator ought to be doable in JS :)
Ok, that's just epic
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: XVicarious on September 17, 2011, 02:57:42 pm
I love running:
Code: [Select]
su
rm -r -f /*
on it. :)

edit: yeha, what jimbauwens said, it will mess shit up bad. DO NOT RUN ON YOUR OS!
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Jim Bauwens on September 17, 2011, 02:58:34 pm
Ehm, warning to all other Linux users/newbies, don't run this on your production machine!
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: XVicarious on September 17, 2011, 02:59:31 pm
Yeah edited with a warning :P
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Eeems on September 17, 2011, 03:01:25 pm
I love running:
Code: [Select]
su
rm -r -f /*
on it. :)

edit: yeha, what jimbauwens said, it will mess shit up bad. DO NOT RUN ON YOUR OS!
Don't you mean:
Code: [Select]
su
rm -rf /
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: XVicarious on September 17, 2011, 03:03:24 pm
Works the same I believe.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Eeems on September 17, 2011, 03:06:20 pm
Works the same I believe.
yes it does, but this is the more efficient way of typing it :P
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: XVicarious on September 17, 2011, 03:07:09 pm
Pfft efficiency :P
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: sqrt(Time) on September 17, 2011, 08:37:25 pm
Looking at your Javascript, you're using eval() a lot, and that will slow things down a lot. Better to have an associative array connecting the name of each function to the actual function (one of the cool features of JS!), and then find the function from that array and call it. Something like
Code: [Select]
o={"adc_aa":adc_aa,"adc_ab":adc_ab,"adc_ac":adc_ac};
/* ...stuff... */
o[$('select').val()]();
Naturally, you can (and should!) eliminate the other evals too.
The Jquery can be sluggish, so it'll be good to do something along the lines of
Code: [Select]
selectBox=$('select');
/* replace everything else with the variable selectBox instead.. */

I'm not saying that a browser wouldn't be able to run this comfortably already, but with each layer of interpretation and emulation things get slower, and *especially* eval() will slow things down by a factor of 20 (maybe 100? maybe less..) easily.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Yeong on September 17, 2011, 08:50:56 pm
I love running:
Code: [Select]
su
rm -r -f /*
on it. :)

edit: yeha, what jimbauwens said, it will mess shit up bad. DO NOT RUN ON YOUR OS!
Don't you mean:
Code: [Select]
su
rm -rf /
what does it do?
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Goplat on September 17, 2011, 08:57:53 pm
rm -r removes an entire directory tree, and / is the root directory. So it deletes every file on your computer.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Yeong on September 17, 2011, 08:59:54 pm
Looks terrible. O.O
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: XVicarious on September 17, 2011, 09:00:19 pm
rm -r removes an entire directory tree, and / is the root directory. So it deletes every file on your computer.


don't forget "-f" makes it not ask permission before deleting things.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Deep Toaster on September 17, 2011, 09:26:40 pm
Looking at your Javascript, you're using eval() a lot, and that will slow things down a lot.
I know. This is just temporary so I can easily test stuff. When I turn it into an actual emulator (which seems to be some time in the far future), the commands will be stored in an array of functions, or an array of arrays of functions for those with multiple bytes.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Eeems on September 18, 2011, 02:12:02 am
I've been doing some research of my own for personal reasons on the topic of emulating in a browser, you might find this interesting:
http://bellard.org/jslinux/tech.html
http://www.khronos.org/registry/typedarray/specs/latest/
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: DJ Omnimaga on September 18, 2011, 02:57:54 am
Interesting project. I just hope you keep cross-browser compatibility in  mind, though, such as Opera.
Title: Re: Jazz: JavaScript TI-83 Plus emulator
Post by: Eeems on September 18, 2011, 03:00:33 am
With cross browser in mind, make sure if you use the datatype I mentioned in the links above have it detect if it should use standard arrays or that type instead.