Author |
Topic: Creating D3DX8BBC.DLL for BBCBASIC for Windows (Read 2384 times) |
|
JonR
New Member
member is offline


Posts: 24
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #13 on: Sep 20th, 2009, 09:59am » |
|
What is qute bizzare is that the exported functons have names like 'struct D3DXCOLOR * __cdecl D3DXColorAddBBC(struct D3DXCOLOR *,struct D3DXCOLOR const *,struct D3DXCOLOR const *)' instead of simply 'D3DXColorAddBBC' or indeed the preferable (to me) 'D3DXColorAdd'.
There's a quick and dirty guide to creating Win32 DLLs with C+ 2005 that might be worth taking a look through: http://www.kapilik.com/2007/09/17/how-to-create-a-simple-win32-dll-using-visual-c-2005/
I notice that you seem to be having some difficulty using the DLL function import tool. Using the latest verson on my site you can specify the DLL as the input file; there is no need to manually use Nir Sofer's DLL Export Viewer unless you want to only export certain functions.
If you do use the DLL Export Viewer you must save the selected funtions list as a 'Tab delimited text file', failure to do so will cause the DLL Importer to generate garbage code as you discovered.
Of course it seems that you'll have to fix the function names issue before DLL Import tool can produce sensible code.
|
| « Last Edit: Sep 20th, 2009, 10:06am by JonR » |
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #14 on: Sep 20th, 2009, 12:30pm » |
|
I *think* the problem is Visual Studio itself which, I was reading today, will decorate the function names. One of the ways around this, apparently, is to create an "export.def' file to tell the compiler the function names.
On a related note I have now been able to create a new PerlinDLL which includes a new "GeneratePerlinTexture3d" function which will create a 2d texture based on a third (float) z parameter. Now you can scroll through 3 dimensions to create clouds etc. I'll upload to the group. The only thing I haven't figured out is why my dll is 499kb long whereas the original is 70kb. I have only added a few functions, so I don't know what my problem is. I must be adding something somewhere.
On another aside, looking at the ASM output the code seems *very* inefficient (ahem! :-X), although very 'safe' with lots of stack maniputlations which a dedicated embedded BB4W ASM routine probably wouldn't need. It is interesting to see the way the compiler will translate
Code:
c = (r << 16) || (g <<8) || b
and compare to: Code:
c = (r << 16) + (g <<8) + b
where r g abd b are ints the first being seemingly indeciferable and the second using the expected add eax,[ebp+x]. I haven't got the output handy as I did this earlier on today.
Michael
|
|
Logged
|
|
|
|
knudvaneeden
Developer
member is offline


