Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Mighty Moose on May 17, 2012, 12:24:19 am

Title: nCHIP8
Post by: Mighty Moose on May 17, 2012, 12:24:19 am
Well, I was going to post about this when I had this complete, but it appears hoffa beat me to the punch <_<

Anyways, I have a (mostly :P) complete CHIP8 interpreter written in C.  I started this last Friday and really haven't touched it since (mostly because I've been out of town).  Ironically, the only problem I'm really having is working with the Nspire's screen, so if someone could look at my code and see what I'm doing wrong/give me some pointers* in the right direction, that would be great.

I am using the setPixel routine from the ndless example source code.  chip->LCD is a 2,048 (64x32) byte array with each element presumably holding a 1 if the pixel is set and a 0 if it is reset.
Code: [Select]
if (chip->drawflag)
{
for(int row = 0; row < 32; row++)
{
for(int col = 0; col < 64; col++)
{
/*ignore the comments if you must
                                                        for(int rowoffs = 0; rowoffs < 8; rowoffs++){
for(int coloffs = 0; coloffs < 8; coloffs++){
setPixel(col + coloffs, row + rowoffs, (0x0F * (chip->LCD[32*row + col])) ^ 0x0F);
}
}*/
setPixel(col, row, (0x0F * (chip->LCD[32*row + col])) ^ 0x0F);

}
}
}

Now, I think this is all fine and dandy, but I get something that looks like garbled junk when trying to run SPACEINVADERS (see attached pic).

???

Can anyone help?  Thanks in advance.

MM

*Pun so totally intended.
Title: Re: nCHIP8
Post by: DJ Omnimaga on May 17, 2012, 12:48:19 am
Interesting, I remember there was such emulator on the 83+, but I wondered if one would make it for the TI-Nspire. But yeah Hoffa ported SDL to the Nspire which lets him run a CHIP8 emulator on it. It would be nice to see someone make a totally standalone version, though. :)

By the way did the CHIP8 support colors? Also do you have plans for SCHIP emulation like the 83+ version? http://www.ticalc.org/archives/files/fileinfo/385/38530.html

Anyway hopefully someone can help soon, although it might be best to re-ask the question in the help section in case it gets missed in the projects section.

Title: Re: nCHIP8
Post by: Juju on May 17, 2012, 12:55:52 am
You can try some games in your browser here: http://chip.emulationcollective.com/

From what I see, it features a small monochrome screen (the pixels are oversized so it looks decent) and a hex keypad.
Title: Re: nCHIP8
Post by: Mighty Moose on May 17, 2012, 01:01:14 am
Interesting, I remember there was such emulator on the 83+, but I wondered if one would make it for the TI-Nspire. But yeah Hoffa ported SDL to the Nspire which lets him run a CHIP8 emulator on it. It would be nice to see someone make a totally standalone version, though. :)

By the way did the CHIP8 support colors? Also do you have plans for SCHIP emulation like the 83+ version? http://www.ticalc.org/archives/files/fileinfo/385/38530.html

Anyway hopefully someone can help soon, although it might be best to re-ask the question in the help section in case it gets missed in the projects section.



Yeah, if you look at the topic description, I'm planning on an including an SCHIP8 interpreted as well (lol it's not that much more).  I believe the original CHIP8 "machine" was intended for black-and-white displays, so no colors :(.

This project is mostly just practice and experience for me :P

Edit: I'll probably mess around with the source some more, just to see if I can get it to work (right now, I've only put ~2-3 hours into it).
Title: Re: nCHIP8
Post by: DJ Omnimaga on May 17, 2012, 01:25:50 am
Oh ok it's SCHIP8?  Thanks for the correction. Also I think that one had a larger screen, right?

Btw I wish the new posts list showed topic descriptions. <_<
Title: Re: nCHIP8
Post by: Mighty Moose on May 17, 2012, 10:37:45 am
Oh ok it's SCHIP8?  Thanks for the correction. Also I think that one had a larger screen, right?

Btw I wish the new posts list showed topic descriptions. <_<

Whoops, my bad :P.  It's usually abbreviated as SCHIP, but I've seen it as SCHIP8, CHIP-48, or Super CHIP8 before.

(Also, I will scale up the screen size (to take advantage of the Nspire's larger screen and to work with the SCHIP) once I figure out how or get some help to get the screen display working.)
Title: Re: nCHIP8
Post by: lkj on May 17, 2012, 01:53:06 pm
I am using the setPixel routine from the ndless example source code.  chip->LCD is a 2,048 (64x32) byte array with each element presumably holding a 1 if the pixel is set and a 0 if it is reset.
Code: [Select]
if (chip->drawflag)
{
for(int row = 0; row < 32; row++)
{
for(int col = 0; col < 64; col++)
{
/*ignore the comments if you must
                                                        for(int rowoffs = 0; rowoffs < 8; rowoffs++){
for(int coloffs = 0; coloffs < 8; coloffs++){
setPixel(col + coloffs, row + rowoffs, (0x0F * (chip->LCD[32*row + col])) ^ 0x0F);
}
}*/
setPixel(col, row, (0x0F * (chip->LCD[32*row + col])) ^ 0x0F);

}
}
}

Now, I think this is all fine and dandy, but I get something that looks like garbled junk when trying to run SPACEINVADERS (see attached pic).
Shouldn't it be setPixel(col, row, (0x0F * (chip->LCD[64*row + col])) ^ 0x0F); ? Or am I wrong?
Title: Re: nCHIP8
Post by: Mighty Moose on May 17, 2012, 02:33:56 pm
Oh lol, silly me, that works perfectly now!  I can't believe I missed that.  Thanks lkj! +1 for you.

Now to solve the other issues...

Edit: Well, I suppose this is ok progress (something sorta works), so here is an initial release.

Make sure to put it in a folder called "nCHIP8."

Enjoy!
Title: Re: nCHIP8 [Working Title]
Post by: Mighty Moose on May 18, 2012, 06:33:19 pm
OK, here's a small update

v0.2a.12.5.18 - 5/18/12
* fixed a bug in keypress handling that caused keys that had already been pressed to continue to be pressed.
* added support for the Casio PRIZM :w00t:

Bugs:
Problems with the way sprites are being drawn - not quite sure what it is though D:

TODO:
Optimize this to make it faster :P
Implement SCHIP instructions

Enjoy!