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

  • Thread starter dhruba.bandopadhyay
  • Start date
D

dhruba.bandopadhyay

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?

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'
'mem'
'port'
'wherex'
'wherey'
'white'
'yellow'


---undefined functions---
'addr'
'blockread'
'delay'
'fillchar'
'fsearch'
'getintvec'
'gettime'
'gotoxy'
'hi'
'inline_'
'int_'
'intr'
'lo'
'ofs'
'seg'
'setintvec'
'settime'
'swap'
'textbackground'
'textcolor'
'window'


---unknown types---
Single
registers


---misc---
Port[$3C8] := reg;
l := port[$60];
port[$20] := $20;
Port[$43] := $B6;
ch := mem[seg(tex) + (let div 16): ofs(tex) + (let mod 16)];
procedure NewInt1C; Interrupt;
procedure NewInt08; Interrupt;
 
A

Alf P. Steinbach

* (e-mail address removed):
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?

1. Yes, there are.

2. But no, not in the standard C++ library.

3. You probably don't want what you're asking! Probably you're
porting to Windows console, not DOS.

4. DO NOT CROSSPOST TO C, C++ AND PASCAL GROUPS!

5. This is a FAQ. Check the C++ FAQ.

6. You're OFF-TOPIC in all groups posted to.

7. Post to an appropriate group (some appropriate groups are listed
in the FAQ).

Please do not reply to this posting (see points 4, 6 and 7).
 
D

David Harmon

On 1 Sep 2006 08:12:41 -0700 in comp.lang.c++,
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?

This issue is covered in Marshall Cline's C++ FAQ. See the topics:
# [15.17] How can I tell {if a key, which key} was pressed before the user presses the ENTER key?
# [15.18] How can make it so keys pressed by users are not echoed on the screen?
# [15.19] How can I move the cursor around on the screen?
# [15.20] How can I clear the screen? Is there something like clrscr()?
# [15.21] How can I change the colors on the screen?

It is always good to check the FAQ before posting. You can get the
FAQ at:
http://www.parashift.com/c++-faq-lite/

See the welcome message posted twice per week in comp.lang.c++ under
the subject "Welcome to comp.lang.c++! Read this first." or
available at http://www.slack.net/~shiva/welcome.txt
 
N

Neil

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?

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'
'mem'
'port'
'wherex'
'wherey'
'white'
'yellow'


---undefined functions---
'addr'
'blockread'
'delay'
'fillchar'
'fsearch'
'getintvec'
'gettime'
'gotoxy'
'hi'
'inline_'
'int_'
'intr'
'lo'
'ofs'
'seg'
'setintvec'
'settime'
'swap'
'textbackground'
'textcolor'
'window'


---unknown types---
Single
registers


---misc---
Port[$3C8] := reg;
l := port[$60];
port[$20] := $20;
Port[$43] := $B6;
ch := mem[seg(tex) + (let div 16): ofs(tex) + (let mod 16)];
procedure NewInt1C; Interrupt;
procedure NewInt08; Interrupt;

Single = float
 
M

Moonlit

Hi,

Well from the top of my head 1C is I believe the timer interrupt. I just
checked a decennia old assembly program of mine
http://moonlit.xs4all.nl/MUSIC.COM
and it still runs in a dosbox. I.e. apparently you can still set
timerinterrupts. 08 interupt vector was I believe the keyboard interrupt.

Open a dosbox and enter music.com (if you dare :) ) It is a tsr so to
remove it from memory just run it again.

