CodeWalrus

Development => Consoles => Topic started by: Ivoah on February 23, 2016, 03:51:04 am

Title: CHIP-8 emulator
Post by: Ivoah on February 23, 2016, 03:51:04 am
So as some people lurking in IRC already know, I started work on a CHIP-8 emulator a little under a year and a half ago. I just picked it back up a couple days ago, and have made some major progress. It was originally written in C++, and I wanted to first write it for the computer using SDL, and then port it to the Nspire, hence the name "nCHIP-8." The C++ to C conversion was surprisingly easy! I'm not sure I did it the right way, but at least it works. Basically, I put all the data stuff in a struct, and renamed the functions to
chip8_blah()
All the functions take a pointer to a chip8 struct as their first argument, and then just edit that.

I've ported it to the GBA, and it runs great, except for a few bugs in the actual core that I need to fix.
(https://sr.ht/cCzo.gif)

As the CHIP-8 has 16 buttons and the GBA only has 10, I have to make a keymap for each game. If you want to try out Space Invaders here's a ROM you can run on an emulator (or real hardware): https://sr.ht/MfIH.gba
I personally recommend mGBA (http://mgba.io/)

Next steps are (in no particular order):


The emulator core is pretty easy to use, and as such makes it a breeze to port to other platforms. The GBA port only took about an hour to go from SDL to GBA.
Source for everything is here: https://github.com/Ivoah/nCHIP-8
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 23, 2016, 04:18:43 am
Cool! As for the CE port, which I hope I can look forward to, maybe CEmu could be of assistance?
Title: Re: CHIP-8 emulator
Post by: Ivoah on February 23, 2016, 04:23:35 am
Quote from: Dudeman313 on February 23, 2016, 04:18:43 am
Cool! As for the CE port, which I hope I can look forward to, maybe CEmu could be of assistance?

Well, if I don't have a CE, then I don't have a CE ROM.
If any generous soul wants to donate a CE for the good of mankind, I certainly wouldn't turn them away ;)
Title: Re: CHIP-8 emulator
Post by: Max Leiter on February 23, 2016, 04:29:04 am
I think the problem is he needs a ROM, @Dudeman313


Looks super cool Ivoah, it's nice to finally see a topic after seeing you mention it in IRC all the time :)

@Ivoah ninja'd
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 23, 2016, 04:32:59 am
If it's illegal to transport a ROM file, is it also illegal to transport those ROM dump data segments that compiled into a ROM image? 'Cause I have those. ;)
Title: Re: CHIP-8 emulator
Post by: Ivoah on February 23, 2016, 04:34:38 am
Quote from: Dudeman313 on February 23, 2016, 04:32:59 am
If it's illegal to transport a ROM file, is it also illegal to transport those ROM dump data segments that compiled into a ROM image? 'Cause I have those. ;)


Yeah, it's illegal to share anything that has the ROM data in it.
Title: Re: CHIP-8 emulator
Post by: DJ Omnimaga on February 23, 2016, 05:47:03 am
Nice work Ivoah and the speed is impressive so far. There was a 83+ one by Benryves so I assume a CE version of your emulator would run fast enough. I remember there was also an HP Prime CHIP-8 emulator but it was much slower, partly due to being written in HP PPL (although still impressive per proprietary calculator language standards). Keep up the good work on this :3=
Title: Re: CHIP-8 emulator
Post by: Jim Bauwens on February 23, 2016, 09:43:59 am
If you want I have a small CHIP-8 'decompiler' I made in (PC) Lua, I used it understand what some games were doing when debugging an emulator.

Edit: all the files are here: https://github.com/jimbauwens/chip-8 (you might have to change the offset at the end of the decompiler)
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 23, 2016, 02:38:07 pm
@Ivoah : Go to Walmart, but a CE for about $125(If you have that money...) make a ROM, and return it. :P
Title: Re: CHIP-8 emulator
Post by: Ivoah on February 23, 2016, 02:39:04 pm
Quote from: Dudeman313 on February 23, 2016, 02:38:07 pm
@Ivoah : Go to Walmart, but a CE for about $125(If you have that money...) make a ROM, and return it. :P

I believe it'd be illegal to continue using the ROM
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 23, 2016, 02:56:02 pm
Why? That's not fair!  :banghead: I don't know how else I can help you, other than that. Unless you can finish the CE port within 90 days...
Title: Re: CHIP-8 emulator
Post by: aeTIos on February 23, 2016, 03:36:31 pm
You can borrow my ROM! I won't use my CE in the meantime! Honest!

