VOGONS


First post, by saur2004

User metadata
Rank Newbie
Rank
Newbie

Must be a year since I first reported on this.

Ive been carefully trying out new CVS builds as they come out.

This:

          NAME     JOYSTICK_BUTTONS
ASSUME CS:CODE,DS:DATA

DATA SEGMENT PUBLIC
DATA ENDS

CODE SEGMENT PUBLIC

PUBLIC JSBTNS

RETAD DW ?

;gets joystick vals

JSBTNS PROC NEAR
POP BX
MOV RETAD,BX
MOV AH,84H
MOV DX,0000H
INT 15H
POP DI
POP ES
XOR AH,AH
MOV ES:WORD PTR [DI],AX
MOV BX,RETAD
JMP BX
JSBTNS ENDP

CODE ENDS

END

recognizes old analog joystick buttons just fine when using MS-DOS 6.22. But, under dosbox, under windows 2000 with a CH products USB fighterstick, it does not.

Reply 1 of 19, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

There was a recent addition of a patch which I think takes care of this:
http://sourceforge.net/tracker/index.php?func … 551&atid=467234

Reply 3 of 19, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

but did you set the stuff in your conf file?

[bios] # type -- Type of joystick to emulate: none, 2axis, 4axis, # fcs (Thrustmaster) ,ch (CH Flightstick). # n […]
Show full quote

[bios]
# type -- Type of joystick to emulate: none, 2axis, 4axis,
# fcs (Thrustmaster) ,ch (CH Flightstick).
# none disables your joysticks and 2axis is the default.

joysticktype=4axis

Reply 4 of 19, by saur2004

User metadata
Rank Newbie
Rank
Newbie

I just tried putting that in.

There was a comment in the BIOS section that said something about "nothing yet".

Adding it, didn't change a thing.

BTW Just to add a little information incase someone thinks I havent tried everything, the CH fighterstick control utility comes with 3 different modes.

Off mode, Direct mode, and Mapped mode.

I have made sure I have tried all 3 modes for every test I have run. I have never once gotten dosbox to run this one game, that uses the code I displayed.

Note that its the button reader code. I have no idea if the axises are working. The game will not get past the joystick trainer since I cant click.

Reply 5 of 19, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

too bad.

A little advice on CVS and new Dosbox versions, it pays to do a writeconf at times because new settings will of course not get listed in your old conf file.

Reply 6 of 19, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author
	case 0x84:	/* BIOS - JOYSTICK SUPPORT (XT after 11/8/82,AT,XT286,PS) */
