<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro Legacy Project</title>
		<link>http://www.allegro.cc/forums/view/617115</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 14 Nov 2017 16:09:25 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A few months ago I brought up an idea in <a href="https://www.allegro.cc/forums/thread/616977">this thread</a> to create a drop-in replacement library for Allegro 4 that utilizes Allegro 5 for accessing the underlying system instead of having platform-specific drivers to access the hardware for each platform. <a href="https://github.com/NewCreature/Allegro-Legacy">Allegro Legacy</a> does just that.</p><p>With Allegro Legacy you get a complete implementation of Allegro 4 (minus MIDI support and audio recording for now) and a few helper functions to get images onto the screen. These functions are:</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span> allegro_get_a5_bitmap<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP"><span class="a">BITMAP</span></a> <span class="k3">*</span> bp<span class="k2">)</span><span class="k2">;</span>
<span class="k1">void</span> allegro_render_a5_bitmap<span class="k2">(</span><a href="http://www.allegro.cc/manual/BITMAP"><span class="a">BITMAP</span></a> <span class="k3">*</span> bp, <a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span> a5bp<span class="k2">)</span><span class="k2">;</span>
<span class="k1">void</span> allegro_render_screen<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

To get your program up and running with Allegro Legacy, you simply call <span class="source-code">allegro_render_screen<span class="k2">(</span><span class="k2">)</span></span> immediately after you are done drawing to <span class="source-code"><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a></span> and it will copy the contents of <span class="source-code"><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a></span> onto the Allegro 5 display it created when you called <span class="source-code"><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span><span class="k2">)</span></span>. You can even support vanilla Allegro 4 and Allegro Legacy in the same program by utilizing <span class="source-code"><span class="p">#ifdef ALLEGRO_LEGACY</span></span>.</p><p>Once you have your program up and running, you might want to replace that old CPU hogging timing loop with a nicer Allegro 5 timing loop. You can do this easily with Allegro Legacy since it gives you access to Allegro 4 and Allegro 5 functionality simultaneously.</p><p>This project should be considered early development. I am looking into getting MIDI support added, possibly with FluidSynth and/or PortMidi. I also should be able to get sound recording implemented easily. The <span class="source-code">allegro_render_screen<span class="k2">(</span><span class="k2">)</span></span> function could probably be optimized quite a bit as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sun, 29 Oct 2017 12:00:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Great, i wanted to do something similar, but I couldn&#39;t take the time to do so yet. So , I will follow your approach, since it seems to work better than my idea. </p><p>For midi support, i still think it would probably best to write an allegro5 midi add on and then wrap that for this project.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (beoran)</author>
		<pubDate>Sun, 29 Oct 2017 12:22:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Great work!!!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Mon, 30 Oct 2017 20:40:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Looking forward to this.  For the A4 application I work on, it&#39;s possible that it can no longer render at all in the latest Mac OS X update (High Sierra).  I haven&#39;t heard from any other Mac users to confirm this.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (raynebc)</author>
		<pubDate>Tue, 31 Oct 2017 00:36:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/617115/1033236#target">beoran</a> said:</div><div class="quote"><p>For midi support, i still think it would probably best to write an allegro5 midi add on and then wrap that for this project.</p></div></div><p>
