windows-7allegrodirectdrawpalette

Allegro 4.2.4 in palette mode on Windows7 corruption


I have problem with Allegro 4.2.4 running palette mode (256 colors) in Windows 7. I found over Internet solution of killing explorer and it's working indeed, however it would be ridiculous to expect that end user will kill explorer when trying to play game.

Then I found solution to replace DDraw.dll with hacked version, but it doesn't work either - DDHack just results in no screen being shown at all after application launch.

Then I found solution of adding registry hack:

Windows Registry Editor Version 5.00
;This file has been created with DirectDraw Compatibility Tool (http://crappybitter.livejournal.com/tag/ddc_tool)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectDraw\Compatibility\MyApp]
"Name"="MyApp.exe"
"ID"=dword:4E7B8A88
"Flags"=hex:00,08,00,00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DirectDraw\Compatibility\MyApp]
"Name"="MyApp.exe"
"ID"=dword:4E7B8A88
"Flags"=hex:00,08,00,00

But sadly it won't work either, the palette keeps flickering with all rainbow colors.

Do I have any other solution other than porting entire application to different programming lib? Is it possible to fix DDraw problem on Vista/W7 without touching palettes? If not, what library will give me palette programming (I am doing game that requires palettes) without such problems on Vista/W7?

I know of one more solution - I can compile Allegro 4.2.4 application as DOS application and run in DosBox. Sadly, but that's all I can think of now...

Thanks in advance for other solutions!


Solution

  • First off, there's no such version 4.2.4. I assume you mean 4.4.2.

    True palettes are a dying thing. Setting 8-bit color depths just isn't supported very well on modern operating systems. Regarding Allegro 4.4, you could do this:

    set_color_depth(8);
    set_gfx_mode(GFX_GDI, w, h, 0, 0);
    

    It will give you a windowed mode, and the most compatible palette support on Windows that Allegro 4.4 offers. If you really must have full screen mode, you could try this patch:

    It fixes a problem with corrupted palettes while in the game. It may help with the issue you describe.

    Or you could try using 32-bit color depth for the screen, and use an 8-bit bitmaps for sprites and buffers:

    set_color_depth(desktop_color_depth());
    set_gfx_mode(GFX_AUTODETECT, w, h, 0, 0);
    BITMAP *buffer = create_bitmap_ex(8, w, h);
    

    Of course you would have to blit the bitmap to the screen again after changing the palette, so if you need very fast real time effects, it might not work.

    Alternatively, Allegro 5.1 (i.e., unreleased SVN version) has a palette addon that works via shaders. It's probably undocumented and likely to change. (Note that the 5 series is not source compatible with the 4 series.)