:trollface:

Kidding aside, this looks pretty impressive! I really should get myself a flashcart for the GBA.
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 23, 2016, 06:38:06 pm
Okay, @Ivoah . Here's the plan... you gotta think like a  :ninja: . Maybe a  :ninja: :walrii: . Go to Walmart. Buy a CE. Use it to create a ROM. Do some testing and such. Eat food. 90 days later, delete the ROM. Return the CE. Buy another one. Keep being a  :ninja: . Create a new ROM. Think like a :walrii: . Eat food. Repeat until you finish the CE port. It's the perfect  :ninja: plan!  >:D

:walrii:
Title: Re: CHIP-8 emulator
Post by: Ivoah on February 23, 2016, 11:22:20 pm
Quote from: Dudeman313 on February 23, 2016, 06:38:06 pm
Okay, @Ivoah . Here's the plan... you gotta think like a  :ninja: . Maybe a  :ninja: :walrii: . Go to Walmart. Buy a CE. Use it to create a ROM. Do some testing and such. Eat food. 90 days later, delete the ROM. Return the CE. Buy another one. Keep being a  :ninja: . Create a new ROM. Think like a :walrii: . Eat food. Repeat until you finish the CE port. It's the perfect  :ninja: plan!  >:D

:walrii:


O.O das a lotta emoticons
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 23, 2016, 11:52:48 pm
Figures and placeholders are essential in any evil scheme. Did I say evil scheme? I meant elaborate plot.... >:D
Title: Re: CHIP-8 emulator
Post by: DJ Omnimaga on February 24, 2016, 01:28:19 am
You can probably just wait until June or August when various stores do big calculator sales. If you are lucky enough to find an European store that don't charge a lot for oversea shipping, then all you have to do is buy a TI-83 Premium CE for 90 euros then you just saved $20. Used ones might be cheaper, but some Ebay sellers might charge a lot for oversea shipping.

Else, you can wait until Canada got some for sale and take advantage of the poor exchange rate.
Title: Re: CHIP-8 emulator
Post by: Ivoah on February 24, 2016, 01:31:20 am
Quote from: DJ Omnimaga on February 24, 2016, 01:28:19 am
You can probably just wait until June or August when various stores do big calculator sales. If you are lucky enough to find an European store that don't charge a lot for oversea shipping, then all you have to do is buy a TI-83 Premium CE for 90 euros then you just saved $20. Used ones might be cheaper, but some Ebay sellers might charge a lot for oversea shipping.

Else, you can wait until Canada got some for sale and take advantage of the poor exchange rate.


~$80 is still a lot for a (soon to be) poor college student.
Title: Re: CHIP-8 emulator
Post by: DJ Omnimaga on February 24, 2016, 01:32:50 am
Yeah true. Hopefully you can save and buy one later, though :P
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 24, 2016, 02:33:42 am
Too bad DJ is so far from you. He could send you his CE. Or, you could always try GoFundme. What never worked for me might work for you... ;)
Title: Re: CHIP-8 emulator
Post by: Ivoah on February 24, 2016, 02:46:57 am
Quote from: Dudeman313 on February 24, 2016, 02:33:42 am
Too bad DJ is so far from you. He could send you his CE. Or, you could always try GoFundme. What never worked for me might work for you... ;)


Actually, DJ only lives ~6 hours away from me.
Title: Re: CHIP-8 emulator
Post by: DJ Omnimaga on February 24, 2016, 03:01:05 am
Kinda surprising considering we are in two different countries, but not surprising I guess if your city is close to the border.
Title: Re: CHIP-8 emulator
Post by: Ivoah on February 24, 2016, 03:02:27 am
Quote from: Dudeman313 on February 24, 2016, 02:33:42 am
Or, you could always try GoFundme.

Well, it's worth a shot: https://www.gofundme.com/ivoah
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on February 24, 2016, 03:43:02 am
You can't do it like that, @Ivoah! You must state your purpose,  explain your intentions, give several links to increase interest, make it all look fancy, share it everywhere you can with some photoshopped "would-be screenies," and add some sentimental reason exactly why you can't currently get the money! The way you are doing it now is the same way I tried, and I am currently posting from a Nokia E63, not a gleaming and frequently cleaned beautiful Android.
You must think like a :ninja: :walrii: !

EDIT

