Joystick issue

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
LukasP
Posts: 15
Joined: Mon Mar 11, 2019 10:56 pm

Joystick issue

Post by LukasP » Thu May 16, 2019 12:51 am

My joystick does work on Balloon Fight, Bomberman, however in Balloon fight it doesn't work. I pass nestest and Blarrg's CPU test and I have no idea why it could not work. Controller code is checked rechecked and rewritten few times still to no avail.
Now I have an idea maybe it's somehow related to dummy reads/writes. I've not implemented those however now start to think if they would help?
Can anyone shed me some light?

lidnariq
Posts: 8703
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Joystick issue

Post by lidnariq » Thu May 16, 2019 10:39 am

LukasP wrote:My joystick does work on Balloon Fight, Bomberman, however in Balloon fight it doesn't work. I pass nestest and Blarrg's CPU test and I have no idea why it could not work. Controller code is checked rechecked and rewritten few times still to no avail.
Even so, I think you've got a CPU bug.

Paperboy is the only game that we know of that relies on correct open bus behavior on the upper three bits of the controller ports, and I can't imagine we'd recommend people try Balloon Fight if it also depended on same.
Now I have an idea maybe it's somehow related to dummy reads/writes. I've not implemented those however now start to think if they would help?
Unless you explicitly see something wacky like lda $3FFF,x being used to load the controller port, no, that won't help.

LukasP
Posts: 15
Joined: Mon Mar 11, 2019 10:56 pm

Re: Joystick issue

Post by LukasP » Thu Jun 06, 2019 5:04 am

@lidnariq you were totally correct about the CPU issue. Tired of shooting in the dark I just went to NMI of a balloon fight and just looked what are the instructions used inside of it. There were only several so I hand checked them super super carefully and found a bug in my LSR routine. Now i'm amazed that nestest passed with my faulty implementation of it. As I fixed LSR a bunch of games fixed - donkey kong started to show proper loading screen instead of trash, input works on all of the games.
Thanks for reaffirming that it's a CPU issue as otherwise I would have probably poked elsewhere for a while

User avatar
zeroone
Posts: 929
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Joystick issue

Post by zeroone » Thu Jun 06, 2019 6:51 am

LukasP wrote:i'm amazed that nestest passed with my faulty implementation of it
What was the bug? Maybe the test ROM can be enhanced.

tepples
Posts: 21720
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Joystick issue

Post by tepples » Thu Jun 06, 2019 7:42 am

Correct behavior: LSR sets carry to bit 0 of input value
The defect in this case: LSR sets carry to old carry AND bit 0 of input value. Can clear to 0 but not set to 1.

If carry is 1 before the test, or if input bit 0 is 0, there is no difference. The defect is apparent only if carry was 0 before the test and input bit 0 is 1.

Post Reply