if (reg_dx == 0x0000) {
// Get Joystick button status
if (JOYSTICK_IsEnabled(0) || JOYSTICK_IsEnabled(1)) {
reg_al = (JOYSTICK_GetButton(0,0)<<7)|(JOYSTICK_GetButton(0,1)<<6);
reg_al |= (JOYSTICK_GetButton(1,0)<<5)|(JOYSTICK_GetButton(1,1)<<4);
CALLBACK_SCF(false);
} else {
// dos values
reg_ax = 0x00f0; reg_dx = 0x0201;
CALLBACK_SCF(true);
}

This is the code we have there.
Seems to in order I would say. so are you sure you are pressing the right buttons ?
Could you perharps attach an example executable ?

Water flows down the stream
How to ask questions the smart way!

Reply 7 of 19, by saur2004

User metadata
Rank Newbie
Rank
Newbie

OK this in interesting.

I had forgoten that I had a little test utility that used that assembly code segment. It showed that the buttons were indeed being recognized.

(and just for the record I have ZERO hope of changing any of this code. If I did I would actually program a win2k version, and not try running it under dosbox.)

My utility was reporting:
Button 1 as 128 or 1000-0000 binary.
Button 2 as 64 or 0100-0000 binary.

Hate to say this but that is not the correct classical bios, bit possitions for the buttons.

The game uses the following mask to prevent other bits activating things other than button 1 or 2.

writeln('Hold the joystick in each of the following positions and');
writeln('press a joystick button !!');
writeln;
writeln(' TOP - LEFT');
repeat
jsbtns(jbtns)
until ((jbtns & $0030) <> $0030);
jstick(jxpos,jypos);
repeat
jsbtns(jbtns)
until ((jbtns & $0030) = $0030);
jslft := jxpos;
jstop := jypos;
writeln;
writeln(' CENTER');
repeat
jsbtns(jbtns)
until ((jbtns & $0030) <> $0030);
jstick(jxpos,jypos);
repeat
jsbtns(jbtns)
until ((jbtns & $0030) = $0030);
jsrit := jxpos;
jsbot := jypos;
jslft := jslft + ((jxpos - jslft) div 16);
jstop := jstop + ((jypos - jstop) div 16);
writeln;
writeln(' BOTTOM - RIGHT');
repeat
jsbtns(jbtns)
until ((jbtns & $0030) <> $0030);
jstick(jxpos,jypos);
repeat
jsbtns(jbtns)
until ((jbtns & $0030) = $0030);
jsrit := jxpos - ((jxpos - jsrit) div 16);
jsbot := jypos - ((jypos - jsbot) div 16);
writeln;
writeln('----- JOYSTICK READY TO GO ------');
(*end*)
end;

Note the bit mask of 0011_0000 and that it happens to be reversed.

Whatever the classical bit positions are, this code does indeed work under true MS-DOS.

Reply 8 of 19, by Kippesoep

User metadata
Rank Oldbie
Rank
Oldbie

According to my systems programming manual, DOSBox does use the correct bits for those buttons. (I have the sneaky suspicion Qbix and Harekiet might be using the same book -- "PC Intern 4" by Michael Tischer).

Everything I can find on the net, though, says that the mask for jAb1 is 00010000, jAb2 is 00100000, jBb1 is 01000000 and jBb2 is 10000000 and that 0 values mean that the button is actually being held down. This matches what is read from the joystick port.

My site: Ramblings on mostly tech stuff.

Reply 9 of 19, by saur2004

User metadata
Rank Newbie
Rank
Newbie

Whatever it may or may not be, Im just reporting what I had to do when I originally programed it back in 1993.

And, yes it still works correctly if I boot to MS-DOS. My sound card is Cmedia and they do distribute DOS drivers. Of course I have to dig out an old analog stick. But it DOES work in that environment.

And it DOES NOT work in dosbox. And the bit positions and states are obviously the reason why.

Edit: Hmmmm, I wonder if I did get it backward. If you analize my code you can see that if you hold the stick in the correct positions at just the right times it would still work. Maybe thats why the game occasionally doesnt have a good stick calabration.

However you did indeed notice that the A and B controlers are indeed backward in dosbox, right?

Reply 11 of 19, by saur2004

User metadata
Rank Newbie
Rank
Newbie

Actually I think Im partly wrong and partly right. I think dosbox does have the A and B buttons backward. But I think my bit state code is wrong, which would explain why my game would occasionally misbehave.

I may try and dig out that old Digital pascal compiler and see if I can fix it someday. Maybe make it check for all 4 bits.

Reply 12 of 19, by Kippesoep

User metadata
Rank Oldbie
Rank
Oldbie

The book is wrong, and so is DOSBox. For the button state, it should return a packed value as it does for reading the joystick port directly.

My site: Ramblings on mostly tech stuff.

Reply 13 of 19, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author
On entry:      AH         84h
DX Subservice
00h - Read current switch settings
01h - Read resistive inputs

Returns: Carry Set if error, else cleared
If DX = 00h (Read current switch settings):
AL Bits 7 to 4 contain switch settings
If DX = 01h (Read resistive inputs):
AX A(x) value
BX A(y) value
CX B(x) value
DX B(y) value

This is what norton guide has to say about it.
unfortunate it doesn't point out which joystick is at which position

Water flows down the stream
How to ask questions the smart way!

Reply 14 of 19, by Kippesoep

User metadata
Rank Oldbie
Rank
Oldbie

Yeah, that's what most of the guides say. There's quite a few places, though, that indicate that the proper value is that mentioned by saur2004. Check out paragraph 4 of chapter 24 of the PC Game Adapter (PDF), old SWAG articles (9 of which deal with INT15 and they all agree).

My site: Ramblings on mostly tech stuff.

Reply 15 of 19, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

hmm it seems we have it indeed totally wrong
A and B are switched as well the 0 and 1 (for active or unactive)
will probably switch it using a real port in. and and it with 0xf0

Water flows down the stream
How to ask questions the smart way!

Reply 17 of 19, by dvwjr

User metadata
Rank Member
Rank
Member

Here is some more technical data from two sources. The information was scanned and attached as three JPG files in the ZIP file attached to this message.

First source is the Microsoft Press "Advanced MSDOS Programming" by Ray Duncan, second edition 1988, page 567 - Int 15h, Function 84h (Read Joystick).

The second source is The IBM Technical Reference, Personal Computer AT, First Edition 1985. Document 6280070 reference S229-9611-00. Specifically, Section 5, System BIOS. Complete BIOS listing, pages 5-165 and 5-166 concerning the Int_15h, Function 84h, Read Joystick BIOS code.

Since there was only a single joystick defined in 1985, it should be fairly easy to determine which was the original "A" and the later defined "B".

Hope this helps,

dvwjr

Attachments

  • Filename
    IBM_BIOS_Int15h_84h.zip
    File size
    1.62 MiB
    Downloads
    143 downloads
    File license
    Fair use/fair dealing exception

Reply 18 of 19, by Kippesoep

User metadata
Rank Oldbie
Rank
Oldbie

The important part in that is

JOY_2:
IN AL, DX (where DX=201)
AND AL, 0F0h

which means that the value of the upper nibble of AL is the same as what is read from the joystick port, as I mentioned below.

My site: Ramblings on mostly tech stuff.

Reply 19 of 19, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

yeah i commited this:


reg_al = IO_ReadB(0x201)&0xf0;
CALLBACK_SCF(false);

Water flows down the stream
How to ask questions the smart way!