[IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RAM)
Moderator: Moderators
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
[IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RAM)
Second topic
"I want to see Chip-8 on NES so that I can extend an emulator stack one higher. Imagine Chip-8 emulator in PocketNES in VisualBoyAdvance GX in Dolphin in Wine in Virtual PC or VMware." - tepples
2 of the main problems I can think of are:
1) Screen resolution- Easy to solve, just have 16 tiles with all possible values of 4 bits to simulate 4x4 tiles
2) Memory- Without expansion RAM, the NES only has 2KB of RAM and CHIP-8 has 4KB. However, we can get an extra kilobyte from the unused nametable, and almost 512 bytes from the fact that some of the main nametable is unused. We can solve the garbage data with forced blanking (timed with sprite 0 hits and timed code) and get more time to read and write to the to the PPU midframe and use OAM memory (disabling sprites) or attribute tables (duplicating palettes) for the rest. Hopefully this will give us 3.5 KB, and 512 bytes are reserved for the interpreter on CHIP-8 so that should be enough. I haven't worked out the numbers so I may be wrong. We can get more memory for the interpreter by duplicating tiles 16 times, so we can used the unused 4 bits to get more RAM for the interpreter. We only need to emulate 9 cycles per frame (540Hz), so there should be enough time.
Thoughts?
"I want to see Chip-8 on NES so that I can extend an emulator stack one higher. Imagine Chip-8 emulator in PocketNES in VisualBoyAdvance GX in Dolphin in Wine in Virtual PC or VMware." - tepples
2 of the main problems I can think of are:
1) Screen resolution- Easy to solve, just have 16 tiles with all possible values of 4 bits to simulate 4x4 tiles
2) Memory- Without expansion RAM, the NES only has 2KB of RAM and CHIP-8 has 4KB. However, we can get an extra kilobyte from the unused nametable, and almost 512 bytes from the fact that some of the main nametable is unused. We can solve the garbage data with forced blanking (timed with sprite 0 hits and timed code) and get more time to read and write to the to the PPU midframe and use OAM memory (disabling sprites) or attribute tables (duplicating palettes) for the rest. Hopefully this will give us 3.5 KB, and 512 bytes are reserved for the interpreter on CHIP-8 so that should be enough. I haven't worked out the numbers so I may be wrong. We can get more memory for the interpreter by duplicating tiles 16 times, so we can used the unused 4 bits to get more RAM for the interpreter. We only need to emulate 9 cycles per frame (540Hz), so there should be enough time.
Thoughts?
Last edited by orlaisadog on Sun Jul 15, 2018 4:51 am, edited 10 times in total.
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
Re: CHIP-8 on NES? (NROM)
Another problem:
3) Input- The CHIP-8 (or is Chip-8?) has a 16-key hex keyboard whereas the NES controller only has 8 buttons. An obvious solution would be to have a screen for mapping NES controller buttons to CHIP-8 keys, or use 2 controllers. Another way would be to use button combinations or modifier button (if NES A is pressed, NES B means CHIP-8 5, but otherwise it means CHIP-8 F).
3) Input- The CHIP-8 (or is Chip-8?) has a 16-key hex keyboard whereas the NES controller only has 8 buttons. An obvious solution would be to have a screen for mapping NES controller buttons to CHIP-8 keys, or use 2 controllers. Another way would be to use button combinations or modifier button (if NES A is pressed, NES B means CHIP-8 5, but otherwise it means CHIP-8 F).
- NovaSquirrel
- Posts: 423
- Joined: Fri Feb 27, 2009 2:35 pm
- Location: Fort Wayne, Indiana
- Contact:
Re: CHIP-8 on NES? (NROM)
I can't seem to find information about it (maybe the original pages are gone?), but a long time ago I remember reading about a CHIP-8 emulator for the Vectrex, which has even less RAM, and it ran into the lack of memory problem too.
The author of that emulator made the realization that most games treat most of the address space as read-only, aside from some games like the Pac-Man clone (Blinky), and you could put the addresses actually treated as RAM in RAM while the rest went in ROM. That requires looking at how each game works, but CHIP-8 games are so simple that it's probably not very hard.
Edit: found some information on that via Internet Archive, though it's mostly just confirming what I remembered
The author of that emulator made the realization that most games treat most of the address space as read-only, aside from some games like the Pac-Man clone (Blinky), and you could put the addresses actually treated as RAM in RAM while the rest went in ROM. That requires looking at how each game works, but CHIP-8 games are so simple that it's probably not very hard.
Edit: found some information on that via Internet Archive, though it's mostly just confirming what I remembered
Last edited by NovaSquirrel on Sat Jul 14, 2018 9:42 am, edited 1 time in total.
Re: Look tepples- CHIP-8 on NES? (NROM)
This convoluted RAM layout is not something I'd feel comfortable working around... I'd much rather just add extra RAM to the cartridge and have a nice contiguous block of memory that can be used without special tricks.
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
Re: CHIP-8 on NES? (NROM)
But that wouldn't be completely accurate and is less fun.NovaSquirrel wrote:treat most of the address space as read-only
Tokumaru, again for fun. I suppose it would help with a competition, too?
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
Re: Look tepples- CHIP-8 on NES? (NROM)
Is anyone interested in making this? I don't have enough experience yet- I know a lot about how the NES works in theory from browsing the forums but can't do much assembly. I could do it myself one day, probably.
Re: [IDEA] Look tepples- CHIP-8 on NES? (NROM)
I have considered making a CHIP-8 emulator for the NES many times, but the lack of interesting CHIP-8 games to play ends up discouraging me. Most of the games look too glitchy to be fun, IMO. If there was a cool platformer with smooth physics for the CHIP-8, I'd feel much more compelled to write an emulator. The original CHIP-8 looks fairly easy to implement, but I definitely wouldn't use this absurd memory layout, I'd just use extra RAM.
Last edited by tokumaru on Sat Jul 14, 2018 11:22 am, edited 1 time in total.
Re: [IDEA] Look tepples- CHIP-8 on NES? (NROM)
That's sort of what I was interested in. Is there a well-known repository of CHIP-8 games distributed as free software with which to test an emulator?
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
Re: [IDEA] Look tepples- CHIP-8 on NES? (NROM)
- tokumaruDoing things like this in a machine you KNOW can handle it is not fun, it's just convenient. The fun is all about trying the unusual. Emulating a GB on the NES is not about the goal (playing Game Boy games), but the means (NES simulating another machine).
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
Re: [IDEA] Look tepples- CHIP-8 on NES? (NROM)
Sorry for all of the short posts but will most CHIP-8 games work well with overscan? Also why not make a Mario game? Would it work? I could try to learn to make it. Would it be possible to make music with the single-pitched beep? How does it work with 9 cycles per frame?
Re: [IDEA] Look tepples- CHIP-8 on NES? (NROM)
Haha OK, an emulator running on the NES is already novel enough, I don't see why avoid using something that was common back in the day (extra RAM) and make the development significantly harder or even impossible, since even all the sacrifices won't get you all the RAM you need. Remember that you don't need just the RAM for the CHIP-8 program, the emulator itself will need a decent amount of RAM to function.orlaisadog wrote:- tokumaruDoing things like this in a machine you KNOW can handle it is not fun, it's just convenient. The fun is all about trying the unusual. Emulating a GB on the NES is not about the goal (playing Game Boy games), but the means (NES simulating another machine).
I don't get what you mean by 9 cycles per frame... 540Hz aren't enough to do anything that vaguely resembles a game... Where did you get that number from?orlaisadog wrote:How does it work with 9 cycles per frame?
EDIT: OK, I've seen this 540Hz figure thrown around, but I really don't get how that relates to clock speed.
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
Re: [IDEA] Look tepples- CHIP-8 on NES? (NROM)
Here. How much should it be? As fast as we can?tokumaru wrote:Haha OK, an emulator running on the NES is already novel enough, I don't see why avoid using something that was common back in the day (extra RAM) and make the development significantly harder or even impossible, since even all the sacrifices won't get you all the RAM you need. Remember that you don't need just the RAM for the CHIP-8 program, the emulator itself will need a decent amount of RAM to function.orlaisadog wrote:- tokumaruDoing things like this in a machine you KNOW can handle it is not fun, it's just convenient. The fun is all about trying the unusual. Emulating a GB on the NES is not about the goal (playing Game Boy games), but the means (NES simulating another machine).
I don't get what you mean by 9 cycles per frame... 540Hz aren't enough to do anything that vaguely resembles a game... Where did you get that number from?orlaisadog wrote:How does it work with 9 cycles per frame?
EDIT: OK, I've seen this 540Hz figure thrown around, but I really don't get how that relates to clock speed.
P.S. I'm saying "we" because someone else may do it
Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA
Yeah, I've seen the number being mentioned, but I'm not sure what it means. It definitely isn't CPU cycles as we're used to measuring on the NES, because 540 instructions per second (assuming each instruction is one cycle) isn't nearly enough to make a game with any sort of real time interaction.
- orlaisadog
- Posts: 167
- Joined: Thu May 31, 2018 11:12 am
- Location: Bristol, England
Re: [IDEA] Look tepples- CHIP-8 on NES? (NROM)
As I explained you can get 3.5KB, and at least an extra 256 from 4 bits of the tile data and maybe more from OAM. I just realised that attribute data is not extra data as it is included in the name table RAM. Anyway it's fun, cheaper to make a cartridge out of and more impressive that way.tokumaru wrote: Haha OK, an emulator running on the NES is already novel enough, I don't see why avoid using something that was common back in the day (extra RAM) and make the development significantly harder or even impossible, since even all the sacrifices won't get you all the RAM you need. Remember that you don't need just the RAM for the CHIP-8 program, the emulator itself will need a decent amount of RAM to function.