Re: MS-DOS Porting trouble

Search this archive.

From: Bart Oldeman (Bart.Oldeman@bristol.ac.uk)
Date: Fri 11 Aug 2000 - 23:47:49 IDT


On Fri, 11 Aug 2000, Lionel Pinkhard wrote:

[just saw that Matan Ziv-Av already answered while I was writing this,
so some of this overlaps a bit]

> Firstly, my game uses CGA mode 4h, which it doesn't look like SVGALIB
> supports, is there a way of setting this mode? I saw a function in the
> source code called vga_addmode(), does this have anything to do with it?
> If not, what's it for? And how can I use it? Or is it only for internal
> use?

As far as I could see, vga_addmode just adds (maxx, maxy, bpp, 
etc.) information to the internal mode database. Whilst it is possible
to add support for it by programming the chipset, you can easily simulate
CGA mode 4h by using G320x200x16 or G320x200x256 and just using 4 colors.

> Secondly, my routine for trapping keystrokes doesn't work under Linux,
> here's the code I tried:
> 
>     while (kbhit()) {
>         keypressed = getch();
> 
> Why doesn't it work? Or what do I need to include?

If you use ncurses you can use getch. See man getch. You could do the
following:

noecho();
cbreak(); /* set cbreak mode (don't wait for return key) */
while (1) {
	keypressed=getch(); /* getch waits for the key */

The DOS method is very dirty in Linux since it continuously polls
kbhit() and therefore eats a lot of CPU cycles.

Or use vga_getch() instead. Then you don't need ncurses.
If you need certain keys not available through ncurses/vga_getch then you
need to use raw keyboard handling. See man svgalib + individual manpages.

> Thirdly, my timing doesn't work, for the old DOS version, I used Interrupt
> 1ah, is there a way I can get the time in the same format under Linux?

processor time used by program: clock(3)
seconds since 1 January 1970: time(2)
most accurate: gettimeofday(2)
 
> Fourthly, how can I determine whether a joystick is installed? And if so,
> how can I get it's axis? I have never programmed ports on Linux before,
> and the outport() and inport() functions don't seem to work, or would I
> have to rewrite the entire function differently? If so, how?

svgalib has joystick functions. It's better to use them.
joystick_getaxis(3) is the obvious function to get its axis.

Regards,
Bart


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST