Re: HELP: C/C++ equivalent of dos,crt Pascal units

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Dhruba Bandopadhyay" <dhruba.bandopadhyay@xxxxxxxxxxx> wrote:

I am trying to port an old Pascal DOS game to DOS C/C++. I am wondering if
anyone is familar with the dos & crt Pascal units and whether there are
C/C++ equivalent libraries. Maybe dos.c & crt.c?

You need to be careful with your terminology here. None of this stuff is
in the standards for either Pascal or C. What you have is a Borland Turbo
Pascal program. Assuming you want to do the same thing in Microsoft Visual
C++ 1.52 (which was the last 16-bit compiler), then we can give you an
answer.

Below lists names of variables, functions, types & weird interrupt
procedures found in Pascal. Am wondering what can be done to get around them
for use in C/C++.

dos.pas
crt.pas

---undefined identifiers---
'black'
'blue'
'clrscr'
'lightblue'
'lightcyan'
'lightgray'
'lightgreen'
'lightmagenta'
'lightred'
'white'
'yellow'

You will have to compute these constants yourself. It isn't hard.

'mem'

The "mem" array is just Turbo Pascal's way of accessing arbitrary memory
accesses. You will want to use far pointers or huge pointers for this.

'port'

The "port" array is the equivalent of the inp and outp functions in
Microsoft C.

'wherex'
'wherey'

These return the current cursor position. You'll probably have to write
that yourself by calling INT 10.

---unknown types---
Single
registers

The Pascal "single" type is the same as C's "float" type. In VC++1.52, the
dos.h include file has a REGS type that can be used to make interrupt
calls.

---misc---
Port[$3C8] := reg;
l := port[$60];
port[$20] := $20;
Port[$43] := $B6;

outp( 0x3c8, reg );
l = inp( 0x60 );
outp( 0x20, 0x20 );
outp( 0x43, 0xb6 );

ch := mem[seg(tex) + (let div 16): ofs(tex) + (let mod 16)];

There are probably better ways to do this in C. Microsoft C suports a
"huge" pointer type that is probably the same as this. Assuming you have
this:
char __huge * tex;
then you can say:
ch = tex[let];

procedure NewInt1C; Interrupt;
procedure NewInt08; Interrupt;

Microsoft C has an __interrupt keyword to let you define interrupt
routines, although it isn't as automatic as Turbo Pascal.

void __interrupt NewInt1C()
{
__asm push ax
__asm push bx
etc...
}
--
- Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • Re: Had it with Fedora!
    ... DOS - EDLIN.COM, EDIT.COM and friends. ... the VMS kernel, to write NT. ... the spot and sued Microsoft. ... source code of multiple versions of Windows (and possibly other ...
    (alt.os.linux)
  • Re: Who has the oldest computer?
    ... there is no "DOS-legacy OS" being produced by Microsoft. ... The latest 64-bit versions don't even have the DOS ... Microsoft also has a fifth generation, variously called "Windows CE", ... there are very specific components in Intel CPUs which would ...
    (rec.food.cooking)
  • Re: Strange PSAPI process path / convert device name to DOS name
    ... Microsoft Developer Support ... | From: "Pieter" ... | Subject: Re: Strange PSAPI process path / convert device name to DOS name ... |>> module returns the process path. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Using tasm
    ... "write 32-bit Windows code rather ... than 16-bit DOS code instead!"...of course, ... the other pieces...that is, I have, say, 64KB of RAM installed ... sold itself on in _1985_...it took Microsoft a _decade_ to get their ...
    (alt.lang.asm)
  • Re: Using tasm
    ... "write 32-bit Windows code rather ... than 16-bit DOS code instead!"...of course, ... the other pieces...that is, I have, say, 64KB of RAM installed ... sold itself on in _1985_...it took Microsoft a _decade_ to get their ...
    (comp.lang.asm.x86)