Full Version: Original Challenge: *FAST* Joystick Library for QB!! ;*) !
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Dearest ***WORTHY*** QB45/QB71 community,

Hello there and WELCOME!!! Wink !

Just currently today, I was already working on adding some **HOT**, smooth-controlling joystick routines to the game Frantic Journey (FJ). I’ve tested the ORIGINAL QuickBASIC joystick routines for one of my programs, and the whole operation of the program SLOWED down (even though the routines did work properly). And, I’ve tried DirectQB’s own joystick routines for FJ, and the result there was that some of the controls there were _absolutely_ jerky, making the game a pain to play using those joystick routines (which was WHY I had to just throw them out of the project for good! Cry ! ), even though they did not slow the game down at all.

And that, my friends, brings me to my next original challenge which is this:

Create the FASTEST AND MOST RESPONSIVE joystick library for QuickBASIC as _accurately_ as possible!! :king: !!

Here are the rules:
  • 1 • You are to create your own original joystick code from Assembler (ASM) or any other programming language only, and NOT from QB.
    2 • Your original joystick code must support at least one (1) gamepad with at least FOUR (4) buttons.
    3 • After your original joystick code has been created, be sure to save it and compile it into a QuickBASIC-readable library (for at least QuickBASIC 4.5, with the .LIB and .QLB files included in your newly-created lib).
    4 • Make sure your commands for your joystick library work as properly for your gamepads/joysticks as possible *WITHOUT* slowing your program operation down at all.
    5 • Create a .BI file listing ALL of the commands for your own joystick library.
    6 • Add some examples to show the user how your routines work.
    7 • After you are all done, please present your ENTIRE library (routines, examples, documentation, along with your .LIB, .QLB, and .BI files as well) in the form of a .ZIP archive file only.

Entries that fail to follow either of the seven (7) steps *WILL* be disqualified. PERIOD.

With all of that in mind,


[Image: AAPMini.gif]
Adigun Azikiwe Polack
One of the Founders of “Aura Flow”
Webmaster of the AAP Official Homepage
Official Founder of the “QuickBASIC Caliber Programming Compo”
...reading Mr. Polack's posts always makes me feel like some very special ambassador for an important country or something. I just want to stand up proud!

:king: :bounce: :lol: Big Grin


Now if only I had a joystick.... Sad

Oh well. Good stuff comes out of challanges, like the 1 hour compo. :bounce:


Meg... you're in Maryland? :o
Sounds to me like you just want someone to do your work for you...anyhow, reading the joystick is a piece cake. Here's part of the code I wrote for my MP3 player (it used a gameport interface):

OUT &H201, 0
Btn = INP(&H201)

Btn1 = (Btn AND &H10) = 0
Btn2 = (Btn AND &H20) = 0
Btn3 = (Btn AND &H40) = 0
Btn4 = (Btn AND &H80) = 0

AxisX = 0
AxisY = 0
Count = 32767
OUT &H201, 0
  Count = Count - 1
  Axis = INP(&H201)
  IF Axis AND 1 THEN AxisX = AxisX + 1
  IF Axis AND 2 THEN AxisY = AxisY + 1
LOOP WHILE Count > 0 AND (Axis AND 3) <> 0

Now obviously you'd want some kind of dead-zone...again, this is very easy to implement:

First you calibrate the joystick. Read AxisX and AxisY when the stick is centered. Then compute the dead-zone:

DeadX = AxisX * 2 / 3
DeadY = AxisY * 2 / 3
DeadMinX = AxisX - DeadX
DeadMinY = AxisY - DeadY
DeadMaxX = AxisX + DeadX
DeadMaxY = AxisY + DeadY
(you only have to do this once at start-up)

To determine the gamepad direction after you have the dead-zone settings, just use:

BtnLeft = AxisX < DeadMinX
BtnRight = AxisX > DeadMaxX
BtnUp = AxisY < DeadMinY
BtnDown = AxisY > DeadMaxY

You could port this to assembly, but there's no point. The speed limitation here is the joystick hardware, not the code. (Thus making your rule #4 impossible. Hint - don't poll the joystick every time you update the screen...)
Plasma: Cool. I didnt know how to use the joystick. Looks pretty nice and simple. Thanks, Plasma!

Pr0gger: yes, I'm in Maryland. I went to school here (at UMD). Recently graduated. Go Terps! Big Grin



p.s. I don't wanna put my age next to my location. :-p I'm 22.
Quote:Hint - don't poll the joystick every time you update the screen...)
Darn, why didn't I think of that... I could have put 3 players in Squealer TNT after all..

How did commercial DOS games get around the slowness of the joystick hardware in 'the olden days'?
The joystick is the same speed now as it was in the "olden days" Smile You still have to wait for the pot countdown. With faster computers, you're just wasting more cycles...
To Piptol and Plasma357,

Now, I know it is not even easy creating a *FAST* joystick library for QB, but really, it has been done with DirectQB to where it got around the slowdown problems, which was _VERY_ fortunate, to be downright honest with you (remember that one?). Wink Also, such good-ol’ MS-DOS games, like Cash Invaders for instance (the analogue controls on my gamepad worked GREAT for that game, believe it or not!), have done the exact same thing, as well.

And, according to rule #1 of my current challenge, other than QB, you are *allowed* to create your own joystick code through some other programming language as C, C++, Assembler, and/or Visual Basic for Windows. Or, if you prefer, you can make your **fastest** joystick library that actually interfaces from Windows (using DirectX Joystick support for a WIDE variety of current controllers!!) directly to QuickBASIC, just like both DS4QB2 and DS4QB++ did for music and sound. Now there’s both an idea and a challenge for ‘ya, huh? Again, it sure ain’t easy to create, but it **CAN** be mastered successfully with at least some wise thinking on tap!! Big Grin !

By the way, I do have both a 9-button PC gamepad and a 10-button PC gamepad, just to get you all thinking here. Cool

I am just helping you look into something really REVOLUTIONARY and MIND-BLOWING for QB where joystick/gamepad routines are concerned. If nothing else here, at very least I am giving you some cool ideas on this, okay? Wink

Again, I thank you so much for your wonderful time.


[Image: AAPMini.gif]
Adigun Azikiwe Polack
One of the Founders of “Aura Flow”
Webmaster of the AAP Official Homepage
Official Founder of the “QuickBASIC Caliber Programming Compo”
I don't think you understand how a joystick works. The x and y axis values are based on TIMING. The TIME is the same no matter which language you use. Try it yourself.
I know joysticks on other machines, and stuff like NES gamepads are controlled by timer frequency, but there's 9 pins on the game port, and I always thought that they light up to different joystick directions and stuff.

But hey, I dont know much about hte things either. Just make it keyboard support and be happy with it, dammit...
Pages: 1 2 3