InGameRoutines for NESRGB

Discussion in 'Modding and Hacking - Consoles and Electronics' started by borti4938, Oct 14, 2014.

  1. Bad_Ad84

    Bad_Ad84 Keyboard Error: Press F1 to Continue

    Joined:
    May 26, 2011
    Messages:
    7,087
    Likes Received:
    280
    Yes, I did mean you would need them on all lines... I'd assumed you would be smart enough to figure that out (and rightly too)

    I don't know how the new pad works off the top of my head, but if there is a clock from the console to the controller you can't put a diode on that line.

    Need to do some trial and error or look how the nes controller works and what the lines do exactly. Any signal that goes Console to controller can't have a diode
     
    Last edited: Feb 27, 2016
  2. Marmotta

    Marmotta Enthusiastic Member

    Joined:
    Apr 14, 2009
    Messages:
    586
    Likes Received:
    3
    The NES controller has Latch, Clock and Data lines. I think the only one sending signals from the pad to the console is Data.
     
    Last edited: Feb 27, 2016
  3. borti4938

    borti4938 Spirited Member

    Joined:
    May 8, 2014
    Messages:
    137
    Likes Received:
    23
    I don't think that it is a good idea to combine the signals for both controllers.
    However, I want to say a few words to that.
    I haven't looked into NES schematics. If it is the similar to the SNES' one, the Latch signal is the same for both - P1 and P2. Only the clock and, of course, data is different.
    I expect that P1 and P2 are getting the same clock from the CPU. One may check that with an oscilloscope or just test it. If my assumption is correct, the connection to P1 clock is enough.
    The data lines to the PIC can be combined using an AND-gate (e.g. a 74HCT08 or 74HC1G08 (samples are available from TI)).
    The AND-gate combines both data lines for the PIC.
    But keep in mind: a button comibination for the PIC can be spreaded over both controllers. E.g. If P1 presses A+B and P2 Sel+St, the PIC reads Sel+St+A+B and initiate a reset.
     
  4. Marmotta

    Marmotta Enthusiastic Member

    Joined:
    Apr 14, 2009
    Messages:
    586
    Likes Received:
    3
    I'll try out the AND-gate idea as well. I don't think the chances of a button combination across both controllers would be very high (how often would you need to press A and B together or even the Select button alone in general use?).

    This is what I found about the Latch and Clock signals (read Pulse as Clock):

    The NES uses a serialized polling mechanism to query the state of the buttons. Every 60 Hz, the NES sends a 12us high signal to the Latch pin, telling the controller to latch the state of of all buttons internally. Six microseconds later, the NES sends 8 high pulses on the Pulse pin, 12us per full cycle, 50% duty cycle.

    After the initial wide pulse on the Latch pin, Data goes high until the eighth pulse passes, at which point it drops low again. For each pulse on the Pulse pin, Data will assert ground if the button corresponding to that pulse was pressed. (The button states on Data are thus negative true.) The button order is always the same: A, B, Select, Start, Up, Down, Left, Right.
     
    Last edited: Feb 28, 2016
  5. borti4938

    borti4938 Spirited Member

    Joined:
    May 8, 2014
    Messages:
    137
    Likes Received:
    23
    The information about pulse widths is not correct.
    The pulse width of latch is around 3.5us, the width of a clock pulse around 350ns (negative to positive edge). One cannot say that this is a 50% duty cycle :D
    Also: as the NES does not have a auto joypad read feature like the SNES. Every game reads the joypad on its own code and the structure may look a bit different from game to game.
     
    Last edited: Feb 28, 2016
  6. Marmotta

    Marmotta Enthusiastic Member

    Joined:
    Apr 14, 2009
    Messages:
    586
    Likes Received:
    3
    Got round to trying out some stuff - my code works fine, so that's good. However, I did try running both controller data lines through an AND gate, but the second controller didn't work and on Contra the three different palettes were cycled through automatically, so I may have to try something else... Unfortunately I don't have an oscilloscope to check what is happening on the lines.
     
    Last edited: Mar 5, 2016
  7. splitter

    splitter Newly Registered

    Joined:
    Jun 9, 2016
    Messages:
    2
    Likes Received:
    0
    I was going to order a board from OSH Park, but I'd like to check that the current US schematic is OK. I just uploaded the .brd file to OSH Park and the output is below.

    Some of the through holes extend off the board (RCA jacks), as in the picture. It shows up like this in multiple viewers. Just want to check.

    Also, were the J4 jumpers intentionally removed?

    4a9a0e2a3e60c69a52c85ff0b8002a81.png
     
  8. borti4938

    borti4938 Spirited Member

    Joined:
    May 8, 2014
    Messages:
    137
    Likes Received:
    23
    Looks good.

    The holes of the RCA jacks are partly off the dimension layer - that is as designed. Once produced and soldered it should looks like as the in the attached pictures.

    I also removed J4 for the US version.

    Btw: I have seen that C1 is shifted too much to the right.
     

    Attached Files:

  9. splitter

    splitter Newly Registered

    Joined:
    Jun 9, 2016
    Messages:
    2
    Likes Received:
    0
    Thanks for confirming that. This is an awesome project. I was about to install an NESRGB and re-cap the power supply/component out/RF daughterboard before finding this thread, but I was lamenting having to open a hole for my multiav port. This is the perfect solution--with some extra functionality to boot.

    I have never programmed a PIC microcontroller, but I have a model 1 RPi B with the Slice of Pi I/O addon board, and there is a package called "pickle" that apparently is able to program the 16F684.

    Also, I wanted to ask: I was looking at rectifier diodes, and the 1N5059s look like 1A diodes. Is that correct, or should I be looking for 1.5A diodes?
     

Share This Page