Previous Thread
Next Thread
Print Thread
Joined: Feb 2014
Posts: 817
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 817
Likes: 32
Hi guys,

I was reading up on amiga analog joysticks and wanted to see if I could get one working with the amiga driver but something very strange is going on.

For some reason, the x and y axes are inverted. When the POT0DAT or POT1DAT registers are read, it's supposed to return a 16 bit word that has Y in the upper 8 bits and X in the lower 8 bits.
Code
Bit 	15 	14 	13 	12 	11 	10 	09 	08 	07 	06 	05 	04 	03 	02 	01 	00
        Y7 	Y6 	Y5 	Y4 	Y3 	Y2 	Y1 	Y0 	X7 	X6 	X5 	X4 	X3 	X2 	X1 	X0



I thought I'd just have a couple of analog input ports named m_analog0 and m_analog1 and then do a direct read to keep things simple.

Code
                case REG_POT1DAT:
                        if (m_pot1dat_port.found())
                        {
                                return m_pot1dat_port->read();
                        }
                        else
                        {
                                m_pot1dat  = m_analog0->read() | (m_analog1->read() << 8);
                                return m_pot1dat;
                        }


So it reads properly, but I can't figure out why the high and low bytes get swapped.

I set a watchpoint on POT1DAT = DFF014 and it looks like its getting the right data.


There's a few games that have analog joystick support, one is Nova9 which has a totally incorrect manual with regard to analog joystick support, you have to hit the period key to get it to enable (at least with the pal version).

Jet Pilot by Vulcan Software has a good calibration program (only the cracked version would load and run in mame)


./myamiga64 a500 -mouse -window -debug -fdc:0 35dd -fdc:1 35dd -fdc:2 35dd -fdc:3 35dd -flop1 "../../wbenc133_us/317746-04_workbench.adf" -flop2 "../../Jet Pilot (1996)(Vulcan Software)[cr HF](Disk 1 of 4)[WB].zip/Jet Pilot (1996)(Vulcan Software)[cr HF](Disk 1 of 4)[WB].adf" -flop3 "../../Jet Pilot (1996)(Vulcan Software)[cr HF](Disk 2 of 4)[WB].zip/Jet Pilot (1996)(Vulcan Software)[cr HF](Disk 2 of 4)[WB].adf" -flop4 "../../Jet Pilot (1996)(Vulcan Software)[cr HF](Disk 4 of 4)[WB].zip/Jet Pilot (1996)(Vulcan Software)[cr HF](Disk 4 of 4)[WB].adf"

[Linked Image from i.imgur.com]
[Linked Image from i.imgur.com]

so in the debugger I put in a watchpoint to see what's going on: I'm modifying the x axis and its the low bits that are changing but on the screen the Y axis values are changing.
[Linked Image from i.imgur.com]


It reads 78F0 from $dff014 and then writes 78F0 to $44332
[Linked Image from i.imgur.com]


Everything seems to work properly if I reverse the byte order with:

Code

                                m_pot1dat  = m_analog1->read() | (m_analog0->read() << 8);
                                return m_pot1dat;


[Linked Image from i.imgur.com]

Seems to work ok in reversing the order, x/y drives the intended axis. Player 2 right and left are the analog buttons 1 and 2 but since it thinks its a digital joystick it disallows simultaneous pressing.





I was also able to get Flight of the Intruder to run to where I could calibrate the joystick.

./myamiga64 a4000n -mouse -window -debug -fdc:0 35dd -fdc:1 35dd -fdc:2 35dd -fdc:3 35dd -flop1 "../../Flight of the Intruder (1991)(Spectrum HoloByte)[cr QTX](Disk 1 of 2).adf" -flop2 "../../Flight of the Intruder (1991)(Spectrum HoloByte)[cr QTX](Disk 2 of 2).adf"

[Linked Image from i.imgur.com]

Pressing ESC ingame brings up the menu:

[Linked Image from i.imgur.com]
[Linked Image from i.imgur.com]


Is this endian thing because I'm running on an intel little endian machine?

Joined: Feb 2014
Posts: 817
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 817
Likes: 32
I came across an Analog Joystick program on fish disk 247 and thought I'd give it a spin:

(The hard part was getting the .lha program onto an adf floppy, but fs-uae was able to mount a hard drive directory.)

Code
CONTENTS OF DISK 247
====================

AnalogJoystick	Software support for use of analog joysticks on the
		Amiga. Includes a driver, a header file for code that
		calls the driver, and an example program that uses the
		driver. Includes source. Author: Dave Kinzer



With the joystick setup that works properly for JetPilot, I get exactly the opposite axes with this Analog Joystick Test.

Here you see the xaxis is vertical,

[Linked Image from i.imgur.com]

and then I add in the yaxis (which is horizontal).

[Linked Image from i.imgur.com]

I think maybe somebody got it backwards, possibly hooked up the wrong pin to the wrong axis on the joystick.

[Linked Image from i.imgur.com]

