News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_MacDeath

[GX4000/Plus] Analog joystick port

Started by MacDeath, 12:41, 01 February 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MacDeath

ok, i start a topic here.

This is the continued discussion from
http://cpcwiki.eu/forum/index.php/topic,417.msg5143.html#msg5143

concerning the analog joystick stuff related for the Plus range.


I found out that Tennic cup 2 allows the use of an anolog Joystick (for the 2nd player only).

Also I gave it a try with a 4 button analog joystick.

If someone could find a proper 2 button one, this would be better as the "4 buttons" is a bit too exotic or modern for our good old Plus.


Also analysis of the "Tennis cup2" game programm may be fine to see how they managed it.


Also a question : did the CPC old range included peripherals such as an analog joystick extension ?

If not, this may be a fun project in a DIY section, yet I'm not sure actual Games developpers would feature this possibility in their gameplays.

Related Wiki pages :

http://cpcwiki.eu/index.php/Tennis_Cup_2_%28_Cartridge_%29
http://cpcwiki.eu/index.php/Connector:Analogue_joystick_%28CPC_Plus_only%29
http://cpcwiki.eu/index.php/Analog_Joysticks

Also what is the proper term ?

Analog or Analogue ?
Or even Analogic ?

arnoldemu

Quote from: MacDeath on 12:41, 01 February 10
ok, i start a topic here.

This is the continued discussion from
http://cpcwiki.eu/forum/index.php/topic,417.msg5143.html#msg5143

concerning the analog joystick stuff related for the Plus range.


I found out that Tennic cup 2 allows the use of an anolog Joystick (for the 2nd player only).

Also I gave it a try with a 4 button analog joystick.

If someone could find a proper 2 button one, this would be better as the "4 buttons" is a bit too exotic or modern for our good old Plus.


Also analysis of the "Tennis cup2" game programm may be fine to see how they managed it.


Also a question : did the CPC old range included peripherals such as an analog joystick extension ?

If not, this may be a fun project in a DIY section, yet I'm not sure actual Games developpers would feature this possibility in their gameplays.

Related Wiki pages :

http://cpcwiki.eu/index.php/Tennis_Cup_2_%28_Cartridge_%29
http://cpcwiki.eu/index.php/Connector:Analogue_joystick_%28CPC_Plus_only%29
http://cpcwiki.eu/index.php/Analog_Joysticks

Also what is the proper term ?

Analog or Analogue ?
Or even Analogic ?
I analysed it and the source code is on the info for tennis cup 2.

I always use the term "analogue".

btw I had a pc gamepad that didn't work with cpc+.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

MacDeath

Thx for that.

What is the reference/model of this analogue pad ?

It would be great to find some who actually work so we have to test every model we may find....


Also I wonder :
would it be possible to add a proper keyboard to a GX4000 thx to the analogue port ?
Would it work or is the analogue port too limited ?

arnoldemu

Quote from: MacDeath on 19:07, 01 February 10
Thx for that.

What is the reference/model of this analogue pad ?
mine didn't work, but I think they said that the ones that were suitable for the amstrad pc's worked fine. not sure if they were talking about pc1640 or the later ones...

Quote from: MacDeath on 19:07, 01 February 10
It would be great to find some who actually work so we have to test every model we may find....
I'lll look at it. think it was a competition pro.
I tried to make adaptor, but that didn't work :(

Quote from: MacDeath on 19:07, 01 February 10
Also I wonder :
would it be possible to add a proper keyboard to a GX4000 thx to the analogue port ?
Would it work or is the analogue port too limited ?
No I don't think so, the port is too limited. Also a "newer" usb/ps2 style keyboard needs init commands - so needs 2 way communication.

However, I would like to know which gamepads/joysticks would work.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

dragon

I have a genius maxfire g-07.I remember that some buttons operating In the basic.

But right now I do not remember which.

The pad has 8 buttons and 4 turbo mode  ::)

let me try it again.


TFM

Quote from: MacDeath on 12:41, 01 February 10
Also analysis of the "Tennis cup2" game programm may be fine to see how they managed it.

Why dissassemble Tennis cup2 when you can do it with FutureOS?

No, serious. To use the analogue joystick is very easy:

- Read X value from the memory mapped IO
- Subtract &20 = 32 (like I remember)
- negative values go left, positive values go right. The bigger the value, the faster the move.
- Do the same for Y

Do you need source? Then contact me via email.

Would be nice to see SOS working with the analogue Joystick too :-P
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

MacDeath

