Re: MS-DOS Porting trouble

Search this archive.

From: Matan Ziv-Av (matan@svgalib.org)
Date: Fri 11 Aug 2000 - 23:34:44 IDT


> I'm busy porting a game I wrote back when I used MS-DOS to the Linux
> operating system. But I have quite a few problems:
> 
> 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?

You can add a mode with the same resolution as the CGA mode, and might
even find a modeline for it (it is not easy for low res modes, as I
found out when looking for spectrum resloution mode). But there is no
way svgalib will supports 2 bit (4 color) modes, or the funny memory
layout of cga. I think you best course is to move the game to
320x200x256 mode (or 640x400x256, if you previously used 640x200).
You might also use lrmi to set cga mode with the bios, but then you must
take care of console switching.

> Secondly, my routine for trapping keystrokes doesn't work under Linux,
> here's the code I tried:
> 
>   while (kbhit()) {
>       keypressed = getch();

There is no kbhit() in libc or svgalib, and the keyboard handling
will have to change from DOS. Look at zgv, spectemu, keytest, eventtest
for examples of non blocking keyboard input. 

> 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?

Not exactly. try man gettimeofday.

> 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
> haveto rewrite the entire function differently? If so, how?

Don't use ports. That won't support modern (digital, usb) joysticks. Use
the joystick device.



> That's all I can think of right now, can somebody please help me out?

Just remember that Linux is very different from DOS for most of the
points you raised, so you need to learn a lot.



-- 
Matan Ziv-Av.                         matan@svgalib.org


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