Project: N64 controller to SNES adapter; GOT IT WORKING!!

Place to talk about all that new hardware and decaying software you have.

Moderator: General Mods

adventure_of_link
Locksmith of Hyrule
Posts: 3634
Joined: Sun Aug 08, 2004 7:49 am
Location: 255.255.255.255
Contact:

Post by adventure_of_link »

declan wrote:I would like too, but some one has beaten me to it :(
Really? find me some sites. I'd like to try this :D

also, congrats on the adaptor. nice work.
<Nach> so why don't the two of you get your own room and leave us alone with this stupidity of yours?
NSRT here.
declan
Lurker
Posts: 194
Joined: Thu Jan 03, 2008 12:45 am
Location: Austalia

Post by declan »

adventure_of_link wrote:
declan wrote:I would like too, but some one has beaten me to it :(


Really? find me some sites. I'd like to try this :D
Raphaël Assénat imediately comes to mind, as i have built his adapter
http://raphnet.net/electronique/gc_n64_usb/index_en.php

you will need to buy one of his preprogramed chips too, that is unless you want to buy an AVR ISP programer...

I think there are others that have done this (n64 to usb) too, a google search could confirm that.
adventure_of_link wrote:also, congrats on the adaptor. nice work.
Thanks man, I still need to get it working on a real snes though :)

Once i have this done, I will begin rewriting the code, to allow the n64 analog stick to emulate a snes mouse :D
Hardware means nothing if you don't have good software.
Compare the success of SNES over Genisis
BCprogger
Hazed
Posts: 57
Joined: Thu Aug 03, 2006 1:11 am
Location: Nanaimo B.C

Post by BCprogger »

Yoshi's Island kicks ass. Just don't get hit lol. If I was yoshi I would have let the timer run out just for the sweet relief of both having nothing on my back and no loud damn crying.

Being the launch title for the SNES Super Mario World would also be a good choice. (not that I can think of any really unsuitable game).
ZH/Franky

Post by ZH/Franky »

Play Ninja Gaiden Trilogy, the whole way through (actually, just play whatever you want, but Ninja Gaiden really is an awesome game).
ReRuss
Trooper
Posts: 443
Joined: Sun Aug 15, 2004 9:49 pm
Location: Somewhere
Contact:

Post by ReRuss »

I really need to do a SNES USB adapter...
[img]http://i5.photobucket.com/albums/y180/ReRuss/UBAR.gif[/img]
360 and PS3 - ReRuss
declan
Lurker
Posts: 194
Joined: Thu Jan 03, 2008 12:45 am
Location: Austalia

Post by declan »

yknarF wrote:Play Ninja Gaiden Trilogy
hmm......
1) Its a not true SNES game.... its a port from NES if i recall

2) I've never played it :(, i'd look like an ass, bumbling my way though it DX<.

SMW might be a winner....

I'll list the games that i'm okay at:
SMW
YI
DKC
DKC2
DKC3
SMK
SMRPG
SFx
SFx2
?
?

Fine.... go ahead a laugh at limited scope :cry:
Hardware means nothing if you don't have good software.
Compare the success of SNES over Genisis
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

Not good at Megaman X, even after getting the completely game breaking Storm Tornado that kills every non mini-boss or boss with one hit?
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

I.S.T. wrote:Not good at Megaman X, even after getting the completely game breaking Storm Tornado that kills every non mini-boss or boss with one hit?
I don't recall it ever doing that. It was effective though since its projectile stays out long enough to keep dealing damage.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

Deathlike2 wrote:
I.S.T. wrote:Not good at Megaman X, even after getting the completely game breaking Storm Tornado that kills every non mini-boss or boss with one hit?
I don't recall it ever doing that. It was effective though since its projectile stays out long enough to keep dealing damage.
*Has played the game to death.*

It will kill each and every non mini-boss and boss in one hit. The only flaw, really, is that it takes so long. If it was a faster attack, it'd probably be used in speed runs...
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

I also kills a couple minibosses in one hit. But it's not really game breaking.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

grinvader wrote:I also kills a couple minibosses in one hit. But it's not really game breaking.
Considering it allows even a n00b to go through each stage without even trying, I'd call it game breaking.
declan
Lurker
Posts: 194
Joined: Thu Jan 03, 2008 12:45 am
Location: Austalia

Post by declan »

hmmm.....

Apon further investigation, i found that the clock and latch signals are infact NOT too weak for the avr.

When i pulled open a working snes controller, i soldered wires onto the PCB to listen to conversation with my scope.

