Advertisement

Issue with Borland C++ 4 MSDOS code compiling.

Started by April 02, 2019 12:38 PM
94 comments, last by UnshavenBastard 5 years, 6 months ago

I can help you a bit better if I know what you are trying to do right now … I think I have the same code as you … I took the source code from the link you originally provided. It's the "Amazing 3-D Adventure Set CD-ROM" right?

If yes, what part of it are you having trouble building? I was able to run most of the demos in a DOSBOX window.

Are you trying to build the ACK engine? If so, for DOS or for Windows?

 

 

16 minutes ago, Steve_Segreto said:

I can help you a bit better if I know what you are trying to do right now … I think I have the same code as you … I took the source code from the link you originally provided. It's the "Amazing 3-D Adventure Set CD-ROM" right?

If yes, what part of it are you having trouble building? I was able to run most of the demos in a DOSBOX window.

Are you trying to build the ACK engine? If so, for DOS or for Windows?

 

 

I am able to run the demos, I just cannot make edits to the code and then compile them. I am trying to compile with dos. The windows versions do not work in DosBox or Windows 10 64 bit, so I just don’t use them.

 

i can compile the ACK engine(at least I think I can, as the library file appears every time I compile the library project). I cannot, however, compile the example projects that have the actual game.

Advertisement

Can you give me a specific example of what you can't compile please? I don't have the book, I don't know what the examples are … can you write out the exact path and also cut and paste the exact errors you are receiving?

Btw, Borland was the best at the time for DOS/Win development. DJGPP has a cool IDE that works in DOS and can build 32-bit protected mode console programs, but I'm not sure its going to work for your needs. Skimming through the CD contents, it looks like it relies on a lot of Windows specific things, which you can't have in DOSBOX today. 

8 hours ago, Steve_Segreto said:

Can you give me a specific example of what you can't compile please? I don't have the book, I don't know what the examples are … can you write out the exact path and also cut and paste the exact errors you are receiving?

Btw, Borland was the best at the time for DOS/Win development. DJGPP has a cool IDE that works in DOS and can build 32-bit protected mode console programs, but I'm not sure its going to work for your needs. Skimming through the CD contents, it looks like it relies on a lot of Windows specific things, which you can't have in DOSBOX today. 

A background:

 

The example I am trying to compile, if you look through the CD, is at(if it is in you’re D drive) is D:/ACK/DOS/BORLAND.

 

The Projects:

It is in there that you will see two projects. One will be called ACK. This is the actual ACK3D library project which exports a .LIB file which I am pretty sure only works with Borland. 

 

There will also be a project file called FDEMO. This is the actual game, where it loads in the ACK library file that comes from the other project. It will load in fdemo.c and mouse.c (mouse.c loads in mouse functions for things such as buttons) and also Some other header files (for help with the library defines). 

 

Ok. Now for the errors.

So, I have 3 different Borland versions: 4.0, 4.5, and 5.0 and I have TASM for Borland 4.0.

 

When I run the project in Borland C 4.0 and 4.5, I get errors that are saying that regs.w are undefined. This is in the mouse.c files. I get several errors, as this is used frequently in the file. It is defined like this:


union ACKREGS regs;

 This is in mouse.c around line 37 (I don’t have the code with me right now... it is at the beginning of the file in the defines (yes it was also defined) and in one of the functions near the top of the file).

 

ok, usually around this time I see these errors, I go to Borland C 5.0. Here, I get errors saying that there is a 32 bit piece of code detected in one of the assembly files in the Borland 5 folder. I can fix this by going into Project > Linker settings(16 big) and enabling execution for 32 bit.

 

i then either get one of the linked errors I previously mentioned where it says “unknown symbol->k or unknown symbol -> ts”. This is a tlink error.

 

either this or this: “file type exceeds 64k” error pops up.

 

-R

A few more questions... what is your development environment? Are you in a DOSbox in a modern windows hardware or do you actually have an old system that can run the original Borland windows Gui IDE? I’m trying to understand how you are building 

3 hours ago, Steve_Segreto said:

A few more questions... what is your development environment? Are you in a DOSbox in a modern windows hardware or do you actually have an old system that can run the original Borland windows Gui IDE? I’m trying to understand how you are building 

I am using VMWare. 

Modern Windows with Borland 5.0 may possibly work, but probably not.

Advertisement

Sorry to keep asking questions, but I lost my mind reading abilities years ago in a freak game dev accident … :) but seriously … what OS are you installing on the VMWare? Win 3.1 or Win95?

One thing I noticed skimming through the makefiles in D:\ACK\DOS\BORLAND\ACK.MAK was it appears the book wants you to install part of its content into your Borland 4.0 installation folder (C:\BC4\ACK). Double check you've got this part correctly installed, I don't have the text of the book, so I'm not sure what you are supposed to do.

LLATD32_ackdlib =  -Tpe -ax -LC:\BC4\LIB;C:\BC4\ACK

 

I think I figured out what your issue is …

ACKREGS is #define'd as 'union REGS' which is a 16-bit DOS specific struct in C:\BC4\INCLUDE\DOS.H,

however the author of mouse.c wrote their code against a different DPMI structure than the one supplied with Borland 4.0. It seems they distributed Open Watcom's DOS4GW.EXE DPMI extender and wrote their code mostly with Borland but against Watcom's DPMI structure. Go figure :)

When your compiler says 'regs.w' is undefined, it's referring to the word part of the union defined in the DOS4GW DPMI structure (which is not the same as Borland's).


