Slimelite BBS

pascal to c++; marilyn manson rule!..

Back to EMULATE

From Corey Cahill · 1996-04-04 12:45 · #73632 in EMULATE

 CC> ptr() (p:=ptr($a000,$0320); {p=pointer})
 JVH> You can use a simple macro to do all the work:
 JVH> #ifndef MK_FP
 JVH> #define MK_FP(seg, ofs) ((void far *) ((unsigned long)(seg)<<16|ofs)))
 JVH> #endif
 JVH> p = MK_FP(0xa000,0x0320);
kewl..this is also included in the dos.h (i think)..

 CC> new()        (new(p);)
 JVH> new
 CC> dispose()    (dispose(p);)
 JVH> delete
get 'em already..

 CC> getmem()     (getmem(p,1);)
 CC> freemem()    (freemem(p,1);)
 JVH> as in Pascal, use new/delete as they are 'better' (in C/C++ new/delete
 JVH> is part of C++, delete will call destructors automatically,....)
ya..but sometimes i want only x amount of memory allocated..someone mentioned
malloc() and free() to me..

 CC> absolute     (var b : byte absolute $b800:0080;)
 JVH> I don't know if you can use it in this way in C(++). A pointer will do
 JVH> the job easily:
 JVH> #define BIOS_KBF ((unsigned far *) MK_FP(0x40, 0x17))
 JVH> *BIOS_KBF |= flag; // or [0040:0017] with flag
ya..someone mentioned something like that already..

 CC> pointer      (var p : pointer; {think this is same as "void *p;")
 JVH> Yep.
kewl..

 CC> boolean      (is there one?)
 JVH> Nope, you can always make one yourself:
 JVH> typedef unsigned char BOOL;
i suppose that's what i'll have to do..hey..is there an equivilant to:

 "type bool = (false,true);"  in c++??

 CC> pchar        (think this is same as "char *x;")
 JVH> I think so too, but I don't know pchar that well.
i think it's the same..it is basically a ^char in pascal..

 CC> ^variable    (is this the same as "<type> *<var>"?)
 JVH> Yep.
kewl..

 CC> also, how do i link .obj files into c++ proggys
 JVH> using a linker, but since you're talking about .tpu (Turbo Pascal
 JVH> Units) I assume you use a borland compiler for C/C++ too ;-) In that
 JVH> case you can include the .obj in the project and use
 JVH> extern <type> < (); in your .c/.cpp file.
 CC> ..and finally..how would i go about making a .tpu equivilent
 CC> in c++?..(.lib's?..if so..how?)..
 JVH> Why? You can #include the .h files of your 'units' to use them.
'cause i'd like to have many procs/functions..etc..actually i figured out how
to use projects in tc++..with the help of someone else of course..

newayz..thanx for the help man..c!

~~~ TGWave v1.13 Beta-02+
--- Telegard v2.99.b23 [ml]
 * Origin: Battle Zone Systems <*> ONTARIO <*> 1-905-715-7963 (1:259/900)