Hello, I'm very much a newcomer to this board, and to NES development in general, so excuse any stupid questions or faux pas. I imagine all this stuff is basic to you guys but I haven't been able to find anyone doing a project like this so I would appreciate some input.
I was disappointed when this project -
https://howchoo.com/g/mti0oge5nzk/pi-ca ... -cartridge - turned out to just be another Raspberry Pi case mod. It got me thinking - could you actually put a Pi in a cart and have it output video through the NES? Running any game that the Pi can on an unmodified NES seemed like a fun idea. I was hoping the NES had a simple composite passthrough or something, but that would be too easy!
I suppose the "proper" way to do it would be to have the Pi fill some RAM attached to the PPU's memory bus, but that limits us to 256 different tiles and 16x16 attribute areas. I guess you could do some kind of pattern-matching thing that squashed similar patterns together, or map the pattern and attribute tables to a larger virtual address space using scanline-synced binary counters or something, but I'm lazy and stupid and it just made my head hurt.
So I thought - since we know the exact sequence the PPU will fetch data, why not ignore the address bus entirely and just feed it bytes in the correct order? Since we can feed it different pattern and attribute bytes for each 8x1 pixel area, that gives us 8x1 attributes and a unique pattern for each tile.
Anyway, long story short, I've (mostly) got it working :
https://www.youtube.com/watch?v=CxBBYujFDYMRight now I'm squirting pre-generated 40970 byte (170 bytes per scanline * 241 scanlines) packets to the PPU using a high-speed USB-to-parallel-FIFO chip (FT232H). There's a small PRG rom that sets up the palette and turns on rendering, as well as sending frame-sync commands back to the Pi. Unfortunately the first-generation Pi I'm using isn't quite fast enough to generate the palette-matched and Floyd-Steinberg dithered frames on-the-fly, but I expect the Pi 3 would have enough power to do it.
I guess my questions are :
1. Has anyone done any work on converting images into NES-friendly formats? I've tried using various homebrew per-frame palette generating algorithms, but nothing seems to work as well as manually hand-picking a palette.
2. What would be the best way of getting controller input back to the Pi? I was thinking a binary comparator on the PRG address lines feeding the chip enable pin of an 8-bit latch, but I'm not really a hardware guy so I'm sure there's a simpler way than that. Keep in mind the process latency on a Pi is far too high to be able to sit directly on a traditional CPU bus.
3. I don't want to reinvent the wheel, so has anyone done any work in this sort of area before? Again I'm a total newcomer to the NES scene (in fact I'd never even played a NES before starting this project, they weren't very common in the UK, haha).
I will of course share source code if anyone's interested.