VOGONS


First post, by wiebermensch

User metadata
Rank Newbie
Rank
Newbie

I think it's because of the incompleteness of VC6..
(VC6 does not fully support template class and template function.)
When I compile CVS version of DOSBox, I can only see this error message:

(In src/gui/render_normal.h)static RENDER_Line_Handler Normal_8[4]={...}
<------- cannot convert from '' to 'void (__cdecl *)(unsigned char *)'
(and many same sort of errors in many parts of the source code)

So I tried this sample code :

template<int k> void set2k(int a){ a=k; }
int main(int argc, char* argv[]){
void(*phwptf)(int) = &set2k<132>;
return 0;
}

Interestingly, G++ compiler compiled this code with no problem,
but Visual C++ 6.0 showed this error message :

error C2440: 'initializing' : cannot convert from '' to 'void (__cdecl *)(int)'

I changed the code a little, but the result was the same :

typedef void(*PHWPTF)(int);
template<int k> void set2k(int a){ a=k; }
int main(int argc, char* argv[]){
PHWPTF ptf; *ptf = set2k<132>;
return 0;
}

error C2783: 'void __cdecl set2k(int)' : could not deduce template argument for 'k'

Reply 2 of 2, by wiebermensch

User metadata
Rank Newbie
Rank
Newbie

Myself reply 😀
Use VC7.1(a.k.a .NET 2003) to compile with no problem.
Or, you can use VC7.0(a.k.a .NET 2002) and overwrite VC Toolkit 2003 files into VC7.0 folder.
Important Fact: VC .NET 2003 is free except IDE. Microsoft guys are freely distributing VC7.1 without IDE, i.e, VC Toolkit 2003.
If you copy cl.exe, mspdb71.dll etc. into old version VC directory, you can compile DOSBox without problems.
If you have VC6.0, you should change these files.
1. render_normal.h :
Replace template function static void Normal(Bit8u * src){...}
to eight different functions, namely, Normal880, Normal8160, Normal8240, Normal8320, Normal881, Normal8161, Normal8241, Normal8321.

In detail,
for example, copy and paste static void Normal(Bit8u * src){...}, change its name to Normal880, and replace every occurrence of sbpp to 8, dbpp to 8, xdouble to false. The result will be like this:
static void Normal880(Bit8u * src) {
Bitu line_size=LineSize<8>(render.src.width) * (false ? 2 : 1);
Bit8u * line;
if (8 == 8 && !false) {
line=src;
BituMove(render.op.pixels,line,line_size);
} else {
Bit8u * line_dst=&normal_cache[0];
Bit8u * real_dst=render.op.pixels;
line=line_dst;
Bit8u * temp_src=src;
for (Bitu tempx=render.src.width;tempx;tempx--) {
Bitu val=ConvBPP<8,8>(LoadSrc<8>(temp_src));
AddDst<8>(line_dst,val);
AddDst<8>(real_dst,val);
if (false) {
AddDst<8>(line_dst,val);
AddDst<8>(real_dst,val);
}
}
}
render.op.pixels+=render.op.pitch;
for (Bitu lines=render.normal.hlines[render.op.line++];lines;lines--) {
BituMove(render.op.pixels,line,line_size);
render.op.pixels+=render.op.pitch;
}
}

Normal8160 means sbpp=8, dbpp=16, xdouble=false.
Normal8240 means sbpp=8, dbpp=24, xdouble=false.
Normal8320 means sbpp=8, dbpp=32, xdouble=false.
Normal881 means sbpp=8, dbpp=8, xdouble=true.
Normal8161 means sbpp=8, dbpp=16, xdouble=true.
Normal8241 means sbpp=8, dbpp=24, xdouble=true.
Normal8321 means sbpp=8, dbpp=32, xdouble=true.

Also, you should change Normal_8 and Normal_2x_8 like this:

static RENDER_Line_Handler Normal_8[4]={
Normal880,Normal8160,
Normal8240,Normal8320,
};

static RENDER_Line_Handler Normal_2x_8[4]={
Normal881,Normal8161,
Normal8241,Normal8321,
};

2. render_scale2x.h :
Replace template function static void AdvMame2x(Bit8u * src){...}
to four different functions, namely, AdvMame2x88, AdvMame2x816, AdvMame2x824, AdvMame2x832.

In detail,
for example, copy and paste static void AdvMame2x(Bit8u * src){...}, change its name to AdvMame2x88, and replace every occurrence of sbpp to 8, dbpp to 8. The result will be like this:
static void AdvMame2x88(Bit8u * src) {
RENDER_TempLine=render_line_cache[render.op.line&3];
am2x.cache[render.op.line&3]=src;
Bitu lines=*am2x.cmd_index++;
while (lines--) {
Bit8u * src0=am2x.cache[*am2x.cmd_index++];
Bit8u * src1=am2x.cache[*am2x.cmd_index++];
Bit8u * src2=am2x.cache[*am2x.cmd_index++];
AdvMame2x_line<8,8>(render.op.pixels,src0,src1,src2,render.src.width);
render.op.pixels+=render.op.pitch;
}
render.op.line++;
}

AdvMame2x816 means sbpp=8, dbpp=16.
AdvMame2x824 means sbpp=8, dbpp=24.
AdvMame2x832 means sbpp=8, dbpp=32.

Also, you should change AdvMame2x_8_Table like this:

static RENDER_Line_Handler AdvMame2x_8_Table[4]={
AdvMame2x88,AdvMame2x816,AdvMame2x824,AdvMame2x832
};

Finally, if src/hardware/vga.h is obsolete, copy include/vga.h and overwrite to src/hardware/.

P.S. Outrageous but effective way to reduce errors is... COMMENT IT!

Attachments

  • Filename
    vc6fix.rar
    File size
    260.06 KiB
    Downloads
    219 downloads
    File comment
    Builds well on VC6.0
    File license
    Fair use/fair dealing exception