#6
QuoteI have a genius maxfire g-07.I remember that some buttons operating In the basic.
But right now I do not remember which.
The pad has 8 buttons and 4 turbo mode
That must be a bit too much buttons...lol.
Yet you should try it on Tennis cup 2 if you own it.

Quotemine didn't work, but I think they said that the ones that were suitable for the amstrad pc's worked fine. not sure if they were talking about pc1640 or the later ones...
OMFG, I completly forgot Amstrad used to built PC, and those used to have analogue joysticks...

Yet those must be hard to find nowadays...

QuoteWhy dissassemble Tennis cup2 when you can do it with FutureOS?
All right, yet I see no point having an analogue joystick in an OS...
Games may be suitable, perhaps some 3D construction applications too...
But an OS...a mouse would be more usefull...lol.

Thx for your source, but I definitly suck at coding.

I'm just trying to be usefull, as the Analogue topic was a bit in the fog of ignorance, or seemed to be.



Yet the best way may be to re-wire entirely an analogue joy...as always.



Also, what kind of game may actually be well suited for the use of an analogue joy ?


Games like 3D shooterz (Starglider, elite ?)
Flight simulators...
And ? Tennis games ?

The problem is that such games are no more produced on Amstrad.

Most productions are :
--Adventure : no great need for analog.
--2D action games : platformers, shooterz...no need too.
--reflexion and reflex games (tetris-like,  sudoku, othello like...), no need too.

Analogue is best fit for pseudo 3D environment or Race games (Burnin rubber like, test drive and so on).


Yet modding actual games to include the Analog feature may be interesting...
Yet we don't even know if we will find a proper working model.


Do you think Arkanoid like games would be nice with an analog joy ?



Another question :
the analog port allows in fact the use of 2 analog joysticks (need a special Y-cable).

So is it possible to actually get 4 joysticks on the good old GX4000/Plus range ?

As Analog can also be used to get pseudo-digital joysticks.

arnoldemu

Quote from: TFM/FS on 23:07, 01 February 10
Why dissassemble Tennis cup2 when you can do it with FutureOS?
Well it is interesting to see the routine that scans the joystick because you may do it a different way.


Quote from: TFM/FS on 23:07, 01 February 10
Do you need source? Then contact me via email.
Would you upload the source to the wiki in the article about the analogue joystick?

Quote from: TFM/FS on 23:07, 01 February 10
Would be nice to see SOS working with the analogue Joystick too :-P
agreed. it would be nice to see lots of games using the joystick.
Which joystick/joypad did you use because mine is not compatible with the CPC+ :(
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

Quote from: MacDeath on 00:21, 02 February 10
So is it possible to actually get 4 joysticks on the good old GX4000/Plus range ?

As Analog can also be used to get pseudo-digital joysticks.
Well maybe.. BUT:

The analogue joysticks share the same fire buttons with the digital joysticks.

The directions are independant so from that perspective 4 joysticks are useable (using a splitter on the analogue port to get 2 here) although the "keyboard" clash may come into effect with the digitial joysticks (not tested on cpc+).

But it's the fire buttons that cause problems. It may be possible to use 2nd fire buttons on the digital joysticks and then you can do it, but this is not really workable.

So I think tennis cup used digital and analogue because they can work together and to avoid keyboard clash.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

MacDeath

What do you call "keyboard clash" ?

Is it covered in the wiki ?

arnoldemu

Quote from: MacDeath on 15:47, 02 February 10
What do you call "keyboard clash" ?

Is it covered in the wiki ?
no it's not in the wiki yet.

"keyboard clash" is where you press some keys on the cpc keyboard, and the keyboard hardware generates another key which you did not press. It is a side effect of the hardware of the keyboard itself. These extra key presses are sometimes called "phantom" or "ghost" keys.

Looking at the diagram of the keyboard matrix, if you select 3 keys, and imagine these form 3 corners of a rectangle, then the fourth key in the rectangle will also be "pressed".

Another example is playing Gauntlet with 2 players, one on keyboard another on joystick. One player will suddenly say "why am I moving down, I didn't press that". The reason the joystick and keyboard are in the keyboard matrix and "keyboard clash" has hit you.


My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

MacDeath

Oh yea, I knew it but I wanted your confirmation it was that.


I experienced it a lot while playing Rampage.

As a 3 player game (one of the rare one, perhaps the only one ?), it was a heavy Keyboard user, and those happened often.

Yet better have Keyboard clashes than colour clashes. ;D

redbox

Quote from: arnoldemu on 18:31, 02 February 10
"keyboard clash" is where you press some keys on the cpc keyboard, and the keyboard hardware generates another key which you did not press. It is a side effect of the hardware of the keyboard itself. These extra key presses are sometimes called "phantom" or "ghost" keys.

It would appear that Amstrad have always used cheap keyboard decoding circuitry in their products...!

nocash

> No, serious. To use the analogue joystick is very easy:
Of course it's easy. The problem is that its all undocumented. Everybody knows that there are those 8 ADC ports, but which of them connect to which of the 4 axes?

> - Read X value from the memory mapped IO
> - Subtract &20 = 32 (like I remember)
> - negative values go left, positive values go right.
> - Do the same for Y
You mean negative Y moves left, too??? :-) I'd have bet either up... or down. As I said, nobody has ever described that properly.

