Peripheral Address Usage

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderators: B00daW, Moderators

User avatar
chykn
Posts: 108
Joined: Sun Feb 21, 2010 6:06 pm

Peripheral Address Usage

Post by chykn »

I've built a NES peripheral which is currently accessed via address $5000. Does anyone know if this would cause problems with mappers aside from those based on MMC5? I'm willing to sacrifice compatibility with that one given it's rarity. Mainly concerned with compatibility with SxROM variants and other popular cart types.
User avatar
MottZilla
Posts: 2835
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

I don't think anything else should attempt to respond to that address, atleast for NES. Some pirate Famicom cartridges might use that space maybe. But I would think you are safe from conflicts. Curious what your device is though.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Something related to this, most likely... =)
User avatar
chykn
Posts: 108
Joined: Sun Feb 21, 2010 6:06 pm

Post by chykn »

tokumaru wrote:Something related to this, most likely... =)
Yeah, I'm finally getting back on that project again. I took a slight detour though. I just finished a USB keyboard adapter. I didn't want to run any wires out through the cart for now so I wired the board straight to the 2A03. The MCU decodes the ASCII value from the USB HID report and puts it to a buffer accessible via $5000.

It would have been easier to splice it into a controller cable like the NES232, but this way it won't take 64 instructions to get a single byte. Instead it's just one LDA. Building this board was more for the educational value, though. Learning how to 2A03 addresses the various components makes writing a ROM much easier to understand.

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

Post by tokumaru »

Ah, interesting. Can multiple keys be pressed at once?
User avatar
Memblers
Site Admin
Posts: 3902
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers »

The registers for all the mappers I've made are at $5xxx (both older Squeedo revisions and my current CPLD mapper). $6000-$FFFF is writable so they can't go there, so about the only other good place left is at $4800. Or anywhere in $4020-$4FFF. Only some Namco Famicom carts (just Namco106?) use that area, AFAIK. I could move my CPLD mapper to $4800 if I have to, but I'd prefer to continue on with $5xxx.
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

MMC5 only uses $5000-$5206 & $5c00-$5fff, and the FDS uses $4020-$4086 and N106 uses $4800-$4fff

So I guess $5300-$5bff and $4100-$47ff should be safe areas no mapper uses.
Useless, lumbering half-wits don't scare us.
User avatar
Memblers
Site Admin
Posts: 3902
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers »

I believe CopyNES also uses $4800-$4FFF, which is another reason to have my mapper registers at $5000-$5FFF. I want CopyNES to be usable for programming my carts, and also don't really have enough address inputs to decode those more specific addresses that nothing else uses.
User avatar
chykn
Posts: 108
Joined: Sun Feb 21, 2010 6:06 pm

Post by chykn »

tokumaru wrote:Ah, interesting. Can multiple keys be pressed at once?
Modifier keys such as shift will produce the expected results. If you mash the keyboard and hold down five keys at once it will behave like usual. All characters are submitted to the buffer and the last one held down is repeated.
Bregalad wrote:MMC5 only uses $5000-$5206 & $5c00-$5fff, and the FDS uses $4020-$4086 and N106 uses $4800-$4fff
So I guess $5300-$5bff and $4100-$47ff should be safe areas no mapper uses.

Memblers wrote:I believe CopyNES also uses $4800-$4FFF, which is another reason to have my mapper registers at $5000-$5FFF. I want CopyNES to be usable for programming my carts, and also don't really have enough address inputs to decode those more specific addresses that nothing else uses.
Thanks for the input guys. Given those two statements, I'll go ahead and go with $4100-$41FF for the USB keyboard and anything else I come up with. I looked in the wiki and elsewhere on the web, but I couldn't find any tables with a comprehensive list of uses in the $4018-$5FFF range. If one does not already exist, can we go ahead and create it? I know it isn't completely accurate, but this should get us started...
  • $4000 - $4017 -> Internally mapped in 2A03
    $4018 - $401F -> ?
    $4020 - $4087 -> Famicom Disk System
    $4088 - $40FF -> ?
    $4100 - $41FF -> USB Keyboard
    $4200 - $47FF -> (unused)
    $4800 - $4FFF -> N106 & CopyNES
    $5000 - $5206 -> MMC5 & Squeedo
    $5207 - $5BFF -> Squeedo
    $5C00 - $5FFF -> MMC5 & Squeedo
