From: krohn@bae.bellcore.com (Eric Krohn(C++))
Newsgroups: comp.sys.3b1
Subject: Re: MGR questions (second try)
Date: 15 Apr 92 19:34:17 GMT
Reply-To: krohn@bae.bellcore.com
Organization: Bellcore

In article <1992Apr1.191238.9898@cc.gatech.edu>, arnold@cc.gatech.edu (Arnold Robbins) writes:
|> I am experimenting with MGR on my sparcstation IPC.  It is nice and fast.
|> I'm using the "movie" version. I'm using the color executable.  (I know
|> that the 3B1 is monochrome etc, but I figure most of the active MGR
|> expertise out in the world is to be found in this group.)
|> 
|> 1. The menu invoked by the left mouse button on a terminal emulator window
|>    does not have "cut" or "paste" in it.  This cuts down on functionality
|>    in a *major* fashion. :-(  All hints, advice, etc. on this are welcome.

How about code?  :-)  See below.  I sent this code to Steve Uhler last
year, but I don't think it ever made its way into any MGR release.

|> 2. MGR is supposed to be a networking windowing system; what do I do on
|>    a remote system to get a window on my screen, short of just doing an
|>    rlogin?

Don't complain too much about using rlogin.  I'm stuck using cu.
I open a nice sized window on my local machine, cu to a machine at work,
then run rmgr, a decent program posted by Howard Chu in Oct 1990.
Rmgr resizes the window and downloads some menus.  Then I can use the
mouse to open new windows to the machine at work.  Updates are pretty
choppy when multiple remote windows talk simultaneously across a 1200
baud connection, but it works.  Using Meta-1 (when I run the cu in
mgr window 1) lets me quickly cycle through the remote windows -- that
helps make up for the 1200 baud connection.

I believe rmgr was posted to comp.sources.misc.  Send email if you cannot
find it elsewhere.

|> 3. I linked /dev/kbd to /dev/bell but MGR still does not beep.  (The screen
|>    flashes just fine though.)

I don't think I ever got the bell to work either.  It works on my 3b1 with
MGR, though the screen *bounces* everytime the bell rings.  Very annoying.

|> 4. MGR does not come with a ton of clients.  What nifty MGR clients are
|>    out there, and where can I get them (ftp preferred, uucp ok if
|>    necessary and telebit available).

I have this suspicion that Steve Uhler has a number of interesting MGR
tools that have never been released -- and, sadly, probably never will.
I've heard about some, but have never seen any, and I work for the same
company as Steve. :-(

Here's the promised code.  It's not fast, but it worked on a Sun3 two 
years ago.  It mashes the color glyphs to monochrome, and then applies
the normal MGR hashing algorithm to figure out what the characters are.


*** /tmp/,RCSt1029386	Wed Apr 15 14:41:26 1992
--- cut.c	Wed Apr 15 14:41:27 1992
***************
*** 48,53
  unsigned long data[MAXROWS];		/* bit data for glyph */
  BITMAP *check;				/* other spot for glyph comparison */
  unsigned long data2[MAXROWS];		/* bit data for other glyph */
  
  static struct entry **table;		/* hash table */
  

--- 48,59 -----
  unsigned long data[MAXROWS];		/* bit data for glyph */
  BITMAP *check;				/* other spot for glyph comparison */
  unsigned long data2[MAXROWS];		/* bit data for other glyph */
+ #if	DEPTH > 1
+ static BITMAP *deep_glyph;		/* spot for multiplane glyph comparison */
+ static unsigned char data3[BIT_Size(MAXCOLS,MAXROWS,DEPTH)];	/* bit data for glyph */
+ BITMAP *mono_glyph;			/* convert color to mono glyph */
+ unsigned long data4[MAXROWS];		/* bit data for mono_glyph */
+ #endif
  
  static struct entry **table;		/* hash table */
  
***************
*** 82,87
  
     glyph = bit_alloc(32,FSIZE(high),data,1);
     check = bit_alloc(32,FSIZE(high),data2,1);
     bit_blit(check,0,0,32,FSIZE(high),BIT_CLR,NULL_DATA,0,0);
  
     /* build hash table */

--- 88,97 -----
  
     glyph = bit_alloc(32,FSIZE(high),data,1);
     check = bit_alloc(32,FSIZE(high),data2,1);
+ #if DEPTH > 1
+    deep_glyph = bit_alloc(32,FSIZE(high),data3,BIT_DEPTH(W(window)));
+    mono_glyph = bit_alloc(32,FSIZE(high),data4,1);
+ #endif
     bit_blit(check,0,0,32,FSIZE(high),BIT_CLR,NULL_DATA,0,0);
  
     /* build hash table */
***************
*** 233,238
     return(count);
     }
  
  /* given bitmap, get hash code */
  
  static int

--- 243,253 -----
     return(count);
     }
  
+ /* TODO: If the depth == 8, scan the pixels assuming that the first pixel
+  * value seen is 0 and the second pixel value seen is 1.
+  * Use the resulting values to compute the hash value.
+  */
+ 
  /* given bitmap, get hash code */
  
  static int
***************
*** 245,251
     register int i,j;
     bit_blit(glyph,0,0,32,h,BIT_CLR,NULL_DATA,0,0);
     bit_blit(glyph,32-w,0,w,h,how ? BIT_NOT(BIT_SRC) : BIT_SRC,map,x,y);
!          for (j=0;j<h;j++)
              sum += data[j]*(j+1);
     return(sum%H_SIZE);
     }

