Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Jim Bauwens on December 08, 2012, 02:54:57 pm

Title: [Lua] CHIP-8 emulator
Post by: Jim Bauwens on December 08, 2012, 02:54:57 pm
A couple of days ago I started to port a Lua based CHIP-8 emulator I found online to the TI-Nspire.
Yesterday I got it working, and after fixing some emulator bugs and improving/optimizing the overall code I can say that it's already quite decent.


(http://i.imgur.com/Mbd0B.jpg)
(http://i.imgur.com/yBN3W.jpg)

As you can see in the video, there are still some issues with screen flickering (well, actually invaders is the only game that really has a problem with that).
Space Invaders runs a little slow, but it's one of the more complex CHIP-8 games.
Blitz, Tetris, Brix, Vbrix and some other games I tested run basically at full speed.

I'm still going to try to optimize the screen drawing part, but I'm already very happy with the result :)
Title: Re: [Lua] CHIP-8 emulator
Post by: ElementCoder on December 08, 2012, 02:57:26 pm
This looks awesome, though I have no idea what CHIP-8 is :P some sort of old computer system?
Title: Re: [Lua] CHIP-8 emulator
Post by: Jim Bauwens on December 08, 2012, 03:01:20 pm
CHIP-8 is a kind of virtual machine, with it's own instruction set and hardware. It was created in the 80's for some consoles in that time, allowing games to run on multiple different architectures.
Title: Re: [Lua] CHIP-8 emulator
Post by: TIfanx1999 on December 08, 2012, 03:09:03 pm
Wow, great work Jim! There is also a Z80 asm implementation of this floating around on Ticalc somewhere.
Title: Re: [Lua] CHIP-8 emulator
Post by: annoyingcalc on December 08, 2012, 03:22:15 pm
How is this possible? I thought lua couldnt open files?
Title: Re: [Lua] CHIP-8 emulator
Post by: Adriweb on December 08, 2012, 03:26:14 pm
Nspire-Lua can't, indeed, with io.* things as in normal lua, but here, the game is put as a one-big-line-array thing embedded directly in the script :)
The emulator itself not being huge at all, each .tns contains the game and the emulator ^^

Edit : as Jim said in the next post, you can actually "import" stuff from outside : math/basic variables from documents located in MyLib folder, in fact :)
Title: Re: [Lua] CHIP-8 emulator
Post by: Jim Bauwens on December 08, 2012, 03:27:17 pm
I plan to add support for opening external ROM files ;)
That is most certainly possible.
Title: Re: [Lua] CHIP-8 emulator
Post by: annoyingcalc on December 08, 2012, 03:30:13 pm
Nspire-Lua can't, indeed, with io.* things as in normal lua, but here, the game is put as a one-big-line-array thing embedded directly in the script :)
The emulator itself not being huge at all, each .tns contains the game and the emulator ^^

Edit : as Jim said in the next post, you can actually "import" stuff from outside : math/basic variables from documents located in MyLib folder, in fact :)
Oh, ok thanks for clarifying
Title: Re: [Lua] CHIP-8 emulator
Post by: excale on December 08, 2012, 04:01:16 pm
I plan to add support for opening external ROM files ;)
That is most certainly possible.

Well, luaext could be used for this purpose. :)
Title: Re: [Lua] CHIP-8 emulator
Post by: Lionel Debroux on December 08, 2012, 04:05:27 pm
For this purpose and so many others, yeah. It's a perfect example of the power of native code and its complementarity with TI's narrow-minded views. TI is silly to try and prevent the inevitable access to native code.
Title: Re: [Lua] CHIP-8 emulator
Post by: annoyingcalc on December 08, 2012, 11:16:24 pm
Can you post an aplha soon, Id like to look into the source (to see how an emulator works) and I think lua would be a good place for me to start since I know lua
Title: Re: [Lua] CHIP-8 emulator
Post by: DJ Omnimaga on December 09, 2012, 03:55:40 pm
Very nice. I might try it when it comes out.

Wow, great work Jim! There is also a Z80 asm implementation of this floating around on Ticalc somewhere.

Yep, it's called Vinegar, by Benryves, and it supports both CHIP-8 and SCHIP.
Title: Re: [Lua] CHIP-8 emulator
Post by: annoyingcalc on December 09, 2012, 04:33:29 pm
Vinegar also has sound O.O
Title: Re: [Lua] CHIP-8 emulator
Post by: Sorunome on December 09, 2012, 05:26:09 pm
you wrote dat emulator in lua? O.o pretty cool! :D
Title: Re: [Lua] CHIP-8 emulator
Post by: DJ Omnimaga on December 09, 2012, 06:30:34 pm
Annoyingcalc really?? O.O I didn't remember that... that's even better

Also Jim's emu is really in Lua? O.O
Title: Re: [Lua] CHIP-8 emulator
Post by: Jim Bauwens on December 10, 2012, 01:11:33 am
Yes, the emulator is fully in Lua ^^

Will see to make a decent release soon.
Title: Re: [Lua] CHIP-8 emulator
Post by: DJ Omnimaga on December 11, 2012, 03:13:30 pm
How does the speed compare with the original thing? I couldn't find the Space Invader and Breakout clones shown in the first post so I couldn't compare.
Title: Re: [Lua] CHIP-8 emulator
Post by: Jim Bauwens on December 12, 2012, 02:16:11 pm
Well, there isn't a 'real' thing, but the only other CHIP-8 emulator I tested was slower :P
But maybe I just didn't test a good one ^.^
Title: Re: [Lua] CHIP-8 emulator
Post by: DJ Omnimaga on December 12, 2012, 02:48:09 pm
If it was on the computer, then  how did an emulator of a '80s device  manage to be slower on a GHz processor speed machine? O.O
Title: Re: [Lua] CHIP-8 emulator
Post by: Jim Bauwens on December 12, 2012, 03:11:14 pm
If it was on the computer, then  how did an emulator of a '80s device  manage to be slower on a GHz processor speed machine? O.O
Well, it was made in Javascript. But still, it could have been faster.
Or I'm just emulating too fast...