Active Forums => QB64 Discussion => Topic started by: Omerta7486 on September 01, 2018, 07:14:51 pm
Title: INP addresses?
Post by: Omerta7486 on September 01, 2018, 07:14:51 pm
Does anyone know of any good documentation on the INP memory addresses? The only one I can figure out is the &H60 address for keyboard input...
Thanks in advance,
-Omerta
Title: Re: INP addresses?
Post by: TempodiBasic on September 01, 2018, 08:25:13 pm
Hi Omerta here some links http://qb64.org/wiki/INP (http://qb64.org/wiki/INP) https://en.wikipedia.org/wiki/Input/output_base_address#Common_I.2FO_base_address_device_assignments_in_IBM_PC_compatible_computers (https://en.wikipedia.org/wiki/Input/output_base_address#Common_I.2FO_base_address_device_assignments_in_IBM_PC_compatible_computers) http://www.o-bizz.de/qbtuts/mallard/sbfaq.htm (http://www.o-bizz.de/qbtuts/mallard/sbfaq.htm) http://www.os2site.com/sw/info/memory/ports.txt (http://www.os2site.com/sw/info/memory/ports.txt) but why do you like use INP? Often there is something that already works on hardware that you want manage at low level. IMHO be careful to use INP to change hardware settings.
Title: Re: INP addresses?
Post by: FellippeHeitor on September 02, 2018, 03:52:02 pm
INP is emulated. Here's the implementation in libqb.cpp:
From which we get the following ports being currently emulated/supported:
0x3C9 for reading palette data in palette-enabled screen modes
0x3DA for vertical retracing
0x60 for the last keyboard scancode
Any other ports are ignored and return 0.
Title: Re: INP addresses?
Post by: TempodiBasic on September 02, 2018, 04:58:55 pm
Thanks Fellippe
So, we can say that inQB64 a set of QBasic functions is emulated! Because it is not possible to really do in actual OS I can imagine. Basic and ASM are not in competition! So C++ and ASM! In fact they work at different level. Moreover some Basic let us to write asm inline (TurboBasic, PowerBasic, FreeBasic...) but not QBasic or QuickBasic ! Surely to use some device there are others Keyword of QB64, while to write a driver for a device we can agree that QB64 (like Qbasic and QuickBasic) is not the right development tool. ;-)
Title: Re: INP addresses?
Post by: FellippeHeitor on September 02, 2018, 05:14:36 pm
...to write a driver for a device we can agree that QB64 (like Qbasic and QuickBasic) is not the right development tool. ;-)
Exactly!
Title: Re: INP addresses?
Post by: Omerta7486 on September 06, 2018, 02:45:14 pm
Can we not poll address &H201(Gamepad) ourselves? The gamepad, and the frame buffer/screen buffer are the two addresses I am most interested in.
The first, I want to see if I can separate XInput's Axis 3 for the Xbox/XInput controller's L/R triggers. The second, I want to see if I can squeeze an image into the screen's buffer before it refreshes to help ease the screen tearing inherent to QB64.
Title: Re: INP addresses?
Post by: FellippeHeitor on September 06, 2018, 02:55:06 pm
I recommend using the _DEVICES interface (http://qb64.org/wiki/DEVICES) (and related functions) for your controller. Or even legacy STICK (http://qb64.org/wiki/STICK) which has been adapted to poll controllers via modern approaches as well.
I also recommend using _DISPLAY (http://qb64.org/wiki/DISPLAY) to stop screen tearing.
Not being able to poll some addresses doesn't mean you can't do what used to be done via interrupts back in DOS days. You just need a more QB64 approach to it.
Title: Re: INP addresses?
Post by: TerryRitchie on September 06, 2018, 03:11:10 pm
INP was emulated to allow existing Qbasic code to operate in the QB64 environment. Those INP routines were used in Qbasic to overcome shortcomings in the language. QB64 has all the tools you will ever need for joystick, mouse, palette control, vertical retrace, etc..
The Wiki is a great source for all the commands available:
http://qb64.org/wiki/Keyword_Reference_-_By_usage
Title: Re: INP addresses?
Post by: Omerta7486 on September 06, 2018, 06:19:55 pm
The thing with the normal _AXIS() function is that with an XInput device, such as a PC's USB gamepad, or an Xbox 360 controller, the third axis corresponds to the L/R trigger. The problem is that L is on the positive axis and R is on the negative. If both triggers are pulled together, it nulls out to it's neutral state, and it's as if neither trigger had ever been pulled.
As you can see, for every step that you pull both triggers together the axis cancels itself out. This is normally not a problem as it's easy to tell if both triggers are being pulled part way, as a human could never perfectly half pull two triggers with the exact same force at the exact same moment. The problem arises when both triggers are pulled all the way, they cancel back out to the axis' neutral state, which tells the program the triggers aren't even being pulled. I was thinking if I could poll the gamepad directly, I may be able to sort the two apart.
I mean, I could build my games around not using both triggers simultaneously, but... If I can't solve such a tedious problem, how can I be a game developer? ;D LOL
[EDIT:] Random thought, but can we use &H3DA to only update our screens between vertical retraces? _DISPLAY and hardware images only gets rid of so much screen tearing.