Author Topic: nCHIP8  (Read 1921 times)

0 Members and 1 Guest are viewing this topic.

Offline Mighty Moose

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 141
  • Rating: +4/-0
    • View Profile
nCHIP8
« 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.
Cheers!
I beta test, so...yeah.  PM me if you want me to test anything :D.

Almost only counts in horseshoes and handgrenades.

Cogito ergo sum.

Calcs:
TI-84+, OS 2.43, Boot Code 1.02, 128k RAM
TI-84+SE VSC, OS 2.43, Boot Code 1.00, 128k RAM  (I'm spoiled :P)
TI-81, OS 1.6K (only borrowed)
Casio fx-CG10 (Prizm), OS 01.04.0200
TI-Nspire Clickpad, OS 1.4
TI-Nspire Clickpad, OS 3.1.0.392
TI-Nspire CAS Clickpad, OS 1.6.10110 (!?) now OS 3.1.0.392

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55828
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: nCHIP8
« Reply #1 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.

« Last Edit: May 17, 2012, 12:52:06 am by DJ_O »
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: nCHIP8
« Reply #2 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.
« Last Edit: May 17, 2012, 12:56:37 am by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Mighty Moose

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 141
  • Rating: +4/-0
    • View Profile
Re: nCHIP8
« Reply #3 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).
« Last Edit: May 17, 2012, 01:07:07 am by Mighty Moose »
Cheers!
I beta test, so...yeah.  PM me if you want me to test anything :D.

Almost only counts in horseshoes and handgrenades.

Cogito ergo sum.

Calcs:
TI-84+, OS 2.43, Boot Code 1.02, 128k RAM
TI-84+SE VSC, OS 2.43, Boot Code 1.00, 128k RAM  (I'm spoiled :P)
TI-81, OS 1.6K (only borrowed)
Casio fx-CG10 (Prizm), OS 01.04.0200
TI-Nspire Clickpad, OS 1.4
TI-Nspire Clickpad, OS 3.1.0.392
TI-Nspire CAS Clickpad, OS 1.6.10110 (!?) now OS 3.1.0.392

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55828
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: nCHIP8
« Reply #4 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. <_<
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline Mighty Moose

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 141
  • Rating: +4/-0
    • View Profile
Re: nCHIP8
« Reply #5 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.)
Cheers!
I beta test, so...yeah.  PM me if you want me to test anything :D.

Almost only counts in horseshoes and handgrenades.

Cogito ergo sum.

Calcs:
TI-84+, OS 2.43, Boot Code 1.02, 128k RAM
TI-84+SE VSC, OS 2.43, Boot Code 1.00, 128k RAM  (I'm spoiled :P)
TI-81, OS 1.6K (only borrowed)
Casio fx-CG10 (Prizm), OS 01.04.0200
TI-Nspire Clickpad, OS 1.4
TI-Nspire Clickpad, OS 3.1.0.392
TI-Nspire CAS Clickpad, OS 1.6.10110 (!?) now OS 3.1.0.392

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nCHIP8
« Reply #6 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?

Offline Mighty Moose

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 141
  • Rating: +4/-0
    • View Profile
Re: nCHIP8
« Reply #7 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!
« Last Edit: May 17, 2012, 05:27:58 pm by Mighty Moose »
Cheers!
I beta test, so...yeah.  PM me if you want me to test anything :D.

Almost only counts in horseshoes and handgrenades.

Cogito ergo sum.

Calcs:
TI-84+, OS 2.43, Boot Code 1.02, 128k RAM
TI-84+SE VSC, OS 2.43, Boot Code 1.00, 128k RAM  (I'm spoiled :P)
TI-81, OS 1.6K (only borrowed)
Casio fx-CG10 (Prizm), OS 01.04.0200
TI-Nspire Clickpad, OS 1.4
TI-Nspire Clickpad, OS 3.1.0.392
TI-Nspire CAS Clickpad, OS 1.6.10110 (!?) now OS 3.1.0.392

Offline Mighty Moose

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 141
  • Rating: +4/-0
    • View Profile
Re: nCHIP8 [Working Title]
« Reply #8 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!
Cheers!
I beta test, so...yeah.  PM me if you want me to test anything :D.

Almost only counts in horseshoes and handgrenades.

Cogito ergo sum.

Calcs:
TI-84+, OS 2.43, Boot Code 1.02, 128k RAM
TI-84+SE VSC, OS 2.43, Boot Code 1.00, 128k RAM  (I'm spoiled :P)
TI-81, OS 1.6K (only borrowed)
Casio fx-CG10 (Prizm), OS 01.04.0200
TI-Nspire Clickpad, OS 1.4
TI-Nspire Clickpad, OS 3.1.0.392
TI-Nspire CAS Clickpad, OS 1.6.10110 (!?) now OS 3.1.0.392