(when my adapter is connected) It seems that for some reason, the snes refuses to spit out clock and latch pulses.... leaving my adapter stuck in loop of death continually polling for the latch pulse, on the snes controller to usb adapter, the processor is constanly sending out clock and latch pulses, regardless of a controller being connected....

..... interesting.....

There must be some kind of sign the controller gives to the (real) snes (which my adapter doesn't) to say "Yo, im ready, are you ready?"....

I don't know, maybe the data line is left in high impendence with no controller, then when a controller is connected, the line is pulled low, telling the snes to start the clock/ latch pulses....

... maybe i have i fried snes.

In any case, i will need to do more research/ experiments.

EDIT:
BINGO!

The data line is held high (presumably by a pullup resistor in the snes) when no controller is connected.

To tell the snes a controller is present, i will have to drive the line low before and after clock/latch cycles.... which i already thought i did (?)
Hardware means nothing if you don't have good software.
Compare the success of SNES over Genisis
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

It seems you could save a lot of time reading an accurate doc on snes pads before further trial and error.
anomie wrote: The controller ports of the SNES has 7 pins, laid out something like this:

Code: Select all

   _________________ ____________
  |                 |            \
  | (1) (2) (3) (4) | (5) (6) (7) |
  |_________________|____________/
The pins are:
1: +5v (power)
2: Clock
3: Latch
4: Data1
5: Data2
6: IOBit
7: Ground

Latch is written trhough bit 0 of register $4016. Writing 1 to this bit
results in Latch going to whatever state means 'latch' to a joypad.

Clock of Port 1 is connected to the 'read' signal of $4016, in that reading
$4016 causes Clock to transition. Data1 and Data2 are then read, and Clock
transitions back (at this point, the pad is expected to stick its next bits
of data on Data1 and Data2). Clock of Port 2 is connected to $4017.

Data1 and Data2 are read through bits 0 and 1 (respectively) of $4016 and
$4017 (for Ports 1 and 2, respectively). Thus, you must read both bits at
once, you can't choose to read only Data1 and leave Data2 for later.

IOBit is connected to the I/O Port (which is accessed through registers
$4201 and $4213). Port 1's IOBit is connected to bit 6 of the I/O Port, and
Port 2's IOBit is connected to bit 7. Note that, since bit 7 of the I/O Port
is connected to the PPU Counter Latch, anything plugged into Port 2 may
latch the H and V Counters by setting IOBit to 0.

(...)

"Open Port"
-----------

If nothing is plugged into a port (or the thing plugged in doesn't connect to
the pin), the SNES will read zeros from Data1 and Data2.


Joypads
-------

The joypads return 16 bits of data out Data1, then one bits until
latched again. The data is:
byetUDLRaxlr0000

b/y/a/x/l/r are the similarly named buttons. 'e' is select. 't' is start.
U/D/L/R are the pad directions. Note that the standard joypad can only
return either U or D set, and either L or R set. Some games will crash or
exhibit other odd behavior if both U and D and/or both L and R are set.

Data2 is not even connected, nor is IOBit.


Mouse
-----

The mouse returns 32 bits of data out Data1, and 1 bits thereafter. The data
is:
00000000rlss0001 YyyyyyyyXxxxxxxx

l/r are the two mouse buttons. 'ss' are the "speed bits", which are
incremented mod 3 if Clock cycles while Latch is active. Y/X are the
direction bits (set is up/left), and yyyyyyy/xxxxxxx are the distance
traveled in the appropriate direction.

Supposedly, the 'speed bits' may not match the internal speed setting when
the mouse first receives power. The speed setting controls the delta curve
of the mouse, with 0 giving a flat curve and 2 giving the greatest delta
response.

Data2 and IOBit are presumably not connected, but this is not known for
sure.


SuperScope
----------

The SuperScope returns 8 bits of data out Data1, and 1 bits thereafter. The
data is:
fctp00on

'f' is Fire, 'c' is Cursor, 't' is Turbo, 'p' is Pause, 'o' is Offscreen,
and 'n' is Noise.

The SuperScope has two modes of operation: normal mode and turbo mode. The
current mode is controlled by a switch on the unit, and is indicated by the
't' bit. Note however that the 't' bit is only updated when the Fire button
is pressed (i.e. the 'f' bit is set). Thus, when you turn turbo on the 't'
bit remains clear until you shoot, and similarly when turbo is deactivated
the bit remains set until you fire.

In either mode, the Pause bit will be set for the first strobe after the
pause button is pressed, and then will be clear for subsequent strobes until
the button is pressed again. However, the pause button is ignored if either
cursor or fire are down(?).

In either mode, the Cursor bit will be set while the Cursor button is pressed.

In normal mode, the Fire bit operates like Pause: it is on for only one strobe.
In turbo mode, it remains set as long as the button is held down.

When Fire/Cursor are set, Offscreen will be set if the gun did not latch during
the previous strobe and cleared otherwise (Offscreen is not altered when
Fire/Cursor are both clear).

Noise is set if there is interference in the infrared transmission from the
Scope to the receiver.

If the Fire button is being held when turbo mode is activated, the gun sets the
Fire bit and begins latching. If the Fire button is being held when turbo mode
is deactivated, the next poll will have Fire clear but the Turbo bit will not
be updated until the next fire (i.e. FcTp => turbo off => fcTp, not fctp).

The PPU latch operates as follows: When Fire or Cursor is set, IOBit is set
to 0 when the gun sees the TV's electron gun, and left a 1 otherwise. Thus,
if the SNES also leaves it one (bit 7 of $4201), the PPU Counters will be
latched at that point. This would also imply that bit 7 of $4213 will be 0
at the moment the SuperScope sees the electron gun.

Since the gun depends on the latching behavior of IOBit, it will only
function properly when plugged into Port 2. If plugged into Port 1 instead,
everything will work except that there will be no way to tell where on the
screen the gun is pointing.

When creating graphics for the SuperScope, note that the color red is not
detected. For best results, use colors with the blue component over 75% and/or
the green component over 50%.

Data2 is presumably not connected, but this is not known for sure.


Justifiers
----------

The Justifier returns 48 bits of data out Data1. Presumably it returns
one bits after (if so, it really only returns 32 bits), but this is not
known. The data is:
0000000000001110 01010101TtSsl000 1111111111111111

T/t are the trigger states for guns 1 and 2. S/s are the start button states
for guns 1 and 2. 'l' indicates which gun was connected to IOBit: 1 means
gun 1, 0 means gun 2. Note that 'l' toggles even when gun 2 is not connected.

IOBit is used just like for the SuperScope. However, since two guns may be
plugged into one port, which gun is actually connected to IOBit changes each
time Latch cycles. Also note, the Justifier does not wait for the trigger to
be pulled before attempting to latch, it will latch every time it sees the
electron gun. Bit 6 of $213F may be used to determine if the Justifier was
pointed at the screen or not.

Data2 is presumably not connected, but this is not known for sure.


MP5
---

The MP5 plugs into one Controller Port on the SNES (typically Port 2), and
has 4 ports for controllers to be plugged into it (labeled 2 through 5). It
also has an override switch which makes it pass through Pad 2 and ignore
everything else.

If IOBit is 1, Clock is passed through to Pad 2 and Pad 3, Data1 is
connected to Data1 on Pad 2, and Data2 is connected to Data1 on Pad 3. If
IOBit is 0, Pads 4 and 5 are used instead of 2 and 3, respectively. In
either case, Latch is passed through to all pads, and IOBit is presumably
not passed through at all.

Note that Clock is only passed through to the pads that are actually being
passed through. Thus, you can read the first two pads (or let Auto-Joypad
Read do it), then toggle IOBit and read the other two pads manually. Most
games requiring more than 3 players do exactly this.

Also note that there is nothing preventing the MP5 from functioning
perfectly when plugged in to Port 1, except that the game must use bit 6 of
$4201 instead of bit 7 to set IOBit and must use the Port 1 registers
instead of the Port 2 registers. With 2 MP5 units, one could actually create
an 8-player game!

When Latch is active, 1s will be read from Data2 and 0s from Data1. This is
sometmies used to detect the presence of an MP5 unit. The override switch
disables this behavior.

There are reports that the MP5 does not react immediately when IOBit is
transitioned from 0 to 1. Thus, reading 2&3 then 4&5 will probably work
better than vice versa.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

I.S.T. wrote:
Deathlike2 wrote:
I.S.T. wrote:Not good at Megaman X, even after getting the completely game breaking Storm Tornado that kills every non mini-boss or boss with one hit?
I don't recall it ever doing that. It was effective though since its projectile stays out long enough to keep dealing damage.
*Has played the game to death.*

It will kill each and every non mini-boss and boss in one hit. The only flaw, really, is that it takes so long. If it was a faster attack, it'd probably be used in speed runs...
Mini-bosses are one thing, and worth abusing against. Bosses have delayed damage intake, which dish out another extra hit or two.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
declan
Lurker
Posts: 194
Joined: Thu Jan 03, 2008 12:45 am
Location: Austalia

Post by declan »

Where did you find that grin??

I wasn't able to find any documents anywhere near that level of detail (using google).

Any way, all i had to do (i think, haven't tested yet) was change bit 0 of PortD from 1 to 0, in the Init section.

This changes the initial state of the snes data line.

Before the data line was held high, so the snes didn't think there was any controller connected.
Hardware means nothing if you don't have good software.
Compare the success of SNES over Genisis
declan
Lurker
Posts: 194
Joined: Thu Jan 03, 2008 12:45 am
Location: Austalia

Post by declan »

I have done some more tests on my snes.... here are my findings

The state data line means nothing.... it is held high when no controller is connected so the CPU doesn't think that every buttton is pressed!

After ripping open my snes, to stick probes into it, i found that infact the snes IS spittig out clock and latch pulses..... the reason that they don't register on my scope is.... the controller has to provide pullups on the clock and lach sinals......

I discovered this, when i decided to take a 1K resistor and shork it between the Vcc pin and the clock/ latch pins, and PRESTO, the clock and latch pulses show on my scope!

..... Its so simple :/, why didn't i realise earlier.

So all i had to do is activate the internal pullups on PC5 (latch) and PC3 (clock).

After changing the value of 2 bits in the PortD, i tested on a real snes, it tested PERFECTLY.

WOOHOO

Now it works on my usb adapter and more importantly, on a real snes :)

*dances around the room like a friggen idiot*

I will now be posting a video of me using it on a snes, not an emulator.:D

*goes and plays massive session of Yoshi's Island*
Hardware means nothing if you don't have good software.
Compare the success of SNES over Genisis
Rashidi
Trooper
Posts: 515
Joined: Fri Aug 18, 2006 2:45 pm

Post by Rashidi »

great progress there. congrats

to spice up your skills, how about mapping the unused n64 gamepad button to rapidfire/turbo button for snes?
(perhaps with clock-counting and ...)


my story with certain game with Turbo button feature (on ZSnes):
  • for game terranigma, i assign button for "A" and "Turbo A" in ZSnes.

    with the way Turbo button programmed in emulator, if i hold the "Turbo A" buton Ark wil do attack repeatedly but not the Rushing Attack.

    however, if i repeatedly tapping the "A" buton Ark will do the Rushing Attack.
    while in Rushing Attack mode, if i hold the "Turbo A" button and no-longer tapping the "A" button, Ark will maintain the Rushing Attack.

    I really like how ZSnes implement the turbo button :D
declan
Lurker
Posts: 194
Joined: Thu Jan 03, 2008 12:45 am
Location: Austalia

Post by declan »

Rashidi wrote:to spice up your skills, how about mapping the unused n64 gamepad button to rapidfire/turbo button for snes?
(perhaps with clock-counting and ...)
Not sure how that could be done.

My adapter is emulating a snes controller. So there's no buttons left to map.... even though there is physically two face bottons and an analog stick that are unused.... do you see what i mean?

Its a nice thought, but i'm restriced by limitations of the snes controller.
Hardware means nothing if you don't have good software.
Compare the success of SNES over Genisis
ReRuss
Trooper
Posts: 443
Joined: Sun Aug 15, 2004 9:49 pm
Location: Somewhere
Contact:

Post by ReRuss »

I've never tested a rapid button assignment...

I always use my asciipad which has turbo switches for all buttons...
[img]http://i5.photobucket.com/albums/y180/ReRuss/UBAR.gif[/img]
360 and PS3 - ReRuss
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

declan wrote:Where did you find that grin??

I wasn't able to find any documents anywhere near that level of detail (using google).
Well, the first part is from this one: link
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
declan
Lurker
Posts: 194
Joined: Thu Jan 03, 2008 12:45 am
Location: Austalia

Post by declan »

And more pics:

I remade the circuit with new parts, the prototype was all dirty.
Image

And the finished product..... how pretty!
Image

And finally the video.
http://youtube.com/watch?v=7NUzgL1l4_U

The video has poor resolution and poor sound.

PLEASE NOTE
I don't intend on distributing my source code or hex file yet. I plan on adding mouse and joystick (as snes D-pad) support first.

Though I will happily send you a preprogrammed chip ,for the cost of the chip and postage, if you really want do build by adapter sooner :) ..... but i doubt you will.
Hardware means nothing if you don't have good software.
Compare the success of SNES over Genisis
Post Reply