--- 260,266 -----
     register int i,j;
     bit_blit(glyph,0,0,32,h,BIT_CLR,NULL_DATA,0,0);
     bit_blit(glyph,32-w,0,w,h,how ? BIT_NOT(BIT_SRC) : BIT_SRC,map,x,y);
!          for (j=0;j<h;j++) {
              sum += data[j]*(j+1);
  	    }
     return(sum%H_SIZE);
***************
*** 247,252
     bit_blit(glyph,32-w,0,w,h,how ? BIT_NOT(BIT_SRC) : BIT_SRC,map,x,y);
           for (j=0;j<h;j++)
              sum += data[j]*(j+1);
     return(sum%H_SIZE);
     }
  

--- 262,268 -----
     bit_blit(glyph,32-w,0,w,h,how ? BIT_NOT(BIT_SRC) : BIT_SRC,map,x,y);
           for (j=0;j<h;j++) {
              sum += data[j]*(j+1);
+ 	    }
     return(sum%H_SIZE);
     }
  
***************
*** 250,255
     return(sum%H_SIZE);
     }
  
  /* enter a glyph into the hash table */
  
  static int

--- 266,343 -----
     return(sum%H_SIZE);
     }
  
+ #ifdef SHOW_DEBUG
+ static int
+ show_bitmap(map,x,y,w,h)
+ BITMAP *map;
+ int x,y,w,h;		/* where in map */  
+    {
+    register int i,j;
+    dprintf(C)(stderr, "show_bitmap: x=%d,y=%d,w=%d,h=%d\n", x, y, w, h);
+    dprintf(C)(stderr, "depth=%d, pixels x=%d, y=%d\n", BIT_DEPTH(map), BIT_WIDE(map), BIT_HIGH(map));
+    if (BIT_DEPTH(map) == 1) {
+       bit_blit(glyph,0,0,32,h,BIT_CLR,NULL_DATA,0,0);
+       bit_blit(glyph,32-w,0,w,h,BIT_SRC,map,x,y);
+       for (j=0;j<h;j++) {
+ 	 dprintf(C)(stderr, " %3lo", data[j]);
+ 	 }
+       dprintf(C)(stderr, "\n", data[j]);
+       }
+    else {
+       register int k;
+       bit_blit(deep_glyph,0,0,w,h,BIT_SRC,map,x,y);
+       k = 0;
+       for (i=0;i<h;i++) {
+ 	 k = i * MAXCOLS;
+          for (j=0;j<w;j++) {
+ 	    dprintf(C)(stderr, " %2u", data3[k]);
+ 	    ++k;
+ 	    }
+ 	 dprintf(C)(stderr, "\n");
+ 	 }
+       }
+    return(0);
+    }
+ #endif
+ 
+ #if DEPTH > 1
+ /* Convert color bitmap to monochrome.
+  * Return ptr to mono_glyph.
+  * Place bitmap at 0,0 in mono_glyph.
+  */
+ static BITMAP *
+ mono_bitmap(map,x,y,w,h)
+ BITMAP *map;
+ int x,y,w,h;		/* where in map */  
+    {
+    register int i,j;
+    dprintf(C)(stderr, "mono_bitmap: x=%d,y=%d,w=%d,h=%d\n", x, y, w, h);
+    dprintf(C)(stderr, "depth=%d, pixels x=%d, y=%d\n", BIT_DEPTH(map), BIT_WIDE(map), BIT_HIGH(map));
+    if (BIT_DEPTH(map) == 1) {
+       bit_blit(mono_glyph,0,0,w,h,BIT_SRC,map,x,y);
+       }
+    else {
+       register unsigned long background = 0;
+       register int k = 0;
+       bit_blit(deep_glyph,0,0,w,h,BIT_SRC,map,x,y);
+       background = data3[0];
+       dprintf(C)(stderr, "background=%d\n", background);
+       for (i=0;i<h;i++) {
+ 	 register unsigned long bits = 0;
+ 	 k = i * MAXCOLS;
+          for (j=0;j<w;j++) {
+ 	    if (data3[k] != background)
+ 	       bits |= 1 << (31 - j);
+ 	    ++k;
+ 	    }
+ 	 dprintf(C)(stderr, "\n bits=%lo\n", bits);
+ 	 data4[i] = bits;
+ 	 }
+       }
+    return (mono_glyph);
+    }
+ #endif
+ 
  /* enter a glyph into the hash table */
  
  static int
***************
*** 285,290
     int code;				/* hash code */
     int size = sizeof(long) * h;
  
     code = get_hash(map,x,y,w,h,0);		/* leaves char in glyph */
     for(entry=table[code];entry;entry=entry->next) {
        bit_blit(check,32-w,0,w,h,BIT_SRC,W(font)->glyph[entry->value],0,0);

--- 373,389 -----
     int code;				/* hash code */
     int size = sizeof(long) * h;
  
+ #ifdef SHOW_DEBUG
+    show_bitmap (map,x,y,w,h);
+ #endif
+ #if DEPTH > 1
+    /* Convert 8-bit deep bitmap to 1-bit deep. */
+    map = mono_bitmap (map,x,y,w,h);
+ #ifdef SHOW_DEBUG
+    show_bitmap (map,0,0,w,h);
+ #endif
+    x = y = 0;	/* Potential character now at (0,0) */
+ #endif
     code = get_hash(map,x,y,w,h,0);		/* leaves char in glyph */
     for(entry=table[code];entry;entry=entry->next) {
        bit_blit(check,32-w,0,w,h,BIT_SRC,W(font)->glyph[entry->value],0,0);

-- 
Eric Krohn	krohn@bae.bellcore.com   or   uunet!bellcore!bae!krohn