Re: C/C++ equivalent of dos,crt Pascal units
"Dhruba Bandopadhyay" 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?
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;
It seems that this Pascal program directly operates video
memory buffer as well as sound, clock and something else I'm
not familiar with. If you want to port it to 16-bit DOS
program, then it should be straightforward. First of all,
get 16-bit compiler (Visual C++ v1.52 or old Borland Turbo
C++, or whatever). Then writing and reading to/from ports is
basically the same. You just call outp/inp functions. Also,
IIRC, Turbo C++ had quite rich functions set for console IO.
I reckon VC++1.52 is on par with TC++.
Porting it to Windows is completely different story. You
cannot access hardware directly anymore. So, you have
different functions in Platform SDK to reach your goals. See
these sections for beginning:
"Using the Console"
http://msdn.microsoft.com/library/en-us/dllproc/base/using_the_console.asp
"Multimedia Timers"
http://msdn.microsoft.com/library/en-us/multimed/htm/_win32_multimedia_timers.asp
"Multimedia Audio"
http://msdn.microsoft.com/library/en-us/multimed/htm/_win32_multimedia_audio.asp
If you need just a basic beep, then call to Beep() can
suffice.
HTH
Alex