在 Turbo C 中以高分辨率模式使用 IBM 3514 Borland 图形接口驱动程序;在 Windows 7 64 位操作系统上使用 DosBox
我正在 Windows 7 64 位上使用 DosBox 在 Turbo C++ 中运行图形程序。现在,我想在高分辨率模式 (IBM3514HI
) 下使用 IBM3514
图形驱动程序。因此,我编写了以下基本程序来测试它:
#include <graphics.h>
#include <iostream.h>
void main() {
int gd = IBM3514, gm = IBM3514HI, e;
initgraph(&gd, &gm, "C:\\TC\\BGI");
if (e = graphresult()) {
cout << grapherrormsg(e);
}
cleardevice();
rectangle(100, 100, 300, 300);
cin.get();
closegraph();
restorecrtmode();
}
现在,该程序可以编译并运行,没有任何错误。但是,initgraph
函数调用不会初始化图形模式。 graphresult
的返回值为0
。因此,没有发生错误。然而,该程序仍然以文本模式运行。闪烁的下划线可见,但未绘制矩形。
我检查了我的 C:\TC\BGI
文件夹,并且 IMB3514.BGI
文件存在。因此我假设它确实加载了图形驱动程序。然而,我不明白为什么程序不能在图形模式下执行,甚至抛出错误。但是,如果我使用默认设置,它就可以正常工作: int gd = DETECT, gm;
对于我的程序为何无法工作的任何解释,我们将不胜感激。请尝试解决此问题。我真的很想在 1024x768
屏幕上使用 256
颜色进行绘制。
I'm running a graphical program in Turbo C++ using DosBox on Windows 7 64 bit. Now, I want to use the IBM3514
graphics driver in the High resolution mode (IBM3514HI
). So, I wrote the following bare bones program to test it:
#include <graphics.h>
#include <iostream.h>
void main() {
int gd = IBM3514, gm = IBM3514HI, e;
initgraph(&gd, &gm, "C:\\TC\\BGI");
if (e = graphresult()) {
cout << grapherrormsg(e);
}
cleardevice();
rectangle(100, 100, 300, 300);
cin.get();
closegraph();
restorecrtmode();
}
Now, the program compiles and runs without any errors. However, the initgraph
function call doesn't initialize graphics mode. The return value of graphresult
is 0
. Hence, no error has occurred. Yet, the program still runs in text mode. The blinking underscore is visible and the rectangle is not drawn.
I checked my C:\TC\BGI
folder and the IMB3514.BGI
file exists. Thus I assume that it does load the graphics driver. Yet, I can't figure out why the program doesn't execute in graphics mode, or even throw an error. However it works perfectly fine if I use the default settings: int gd = DETECT, gm;
Any explanation as to why my program doesn't work will be greatly appreciated. Please try to provide a fix to this problem. I would really like to draw on a 1024x768
screen with 256
colors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Windows 下,您的图形适配器是虚拟化的。你无法直接访问它并使用它的特定功能(除非你使用DirectX/OpenGL/其他奇怪的方法)。 DOSBox 为其运行的程序模拟一些“历史上的”图形适配器(准确地说:Tandy/Hercules/CGA/EGA/VGA/VESA)。您必须使用 TC 的 VESA 2.0 驱动程序(或一般的 VESA 驱动程序)。
Under Windows your graphical adaptor is virtualized. You can't access it directly and use its specific features (unless you use DirectX/OpenGL/other strange methods). DOSBox emulates some "historical" graphical adaptors for the programs it runs (to be precise: Tandy/Hercules/CGA/EGA/VGA/VESA). You must use the VESA 2.0 driver of TC (or in general the VESA driver).
驱动程序的正确名称是 ibm8514.bgi - 不是“3514”,也不是“imb”等。但就像我之前的发言者所说,最好使用另一个驱动程序。最好的选择是使用 Turbo 的 egavga.bgi 驱动程序。 Borland C++ 或 Turbo Pascal 包。然后你应该编译它们成功。
预计您需要该驱动程序的特殊功能。然后,如果您需要的话,您必须检查他们的努力。我认为 egavga.bgi、vesa 或直接切换到图形模式并使用一些特殊例程来制作图形应该可以在 DOSBox、EmuDOS 或所有 32 位版本的 Windows(如 Windows XP 等)中工作。
The correctly name of the driver is ibm8514.bgi - not "3514" and not "imb" or so. But like my previous speaker said, better you use another driver. The best choice is to use the egavga.bgi driver of the Turbo resp. Borland C++ or Turbo Pascal package. Then you should compile them successful.
Expect you need a special feature of this driver. Then you must check them of this effort if you need them. I think the egavga.bgi, vesa or a directly switch to the graphic mode with some special routines to make graphic should work in DOSBox, EmuDOS or in all 32-Bit-Version of Windows like Windows XP or so.
尝试使用以下代码:(
两个变量都是整数,而不是字符串)
Try this code instead:
(Both variables are INTEGERS, not STRINGS)