union REGS {		/* Compatible with DPMI structure, except cflag */
  struct DWORDREGS d;
#ifdef _NAIVE_DOS_REGS
  struct WORDREGS x;
#else
#ifdef _BORLAND_DOS_REGS
  struct DWORDREGS x;
#else
  struct DWORDREGS_W x;
#endif
#endif
  struct WORDREGS w;
  struct BYTEREGS h;
};

Borland's structure only has WORDREGS x instead of w:


struct WORDREGS {
    unsigned int    ax, bx, cx, dx, si, di, cflag, flags;
};

struct BYTEREGS {
    unsigned char   al, ah, bl, bh, cl, ch, dl, dh;
};

union  REGS    {
    struct  WORDREGS x;
    struct  BYTEREGS h;
};

So you have a few options:

1. Inside mouse.c, change all the instances of 'regs.w' to 'regs.x' and then change the ACKINT from int386 to the correct instruction

*OR*

2. Find the correct dos.h include file for the DPMI provided in the ACK book and include that instead of the one from Borland C++ 4.0

I was able to compile everything in FDEMO successfully using option 1 above, but only on this old 32-bit Windows XP system I had laying around, and Borland 4.0 warned me that using it on Windows NT was at my own risk. :)

To compile, I had to make the following changes in mouse.c and fdemo.c


// MOUSE.C
// Changed by Steve S., instead of int386 use intr
#ifdef __BORLANDC__
#define ACKREGS union		REGS
#define ACKINT(n,r) intr(n,r)
#else
#define ACKREGS union		REGPACK
#define ACKINT(n,r)		intr(n,r)
#endif

// Changed by Steve S., instead of regs.w.ax use regs.x.ax (repeat this modification throughout the file)
yesno = regs.x.ax;

 


// FDEMO.C
// Changed by Steve S., I had to add 'huge' keyword as this is greater than 256 * 256 bytes
extern	huge long	zdTable[VIEW_WIDTH][200];

 

I recommend you return to Borland 4.0, revert everything you did to try to get past the 'regs.w undefined' error and try to find the matching DOS4GW DPMI includes (that or try the hacks I show above).

4 hours ago, Steve_Segreto said:

I think I figured out what your issue is …

ACKREGS is #define'd as 'union REGS' which is a 16-bit DOS specific struct in C:\BC4\INCLUDE\DOS.H,

however the author of mouse.c wrote their code against a different DPMI structure than the one supplied with Borland 4.0. It seems they distributed Open Watcom's DOS4GW.EXE DPMI extender and wrote their code mostly with Borland but against Watcom's DPMI structure. Go figure :)

When your compiler says 'regs.w' is undefined, it's referring to the word part of the union defined in the DOS4GW DPMI structure (which is not the same as Borland's).



union REGS {		/* Compatible with DPMI structure, except cflag */
  struct DWORDREGS d;
#ifdef _NAIVE_DOS_REGS
  struct WORDREGS x;
#else
#ifdef _BORLAND_DOS_REGS
  struct DWORDREGS x;
#else
  struct DWORDREGS_W x;
#endif
#endif
  struct WORDREGS w;
  struct BYTEREGS h;
};

Borland's structure only has WORDREGS x instead of w:



struct WORDREGS {
    unsigned int    ax, bx, cx, dx, si, di, cflag, flags;
};

struct BYTEREGS {
    unsigned char   al, ah, bl, bh, cl, ch, dl, dh;
};

union  REGS    {
    struct  WORDREGS x;
    struct  BYTEREGS h;
};

So you have a few options:

1. Inside mouse.c, change all the instances of 'regs.w' to 'regs.x' and then change the ACKINT from int386 to the correct instruction

*OR*

2. Find the correct dos.h include file for the DPMI provided in the ACK book and include that instead of the one from Borland C++ 4.0

I was able to compile everything in FDEMO successfully using option 1 above, but only on this old 32-bit Windows XP system I had laying around, and Borland 4.0 warned me that using it on Windows NT was at my own risk. :)

To compile, I had to make the following changes in mouse.c and fdemo.c



// MOUSE.C
// Changed by Steve S., instead of int386 use intr
#ifdef __BORLANDC__
#define ACKREGS union		REGS
#define ACKINT(n,r) intr(n,r)
#else
#define ACKREGS union		REGPACK
#define ACKINT(n,r)		intr(n,r)
#endif

// Changed by Steve S., instead of regs.w.ax use regs.x.ax (repeat this modification throughout the file)
yesno = regs.x.ax;

 



// FDEMO.C
// Changed by Steve S., I had to add 'huge' keyword as this is greater than 256 * 256 bytes
extern	huge long	zdTable[VIEW_WIDTH][200];

 

I recommend you return to Borland 4.0, revert everything you did to try to get past the 'regs.w undefined' error and try to find the matching DOS4GW DPMI includes (that or try the hacks I show above).

Wow, thanks.

 

last error is: “Linker Fatal: 32 bit module encountered in module clib\c0nt.ASM”.

 

When I go to Linker settings and change the 16 bit Linker to enable 32 bit processing, I get another error that says:

”Linking fdemo.exe 

IDE error:

BCW: unexpected build termination”

 

thanks for going through the trouble, though, of compiling everything!

 

should I move my project to a Windows XP 32 bit VMWare machine/Vortualbox machine?

I suggest you go back to Borland 4.0 and make the changes I suggested and see if you still get that linker error. Like I said, you made the wrong decision to get around 'regs.w undefined' by changing toolchains into the future. You want to play in 1993? Stay in 1993, don't fast forward your tools past the publish date of the book's source code or you will get into undefined territory.

It seems like the author in his effort to support both major DOS development toolchains of the 1993-1994 timeframe accidentally made it so some of his code requires both Borland and Open Watcom to be installed at the same time to be built.

This topic is closed to new replies.

Advertisement