----

For the the hardware side. One warning: It'd be a VERY bad idea to connect joysticks just to try if they do work. With the reversed polarity of the power supply you can at best try if they do produce smoke.

A better approach would be not to use joystick at all, and instead use a piece of wire to shortcut Pin1 and Pin3 for X1. Then check which of the 8 adc inputs reacts to it, and if it returns 00h or 3Fh or whatever.

I don't own a cpc+/gx4000. But if you own one, it should be super easy to test that.

----

Pin CPC+          PC
1   Ground        +5V
2   /Fire 1       Player 1 Fire 1
3   X1            Player 1 X (lt/rt)
4   /Joystick 1   GND
5   +5V           GND
6   Y1            Player 1 Y (up/dn)
7   /Fire 2       Player 1 Fire 2
8   Ground        +5V (Soundblaster: GND)
9   Ground        +5V
10  /Fire 1       Player 2 Fire 1
11  X2            Player 2 X (lt/rt)
12  /Joystick 2   GND (Soundblaster: Midi TxD)
13  Y2            Player 2 Y (up/dn)
14  /Fire 2       Player 2 Fire 2
15  Ground        +5V (Soundblaster: Midi RxD)

From Arnold V specs...
Analogue paddle ports
The ASIC includes the logic for an octal A/D converter, in conjunction with an external R-2R network, comparator and analogue multiplexer. Eight analogue input channels are thus available on the PCB, of which only four have connectors. This allows support for four paddles or two joysticks, with capacity for twice this many without redesigning the ASIC. The A/D is 6 bits wide, to give sufficient resolution after calibrating joysticks. It appears to the software as a bank of eight, 6 bit, read-only registers from 6808h to 680Fh, known as ADC0-7. They are updated approximately 200 times per second. The A/D inputs have an input range of 0V (data = 00) to 2.5V (data = 3Fh), and an input impedance of 180k to Vcc.

nocash

TFM: "Every PC analog joystick can be used with the CPC Plus"

Are you sure there??? I think it'd be none... or almost none.

I guess there's a minimal chance that a few PC joysticks work on the CPC+. That provided that PC uses 5V=Left, and CPC+ uses GND=Left (or vice-versa, I haven't checked either hardware).

Either way, if should be like so, then the reversed supply voltages would be "undone" by the reversed left/right assignments. And then a PC joystick could actually work on the CPC+.

Additional requirements would be the buttons connected to the "correct" common pin. And of course, the joystick not containing any electronics (like autofire) which requires the supply voltages.

nocash

> MacDeath comment : I tested it with a Trust Predator Lite PC
> analog joystick... Yet I found out that it was impossible to go
> to directions Down and Right (yet Up and Left worked)
Interesting.

