<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>patches for DMC support</title>
		<link>http://www.allegro.cc/forums/view/591863</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 20 Jun 2007 07:58:41 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Attached are some patches and files to add support for DMC. Tested against 4.2, but should work on 4.9 as well (with maybe a change or two to the makefile).</p><p><b>New Files</b>:
</p><ul><li><p>/include/allegro/platform/aldmc.h</p></li><li><p>/makefile.dmc</p></li></ul><p>

<b>Updated Files</b>:
</p><ul><li><p>/include/allegro/internal/alconfig.h</p></li><li><p>/misc/fixver.sh</p></li><li><p>/misc/fixdll.bat</p></li><li><p>/misc/fixdll.sh</p></li><li><p>/src/win/wsystem.c</p></li><li><p>/tools/datedit.c</p></li><li><p>/fix.bat</p></li></ul><p>

It basically works, but there are a few known problems that I haven&#39;t looked into yet. (For example, the demo.exe freezes while displaying the &quot;Scanning&quot; message.)</p><p>So for some notes...</p><p>Obviously it requires the base DMC compiler, and maybe an add-on package for rcc.exe or lib.exe, I don&#39;t remember. As with MinGW, it requires a mini dx7 package. I put one together; I&#39;ll post it later. And it also requires mingw32-make.</p><p>It&#39;s a C-only build. The makefile won&#39;t let you do anything else. I don&#39;t even know if assembler would be possible as-is. It doesn&#39;t really matter. The C and ASM DLL&#39;s are compatible for all practical purposes.</p><p>I had to add a few missing structs and miscellaneous stuff to the aldmc.h. It&#39;s possible that future versions of DMC will define some of it. But we can worry about that if it ever happens.</p><p>DMC requires extra header information in the allegro.def file. I added it to the fixdll scripts (untested). DMC does not support { and } in resource files. I renamed them to BEGIN and END in fixver.sh (untested). It&#39;s possible that those changes break MinGW32 or MSVC, but I doubt it.</p><p>DMC requires a DllMain() function, or else the DLL hangs. I added it unconditionally to /src/win/wsystem.c for all compilers. </p><p>The makefile is pretty much straightforward. The most annoying thing is that link.exe cannot accept forward slashes in the file names. As much as possible, I tried to limit the $(subst) by just using backslashes in the variable names. (This means if someone wants to add support for UNIXy environments, they&#39;ll have to hack around the slashes a lot.)</p><p>I had to do this:
</p><pre>
OBJECT_LIST := $(subst dllver,,$(OBJECT_LIST))   
OBJECT_LIST := $(subst asmlock,,$(OBJECT_LIST))
</pre><p>

asmlock.s is in the main Windows source object list. (Should it be?) I just manually cleared it from the list, since it&#39;s a C-only build. Also, DM&#39;s rcc.exe does not compile .rc files to .obj, so I had to remove dllver.obj out of the list. The resource file is linked in at the end instead.</p><p>I don&#39;t think plugins.h gets created ever. Doing a <tt>mingw32-make obj\dmc\plugins.h</tt> by hand fixes it.</p><p>Some of the compiler switches for the various modes (debug, profile, etc) could probably be improved upon. I didn&#39;t really read through what options dmc offered.</p><p>There&#39;s probably other things that I should mention, but that&#39;s all I can think of for now.</p><p>Edit: Here&#39;s <a href="http://www.allegro.cc/files/dx70_dmc.zip">dx70_dmc.zip</a>.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 13 Jun 2007 03:46:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I had to copy asmcapa.h over from obj/mingw32, and create the lib/dmc dir.  I also copied over plugins.h, which didn&#39;t seem to make a difference for building the library.</p><p>I ran &#39;gmake ALLEGRO_USE_C=1 STATICLINK=1&#39;, and got this:</p><pre>
dmc   -L/SUBSYSTEM:WINDOWS -otests\win\dibgrab.exe obj\dmc\alleg_s\win\dibgrab.o
bj lib\dmc\alleg_s.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib
dinput.lib ddraw.lib winmm.lib dsound.lib dxguid.lib
link obj\dmc\alleg_s\win\dibgrab,tests\win\dibgrab.exe,,lib\dmc\alleg_s+kernel32
+user32+gdi32+comdlg32+ole32+dinput+ddraw+winmm+dsound+dxguid+user32+kernel32/no
i/SUBSYSTEM:WINDOWS;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

