News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_mr_lou

Joystick Firebutton confusion

Started by mr_lou, 15:43, 12 July 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mr_lou

So a while back my girlfriend I were gonna play a 2-player game of PANG on my CPC+ but experienced something weird:
The firebuttons seemed to be reversed on port 2 (JOY1), so player 2 couldn't play with a joystick that only had 1 fire button.

Ok, fast forward to now. I'm experiencing the same when developing using CPCTelera by @ronaldo.

First, a BASIC program:

10 print joy(0), joy(1)
20 goto 10


This little BASIC program tells me that both JOY0 and JOY1 returns the value 16 when I press the FIRE button. That's what I expected.

Ok, now this little program in CPCTelera:


#include <cpctelera.h>
#include <stdio.h>

void main(void) {
    printf("Joystick firebutton test\n\r");
    printf("========================\n\r");
    while (1) {
    cpct_scanKeyboard();
    if (cpct_isKeyPressed(Joy0_Fire1)) printf("Joy0 fire 1\n\r");
    if (cpct_isKeyPressed(Joy0_Fire2)) printf("Joy0 fire 2\n\r");
    if (cpct_isKeyPressed(Joy0_Fire3)) printf("Joy0 fire 3\n\r");
    if (cpct_isKeyPressed(Joy1_Fire1)) printf("Joy1 fire 1\n\r");
    if (cpct_isKeyPressed(Joy1_Fire2)) printf("Joy1 fire 2\n\r");
    if (cpct_isKeyPressed(Joy1_Fire3)) printf("Joy1 fire 3\n\r");
    cpct_waitVSYNC();
   }
}


This little program tells me, that the FIRE button on JOY0 is Fire1 as I expected it to be.
But the FIRE button on JOY1 is in fact Fire2. Did not expect that.

I would think it was an error i CPCTelera, except I already experienced the same with PANG. And I know it's not a faulty wiring, because both joysticks returns 16 in BASIC.
So what is it? Some old well-known bug that everyone knows about except me?
What do other coders typically do about it?

TFM

Did you use an original Joypad? Or just some random joystick, which may have a shortcut?


Fire 1 should return 16
Fire 2 should return 32
Fire 3 should return 64 (spare)

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

mr_lou

Quote from: TFM on 15:47, 12 July 15
Did you use an original Joypad? Or just some random joystick, which may have a shortcut?

In Pang, I can plug CPC+ joypads into both ports. Then the player on JOY0 will need to press Fire1 to shoot, and the player on JOY1 will need to press Fire2 to shoot.
That makes no sense.

But now I'm seeing it's the same in CPCTelera.

No, I have tried different joysticks.

mr_lou


TFM

Quote from: mr_lou on 15:50, 12 July 15
In Pang, I can plug CPC+ joypads into both ports. Then the player on JOY0 will need to press Fire1 to shoot, and the player on JOY1 will need to press Fire2 to shoot.
That makes no sense.


So Fire 1 selects Player 1 and Fire 2 selects Player 2. Makes sense.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TFM

Quote from: mr_lou on 15:52, 12 July 15
Here is the joytest DSK.


It works fine for Joystick1 Fire 1,2,3. Couldn't test Joy0.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

mr_lou

#6
Quote from: TFM on 16:05, 12 July 15It works fine for Joystick1 Fire 1,2,3. Couldn't test Joy0.

That is just extremely weird!!!!

I have the problem both on my CPC464 and my CPC+.

On the CPC+:
The same joypad first in port 0, fire button 1 = fire 1, fire button 2 = fire 2.
Then put the same joypad into port 1, fire button 1 = fire 2 and fire button 2 = fire 1.

On the CPC:
The same happens, tried with 2 identical Wico joysticks in both ports.

This not faulty wiring as I said. This is some hardware bug thingy that I never heard about, and you apparently haven't either.

EDIT: Unless it really is a bug in both Pang and CPCTelera....

TFM

