nanogui@linuxhacker.org

nanogui@linuxhacker.org


Subject: Re: Drawing modes
From: Ben Pfaff
Date: 19 May 1999 19:20:29 -0400

Alex Holden <alex@linuxhacker.org> writes:

   On Wed, 19 May 1999, Greg Haerr wrote:
   > 	Don't get confused by the "read-modify-write" cycle that the EGA/VGA
   > controllers require for the damned hardware.  It think this is what 
   > you're looking at.  The EGA/VGA doesn't require an rmw cycle for XOR, it
   > requires it for all writes, and the SET, AND, OR, XOR stuff is
   > controlled in yet another hw register.

   Since you keep insisting that it is possible to get around the requirement
   to do RMW, I've looked hard for any code which demonstrates this, but I'm
   sorry to say I've been unable find any. As an example, here is an extract
   from __linear_putpixel8 (the basis of pretty much all operations on 8 bit
   linear devices- the other bit depths all seem to work the same way) from
   allegro:

He might be referring to one (or both) of two different things:

1. Under VGA planar (16-color) modes, there is hardware assistance for
   logical operations, which supports NOP, AND, OR, XOR at the
   hardware level.  You write the desired logical operation to a
   couple of bits in the VGA Data Rotate Register, then perform the
   operations like you would usually, and the device automatically
   does the desired logical operation.

   Unfortunately, you still need to do a read and a write, unless
   there's some clever combination of write mode and register settings
   that I'm missing right now.  You don't necessarily need to do a
   rmw, though: often, due to the VGA architecture, the following does
   just fine:
	volatile char *x;
	...set up registers...
	y = *x; *x = 0x42;
	...finish up...
   i.e., you don't care what gets read from the VGA, and you don't
   care what byte gets written to the VGA; the 0x42 above may be any
   arbitrary byte, which produces identical results.

2. Video RAM is often quite a bit slower than system RAM, so sometimes
   it's faster to keep `video RAM shadow' as a bitmap in system RAM.
   Then, to update the screen image, you rmw the bitmap and just do
   the write to video RAM (as opposed to a read and a write to video
   RAM and none to a bitmap): three memory accesses instead of two,
   but only one really slow memory access rather than two.
-- 
"Let others praise ancient times; I am glad I was born in these."
--Ovid (43 BC-18 AD)

nanogui@linuxhacker.org