User avatar
Memblers
Site Admin
Posts: 3902
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers »

A USB keyboard add-on like this would be quite cool. One thing I'd be curious to know, is how much current an (average) USB keyboard will use, in practice. I'm sure it's fine though for the NES. I've designed (not started to prototype yet) a powered USB port, not sure how useful the power will be for it, but I was needing an efficient switching power supply anyways for other parts of the circuit, so piling on another 500mA to the specs wasn't gonna hurt anything. :P

But yeah what's cool about this, is that it surely is cheaper than my design, so that hopefully could help bring more keyboards into use on NES.

Also to correct what I said earlier, CopyNES has a switch (controlled by $4016.d2) that moves the registers from $48xx to a lower address (I forget the exact location). I remember he had to make a special adapter to dump N106 carts though (N106 has $48xx readable and writable, so I guess that caused a bus conflict, and your adapter might also if it was there, but I dunno).

Also, kevtris said there is one area that never gets used by any mappers, $4700-$47FF. I'm sure that includes the hundreds of obscure mappers that exist, so if you wanted an area that absolutely nothing uses, that would be it. But in practice I guess, this really only needs to work with carts that people might actually use, heheh. And the most obscure mappers are surely for Famicom only.
User avatar
chykn
Posts: 108
Joined: Sun Feb 21, 2010 6:06 pm

Post by chykn »

Memblers wrote:Also, kevtris said there is one area that never gets used by any mappers, $4700-$47FF.
If that's the case, I can use that location. It will probably work better anyway. To help speed up peripheral development, I'm building a board to provide external connectivity. In a nutshell you'll have a DB25 header coming out of the back of the NES. For now I'll call it EXP port 2.

CE goes low if the CPU is addressing the specified range. Parts cost is around $6 or so, but then you'd have the ability to build any device with your favorite MCU and connectors from Radio Shack. Better yet, all signal levels are already at 3.3v. I've tested this with a PIC24F chip. The only hard part is cutting the hole in the back of the NES and soldering either 17 or 25 lines to the motherboard.
  • Pins for EXP port 2
    VDD
    VSS
    /CE
    R/W
    D0-7
    A0-7
    (optional)
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Memblers wrote:Also, kevtris said there is one area that never gets used by any mappers, $4700-$47FF. I'm sure that includes the hundreds of obscure mappers that exist, so if you wanted an area that absolutely nothing uses, that would be it. But in practice I guess, this really only needs to work with carts that people might actually use, heheh. And the most obscure mappers are surely for Famicom only.
And the Famicom already has an official keyboard, and so do SUBOR style Famiclones. So it's not quite as critical for an NES keyboard interface to stay out of the way of foreign mappers as it would be if it were made for the Famicom.
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

What about a JoypadPlug/USB adapter ? Doesn't both have +5V, GND, and two signals ?
Useless, lumbering half-wits don't scare us.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

USB is data, data ground, power, and power ground. To oversimplify things, the difference between NES and USB is like the difference between 240p RGB video on a JAMMA plug and 1080p RGB video on a VGA plug. USB's minimum signaling rate is far too fast for the NES to process; there has to be a USB host controller in the middle.
User avatar
chykn
Posts: 108
Joined: Sun Feb 21, 2010 6:06 pm

Post by chykn »

Bregalad wrote:What about a JoypadPlug/USB adapter ? Doesn't both have +5V, GND, and two signals ?
Good question. That's exactly how I had it hooked up at first. I took the NES232 upgraded it with an MCU that had USB host capabilities. The problem was throughput and CPU time. Using the controller port for sending and receiving data limits you to roughly 115,200 kb/s and saturates the NES CPU. You couldn't transfer more than 192 bytes or so between vblanks. My current project requires bus speed transfer rates and low CPU usage. The idea was to get the peripheral addressing worked out and tested with something simple (keyboard input) before proceeding with the next step.
Post Reply