Quote from: mr_lou on 16:11, 12 July 15
On the CPC+:
The same joypad first in port 0, fire button 1 = fire 1, fire button 2 = fire 2.
Then put the same joypad into port 1, fire button 1 = fire 2 and fire button 2 = fire 1.

On the CPC:
The same happens, tried with 2 identical Wico joysticks in both ports.


But the CPC only has ONE port. So I don't get it? Can somebody can do some tests please?  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

mr_lou

Quote from: TFM on 16:17, 12 July 15But the CPC only has ONE port. So I don't get it? Can somebody can do some tests please?  :)

I'm using a Y-splitter of course.
Bought 2 of these off eBay. Seller says it has the diodes.

arnoldemu

#9
I tested Pang.
Confirmed, player 2 presses fire 2 to shoot the harpoon, player 1 presses fire 1.

However, i then used the arnold v  diagnostic cart. it showed the same as your first test in basic.

I looked at cpctelera's header file. It is incorrect.


Don't know why Pang uses fire1/fire2 like that! My only guess is that they experienced some button clash with fire1/fire2 when two players are playing. I see that fire1 and fire2 don't have diodes. But, because the directions have diodes and the fire's don't, I think you still can't cause clash if using just joysticks.

To cause clash you ordinarily need to press a direction AND fire, and the other player needs to press at least a direction or fire, then clash happens, but with diodes on the directions, the only way to cause clash is if one player presses both fires, and the other player presses 1 fire, I think.

I will need to retest, but I never saw clashes on the joysticks on plus.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

mr_lou

Thanks a lot Kevin!

Quote from: arnoldemu on 16:56, 12 July 15
I looked at cpctelera's header file. It is incorrect.

So you're saying I found a bug in CPCTelera?

Hereby forwarded to @ronaldo.

ronaldo

Why shouldn't it be a bug in CPCtelera? Who thinks I'm so evil as to be perfect? :D

I'm pretty sure that CPCtelera is far from being bug-free. It should have at least as many bugs as I have as person, or more :D.

That's why it's so nice to be a complete community, and not just a solitary plainsman ;)

I'll have a look at it :)

mr_lou

Quote from: ronaldo on 17:54, 12 July 15
Why shouldn't it be a bug in CPCtelera? Who thinks I'm so evil as to be perfect? :D

It was my Pang experience that threw me off.
Being so flawless as I am, I tend to think everyone else is too.  ;)

ronaldo

I think I might have found the source from the problem. We have 2 conflicting documentations online, if I'm not mistaken. Take a look:
As you can see, CPCWiki's says that Joy1_Fire = Key G (without saying anything about Fire1/Fire2/Fire3). CPCTech says that Joy1_Fire1 = Key F, Joy1_Fire2 = Key_G.

CPCtelera follows CPCTech's and I haven't got a 2nd joystick interface to test it on a real CPC. However, I think this might be the source of the problem and CPCTech's documentation might be incorrect. Anyone can check this information? @arnoldemu?
I think this is a good opportunity to check this documentation discrepancy between CPCTech's and CPCWiki's and unify both :).

KaosOverride

If you look to the joystick pinout, you have fire 3, 1 and 2 in that order. If you redefine keys at north and south, Fire 1 and Fire 2 are named incorrect, both names are interchanged.

My theory is that fires where designed as Fire 3, 2, 1 and then coders found that the Atari norm used the Fire 2, so Fire 2 became the "main" fire. Then you have the Fire 3, 1, 2 we have today.
KaosOverride · GitHub
MEGA Amstrad Public Amstrad folder

Lazy Dude

Being a knowledgeable person who knows nothing about anything, I thought I'd pop up my opinion!

Firstly with the instruction manual for the 464 and 6128 it shows all the keyboard and joystick values etc.. so that's definitive, no guessing!

Joys 0 & 1 primary fire is fire 2 and fire 1 is the secondary "optional" function which on one of the joy (forget which!) is not always supported by all softwares.

Maybe open the plugs on the splitter to satisfy yourself that its all good for diodes and wiring?

arnoldemu