lib\dmc\alleg_s.lib(wgdi)
 Error 42: Symbol Undefined _gfx_gdi_unwrite_bank
lib\dmc\alleg_s.lib(wgdi)
 Error 42: Symbol Undefined _gfx_gdi_write_bank
lib\dmc\alleg_s.lib(wddwin)
 Error 42: Symbol Undefined _gfx_directx_write_bank_win
lib\dmc\alleg_s.lib(wddwin)
 Error 42: Symbol Undefined _gfx_directx_unwrite_bank_win
lib\dmc\alleg_s.lib(wddwin)
 Error 42: Symbol Undefined _gfx_directx_unlock_win
lib\dmc\alleg_s.lib(wddwin)
 Error 42: Symbol Undefined _gfx_directx_write_bank
lib\dmc\alleg_s.lib(wddwin)
 Error 42: Symbol Undefined _gfx_directx_unwrite_bank

--- errorlevel 7
gmake: *** [tests/win/dibgrab.exe] Error 7
</pre><p>


So the librrary was built, but some symbols are missing.  I haven&#39;t really looked into it yet.  I&#39;m using vanilla Allegro 4.2.1.</p><p>In case you haven&#39;t discovered it yet, the cl.exe tool that comes with translates msvc command lines into dmc ones.  If you run it without any input files, it&#39;ll just print the msvc options.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Thu, 14 Jun 2007 10:50:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
So the librrary was built, but some symbols are missing. I haven&#39;t really looked into it yet. I&#39;m using vanilla Allegro 4.2.1.
</p></div></div><p>
It requires the latest SVN to work, since that contains the patches needed to build the C-only library.</p><p>As a side note, I&#39;m pretty sure the I/O stuff doesn&#39;t work, as the grabber hangs when selecting a file and the demo hangs when reading the credits.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Thu, 14 Jun 2007 11:03:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, I got it working now.  I tried the exhello example, but it looks weird.  No text, only a small black square on a white background.</p><p>But thanks anyway, linking DAllegro statically with alleg_s.lib works now. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>=====================================================<br />EDIT:<br />=====================================================<br />I built just the Allegro library with gcc, msvc6 and dmc, and timed it.</p><p>Command: &#39;gmake lib STATICLINK=1 ALLEGRO_USE_C=1&#39;</p><p>GCC: 107 seconds<br />msvc6: 55 seconds<br />DMC: 42 seconds</p><p>btw, the free DMC version is unable to link dynamically with the C std library (msvcrt.dll), because SND.lib is not included in the free download.  Kind of silly.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Sat, 16 Jun 2007 06:02:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
btw, the free DMC version is unable to link dynamically with the C std library (msvcrt.dll), because SND.lib is not included in the free download. Kind of silly.
</p></div></div><p>
What limitations does this create? (And what&#39;s snn.lib?)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Tue, 19 Jun 2007 01:44:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The only limitation I can think of is that the executables become larger.</p><p>snn.lib is the standard C library implementation that both dmc an dmd uses.  It&#39;s for static linking.  snd.lib is the import library that dmc needs for linking dynamically with the C library DLL (which isn&#39;t free either).</p><p>I wasn&#39;t sure this would work, but by using the implib tool available <a href="ftp://ftp.digitalmars.com/bup.zip">here</a>, you can create an msvcrt.lib file that both dmc an dmd will accept.  Which will enable you to link dynamically with msvcrt.dll (the msvc C std library implementation).</p><p>The implib command line:<br />implib /s msvcrt.lib %windir%\system32\msvcrt.dll</p><p>And put the resulting msvcrt.lib in your dm\lib dir.  implib also accepts a .def file instead of a .dll.</p><p>I don&#39;t know whether doing this is likely to cause trouble, but my &#39;hello world&#39; test app works fine.  It&#39;s only that Walter Bright (dmc and dmd creator) seems to think that using msvcrt.dll for DMC or DMD won&#39;t work.  So it could easily be a dead end.  No big deal, though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Tue, 19 Jun 2007 04:23:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Okay, I&#39;m not going to worry about mentioning the difference between the two in the Allegro docs. I did write up a <a href="http://wiki.allegro.cc/Build/DMC">simple document</a> for building Allegro with DMC. (Some links may not be working yet.) It will serve as the basis for the ._tx documentation for inclusion with Allegro.</p><p>By the way, have you tried demo.exe built by DMC? For me it freezes when loading credits.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Tue, 19 Jun 2007 06:02:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The demo works for me.  But the gfx mode selection gui doesn&#39;t have any text readable text in it.  And part of my desktop shows through the title screen.</p><p>EDIT:<br />It seems to just skip loading the credits.  It doesn&#39;t show the file names as they are scanned, and it just displays the title screen without the credits.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Tue, 19 Jun 2007 20:53:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does al_findfirst work for you with the DMC build? For me it doesn&#39;t. </p><p>However, if I clear the os_type, it works. (<tt>os_type = OSTYPE_UNKNOWN;</tt>) This makes Allegro call _findfirst instead of _wfindfirst. Maybe this goes back to DMC not supporting _wfinddata_t?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 20 Jun 2007 01:54:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I get the same results you do.  Without setting os_type, al_findirst returns nonzero, but the file name is just an empty string.  al_findnext then returns -1.  errno is zero.</p><p>With os_type = OSTYPE_UNKNOWN it works just fine.</p><p>My test program:<br /><a href="http://pastebin.co.uk/17433">http://pastebin.co.uk/17433</a></p><p>It&#39;s starting to look like a character encoding issue to me. That might explain the garbled text I get in the menus too.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Wed, 20 Jun 2007 04:16:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>personally I don&#39;t get it. Why would DMC have anything to do with a runtime error? Its using the system&#39;s libc. The only way its DMCs fault here is if its compiling wrong.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 20 Jun 2007 04:33:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It works fine if you link dynamically with an allegro DLL built with msvc.  It&#39;s dmc&#39;s own static lib build that doesn&#39;t work (which uses dmc&#39;s own C lib, not msvcrt.dll).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Wed, 20 Jun 2007 04:41:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah. I had thought the last attempt was with the standard windows libc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 20 Jun 2007 05:01:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
But the gfx mode selection gui doesn&#39;t have any text readable text in it.
</p></div></div><p>
I don&#39;t have any problem with that. Could you try taking a screenshot?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I get the same results you do. Without setting os_type, al_findirst returns nonzero, but the file name is just an empty string. al_findnext then returns -1. errno is zero.
</p></div></div><p>
That&#39;s basically what happens here. Although depending on the pattern, it behaves slightly differently. (Never properly.) To work around this for now, I can easily just change the find* routines to look for (OLD_WINDOWS || DMC).</p><p>For testing purposes, I changed title.c in demo to:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/os_type" target="_blank"><span class="a">os_type</span></a> <span class="k3">=</span> OSTYPE_WIN98<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/for_each_file_ex" target="_blank"><span class="a">for_each_file_ex</span></a><span class="k2">(</span>buf2, <span class="n">0</span>, ~<span class="k2">(</span>FA_ARCH <span class="k3">|</span> FA_RDONLY <span class="k3">|</span> FA_DIREC<span class="k2">)</span>,
                    parse_source,
                    <span class="k2">(</span><span class="k1">void</span> <span class="k3">*</span><span class="k2">)</span><span class="k2">(</span><span class="k1">unsigned</span> <span class="k1">long</span><span class="k2">)</span><span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_764.html" target="_blank">strlen</a><span class="k2">(</span>buf2<span class="k2">)</span> <span class="k3">-</span> <span class="n">3</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/os_type" target="_blank"><span class="a">os_type</span></a> <span class="k3">=</span> OSTYPE_WINVISTA<span class="k2">;</span>
</pre></div></div><p>
All the file stuff worked then.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Leverton)</author>
		<pubDate>Wed, 20 Jun 2007 05:04:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Attached screenshot of demo gui.  The screenshot is messed up, the only thing that didn&#39;t look right in reality was the menu text.  The text looked exactly like in the screenshot.</p><p>EDIT: added a better screenshot, this time of ex3d.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Wed, 20 Jun 2007 05:12:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Looks like its drawing all the letters one on top of the other. As if the letters are all 0 px wide.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 20 Jun 2007 07:58:41 +0000</pubDate>
	</item>
</rss>
