“独家" DirectDraw调色板实际上不是排他性的 [英] "Exclusive" DirectDraw palette isn't actually exclusive

查看:139
本文介绍了“独家" DirectDraw调色板实际上不是排他性的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在维护一个旧的视频游戏,该游戏通过DirectDraw使用全屏256色图形模式.问题是,某些在后台运行的应用程序有时会在游戏运行时尝试更改系统调色板,从而导致图形损坏.

We're maintaining an old video game that uses a full-screen 256-color graphics mode with DirectDraw. The problem is, some applications running in the background sometimes try to change the system palette while the game is running, which results in corrupted graphics.

我们可以(有时)通过处理WM_PALETTECHANGED消息来检测何时发生这种情况.几个更新版本之前,我们添加了日志记录(只需记录窗口标题/类/进程名称),可以帮助用户识别有问题的应用程序并关闭它们. MSN Live Messenger是常见的罪魁祸首.

We can (sometimes) detect when this happens by processing the WM_PALETTECHANGED message. A few update versions ago we added logging (just log the window title/class/process name), which helped users identify offending applications and close them. MSN Live Messenger was a common culprit.

当我们发现Windows Vista(和7)独立"完成时,问题变得更加严重. WM_PALETTECHANGED参数指向CSRSS和桌面窗口.在Vista中,一种常用的解决方法是打开任何文件夹(计算机,文档等),并在运行游戏时将其保持打开状态.听起来很荒谬,但是在大多数情况下还是有效的.在Windows 7中,甚至没有这种解决方法起作用.用户发现停止某些服务(Windows Update和索引服务)也可以解决某些配置问题.

The problem got worse when we found out that Windows Vista (and 7) does it "by itself". The WM_PALETTECHANGED parameters point towards CSRSS and the desktop window. In Vista, a workaround that often worked was to open any folder (Computer, Documents, etc.) and leave it open while running the game. Sounds ridiculous, but it worked - in most cases. In Windows 7, not even this workaround worked any more. Users found that stopping some services (Windows Update and the indexing service) also resolved the problem on some configurations.

前一段时间,我刚刚开始尝试随机事物,以期找到解决方案.我发现,在设置DirectDraw调色板(使用IDirectDrawPalette :: SetEntries)之前,先设置GDI调色板(使用Create/SelectPalette)会在调色板损坏(WM_PALETTECHANGED处理程序)后恢复该调色板. SetSystemPaletteUse和在主表面上调用SetPalette可以提供更多帮助.但是,当应用程序尝试窃取调色板时,仍然可以感觉到闪烁,这在淡入淡出时尤为明显.

Some time ago I just started trying random things in hope of finding a solution. I found that setting the GDI palette (using Create/SelectPalette) before setting the DirectDraw palette (using IDirectDrawPalette::SetEntries) would restore the palette after it became corrupted (WM_PALETTECHANGED handler). SetSystemPaletteUse and calling SetPalette on the primary surface helped some more. However, there is still perceivable flickering when an application tries to steal the palette, which is especially prominent during fades.

问题:有没有办法获得一个真实的"独家调色板,只要我们的游戏保持焦点,它就完全不允许其他应用程序更改Windows调色板?

Question: is there a way to get a "real" exclusive palette, which completely disallows other applications changing the Windows palette as long as our game retains focus?

推荐答案

实际上有人为此找到了注册表项修复程序:

Someone actually found a registry entry fix for this, here:

http://answers.ea.com/t5/Command-Conquer-The-Ultimate/Common-Problems-Read-This-Before-Posting/mp/222052

在该页面上查找乱七八糟的颜色",您将获得所需的修补程序.

Look for "scrambled colours" on that page and you'll get to the part with the fix you need.

但是,由于在线资源正在转瞬即逝,因此,这里有完整的解释:

Since online resources are fleeting, though, here's the full explanation:

在程序的"HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ DirectDraw \ Compatibility \"下新建一个密钥.

Make a new key under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectDraw\Compatibility\" for the program.

如果您要应用兼容性的程序是32位程序,并且您使用的是64位系统(手动或通过64位程序来应用),请不要忘记添加软件"和"DirectDraw"之间的"Wow6432Node"可以弥补这一点.

If the program you're applying the compatibility for is a 32-bit program, and you're on a 64-bit system (either applying it manually or through a 64-bit program), don't forget to add the "Wow6432Node" between "Software" and "DirectDraw" to compensate for that.

在该键中,设置以下值:

In that key, set these values:

  • 标志"(REG_BINARY):[00,08,00,00]
  • 名称"(REG_SW):程序的文件名.没有路径,只有可执行文件名.
  • "ID"(REG_BINARY):应用程序的DirectDraw ID.

要获取所需的DirectDraw ID,请运行该程序,然后检查此注册表项:

To get the required DirectDraw ID, run the program and then check this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectDraw\MostRecentApplication

同样,如果您使用的是64位系统,并且要执行的程序是32位系统,则在软件"之后添加"Wow6432Node".

Again, if you're on a 64 bit system and the program you're doing this for is a 32-bit one, add the "Wow6432Node" after "Software".

该密钥中的ID为四个字节.颠倒它们的顺序以获取要放入ID值的字节. 32dd83d5变成d5,83,dd,32.

The ID in that key is four bytes. Reverse their order to get the bytes to put in the ID value. 32dd83d5 becomes d5,83,dd,32.

这篇关于“独家" DirectDraw调色板实际上不是排他性的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