nanogui: Thread: Microwindows for Hercules


[<<] [<] Page 1 of 4 [>] [>>]
Subject: Microwindows for Hercules
From: Greg Haerr ####@####.####
Date: 15 Jul 1999 16:19:33 -0000
Message-Id: <01BECEAB.05B1A410.greg@censoft.com>

: I am not realy up to writing the driver myself because I have never writen a 
: driver before, but I will test it for you. I have 2 8086's with herc cards 
: in.

	Well, last night I took Jacob's hercules code samples and wrote
a complete hercules graphics driver for MicroWindows and Nano-X.  I wrote
all the driver entry points, but since I don't have a hercules card, I can't test it.
Basically, the hercules card appears to use 32k of graphics ram for 720x350 mono
pixels starting at segment b000.  Each "screen ram line" corresponds to 4 physical
scan lines, and there's one bit per pixel.  There's a sequence of OUT instructions
to turn the card from text to graphics modes and back, and I use int10 to get
the bios rom's character set map.

	The files mwin/src/drivers/scr_herc.c are the hercules driver and
mwin/src/drivers/elksutil.c are some support functions to read/write far data, etc.

	I'm looking for volunteers to test, I think this baby should run pretty quickly.
It will be slow, since I've implemented hline by calling drawpixel.  This
needs to be sped up by drawing a scan line directly.  I didn't want to do that
until I knew drawpixel() works.

	The files are all incorporated in microwindows 0.83, due on my site in about
fifteen minutes...

Greg

Subject: Re: Microwindows for Hercules
From: Jakob Eriksson ####@####.####
Date: 15 Jul 1999 16:40:28 -0000
Message-Id: <Pine.GSO.3.95.990715182840.5200A-100000@bilbo.mdh.se>

On Thu, 15 Jul 1999, Greg Haerr wrote:

> : I am not really up to writing the driver myself because I have never writen a 
> : driver before, but I will test it for you. I have 2 8086's with herc cards 
> : in.
> 
> 	Well, last night I took Jacob's hercules code samples and wrote
                                  k              :-)

> a complete hercules graphics driver for MicroWindows and Nano-X.  I wrote
> all the driver entry points, but since I don't have a hercules card, I can't test it.
> Basically, the hercules card appears to use 32k of graphics ram for 720x350 mono
> pixels starting at segment b000.  Each "screen ram line" corresponds to 4 physical
> scan lines, and there's one bit per pixel.  There's a sequence of OUT instructions
> to turn the card from text to graphics modes and back, and I use int10 to get
> the bios rom's character set map.
> 
> 	The files mwin/src/drivers/scr_herc.c are the hercules driver and
> mwin/src/drivers/elksutil.c are some support functions to read/write far data, etc.
> 
> 	I'm looking for volunteers to test, I think this baby should run pretty quickly.
> It will be slow, since I've implemented hline by calling drawpixel.  This
> needs to be sped up by drawing a scan line directly.  I didn't want to do that
> until I knew drawpixel() works.

Excellent!

I have examples on how to draw fast lines horizontal, vertical and
(x1, y1) -> (x2, y2) using Bresenham.
These are in a book in asm. so I don't know about their copyright but
I think they are intended to be used, ie public domain.
Bresenham on Hercules is a little tricky.
If I don't remember wrong, there are two buffers on a Hercules (2 * 32k mem)
so you can even doublebuffer changes. Now that would be cool to work into
the driver.
If you other people fix it into working order, I can fix double buffering.


Jakob


Subject: RE: Microwindows for Hercules
From: Greg Haerr ####@####.####
Date: 15 Jul 1999 16:48:12 -0000
Message-Id: <01BECEAE.D58CABF0.greg@censoft.com>

: I have examples on how to draw fast lines horizontal, vertical and
: (x1, y1) -> (x2, y2) using Bresenham.
: These are in a book in asm. so I don't know about their copyright but
: I think they are intended to be used, ie public domain.
: Bresenham on Hercules is a little tricky.

	No need.  MicroWindows handles the Bresenham algorithm in the mid
level code in devdraw.c.  It uses successive calls to drawpixel to make it work.
In this way, people like you and me don't have to rewrite bresenham for every
card someone wants....

	The fast line draw that we need is the one that calculates the 