If Up/Left works, that would imply that the Left<-->Right and Up<-->Down are actually reversed (and that the reversed directions are undone by the reversed power supply voltages.

If Down/Right don't work. I'd bet that POTs have other values. Amstrad stated "The A/D inputs have an input range of 0V (data = 00) to 2.5V (data = 3Fh), and an input impedance of 180k to Vcc." Which, I guess, means, that the joystick should contain 180K ohm POTs. What kind do you have in the PC stick?

NB: PC games allowed to calibrate the joystick, so the "middle" position could be everywhere. The disassembly for the Tennis game shows that it doesn't use calibration, so the POTs must have a specific value.

redbox

I agree with the 'be careful what you plug in' statement because my 6128 Plus seems to have a faulty standard game paddle.

If I leave the paddle plugged in then the Plus is prone to randomly crashing, where as if I leave it unplugged then the Plus runs fine.  I expect it's a dodgy wire or dry solder joint either in the Plus or the paddle, but it does show that you have the ability to knacker the Plus if you're not careful.

nocash

#17
Have done some more research. The Arnold V specs do list Pin1,8,9,15 (GND on CPC+) as "Pot common".

And, I've disassembled an old PC gamepad. It uses Pin1 (5V on PC) as pot common.

So, that part seems to be compatible between CPC and PC. As everybody known, pots have 3 pins, which are connected as: 
- one pot-pin to to X1 (or Y1)
- one pot-pin to CPC's GND or PC's 5V (which is Pin1 on either CPC and PC)
- one pot-pin left unconnected

The missing info is which resistance in Ohms is needed, on CPC, sth like:
  nnn Ohms = Leftmost
  nnn Ohms = Rightmost
Can somebody connect a pot to the cpc+, and measure at which settings the ADCs reach their minimum and maximum values?

That values may differ from joystick to joystick. Atari used 1M ohm. My PC joystick uses around 300K ohm. More specific: It has (mechanical) calibration that allows to adjust the range:
  calibration          ohms
  "slowest"            up=170K, center=300K, down=300K
  "middle"            up=0K, center=140K, down=290K
  "fastest"            up=0K, center=0K, down=130K
The utmost slowest/fastest settings won't be working, since the center is same as up/down in that calibration state.
NOTE: With slowest/fastest, I mean how long it'd take up to charge the capacitors inside of a PC.

dragon

I tried The max fire g07.

Only works A,B,And C buttons.

They return 10 characters in the basic.jaja.

I do not have the tennis game to try.

Bryce

#19
According to the CPC Plus Schematics, the inputs RX1 / RY1 / RX2 / RY2 are all strapped high with 100K resistors (R123 - R126), after these signals have been selected by the 74HC4051 (Analogue Signal multiplexer to avoid having a comparator for each input) the signal is fed into an LA6393 (Comparator) Pin2 and the signal is being compared with the voltage on Pin3.... This is where it gets complicated.... Pin3 is connected to a cascaded array of potential dividers (R132 - R144) which can be switched on and off using the ASIC outputs ADC0 - ADC6 (Pins 4 - 9) to vary the voltage at Pin3 of the comparator, suggesting that the ASIC either self-tunes the ADC or is at least configurable. The output of the comparator is fed into Pin 15 of the ASIC (Comp), but is also strapped high with a 4.7K resistor (R127). Without knowing what state pins ADC0 - ADC6 are at, it's very difficult (impossible) to work out the voltages being compared. To really understand the circuit, you would need a logic analyser connected to Pins 4 - 9 and 12-14 (Multiplexer selection) of the ASIC and an oscilloscope connected to pins2 and 3 (and possibly pin1) of the LA6393.

I have the test equipment, but I don't own a Plus or GX (Yet. I'm still looking though).

If you happen to own all of the above, then have fun...

Bryce.

nocash

> it's very difficult (impossible) to work out the voltages being compared.
> To really understand the circuit, you would need a logic analyser
> If you happen to own all of the above, then have fun...

Is that necessary to understand how it works inside the CPC+? I mean, you have a potentiometer in the joystick - and who cares how the CPC+ handles it? Only thing relevant should be to know if needs to be a 100K, or 300K ohm potentiometer, or whatever else value.

Can't somebody just stick two wires in his joystick port, and attach a potentiometer to it?

For testing, 1M ohm or 500K ohm should be great enough. Then turn the potentiometer until the ADC inputs become 00h=min (or 3Fh=max). Then unplug the wires, and measure the resistance in Ohms that you've set the potentiometer to. You don't even need to know anything about electronics to do that. Only, you'd need a test program that unlock/enables the ASIC and display the ADC values on the monitor...

arnoldemu

Quote from: nocash on 21:46, 04 February 10
> it's very difficult (impossible) to work out the voltages being compared.
> To really understand the circuit, you would need a logic analyser
> If you happen to own all of the above, then have fun...

Is that necessary to understand how it works inside the CPC+? I mean, you have a potentiometer in the joystick - and who cares how the CPC+ handles it? Only thing relevant should be to know if needs to be a 100K, or 300K ohm potentiometer, or whatever else value.

Can't somebody just stick two wires in his joystick port, and attach a potentiometer to it?

For testing, 1M ohm or 500K ohm should be great enough. Then turn the potentiometer until the ADC inputs become 00h=min (or 3Fh=max). Then unplug the wires, and measure the resistance in Ohms that you've set the potentiometer to. You don't even need to know anything about electronics to do that. Only, you'd need a test program that unlock/enables the ASIC and display the ADC values on the monitor...
I have a CPC6128+. I have a multimeter.
I have some small electronics knowledge.
Can I do what you suggest with these?

I also have a competition pro joypad that works on pc but not on cpc+.
I would be willing to write the test program too if others need the help.


Ok, say that we had to make our own joysticks for example... what is needed to make an analogue joystick?

I know that in a digital joystick you just need some microswitches, a stick and then solder it all up.. but for an analogue joystick?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Bryce

