VOGONS


Glide patch

Topic actions

First post, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

This patch has been available for a while now in ykhwong's builds. It allows DOSBox to run DOS Glide games (not all of them though) and now I am also releasing the source. The patch is composed of two (3 if you count glide wrapper) parts.

The first part is the GLIDE2X.OVL file. This is a DOS (kinda) DLL file that games use to access the Voodoo board. This OVL has been rewritten to talk to DOSBox instead of the Voodoo board. The file has to be present in the game directory (or somewhere in the path inside DOSBox, it can also be present in DOSBox directory; in this case it will automatically be added to the Z: drive) and is platform independent (since it runs inside DOSBox). There are games which directly access the Voodoo board without loading the OVL file. These games will not work with this patch (these are mostly early 3dfx games/demos: original [not Voodoo Rush] Tomb Rider patch, Fatal Racing, Eurofighter 2000...) and (should) work with 3DFX chip emulation by kekko.

The second part is the DOSBox patch. The patch should be relatively easy to apply and compile, it only requires a few 3dfx headers (sdk2_*.h files) which are available in the OpenGlide cvs. You need to run autogen.sh before running configure. The patch should be fairly crossplatform, but only Linux (x86 & x64), Windows ans MAC OSX have been tested so far...

These two patches allow games to access Glide on the host computer. But since most of you do not have Voodoo boards anymore (Glide DOSBox version has been tested to work with true Voodoo2 board in Win98 without any wrappers 😉) a glide wrapper is also required. You can use any wrapper you like, but some might work better or worse. The tested ones are:
- OpenGlide (see patches here)
- dgVoodoo (be sure to set it to render in window mode)
- zeckensack's (switches to fullscreen automatically)
- psvoodoo
- nGlide (actively supported, windows only)
- dgVoodoo2

OpenGlide is usually included with builds having this patch, but any wrapper can be used. Some games might work better with OpenGlide, others with dgVoodoo or nGlide, but OpenGlide is the only one crossplatform. MAC users, see MACGlide and it might be possible with some simple patches to get OpenGlide to work as well. But DOSBox patch has not been tested on Mac at all 😀 (Update: DOSBox-Glide has been tested to work on MacOSX, see this thread for OpenGlide patches, use latest dosbox_glide patch).

Currently, the following games have been tested:

Archimedean Dynasty (wrapper related graphics corruption, use nGlide)
Blood (works with dgvooodoo)
Carmageddon (works with dgVoodoo afaik)
Descent2 (works with openglide, use the unofficial 3dfx patch)
Dreams to Reality (working)
Extreme Assault (DEMO version works, full version not tested...)
GTA (no problems)
Lands of Lore 2 (works fine, some wrapper related problems, use nGlide)
RedGuard (no problems)
Screamer 2 & Rally (a bit slow with openglide, works fine with dgvoodoo if LFB access is disabled)
TombRider (no problems, use the patch from Eidos, search for Voodoo Rush patch if the link is broken)
For testing purposes, free Glide SDK tests can be found on the net, which should all work fine.

PROBLEMS:
- OpenGlide (some recent cvs version should be fine) has some serious drawbacks and performance issues. For now, use the version in my builds or compile your own version with the patches (most of the patches have been already commited)
- When glide is active, the wrapper is in control of the DOSBox window. This means that DOSBox window related options (resolution, scaler, ...) do not work
- Because of that, ALT-Enter fullscreen switch will not work as desired. In OpenGlide you have to edit OpenGLid.ini to have fullscreen, other wrappers work in fullscreen by default. With dgVoodoo, if you set the renderer to Direct3D9, ALT-Enter should work ok! (at least it does on my computer 😀)
- If you receive warnings like "Glide:Warning, unable to load grSstConfigPipeline from glide2x", it's not a problem. These are just functions that the particular wrapper does not support...unless of course the game happens to use them, but that will show as another error 😀
- Do not use the mapper when Glide is running
- If you like, you can place 3dfxSpl2.dll from the voodoo drivers in the DOSBox directory and you will see 3dfx splash screen when Glide activates 😀