I&#39;ve been considering doing this as well. I need MIDI support for <a href="http://www.t3-i.com/pages/project.php?id=omo">one of my other projects</a>, and I already put together a Windows MIDI driver from Allegro 4 code. If I was going to make an Allegro 5 add-on, I would probably just rip all the drivers out of Allegro 4 and use that as the basis of it. The biggest problem there would be to make an Android driver. It looks like <a href="https://developer.android.com/reference/android/media/midi/MidiManager.html">there&#39;s a nice API available</a> on the platform.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/617115/1033250#target">raynebc</a> said:</div><div class="quote"><p>For the A4 application I work on, it&#39;s possible that it can no longer render at all in the latest Mac OS X update (High Sierra).</p></div></div><p>
That was the program I used to test Allegro Legacy and get everything working, since it uses just about everything Allegro has (I had to make a couple of modifications since MIDI support isn&#39;t implemented yet). The good news is I was able to compile Allegro Legacy with the MacOS 10.12 SDK and the program ran fine. It&#39;s a bit slow, though. One of the main things I want to do is optimize the process of converting the screen bitmap to an Allegro 5 bitmap to get it onto the screen.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Tue, 31 Oct 2017 05:40:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>iirc allegro 4 has it&#39;s own midi renderer so, i think porting the allegro 4 midi code  to allegro 5 is a great idea. And if the OS supports it directly, that&#39;s even better...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (beoran)</author>
		<pubDate>Tue, 31 Oct 2017 09:46:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for this nice legacy library.</p><p>I tried to use it but failed. I want to replace allegro 4.4.2 with allegro 5.2.3 and your legacy lib. </p><p>I blit to screen with allegro 4.4.2 like this</p><div class="source-code snippet"><div class="inner"><pre>    <a href="http://www.allegro.cc/manual/scare_mouse"><span class="a">scare_mouse</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
    <a href="http://www.allegro.cc/manual/acquire_screen"><span class="a">acquire_screen</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
    <a href="http://www.allegro.cc/manual/blit"><span class="a">blit</span></a><span class="k2">(</span>ScreenBuf,<a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span>,SCREEN_WIDTH,SCREEN_HEIGHT<span class="k2">)</span><span class="k2">;</span>
    <a href="http://www.allegro.cc/manual/release_screen"><span class="a">release_screen</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
    <a href="http://www.allegro.cc/manual/unscare_mouse"><span class="a">unscare_mouse</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

If I use your lib and allegro5 and just add allegro_render_screen() after blit() it crashes in acquire_screen() </p><p>acquire_screen () at /usr/local/include/allegro/inline/gfx.inl:221<br />221     AL_LEGACY_INLINE(void, acquire_screen, (void),</p><p>If I remove acquire_screen() and release_screen() it crashes in BLIT</p><p>0x00007ffff7609f32 in blit (src=0x93d350, dest=0x0, s_x=0, s_y=0, d_x=0, d_y=0, w=800, h=600) at /home/hbs/src/Allegro-Legacy/src/blit.c:706<br />706        BLIT_CLIP();<br /> <br />Obviously I&#39;m missing something ? At what point do I have to use</p><p>ALLEGRO_BITMAP * allegro_get_a5_bitmap(BITMAP * bp);<br />void allegro_render_a5_bitmap(BITMAP * bp, ALLEGRO_BITMAP * a5bp); ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Larkin)</author>
		<pubDate>Fri, 03 Nov 2017 17:55:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for testing!</p><p>Your program is crashing because <span class="source-code"><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a> <span class="k3">=</span><span class="k3">=</span> NULL</span>. If you have called <span class="source-code"><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span><span class="k2">)</span></span> prior to calling <span class="source-code"><a href="http://www.allegro.cc/manual/acquire_screen"><span class="a">acquire_screen</span></a><span class="k2">(</span><span class="k2">)</span></span> and/or <span class="source-code"><a href="http://www.allegro.cc/manual/blit"><span class="a">blit</span></a><span class="k2">(</span><span class="k2">)</span></span> and checked the return value to ensure the graphics mode has been successfully set, there is probably a bug with the creation of the <span class="source-code"><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a></span> bitmap in Allegro Legacy.</p><p>If you could post your init code here, it would be helpful in tracking down the cause of the issue.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sat, 04 Nov 2017 05:41:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When I replace your legacy lib it is immediatly running with allegro 4.4.2.</p><p>screen is != NULL and set_gfx_mode() returns 0.</p><p>I&#39;m using it on a 24 bit depth linux computer.</p><p>What part of the init code are you interested ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Larkin)</author>
		<pubDate>Mon, 06 Nov 2017 14:51:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/617115/1033344#target">Larkin</a> said:</div><div class="quote"><p>screen is != NULL and set_gfx_mode() returns 0.</p></div></div><p>
Is that with Allegro 4.4.2 or Allegro Legacy?</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/617115/1033319#target">Larkin</a> said:</div><div class="quote"><p><tt>0x00007ffff7609f32 in blit (src=0x93d350, <b>dest=0x0</b>, s_x=0, s_y=0, d_x=0, d_y=0, w=800, h=600) at /home/hbs/src/Allegro-Legacy/src/blit.c:706
706 BLIT_CLIP();</tt></p></div></div><p>
This error message shows that <span class="source-code"><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a></span> was <span class="source-code">NULL</span> (<span class="source-code"><span class="n">0x0</span> <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span> <span class="k3">=</span><span class="k3">=</span> NULL</span>) when it crashed on the <span class="source-code"><a href="http://www.allegro.cc/manual/blit"><span class="a">blit</span></a><span class="k2">(</span><span class="k2">)</span></span> call. <span class="source-code"><a href="http://www.allegro.cc/manual/acquire_screen"><span class="a">acquire_screen</span></a><span class="k2">(</span><span class="k2">)</span></span> will also crash if <span class="source-code"><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a> <span class="k3">=</span><span class="k3">=</span> NULL</span>. That&#39;s why I suspect <span class="source-code"><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span><span class="k2">)</span></span> is failing.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/617115/1033344#target">Larkin</a> said:</div><div class="quote"><p>What part of the init code are you interested ? </p></div></div><p>
I would like to see your <span class="source-code"><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span><span class="k2">)</span></span> call if you don&#39;t mind. If <span class="source-code"><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span><span class="k2">)</span></span> is succeeding and <span class="source-code"><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a> <span class="k3">=</span><span class="k3">=</span> NULL</span>, I am missing something in my Allegro 5 graphics driver code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Tue, 07 Nov 2017 05:11:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I fixed my logging so here is what really happens :</p><p><span class="source-code">ret <span class="k3">=</span> <a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span>GFX_AUTODETECT_WINDOWED,<span class="n">800</span>,<span class="n">600</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span></span></p><p>ret is -1 and allegro_error is &quot;Unable to find a suitable graphics driver&quot;.</p><p>Requested depth is 24bit on a 24bit linux desktop.</p><p>Btw while the programm is properly exiting on error with allegro4, with allegro legacy there is still a thread running. Something special I have to clear on exit which is different to allegro4 behavior ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Larkin)</author>
		<pubDate>Tue, 07 Nov 2017 18:50:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright, I&#39;ll see if I can replicate the issue here and fix it. The hanging thread is also a bug.</p><p>Append: <span class="source-code"><a href="http://www.allegro.cc/manual/set_gfx_mode"><span class="a">set_gfx_mode</span></a><span class="k2">(</span><span class="k2">)</span></span> was failing because the display driver wasn&#39;t flagged as a windowed driver. Since you are using <span class="source-code">GFX_AUTODETECT_WINDOWED</span>, a suitable graphics driver could not be found. I have just committed a fix for this issue.</p><p>Append 2: The thread hanging issue is now also fixed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Wed, 08 Nov 2017 05:06:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, progress was made.</p><p>Now I get a 800x600 black window and</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Thread 1 &quot;battle2&quot; received signal SIGSEGV, Segmentation fault.<br />0x00007ffff767bdbd in allegro_render_a5_bitmap (bp=0x909b50, a5bp=0x100b8d0) at /home/hbs/src/Allegro-Legacy/src/a5/a5_display.c:171<br />171                         al_put_pixel(j, i, a5_get_color(depth == 8 ? palette : NULL, depth, ((long *)bp-&gt;line[i])[j]));
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Larkin)</author>
		<pubDate>Wed, 08 Nov 2017 16:32:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright, I ran my test program using every color depth and found that for color depths &gt; 16-bit, the image was being distorted. According to Allegro&#39;s documentation, you are supposed to be able to get the raw bitmap data by accessing the <span class="source-code"><a href="http://www.allegro.cc/manual/line"><span class="a">line</span></a></span> pointers and casting to <span class="source-code"><span class="k1">short</span></span> or <span class="source-code"><span class="k1">long</span></span> for 15-, 16-, and 32-bit. This is probably wrong for 64-bit systems. By changing these to <span class="source-code"><span class="k1">uint16_t</span></span> and <span class="source-code"><span class="k1">uint32_t</span></span> I was able to fix the distortion (and prevent reading past the end of the allocated memory).</p><p>I also noticed that I had mistakenly used the 32-bit code for 24-bit bitmaps (I assumed wrongly that the data was stored the same for both formats). I added a separate implementation for working with 24-bit mode.</p><p>After all of these changes, everything seems to be working for every color depth. These changes have just been committed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Fri, 10 Nov 2017 07:36:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Nice work Todd, and thanks Larkin for the testing. :-)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Fri, 10 Nov 2017 14:01:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks, it is basically working now. </p><p>I noticed though that wav soundplay has a noticable (100+ msec) delay with your legacy lib.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Larkin)</author>
		<pubDate>Fri, 10 Nov 2017 14:36:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I was using a fragment count of 4 with a sample count of 1024 in the <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_AUDIO_STREAM"><span class="a">ALLEGRO_AUDIO_STREAM</span></a></span> that&#39;s used by the audio driver. I reduced the fragment count to 2, which might help some. This amounts to ~46ms of delay (was ~93ms with 4 fragments).</p><p>There might be extra latency due to differences in the way the Allegro 4 and Allegro 5 audio drivers work. The audio driver will certainly add some extra latency with its own buffers which it needs to ensure smooth audio playback. Maybe Allegro 5&#39;s Linux audio driver has a larger buffer that increases latency. I had this issue in the past with Linux ports of some of my games. Maybe it&#39;s still an issue.</p><p>When running my test program on Mac, there isn&#39;t really an abnormal amount of delay. I have Ubuntu 16 installed on a few computers so I&#39;ll test it there soon.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Sat, 11 Nov 2017 19:17:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmmm. Some things that did work no longer do. I have no longer wav sound/music streaming, and the mouse pointer image is gone. Sound delay is still there and very obvious.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Larkin)</author>
		<pubDate>Mon, 13 Nov 2017 14:53:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I haven&#39;t been able to reproduce any of those issues yet. I&#39;ll try on Linux soon. </p><p>How are you drawing the mouse pointer? Are you just doing <span class="source-code"><a href="http://www.allegro.cc/manual/show_mouse"><span class="a">show_mouse</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen"><span class="a">screen</span></a><span class="k2">)</span><span class="k2">;</span></span>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Todd Cope)</author>
		<pubDate>Tue, 14 Nov 2017 04:40:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, doing just show_mouse(screen);
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Larkin)</author>
		<pubDate>Tue, 14 Nov 2017 16:09:25 +0000</pubDate>
	</item>
</rss>
