CHIP-8 interpreter on NES! (expansion RAM)

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

Post Reply
User avatar
NovaSquirrel
Posts: 374
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

CHIP-8 interpreter on NES! (expansion RAM)

Post by NovaSquirrel » Mon Jul 16, 2018 8:46 pm

Image
I threw this together in a day, somewhat based on my Conway's Life code. It's set to use MMC1 but doesn't actually write to any MMC1 registers, only using it for the extra RAM emulators grant it.

This demo runs breakout, using left and right to move the paddle. You could replace it with something else, though Blinky wouldn't run when I tried.

One big problem I ran into is that despite the sprite drawing being incredibly inefficient (calls a routine for every single pixel that should be flipped), games still run way too fast. If games actually used the timer it would be fine, but many don't seem to, so I need some sort of instruction limiter. This ROM just runs one instruction per frame.
Attachments
CHIP-8.zip
source and ROM
(13.65 KiB) Downloaded 240 times
chip.nes
(24.02 KiB) Downloaded 258 times

tepples
Posts: 21755
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by tepples » Mon Jul 16, 2018 9:02 pm

This is the last piece of the puzzle. Thank you for building it. I hereby offer to donate money to the first person to make a video of running a CHIP-8 game in this interpreter in PocketNES in VBA GX in Dolphin in VirtualBox. Bwonng!

As for speed: How fast does the original CHIP-8 interpreter run on an RCA 1802?

User avatar
tokumaru
Posts: 11470
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by tokumaru » Mon Jul 16, 2018 9:16 pm

That's cool! I figured it wouldn't be hard to get CHIP-8 games running, but this was extremely quick! And holy crap, 1 instruction per frame and games still work OK? That's insane!

User avatar
NovaSquirrel
Posts: 374
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by NovaSquirrel » Mon Jul 16, 2018 9:42 pm

The main problem speed-wise is that all graphics are drawn with XOR, so everything moving tends to flicker, and you need to be able to catch it when it's actually displaying. I was having problems where the ball was just invisible at high speeds. The interpreter also can't update the screen in a single frame, and it needs two, because of how many tiles it needs to draw. Maybe I could OR some frames together and display that to minimize flicker?

User avatar
NovaSquirrel
Posts: 374
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by NovaSquirrel » Mon Jul 16, 2018 10:33 pm

Here's a faster version that, instead of waiting a frame every instruction, waits two frames every draw instruction instead, to make sure every change is visible. Makes Breakout way more like an actual game, and from what I can tell the original interpreter added a delay after drawing too.

Still would be good to reduce flicker if I can.
Attachments
chip.nes
(24.02 KiB) Downloaded 245 times
CHIP-8.zip
(13.67 KiB) Downloaded 228 times

User avatar
tokumaru
Posts: 11470
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by tokumaru » Mon Jul 16, 2018 10:44 pm

Yeah, the main issue with CHIP-8 and flicker is that anything that moves must be erased and drawn again, so if you update the screen after an object is erased but before it's drawn again, you get flicker.

One solution I've seen was to not update the screen until a few instructions have passed since the last DRAW command. This would in theory give the game time to move all it's objects, or at very least not render frames where objects are invisible.

With so much free screen space, you could use some forced blanking to update the entire playfield at 60Hz, or you could use the second name table for double buffering and do it at 30Hz.

tepples
Posts: 21755
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by tepples » Fri Sep 07, 2018 1:03 pm

Yo dawg, it looks like it's been done on Super NES too now. See Super Chip8x

User avatar
orlaisadog
Posts: 167
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by orlaisadog » Mon Sep 10, 2018 9:49 am

Does this have anything to do with my thread?

User avatar
NovaSquirrel
Posts: 374
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: CHIP-8 interpreter on NES! (expansion RAM)

Post by NovaSquirrel » Mon Sep 10, 2018 6:27 pm

orlaisadog wrote:Does this have anything to do with my thread?
Mine was, hence the intentionally similar thread title. I wanted to show how easy it would be to just knock out a simple interpreter if extra RAM was used, so I just went and did that in a day.

Post Reply