Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
Joined: Feb 2014
Posts: 819
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 819
Likes: 32
Hi guys,

Was watching some longplays on youtube and got inspired to play Datasoft Conan but I had some weirdness with the joystick.


For some reason, using apple2e the joystick isn't working correctly, I can't go up the ladder.

Apple2p works. Apple2c works.

but strangely apple2e and apple2ee doesn't work.

I try a little basic program

100 ? PDL(0), PDL(1)
110 GOTO 100

and it doesn't seem to respond for apple2e. For apple2p only PDL(1) seems to respond. I'm kinda baffled.

I tried total replay and it said no joystick detected and I've got -gameio joy specified.


edit:
total replay with apple2p 242 detects joystick
total replay with apple2p 243 doesn't detect joystick

(both self compiled)

Last edited by Golden Child; 05/04/22 08:33 PM.
Joined: Mar 2001
Posts: 16,911
Likes: 56
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 16,911
Likes: 56
That's bizarre. Literally nothing changed in apple2p or the gameio stuff for 243.

Joined: Feb 2014
Posts: 819
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 819
Likes: 32
Yeah, I don't know if there's something wrong with this computer.

What's really wacky is that sometimes when I launch my self compiled mame 243 with Total Replay sometimes it will detect the joystick and sometimes it won't. I always thought it was supposed to be deterministic, but maybe it's one of those uninitialized memory things or memory's getting trashed.

Joined: Feb 2004
Posts: 2,367
Likes: 81
Very Senior Member
Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,367
Likes: 81
Use a debug build? Use valgrind to catch uninitialised memory?

Joined: Dec 2011
Posts: 181
Likes: 2
Senior Member
Offline
Senior Member
Joined: Dec 2011
Posts: 181
Likes: 2
Wasn't 0.243 the release MAME finally merged drvnoclear? Maybe this is fallout from that.

1 member likes this: R. Belmont
Joined: Mar 2001
Posts: 16,911
Likes: 56
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 16,911
Likes: 56
That's a very good point. I'll check for uninitialized variables.

Joined: Feb 2014
Posts: 819
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 819
Likes: 32
I installed Valgrind and ran with it and it says "Conditional jump or move depends on uninitialized value(s) and it lists apple2_state::controller_strobe_w".

maybe it fails to handle the case where m_joystick_x1_time < machine time and never updates the m_joystick_x1_time (like NaN comparison or something) because I don't see where m_joystick_x1_time (and the others get initialized)


Code
void apple2_state::controller_strobe_w(u8 data)
{
        // 558 monostable one-shot timers; a running timer cannot be restarted
        if (machine().time().as_double() >= m_joystick_x1_time)
        {
                m_joystick_x1_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl0_r();
        }
        if (machine().time().as_double() >= m_joystick_y1_time)
        {
                m_joystick_y1_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl1_r();
        }
        if (machine().time().as_double() >= m_joystick_x2_time)
        {
                m_joystick_x2_time = machine().time().as_double() + m_x_calibration * m_gameio->pdl2_r();
        }
        if (machine().time().as_double() >= m_joystick_y2_time)
        {
                m_joystick_y2_time = machine().time().as_double() + m_y_calibration * m_gameio->pdl3_r();
        }

}

Last edited by Golden Child; 05/05/22 08:52 PM.
Joined: May 2009
Posts: 2,036
Likes: 77
J
Very Senior Member
Offline
Very Senior Member
J
Joined: May 2009
Posts: 2,036
Likes: 77
Originally Posted by Golden Child
maybe it fails to handle the case where m_joystick_x1_time < machine time and never updates the m_joystick_x1_time (like NaN comparison or something) because I don't see where m_joystick_x1_time (and the others get initialized)

You mean it fails to handle the case where m_joystick_*_time > machine_time. Every one of those checks is a less-than check. The relevant members should simply be initialized to zero.

Joined: Feb 2014
Posts: 819
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 819
Likes: 32
You're right, JD.

If one of the variables is NaN the comparison will always fail. So if the uninitialized variable gets NaN the comparison fails and then it will never get updated.

At least that's the way I understand it. (Plugging NaN < 1.0 into firefox's console gives false)

"If your compiler produces a NaN, it has the unusual property that it is not equal to any value, including itself. For example, if a is NaN, then a == a is false. In fact, if a is NaN, then a will be neither less than, equal to, nor greater than any value including itself. In other words, regardless of the value of b, a < b, a <= b, a > b, a >= b, and a == b will all return false."

Also, if the uninitialized variable m_joystick_x1_time is large, the comparison (machine().time().as_double() >= m_joystick_x1_time) will not be true and it will never update the m_joystick_x1_time.

Joined: Mar 2001
Posts: 16,911
Likes: 56
R
Very Senior Member
Online Content
Very Senior Member
R
Joined: Mar 2001
Posts: 16,911
Likes: 56
Right, it's just that those aren't initialized in apple2.cpp or apple2e.cpp (but they are in apple2gs.cpp). I'll check in a fix in a minute. (And thanks to Alegend for suggesting what was actually the problem!).

Page 1 of 2 1 2

Link Copied to Clipboard
Who's Online Now
2 members (Pernod, 1 invisible), 28 guests, and 3 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,086
Posts119,087
Members5,014
Most Online890
Jan 17th, 2020
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com