Subject: Re: Sun CG6, X11 and so on
To: None <port-sparc64@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-sparc64
Date: 04/28/2005 18:27:56
>> (You can do it either as rows, 32 pixels at a time, or as
>> 32-pixel-wide vertical stripes, whichever you prefer.  Most
>> characters, of course, are narrower than 32 pixels and hence can be
>> done as a vertical strip.)
> Sounds like the Weitek P9100 - you give it a rectangle where you want
> the data to end up and tell it if your lines are byte-aligned or not,
> then start shoving data into a port.

The cg6 does it thus:

	...->x0 = X coordinate of first pixel of first write
	...->y0 = Y ditto
	...->x1 = X coordinate of last pixel of first write
		(x0 plus some number in 0..31 - if you're using the
		"write foreground, don't touch background" mode, you
		can set this to anything >= the actual edge and pad the
		data with 0 bits)
	...->incx = value to add to x0 after each write
	...->incy = ditto y0 ditto
	loop { ...->font = next 32 bits of data }

If you are drawing a wide line, you set incx to 32 and incy to 0; if
you're drawing a vertical strip, you set incx to 0 and incy to 1.

This actually can be used for slabbed drawing of objects and triangles
and such (though in many cases using the filled-rectangle mode or the
line mode may be faster); for example, a line of slope 1/N for N<=32
can be drawn slabbed by setting incy=±1 incx=±N (± choices depending on
direction), and repeatedly writing (~0U)<<(32-N) in
don't-touch-background mode.

>>> So - is there any halfway decent CG6 documentation out there?
>> I have a number of programs that make the cg6 sit up and do tricks.
>> I'll see about writing up a doc file [...]
> The sources alone would help a lot.

ftp.rodents.montreal.qc.ca:/mouse/games/ and look at cg6.list, which is
a list of source files that use cg6.h (which is in cg6/) and a few
others which use the cg6 but don't use that include file.  I've copied
the files named in cg6.list into the places named.  In most cases, they
are not complete programs, needing pieces which are not present, but
for your purposes they may be helpful.  Not all the programs are
working, but some definitely are; in particular, asteroids, aargon,
liss, and I think all of the 4d/rot* ones work.  In the tempest/
directory there is at least one fully working piece, but it's been long
enough since I picked it up that I'm not sure exactly which piece.

And of course I'll be happy to answer question and such, to the extent
I can.

I have reason to think the cg6 includes a full 3D transform engine, but
I have no idea how to use it.  Fortunately, it appears to default to
parallel projection looking straight down the Z axis, so you can mostly
ignore it for 2D work.  (All my own 3D code for the cg6 does the 3D->2D
transformation on the host CPU.)

> Some other stupid question - I know there are cg6-variants with more
> than 1MB RAM,

I know nothing about any such; I've never even tried to work with video
memory beyond rows*cols bytes.  You might be able to just try writing
to video memory and seeing if (a) it doesn't fault and (b) it retains
what's written....

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B