Updates:
22.8.2007: Fix compilation problems
23.8.2007: Fix buffer overflow
28.8.2007: x86_64 support
03.9.2007: Fix a crash when closing dosbox while glide is active
18.10.2007: Add TombRaider shadow hack (thanks gidierre!)
06.11.2007: Improve TR shadow support (gidierre)
17.2.2008: Updated for current CVS
14.9.2008: Updated for current CVS, allow disabling LFB reads/writes
04.6.2009: Updated for 0.73, add MSVC6 projects for glide2x win9x build
30.8.2009: Fix LFB operations when paging is active
09.10.2009: Various fixes and code cleanups, fix originlocation + splash screen
24.11.2009: Fix some minor issues, add MacOSX support (!)
27.10.2010: Add Pył support, fix grLFBRead/WriteRegion
03.08.2011: Fix polygon rendering
08.06.2012: Fix grTexClampMode (thanks robertmo!)
11.03.2013: Increase LFB mem and support simultaneous locks, fix Unreal GPF

Last edited by gulikoza on 2013-03-11, 15:38. Edited 26 times in total.

http://www.si-gamer.net/gulikoza

Reply 1 of 246, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Nice, thanks 😀

Reply 2 of 246, by qsonic

User metadata
Rank Newbie
Rank
Newbie

Very cool indeed, works perfectly.

Adding to your note about Archimedean Dynasty: the game seems to display graphics fine using Zeckensacks wrapper, although it has windowing issues (at least for me, controlling the game with his wrapper is impossible).

Seems like OpenGlide has a variety of issues as of now... Hope to be able to fix a couple of them.

Reply 3 of 246, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

Thanks, haven't tried it with zeckensack's yet 😉
Try to set the configuration to render in the game window (the default option is to render in it's own window). But it's still somewhat annoying since it will switch resolutions. Somebody has to hexedit the dll and NOP that ChangeDisplaySetting call 😜

http://www.si-gamer.net/gulikoza

Reply 4 of 246, by qsonic

User metadata
Rank Newbie
Rank
Newbie

Oh, I forgot to mention I am compiling with VC8, and for anyone who wants to do that, as well:

1.) Add the files which the patch adds to the source tree to the VC project file, namely:
src\hardware\glide.cpp
include\glide.h
include\glidedef.h

2.) Change these 2 lines in glide.cpp:
Line 393: typedef FxBool FX_CALL (*pfxSplashInit)(FxU32 hWnd, FxU32 screenWidth, FxU32 screenHeight,
To: typedef FxBool (FX_CALL *pfxSplashInit)(FxU32 hWnd, FxU32 screenWidth, FxU32 screenHeight,

Line 395: typedef void FX_CALL (*pfxSplash)(float x, float y, float w, float h, FxU32 frameNumber);
To: typedef void (FX_CALL *pfxSplash)(float x, float y, float w, float h, FxU32 frameNumber);

Reply 5 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

Hi,

I just tried the patch on Linux, but it fails when compiling glide.cpp:

g++ -DHAVE_CONFIG_H -I. -I../.. -I../../include -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -g -O2 -MT glide.o -MD -MP -MF .deps/glide.Tpo -c -o glide.o glide.cpp
../../include/sdk2_glide.h:53: error: expected `)' before ‘*’ token
glide.cpp: In constructor ‘GLIDE::GLIDE(Section*)’:
glide.cpp:204: error: expected primary-expression before ‘void’
glide.cpp:204: error: expected `)' before ‘void’
glide.cpp: At global scope:
glide.cpp:393: error: typedef ‘__stdcall’ is initialized (use __typeof__ instead)
glide.cpp:393: error: ‘pfxSplashInit’ was not declared in this scope
glide.cpp:395: error: typedef ‘__stdcall’ is initialized (use __typeof__ instead)
glide.cpp:395: error: ‘pfxSplash’ was not declared in this scope

and then the make process fails, quitting with an error...

Looking at line 53 of sdk2_glide.h, the "culprit" is this one:

typedef void (FX_CALL *GrProc)();

It probably isn't a matter of g++ 4.1 vs 3.4, because I tried them both with the same result: besides, I successfully installed Openglide CVS using 4.1.

What could be the reason?
Thanks in advance, hope to hear from you soon!

Reply 6 of 246, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

There's one ) missing at glide.cpp:204. The 393 error is probably the same as qsonic reported, will check what's wrong at sdk2_glide.h:53 and fix my patch accordingly 😀

http://www.si-gamer.net/gulikoza

Reply 7 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

I managed to turn around the compilation problems this way:

1) I forced the defines of FX_ENTRY and FX_CALL to
#define FX_ENTRY extern
#define FX_CALL
in sdk2_3dfx.h, because otherwise it kept introducing __stdcall which doesn't exist in Linux;

2) I didn't notice the mixxing bracket at line 204, you're right; however, I just removed the (void*) caster, since dlsym already returns a void*, and it compiled fine.

Unfortunately, dosbox crashes when trying to start it...

CONFIG:Loading primary settings from config file dosbox.conf ALSA:Client initialised [17:0] MIDI:Opened device:alsa Glide:Warnin […]
Show full quote

CONFIG:Loading primary settings from config file dosbox.conf
ALSA:Client initialised [17:0]
MIDI:Opened device:alsa
Glide:Warning, unable to load grSstConfigPipeline from glide2x
Glide:Warning, unable to load grSstVidMode from glide2x
Glide:Warning, unable to load guMPDrawTriangle from glide2x
Glide:Warning, unable to load guMPInit from glide2x
Glide:Warning, unable to load guMPTexCombineFunction from glide2x
Glide:Warning, unable to load guMPTexSource from glide2x
Glide:Warning, unable to load guMovieSetName from glide2x
Glide:Warning, unable to load guMovieStart from glide2x
Glide:Warning, unable to load guMovieStop from glide2x
Segmentation fault

This is the backtrace:

[Thread debugging using libthread_db enabled] [New Thread -1208506640 (LWP 13227)] [New Thread 25160592 (LWP 13230)] CONFIG:Load […]
Show full quote

[Thread debugging using libthread_db enabled]
[New Thread -1208506640 (LWP 13227)]
[New Thread 25160592 (LWP 13230)]
CONFIG:Loading primary settings from config file dosbox.conf
[New Thread 35650448 (LWP 13231)]
ALSA:Client initialised [17:0]
MIDI:Opened device:alsa
Glide:Warning, unable to load grSstConfigPipeline from glide2x
Glide:Warning, unable to load grSstVidMode from glide2x
Glide:Warning, unable to load guMPDrawTriangle from glide2x
Glide:Warning, unable to load guMPInit from glide2x
Glide:Warning, unable to load guMPTexCombineFunction from glide2x
Glide:Warning, unable to load guMPTexSource from glide2x
Glide:Warning, unable to load guMovieSetName from glide2x
Glide:Warning, unable to load guMovieStart from glide2x
Glide:Warning, unable to load guMovieStop from glide2x

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208506640 (LWP 13227)]
0x00ceff5c in malloc_consolidate () from /lib/libc.so.6
(gdb) bt
#0 0x00ceff5c in malloc_consolidate () from /lib/libc.so.6
#1 0x00cf20bd in _int_malloc () from /lib/libc.so.6
#2 0x00cf3ebe in malloc () from /lib/libc.so.6
#3 0x07a42557 in operator new () from /usr/lib/libstdc++.so.6
#4 0x07a1dc0b in std::string::_Rep::_S_create () from /usr/lib/libstdc++.so.6
#5 0x07a1e7a8 in std::string::_Rep::_M_clone () from /usr/lib/libstdc++.so.6
#6 0x07a1f358 in std::string::reserve () from /usr/lib/libstdc++.so.6
#7 0x07a18003 in std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::overflow () from /usr/lib/libstdc++.so.6
#8 0x07a1cdd1 in std::basic_streambuf<char, std::char_traits<char> >::xsputn
() from /usr/lib/libstdc++.so.6
#9 0x07a1217b in std::operator<< <std::char_traits<char> > ()
from /usr/lib/libstdc++.so.6
#10 0x080e8841 in GLIDE_Init (sec=0x9e92158)
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/ostream.tcc:86
#11 0x081c4f5b in Section::ExecuteInit (this=0x9e92158, initall=true)
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_list.h:131
#12 0x081c4f95 in Config::Init (this=0xbfb88070)
at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_list.h:212
#13 0x080fa877 in main (argc=1, argv=0xbfb88134) at sdlmain.cpp:1499

The dosbox.conf I used is exactly the same as the one I used wih the stable dosbox, with the only addons being the [glide] context copied from ykhwong's one.

Any idea what it could be?

Reply 8 of 246, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

Okay...fixed the compilation problems, the patch is updated in the first post.
But this crash is strange...I can't reproduce it, and it crashes somewhere inside malloc??

http://www.si-gamer.net/gulikoza

Reply 9 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

Just tried recompiling with your new patch, and now it compiles fine without having to touch anything. I also added --enable-debug to see if it gave me more info about the crash. However, now it didn't crash at all!
So I made a few tests:

The 3dfx diagnostic kit tests worked fine;

Tomb Raider also did start fine, even if it crashed when leaving the game;

Redguard instead crashed after leaving the game menu, which, as it was in ykhwong's build, was corrupt anyway (the main diary page is invisible, you can see the side of the book on the right).

But it's a great step ahead from the previous issues 😀

Reply 10 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

I recompiled disabling the debug, and dosbox crashes again on startup... it looks like debug mode made it more fault tolerant. 😕

Reply 11 of 246, by `Moe`

User metadata
Rank Oldbie
Rank
Oldbie

Crashes inside malloc usually result from a buffer overrun that has clobbered malloc's data structures. A double free might also apply, but IIRC modern glibcs should detect those.

BTW, is that a 32-bit or a 64-bit build?

Reply 12 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

Hi Moe,
it's a 32-bit build, in a Fedora 7 OS. Let me know if there's anything I can do to help you sort out the problem.

Reply 13 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

Investigating the issues another bit, I found out a line where the problem might be. The backtrace reports:

(gdb) bt
#0 0x00ceff5c in malloc_consolidate () from /lib/libc.so.6
#1 0x00cf20bd in _int_malloc () from /lib/libc.so.6
#2 0x00cf3ebe in malloc () from /lib/libc.so.6
#3 0x07a42557 in operator new () from /usr/lib/libstdc++.so.6
#4 0x07a1dc0b in std::string::_Rep::_S_create () from /usr/lib/libstdc++.so.6
#5 0x07a1e7a8 in std::string::_Rep::_M_clone () from /usr/lib/libstdc++.so.6
#6 0x07a1f358 in std::string::reserve () from /usr/lib/libstdc++.so.6
#7 0x07a18003 in std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::overflow () from /usr/lib/libstdc++.so.6
#8 0x07a1cdd1 in std::basic_streambuf<char, std::char_traits<char> >::xsputn
() from /usr/lib/libstdc++.so.6
#9 0x07a1217b in std::operator<< <std::char_traits<char> > ()
from /usr/lib/libstdc++.so.6
#10 0x080eca53 in GLIDE (this=0xabf5c80, configuration=0xabc2158)
at glide.cpp:217
#11 0x080ec309 in GLIDE_Init (sec=0xabc2158) at glide.cpp:268
#12 0x081d4655 in Section::ExecuteInit (this=0xabc2158, initall=true)
at setup.cpp:271
#13 0x081d4ca8 in Config::Init (this=0xbfd6f25c) at setup.cpp:256
#14 0x080ff887 in main (argc=Cannot access memory at address 0x1
) at sdlmain.cpp:1499

The overflow appears when compiling a string at the line:

	ostringstream temp;
temp << "SET GLIDE=" << hex << setw(3) << glide_base << ends;

I have no idea why such an operation should fail, I guess temp is correctly initialized... however, considering glide_base is statically set up as 0x300, I removed those lines and forced a static

    	autoexecline.Install("SET GLIDE=0x300");

which should do the same.
Doing this, dosbox stops crashing at that point but crashes somewhere else:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208301840 (LWP 14368)]
0x00ceff5c in malloc_consolidate () from /lib/libc.so.6
(gdb) bt
#0 0x00ceff5c in malloc_consolidate () from /lib/libc.so.6
#1 0x00cf20bd in _int_malloc () from /lib/libc.so.6
#2 0x00cf3ebe in malloc () from /lib/libc.so.6
#3 0x07a42557 in operator new () from /usr/lib/libstdc++.so.6
#4 0x080aa2a4 in DOS_SetupFiles () at dos_files.cpp:1091
#5 0x080a7690 in DOS (this=0xa0a0630, configuration=0xa06b278) at dos.cpp:1089
#6 0x080a5149 in DOS_Init (sec=0xa06b278) at dos.cpp:1122
#7 0x081d40e5 in Section::ExecuteInit (this=0xa06b278, initall=true)
at setup.cpp:271
#8 0x081d4738 in Config::Init (this=0xbff72c5c) at setup.cpp:256
#9 0x080ff317 in main (argc=Cannot access memory at address 0x1
) at sdlmain.cpp:1499

These errors are related to setting up the file systems, so I really have no idea how I could mess around with this...

I hope all this helped, hope to hear from you soon.

Reply 14 of 246, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

your stack is allready corrupt before that.
have you tried running it through valgrind ?

Water flows down the stream
How to ask questions the smart way!

Reply 15 of 246, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

The autoexec line is not even needed. And it is created the same way as other autoexec lines (sblaster...)
Something seems very wrong here. If you start with glide disabled (or even without the patch compiled in), does dosbox work??

http://www.si-gamer.net/gulikoza

Reply 16 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

I just did it, you can find the output in the attached file. Running through Valgrind doesn't make dosbox crash (as the dosbox --enable-debug did). However, trying one of the 3dfx tests freezes dosbox.

My guess is the problem starts here:

==14936== Invalid write of size 4
==14936== at 0x80EC8CB: GLIDE::GLIDE(Section*) (glide.cpp:204)
==14936== by 0x80EC308: GLIDE_Init(Section*) (glide.cpp:268)
==14936== by 0x81D4664: Section::ExecuteInit(bool) (setup.cpp:271)
==14936== by 0x81D4CB7: Config::Init() (setup.cpp:256)
==14936== by 0x80FF896: main (sdlmain.cpp:1499)
==14936== Address 0x4D0F384 is 0 bytes after a block of size 516 alloc'd
==14936== at 0x40054E5: malloc (vg_replace_malloc.c:149)
==14936== by 0x80EC88D: GLIDE::GLIDE(Section*) (glide.cpp:192)
==14936== by 0x80EC308: GLIDE_Init(Section*) (glide.cpp:268)
==14936== by 0x81D4664: Section::ExecuteInit(bool) (setup.cpp:271)
==14936== by 0x81D4CB7: Config::Init() (setup.cpp:256)
==14936== by 0x80FF896: main (sdlmain.cpp:1499)
==14936==

but I'm not sure of it...

Reply 17 of 246, by Rainmak3r

User metadata
Rank Newbie
Rank
Newbie

Yes, with glide disabled dosbox works just fine, so it surely is a problem in the glide initialization somewhere...

Reply 18 of 246, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

That malloc might indeed be 1 element too small 😀

try

fn_pt = (void**)malloc(sizeof(void*)*(GLIDE_END-GLIDE_START)+1);

http://www.si-gamer.net/gulikoza

Reply 19 of 246, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

if it 1 element shouldn't it be
fn_pt = (void**)malloc(sizeof(void*)*(GLIDE_END-GLIDE_START+1));

Water flows down the stream
How to ask questions the smart way!