uXe wrote:
yogi wrote:

void setup ()
{
  pinMode(x, INPUT); // for all the CD4021 pins
  PORTB &= b00000000; // Arduino pins 8, 9, 10 and 11; PB0:PB3 to Hi-Z inputs
  PORTC &= b00000000; // Arduino pins A0, A1, A2 and A3; PC0:PC3 to Hi-Z inputs
}

Not to nit-pick, because I know you were just typing this off the top of your head, but I think what you mean is:

PORTB &= ~B00001111;
PORTC &= ~B00001111;

to set only those pins to '0'

yogi wrote:

DDRB = (1 << PBx) // Change pin to output
DDRB = (0 << PBx) // Change pin to Hi-Z input

again:

DDRB |= (1 << PBx);
DDRB &= ~(1 << PBx);

to affect only that pin, otherwise you are changing all of the bits on that port, and with Arduinos that can be bad when some of them are permanently assigned as reset or crystal pins...

Glad you caught this,Thanks. sorry for my confusion.
My poor C skills are showing sad Let this be a lesson: 'Compound bitwise logic and late night posting don't mix'!

uXe wrote:

Although reading in the buttons would have its advantages too - you could write code to implement 'turbo' modes etc!

First thoughts could be:
void setup ()
{
  pinMode(x, INPUT); // for all the CD4021 pins
  PORTB &= b00000000; // Arduino pins 8, 9, 10 and 11; PB0:PB3 to Hi-Z inputs
  PORTC &= b00000000; // Arduino pins A0, A1, A2 and A3; PC0:PC3 to Hi-Z inputs
}
to write a button to NES, with 0x00 loaded into the output port latch
  pinMode (pin, OUTPUT) ; // 'button' press
or DDRB = (1<<PBx) // Change pin to output
and then to release it
  pinMode (pin, INPUT) ; // 'button' release
or DDRB = (0 << PBx) // Change pin to Hi-Z input

To read from a pad button
  PORTx |= _BV[x] ; // while in input mode, set bit
read pin and store the bit
  PORTx &= ~_BV[x] ;  //  back to Hi-Z, clr bit
EDIT- After thinking over the above snippet, there shouldn't be a problem just reading the pin; Hi-Z is only relevant to not loading a shared connection. With the external pull-up, the button should only be one of two states, and pose no problem just reading the pin.

Internal pull-ups are "between 20K to 50K", so that would be ~38K in parallel with 38K=19K of pull-up, should be good. We'll see
Yogi

uXe wrote:

Just occurred to me though - not sure if the buttons on the joypad itself could still be functional or if you would need to cut the pins from their previous connections before you wire them to the Arduino... wondering what would happen if you are trying to pull a pin low with the Arduino if it is still being held high by the joypad's built-in pull-ups, or try to pull a pin low by pressing a button on the joypad when it is being held high by the Arduino?

  Going through your sketch, occurred to me, if you toggle the Arduino pins between button Press = 'Outputing' a 0 and button Release = tri-state Input , would be open collector. Not sure how much the AT can drain, but it would work as long as the pad's pull-ups  are high values (low current flow). Not sure if you could Read the buttons, but think you could send button presses to the NES easy.
Will cobble together a test sketch to try this out.
Yogi

uXe wrote:

The way I've re-written the code is to have a toggle switch on pin 12 to choose between MIDI or Joypad mode, so the two modes would never be running at the same time, and there wouldn't be any slow-down to worry about... it seems like having the two modes running at once would cause issues / conflicts with both of them wanting to have control of the same 8 bits?

Also, the code is written with the Duemilanove in mind, so the pin / port values may need to be adjusted for a Teensy - all of the 'genuine' Teensy boards seem to have more than just 18 pins available?

