nand2mario / nestang

NESTang is an FPGA Nintendo Entertainment System implemented with Sipeed Tang Primer 25K, Nano 20K and Primer 20K boards
https://nand2mario.github.io/nestang
GNU General Public License v3.0
354 stars 38 forks source link

[help needed] Standard nes controller #12

Open siffland opened 1 year ago

siffland commented 1 year ago

Is there a way to have an alternate configuration at compile time for a standard 7 pin NES controller port to be wired to the nano20k instead of the PS2 ones that come with the kit? Besides the 5 volt and ground there are just the other 5 pins to deal with. It would make it a bit more authentic feeling.......or the homebrew analogue NT people can still purchase and afford :) . I do not know if that is a huge effort in code, but would think not (I could be wrong).

Chandler-Kluser commented 1 year ago

I am actually working in a USB Host Interface design for USB Gamepads. A NES Gamepad Interface I believe that would be a lot simpler to implement, if you want to help us :)

wolfshow commented 1 year ago

I am actually working in a USB Host Interface design for USB Gamepads. A NES Gamepad Interface I believe that would be a lot simpler to implement, if you want to help us :)

I have some ATmega32u4 driver for USB gamepad. https://github.com/wolfshow/gamepad

Chandler-Kluser commented 1 year ago

thanks, I will look for that!!

nand2mario commented 1 year ago

There's a verilog NES controller interface module: https://github.com/michael-swan/NES-Controller-SIPO And also for SNES controller: https://www.fpgalover.com/ip-cores/snes-controller-core.

I don't quite have time to look at this right now. So pull requests are welcome.

fjpolo commented 9 months ago

NESGamepad module will support NES original joysticks #1 and #2 and has support for 8BitDo NES controllers

fpolomimi commented 8 months ago

@nand2mario #52 adds OEM gamepad feature to NESTang_nano20k. I never implemented nor tested in in NESTang_primer25k since I don't own a board.

This issue could be kept open to track until Primer25k supports OEM, or be closed and add a new issue for Primer25k only

nand2mario commented 6 months ago

Thanks for everyone's help. The new NES/SNES controller support is ported from snestang. Could you test the attached test build. I've tested SNES controllers and they work fine for primer25k. Help with NES controllers are needed as my pair is currently on the way. Also I haven't got around to test on nano 20k yet.

Installation.pdf includes a diagram for wiring the NES socket, as well as SNES.

nestang-0.10-test-snes-nes-controllers.zip

nick3252 commented 6 months ago

Thanks for everyone's help. The new NES/SNES controller support is ported from snestang. Could you test the attached test build. I've tested SNES controllers and they work fine for primer25k. Help with NES controllers are needed as my pair is currently on the way. Also I haven't got around to test on nano 20k yet.

Installation.pdf includes a diagram for wiring the NES socket, as well as SNES.

nestang-0.10-test-snes-nes-controllers.zip

I just installed and tested this on a nano 20k, using an OEM NES controller. The NES controller is connected through the instructions in the included pdf. The setup to connect the controller this way has also worked with full functionality in previous versions of nestang.

The A and B buttons are repeatedly being pressed and unpressed, both in the menu and ingame. Other buttons appear to be functioning properly, though. I used this ROM to test: https://github.com/ClusterM/nes-input-test

In the video I demonstrate the effect occurring in the menu, as well as showing the other buttons working properly:

https://github.com/nand2mario/nestang/assets/90110064/8a61e407-0ca1-4d1a-b06d-1840888216f7

nand2mario commented 6 months ago

It's probably the autofire misbehaving. Let me fix that.

nand2mario commented 6 months ago

According to https://tresi.github.io/nes/, for the NES controller, data line will be 0 after 8 clock cycles. As signal is negative true, this will indicate the other buttons to be "pressed" if we read this as a SNES controller signal. The current code uses SNES A and X buttons as auto-fire buttons for NES. Therefore A and B becomes repeatedly pressed and unpressed.

To fix this, we can detect between SNES and NES controller (https://www.nesdev.org/wiki/Controller_detection), and apply autofire only for SNES controllers.

fpolomimi commented 5 months ago

Sorry I'm late to the show, I don't know why I'm subscribed with my work email instead of my personal one @.***). I'll see what I can do whenever I have some time to test/debug it.

On Sun, 19 May 2024 at 13:42, nand2mario @.***> wrote:

According to https://tresi.github.io/nes/, for the NES controller, data line will be 0 after 8 clock cycles. As signal is negative true, this will indicate the other buttons to be "pressed" if we read this as a SNES controller signal. The current code uses SNES A and X buttons as auto-fire buttons for NES. Therefore A and B becomes repeatedly pressed and unpressed.

To fix this, we can detect between SNES and NES controller ( https://www.nesdev.org/wiki/Controller_detection), and apply autofire only for SNES controllers.

— Reply to this email directly, view it on GitHub https://github.com/nand2mario/nestang/issues/12#issuecomment-2119205222, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXHOLXFHYNUG72DOPF5NU2LZDCFYPAVCNFSM6AAAAAAZBEV446VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZGIYDKMRSGI . You are receiving this because you commented.Message ID: @.***>

-- Franco J. Polo Embedded Engineer Phone: +49 (0)30 20236420-0

-- mimi.io  http://mimi.io/| Mimi Hearing Test App  https://apps.apple.com/us/app/mimi-hearing-test/id932496645| LinkedIn https://www.linkedin.com/company/mimihearing/

Mimi Hearing Technologies GmbH | Boxhagener Str. 82, 10245 Berlin | AG Charlottenburg HRB 155320B | Geschäftsführer / MD: Florian Schneidmadel

nand2mario commented 5 months ago

74 is a duplicate of this. I've just merged a fix by @nikitalita. Let me know if it works for you.

nick3252 commented 5 months ago

Navigating menus appears to be working without auto-fire issues on the latest commit using an OEM NES controller. I don't have an SNES controller to test its functionality though. Of note, inputs on the OSD when in-game passes through to the game, but I'd imagine that's a different scope.