*bit* starting position in a starting scan line byte, and the end *bit* position.
The bits in between the begin and end are then filled with ones.  For the bytes
inbetween, this is ridculously easy, just set them to 0xff.  For the begin and
end, use a mask to set those bits...



: If I don't remember wrong, there are two buffers on a Hercules (2 * 32k mem)
: so you can even doublebuffer changes. Now that would be cool to work into
: the driver.
: If you other people fix it into working order, I can fix double buffering.

	Neither nano-X or microwindows require or use double buffering currently, 
This might be useful when bitblt is implemented though...

Greg
Subject: RE: Microwindows for Hercules
From: Jakob Eriksson ####@####.####
Date: 15 Jul 1999 18:25:40 -0000
Message-Id: <Pine.GSO.3.95.990715200356.6936A-100000@bilbo.mdh.se>

On Thu, 15 Jul 1999, Greg Haerr wrote:

> : I have examples on how to draw fast lines horizontal, vertical and
> : (x1, y1) -> (x2, y2) using Bresenham.
> : These are in a book in asm. so I don't know about their copyright but
> : I think they are intended to be used, ie public domain.
> : Bresenham on Hercules is a little tricky.
> 
> 	No need.  MicroWindows handles the Bresenham algorithm in the mid
> level code in devdraw.c.  It uses successive calls to drawpixel to make it work.
> In this way, people like you and me don't have to rewrite bresenham for every
> card someone wants....

That is fine for normal cards, but since Hercules cards are so ... strange...
the algo is very optimized for the Hercules.
Example:
----
    ----
	----
	    ----

If using writepixel, there need be 16 writes to videomemory.
When using the native HGC linedraw, there need be only 4 writes to videomem.

 BYTE    BYTE
7654321076543210
----
    ----
	----
	    ----

The benefit increases the more horizontal the line is.

Also, the algo. uses an incrementing form of bresenham. Very standard,
yes. But the incrementing scheme takes into account the bizarre
HGC memory layout.
Calculating a byte address and bit offset for a given X, Y is rather
costly, whatever way you do it.
But when drawing a line you know a lot of stuff already, so you are
not solving the problem (X, Y) --->  (byte address, bit offset),
you are only drawing a line.

If someone wants asm code I can write it down from the book.

> 	The fast line draw that we need is the one that calculates the 
> *bit* starting position in a starting scan line byte, and the end *bit* position.
> The bits in between the begin and end are then filled with ones.  For the bytes
> inbetween, this is ridculously easy, just set them to 0xff.  For the begin and
> end, use a mask to set those bits...

I am not sure about what you mean here.
You mean we need an algo that returns BYTEADDRESS, BITSTART and BITEND?

> : If I don't remember wrong, there are two buffers on a Hercules (2 * 32k mem)
> : so you can even doublebuffer changes. Now that would be cool to work into
> : the driver.
> : If you other people fix it into working order, I can fix double buffering.
> 
> 	Neither nano-X or microwindows require or use double buffering currently, 
> This might be useful when bitblt is implemented though...

I was rather thinking of a solution not visible to above layers, but
maybe that was not a good idea... :-)
(A hack.)

Regards,
Jakob Eriksson


Subject: RE: Microwindows for Hercules
From: Greg Haerr ####@####.####
Date: 15 Jul 1999 18:38:51 -0000
Message-Id: <01BECEBE.64054E50.greg@censoft.com>

: That is fine for normal cards, but since Hercules cards are so ... strange...

	The VGA is *far* stranger, believe me, because of it's requiring more than
64k of video memory...


: the algo is very optimized for the Hercules.
: Example:
: ----
:     ----
: 	----
: 	    ----
: 
: If using writepixel, there need be 16 writes to videomemory.
: When using the native HGC linedraw, there need be only 4 writes to videomem.
: 
:  BYTE    BYTE
: 7654321076543210
: ----
:     ----
: 	----
: 	    ----
: 
: The benefit increases the more horizontal the line is.
: 
: Also, the algo. uses an incrementing form of bresenham. Very standard,
: yes. But the incrementing scheme takes into account the bizarre
: HGC memory layout.
: Calculating a byte address and bit offset for a given X, Y is rather
: costly, whatever way you do it.
: But when drawing a line you know a lot of stuff already, so you are
: not solving the problem (X, Y) --->  (byte address, bit offset),
: you are only drawing a line.

	Yep, you're right.  But currently, very few applications require bresenham,