Cool! Midi or joypad works. Been reading the SPI lib and I think could still read buttons as well as process midi to the NES. Will do some testing.
The boards I order are copies of the Sparkfun ProMicro Leonardo compatible,
https://www.sparkfun.com/products/11098
$5 w/Free shipping (from HK, ugh!) About the same form factor of the Teensy and same AVR, ATMega32u4. Guess I could burn the Teensy bootloader to it (don't even know if it comes with a BL?), but the pin def is a little different.
Yogi

uXe wrote:
yogi wrote:

A brute force approach could be adding a second 4021, with the arduino in the middle-reading the KB 4021 and outputting a parallel byte to the second NES 4021.

Another alternative would be to go ahead and cut the shift register input pins from their original connections to the joypad, wire them up to the Arduino for MIDI control, and then make connections directly to the pads on the controller PCB for detecting button presses - read them into the Arduino directly and bypass the shift register! Simple on / off, like how an Atari joystick works - just wire eight Arduino pins to the pads highlighted here in blue, the pins should be held high by the joypad's pull-ups and then when the buttons are pressed those pins should be pulled low:

My only concern with letting the Arduino scan the buttons is pin count, but it's just doable on a Teensy sized form factor. 16 digital +2 uart pins out of 18 total.
The NESpad lib you pointed to is good, but it seems to use digitalRead and digitalWrite. Which is OK, but burns allot of cycles. I think the AVR's SPI hardware would be a better choice with the 4021, but I may be overlooking something, Will have to play around with some hardware.
The cost of an extra 4021 is small and if the SPI works out it wouldn't slow down your main code much compared to reading 8 pins.
Yogi

uXe wrote:

[
No, the Arduino is not simulating a joypad. The FamiiDI shield does have connections to Clock and Latch, but it also has a 4021 shift register onboard - and it is much quicker and easier to just feed the shift register with button presses and let it do it's thing than to try and make the Arduino pretend to be a shift register, and be able to keep up with something that is so timing-dependant while it is doing several other things at the same time!

And in the case of the code I have provided for a 'quick and dirty' solution without the FamiiDI shield, the joypad's 4021 is just taking the place of the 4021 on the shield.

You could just as easily buy a shift register IC from any electronics supplier, wire that to the Arduino, and then wire it up internally directly to the NES Expansion Port pins without having to sacrifice a joypad. It is just that a joypad happens to be a quick and dirty way of getting hold of both a 4021 shift register and a cable that lets you communicate with the NES! smile

Understand. Still seems doable without too much pain. Will think this through a bit.
  A brute force approach could be adding a second 4021, with the arduino in the middle-reading the KB 4021 and outputting a parallel byte to the second  NES 4021.
  Remeber seeing code somewhere of a AVR Gamepad, but this will complicate your code a bit.
Yogi

uXe wrote:
uXe wrote:

and then open up a NES joypad and connect the 8 input pins on the joypad's shift register to 8 pins on the Arduino and you'd have yourself a MIDI controlled NES joypad! smile You would even have enough spare pins to connect another 8 to a second joypad if you really wanted to...

...or connect 12 pins to a SNES joypad instead and you'd have yourself a MIDI controlled SNES joypad! smile

Just occurred to me though - not sure if the buttons on the joypad itself could still be functional or if you would need to cut the pins from their previous connections before you wire them to the Arduino... wondering what would happen if you are trying to pull a pin low with the Arduino if it is still being held high by the joypad's built-in pull-ups, or try to pull a pin low by pressing a button on the joypad when it is being held high by the Arduino?

Well you may have a point, will look into this. Off the top of my head, a work-around would be letting the Arduino sacn the KB and then interleave button presses with Midi messages to send to the NES. Haven't looked thru your code, but you are simulating the Game pad with the Arduino? If so, adding a key scan may be possible?
Yog
EDIT- Or better yet, setup a SPI read loop for the CD4021. So a ruff setup:
1. Disconnect cable from gamepad board.
2. Connect gamepad board to Arduino SPI pins
3. Connect NES cable to Arduino
Sound workable?

uXe wrote:

...if anybody does decide to build this into a joypad and wants to make an extra one for me (I would pay for parts / postage of course) then nothing would make me happier! smile

Enjoy!

Thanks for the code!
Got a couple of ProMicro Leonardo clones coming from HK (for another project) so if things workout, you got it!
Yogi

stargazer wrote:

Hey Yogi, let me ask again how long shipping took? I ordered a week ago and haven't heard anything shipment wise. The FAQ says I should get a shipment confirmation, is that consistent with your experience?

  The first board I ordered took a little over a week if I recall. EDTI- ordered on Nov 20, shipped on Dec 2.. I got an email with tracking # when it shipped. Some of the time is setting up the board for a order. I don't think INL had a stock of pre-configured SXROM boards. So... With a up tick in demand for SX boards (hehehe) and the holidays, I expect it may take a little longer. That said, I know the waiting is painful! I too am waiting on an order. But INL is very responsive on NESDev.org so If you need to contact him it shouldn't be a problem.
It's worth it!
Yogi

Very nice! looking forward to seeing the sketch. Setup on a Teensy, it would make a compact midi/sync interface. Could even fit it into a game pad!
Yogi

Dam! to cool, but it makes waiting for mine that much harder ;( going back to putting it out of my mind....
Yogi

Limitbreak wrote:

Totally just bought a new NES in preparation for these carts and transferers. I'm very happy this post was made. This REALLY changes things for people wanting to get into NES music...while it lasts...you never know how long these products will be in stock.

LOL too cool.

stargazer wrote:

Well it looks like Retrozone has all shells back in stock, so I've ordered a clear shell!

Working on a label right now.

Too cool. Been watching Retrozone's web site on a semi-daily basis, so must have been just this afternoon smile
Do hope you'll share  your lable design,please?

stargazer wrote:

I just don't like disassembling games just for the shell. But I guess I need to get over myself, nobody is going to miss that copy of NFL whatever.

Also the clear shells from bunnyboy look amazing.

Yea, not too many choices ATM! This was INL's motivation for commissioning molds, a steady supply.

383

(30 replies, posted in Nintendo Consoles)

herr_prof wrote:

I complete missed this, and recorded a jam I made with it today:

https://soundcloud.com/peterswimm/swmm

Liken it! Cool noise action. What FX are you applying? really mangles and twists it.
Have you checked out droNES?
Yogi

Limitbreak wrote:

This helps a lot, thank you. Hopefully some of these are still available after the holidays. I definitely want at least one cart and a transferer.

INL is very active and he seems to be making boards on a regular basis. He has started a production run of cart cases that should be ready in the spring, so i'm guessing he will have a supply of carts also. The cool thing with his carts is they are 'universal' hardware wise. If you want a SNROM board, he flashes the  CPLD with the configuration for a SNROM and adds the ram and flash chips as needed. So one board to rule them all!
Yogi