Posts: 32
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #15 on: Sep 20th, 2009, 12:34pm » |
|
on Sep 20th, 2009, 09:59am, JonR wrote:Of course it seems that you'll have to fix the function names issue before DLL Import tool can produce sensible code. |
|
I first tried the newest DLL importer, that correctly exported no functions names at all (because the name is thus still in C++ format). Then I tried an older version, which worked somehow, but truncated the result. But it fortunately allowed me also to suddenly see that it still was in C++ format (instead of the usual format)).
Also tried Borland impdef.exe, and Microsoft Visual Studio dumpbin.exe, but never saw the wanted output format of the function names appearing, though it shows still all that it just exports the function names at least (though in the 'strange' format thus).
I tried all kind of things (e.g. adding 'WINAPI', adding of removing 'EXPORT' versus '__declspec(dllexport)', ... But maybe some setting later in the files overwrites somehow the initial settings, I might have to single step debug through it some time.
As a next step, I will now go carefully go through the steps in e.g. that URL tutorial and see what that gives.
Thanks,
with friendly greetings, Knud van Eeden
|
|
Logged
|
|
|
|
knudvaneeden
Developer
member is offline


Posts: 32
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #16 on: Sep 20th, 2009, 12:52pm » |
|
on Sep 20th, 2009, 12:30pm, Michael Hutton wrote:I *think* the problem is Visual Studio itself which, I was reading today, will decorate the function names. One of the ways around this, apparently, is to create an "export.def' file to tell the compiler the function names. |
|
Yes, I will also try that further, did already some trials creating .def file earlier.
http://msdn.microsoft.com/en-us/library/d91k01sh(VS.80).aspx
The problem at this moment is to find out how to tell Visual Studio 2005 in the GUI settings where to find this .def file, and the format to use.
I tried earlier to put the .def file (with the same name as the project, and extension thus .def) in the same directory as the .h files to include, compiled, then checked the function names (after e.g. exchanging @6 and @8 (which should be the order numbers of that function in the DLL, that is the sixth and the eighth)). That exchanging seemed to work at the first quick glance, at least exchanging the order. But the function names were still in that C++ like format.
I will check further (also) along this path.
Thanks,
with friendly greetings, Knud van Eeden
|
|
Logged
|
|
|
|
JonR
New Member
member is offline


Posts: 24
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #17 on: Sep 20th, 2009, 12:55pm » |
|
Is your compilable source code available? Preferably the whole project.
|
|
Logged
|
|
|
|
knudvaneeden
Developer
member is offline


Posts: 32
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #19 on: Sep 20th, 2009, 3:08pm » |
|
on Sep 20th, 2009, 12:30pm, Michael Hutton wrote:On a related note I have now been able to create a new PerlinDLL which includes a new "GeneratePerlinTexture3d" function which will create a 2d texture based on a third (float) z parameter. Now you can scroll through 3 dimensions to create clouds etc. |
|
Maybe create a Wiki about how you created the DLLs (generalizing, ..., simple steps 1, 2, 3, ...), so that that information is conserved and reusable for other projects? That would be great. Otherwise show it here maybe? (e.g. in a separate thread).
Thanks,
with friendly greetings, Knud van Eeden
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #21 on: Sep 20th, 2009, 11:51pm » |
|
Knud,
I must admit I don't really feel qualified yet. I expanded in the PerlinDLL by loading in the solution file to VC++E and then typing in a new function and adding a few lines of code which "look right". I built it and it worked, albeit resulting in a file about 7x larger! I do not think that I should be writing any "how to" guides yet!!
I will have a deeper look at the DirectDXD3 dll now I *think* I understand a little bit more about what is going on, but please don't expect anything from this end very soon.
Michael
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #22 on: Sep 21st, 2009, 11:42am » |
|
Quote:| looking at the ASM output the code seems *very* inefficient |
|
The key word there is "seems"; have you actually compared the timings? I don't know about Visual C, but gcc, with the maximum level of optimisation, can sometimes generate code which outperforms 'naive' hand-written assembler, the reason being that it understands the CPU's internal architecture better.
Don't be too quick to judge the code the compiler generates on the basis of what it looks like to you!
Quote:| It is interesting to see the way the compiler will translate c = (r << 16) || (g <<8) || b and compare to c = (r << 16) + (g <<8) + b |
|
But this is a meaningless comparison. The first is using Boolean logic and the second is using arithmetic.
Surely, to make any kind of sensible comparison the first should be:
Code:c = (r << 16) | (g <<8) | b that is, single | (bitwise OR) rather then double || (Boolean OR) operators. With that change I would be surprised if the code was radically different from the addition example.
If you're at a stage of learning C that you still confuse | and || you've got a very long way to go!
Richard.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #23 on: Nov 30th, 2009, 08:25am » |
|
If you want something doing, do it yourself! I installed Visual Studio 2008 Express on my Vista machine and, despite never having used it before, within a few hours I'd successfully built a complete D3DX8BBC.DLL. I was surprised how easy it was, especially considering some of the earlier comments made in this thread. I had no problems with 'name decoration', and did not need to create a .def file.
One thing I made a particular point of doing was to keep the source file as d3dx8bbc.c rather than renaming it as .cpp so whether that helped I don't know.
I've uploaded the hopefully functional, but largely untested, version of D3DX8BBC.DLL here:
http://groups.yahoo.com/group/bb4w/files/Libraries/D3DX8BBC.dll
This exports 199 functions in total, including those implemented in C++ (which were the ones I couldn't incorporate using GCC). It should be functionally equivalent to Microsoft's D3DX8D.DLL but is slightly smaller (not being a Debug version) and - most importantly - should be entirely legitimate to distribute.
It has had virtually no testing, so I would welcome reports of any problems such as missing functions or incorrect behaviour.
Richard.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #25 on: Dec 4th, 2009, 5:21pm » |
|
D3DX8BBC.DLL has a dependency on the C run-time library MSVCR90.DLL. Unfortunately, unlike MSVCRT.DLL (which is present on every Windows system from Win98 onwards), some PCs appear not to have MSVCR90.DLL installed.
Therefore I've uploaded a new version of D3DX8BBC.DLL without the dependency (although it increases the file size somewhat):
http://groups.yahoo.com/group/bb4w/files/Libraries/D3DX8BBC.dll
I've also updated the Tumbling Teapot executable to use this new version:
http://groups.yahoo.com/group/bb4w/files/Graphics/tumblingteapot.exe
Richard.
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #26 on: Jan 13th, 2010, 11:52am » |
|
Quote:| It has had virtually no testing, so I would welcome reports of any problems such as missing functions or incorrect behaviour. |
|
I couldn't seem to find the D3DXCreateText function in the dll. Is this only with the DirectX9 version ? (I am currently downloading the "old" DirectX8 SDK to check).
Michael
|
|
Logged
|
|
|
|
Michael Hutton
Developer
member is offline


Gender: 
Posts: 248
|
 |
Re: Creating D3DX8BBC.DLL for BBCBASIC for Windows
« Reply #27 on: Jan 13th, 2010, 12:22pm » |
|
Doh. They are there as
D3DXCreateTextA - ANSI version
and D3DXCreateTextW - UNICODE version
Should have thought of that before..
Michael
|
|
Logged
|
|
|
|
|