#22
No, it's not "necessary" to understand every single resistor and voltage flowing, but then that's the difference between software and hardware people. To fully understand the circuit as an electronics person, that's what you'd need to do. Just as when you disect a program, you like to know why every single command was required, where as I am happy to know "This routine moves the sprite", that probably wouldn't be enough for you.

If it's just a question of "What value of Pot do I need", then that's easy.... The analogue inputs are all connected to the 5V rail via a 100K resistor, so the Pot is just acting as half of a potential divider where one half is fixed at 100K, That means a Pot of 100K would allow a variance between 0 and 2.5V, a Pot with a higher value would allow the voltage to be raised higher than 2.5V but would never reach 5V due to the 100K resistor and the internal resistance of the comparators circuit (have to check the datasheet for the exact value) and a Pot with a lower value would shrink the range depending on it's value (eg: 50K Pot would give a range of 0 to 1.66V). When the circuit is fully understood, it would be possible to work out the exact ideal value, but just taking a wild guess (using the values in the schematics), I would say that the circuit probably expected something between 150K and 200K to work properly. If the value is too high, then the centre point of the joystick will be offset to one side and if it was too low then you wouldn't be able to go fully to one side (not sure which side, because I don't know which way around the Pot is connected) , but this is probably what the array of resistors was for, to compansate for the offset and adjust to the resistance of the joystick connected. This is all assuming that one side of the pot is connected to ground.

Did the games which used the analogue joystick have a calibration option?

Bryce.

Edit: Just noticed above, that it's mentioned somewhere that 0-2.5V is the expected range, then obviously a 100K Pot was used in the Joystick. Althought the hardware does still seem to have calibration for other values built in.

MacDeath

I don't remember Tennis cup 2 having a calibrate option.

Yet it is possible that it didn't really used Analog joy in analog way (as in flight simulators) but as a pseudo digital.

The only usefull part in using an analog option was perhaps simply to avoid controlers clashes (just like keyboard clashes).


nocash

> I don't remember Tennis cup 2 having a calibrate option.
> Yet it is possible that it didn't really used Analog joy in analog way
No, of course it doesn't. See the disassembly,
http://cpcwiki.eu/index.php/Tennis_Cup_2_(_Cartridge_)

> The only usefull part in using an analog option was perhaps
> simply to avoid controlers clashes (just like keyboard clashes).
Isn't the cpc+ having diodes in the digital joy ports (like those in Y-cables)? Which, I thought would avoid clashes?

My idea on the "analog" support was, that it's for people whom don't own two digital sticks, but do own one digital, and one analog stick.

Problem there would be that fire is shared for digital stick 1 and analog stick 1. So (if both players can play simultaneously, they can, don't they), then THAT would clash.

Unless the game wants you to use digital stick 2 (!) with analog stick 1. Quite strange configuration, but guess that's the only way how it could work.

> analogue inputs are all connected to the 5V rail via a 100K resistor
Yup, if the cpc+ contains 100K, then the stick should theoretically contain 100K pot's to get the 2.5V.

Ah, what's that part about "... 2.5V (data = 3Fh), and an input impedance of 180k to Vcc"?
That doesn't suggest 180K instead of 100K, or does it? I am not so good at analogue electronics, impedance always sounds a bit esoteric to me, so, if the impedance thing doesn't matter, then it'd just suit me well ;-)

> To fully understand the circuit as an electronics person ...
> Just as when you disect a program,
Okay, I get that. Like to understand things, too. Just the most relevant question is the pot value in the joystick, which is all needed to know at the joystick side, (and which maybe be helpful to understand the computer side, too).

Just when you said, it might be *impossible* to understand the computer-side without logic analyzer. All okay - but I guess most readers dropped dead, and thought one couldn't understand the joystick-side without logic analyzer, too :-)

> I have a CPC6128+. I have a multimeter.
> I have some small electronics knowledge.
> Can I do what you suggest with these?
Perfect. The only extra thing required would be resistor to be connected between GND and X1. The other inputs (X2,Y1,Y2) should work the same, though you may want to test them too once you are there).

Best would be a potentiometer (variable resistor), if you have one around. Or you could stick in different fixed-value resistors, like 100K, 82K, 47K, 33K, 10K, and so on. In that case you won't even need the multimeter, since you the resistors value.

Note: Of course, the multimeter won't work if the computer is sending energy through it, so you'd need to disconnect it before measuring ohms. If you have no potentiometers, you could use those in the PC joystick - ah, no, forget about that (cause the competion pro is a digital joystick without pot's).

Powered by SMFPacks Menu Editor Mod