So, basically, you're trying to do what we (those who are old enough...) did when DOS ruled the world: using Mode 13h and SVGA from custom libraries...
The "outb" problem isn't one. In fact, since you rely on standard PC architecture, you won't need it. You'll write directly in video card's framebuffer, and for that, you'll need so basic primitives:
A full documentation for interruption 10h. "PC System Programming", by Michael Tischer, is quite everything you need.
Start/end video mode: usual ones are mode 13h (320x200x256), VGA (640x480x16), SVGA (640x480x256 and more). Honestly, 256 color modes are easier to program. Something to erase screen, too.
Line drawing primitives: horizontal (very fast), vertical (fast), random (Bresenham's algorithm).
A bitmap font. You can use the one present in your video card, or draw one by yourself. It's however easier to use first a fixed width font.
A primitive to output one char at a given position on screen, then another primitive to output a string.
Primitives to copy/paste/move rectangular zones within framebuffer.
Primitives to read/write the entire palette for 256 (or less) color modes.
All primitives should take one or more color parameter (outline/filling usually).
All these primitives are really easy to implement in pure assembler. You should start with mode 13h, so you won't have to deal with segmentation or latches first.
Once you'll have all these primitives, drawing something like the screen you presented will be trivial: drawing 5 lines, output 3 strings (even if one is multiple characters output with color change) and put two bitmaps/symbols.
For example, my (very...) old PutPixel Pascal procedure was like this, for mode 13h (16-bit assembler):
a) 设置视频模式。这可以使用固件(旧计算机上的 BIOS,或当前计算机上的 UEFI)来完成,固件主要使用视频卡 ROM 提供的视频卡特定代码;或者可以使用与视频卡匹配的您自己的视频卡特定代码(驱动程序)来完成(如果您想花 50 年的时间为所有不同的视频卡编写驱动程序)。设置视频模式的结果是“帧缓冲区”——显卡内存的一部分,映射到 CPU 的物理地址空间,其中包含显卡发送到显示器的每个像素(其颜色)的数据。对于如何执行此操作,您需要选择一种方法(BIOS、UEFI、您自己的显卡代码)并研究和/或询问该方法。
b) 将数据(为像素绘制新颜色)写入视频卡的帧缓冲区。这几乎总是使用(更快的)内存写入而不是(慢速的)IO 端口来完成。如何做到这一点,取决于视频模式的设置方式。通常它是一个线性帧缓冲区,这非常简单 - 它就像某个(物理)地址处的像素数组。有时(特别是对于过时的垃圾),情况并非如此,您必须处理被分成多个库或平面的帧缓冲区,您一次只能访问一个库或一个平面,并且需要特殊的代码在库或平面之间切换。
There are 2 parts:
a) Setting up a video mode. This can be done using the firmware (BIOS on old computers, or UEFI on current computers) which mostly uses video card specific code provided by a video card's ROM; or it can be done using your own video card specific code (a driver) that matches the video card (if you feel like spending 50 years writing drivers for all the different video cards). The result of setting up a video mode is a "frame buffer" - part of the video card's memory that is mapped into the CPU's physical address space, which contains the data for each pixel (its color) that the video card sends to the monitor. For how to do this, you need to choose a method (BIOS, UEFI, your own code for which video card) and research and/or ask about that method.
b) Writing data (drawing new colors for pixels) to the video card's frame buffer. This is almost always done using (faster) memory writes and not (slow) IO ports. For how to do this, it depends on how the video mode was set up. Often it's a linear frame buffer, which is very simple - it's like an array of pixels at a certain (physical) address. Sometimes (especially for obsolete junk), it's not and you have to deal with the frame buffer being split into banks or planes where you can only access one bank or one plane at a time and need special code to switch between banks or planes.
发布评论
评论(2)
所以,基本上,你正在尝试做我们(那些足够老的人...)在 DOS 统治世界时所做的事情:使用自定义库中的模式 13h 和 SVGA...
“outb”问题不是其中之一。事实上,由于您依赖于标准 PC 架构,因此您不需要它。您将直接写入视频卡的帧缓冲区,为此,您需要一些基本原语:
所有这些原语都非常容易在纯汇编程序中实现。您应该从模式 13h 开始,这样您就不必先处理分段或锁存器。
一旦您拥有了所有这些基元,绘制类似您所呈现的屏幕的内容将变得微不足道:绘制 5 条线,输出 3 个字符串(即使一个是带有颜色变化的多个字符输出)并放置两个位图/符号。
例如,我的(非常...)旧的
PutPixel
Pascal 程序是这样的,对于模式 13h(16 位汇编器):这是一个面向最终用户的程序,即它有一些基本参数验证...内部像素设置没有这些测试。
So, basically, you're trying to do what we (those who are old enough...) did when DOS ruled the world: using Mode 13h and SVGA from custom libraries...
The "outb" problem isn't one. In fact, since you rely on standard PC architecture, you won't need it. You'll write directly in video card's framebuffer, and for that, you'll need so basic primitives:
All these primitives are really easy to implement in pure assembler. You should start with mode 13h, so you won't have to deal with segmentation or latches first.
Once you'll have all these primitives, drawing something like the screen you presented will be trivial: drawing 5 lines, output 3 strings (even if one is multiple characters output with color change) and put two bitmaps/symbols.
For example, my (very...) old
PutPixel
Pascal procedure was like this, for mode 13h (16-bit assembler):And this is a procedure for end user, i.e. it has some basic parameters validation... Internal pixel settings were without these tests.
有 2 个部分:
a) 设置视频模式。这可以使用固件(旧计算机上的 BIOS,或当前计算机上的 UEFI)来完成,固件主要使用视频卡 ROM 提供的视频卡特定代码;或者可以使用与视频卡匹配的您自己的视频卡特定代码(驱动程序)来完成(如果您想花 50 年的时间为所有不同的视频卡编写驱动程序)。设置视频模式的结果是“帧缓冲区”——显卡内存的一部分,映射到 CPU 的物理地址空间,其中包含显卡发送到显示器的每个像素(其颜色)的数据。对于如何执行此操作,您需要选择一种方法(BIOS、UEFI、您自己的显卡代码)并研究和/或询问该方法。
b) 将数据(为像素绘制新颜色)写入视频卡的帧缓冲区。这几乎总是使用(更快的)内存写入而不是(慢速的)IO 端口来完成。如何做到这一点,取决于视频模式的设置方式。通常它是一个线性帧缓冲区,这非常简单 - 它就像某个(物理)地址处的像素数组。有时(特别是对于过时的垃圾),情况并非如此,您必须处理被分成多个库或平面的帧缓冲区,您一次只能访问一个库或一个平面,并且需要特殊的代码在库或平面之间切换。
There are 2 parts:
a) Setting up a video mode. This can be done using the firmware (BIOS on old computers, or UEFI on current computers) which mostly uses video card specific code provided by a video card's ROM; or it can be done using your own video card specific code (a driver) that matches the video card (if you feel like spending 50 years writing drivers for all the different video cards). The result of setting up a video mode is a "frame buffer" - part of the video card's memory that is mapped into the CPU's physical address space, which contains the data for each pixel (its color) that the video card sends to the monitor. For how to do this, you need to choose a method (BIOS, UEFI, your own code for which video card) and research and/or ask about that method.
b) Writing data (drawing new colors for pixels) to the video card's frame buffer. This is almost always done using (faster) memory writes and not (slow) IO ports. For how to do this, it depends on how the video mode was set up. Often it's a linear frame buffer, which is very simple - it's like an array of pixels at a certain (physical) address. Sometimes (especially for obsolete junk), it's not and you have to deal with the frame buffer being split into banks or planes where you can only access one bank or one plane at a time and need special code to switch between banks or planes.