Joystick Intr $15

Hardware questions and modifications
Post Reply
Chuckphd53
Posts: 368
Joined: Sun May 13, 2018 9:15 am
Location: Florida, USA
Contact:

Joystick Intr $15

Post by Chuckphd53 »

before I dig into the bios.... let me ask...

Does the Jr Bios support the Intr$15 call to the joysticks or only the read to port[$201]

Looking for a faster way to read the sticks with Turbo Pascal....
(PCJR/JR-IDE-512DOM,TandyMod,V20-10Chip,BiDir,LPT2,3FlopBrd,
USBEmulator,ZIP100,PS2Keybrd,MouseSysMouse,InternalSwitcherPS)
Trixter
Posts: 720
Joined: Mon Sep 01, 2008 12:00 am
Location: Illinois, USA
Contact:

Re: Joystick Intr $15

Post by Trixter »

It's in the BIOS IIRC, but it's terribly slow.

I'm happy to paste my optimized joystick code here, but before I do: Do you want a small, easy-to-read routine that works on systems up to 10 MHz, or would you like a larger routine that works on all speed systems (even pentiums)?
You're all insane and trying to steal my magic bag!
Chuckphd53
Posts: 368
Joined: Sun May 13, 2018 9:15 am
Location: Florida, USA
Contact:

Re: Joystick Intr $15

Post by Chuckphd53 »

optimized if fine,
(PCJR/JR-IDE-512DOM,TandyMod,V20-10Chip,BiDir,LPT2,3FlopBrd,
USBEmulator,ZIP100,PS2Keybrd,MouseSysMouse,InternalSwitcherPS)
Trixter
Posts: 720
Joined: Mon Sep 01, 2008 12:00 am
Location: Illinois, USA
Contact:

Re: Joystick Intr $15

Post by Trixter »

Okay, here's a very small routine from Jordan Knight that returns the X and Y axis on the first joystick. It should work on systems up to about 16 MHz, after that it might return odd numbers. It also returns higher numbers the faster a system you run it on, so you can't just assume the ranges you get on one system will be the same on another system. If you want a more complicated routine that handles more situations, let me know, but for now here is Jordan's code with some slight modifications by me:

Code: Select all

function joyStick1AxisQuick:longint; assembler;
{
Original by Jordan Knight, slight tweaks by Trixter.
Returns:
  AX = joystick 1 X axis
  DX = joystick 1 Y axis

Use like this:

var
  joyX,joyY:integer;
  joyPosition:longint absolute joyX;
...
joyPosition:=joystick1Axis;

...then the axis will be stored in joyX and joyY.

}
asm
        mov     cx,$4ff                 {from XT BIOS; range 1-1279}
        mov     dx,defaultstickport
        xor     ax,ax
        mov     bx,ax
        mov     bp,ax
        mov     di,ax
        pushf
        cli
        out     dx,al                   {fire off one-shots}
@loop:
        shr     al,1
        adc     bx,bp                   {bx:=bx+joy1 xaxis bit}
        add     di,ax                   {di:=di+joy1 yaxis bit}
        in      al,dx                   {read joystick bits}
        and     al,$03                  {we only care about xaxis bits}
        loopnz  @loop                   {if all bits are empty, done reading}
        {note: can increase granularity slightly by unrolling @loop 4x}
        popf
        mov     ax,bx
        mov     dx,di
end;


You're all insane and trying to steal my magic bag!
Post Reply