so it's still in the mid level.  Far more often is drawing rectangles, which consist
mostly of horizontal lines.  This is the code that *must* be fast.  The bresenham code
doesn't have to be fast, since it's rarely called for non-scientic apps (the graphd3d demo
code that I've written for microwindows for instance is too large for ELKS...)

: > 	The fast line draw that we need is the one that calculates the 
: > *bit* starting position in a starting scan line byte, and the end *bit* position.
: > The bits in between the begin and end are then filled with ones.  For the bytes
: > inbetween, this is ridculously easy, just set them to 0xff.  For the begin and
: > end, use a mask to set those bits...
: 
: I am not sure about what you mean here.
: You mean we need an algo that returns BYTEADDRESS, BITSTART and BITEND?

	Yes, it's already done in HERC_drawpixel.  The HERC_drawhline code
will want to precalc each of those for one line, rather than pixel-by-pixel.  Take
a look at the hercules driver, and you'll see what I mean.


: I was rather thinking of a solution not visible to above layers, but
: maybe that was not a good idea... :-)
: (A hack.)
: 
	Nothing wrong with that, except that the low level code for nano-X
and microwindows is only interfaced (currently by design) thru a very few
entry points:
	readpixel
	drawpixel
	drawhline
	drawvline
	fillrect

This was purposely designed so that I or someone else could actually
write a working driver for a new card in one evening...  We can add speed
stuff later, once we find people who actually use it and want the improvement.


Later, I plan on adding a fast text out primitive for Al's work on scrolling 
text for ELKS.

Greg




: Regards,
: Jakob Eriksson
: 
: 


Subject: Re: Microwindows for Hercules
From: Perry Harrington ####@####.####
Date: 15 Jul 1999 20:01:12 -0000
Message-Id: <199907152047.NAA12710@alpha.apsoft.com>

> If using writepixel, there need be 16 writes to videomemory.
> When using the native HGC linedraw, there need be only 4 writes to videomem.
> 
> Also, the algo. uses an incrementing form of bresenham. Very standard,
> yes. But the incrementing scheme takes into account the bizarre
> HGC memory layout.
> 
> Regards,
> Jakob Eriksson
> 
> 

Why not take the approach that Linux takes with the module:

Create the driver structure, have the primitives referenced in the
driver structure.  If the driver doesn't implement a primitive, set
the structure member to NULL, and the driver loader will take care
to use the builtin function.  EG:

struct driver {
	ptr_t	hline
	ptr_t	vline
	ptr_t	bline
	...
} DRIVER;

struct driver herc_card[]={
	herc_hline,
	herc_vline,
	NULL
};

That way you can have driver optimized primitives or rely on the default,
which just calls write_pixel.

--Perry

-- 
Perry Harrington       Linux rules all OSes.    APSoft      ()
email: ####@####.#### 			Think Blue. /\
Subject: Re: Microwindows for Hercules
From: Jakob Eriksson ####@####.####
Date: 15 Jul 1999 21:27:13 -0000
Message-Id: <Pine.GSO.3.95.990715231948.8973A-100000@bilbo.mdh.se>

On Thu, 15 Jul 1999, Perry Harrington wrote:

> Why not take the approach that Linux takes with the module:
> 
> Create the driver structure, have the primitives referenced in the
> driver structure.  If the driver doesn't implement a primitive, set
> the structure member to NULL, and the driver loader will take care
> to use the builtin function.  EG:
> 
> struct driver {
> 	ptr_t	hline
> 	ptr_t	vline
> 	ptr_t	bline
> 	...
> } DRIVER;
> 
> struct driver herc_card[]={
> 	herc_hline,
> 	herc_vline,
> 	NULL
> };
> 
> That way you can have driver optimized primitives or rely on the default,
> which just calls write_pixel.

sounds good.
how much would it take to change/add microwin?

Jakob



Subject: Re: Microwindows for Hercules
From: Ben Pfaff ####@####.####
Date: 15 Jul 1999 21:37:22 -0000
Message-Id: <87oghdk39j.fsf@pfaffben.user.msu.edu>

