MORE INFORMATION
The way in which Basic SIC handles joystick commands (which include the
STICK function, STRIG function, and STRIG statement) depends on which
kind of Intel microprocessor chip the computer uses. If the computer
has an 8086/8088 or 80186/80188 microprocessor, the joystick commands
talk directly to the hardware without going through the ROM BIOS. If
the computer has either an Intel 80286 or 80386 microprocessor, the
joystick commands are handled by going through ROM BIOS Interrupt 15h.
Because of errors in some ROM BIOS joystick functions on some computers,
STICK or STRIG may not work at all, or may not work properly.
If your computer has an Intel 80286 or 80386 microprocessor chip, you
can use the code example below to determine if the problem you are
having is ROM BIOS related. The program accesses the game port by
directly calling INTERRUPT &H15 with function &H84, which is the ROM
BIOS joystick routine. If the problem still occurs when calling the
ROM BIOS joystick routine directly, then the problem is with the
computer's ROM BIOS joystick function and not with Basic's STICK or
STRIG routines.
To access the ROM BIOS joystick routines, you call Interrupt &H15 (21
decimal). The AH register should contain &H84 (132 decimal) to
indicate the game port support function.
Register values prior to issuing interrupt &H15 should be the
following:
AX = &H8400 ' This puts &H84 in the AH register.
DX = 0 or 1
If DX = 0, this indicates to "read switch settings." If DX = 1, this
indicates "read resistive inputs."
Depending on the value of DX when you make the call, different
parameters will be returned by the interrupt. If DX = 1, then upon
returning from Interrupt &H15, the registers will contain the
following:
AX = Port1 x coordinate
BX = Port1 y coordinate
CX = Port2 x coordinate
DX = Port2 y coordinate
If DX = 1, then bits 4 - 7 are used to represent switches. The AX
register will contain the switch settings in bits 4 through 7. BX, CX,
and DX will be unchanged.
Code example
The following code example shows how to use the CALL INTERRUPT routine
to directly call the ROM BIOS joystick routines.
To try this example in VBDOS.EXE:
- From the File menu, choose New Project.
- Copy the code example to the Code window.
- Press F5 to run the program.
To run this program in the VBDOS.EXE environment, you must invoke the
VBDOS.EXE environment with the /L switch to load the default Quick
library:
VBDOS.EXE /L
Note: The INTERRUPT routine is considered an external subroutine by
the compiler. The routine is located in the files QB.LIB and QB.QLB
for QuickBasic for MS-DOS 4.x and in QBX.LIB and QBX.QLB in Basic PDS
for MS-DOS 7.x.
Programs that execute a CALL INTERRUPT statement when compiled in the
QB.EXE editor require the presence of the QB.QLB or QBX.QLB Quick
library. This means that QB.EXE and QBX.EXE must be invoked with the
/L option, which automatically loads the correct Quick library.
Compiled programs that execute CALL INTERRUPT must be linked with the
file QB.LIB or QBX.LIB. More information on the use of CALL INTERRUPT
can be found under the CALL statement in the language reference manual
for each Basic product. For more information on how to use CALL
INTERRUPT, query on the following words:
CALL and INTERRUPT and application and note and QuickBasic
JOYSTICK.BAS
' This code prints to the screen the values of AX, BX, CX, DX registers
' when interrupt &H15, function &H84 is called with given values in the
' DX register. This will allow you to observe the values
' corresponding to a specific action taken on a given device attached
' to either of the two game ports supported by an IBM or compatible.
' Use the following include file for Visual Basic for MS-DOS:
REM $INCLUDE: 'VBDOS.BI'
' Use the following include file for QuickBasic for MS-DOS:
'$INCLUDE: 'QB.BI'
' Use the following include file for Basic PDS for MS-DOS:
'$INCLUDE: 'QBX.BI'
DIM inregs AS RegType
DIM outregs AS RegType
inregs.ax = &H8400 ' Puts &H84 in AH register.
DO
inregs.dx = 1 ' 1 - read resistive inputs.
CALL INTERRUPT(&H15, inregs, outregs)
CLS
LOCATE 16, 10: PRINT "RESISTIVE INPUTS: (STICK)"
LOCATE 19, 20: PRINT "AX","BX","CX","DX"
LOCATE 20, 20: PRINT outregs.ax, outregs.bx, outregs.cx, outregs.dx
inregs.dx = 0 ' 0 - read switch settings.
CALL INTERRUPT(&H15, inregs, outregs)
LOCATE 6, 10: PRINT "SWITCH SETTINGS: (TRIGGER)"
LOCATE 9, 20: PRINT " AX"
LOCATE 10,20: PRINT outregs.ax ' Only bits 4 - 7 are important.
LOOP WHILE INKEY$ = "" ' Loop till any key is pressed.
END
REFERENCES
For a description of the dependency of STICK and STRIG on computers
with certain Intel chips, query on the following words in the
Microsoft Knowledge Base:
It may be possible to avoid using the ROM BIOS routines altogether by
directly accessing the game port using GET and PUT functions. (Basic's
INP and OUT statements cannot do this because of the speed required to
read the port.) It may be possible for you to write an assembly
subroutine, which could be called from Basic to talk directly to the
game port.
Information on programming the game port can be found in the following
references:
- Page 433 of "The Programmer's PC Sourcebook" by Thom Hogan,
published by Microsoft Press, 1988
- "IBM Technical Reference Options and Adapters" Volume 2, "Game
Control Adapter", published by IBM