Quote
Wait, so, if DJ's not so far away, can't he just send you his CE? It's not like it's his only calculator. But you could always try to my :ninja: plan.
Title: Re: CHIP-8 emulator
Post by: Ivoah on March 03, 2016, 11:20:38 pm
Quote from: Dudeman313 on February 24, 2016, 03:43:02 am
Wait, so, if DJ's not so far away, can't he just send you his CE? It's not like it's his only calculator. But you could always try to invest(?) a plan.

Well, seeing as a TI-84+ CE is like $100 I doubt he'd just give it to someone on the internet. But hey, I wouldn't mind if he wanted to ;)
Title: Re: CHIP-8 emulator
Post by: aeTIos on March 03, 2016, 11:24:20 pm
Quote from: Ivoah on February 24, 2016, 02:46:57 am
Quote from: Dudeman313 on February 24, 2016, 02:33:42 am
Too bad DJ is so far from you. He could send you his CE. Or, you could always try GoFundme. What never worked for me might work for you... ;)


Actually, DJ only lives ~6 hours away from me.

You know your country is too big when you think 6 hours is close. Anything over 20 minutes away is far in my book. 6 hours gets me to france, dammit!
Title: Re: CHIP-8 emulator
Post by: Ivoah on March 03, 2016, 11:25:24 pm
Quote from: aeTIos on March 03, 2016, 11:24:20 pm
Quote from: Ivoah on February 24, 2016, 02:46:57 am
Quote from: Dudeman313 on February 24, 2016, 02:33:42 am
Too bad DJ is so far from you. He could send you his CE. Or, you could always try GoFundme. What never worked for me might work for you... ;)


Actually, DJ only lives ~6 hours away from me.

You know your country is too big when you think 6 hours is close. Anything over 20 minutes away is far in my book. 6 hours gets me to france, dammit!

It takes ~30 minutes to get to the nearest supermarket for me, so 6 hours isn't too crazy.
Title: Re: CHIP-8 emulator
Post by: kegwaan on March 04, 2016, 01:29:06 am
~6 hours would get me about 1/6 of the way across the country ('murica)
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on March 04, 2016, 02:52:03 am
Same!  :D
(https://codewalr.us/proxy.php?request=http%3A%2F%2Fpiskel-imgstore-b.appspot.com%2Fimg%2Fd663031c-ddb9-11e5-b1a7-9de9acbde201.gif&hash=f37351a48edd17a9c5c1cb6c158b2ff9)
Title: Re: CHIP-8 emulator
Post by: Ivoah on March 04, 2016, 02:53:10 am
mumble mumble off-topic much
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on March 04, 2016, 02:58:55 am
Quote from: Ivoah on March 04, 2016, 02:53:10 am
mumble mumble off-topic much

Got some more progress, screenies, a fancy progress bar, project website, or any money(or maybe improvements) from GoFundme?
And I wonder if you've considered checking eBay (http://ebay.com)? I saw a CE on sale, working but damaged, for $72. I don't know if it's still there, though.
Oh. DJ Omnimaga already suggested this. :-|
Title: Re: CHIP-8 emulator
Post by: DJ Omnimaga on March 04, 2016, 08:16:52 am
Quote from: aeTIos on March 03, 2016, 11:24:20 pm
Quote from: Ivoah on February 24, 2016, 02:46:57 am
Quote from: Dudeman313 on February 24, 2016, 02:33:42 am
Too bad DJ is so far from you. He could send you his CE. Or, you could always try GoFundme. What never worked for me might work for you... ;)


Actually, DJ only lives ~6 hours away from me.

You know your country is too big when you think 6 hours is close. Anything over 20 minutes away is far in my book. 6 hours gets me to france, dammit!
Yeah lol in Europe anyone can travel to any country in just a few hours in car. Canada and USA are just too big lol. BUt at least it's good that some people live close to me, if they ever want to visit me up there one Summer :P


Also yeah we should get back on topic. I wonder if the CSE would be fast enough for such emulator?
Title: Re: CHIP-8 emulator
Post by: aeTIos on March 04, 2016, 08:45:36 am
Definitely, the CHIP-8 has been emulated on a commodore 64 :P
Title: Re: CHIP-8 emulator
Post by: DJ Omnimaga on March 17, 2016, 08:25:31 am
But the CSE has that horribly slow LCD, though. It takes 0.25 seconds to draw a 320x240 filled rectangle in pure ASM. So a CHIP-8 emulator running in half-res mode would run at 8 FPS max if it needs to update the entire screen every frame, unless scanlines were used.
Title: Re: CHIP-8 emulator
Post by: Dudeman313 on March 20, 2016, 10:19:54 pm
@Ivoah , how's this going so far?