[comp.os.os2.programmer] Is OS/2 really usable for programming?

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (06/06/91)

I have heard from several sources that OS/2 is really the way to go, but I
still have my doubts based on some other and same sources of information.

So I'd like to pose some questions about programming applications to run
under OS/2 as well as MS-DOS.

I want my program to be able to trap and handle every keyboard state change
that takes place.  I want to handle both up and down keystrokes in any
combination.  Under MS-DOS I would just have my program take over the
interrupt handling of the keyboard directly.  How do I make a program do
this under OS/2?

I want my program to be able to write directly to VGA buffers and registers
for the purpose of writing to the screen at the maximum possible speed, and
to be able to pan and scroll the screen smoothly at high speeds.  I also
want to be able to setup special modes such as 360x480x256 and others that
the VGA cards are actually capable of (not all the same for all cards, I do
know).  Under MS-DOS I can easily take control of the video card and do
just what I want.  How do I do this under OS/2?

This article is not to argue the merits of or lack thereof of bypassing the
BIOS or OS to do such things that might cause problems under other systems.
The nature of what I want to do necessitates doing it this way unless the OS
has provides very high performance and flexible interfaces for it.

I just want to know if OS/2 is going to be more hassle than it is worth as
some have already suggested to me w/o much supportive evidence.
-- 
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu   |  Guns don't aim guns at  \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks  |  people; CRIMINALS do!!  /
 \***************************************************************************/

joeb@hpnmdla.sr.hp.com (Joe Barnhart) (06/07/91)

In comp.os.os2.programmer, phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:

  | I want my program to be able to trap and handle every keyboard state change
  | that takes place.  I want to handle both up and down keystrokes in any
  | combination.  Under MS-DOS I would just have my program take over the
  | interrupt handling of the keyboard directly.  How do I make a program do
  | this under OS/2?

Use a "keyboard monitor."  This is an OS-supplied "keyboard hook" which
allows you to do just about anything you want on keystrokes.  You can
hook a similar monitor on virtually any hardware device.

  | I want my program to be able to write directly to VGA buffers and registers
  | for the purpose of writing to the screen at the maximum possible speed, and
  | to be able to pan and scroll the screen smoothly at high speeds.  I also

Don't think for one second that OS/2 has the same limits on raw video 
performance that DOS does.  The standard "VIO" calls are _fast_ under OS/2.
You might find that you don't need to go to this trouble for video I/O 
speed.

  | want to be able to setup special modes such as 360x480x256 and others that
  | the VGA cards are actually capable of (not all the same for all cards, I do
  | know).  Under MS-DOS I can easily take control of the video card and do
  | just what I want.  How do I do this under OS/2?

This can be done, but only for a "full screen" application.  As you might
imagine, your customer wouldn't be very happy if you switched video modes
and his Presentation Manager screen went gaga (technical term).

For a good treatment on VIO calls, device monitors, etc., I recommend 
Ray Duncan's "Advanced OS/2 Programming" (or something like that).  Also,
Gordon Letwin's book on the philosophy of OS/2 is very enlightening.

-- Joe B.

#include <standard.disclaimer>

dnanian@uw.com (Dave Nanian) (06/07/91)

In article <11560004@hpnmdla.sr.hp.com> joeb@hpnmdla.sr.hp.com (Joe Barnhart)  
writes:
> In comp.os.os2.programmer, phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
> 
>   | I want my program to be able to trap and handle every keyboard state  
change
>   | that takes place.  I want to handle both up and down keystrokes in any
>   | combination.  Under MS-DOS I would just have my program take over the
>   | interrupt handling of the keyboard directly.  How do I make a program do
>   | this under OS/2?
> 
> Use a "keyboard monitor."  This is an OS-supplied "keyboard hook" which
> allows you to do just about anything you want on keystrokes.  You can
> hook a similar monitor on virtually any hardware device.
>[stuff deleted]

Please note that keyboard monitors don't work under PM -- they only work full  
screen.  You can simulate keyboard monitors with PM calls, but doing so means  
your application won't work outside of PM.

IBM and Microsoft seemed to have second thoughts about the whole keyboard  
monitor interface.  Perhaps it'll return in 2.0 or 32-bit OS/2....

--Dave Nanian, UnderWare, Inc. (dnanian@uw.com, uunet!uw!dnanian, NeXT Mail  
Preferred)

tom@microsoft.UUCP (Tom MCCONNELL) (06/09/91)

In article <1991Jun5.212129.11089@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
>I have heard from several sources that OS/2 is really the way to go, but I
>still have my doubts based on some other and same sources of information.
>
>So I'd like to pose some questions about programming applications to run
>under OS/2 as well as MS-DOS.
>
>I want my program to be able to trap and handle every keyboard state change
>that takes place.  I want to handle both up and down keystrokes in any
>combination.  Under MS-DOS I would just have my program take over the
>interrupt handling of the keyboard directly.  How do I make a program do
>this under OS/2?
>