Joined: Feb 2014
Posts: 817
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 817
Likes: 32
Found a couple of more analog joystick test programs on Aminet searching on "analog joystick".

anacal.lha driver/input 2735 20K 1992-02-14 m68k-amigaos Calibrate analog joysticks - (readme)


The X axis matches that of Flight of the Intruder.

[Linked Image from i.imgur.com]

anjoyprefs.lha util/misc 431 29K 1997-10-09 m68k-amigaos Prefs for Analog Joystick Calibration - (readme)


The X axis is reversed to Flight of the Intruder.

[Linked Image from i.imgur.com]
[Linked Image from i.imgur.com]

crashes on its way out.

[Linked Image from i.imgur.com]


and some clues in the documentation of an Analog Joystick Hack called "Deluxe22.lha" as to why the axes might be reversed.


Deluxe22.lha docs/hard 503 27K 1996-04-30 generic Analog Joystick Hack.. Deluxe Version - (readme)

Quote

Deluxe Analog Joystick v2.1
===========================


By: David Templeton

E-mail: wizard@galstar.com

©1996 David Templeton All Rights Reserved


Amiga Deluxe Analog Joystick Switch


While researching analog joysticks for my Amiga, I found
that there were alot of different hacks out there all trying
to do the same thing. Before you say and here comes another,
let me explain why this one is the best.

The major problem is there is no standard for analog
joysticks on the Amiga. Some software companies wrote the
analog drivers differently. Some swapped the X & Y axis
connections and some swapped the Fire button 1 & 2
connections, while others need a capacitor on the X & Y
potentiometer wiper for added sensitivity! Why they choose
to do it this way is beyond me.

This hack will allow you to switch between all the
different functions, so you will be compatable with programs
out now or others written in the future.

So until someone develops a standard or makes a fair
priced analog joystick for the Amiga, this is it.
@endnode

@node "Compatible Games" "Compatible Games"


Games Supporting Analog Sticks:

> Fighter Duel Pro
> Fighter Duel Pro-2
> Fighter Duel: Corsair vs Zero!
> Flight of the Intruder
> Mig-29 Fulcrum
> Mig-29 SuperFulcrum
> F-19 Stealth Fighter
> F-15 Strike Eagle II
> Birds of Prey
> Knights of the Sky
> Flight Simulator II
> Genie Airwarrior
> A10 Tank Killer Enhanced version
> World Circuit
> more?? Send me E-mail.
@endnode


Sensitivity Adjustment:

Ideally you want to use .15 microFarad caps, but other
values will work. Here is list of values and their range
readings using Anacal.

Note theses values may be a little different depending on
the brand of Joystick you use.

.1 micro-- X axis 0-120
Y axis 0-120

.15 micro--X axis 0-220 (Full Range of Amiga 0-255)
Y axis 0-220

.22 micro--X axis 0-255+ (off scale)
Y axis 0-255+ (off scale)

Joined: Feb 2014
Posts: 817
Likes: 32
G
Senior Member
OP Online Content
Senior Member
G
Joined: Feb 2014
Posts: 817
Likes: 32
I thought I'd try the analogmouse program from Aminet that would allow you to control the mouse with the analog joystick.

AnalogMouse.lha 1.0 util/mouse 1521 12K 1998-03-19 m68k-amigaos Use analog joystick as a mouse. - (readme)


However, it doesn't work properly unless you give it pot values from 0-127. 128 and above causes a rollover in how it computes things.


Quote

AnalogMouse v1.0 by Piotr Pawlow (PP/UNION)

1. Introduction

AnalogMouse is a CLI-only tool that allows you to control your
mouse with an analog joystick connected to the joystick port. You can use
your joystick to work with the system as well as play many mouse-only
games. I tried it with DoomAttack, ADoom and MegaBall and it was working
very well. (To be honest - I made this program just to be able to play
DoomAttack with my analog joystick, compatibility with the system and other
games is simply a side-effect smile

3. Requirements

Any Amiga with at least Kickstart 2.0, about 8KB of free memory
and 6KB of free disk space. (or at least Pentium Pro 200 with a huge
hard drive and a lot of memory, running UAE smile

4. Quick start

Just run it. That's all smile No calibration is needed, you don't
need to set thousands of options, install a special Plug'n'Pray Advanced
32-bit Analog Joystick Driver(tm) and stuff...
After starting AnalogMouse move your joystick in all directions so
the program can find minimum and maximum values and aspect ratio of your
joystick. Then move the joystick to a neutral position. If the mouse
pointer still moves, correct it with TRIM potentiometers.
Press Ctrl-C to exit the program.


Feeding it values from 0 to 119: (the 4682 stuff is because I've mapped the analog joystick to the keypad keys)

Sensitivity 10 makes it a lot easier to control.

[Linked Image from i.imgur.com]


Feeding values from 0 to 128 causes a rollover and the mouse becomes uncontrollable:
[Linked Image from i.imgur.com]


Link Copied to Clipboard
Who's Online Now
1 members (Dorando), 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,083
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