Re: HELP: C/C++ equivalent of dos,crt Pascal units
- From: Tim Roberts <timr@xxxxxxxxx>
- Date: Sat, 02 Sep 2006 23:07:58 -0700
"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.
.
- References:
- HELP: C/C++ equivalent of dos,crt Pascal units
- From: Dhruba Bandopadhyay
- HELP: C/C++ equivalent of dos,crt Pascal units
- Prev by Date: Re: Writing wizard from scratch using express edition(no appwizard)
- Next by Date: charts in vc++.net windows application
- Previous by thread: Re: HELP: C/C++ equivalent of dos,crt Pascal units
- Next by thread: how to output the All macros in the C file
- Index(es):
Relevant Pages
|