OS2 will allow you to have this granualarity of keyboard input.

If you really want to be a part of the input chain, simply use the 
DosMonReg() class of apis.  These allow you to set up a routine
which get's all keyboard info.  You can have multiple keyboard handlers
all hooked in, allowing keyboard handlers to coexits peacefully.  Of
course there is info which specifies where in the chain you want to 
be, at the front, at the end, you don't care, or a specific point.

It's all very easy.  In fact the very first OS2 program I wrote was
a DosMonReg program.

>I want my program to be able to write directly to VGA buffers and registers
>for the purpose of writing to the screen at the maximum possible speed, and
>to be able to pan and scroll the screen smoothly at high speeds.  I also
>want to be able to setup special modes such as 360x480x256 and others that
>the VGA cards are actually capable of (not all the same for all cards, I do
>know).  Under MS-DOS I can easily take control of the video card and do
>just what I want.  How do I do this under OS/2?

If you are using a "full screen" or better known as text mode, then there 
is a class of api's called VIO api's which give you the same sort
of control and speed.  The nice thing about using VIO's, is that
when you are running as a full screen, you have the speed, and when you 
are running as a windowed shell, it still displays the same, just in
a window.  This API is also very rich, flexible and fast.   It gives you
an OS 'okayed' method of doing the high performance sort of things you
want to do.

>
>This article is not to argue the merits of or lack thereof of bypassing the
>BIOS or OS to do such things that might cause problems under other systems.
>The nature of what I want to do necessitates doing it this way unless the OS
>has provides very high performance and flexible interfaces for it.
>
>I just want to know if OS/2 is going to be more hassle than it is worth as
>some have already suggested to me w/o much supportive evidence.

Not only are these interfaces easy, but they are high performance as well.

Try it, you'll like it! :-)

-Tom


>-- 
> /***************************************************************************\
>/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu   |  Guns don't aim guns at  \
>\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks  |  people; CRIMINALS do!!  /
> \***************************************************************************/
-- 
"Hey COW!"  _____________((     
           /       **    o \    ______     _______________________
          /|      ****      \ _/moo...\    |     Tom McConnell   |
         / |      **    /\__/  \______/    | uunet!microsoft!tom |

rickr@virtech.uucp (Rick Rodman) (06/14/91)

In article <11560004@hpnmdla.sr.hp.com>, joeb@hpnmdla.sr.hp.com (Joe Barnhart) writes:
> In comp.os.os2.programmer, phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
> 
>   | I want my program to be able to trap and handle every keyboard state change
>   | that takes place.  I want to handle both up and down keystrokes in any
>   | combination.  Under MS-DOS I would just have my program take over the
>   | interrupt handling of the keyboard directly.  How do I make a program do
>   | this under OS/2?
> 
> Use a "keyboard monitor."  This is an OS-supplied "keyboard hook" which
> allows you to do just about anything you want on keystrokes.  You can
> hook a similar monitor on virtually any hardware device.
> 
>   | I want my program to be able to write directly to VGA buffers and registers
>   | for the purpose of writing to the screen at the maximum possible speed, and
>   | to be able to pan and scroll the screen smoothly at high speeds.  I also
> 
> Don't think for one second that OS/2 has the same limits on raw video 
> performance that DOS does.  The standard "VIO" calls are _fast_ under OS/2.
> You might find that you don't need to go to this trouble for video I/O 
> speed.
> 
>   | want to be able to setup special modes such as 360x480x256 and others that
>   | the VGA cards are actually capable of (not all the same for all cards, I do
>   | know).  Under MS-DOS I can easily take control of the video card and do
>   | just what I want.  How do I do this under OS/2?
> 
> This can be done, but only for a "full screen" application.  As you might
> imagine, your customer wouldn't be very happy if you switched video modes
> and his Presentation Manager screen went gaga (technical term).
> 
> For a good treatment on VIO calls, device monitors, etc., I recommend 
> Ray Duncan's "Advanced OS/2 Programming" (or something like that).  Also,
> Gordon Letwin's book on the philosophy of OS/2 is very enlightening.
> 
> -- Joe B.
> 

SCR_ALLOCLDT allows R/W access to the screen buffer to do whatever you want.
See p. 269 of vol. 4 of the programmer's reference.

It also allows R/O access to rest of 1st megabyte.  Anyone know how to get
R/W access?  Are there backdoor segments like in Windows?


Rick Rodman      uunet!virtech!rickr	"Yesterday's Tomorrow is Here Today"

-- 

Rick Rodman      uunet!virtech!rickr	"Yesterday's Tomorrow is Here Today"