--
Here is a piece of code (in assembly, the C functions are not compatible
amongst the C compiler (msc or turbo C). This replaces interrupt 1C (the
time interrupt) using msdos function (interrupt 21) 35h and 25h. It saves
the old address because you have to restore it when exiting your program.
Otherwise it will obviously point into nothing (which is pretty bad for the
timer interrupt).

Playtune is the offset of your interrupt routine. In MSVC you can use the
__asm keyword. The interrupt itself is best created with as 'naked' routine
and should end with reti (return from interrupt, instead of the compiler
generated ret)

Install: Mov Ax,351ch ;Get old interuptvector
Int 21h
Mov [Oldintoff],Bx
Mov [Oldintseg],Es
Mov Ax,251ch ;Install new interuptvector.
Mov Dx, Play_tune
Int 21h


Ok, so you really don't want to do this right? Just learn windows
programming and lookup WM_TIMER message, SetTimer, KillTimer and WM_CHAR
messages.
Let msvc generate a basic MFC app and do something with those messages in
the main event loop.
Then on the WM_PAINT event draw in your window using the nice GDI functions.
That should cover all those turbo pascal functions I see in your listing.

Regards, Ron AF Greve

http://moonlit.xs4all.nl

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?

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'
'mem'
'port'
'wherex'
'wherey'
'white'
'yellow'


---undefined functions---
'addr'
'blockread'
'delay'
'fillchar'
'fsearch'
'getintvec'
'gettime'
'gotoxy'
'hi'
'inline_'
'int_'
'intr'
'lo'
'ofs'
'seg'
'setintvec'
'settime'
'swap'
'textbackground'
'textcolor'
'window'


---unknown types---
Single
registers


---misc---
Port[$3C8] := reg;
l := port[$60];
port[$20] := $20;
Port[$43] := $B6;
ch := mem[seg(tex) + (let div 16): ofs(tex) + (let mod 16)];
procedure NewInt1C; Interrupt;
procedure NewInt08; Interrupt;
 
M

Moonlit

Oops in the unlikely event you really want to execute the dos program (or
look into it with debug).

Here is the correct link

http://moonlit.xs4all.nl/~moonlit/MUSIC.COM


--


Regards, Ron AF Greve

http://moonlit.xs4all.nl

Moonlit said:
Hi,

Well from the top of my head 1C is I believe the timer interrupt. I just
checked a decennia old assembly program of mine
http://moonlit.xs4all.nl/MUSIC.COM
and it still runs in a dosbox. I.e. apparently you can still set
timerinterrupts. 08 interupt vector was I believe the keyboard interrupt.

Open a dosbox and enter music.com (if you dare :) ) It is a tsr so to
remove it from memory just run it again.

--
Here is a piece of code (in assembly, the C functions are not compatible
amongst the C compiler (msc or turbo C). This replaces interrupt 1C (the
time interrupt) using msdos function (interrupt 21) 35h and 25h. It saves
the old address because you have to restore it when exiting your program.
Otherwise it will obviously point into nothing (which is pretty bad for
the timer interrupt).

Playtune is the offset of your interrupt routine. In MSVC you can use the
__asm keyword. The interrupt itself is best created with as 'naked'
routine and should end with reti (return from interrupt, instead of the
compiler generated ret)

Install: Mov Ax,351ch ;Get old interuptvector
Int 21h
Mov [Oldintoff],Bx
Mov [Oldintseg],Es
Mov Ax,251ch ;Install new interuptvector.
Mov Dx, Play_tune
Int 21h


Ok, so you really don't want to do this right? Just learn windows
programming and lookup WM_TIMER message, SetTimer, KillTimer and WM_CHAR
messages.
Let msvc generate a basic MFC app and do something with those messages in
the main event loop.
Then on the WM_PAINT event draw in your window using the nice GDI
functions. That should cover all those turbo pascal functions I see in
your listing.

Regards, Ron AF Greve

http://moonlit.xs4all.nl

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?

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'
'mem'
'port'
'wherex'
'wherey'
'white'
'yellow'


---undefined functions---
'addr'
'blockread'
'delay'
'fillchar'
'fsearch'
'getintvec'
'gettime'
'gotoxy'
'hi'
'inline_'
'int_'
'intr'
'lo'
'ofs'
'seg'
'setintvec'
'settime'
'swap'
'textbackground'
'textcolor'
'window'


---unknown types---
Single
registers


---misc---
Port[$3C8] := reg;
l := port[$60];
port[$20] := $20;
Port[$43] := $B6;
ch := mem[seg(tex) + (let div 16): ofs(tex) + (let mod 16)];
procedure NewInt1C; Interrupt;
procedure NewInt08; Interrupt;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top