joypad handles

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
joypad handles
by on (#48101)
I have some doubts about joypad handles, due to
controversial points I found in the various docs:

1. Reading from $4016/$4017 when a button is pressed,
returns 1 or $41? (and when is released, 0 ro $40?)

2. $4016: After the 16 bytes from joypad#1 and joypad#3,
how many bytes for signature in the last 8 bytes?
(some docs tells 4, followed
by 4 zero bytes, other docs tell all the eight bytes)

3. Seems that when four score is not present or not switched
to 4 players, output is different (joypad#3 bytes returns
0, and signature is 0, or $ff, but what it should returns
exactly?)

4. Older documents tells that when the joypad is in
half strobe state returns data from expansion port.
From posts on this forum I know this is not true
(it returns the state of A button, because no shift
occurs). But, then, how data are read from expansion port?

Thanks,
tano
Re: joypad handles
by on (#48129)
tanoatnd wrote:
I have some doubts about joypad handles, due to
controversial points I found in the various docs:

1. Reading from $4016/$4017 when a button is pressed,
returns 1 or $41? (and when is released, 0 ro $40?)

2. $4016: After the 16 bytes from joypad#1 and joypad#3,
how many bytes for signature in the last 8 bytes?
(some docs tells 4, followed
by 4 zero bytes, other docs tell all the eight bytes)

3. Seems that when four score is not present or not switched
to 4 players, output is different (joypad#3 bytes returns
0, and signature is 0, or $ff, but what it should returns
exactly?)

4. Older documents tells that when the joypad is in
half strobe state returns data from expansion port.
From posts on this forum I know this is not true
(it returns the state of A button, because no shift
occurs). But, then, how data are read from expansion port?

Thanks,
tano


1. It generally returns 0x40 for not pressed, 0x41 for pressed, it is ORed with 0x40 because of open bus (the 0x40 comes from the high address of 0x4016 and 0x4017).

2. For generally up to date docs, use the nesdevwiki.org, as for the read, http://nesdevwiki.org/wiki/Four_Score .

by on (#48134)
I found the nesdevwiki very useful for many points.
However about this I am a bit confusing, it says (in the standard
controller page), that all the reads following the first 8 bytes should
return 1 on authentic controller and could return 0 on third-party controllers (nothing about open bus there).
In the four score page,
it says that when the switch is 2-players mode, it returns as
a normal controller, i.e. 0 or $ff depending on the controller.

Thanks,
tano

by on (#48135)
tanoatnd wrote:
I found the nesdevwiki very useful for many points.
However about this I am a bit confusing, it says (in the standard
controller page), that all the reads following the first 8 bytes should
return 1 on authentic controller and could return 0 on third-party controllers (nothing about open bus there).
In the four score page,
it says that when the switch is 2-players mode, it returns as
a normal controller, i.e. 0 or $ff depending on the controller.

Thanks,
tano


The wiki only covered bit 0 of the read because its the only relevant bit for the controller, I got the open bus info from Disch http://disch.arc-nova.org/nes_input.txt , and kevtris, http://blog.kevtris.org/blogfiles/EWJ2PROT.TXT , (at the end), games should use only bit 0, but as you can see, some carts rely on open bus behavior for pirate protection. If the wiki says four score behavior is the same as a regular controller if it is in the 2 player mode, i would guess it will return the same thing as if 2 controllers are hooked up (like the standard controller), since the four score is an adapter, if 2 controllers are hooked up, they should treat it as if 2 controllers are hooked to the real nes. I am not sure what the doc meant by return $00 or $FF depending on the controller.

by on (#48142)
Thanks. Open bus is a curious behavior.

by on (#48144)
I wish we had open bus here in Fort Wayne. Citilink doesn't run at night, on Saturday evenings, or on Sundays at all.

Oh, you meant that open bus.

by on (#48147)
To Tepples: some days from here I will be able to start implementing
APU support in my emulator: I will not speaking about that APU ;-)

by on (#48430)
tepples wrote:
I wish we had open bus here in Fort Wayne. Citilink doesn't run at night, on Saturday evenings, or on Sundays at all.

Oh, you meant that open bus.


Meh. :)
I wonder if the correct write is openbus, like mentioned here.

Did you see a ghost, a phantom or a spirit? ;)