I was thinking of a one-chip bootloader that could be built in to a NES. It would run the serial bootloader if no cartridge was present (at which point one could be hotswapped in or whatever). It seems that it could get away with just 10 wires to the NES:
GND
+5V
D0-D7
/PRG CE to cart
For booting, it would supply the proper bytes to have the CPU run repeated LDA #n; StA $1xx instructions until the stack had the bootloader in it, then a JMP $1xx to run it. It wouldn't need the address bus because it would know every cycle what the CPU is doing and know when to ignore dummy reads.
For cartridge detection, it would simply watch the bus until the two reset vector reads. If they read back as something other than open bus, it would know a cartridge was present and stay dormant.
I'm considering trying this with an AVR at 16MHz. I'm hoping it will be able to respond fast enough to the /CE signal. I think I can get response down to under 3 clocks (187ns).
Perhaps it could also even work *with* a cartridge present, by forcing the high bit of the reset vector zero (and maybe bit 15 high) so it'd land in an unmapped area.
GND
+5V
D0-D7
/PRG CE to cart
For booting, it would supply the proper bytes to have the CPU run repeated LDA #n; StA $1xx instructions until the stack had the bootloader in it, then a JMP $1xx to run it. It wouldn't need the address bus because it would know every cycle what the CPU is doing and know when to ignore dummy reads.
For cartridge detection, it would simply watch the bus until the two reset vector reads. If they read back as something other than open bus, it would know a cartridge was present and stay dormant.
I'm considering trying this with an AVR at 16MHz. I'm hoping it will be able to respond fast enough to the /CE signal. I think I can get response down to under 3 clocks (187ns).
Perhaps it could also even work *with* a cartridge present, by forcing the high bit of the reset vector zero (and maybe bit 15 high) so it'd land in an unmapped area.