【问题标题】:Force screen size when testing embedded DOS app in Windows 7 command window在 Windows 7 命令窗口中测试嵌入式 DOS 应用程序时强制屏幕大小
【发布时间】:2011-01-10 23:37:01
【问题描述】:

我正在使用 OpenWatcom(针对 16 位 DOS 应用程序的出色的 Windows 托管编译器)进行一些嵌入式 DOS 开发。目标硬件有一个 24x16 字符屏幕(据说在某种程度上模拟了 CGA),我试图让我的 Windows 7 机器上的 CMD.EXE 窗口保持在固定的 24x16,没有任何滚动条。

我已经使用了窗口属性和MODE CON: COLS=24 LINES=16 来获得我想要的屏幕尺寸,但是一旦我的应用程序使用 INT10 BIOS 调用来清除屏幕,模式就会跳回到 80x24。

这是我用来清屏的方法:

void cls(void)
{
// Clear screen and reset cursor position to (0,0)
    union REGS  regs; 

    regs.w.cx = 0;          // Upper left
    regs.w.dx = 0x1018;     // Lower right (of 16x24)
    regs.h.bh = 7;          // Blank lines attribute (white text on black)
    regs.w.ax = 0x0600;     // 06 = scroll up, AL=00 to clear

    int86( 0x10, &regs, &regs ); 
}

有什么想法吗?我仍然可以在 80x24(或 80x25)下进行测试,但它并不完全像 24x16 模式。

【问题讨论】:

    标签: c embedded dos


    【解决方案1】:

    我知道,调用 system() 并不优雅(见下文),但这是一种务实的可能性:

    #ifdef deployed
    int86( 0x10, &regs, &regs );
    #endif
    #ifndef deployed
    system("MODE CON: COLS=24 LINES=16");  // includes a clear-screen
    #endif
    

    如果您不想使用 system(),您可以在调用中断 0x10 后使用 consoleHandle 将控制台窗口改回来。以下是更改缓冲区大小和窗口尺寸的函数:

    http://msdn.microsoft.com/en-us/library/ms687089%28VS.85%29.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-23
      • 2010-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多