I think you are correct the cpctech document is probably incorrect.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

mr_lou

That means, that bit 4 (value 16) = Fire 2 and bit 5 (value 32) = Fire 1.

Indeed, that is what the manual says too in chapter 8 page 22.

@ronaldo, that actually means that CPCTelera keyID Joy0_Fire1 and Joy0_Fire2 is wrong, while Joy1_Fire1 and Joy1_Fire2 is right.
I thought it was the other way around.

Standard fire button on joysticks that only has 1 button, is bit 4 (value 16) which should correspond to Joy0_Fire2 in CPCTelera. Currently it corresponds to Joy0_Fire1.

This should no doubt be mentioned in the Reference Manual: "Please note that the standard fire button is Fire 2!!! Yes! This is normal. Look it up. All games use Fire 2 button. Fire 1 only exists on joysticks that has 2 buttons".


ronaldo

@mr_lou: the only real problem is messing up constants. If both Joy0_Fire1 and Joy1_Fire1 refer to the same button of the different joysticks, that would be enough. If they are really wired to Fire2, but Fire2 is used as main fire in 1-button joysticks, I think that's okay. In fact, I think that's preferably from the programmer point of view: they would prefer using Fire1 intuitively rather than finding that they should use Fire2 as that's the real fire button used in joysticks (and having to ask and read about the subject).

As long as constant names are consistent, I think it's not a problem, as CPCtelera progammers will use the appropriate constant and refer to the button they wanted. I'm going to change the Joy1_Fire1 <-> Joy1_Fire2 constants to solve this issue, as I think that's the better solution by now.

Lazy Dude

As Alan Sugar would say- "You're Fired!"   :P

ZbyniuR

Should be:

In old CPC
Joy0  pin8  connect with:
pin6  Fire1  key76  code(X)
pin7  Fire2  key77  code(Z)
pin5  Fire3  key78  code(255 not visible)

Joy1  pin9  connect with:
pin6  Fire1  key52  code(g)
pin7  Fire2  key53  code(f)
pin5  Fire3  key54  code(b)


In CPC Plus
Joy0 and Joy1 have separately ports, so in both GND is on pin8.
And no signal on Pins5 so Fire3 dosen't work.

No signal crush in any case. The only problem is, all "User Guides for CPC" show name Fire1 and Fire2 swap as F1 on pin7 and F2 on pin6. What is no make sens, because any Atari standard Joystick with only one fire, connect pins 8 with 6. So why Guide name it as Fire2 ??

Thats is reason why some documents quote Guide and others named Fire with X as Fire1 like in Atari standard. Thats is source of all this misunderstanding. I prefer Atari point of view. :)

In STARS, TREK is better than WARS.

TFM

Because it's Amstard and not Atari. Nobody told that CPC have Atari plugs. They got Amstrad plugs, and Amstrad made Joysticks for em ;-)

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Lazy Dude

I must admit I always took it for granted that when the old cpc manuals state 'pin 5 spare' that it was not connected.
That's something else to tinker with when I get round to it.

ZbyniuR

Yes, some documents mention about Fire3 as undocumented. But AMX mouse is using this pin5 as third button.
And all software producer treat Fire(X), as main or as only one Fire in CPC. The same like in Atari standard. But Atari standard has no second Fire because on pins 5 and 9 have analog paddle signal.

Amiga have:
pin6  F1  Button-L  <- the same like Atari and CPC
pin9  F2  Button-R  <- impossible in CPC here
pin5  F3  Button-M  <- the same like CPC and ST
In STARS, TREK is better than WARS.

TFM

Few games on CPC actually use both official Fire buttons. Probably because there are only a couple of joysticks providing more then one fire signal.


Some of my joysticks have fire 1,2,3 because it's just convenient sometimes. And I liked to solder back the day ;-)


Next up: Using a Quickshot for Nintendo for a mod to run with CPC.  ;D  (In the usa you can't get a regular stick (I means sub D 9 pin plug) for a decent price).  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Powered by SMFPacks Menu Editor Mod