Jakob Eriksson ####@####.#### writes:

   On Thu, 15 Jul 1999, Perry Harrington wrote:

   > Why not take the approach that Linux takes with the module:
   > 
   > Create the driver structure, have the primitives referenced in the
   > driver structure.  If the driver doesn't implement a primitive, set
   > the structure member to NULL, and the driver loader will take care
   > to use the builtin function.  EG:
   > 
   > struct driver {
   > 	ptr_t	hline
   > 	ptr_t	vline
   > 	ptr_t	bline
   > 	...
   > } DRIVER;
   > 
   > struct driver herc_card[]={
   > 	herc_hline,
   > 	herc_vline,
   > 	NULL
   > };
   > 
   > That way you can have driver optimized primitives or rely on the default,
   > which just calls write_pixel.

   sounds good.
   how much would it take to change/add microwin?

If someone's really going to take that approach (I assumed something
like this was already being done), then I recommend modifying it a
little for speed.  Instead of leaving NULL in the table and having to
test it each time the function is being called, replace the NULL with
a function pointer.  This can either be done in the device driver
directly:

    struct driver herc_card[]={
    	herc_hline,
    	herc_vline,
    	generic_line,
    };

or it can be done in a function that examines the structure at load
time and patches up any NULLs with real function pointers.  This is a
good way to reduce the special cases.
-- 
"...dans ce pays-ci il est bon de tuer de temps en temps un amiral
 pour encourager les autres."
--Voltaire, _Candide_
Subject: Re: Microwindows for Hercules
From: Perry Harrington ####@####.####
Date: 15 Jul 1999 21:51:15 -0000
Message-Id: <199907152236.PAA13086@alpha.apsoft.com>

> 
>    sounds good.
>    how much would it take to change/add microwin?

That, I don't know, Greg?

> 
> If someone's really going to take that approach (I assumed something
> like this was already being done), then I recommend modifying it a
> little for speed.  Instead of leaving NULL in the table and having to
> test it each time the function is being called, replace the NULL with
> a function pointer.  This can either be done in the device driver
> directly:

Obviously it would be smart to fill it in.  However you must set it to NULL
in the driver because of symbol resolution.

As long as the device driver header file version matches with the one that
the microwin server uses, the offsets are known.

Locating the symbols inside the driver is the hard part.

Perhaps a separate file, created via an external program, which contains
this structure, is the better way to go.  This way when the structure changes,
you don't have to go around recompiling all the drivers that have been
distributed, you just need a program to fixup your jumptable files.

Does anyone know if code exists to hunt for symbols inside a binary?  Does
bcc generate any symbol information?

If bcc doesn't generate any symbol info, then I would suggest that each driver
be an archive of object files, with a manifest.  You would need the code from
the linker to search the archive and something to read the manifest.

> 
>     struct driver herc_card[]={
>     	herc_hline,
>     	herc_vline,
>     	generic_line,
>     };
> 
> or it can be done in a function that examines the structure at load
> time and patches up any NULLs with real function pointers.  This is a
> good way to reduce the special cases.
> -- 
> "...dans ce pays-ci il est bon de tuer de temps en temps un amiral
>  pour encourager les autres."
> --Voltaire, _Candide_
> 

--Perry

-- 
Perry Harrington       Linux rules all OSes.    APSoft      ()
email: ####@####.#### 			Think Blue. /\
Subject: RE: Microwindows for Hercules
From: Greg Haerr ####@####.####
Date: 15 Jul 1999 22:09:10 -0000
Message-Id: <01BECEDB.BFBE44F0.greg@censoft.com>

: Why not take the approach that Linux takes with the module:
: 
: Create the driver structure, have the primitives referenced in the
: driver structure.  If the driver doesn't implement a primitive, set
: the structure member to NULL, and the driver loader will take care
: to use the builtin function.  EG:
: : That way you can have driver optimized primitives or rely on the default,
: which just calls write_pixel.
: 
	Yes, that's the general idea I was going to use.  However,
my plan was to add required functionality first, and optimize later.  So
far, the only driver speed issue identified is that the text output may be too
slow.  Otherwise, most speed issues are the 8086 itself.

	The other factor is keeping the code size very small, so that there's
room for applications to be linked with the library...

Greg
[<<] [<] Page 1 of 4 [>] [>>]


Powered by ezmlm-browse 0.20.