[IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RAM)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

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

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

tokumaru wrote: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.
That's what I was saying. What is it then?
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by tokumaru »

In this page someone mentions using a clock speed between 500Hz and 1MHz, which doesn't sound right, so maybe they actually mean KHz rather than Hz? If that's really the case, then we might be in trouble... 9000 instructions per frame really wouldn't be possible.
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

tokumaru wrote:In this page someone mentions using a clock speed between 500Hz and 1MHz, which doesn't sound right, so maybe they actually mean KHz rather than Hz? If that's really the case, then we might be in trouble... 9000 instructions per frame really wouldn't be possible.
CHIP-8 was designed for old computers with 4k of RAM, so...
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

That page wrote:a function we can tick at 500Hz
So it is 500Hz?
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by tokumaru »

I don't know, 500Hz sounds like too little, 500KHz sounds like too much... I have no idea.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by tokumaru »

I think there are more CHIP-8 emulators out there than CHIP-8 games!
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by tokumaru »

I've been reading about the CHIP-8 and it does seem like games can run at fairly slow speeds... This is an emulator that lets you select the number of cycles per frame, starting at 7 and going all the way up to 1000. That seems very doable on the NES, which could probably even handle an SCHIP implementation.
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

tokumaru wrote:I've been reading about the CHIP-8 and it does seem like games can run at fairly slow speeds... This is an emulator that lets you select the number of cycles per frame, starting at 7 and going all the way up to 1000. That seems very doable on the NES, which could probably even handle an SCHIP implementation.
1000? OK, I found out that there are 29780.5 CPU cycles per frame. That's about 30 cycles for 1 cycle, or about 15 the way I'm thinking because there can't be PPU memory access in rendering time. Is that enough? I don't know much assembly, either CHIP-8 (none at all) or NES (a tiny bit).
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by tokumaru »

1000 would be too much for the NES to handle, because even though many of the operations are simple, you still have to fetch the instruction, decode it, update the VM state, and so on, for every instruction. Also, drawing sprites is a fairly slow process, since it involves bit shifting, bitwise operations, and even more operations to check if any pixels were erased, all of this between several bytes, but the whole thing still consumes 1 cycle, apparently.

Most examples on that page work fine at 100 cycles per frame though, or even less, and that's fairly realistic for a possible NES version. That should be made configurable on the NES as well, IMO.
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

tokumaru wrote:1000 would be too much for the NES to handle, because even though many of the operations are simple, you still have to fetch the instruction, decode it, update the VM state, and so on, for every instruction. Also, drawing sprites is a fairly slow process, since it involves bit shifting, bitwise operations, and even more operations to check if any pixels were erased, all of this between several bytes, but the whole thing still consumes 1 cycle, apparently.

Most examples on that page work fine at 100 cycles per frame though, or even less, and that's fairly realistic for a possible NES version. That should be made configurable on the NES as well, IMO.
It could end up variable. If we can put the most-used variables in non-PPU RAM it could give a speed boost.
Edit: As NovaSquirrel said, it would be possible to analyse the ROM to see what is never changed, but my RAM layout could act as a fallback?
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

I've just realised that OAM memory will decay if forced blanking is used. Could sprites be turned on occasionally during emulation to keep it refreshed or would there not be enough time?
Edit: Offtopic but I just read that the decay is affected by temperature. Could there be a NES thermometer?
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by FrankenGraphics »

For it to make any sense (to me) i think you need a method to enter s/chip-8 programs into the interpreter. That makes WRAM (battery backed?) all the more important.

you could either transfer the programs to RAM via an usb to nes port cable and an app on your pc, or it could work like family basic, complete with a suitable interface. Most likely something T9-inspired since keyboards aren't an option. 35 opcodes would be no match for a d-pad hexnumpad + action button.

https://en.wikipedia.org/wiki/T9_(predictive_text)
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by tepples »

Unless it's like PocketNES for Game Boy Advance, where you choose a bunch of NES ROMs when you build a GBA ROM.
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

I thought it would be like PocketNES, maybe with a GUI with options on graphics (affects CHR ROM data so cannot be changed at runtime). However, an IDE would be interesting. It would probably need the Family BASIC keyboard though. Oh, I didn't read your post properly.
User avatar
orlaisadog
Posts: 166
Joined: Thu May 31, 2018 11:12 am
Location: Bristol, England

Re: [IDEA] CHIP-8 interpreter on NES? (NROM, no expansion RA

Post by orlaisadog »

FrankenGraphics wrote:Most likely something T9-inspired since keyboards aren't an option. 35 opcodes would be no match for a d-pad hexnumpad + action button.
What about an assembler with the attached layout (I haven't made anything properly yet)? The categories come from https://en.wikipedia.org/wiki/CHIP-8 and the names from http://devernay.free.fr/hacks/chip8/C8TECH10.HTM. Start and select change the active category. These are listed on the left, and the active one is brighter. A graphics editor would also be possible. There would also be a PocketNES-like version with no save RAM. The labels would be named automatically but the names could be changed.
Attachments
asm.png
Post Reply