Note that there are some explanatory texts on larger screens.

plurals
  1. PODOS EGA Graphics Programming in Mode 0Dh
    primarykey
    data
    text
    <p>I'm doing a bit of retro programming for fun. What I want to create is a DOS game using EGA graphics but I am having a bit of trouble finding a good reference on the web. Everybody who talks about doing DOS programming assumes that the programmer will use mode 13h, and although some pages mention the other graphics modes, I haven't found one yet that discusses their proper use.</p> <p>Here's what I'm trying to get working right now:</p> <pre><code>//------------------------------------------------------------------------------ // DOS graphics test // // Thanks to the following links: // http://gamebub.com/cpp_graphics.php // // Written for Digital Mars C compiler to be compiled as a DOS 16 bit binary. //------------------------------------------------------------------------------ #include &lt;dos.h&gt; #include &lt;stdio.h&gt; #define SCREEN_WIDTH 320; #define SCREEN_HEIGHT 200; unsigned char far *vram = (unsigned char far *)0xA0000000L; //------------------------------------------------------------------------------ void set_video_mode(unsigned char mode) { union REGS in, out; in.h.ah = 0; in.h.al = mode; int86(0x10, &amp;in, &amp;out); } //------------------------------------------------------------------------------ void plot_pixel(unsigned int x, unsigned int y, unsigned char color) { // this is wrong because it's only 4 bpp not 8 vram[y * 320 + x] = color; //vram[((y&lt;&lt;8)+(y&lt;&lt;6))+x] = color; } //------------------------------------------------------------------------------ int main(int argc, char* argv[]) { // EGA 320 x 200 x 16 set_video_mode(0x0d); for (unsigned char i = 0; i &lt; 255; i++) { vram[i] = i; } //plot_pixel(10, 10, 1); getc(stdin); return 0; } </code></pre> <p>This sample code works great if you change set_video_mode() to take 0x13 instead of 0x0d, but like I said I'm trying to get EGA graphic here, not VGA. :) I realize that in order to do four bits-per-pixel I'm going to either need to assume that plot_pixel writes two pixels at the same time or do a some bit twiddling to make sure I only write the four bits that I actually want.</p> <p>My problem is that I'm not seeing what I expect as output--in particular, no colors! Everything seems to be mono colored, which is not what I want at all. Is there some kind of different procedure for employing a color palette in this graphics mode than in 13h? Or have I somehow invoked a completely different graphics mode from the one I intended? Guidance would be very much appreciated.</p> <p>I don't think my compiler args would be relevant, but just in case:</p> <pre><code>..\dm\bin\dmc test.c -o test -mm </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload