Author Topic: [Lua] CHIP-8 emulator  (Read 10034 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
[Lua] CHIP-8 emulator
« 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.





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 :)
« Last Edit: December 08, 2012, 07:24:32 pm by Jim Bauwens »

Offline ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: [Lua] CHIP-8 emulator
« Reply #1 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?

Some people need a high five in the face... with a chair.
~EC

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: [Lua] CHIP-8 emulator
« Reply #2 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.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [Lua] CHIP-8 emulator
« Reply #3 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.

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: [Lua] CHIP-8 emulator
« Reply #4 on: December 08, 2012, 03:22:15 pm »
How is this possible? I thought lua couldnt open files?
This used to contain a signature.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: [Lua] CHIP-8 emulator
« Reply #5 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 :)
« Last Edit: December 08, 2012, 03:29:34 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: [Lua] CHIP-8 emulator
« Reply #6 on: December 08, 2012, 03:27:17 pm »
I plan to add support for opening external ROM files ;)
That is most certainly possible.

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: [Lua] CHIP-8 emulator
« Reply #7 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
This used to contain a signature.

Offline excale

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 103
  • Rating: +19/-1
    • View Profile
Re: [Lua] CHIP-8 emulator
« Reply #8 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. :)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: [Lua] CHIP-8 emulator
« Reply #9 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.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: [Lua] CHIP-8 emulator
« Reply #10 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
This used to contain a signature.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Lua] CHIP-8 emulator
« Reply #11 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.

Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: [Lua] CHIP-8 emulator
« Reply #12 on: December 09, 2012, 04:33:29 pm »
Vinegar also has sound O.O
This used to contain a signature.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [Lua] CHIP-8 emulator
« Reply #13 on: December 09, 2012, 05:26:09 pm »
you wrote dat emulator in lua? O.o pretty cool! :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Lua] CHIP-8 emulator
« Reply #14 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