Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!dkuug!diku!zonker From: zonker@diku.dk (Claus Engdahl) Newsgroups: comp.os.msdos.programmer Subject: VGA screen, writemode 2, help needed. Summary: The time has come, the walrus said, to talk of many things.... Keywords: vga writemode 2, bitmask register is ukuxnad? Message-ID: <1991Jun6.202226.13217@odin.diku.dk> Date: 6 Jun 91 20:22:26 GMT Sender: zonker@rimfaxe.diku.dk Organization: Department of Computer Science, U of Copenhagen Lines: 70 Hi. I'm desperately seeking help from one of you VGA gurus out there. I am trying to write to screen, using writemode 2. I manage to get something written, but the bitmask register seems to work in strange and wonderous ways :-( Having read "Programmers guide to the EGA and VGA cards", I managed to cook up the following routine: 1. First setup screen, using bios interrupt (I use mode 0x12, 640x480x16, VGA only mode). 2. Set WM field of MODE register (a Graphics Controller Register), to writemode 2. 3. Set Function Select field, of the "Data Rotate Register" to 0. 4. To enable writing to all 4 bitplanes, I set the Map Mask register (a sequencer register), to 0x0F. 5. The last thing I do is set the Bit Mask register to a pattern according to the pixels I want to write (in my case 0x01). If I set BitMask to 0x01 (write the rightmost pixels in all bytes), and then try to write a 0x0F to a byte in the screen mem, I would assume that I would get a single white pixel on the screen. I get several pixels, with different colours. The strange thing is, that when I try to set the bitmask to 0xFF (write to all pixels in byte), I get a line with the correct colour. Should the registers be setup, in a special order? Is there something missing? Any help (and/or references to examples), would be appreciated. Claus (zonker@diku.dk) ------------------------------------------------------------------ For completeness, my src (TC2.0) has been appended: /* Set Graphics Controller Register writemode 2 */ outportb(0x03CE, 0x05); outportb(0x03CF, 0x02); /* No data rotate, no function select, just let my data through (please) */ outportb(0x03CE, 0x03); outportb(0x03CF,0x00); /* Enable all four bitplanes, set mapmask reg. to: 00001111 */ outportb(0x03C4, 0x02); outportb(0x03C5, 0x0F); /* Now set bitmask to indicate which bits I want to modify */ outportb(0x03CE, 0x08); outportb(0x03CF, 0x01); /* Try to draw some white dots */ for(i=0; i!=80; i++) pokeb(0xA000, i, 0x0F); /* Here I get some blue, green and white dots, when run once. When I */ /* try to run it again, I get some red dots. */ -- Edb-afdeligen (staff@diku.dk) V/ Claus Engdahl (zonker@diku.dk)